Show More
@@ -0,0 +1,45 b'' | |||
|
1 | # Mercurial extension to provide the 'hg children' command | |
|
2 | # | |
|
3 | # Copyright 2007 by Intevation GmbH <intevation@intevation.de> | |
|
4 | # Author(s): | |
|
5 | # Thomas Arendsen Hein <thomas@intevation.de> | |
|
6 | # | |
|
7 | # This software may be used and distributed according to the terms | |
|
8 | # of the GNU General Public License, incorporated herein by reference. | |
|
9 | ||
|
10 | from mercurial import cmdutil, util | |
|
11 | from mercurial.i18n import _ | |
|
12 | from mercurial.node import nullid | |
|
13 | ||
|
14 | ||
|
15 | def children(ui, repo, file_=None, **opts): | |
|
16 | """show the children of the given or working dir revision | |
|
17 | ||
|
18 | Print the children of the working directory's revisions. | |
|
19 | If a revision is given via --rev, the children of that revision | |
|
20 | will be printed. If a file argument is given, revision in | |
|
21 | which the file was last changed (after the working directory | |
|
22 | revision or the argument to --rev if given) is printed. | |
|
23 | """ | |
|
24 | rev = opts.get('rev') | |
|
25 | if file_: | |
|
26 | ctx = repo.filectx(file_, changeid=rev) | |
|
27 | else: | |
|
28 | ctx = repo.changectx(rev) | |
|
29 | if ctx.node() == nullid: | |
|
30 | raise util.Abort(_("All non-merge changesets are children of " | |
|
31 | "the null revision!")) | |
|
32 | ||
|
33 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
|
34 | for node in [cp.node() for cp in ctx.children()]: | |
|
35 | displayer.show(changenode=node) | |
|
36 | ||
|
37 | ||
|
38 | cmdtable = { | |
|
39 | "children": | |
|
40 | (children, | |
|
41 | [('r', 'rev', '', _('show children of the specified rev')), | |
|
42 | ('', 'style', '', _('display using template map file')), | |
|
43 | ('', 'template', '', _('display with template'))], | |
|
44 | _('hg children [-r REV] [FILE]')), | |
|
45 | } |
@@ -0,0 +1,59 b'' | |||
|
1 | #!/bin/sh | |
|
2 | # test children command | |
|
3 | ||
|
4 | cat <<EOF >> $HGRCPATH | |
|
5 | [extensions] | |
|
6 | hgext.children= | |
|
7 | EOF | |
|
8 | ||
|
9 | echo "% init" | |
|
10 | hg init t | |
|
11 | cd t | |
|
12 | ||
|
13 | echo "% no working directory" | |
|
14 | hg children | |
|
15 | ||
|
16 | echo % setup | |
|
17 | echo 0 > file0 | |
|
18 | hg ci -qAm 0 -d '0 0' | |
|
19 | ||
|
20 | echo 1 > file1 | |
|
21 | hg ci -qAm 1 -d '1 0' | |
|
22 | ||
|
23 | echo 2 >> file0 | |
|
24 | hg ci -qAm 2 -d '2 0' | |
|
25 | ||
|
26 | hg co null | |
|
27 | echo 3 > file3 | |
|
28 | hg ci -qAm 3 -d '3 0' | |
|
29 | ||
|
30 | echo "% hg children at revision 3 (tip)" | |
|
31 | hg children | |
|
32 | ||
|
33 | hg co null | |
|
34 | echo "% hg children at nullrev (should be 0 and 3)" | |
|
35 | hg children | |
|
36 | ||
|
37 | hg co 1 | |
|
38 | echo "% hg children at revision 1 (should be 2)" | |
|
39 | hg children | |
|
40 | ||
|
41 | hg co 2 | |
|
42 | echo "% hg children at revision 2 (other head)" | |
|
43 | hg children | |
|
44 | ||
|
45 | for i in null 0 1 2 3; do | |
|
46 | echo "% hg children -r $i" | |
|
47 | hg children -r $i | |
|
48 | done | |
|
49 | ||
|
50 | echo "% hg children -r 0 file0 (should be 2)" | |
|
51 | hg children -r 0 file0 | |
|
52 | ||
|
53 | echo "% hg children -r 1 file0 (should be 2)" | |
|
54 | hg children -r 1 file0 | |
|
55 | ||
|
56 | hg co 0 | |
|
57 | echo "% hg children file0 at revision 0 (should be 2)" | |
|
58 | hg children file0 | |
|
59 |
@@ -0,0 +1,52 b'' | |||
|
1 | % init | |
|
2 | % no working directory | |
|
3 | abort: All non-merge changesets are children of the null revision! | |
|
4 | % setup | |
|
5 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
|
6 | % hg children at revision 3 (tip) | |
|
7 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
8 | % hg children at nullrev (should be 0 and 3) | |
|
9 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
10 | % hg children at revision 1 (should be 2) | |
|
11 | changeset: 2:8f5eea5023c2 | |
|
12 | user: test | |
|
13 | date: Thu Jan 01 00:00:02 1970 +0000 | |
|
14 | summary: 2 | |
|
15 | ||
|
16 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
17 | % hg children at revision 2 (other head) | |
|
18 | % hg children -r null | |
|
19 | abort: All non-merge changesets are children of the null revision! | |
|
20 | % hg children -r 0 | |
|
21 | changeset: 1:708c093edef0 | |
|
22 | user: test | |
|
23 | date: Thu Jan 01 00:00:01 1970 +0000 | |
|
24 | summary: 1 | |
|
25 | ||
|
26 | % hg children -r 1 | |
|
27 | changeset: 2:8f5eea5023c2 | |
|
28 | user: test | |
|
29 | date: Thu Jan 01 00:00:02 1970 +0000 | |
|
30 | summary: 2 | |
|
31 | ||
|
32 | % hg children -r 2 | |
|
33 | % hg children -r 3 | |
|
34 | % hg children -r 0 file0 (should be 2) | |
|
35 | changeset: 2:8f5eea5023c2 | |
|
36 | user: test | |
|
37 | date: Thu Jan 01 00:00:02 1970 +0000 | |
|
38 | summary: 2 | |
|
39 | ||
|
40 | % hg children -r 1 file0 (should be 2) | |
|
41 | changeset: 2:8f5eea5023c2 | |
|
42 | user: test | |
|
43 | date: Thu Jan 01 00:00:02 1970 +0000 | |
|
44 | summary: 2 | |
|
45 | ||
|
46 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
47 | % hg children file0 at revision 0 (should be 2) | |
|
48 | changeset: 2:8f5eea5023c2 | |
|
49 | user: test | |
|
50 | date: Thu Jan 01 00:00:02 1970 +0000 | |
|
51 | summary: 2 | |
|
52 |
General Comments 0
You need to be logged in to leave comments.
Login now