diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2013-05-25 04:29:51 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-28 17:02:05 +0200 |
commit | 883d7be110968c0d319dfa7c595c640e616da9c5 (patch) | |
tree | 7c2cf14b55cfe465243f3c273708475af9d87063 /contrib/remote-helpers/git-remote-hg | |
parent | remote-hg: implement custom checkheads() (diff) | |
download | git-883d7be110968c0d319dfa7c595c640e616da9c5.tar.xz git-883d7be110968c0d319dfa7c595c640e616da9c5.zip |
remote-hg: pass around revision refs
So that when a diverge is detected, we know which ref to report an error
for.
Also, since we are not throwing an exception, return a proper error
code.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/remote-helpers/git-remote-hg')
-rwxr-xr-x | contrib/remote-helpers/git-remote-hg | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index 7eb809b2ce..b6f85b2712 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -857,18 +857,19 @@ def write_tag(repo, tag, node, msg, author): encoding.encoding = tmp - return tagnode + return (tagnode, branch) def checkheads(repo, remote, p_revs): remotemap = remote.branchmap() if not remotemap: # empty repo - return + return True new = {} + ret = True - for node in p_revs: + for node, ref in p_revs.iteritems(): ctx = repo[node] branch = ctx.branch() if not branch in remotemap: @@ -893,7 +894,11 @@ def checkheads(repo, remote, p_revs): if found: continue - raise Exception("non-fast-forward") + node = repo.changelog.node(rev) + print "error %s non-fast forward" % p_revs[node] + ret = False + + return ret def push_unsafe(repo, remote, parsed_refs, p_revs): @@ -903,8 +908,8 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): commoninc = fci(repo, remote, force=force) common, _, remoteheads = commoninc - if not force: - checkheads(repo, remote, p_revs) + if not force and not checkheads(repo, remote, p_revs): + return None cg = repo.getbundle('push', heads=list(p_revs), common=common) @@ -940,7 +945,7 @@ def do_export(parser): global parsed_refs, bmarks, peer p_bmarks = [] - p_revs = set() + p_revs = {} parser.next() @@ -965,7 +970,7 @@ def do_export(parser): if branch in branches and bnode in branches[branch]: # up to date continue - p_revs.add(bnode) + p_revs[bnode] = ref print "ok %s" % ref elif ref.startswith('refs/heads/'): bmark = ref[len('refs/heads/'):] @@ -980,7 +985,7 @@ def do_export(parser): not (bmark == 'master' and bmark not in parser.repo._bookmarks): p_bmarks.append((ref, bmark, old, new)) - p_revs.add(bnode) + p_revs[bnode] = ref elif ref.startswith('refs/tags/'): tag = ref[len('refs/tags/'):] tag = hgref(tag) @@ -988,20 +993,23 @@ def do_export(parser): if mode == 'git': if not msg: msg = 'Added tag %s for changeset %s' % (tag, node[:12]); - tagnode = write_tag(parser.repo, tag, node, msg, author) - p_revs.add(tagnode) + tagnode, branch = write_tag(parser.repo, tag, node, msg, author) + p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch) else: fp = parser.repo.opener('localtags', 'a') fp.write('%s %s\n' % (node, tag)) fp.close() - p_revs.add(bnode) + p_revs[bnode] = ref print "ok %s" % ref else: # transport-helper/fast-export bugs continue if peer: - push(parser.repo, peer, parsed_refs, p_revs) + if not push(parser.repo, peer, parsed_refs, p_revs): + # do not update bookmarks + print + return # update remote bookmarks remote_bmarks = peer.listkeys('bookmarks') |