Commits

David Carr  committed 8c1f2b0

outgoing: re-introduce support for outgoing

  • Participants
  • Parent commits ff05308

Comments (0)

Files changed (4)

File hggit/__init__.py

 from mercurial import bundlerepo
 from mercurial import commands
 from mercurial import demandimport
+from mercurial import discovery
 from mercurial import extensions
 from mercurial import help
 from mercurial import hg
     return ret
 extensions.wrapfunction(localrepo.localrepository, 'nodetags', sortednodetags)
 
-try:
-    from mercurial import discovery
-    kwname = 'heads'
-    if hg.util.version() >= '1.7':
-        kwname = 'remoteheads'
-    if getattr(discovery, 'findcommonoutgoing', None):
-        kwname = 'onlyheads'
-    def findoutgoing(orig, local, remote, *args, **kwargs):
-        if isinstance(remote, gitrepo.gitrepo):
-            raise hgutil.Abort(
-                'hg-git outgoing support is broken')
-        return orig(local, remote, *args, **kwargs)
-    if getattr(discovery, 'findoutgoing', None):
-        extensions.wrapfunction(discovery, 'findoutgoing', findoutgoing)
-    else:
-        extensions.wrapfunction(discovery, 'findcommonoutgoing',
-                                findoutgoing)
-except ImportError:
-    pass
+def findcommonoutgoing(orig, repo, other, *args, **kwargs):
+    if isinstance(other, gitrepo.gitrepo):
+        git = GitHandler(repo, repo.ui)
+        heads = git.get_refs(other.path)[0]
+        kw = {}
+        kw.update(kwargs)
+        for val, k in zip(args,
+                ('onlyheads', 'force', 'commoninc', 'portable')):
+            kw[k] = val
+        force = kw.get('force', False)
+        commoninc = kw.get('commoninc', None)
+        if commoninc is None:
+            commoninc = discovery.findcommonincoming(repo, other,
+                heads=heads, force=force)
+            kw['commoninc'] = commoninc
+        return orig(repo, other, **kw)
+    return orig(repo, other, *args, **kwargs)
+extensions.wrapfunction(discovery, 'findcommonoutgoing', findcommonoutgoing)
 
 def getremotechanges(orig, ui, repo, other, *args, **opts):
     if isinstance(other, gitrepo.gitrepo):

File hggit/git_handler.py

 import os, math, urllib, re
 import stat, posixpath, StringIO
 
-from dulwich.errors import HangupException, GitProtocolError
+from dulwich.errors import HangupException, GitProtocolError, UpdateRefsError
 from dulwich.index import commit_tree
 from dulwich.objects import Blob, Commit, Tag, Tree, parse_timezone, S_IFGITLINK
 from dulwich.pack import create_delta, apply_delta
             return {}
 
         try:
-            client.send_pack(path, changed, lambda have, want: [])
+            try:
+                client.send_pack(path, changed, lambda have, want: [])
+            except UpdateRefsError:
+                pass # dulwich throws an error when send_pack doesn't upload
 
             changed_refs = [ref for ref, sha in new_refs.iteritems()
                             if sha != old_refs.get(ref)]

File hggit/help/git.rst

 
 - Cloning/pushing/pulling local Git repositories is not supported (due to
   lack of support in Dulwich)
-- The `hg incoming` and `hg outgoing` commands are not currently
-  supported.

File tests/test-outgoing

 #!/bin/sh
 
-# This feature is currently completely broken due to changes in
-# dulwich, but since it was already broken on hg 1.9 and later, it's
-# not a blocker.
-exit 80
-
-# Fails for some reason, need to investigate
-# "$TESTDIR/hghave" git || exit 80
-python -c 'from mercurial import util ; assert \
- util.version() == "unknown" or util.version() < "1.8"' || exit 80
-
 # bail if the user does not have dulwich
 python -c 'import dulwich, dulwich.repo' || exit 80