changeset 805:a3f727c41c1d

Fix breakage introduced by discovery refactoring
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Sat, 14 May 2011 21:44:07 +0200
parents 6beca5b97dc7
children ec074ebaa80f
files hgsubversion/__init__.py hgsubversion/svnrepo.py hgsubversion/util.py hgsubversion/wrappers.py
diffstat 4 files changed, 41 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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)
--- 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', '')
 
--- 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()