comparison hgext/children.py @ 4780:8b90d763ea90

Add extension to provide the 'hg children' command (with tests)
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 03 Jul 2007 12:14:25 +0200
parents
children be78ab217109
comparison
equal deleted inserted replaced
4779:37e11c768db9 4780:8b90d763ea90
1 # Mercurial extension to provide the 'hg children' command
2 #
3 # Copyright 2007 by Intevation GmbH <intevation@intevation.de>
4 # Author(s):
5 # Thomas Arendsen Hein <thomas@intevation.de>
6 #
7 # This software may be used and distributed according to the terms
8 # of the GNU General Public License, incorporated herein by reference.
9
10 from mercurial import cmdutil, util
11 from mercurial.i18n import _
12 from mercurial.node import nullid
13
14
15 def children(ui, repo, file_=None, **opts):
16 """show the children of the given or working dir revision
17
18 Print the children of the working directory's revisions.
19 If a revision is given via --rev, the children of that revision
20 will be printed. If a file argument is given, revision in
21 which the file was last changed (after the working directory
22 revision or the argument to --rev if given) is printed.
23 """
24 rev = opts.get('rev')
25 if file_:
26 ctx = repo.filectx(file_, changeid=rev)
27 else:
28 ctx = repo.changectx(rev)
29 if ctx.node() == nullid:
30 raise util.Abort(_("All non-merge changesets are children of "
31 "the null revision!"))
32
33 displayer = cmdutil.show_changeset(ui, repo, opts)
34 for node in [cp.node() for cp in ctx.children()]:
35 displayer.show(changenode=node)
36
37
38 cmdtable = {
39 "children":
40 (children,
41 [('r', 'rev', '', _('show children of the specified rev')),
42 ('', 'style', '', _('display using template map file')),
43 ('', 'template', '', _('display with template'))],
44 _('hg children [-r REV] [FILE]')),
45 }