Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved diff and properties #99

Closed
wants to merge 12 commits into from
Closed

Conversation

apocryphal
Copy link

  1. Improves unit testing on Windows by ensuring canonical file uri.
  2. Improves diff behavior, enabling direct diffing of a single file.
  3. Fixes a bug in diff, where == (equality operator) was used as a separator, which would lead to incomplete diff results.
  4. Fixes properties method failed when no props defined #89

@coveralls
Copy link

coveralls commented Sep 15, 2017

Coverage Status

Coverage increased (+5.4%) to 76.944% when pulling 74cc910 on apocryphal:master into 87066d1 on dsoprea:master.

if target_elem is not None:
property_names = [p.attrib["name"]
for p in target_elem.findall('property')]
else:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is this the case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any time there are no properties associated, the "target" element it's searching for won't be found.
Examples:

http://svn.apache.org/repos/asf/activemq/activecluster/trunk/src/main/java/org/apache/activecluster@1808406
<?xml version="1.0" encoding="UTF-8"?>
<properties>
</properties>

http://svn.apache.org/repos/asf/activemq/activecluster/trunk/src/main/java/org/apache/activecluster/Cluster.java@1808406
<?xml version="1.0" encoding="UTF-8"?>
<properties>
  <target path="http://svn.apache.org/repos/asf/activemq/activecluster/trunk/src/main/java/org/apache/activecluster/Cluster.java">
    <property name="svn:eol-style"/>
  </target>
</properties>

Copy link
Owner

@dsoprea dsoprea Sep 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I got it. Thanks for clarifying. You're absolutely sure that you can't have more than one target? Seems like you could.

svn/common.py Outdated
@@ -450,12 +453,18 @@ def diff(self, old, new, rel_path=None):
do_combine=True)
file_to_diff = {}
for non_empty_diff in filter(None, diff_result.decode('utf8').split('Index: ')):
split_diff = non_empty_diff.split('==')
split_diff = \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation would split the overall diff text any time it finds a ==, including in places like if (a == b). Without an equivalent change, the diff text will be partially lost.

I can think of prettier ways to do it, say something like '='*67 instead of having a big long list.

I provided the unit test test_diff_separator for this one, which checks for code above and below a double-equals in a known file. It passes with the new implementation, but fails with the old one.

file_to_diff[split_diff[0].strip().strip('/')] = split_diff[-1].strip('=').strip()
diff_summaries = self.diff_summary(old, new, rel_path)
for diff_summary in diff_summaries:
diff_summary['diff'] = \
file_to_diff[diff_summary['path'].split(full_url_or_path)[-1].strip('/')]
diff_summary['diff'] = ''
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section could use some commentary. Also, can you also refactor the split() to use startswith() or searching instead? I realize you weren't responsible for this, but the way it is is far from intuitive. Though I can surmise what we're doing here, it's not obvious when the if's will or will not trigger.

@@ -32,7 +32,10 @@ def test_create_repository(self):
a.create(temp_path)

# Do a read.
rc = svn.remote.RemoteClient('file://' + temp_path)
if temp_path[0] == '/':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you place a comment indicating that this is the duck-typing approach to detecting Windows versus non-Windows?

@@ -54,7 +54,10 @@ def __setup_test_environment(self):
self.__temp_co_path = self.__get_temp_path_to_use()
print("CO_PATH: {}".format(self.__temp_co_path))

r = svn.remote.RemoteClient('file://' + self.__temp_repo_path)
if self.__temp_repo_path[0] == '/':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment.

@coveralls
Copy link

coveralls commented Sep 17, 2017

Coverage Status

Coverage increased (+5.4%) to 77.008% when pulling c3e5494 on apocryphal:master into 87066d1 on dsoprea:master.

@dsoprea
Copy link
Owner

dsoprea commented Feb 1, 2020

This will have just been broken by a reimplementation of diff that I did.

@dsoprea
Copy link
Owner

dsoprea commented Apr 23, 2023

Closed since stale.

@dsoprea dsoprea closed this Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

properties method failed when no props defined
3 participants