children.py
63 lines
| 2.0 KiB
| text/x-python
|
PythonLexer
/ hgext / children.py
|
r4783 | # Mercurial extension to provide the 'hg children' command | ||
# | ||||
# Copyright 2007 by Intevation GmbH <intevation@intevation.de> | ||||
|
r8228 | # | ||
|
r4783 | # Author(s): | ||
# Thomas Arendsen Hein <thomas@intevation.de> | ||||
# | ||||
|
r8225 | # This software may be used and distributed according to the terms of the | ||
|
r10263 | # GNU General Public License version 2 or any later version. | ||
|
r4783 | |||
|
r16668 | '''command to display child changesets (DEPRECATED) | ||
|
r16670 | This extension is deprecated. You should use :hg:`log -r | ||
"children(REV)"` instead. | ||||
|
r16668 | ''' | ||
|
r8873 | |||
|
r21780 | from mercurial import cmdutil | ||
|
r6192 | from mercurial.commands import templateopts | ||
|
r4783 | from mercurial.i18n import _ | ||
|
r21248 | cmdtable = {} | ||
command = cmdutil.command(cmdtable) | ||||
|
r25186 | # Note for extension authors: ONLY specify testedwith = 'internal' for | ||
# 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. | ||||
|
r16743 | testedwith = 'internal' | ||
|
r4783 | |||
|
r21248 | @command('children', | ||
[('r', 'rev', '', | ||||
_('show children of the specified revision'), _('REV')), | ||||
] + templateopts, | ||||
|
r21780 | _('hg children [-r REV] [FILE]'), | ||
inferrepo=True) | ||||
|
r4783 | def children(ui, repo, file_=None, **opts): | ||
|
r8026 | """show the children of the given or working directory revision | ||
|
r4783 | |||
|
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. | ||||
|
r27716 | |||
Please use :hg:`log` instead:: | ||||
hg children => hg log -r 'children()' | ||||
hg children -r REV => hg log -r 'children(REV)' | ||||
See :hg:`help log` and :hg:`help revsets.children`. | ||||
|
r4783 | """ | ||
rev = opts.get('rev') | ||||
if file_: | ||||
|
r24482 | fctx = repo.filectx(file_, changeid=rev) | ||
childctxs = [fcctx.changectx() for fcctx in fctx.children()] | ||||
|
r4783 | else: | ||
|
r6747 | ctx = repo[rev] | ||
|
r24482 | childctxs = ctx.children() | ||
|
r4783 | |||
displayer = cmdutil.show_changeset(ui, repo, opts) | ||||
|
r24482 | for cctx in childctxs: | ||
|
r7369 | displayer.show(cctx) | ||
|
r10152 | displayer.close() | ||