Mercurial > hg > hg-git
changeset 523:8c1f2b07c04b
outgoing: re-introduce support for outgoing
author | David M. Carr <david@carrclan.us> |
---|---|
date | Thu, 13 Sep 2012 18:47:11 -0400 (2012-09-13) |
parents | ff05308e460c |
children | c7a19f74dc8c |
files | hggit/__init__.py hggit/git_handler.py hggit/help/git.rst tests/test-outgoing |
diffstat | 4 files changed, 24 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -24,6 +24,7 @@ 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 @@ -142,25 +143,24 @@ 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):
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -1,7 +1,7 @@ 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 @@ -226,7 +226,10 @@ 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)]
--- a/hggit/help/git.rst +++ b/hggit/help/git.rst @@ -78,5 +78,3 @@ - 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. \ No newline at end of file
--- a/tests/test-outgoing +++ b/tests/test-outgoing @@ -1,15 +1,5 @@ #!/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