# HG changeset patch # User Alexis S. L. Carvalho # Date 1206317004 10800 # Node ID 53912d30ac402b5f412bfcae56a7e3bc98b2bbd1 # Parent 2c370f08c4869c194f1358008f5ee908fec2b6a7 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). diff -r 2c370f08c486 -r 53912d30ac40 mercurial/commands.py --- a/mercurial/commands.py Sun Mar 23 23:08:18 2008 +0100 +++ b/mercurial/commands.py Sun Mar 23 21:03:24 2008 -0300 @@ -548,9 +548,18 @@ return repo.commit(files, message, opts['user'], opts['date'], match, force_editor=opts.get('force_editor')) - heads = repo.changelog.heads() - cmdutil.commit(ui, repo, commitfunc, pats, opts) - if len(repo.changelog.heads()) > len(heads): + node = cmdutil.commit(ui, repo, commitfunc, pats, opts) + if not node: + return + cl = repo.changelog + rev = cl.rev(node) + parents = cl.parentrevs(rev) + if rev - 1 in parents: + # one of the parents was the old tip + return + if (parents == (nullrev, nullrev) or + len(cl.heads(cl.node(parents[0]))) > 1 and + (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)): ui.status(_('created new head\n')) def copy(ui, repo, *pats, **opts):