##// END OF EJS Templates
children: don't pass filectx to displayer...
Yuya Nishihara -
r24482:3eb90453 default
parent child Browse files
Show More
@@ -1,49 +1,51 b''
1 # Mercurial extension to provide the 'hg children' command
1 # Mercurial extension to provide the 'hg children' command
2 #
2 #
3 # Copyright 2007 by Intevation GmbH <intevation@intevation.de>
3 # Copyright 2007 by Intevation GmbH <intevation@intevation.de>
4 #
4 #
5 # Author(s):
5 # Author(s):
6 # Thomas Arendsen Hein <thomas@intevation.de>
6 # Thomas Arendsen Hein <thomas@intevation.de>
7 #
7 #
8 # This software may be used and distributed according to the terms of the
8 # This software may be used and distributed according to the terms of the
9 # GNU General Public License version 2 or any later version.
9 # GNU General Public License version 2 or any later version.
10
10
11 '''command to display child changesets (DEPRECATED)
11 '''command to display child changesets (DEPRECATED)
12
12
13 This extension is deprecated. You should use :hg:`log -r
13 This extension is deprecated. You should use :hg:`log -r
14 "children(REV)"` instead.
14 "children(REV)"` instead.
15 '''
15 '''
16
16
17 from mercurial import cmdutil
17 from mercurial import cmdutil
18 from mercurial.commands import templateopts
18 from mercurial.commands import templateopts
19 from mercurial.i18n import _
19 from mercurial.i18n import _
20
20
21 cmdtable = {}
21 cmdtable = {}
22 command = cmdutil.command(cmdtable)
22 command = cmdutil.command(cmdtable)
23 testedwith = 'internal'
23 testedwith = 'internal'
24
24
25 @command('children',
25 @command('children',
26 [('r', 'rev', '',
26 [('r', 'rev', '',
27 _('show children of the specified revision'), _('REV')),
27 _('show children of the specified revision'), _('REV')),
28 ] + templateopts,
28 ] + templateopts,
29 _('hg children [-r REV] [FILE]'),
29 _('hg children [-r REV] [FILE]'),
30 inferrepo=True)
30 inferrepo=True)
31 def children(ui, repo, file_=None, **opts):
31 def children(ui, repo, file_=None, **opts):
32 """show the children of the given or working directory revision
32 """show the children of the given or working directory revision
33
33
34 Print the children of the working directory's revisions. If a
34 Print the children of the working directory's revisions. If a
35 revision is given via -r/--rev, the children of that revision will
35 revision is given via -r/--rev, the children of that revision will
36 be printed. If a file argument is given, revision in which the
36 be printed. If a file argument is given, revision in which the
37 file was last changed (after the working directory revision or the
37 file was last changed (after the working directory revision or the
38 argument to --rev if given) is printed.
38 argument to --rev if given) is printed.
39 """
39 """
40 rev = opts.get('rev')
40 rev = opts.get('rev')
41 if file_:
41 if file_:
42 ctx = repo.filectx(file_, changeid=rev)
42 fctx = repo.filectx(file_, changeid=rev)
43 childctxs = [fcctx.changectx() for fcctx in fctx.children()]
43 else:
44 else:
44 ctx = repo[rev]
45 ctx = repo[rev]
46 childctxs = ctx.children()
45
47
46 displayer = cmdutil.show_changeset(ui, repo, opts)
48 displayer = cmdutil.show_changeset(ui, repo, opts)
47 for cctx in ctx.children():
49 for cctx in childctxs:
48 displayer.show(cctx)
50 displayer.show(cctx)
49 displayer.close()
51 displayer.close()
@@ -1,125 +1,133 b''
1 test children command
1 test children command
2
2
3 $ cat <<EOF >> $HGRCPATH
3 $ cat <<EOF >> $HGRCPATH
4 > [extensions]
4 > [extensions]
5 > children =
5 > children =
6 > EOF
6 > EOF
7
7
8 init
8 init
9 $ hg init t
9 $ hg init t
10 $ cd t
10 $ cd t
11
11
12 no working directory
12 no working directory
13 $ hg children
13 $ hg children
14
14
15 setup
15 setup
16 $ echo 0 > file0
16 $ echo 0 > file0
17 $ hg ci -qAm 0 -d '0 0'
17 $ hg ci -qAm 0 -d '0 0'
18
18
19 $ echo 1 > file1
19 $ echo 1 > file1
20 $ hg ci -qAm 1 -d '1 0'
20 $ hg ci -qAm 1 -d '1 0'
21
21
22 $ echo 2 >> file0
22 $ echo 2 >> file0
23 $ hg ci -qAm 2 -d '2 0'
23 $ hg ci -qAm 2 -d '2 0'
24
24
25 $ hg co null
25 $ hg co null
26 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
26 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
27 $ echo 3 > file3
27 $ echo 3 > file3
28 $ hg ci -qAm 3 -d '3 0'
28 $ hg ci -qAm 3 -d '3 0'
29
29
30 hg children at revision 3 (tip)
30 hg children at revision 3 (tip)
31 $ hg children
31 $ hg children
32
32
33 $ hg co null
33 $ hg co null
34 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
34 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
35
35
36 hg children at nullrev (should be 0 and 3)
36 hg children at nullrev (should be 0 and 3)
37 $ hg children
37 $ hg children
38 changeset: 0:4df8521a7374
38 changeset: 0:4df8521a7374
39 user: test
39 user: test
40 date: Thu Jan 01 00:00:00 1970 +0000
40 date: Thu Jan 01 00:00:00 1970 +0000
41 summary: 0
41 summary: 0
42
42
43 changeset: 3:e2962852269d
43 changeset: 3:e2962852269d
44 tag: tip
44 tag: tip
45 parent: -1:000000000000
45 parent: -1:000000000000
46 user: test
46 user: test
47 date: Thu Jan 01 00:00:03 1970 +0000
47 date: Thu Jan 01 00:00:03 1970 +0000
48 summary: 3
48 summary: 3
49
49
50 $ hg co 1
50 $ hg co 1
51 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
52
52
53 hg children at revision 1 (should be 2)
53 hg children at revision 1 (should be 2)
54 $ hg children
54 $ hg children
55 changeset: 2:8f5eea5023c2
55 changeset: 2:8f5eea5023c2
56 user: test
56 user: test
57 date: Thu Jan 01 00:00:02 1970 +0000
57 date: Thu Jan 01 00:00:02 1970 +0000
58 summary: 2
58 summary: 2
59
59
60 $ hg co 2
60 $ hg co 2
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
62
62
63 hg children at revision 2 (other head)
63 hg children at revision 2 (other head)
64 $ hg children
64 $ hg children
65
65
66 $ for i in null 0 1 2 3; do
66 $ for i in null 0 1 2 3; do
67 > echo "hg children -r $i"
67 > echo "hg children -r $i"
68 > hg children -r $i
68 > hg children -r $i
69 > done
69 > done
70 hg children -r null
70 hg children -r null
71 changeset: 0:4df8521a7374
71 changeset: 0:4df8521a7374
72 user: test
72 user: test
73 date: Thu Jan 01 00:00:00 1970 +0000
73 date: Thu Jan 01 00:00:00 1970 +0000
74 summary: 0
74 summary: 0
75
75
76 changeset: 3:e2962852269d
76 changeset: 3:e2962852269d
77 tag: tip
77 tag: tip
78 parent: -1:000000000000
78 parent: -1:000000000000
79 user: test
79 user: test
80 date: Thu Jan 01 00:00:03 1970 +0000
80 date: Thu Jan 01 00:00:03 1970 +0000
81 summary: 3
81 summary: 3
82
82
83 hg children -r 0
83 hg children -r 0
84 changeset: 1:708c093edef0
84 changeset: 1:708c093edef0
85 user: test
85 user: test
86 date: Thu Jan 01 00:00:01 1970 +0000
86 date: Thu Jan 01 00:00:01 1970 +0000
87 summary: 1
87 summary: 1
88
88
89 hg children -r 1
89 hg children -r 1
90 changeset: 2:8f5eea5023c2
90 changeset: 2:8f5eea5023c2
91 user: test
91 user: test
92 date: Thu Jan 01 00:00:02 1970 +0000
92 date: Thu Jan 01 00:00:02 1970 +0000
93 summary: 2
93 summary: 2
94
94
95 hg children -r 2
95 hg children -r 2
96 hg children -r 3
96 hg children -r 3
97
97
98 hg children -r 0 file0 (should be 2)
98 hg children -r 0 file0 (should be 2)
99 $ hg children -r 0 file0
99 $ hg children -r 0 file0
100 changeset: 2:8f5eea5023c2
100 changeset: 2:8f5eea5023c2
101 user: test
101 user: test
102 date: Thu Jan 01 00:00:02 1970 +0000
102 date: Thu Jan 01 00:00:02 1970 +0000
103 summary: 2
103 summary: 2
104
104
105
105
106 hg children -r 1 file0 (should be 2)
106 hg children -r 1 file0 (should be 2)
107 $ hg children -r 1 file0
107 $ hg children -r 1 file0
108 changeset: 2:8f5eea5023c2
108 changeset: 2:8f5eea5023c2
109 user: test
109 user: test
110 date: Thu Jan 01 00:00:02 1970 +0000
110 date: Thu Jan 01 00:00:02 1970 +0000
111 summary: 2
111 summary: 2
112
112
113
113
114 $ hg co 0
114 $ hg co 0
115 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
116
116
117 hg children file0 at revision 0 (should be 2)
117 hg children file0 at revision 0 (should be 2)
118 $ hg children file0
118 $ hg children file0
119 changeset: 2:8f5eea5023c2
119 changeset: 2:8f5eea5023c2
120 user: test
120 user: test
121 date: Thu Jan 01 00:00:02 1970 +0000
121 date: Thu Jan 01 00:00:02 1970 +0000
122 summary: 2
122 summary: 2
123
123
124
124
125 should be compatible with templater (don't pass fctx to displayer)
126 $ hg children file0 -Tdefault
127 changeset: 2:8f5eea5023c2
128 user: test
129 date: Thu Jan 01 00:00:02 1970 +0000
130 summary: 2
131
132
125 $ cd ..
133 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now