Debian Codegraph @

hgext/children.py

raw
1 # Mercurial extension to provide the 'hg children' command
2 #
3 # Copyright 2007 by Intevation GmbH <[email protected]>
4 #
5 # Author(s):
6 # Thomas Arendsen Hein <[email protected]>
7 #
8 # This software may be used and distributed according to the terms of the
9 # GNU General Public License version 2 or any later version.
10
11 '''command to display child changesets (DEPRECATED)
12
13 This extension is deprecated. You should use :hg:`log -r
14 "children(REV)"` instead.
15 '''
16
17 from __future__ import annotations
18
19 from mercurial.i18n import _
20 from mercurial import (
21 cmdutil,
22 logcmdutil,
23 pycompat,
24 registrar,
25 )
26
27 templateopts = cmdutil.templateopts
28
29 cmdtable = {}
30 command = registrar.command(cmdtable)
31 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
32 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
33 # be specifying the version(s) of Mercurial they are tested with, or
34 # leave the attribute unspecified.
35 testedwith = b'ships-with-hg-core'
36
37
38 @command(
39 b'children',
40 [
41 (
42 b'r',
43 b'rev',
44 b'.',
45 _(b'show children of the specified revision'),
46 _(b'REV'),
47 ),
48 ]
49 + templateopts,
50 _(b'hg children [-r REV] [FILE]'),
51 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
52 inferrepo=True,
53 )
54 def children(ui, repo, file_=None, **opts):
55 """show the children of the given or working directory revision
56
57 Print the children of the working directory's revisions. If a
58 revision is given via -r/--rev, the children of that revision will
59 be printed. If a file argument is given, revision in which the
60 file was last changed (after the working directory revision or the
61 argument to --rev if given) is printed.
62
63 Please use :hg:`log` instead::
64
65 hg children => hg log -r "children(.)"
66 hg children -r REV => hg log -r "children(REV)"
67
68 See :hg:`help log` and :hg:`help revsets.children`.
69
70 """
71 rev = opts.get('rev')
72 ctx = logcmdutil.revsingle(repo, rev)
73 if file_:
74 fctx = repo.filectx(file_, changeid=ctx.rev())
75 childctxs = [fcctx.changectx() for fcctx in fctx.children()]
76 else:
77 childctxs = ctx.children()
78
79 displayer = logcmdutil.changesetdisplayer(
80 ui, repo, pycompat.byteskwargs(opts)
81 )
82 for cctx in childctxs:
83 displayer.show(cctx)
84 displayer.close()