children.py
69 lines
| 2.1 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 | |||
Gregory Szorc
|
r28093 | from __future__ import absolute_import | ||
Thomas Arendsen Hein
|
r4783 | from mercurial.i18n import _ | ||
Gregory Szorc
|
r28093 | from mercurial import ( | ||
cmdutil, | ||||
commands, | ||||
) | ||||
templateopts = commands.templateopts | ||||
Thomas Arendsen Hein
|
r4783 | |||
Gregory Szorc
|
r21248 | cmdtable = {} | ||
command = cmdutil.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
|
r29841 | testedwith = 'ships-with-hg-core' | ||
Thomas Arendsen Hein
|
r4783 | |||
Gregory Szorc
|
r21248 | @command('children', | ||
[('r', 'rev', '', | ||||
_('show children of the specified revision'), _('REV')), | ||||
] + templateopts, | ||||
Gregory Szorc
|
r21780 | _('hg children [-r REV] [FILE]'), | ||
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:: | ||||
timeless
|
r28799 | hg children => hg log -r "children()" | ||
hg children -r REV => hg log -r "children(REV)" | ||||
timeless
|
r27716 | |||
See :hg:`help log` and :hg:`help revsets.children`. | ||||
Thomas Arendsen Hein
|
r4783 | """ | ||
rev = opts.get('rev') | ||||
if file_: | ||||
Yuya Nishihara
|
r24482 | fctx = repo.filectx(file_, changeid=rev) | ||
childctxs = [fcctx.changectx() for fcctx in fctx.children()] | ||||
Thomas Arendsen Hein
|
r4783 | else: | ||
Matt Mackall
|
r6747 | ctx = repo[rev] | ||
Yuya Nishihara
|
r24482 | childctxs = ctx.children() | ||
Thomas Arendsen Hein
|
r4783 | |||
displayer = cmdutil.show_changeset(ui, repo, opts) | ||||
Yuya Nishihara
|
r24482 | for cctx in childctxs: | ||
Dirkjan Ochtman
|
r7369 | displayer.show(cctx) | ||
Robert Bachmann
|
r10152 | displayer.close() | ||