[PATCH cleanup] discovery: put trivial branch first

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Oct 12 16:10:25 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1444635924 25200
#      Mon Oct 12 00:45:24 2015 -0700
# Node ID 306bf601d8cfd056a26ec15c423606ece40b6793
# Parent  9ca13d10881d7044b79d903ad64653f6541591f1
# EXP-Topic disc.cleanup
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 306bf601d8cf
discovery: put trivial branch first

Having the simple and tiny branch of the conditional first help readability. The
"else" that appears after a screen of code is harder to relate to a conditional.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -303,11 +303,13 @@ def checkheads(repo, remote, outgoing, r
             oldhs = set(remoteheads)
         oldhs.update(unsyncedheads)
         candidate_newhs.update(unsyncedheads)
         dhs = None # delta heads, the new heads on branch
         discardedheads = set()
-        if repo.obsstore:
+        if not repo.obsstore:
+            newhs = candidate_newhs
+        else:
             # remove future heads which are actually obsoleted by another
             # pushed element:
             #
             # XXX as above, There are several cases this code does not handle
             # XXX properly
@@ -332,12 +334,10 @@ def checkheads(repo, remote, outgoing, r
                         if suc != nh and suc in allfuturecommon:
                             discardedheads.add(nh)
                             break
                     else:
                         newhs.add(nh)
-        else:
-            newhs = candidate_newhs
         unsynced = sorted(h for h in unsyncedheads if h not in discardedheads)
         if unsynced:
             if None in unsynced:
                 # old remote, no heads data
                 heads = None


More information about the Mercurial-devel mailing list