Mercurial > hg
view hgext/children.py @ 28488:437c32dcec7d
context: use changelogrevision
Upcoming patches will make the changelogrevision object perform
lazy parsing. Let's switch to it.
Because we're switching from a tuple to an object, everthing that
accesses the internal cached attribute needs to be updated to access
via attributes. A nice side-effect is this makes the code easier to
read!
Surprisingly, this appears to make revsets accessing this data
slightly faster (values are before series, p1, this patch):
author(mpm)
0.896565
0.929984
0.914234
desc(bug)
0.887169
0.935642
0.921073
date(2015)
0.878797
0.908094
0.891980
extra(rebase_source)
0.865446
0.922624
0.912514
author(mpm) or author(greg)
1.801832
1.902112
1.860402
author(mpm) or desc(bug)
1.812438
1.860977
1.844850
date(2015) or branch(default)
0.968276
1.005824
0.994673
author(mpm) or desc(bug) or date(2015) or extra(rebase_source)
3.656193
3.743381
3.721032
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Mar 2016 13:26:37 -0800 |
parents | 7353cacd5d54 |
children | ccab2923a093 |
line wrap: on
line source
# Mercurial extension to provide the 'hg children' command # # Copyright 2007 by Intevation GmbH <intevation@intevation.de> # # Author(s): # Thomas Arendsen Hein <thomas@intevation.de> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. '''command to display child changesets (DEPRECATED) This extension is deprecated. You should use :hg:`log -r "children(REV)"` instead. ''' from __future__ import absolute_import from mercurial.i18n import _ from mercurial import ( cmdutil, commands, ) templateopts = commands.templateopts cmdtable = {} command = cmdutil.command(cmdtable) # 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. testedwith = 'internal' @command('children', [('r', 'rev', '', _('show children of the specified revision'), _('REV')), ] + templateopts, _('hg children [-r REV] [FILE]'), inferrepo=True) def children(ui, repo, file_=None, **opts): """show the children of the given or working directory revision 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. 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`. """ rev = opts.get('rev') if file_: fctx = repo.filectx(file_, changeid=rev) childctxs = [fcctx.changectx() for fcctx in fctx.children()] else: ctx = repo[rev] childctxs = ctx.children() displayer = cmdutil.show_changeset(ui, repo, opts) for cctx in childctxs: displayer.show(cctx) displayer.close()