Show More
@@ -1,82 +1,83 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 |
|
17 | |||
18 | from mercurial.i18n import _ |
|
18 | from mercurial.i18n import _ | |
19 | from mercurial import ( |
|
19 | from mercurial import ( | |
20 | cmdutil, |
|
20 | cmdutil, | |
21 | logcmdutil, |
|
21 | logcmdutil, | |
22 | pycompat, |
|
22 | pycompat, | |
23 | registrar, |
|
23 | registrar, | |
24 | ) |
|
24 | ) | |
25 |
|
25 | |||
26 | templateopts = cmdutil.templateopts |
|
26 | templateopts = cmdutil.templateopts | |
27 |
|
27 | |||
28 | cmdtable = {} |
|
28 | cmdtable = {} | |
29 | command = registrar.command(cmdtable) |
|
29 | command = registrar.command(cmdtable) | |
30 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
30 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
31 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
31 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
32 | # be specifying the version(s) of Mercurial they are tested with, or |
|
32 | # be specifying the version(s) of Mercurial they are tested with, or | |
33 | # leave the attribute unspecified. |
|
33 | # leave the attribute unspecified. | |
34 | testedwith = b'ships-with-hg-core' |
|
34 | testedwith = b'ships-with-hg-core' | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | @command( |
|
37 | @command( | |
38 | b'children', |
|
38 | b'children', | |
39 | [ |
|
39 | [ | |
40 | ( |
|
40 | ( | |
41 | b'r', |
|
41 | b'r', | |
42 | b'rev', |
|
42 | b'rev', | |
43 | b'.', |
|
43 | b'.', | |
44 | _(b'show children of the specified revision'), |
|
44 | _(b'show children of the specified revision'), | |
45 | _(b'REV'), |
|
45 | _(b'REV'), | |
46 | ), |
|
46 | ), | |
47 | ] |
|
47 | ] | |
48 | + templateopts, |
|
48 | + templateopts, | |
49 | _(b'hg children [-r REV] [FILE]'), |
|
49 | _(b'hg children [-r REV] [FILE]'), | |
50 | helpcategory=command.CATEGORY_CHANGE_NAVIGATION, |
|
50 | helpcategory=command.CATEGORY_CHANGE_NAVIGATION, | |
51 | inferrepo=True, |
|
51 | inferrepo=True, | |
52 | ) |
|
52 | ) | |
53 | def children(ui, repo, file_=None, **opts): |
|
53 | def children(ui, repo, file_=None, **opts): | |
54 | """show the children of the given or working directory revision |
|
54 | """show the children of the given or working directory revision | |
55 |
|
55 | |||
56 | Print the children of the working directory's revisions. If a |
|
56 | Print the children of the working directory's revisions. If a | |
57 | revision is given via -r/--rev, the children of that revision will |
|
57 | revision is given via -r/--rev, the children of that revision will | |
58 | be printed. If a file argument is given, revision in which the |
|
58 | be printed. If a file argument is given, revision in which the | |
59 | file was last changed (after the working directory revision or the |
|
59 | file was last changed (after the working directory revision or the | |
60 | argument to --rev if given) is printed. |
|
60 | argument to --rev if given) is printed. | |
61 |
|
61 | |||
62 | Please use :hg:`log` instead:: |
|
62 | Please use :hg:`log` instead:: | |
63 |
|
63 | |||
64 | hg children => hg log -r "children(.)" |
|
64 | hg children => hg log -r "children(.)" | |
65 | hg children -r REV => hg log -r "children(REV)" |
|
65 | hg children -r REV => hg log -r "children(REV)" | |
66 |
|
66 | |||
67 | See :hg:`help log` and :hg:`help revsets.children`. |
|
67 | See :hg:`help log` and :hg:`help revsets.children`. | |
68 |
|
68 | |||
69 | """ |
|
69 | """ | |
70 | opts = pycompat.byteskwargs(opts) |
|
70 | rev = opts.get('rev') | |
71 | rev = opts.get(b'rev') |
|
|||
72 | ctx = logcmdutil.revsingle(repo, rev) |
|
71 | ctx = logcmdutil.revsingle(repo, rev) | |
73 | if file_: |
|
72 | if file_: | |
74 | fctx = repo.filectx(file_, changeid=ctx.rev()) |
|
73 | fctx = repo.filectx(file_, changeid=ctx.rev()) | |
75 | childctxs = [fcctx.changectx() for fcctx in fctx.children()] |
|
74 | childctxs = [fcctx.changectx() for fcctx in fctx.children()] | |
76 | else: |
|
75 | else: | |
77 | childctxs = ctx.children() |
|
76 | childctxs = ctx.children() | |
78 |
|
77 | |||
79 |
displayer = logcmdutil.changesetdisplayer( |
|
78 | displayer = logcmdutil.changesetdisplayer( | |
|
79 | ui, repo, pycompat.byteskwargs(opts) | |||
|
80 | ) | |||
80 | for cctx in childctxs: |
|
81 | for cctx in childctxs: | |
81 | displayer.show(cctx) |
|
82 | displayer.show(cctx) | |
82 | displayer.close() |
|
83 | displayer.close() |
General Comments 0
You need to be logged in to leave comments.
Login now