comparison mercurial/commands.py @ 6369:53912d30ac40

Avoid calling heads() twice on every hg commit. In an extreme case (merging two revisions with very low revision numbers) this could be slower than the previous code, but it should be much faster in the usual cases (parents are near the tip). It also avoids some races in some uninteresting cases (e.g. two concurrent hg commits).
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 23 Mar 2008 21:03:24 -0300
parents 51984a2413f2
children cdc458b12f0f
comparison
equal deleted inserted replaced
6368:2c370f08c486 6369:53912d30ac40
546 """ 546 """
547 def commitfunc(ui, repo, files, message, match, opts): 547 def commitfunc(ui, repo, files, message, match, opts):
548 return repo.commit(files, message, opts['user'], opts['date'], match, 548 return repo.commit(files, message, opts['user'], opts['date'], match,
549 force_editor=opts.get('force_editor')) 549 force_editor=opts.get('force_editor'))
550 550
551 heads = repo.changelog.heads() 551 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
552 cmdutil.commit(ui, repo, commitfunc, pats, opts) 552 if not node:
553 if len(repo.changelog.heads()) > len(heads): 553 return
554 cl = repo.changelog
555 rev = cl.rev(node)
556 parents = cl.parentrevs(rev)
557 if rev - 1 in parents:
558 # one of the parents was the old tip
559 return
560 if (parents == (nullrev, nullrev) or
561 len(cl.heads(cl.node(parents[0]))) > 1 and
562 (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)):
554 ui.status(_('created new head\n')) 563 ui.status(_('created new head\n'))
555 564
556 def copy(ui, repo, *pats, **opts): 565 def copy(ui, repo, *pats, **opts):
557 """mark files as copied for the next commit 566 """mark files as copied for the next commit
558 567