comparison mercurial/scmutil.py @ 35185:66ecde8a704d

server: introduce a 'experimental.single-head-per-branch' option When the option is set, the repository will reject any transaction adding multiple heads to the same named branch. For now we reject all scenario with multiple heads. One could imagine handling closed branches differently. We prefer to keep things simple for now. The feature might get extended later. Branch closing is not the best experience Mercurial has to offer anyway.
author Boris Feld <boris.feld@octobus.net>
date Thu, 16 Nov 2017 03:52:42 +0100
parents bc775b8cc020
children 278f1feee73a
comparison
equal deleted inserted replaced
35184:bc775b8cc020 35185:66ecde8a704d
1284 if len(nodes) <= maxnumnodes or repo.ui.verbose: 1284 if len(nodes) <= maxnumnodes or repo.ui.verbose:
1285 return ' '.join(short(h) for h in nodes) 1285 return ' '.join(short(h) for h in nodes)
1286 first = ' '.join(short(h) for h in nodes[:maxnumnodes]) 1286 first = ' '.join(short(h) for h in nodes[:maxnumnodes])
1287 return _("%s and %s others") % (first, len(nodes) - maxnumnodes) 1287 return _("%s and %s others") % (first, len(nodes) - maxnumnodes)
1288 1288
1289 def enforcesinglehead(repo, tr, desc):
1290 """check that no named branch has multiple heads"""
1291 if desc in ('strip', 'repair'):
1292 # skip the logic during strip
1293 return
1294 visible = repo.filtered('visible')
1295 # possible improvement: we could restrict the check to affected branch
1296 for name, heads in visible.branchmap().iteritems():
1297 if len(heads) > 1:
1298 msg = _('rejecting multiple heads on branch "%s"')
1299 msg %= name
1300 hint = _('%d heads: %s')
1301 hint %= (len(heads), nodesummaries(repo, heads))
1302 raise error.Abort(msg, hint=hint)
1303
1289 def wrapconvertsink(sink): 1304 def wrapconvertsink(sink):
1290 """Allow extensions to wrap the sink returned by convcmd.convertsink() 1305 """Allow extensions to wrap the sink returned by convcmd.convertsink()
1291 before it is used, whether or not the convert extension was formally loaded. 1306 before it is used, whether or not the convert extension was formally loaded.
1292 """ 1307 """
1293 return sink 1308 return sink