Mercurial > hg
annotate hgext/children.py @ 28180:2836a43c7722
run-tests: allow run-tests.py to run tests outside current directory
When reloading tests, run-tests.py was assuming that it could look
up the test by the basename, which only works if you are running
tests which are in the current directory.
This patch changes that lookup to use the full path. This is all
that was needed, and does not appear to cause any problems for
any of the existing testing work flows based on running the
suggested commands at the top of run-tests.py.
Motivation: In order to test Mercurial with Hypothesis (according
to https://www.mercurial-scm.org/wiki/HypothesisPlan) it is
useful to be able to generate temporary test files and execute
them. Generating temporary files in the tests/ directory leads to
a lot of suboptimal clutter.
author | David R. MacIver <david@drmaciver.com> |
---|---|
date | Thu, 18 Feb 2016 08:52:15 +0000 |
parents | 7353cacd5d54 |
children | ccab2923a093 |
rev | line source |
---|---|
4783
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 # |
4783
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:
8076
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. |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
10 |
16668
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 |
16670
052047753f7d
children: use hg reST role for example
Martin Geisler <mg@lazybytes.net>
parents:
16668
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:
16668
diff
changeset
|
14 "children(REV)"` instead. |
16668
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:
8277
diff
changeset
|
16 |
28093
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
17 from __future__ import absolute_import |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
18 |
4783
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 _ |
28093
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
20 from mercurial import ( |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
21 cmdutil, |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
22 commands, |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
23 ) |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
24 |
7353cacd5d54
children: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27716
diff
changeset
|
25 templateopts = commands.templateopts |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
26 |
21248
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
27 cmdtable = {} |
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
28 command = cmdutil.command(cmdtable) |
25186
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24482
diff
changeset
|
29 # Note for extension authors: ONLY specify testedwith = 'internal' for |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24482
diff
changeset
|
30 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80c5b2666a96
extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents:
24482
diff
changeset
|
31 # 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:
24482
diff
changeset
|
32 # leave the attribute unspecified. |
16743
38caf405d010
hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents:
16670
diff
changeset
|
33 testedwith = 'internal' |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
34 |
21248
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
35 @command('children', |
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
36 [('r', 'rev', '', |
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
37 _('show children of the specified revision'), _('REV')), |
48e859e30cbf
children: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17773
diff
changeset
|
38 ] + templateopts, |
21780
2d3fb8476d7a
children: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21248
diff
changeset
|
39 _('hg children [-r REV] [FILE]'), |
2d3fb8476d7a
children: define inferrepo in command decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21248
diff
changeset
|
40 inferrepo=True) |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
41 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
|
42 """show the children of the given or working directory revision |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
43 |
9253
d6d811d90976
children: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9055
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 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
|
48 argument to --rev if given) is printed. |
27716
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
49 |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
50 Please use :hg:`log` instead:: |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
51 |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
52 hg children => hg log -r 'children()' |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
53 hg children -r REV => hg log -r 'children(REV)' |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
54 |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
55 See :hg:`help log` and :hg:`help revsets.children`. |
3501bd89dad2
children: update help with replacement
timeless <timeless@mozdev.org>
parents:
25186
diff
changeset
|
56 |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
57 """ |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
58 rev = opts.get('rev') |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
59 if file_: |
24482
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
60 fctx = repo.filectx(file_, changeid=rev) |
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
61 childctxs = [fcctx.changectx() for fcctx in fctx.children()] |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
62 else: |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6192
diff
changeset
|
63 ctx = repo[rev] |
24482
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
64 childctxs = ctx.children() |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
65 |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
66 displayer = cmdutil.show_changeset(ui, repo, opts) |
24482
3eb9045396b0
children: don't pass filectx to displayer
Yuya Nishihara <yuya@tcha.org>
parents:
21780
diff
changeset
|
67 for cctx in childctxs: |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6747
diff
changeset
|
68 displayer.show(cctx) |
10152
56284451a22c
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann <rbachm@gmail.com>
parents:
9253
diff
changeset
|
69 displayer.close() |