author | Martin Geisler <mg@daimi.au.dk> |
Sat, 04 Apr 2009 23:15:37 +0200 | |
changeset 7986 | c756e695012a |
parent 7369 | 87158be081b8 |
child 8026 | 683d8ebcf434 |
permissions | -rw-r--r-- |
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> |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
4 |
# Author(s): |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
5 |
# 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
|
6 |
# |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
7 |
# This software may be used and distributed according to the terms |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 |
# of the GNU General Public License, incorporated herein by reference. |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
9 |
|
4785
be78ab217109
children extension: Don't abort when looking at the null revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4783
diff
changeset
|
10 |
from mercurial import cmdutil |
6192
cd65a67aff31
Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4785
diff
changeset
|
11 |
from mercurial.commands import templateopts |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
12 |
from mercurial.i18n import _ |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
13 |
|
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
14 |
|
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
15 |
def children(ui, repo, file_=None, **opts): |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
16 |
"""show the children of the given or working dir revision |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
17 |
|
7986
c756e695012a
children: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7369
diff
changeset
|
18 |
Print the children of the working directory's revisions. If a |
c756e695012a
children: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7369
diff
changeset
|
19 |
revision is given via --rev, the children of that revision will be |
c756e695012a
children: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7369
diff
changeset
|
20 |
printed. If a file argument is given, revision in which the file |
c756e695012a
children: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7369
diff
changeset
|
21 |
was last changed (after the working directory revision or the |
c756e695012a
children: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7369
diff
changeset
|
22 |
argument to --rev if given) is printed. |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
23 |
""" |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
24 |
rev = opts.get('rev') |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
25 |
if file_: |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
26 |
ctx = repo.filectx(file_, changeid=rev) |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
27 |
else: |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6192
diff
changeset
|
28 |
ctx = repo[rev] |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
29 |
|
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
30 |
displayer = cmdutil.show_changeset(ui, repo, opts) |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6747
diff
changeset
|
31 |
for cctx in ctx.children(): |
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6747
diff
changeset
|
32 |
displayer.show(cctx) |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
33 |
|
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
34 |
|
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
35 |
cmdtable = { |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
36 |
"children": |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
37 |
(children, |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
38 |
[('r', 'rev', '', _('show children of the specified rev')), |
6192
cd65a67aff31
Introduce templateopts and logopts to reduce duplicate option definitions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4785
diff
changeset
|
39 |
] + templateopts, |
4783
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
40 |
_('hg children [-r REV] [FILE]')), |
8b90d763ea90
Add extension to provide the 'hg children' command (with tests)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
41 |
} |