Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 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 | 76b69cccb07a |
children | 49ef9d0ca815 |
comparison
equal
deleted
inserted
replaced
18687:1d183b33f007 | 18688:79107fad06aa |
---|---|
1818 | 1818 |
1819 if not text.strip(): | 1819 if not text.strip(): |
1820 raise util.Abort(_("empty commit message")) | 1820 raise util.Abort(_("empty commit message")) |
1821 | 1821 |
1822 return text | 1822 return text |
1823 | |
1824 def commitstatus(repo, node, branch, bheads=None, opts={}): | |
1825 ctx = repo[node] | |
1826 parents = ctx.parents() | |
1827 | |
1828 if (not opts.get('amend') and bheads and node not in bheads and not | |
1829 [x for x in parents if x.node() in bheads and x.branch() == branch]): | |
1830 repo.ui.status(_('created new head\n')) | |
1831 # The message is not printed for initial roots. For the other | |
1832 # changesets, it is printed in the following situations: | |
1833 # | |
1834 # Par column: for the 2 parents with ... | |
1835 # N: null or no parent | |
1836 # B: parent is on another named branch | |
1837 # C: parent is a regular non head changeset | |
1838 # H: parent was a branch head of the current branch | |
1839 # Msg column: whether we print "created new head" message | |
1840 # In the following, it is assumed that there already exists some | |
1841 # initial branch heads of the current branch, otherwise nothing is | |
1842 # printed anyway. | |
1843 # | |
1844 # Par Msg Comment | |
1845 # N N y additional topo root | |
1846 # | |
1847 # B N y additional branch root | |
1848 # C N y additional topo head | |
1849 # H N n usual case | |
1850 # | |
1851 # B B y weird additional branch root | |
1852 # C B y branch merge | |
1853 # H B n merge with named branch | |
1854 # | |
1855 # C C y additional head from merge | |
1856 # C H n merge with a head | |
1857 # | |
1858 # H H n head merge: head count decreases | |
1859 | |
1860 if not opts.get('close_branch'): | |
1861 for r in parents: | |
1862 if r.closesbranch() and r.branch() == branch: | |
1863 repo.ui.status(_('reopening closed branch head %d\n') % r) | |
1864 | |
1865 if repo.ui.debugflag: | |
1866 repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) | |
1867 elif repo.ui.verbose: | |
1868 repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) | |
1823 | 1869 |
1824 def revert(ui, repo, ctx, parents, *pats, **opts): | 1870 def revert(ui, repo, ctx, parents, *pats, **opts): |
1825 parent, p2 = parents | 1871 parent, p2 = parents |
1826 node = ctx.node() | 1872 node = ctx.node() |
1827 | 1873 |