children.py
84 lines
| 2.3 KiB
| text/x-python
|
PythonLexer
/ hgext / children.py
Thomas Arendsen Hein
|
r4783 | # Mercurial extension to provide the 'hg children' command | ||
# | ||||
# Copyright 2007 by Intevation GmbH <intevation@intevation.de> | ||||
Martin Geisler
|
r8228 | # | ||
Thomas Arendsen Hein
|
r4783 | # Author(s): | ||
# Thomas Arendsen Hein <thomas@intevation.de> | ||||
# | ||||
Martin Geisler
|
r8225 | # This software may be used and distributed according to the terms of the | ||
Matt Mackall
|
r10263 | # GNU General Public License version 2 or any later version. | ||
Thomas Arendsen Hein
|
r4783 | |||
Augie Fackler
|
r16668 | '''command to display child changesets (DEPRECATED) | ||
Martin Geisler
|
r16670 | This extension is deprecated. You should use :hg:`log -r | ||
"children(REV)"` instead. | ||||
Augie Fackler
|
r16668 | ''' | ||
Dirkjan Ochtman
|
r8873 | |||
Matt Harbison
|
r52756 | from __future__ import annotations | ||
Gregory Szorc
|
r28093 | |||
Thomas Arendsen Hein
|
r4783 | from mercurial.i18n import _ | ||
Gregory Szorc
|
r28093 | from mercurial import ( | ||
cmdutil, | ||||
Yuya Nishihara
|
r35906 | logcmdutil, | ||
Pulkit Goyal
|
r34974 | pycompat, | ||
Yuya Nishihara
|
r32337 | registrar, | ||
Gregory Szorc
|
r28093 | ) | ||
Yuya Nishihara
|
r32375 | templateopts = cmdutil.templateopts | ||
Thomas Arendsen Hein
|
r4783 | |||
Gregory Szorc
|
r21248 | cmdtable = {} | ||
Yuya Nishihara
|
r32337 | command = registrar.command(cmdtable) | ||
Augie Fackler
|
r29841 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||
Augie Fackler
|
r25186 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | ||
# be specifying the version(s) of Mercurial they are tested with, or | ||||
# leave the attribute unspecified. | ||||
Augie Fackler
|
r43347 | testedwith = b'ships-with-hg-core' | ||
Thomas Arendsen Hein
|
r4783 | |||
Augie Fackler
|
r43346 | |||
@command( | ||||
Augie Fackler
|
r43347 | b'children', | ||
[ | ||||
( | ||||
b'r', | ||||
b'rev', | ||||
b'.', | ||||
_(b'show children of the specified revision'), | ||||
_(b'REV'), | ||||
), | ||||
] | ||||
Augie Fackler
|
r43346 | + templateopts, | ||
Augie Fackler
|
r43347 | _(b'hg children [-r REV] [FILE]'), | ||
rdamazio@google.com
|
r40329 | helpcategory=command.CATEGORY_CHANGE_NAVIGATION, | ||
Augie Fackler
|
r43346 | inferrepo=True, | ||
) | ||||
Thomas Arendsen Hein
|
r4783 | def children(ui, repo, file_=None, **opts): | ||
Martin Geisler
|
r8026 | """show the children of the given or working directory revision | ||
Thomas Arendsen Hein
|
r4783 | |||
Martin Geisler
|
r9253 | Print the children of the working directory's revisions. If a | ||
revision is given via -r/--rev, the children of that revision will | ||||
be printed. If a file argument is given, revision in which the | ||||
file was last changed (after the working directory revision or the | ||||
argument to --rev if given) is printed. | ||||
timeless
|
r27716 | |||
Please use :hg:`log` instead:: | ||||
Pulkit Goyal
|
r34946 | hg children => hg log -r "children(.)" | ||
timeless
|
r28799 | hg children -r REV => hg log -r "children(REV)" | ||
timeless
|
r27716 | |||
See :hg:`help log` and :hg:`help revsets.children`. | ||||
Thomas Arendsen Hein
|
r4783 | """ | ||
Matt Harbison
|
r51764 | rev = opts.get('rev') | ||
Martin von Zweigbergk
|
r48930 | ctx = logcmdutil.revsingle(repo, rev) | ||
Thomas Arendsen Hein
|
r4783 | if file_: | ||
Martin von Zweigbergk
|
r37375 | fctx = repo.filectx(file_, changeid=ctx.rev()) | ||
Yuya Nishihara
|
r24482 | childctxs = [fcctx.changectx() for fcctx in fctx.children()] | ||
Thomas Arendsen Hein
|
r4783 | else: | ||
Yuya Nishihara
|
r24482 | childctxs = ctx.children() | ||
Thomas Arendsen Hein
|
r4783 | |||
Matt Harbison
|
r51764 | displayer = logcmdutil.changesetdisplayer( | ||
ui, repo, pycompat.byteskwargs(opts) | ||||
) | ||||
Yuya Nishihara
|
r24482 | for cctx in childctxs: | ||
Dirkjan Ochtman
|
r7369 | displayer.show(cctx) | ||
Robert Bachmann
|
r10152 | displayer.close() | ||