children.py
73 lines
| 2.2 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, | ||||
Yuya Nishihara
|
r35906 | logcmdutil, | ||
Pulkit Goyal
|
r34974 | pycompat, | ||
Yuya Nishihara
|
r32337 | registrar, | ||
Martin von Zweigbergk
|
r37375 | scmutil, | ||
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
|
r29841 | testedwith = 'ships-with-hg-core' | ||
Thomas Arendsen Hein
|
r4783 | |||
Gregory Szorc
|
r21248 | @command('children', | ||
Martin von Zweigbergk
|
r37282 | [('r', 'rev', '.', | ||
Gregory Szorc
|
r21248 | _('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:: | ||||
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 | """ | ||
Pulkit Goyal
|
r34974 | opts = pycompat.byteskwargs(opts) | ||
Thomas Arendsen Hein
|
r4783 | rev = opts.get('rev') | ||
Martin von Zweigbergk
|
r37375 | ctx = scmutil.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 | |||
Yuya Nishihara
|
r35906 | displayer = logcmdutil.changesetdisplayer(ui, repo, opts) | ||
Yuya Nishihara
|
r24482 | for cctx in childctxs: | ||
Dirkjan Ochtman
|
r7369 | displayer.show(cctx) | ||
Robert Bachmann
|
r10152 | displayer.close() | ||