Mercurial > hg-stable
changeset 18688:79107fad06aa
commit: factor out status printing into a helper function
We create a new function commitstatus() in cmdutil that handles printing
the status message(s) after a commit. This will allow other commit-like
commands to use it, and in particular is step 2 towards removing
backout's call to commands.commit.
author | Kevin Bullock <kbullock@ringworld.org> |
---|---|
date | Tue, 12 Feb 2013 16:32:14 +0000 |
parents | 1d183b33f007 |
children | 12721a20ed30 |
files | mercurial/cmdutil.py mercurial/commands.py |
diffstat | 2 files changed, 47 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Tue Feb 12 16:05:00 2013 +0000 +++ b/mercurial/cmdutil.py Tue Feb 12 16:32:14 2013 +0000 @@ -1821,6 +1821,52 @@ return text +def commitstatus(repo, node, branch, bheads=None, opts={}): + ctx = repo[node] + parents = ctx.parents() + + if (not opts.get('amend') and bheads and node not in bheads and not + [x for x in parents if x.node() in bheads and x.branch() == branch]): + repo.ui.status(_('created new head\n')) + # The message is not printed for initial roots. For the other + # changesets, it is printed in the following situations: + # + # Par column: for the 2 parents with ... + # N: null or no parent + # B: parent is on another named branch + # C: parent is a regular non head changeset + # H: parent was a branch head of the current branch + # Msg column: whether we print "created new head" message + # In the following, it is assumed that there already exists some + # initial branch heads of the current branch, otherwise nothing is + # printed anyway. + # + # Par Msg Comment + # N N y additional topo root + # + # B N y additional branch root + # C N y additional topo head + # H N n usual case + # + # B B y weird additional branch root + # C B y branch merge + # H B n merge with named branch + # + # C C y additional head from merge + # C H n merge with a head + # + # H H n head merge: head count decreases + + if not opts.get('close_branch'): + for r in parents: + if r.closesbranch() and r.branch() == branch: + repo.ui.status(_('reopening closed branch head %d\n') % r) + + if repo.ui.debugflag: + repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) + elif repo.ui.verbose: + repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) + def revert(ui, repo, ctx, parents, *pats, **opts): parent, p2 = parents node = ctx.node()
--- a/mercurial/commands.py Tue Feb 12 16:05:00 2013 +0000 +++ b/mercurial/commands.py Tue Feb 12 16:32:14 2013 +0000 @@ -1356,50 +1356,7 @@ ui.status(_("nothing changed\n")) return 1 - ctx = repo[node] - parents = ctx.parents() - - if (not opts.get('amend') and bheads and node not in bheads and not - [x for x in parents if x.node() in bheads and x.branch() == branch]): - ui.status(_('created new head\n')) - # The message is not printed for initial roots. For the other - # changesets, it is printed in the following situations: - # - # Par column: for the 2 parents with ... - # N: null or no parent - # B: parent is on another named branch - # C: parent is a regular non head changeset - # H: parent was a branch head of the current branch - # Msg column: whether we print "created new head" message - # In the following, it is assumed that there already exists some - # initial branch heads of the current branch, otherwise nothing is - # printed anyway. - # - # Par Msg Comment - # N N y additional topo root - # - # B N y additional branch root - # C N y additional topo head - # H N n usual case - # - # B B y weird additional branch root - # C B y branch merge - # H B n merge with named branch - # - # C C y additional head from merge - # C H n merge with a head - # - # H H n head merge: head count decreases - - if not opts.get('close_branch'): - for r in parents: - if r.closesbranch() and r.branch() == branch: - ui.status(_('reopening closed branch head %d\n') % r) - - if ui.debugflag: - ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) - elif ui.verbose: - ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) + cmdutil.commitstatus(repo, node, branch, bheads, opts) @command('copy|cp', [('A', 'after', None, _('record a copy that has already occurred')),