# HG changeset patch # User Peter Arrenbrecht # Date 1305402247 -7200 # Node ID a3f727c41c1d1fca385956c13449d2d0ce46c980 # Parent 6beca5b97dc7779de01d028a1a8b43c9d3aba96e Fix breakage introduced by discovery refactoring diff --git a/hgsubversion/__init__.py b/hgsubversion/__init__.py --- a/hgsubversion/__init__.py +++ b/hgsubversion/__init__.py @@ -99,14 +99,21 @@ wrapcmds = { # cmd: generic, target, fix ]), } - -# only need the discovery variant of this code when we drop hg < 1.6 try: from mercurial import discovery + def findcommonoutgoing(orig, *args, **opts): + capable = getattr(args[1], 'capable', lambda x: False) + if capable('subversion'): + return wrappers.findcommonoutgoing(*args, **opts) + else: + return orig(*args, **opts) + extensions.wrapfunction(discovery, 'findcommonoutgoing', findcommonoutgoing) +except AttributeError: + # only need the discovery variant of this code when we drop hg < 1.6 def findoutgoing(orig, *args, **opts): capable = getattr(args[1], 'capable', lambda x: False) if capable('subversion'): - return wrappers.outgoing(*args, **opts) + return wrappers.findoutgoing(*args, **opts) else: return orig(*args, **opts) extensions.wrapfunction(discovery, 'findoutgoing', findoutgoing) diff --git a/hgsubversion/svnrepo.py b/hgsubversion/svnrepo.py --- a/hgsubversion/svnrepo.py +++ b/hgsubversion/svnrepo.py @@ -64,7 +64,7 @@ def generate_repo_class(ui, repo): @remotesvn def findoutgoing(self, remote, base=None, heads=None, force=False): - return wrappers.outgoing(repo, remote, heads, force) + return wrappers.findoutgoing(repo, remote, heads, force) def svnmeta(self, uuid=None, subdir=None): return svnmeta.SVNMeta(self, uuid, subdir) diff --git a/hgsubversion/util.py b/hgsubversion/util.py --- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -149,6 +149,24 @@ def outgoing_revisions(repo, reverse_map if sourcerev.node() != node.nullid: return outgoing_rev_hashes +def outgoing_common_and_heads(repo, reverse_map, sourcerev): + """Given a repo and an hg_editor, determines outgoing revisions for the + current working copy state. Returns a tuple (common, heads) like + discovery.findcommonoutgoing does. + """ + if sourcerev in reverse_map: + return ([sourcerev], [sourcerev]) # nothing outgoing + sourcecx = repo[sourcerev] + while (not sourcecx.node() in reverse_map + and sourcecx.node() != node.nullid): + ps = sourcecx.parents() + if len(ps) != 1: + raise hgutil.Abort("Sorry, can't find svn parent of a merge revision.") + sourcecx = ps[0] + if sourcecx.node() != node.nullid: + return ([sourcecx.node()], [sourcerev]) + return ([sourcerev], [sourcerev]) # nothing outgoing + def default_commit_msg(ui): return ui.config('hgsubversion', 'defaultmessage', '') diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -82,13 +82,22 @@ def incoming(orig, ui, repo, origsource= ui.status('%s%s\n' % (l1.ljust(13), val)) -def outgoing(repo, dest=None, heads=None, force=False): +def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): + assert other.capable('subversion') + # split off #rev; TODO implement --revision/#rev support + svn = other.svn + meta = repo.svnmeta(svn.uuid, svn.subdir) + parent = repo.parents()[0].node() + hashes = meta.revmap.hashes() + return util.outgoing_common_and_heads(repo, hashes, parent) + + +def findoutgoing(repo, dest=None, heads=None, force=False): """show changesets not found in the Subversion repository """ assert dest.capable('subversion') - # split off #rev; TODO implement --revision/#rev support - svnurl, revs, checkout = util.parseurl(dest.svnurl, heads) + #svnurl, revs, checkout = util.parseurl(dest.svnurl, heads) svn = dest.svn meta = repo.svnmeta(svn.uuid, svn.subdir) parent = repo.parents()[0].node()