bugfix: allow diffing/log from common ancestor to work in either direction

This commit is contained in:
Josh Holtrop 2012-06-27 13:53:34 -04:00
parent d425d7ae14
commit 07080d34a7

16
jsvn
View File

@ -381,9 +381,15 @@ def find_branched_revision(svn, branch_url, branch_path, base_path):
new_path, old_path, rev = m.group(1, 2, 3)
if new_path == search_path:
if old_path == base_path:
return int(rev)
return (int(rev), old_path)
search_path = old_path
return -1
return (-1, '')
def find_common_ancestor(svn, url1, path1, url2, path2):
r, path = find_branched_revision(svn, url1, path1, path2)
if r < 0:
r, path = find_branched_revision(svn, url2, path2, path1)
return r, path
###########################################################################
# Subcommand Handlers #
@ -768,12 +774,12 @@ def diff(argv, svn, out):
if operator == '...':
# amend url1 to include the pegged revision from where ref2
# originally branched from it
r = find_branched_revision(svn, url2, path2, path1)
r, path = find_common_ancestor(svn, url2, path2, url1, path1)
if r < 0:
sys.stderr.write(('Could not find revision where "%s" ' +
'branched from "%s"\n') % (ref2, ref1))
return RET_ERR
url1 += '@%d' % r
url = get_svn_repo_real_root_url(svn) + path + '@%d' % r
argv = argv[:i] + [url1, url2] + argv[i + 1:]
break
pout = Popen([svn] + argv, stdout=PIPE).stdout
@ -795,7 +801,7 @@ def log(argv, svn, out):
url2, path2 = resolve_reference(svn, ref2)
if url2 == '':
continue
r = find_branched_revision(svn, url2, path2, path1)
r, path = find_common_ancestor(svn, url2, path2, url1, path1)
if r < 0:
sys.stderr.write(('Could not find revision where "%s" ' +
'branched from "%s"\n') % (ref2, ref1))