comparison 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
comparison
equal deleted inserted replaced
42968:86f39a89b63e 42969:76608f9f27f6
1893 if len(nodes) <= maxnumnodes or repo.ui.verbose: 1893 if len(nodes) <= maxnumnodes or repo.ui.verbose:
1894 return ' '.join(short(h) for h in nodes) 1894 return ' '.join(short(h) for h in nodes)
1895 first = ' '.join(short(h) for h in nodes[:maxnumnodes]) 1895 first = ' '.join(short(h) for h in nodes[:maxnumnodes])
1896 return _("%s and %d others") % (first, len(nodes) - maxnumnodes) 1896 return _("%s and %d others") % (first, len(nodes) - maxnumnodes)
1897 1897
1898 def enforcesinglehead(repo, tr, desc): 1898 def enforcesinglehead(repo, tr, desc, accountclosed=False):
1899 """check that no named branch has multiple heads""" 1899 """check that no named branch has multiple heads"""
1900 if desc in ('strip', 'repair'): 1900 if desc in ('strip', 'repair'):
1901 # skip the logic during strip 1901 # skip the logic during strip
1902 return 1902 return
1903 visible = repo.filtered('visible') 1903 visible = repo.filtered('visible')
1904 # possible improvement: we could restrict the check to affected branch 1904 # possible improvement: we could restrict the check to affected branch
1905 for name, heads in visible.branchmap().iteritems(): 1905 bm = visible.branchmap()
1906 for name in bm:
1907 heads = bm.branchheads(name, closed=accountclosed)
1906 if len(heads) > 1: 1908 if len(heads) > 1:
1907 msg = _('rejecting multiple heads on branch "%s"') 1909 msg = _('rejecting multiple heads on branch "%s"')
1908 msg %= name 1910 msg %= name
1909 hint = _('%d heads: %s') 1911 hint = _('%d heads: %s')
1910 hint %= (len(heads), nodesummaries(repo, heads)) 1912 hint %= (len(heads), nodesummaries(repo, heads))