diff mercurial/scmutil.py @ 42969:76608f9f27f6

singlehead: introduce special handling of closed heads Until now, the experimental option `single-head-per-branch` was also refusing closed heads. The logic is now ignoring them by default and a suboption have been added to refuse them too `single-head-per-branch:account-closed-heads`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 25 Sep 2019 12:59:26 +0200
parents 34ed651ba7e4
children 2372284d9457
line wrap: on
line diff
--- a/mercurial/scmutil.py	Wed Sep 25 12:57:11 2019 +0200
+++ b/mercurial/scmutil.py	Wed Sep 25 12:59:26 2019 +0200
@@ -1895,14 +1895,16 @@
     first = ' '.join(short(h) for h in nodes[:maxnumnodes])
     return _("%s and %d others") % (first, len(nodes) - maxnumnodes)
 
-def enforcesinglehead(repo, tr, desc):
+def enforcesinglehead(repo, tr, desc, accountclosed=False):
     """check that no named branch has multiple heads"""
     if desc in ('strip', 'repair'):
         # skip the logic during strip
         return
     visible = repo.filtered('visible')
     # possible improvement: we could restrict the check to affected branch
-    for name, heads in visible.branchmap().iteritems():
+    bm = visible.branchmap()
+    for name in bm:
+        heads = bm.branchheads(name, closed=accountclosed)
         if len(heads) > 1:
             msg = _('rejecting multiple heads on branch "%s"')
             msg %= name