Mercurial > hg > mercurial-source
annotate hgext/children.py @ 44054:a324f6a0cfd3
tests: opt into python3 when testing virtualenv installation
Otherwise it complains that Mercurial requires '~=2.7'. Since the existing
linux py3 test doesn't flag this, I'm assuming that virtualenv simply isn't
installed on that system.
Differential Revision: https://phab.mercurial-scm.org/D7111
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 15 Oct 2019 21:51:37 -0400 |
parents | 687b865b95ad |
children |
rev | line source |
---|---|
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
1 # Mercurial extension to provide the 'hg children' command |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
2 # |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
3 # Copyright 2007 by Intevation GmbH <intevation@intevation.de> |
8228
eee2319c5895
add blank line after copyright notices and after header
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
4 # |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
5 # Author(s): |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
6 # Thomas Arendsen Hein <thomas@intevation.de> |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
7 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8075
diff
changeset
|
8 # This software may be used and distributed according to the terms of the |
10263 | 9 # GNU General Public License version 2 or any later version. |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
10 |
16606
f393d20fb2ba
children: mark extension as deprecated
Augie Fackler <raf@durin42.com>
parents:
11321
diff
changeset
|
11 '''command to display child changesets (DEPRECATED) |
f393d20fb2ba
children: mark extension as deprecated
Augie Fackler <raf@durin42.com>
parents:
11321
diff
changeset
|
12 |
16608
052047753f7d
children: use hg reST role for example
Martin Geisler <mg@lazybytes.net>
parents:
16606
diff
changeset
|
13 This extension is deprecated. You should use :hg:`log -r |
052047753f7d
children: use hg reST role for example
Martin Geisler <mg@lazybytes.net>
parents:
16606
diff
changeset
|
14 "children(REV)"` instead. |
16606
f393d20fb2ba
children: mark extension as deprecated
Augie Fackler <raf@durin42.com>
parents:
11321
diff
changeset
|
15 ''' |
8873
e872ef2e6758
help: add/fix docstrings for a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
8275
diff
changeset
|
16 |
28764
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28371
diff
changeset
|
17 from __future__ import absolute_import |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28371
diff
changeset
|
18 |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
19 from mercurial.i18n import _ |
28764
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28371
diff
changeset
|
20 from mercurial import ( |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28371
diff
changeset
|
21 cmdutil, |
36674
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35756
diff
changeset
|
22 logcmdutil, |
35756
11a372d80496
py3: handle keyword arguments in hgext/children.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35728
diff
changeset
|
23 pycompat, |
33120
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30611
diff
changeset
|
24 registrar, |
38143
7c8524efd847
children: support specifying revision by revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38051
diff
changeset
|
25 scmutil, |
28764
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28371
diff
changeset
|
26 ) |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28371
diff
changeset
|
27 |
33158
04baab18d60a
commands: move templates of common command options to cmdutil (API)
Yuya Nishihara <yuya@tcha.org>
parents:
33120
diff
changeset
|
28 templateopts = cmdutil.templateopts |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
29 |
21248
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
30 cmdtable = {} |
33120
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30611
diff
changeset
|
31 command = registrar.command(cmdtable) |
30611
d5883fd055c6
extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents:
29549
diff
changeset
|
32 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
25621
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24615
diff
changeset
|
33 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24615
diff
changeset
|
34 # be specifying the version(s) of Mercurial they are tested with, or |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24615
diff
changeset
|
35 # leave the attribute unspecified. |
43864
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
36 testedwith = b'ships-with-hg-core' |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
37 |
43863
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41079
diff
changeset
|
38 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41079
diff
changeset
|
39 @command( |
43864
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
40 b'children', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
41 [ |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
42 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
43 b'r', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
44 b'rev', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
45 b'.', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
46 _(b'show children of the specified revision'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
47 _(b'REV'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
48 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
49 ] |
43863
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41079
diff
changeset
|
50 + templateopts, |
43864
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
51 _(b'hg children [-r REV] [FILE]'), |
41079
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
38143
diff
changeset
|
52 helpcategory=command.CATEGORY_CHANGE_NAVIGATION, |
43863
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41079
diff
changeset
|
53 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41079
diff
changeset
|
54 ) |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
55 def children(ui, repo, file_=None, **opts): |
8026
683d8ebcf434
expand "dir" to "directory" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
7986
diff
changeset
|
56 """show the children of the given or working directory revision |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
57 |
9241
d6d811d90976
children: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9055
diff
changeset
|
58 Print the children of the working directory's revisions. If a |
d6d811d90976
children: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9055
diff
changeset
|
59 revision is given via -r/--rev, the children of that revision will |
d6d811d90976
children: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9055
diff
changeset
|
60 be printed. If a file argument is given, revision in which the |
d6d811d90976
children: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9055
diff
changeset
|
61 file was last changed (after the working directory revision or the |
d6d811d90976
children: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9055
diff
changeset
|
62 argument to --rev if given) is printed. |
28371
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25621
diff
changeset
|
63 |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25621
diff
changeset
|
64 Please use :hg:`log` instead:: |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25621
diff
changeset
|
65 |
35728
d2554ef04d26
children: fix the log expansion of `hg children` in doc
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33158
diff
changeset
|
66 hg children => hg log -r "children(.)" |
29549
ccab2923a093
children: use double quotes for arguments
timeless <timeless@mozdev.org>
parents:
28764
diff
changeset
|
67 hg children -r REV => hg log -r "children(REV)" |
28371
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25621
diff
changeset
|
68 |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25621
diff
changeset
|
69 See :hg:`help log` and :hg:`help revsets.children`. |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25621
diff
changeset
|
70 |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
71 """ |
35756
11a372d80496
py3: handle keyword arguments in hgext/children.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35728
diff
changeset
|
72 opts = pycompat.byteskwargs(opts) |
43864
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43863
diff
changeset
|
73 rev = opts.get(b'rev') |
38143
7c8524efd847
children: support specifying revision by revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38051
diff
changeset
|
74 ctx = scmutil.revsingle(repo, rev) |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
75 if file_: |
38143
7c8524efd847
children: support specifying revision by revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38051
diff
changeset
|
76 fctx = repo.filectx(file_, changeid=ctx.rev()) |
24615
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
77 childctxs = [fcctx.changectx() for fcctx in fctx.children()] |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
78 else: |
24615
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
79 childctxs = ctx.children() |
4780
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
80 |
36674
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35756
diff
changeset
|
81 displayer = logcmdutil.changesetdisplayer(ui, repo, opts) |
24615
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
82 for cctx in childctxs: |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6749
diff
changeset
|
83 displayer.show(cctx) |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
9241
diff
changeset
|
84 displayer.close() |