From fa3484e08b0f3f3ed15893531632fb86e3858e19 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sat, 9 Jul 2016 09:31:37 +0200 Subject: [PATCH] Find outgoing changesets earlier This way we can find if we actually need to push something. Recent versions of Mercurial already handle this correctly, but let's check ourselves to make sure, and make it work with all versions. Rewritten-by: Felipe Contreras Signed-off-by: Felipe Contreras --- git-remote-hg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 023bbb4..7e70e40 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -1083,13 +1083,17 @@ def push_unsafe(repo, remote, parsed_refs, p_revs): fci = discovery.findcommonincoming commoninc = fci(repo, remote, force=force) common, _, remoteheads = commoninc + fco = discovery.findcommonoutgoing + outgoing = fco(repo, remote, onlyheads=list(p_revs), commoninc=commoninc, force=force) if not checkheads(repo, remote, p_revs): - return None + return False + + if not outgoing.missing: + # Nothing to push + return True if check_version(4, 0): - from mercurial import exchange - outgoing = exchange._computeoutgoing(repo, list(p_revs), common) if check_version(4, 4): cg = changegroup.makechangegroup(repo, outgoing, '01', 'push') else: