]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/python/hgext/children.py
hgwebfs: simplify retry loop construction
[plan9front.git] / sys / lib / python / hgext / children.py
1 # Mercurial extension to provide the 'hg children' command
2 #
3 # Copyright 2007 by Intevation GmbH <intevation@intevation.de>
4 #
5 # Author(s):
6 # Thomas Arendsen Hein <thomas@intevation.de>
7 #
8 # This software may be used and distributed according to the terms of the
9 # GNU General Public License version 2, incorporated herein by reference.
10
11 '''command to display child changesets'''
12
13 from mercurial import cmdutil
14 from mercurial.commands import templateopts
15 from mercurial.i18n import _
16
17
18 def children(ui, repo, file_=None, **opts):
19     """show the children of the given or working directory revision
20
21     Print the children of the working directory's revisions. If a
22     revision is given via -r/--rev, the children of that revision will
23     be printed. If a file argument is given, revision in which the
24     file was last changed (after the working directory revision or the
25     argument to --rev if given) is printed.
26     """
27     rev = opts.get('rev')
28     if file_:
29         ctx = repo.filectx(file_, changeid=rev)
30     else:
31         ctx = repo[rev]
32
33     displayer = cmdutil.show_changeset(ui, repo, opts)
34     for cctx in ctx.children():
35         displayer.show(cctx)
36
37
38 cmdtable = {
39     "children":
40         (children,
41          [('r', 'rev', '', _('show children of the specified revision')),
42          ] + templateopts,
43          _('hg children [-r REV] [FILE]')),
44 }