[PATCH] changegroup: do not prompt to merge after adding only closed heads (issue2697)

Kevin Gessner kevin at fogcreek.com
Thu Apr 14 13:31:58 CDT 2011


# HG changeset patch
# User Kevin Gessner <kevin at fogcreek.com>
# Date 1302729493 14400
# Node ID 9afc365d6c2a351d01d6ae18021fc67c45ceb139
# Parent  3d83c7d70a98a1fd4ff1ad4f840c8ce82100bfdb
changegroup: do not prompt to merge after adding only closed heads (issue2697)

When adding a changegroup adds closed heads, note them in the "(+n heads)"
alert. Don't count them in the total number of heads for the note to merge
or update.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1691,6 +1691,8 @@
         cl = self.changelog
         cl.delayupdate()
         oldheads = len(cl.heads())
+        oldclosedheads = len([h for h in cl.heads()
+                              if 'close' in self[h].extra()])
 
         tr = self.transaction("\n".join([srctype, urlmod.hidepassword(url)]))
         try:
@@ -1782,9 +1784,18 @@
                             (f, hex(n)))
 
             newheads = len(cl.heads())
+            newclosedheads = len([h for h in cl.heads()
+                                  if 'close' in self[h].extra()])
+            closingheads = max(0, newclosedheads - oldclosedheads)
             heads = ""
             if oldheads and newheads != oldheads:
-                heads = _(" (%+d heads)") % (newheads - oldheads)
+                closedheads = ""
+                if closingheads:
+                    closedheads = _(", %d closed") % closingheads
+                heads = _(" (%+d heads%s)") % ((newheads - oldheads),
+                                               closedheads)
+            oldheads -= oldclosedheads
+            newheads -= newclosedheads
 
             self.ui.status(_("added %d changesets"
                              " with %d changes to %d files%s\n")


More information about the Mercurial-devel mailing list