children.py
76 lines
| 2.3 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 | |||
|
r28093 | from __future__ import absolute_import | ||
|
r4783 | from mercurial.i18n import _ | ||
|
r28093 | from mercurial import ( | ||
cmdutil, | ||||
|
r35906 | logcmdutil, | ||
|
r34974 | pycompat, | ||
|
r32337 | registrar, | ||
|
r37375 | scmutil, | ||
|
r28093 | ) | ||
|
r32375 | templateopts = cmdutil.templateopts | ||
|
r4783 | |||
|
r21248 | cmdtable = {} | ||
|
r32337 | command = registrar.command(cmdtable) | ||
|
r29841 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||
|
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. | ||||
|
r29841 | testedwith = 'ships-with-hg-core' | ||
|
r4783 | |||
|
r43346 | |||
@command( | ||||
'children', | ||||
[('r', 'rev', '.', _('show children of the specified revision'), _('REV')),] | ||||
+ templateopts, | ||||
|
r21780 | _('hg children [-r REV] [FILE]'), | ||
|
r40329 | helpcategory=command.CATEGORY_CHANGE_NAVIGATION, | ||
|
r43346 | 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:: | ||||
|
r34946 | hg children => hg log -r "children(.)" | ||
|
r28799 | hg children -r REV => hg log -r "children(REV)" | ||
|
r27716 | |||
See :hg:`help log` and :hg:`help revsets.children`. | ||||
|
r4783 | """ | ||
|
r34974 | opts = pycompat.byteskwargs(opts) | ||
|
r4783 | rev = opts.get('rev') | ||
|
r37375 | ctx = scmutil.revsingle(repo, rev) | ||
|
r4783 | if file_: | ||
|
r37375 | fctx = repo.filectx(file_, changeid=ctx.rev()) | ||
|
r24482 | childctxs = [fcctx.changectx() for fcctx in fctx.children()] | ||
|
r4783 | else: | ||
|
r24482 | childctxs = ctx.children() | ||
|
r4783 | |||
|
r35906 | displayer = logcmdutil.changesetdisplayer(ui, repo, opts) | ||
|
r24482 | for cctx in childctxs: | ||
|
r7369 | displayer.show(cctx) | ||
|
r10152 | displayer.close() | ||