[PATCH 3 of 3 rfc] discovery: allow pushing multiple heads if only one is non-closing (BC)

Mads Kiilerich mads at kiilerich.com
Sun Oct 25 11:19:52 CDT 2015


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1445789751 -3600
#      Sun Oct 25 17:15:51 2015 +0100
# Branch stable
# Node ID 97d29fbe8b3a671969f155f41144e8495d9e1bfb
# Parent  bf26cd851f4bb0a68c6f0e7472246e99ef236ea3
discovery: allow pushing multiple heads if only one is non-closing (BC)

Closing a branch by commit --close indicates that the branch head doesn't count
... but you still want to push it to a central server and share the close-ness
with other users, especially when another non-closed head is pushed.

Instead, when checking the list of outgoing branch heads, filter out the closed
heads if there are closed heads. That makes it possible to push multiple branch
heads if there only is one that not is closed.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -295,7 +295,12 @@ def checkheads(repo, remote, outgoing, r
         allfuturecommon.update(allmissing)
     for branch, heads in sorted(headssum.iteritems()):
         remoteheads, newheads, unsyncedheads = heads
-        candidate_newhs = set(newheads)
+        openheads = [h for h in newheads if not repo.changelog.branchinfo(h)[1]]
+        if openheads:
+            # only report open heads - except if all heads are closed
+            candidate_newhs = set(openheads)
+        else:
+            candidate_newhs = set(newheads)
         # add unsynced data
         if remoteheads is None:
             oldhs = set()
diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -864,8 +864,9 @@ Test pushing of close of old branch head
   $ hg push -b. target
   pushing to target
   searching for changes
-  abort: push creates new remote heads 3253c285062f 3ea0cbd2709a on branch 'A'!
-  (merge or see "hg help push" for details about pushing new heads)
-  [255]
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 1 changes to 1 files
 
   $ cd ..


More information about the Mercurial-devel mailing list