children: support specifying revision by revset
Same reason as the previous patch.
Differential Revision: https://phab.mercurial-scm.org/D3085
--- a/hgext/children.py Wed Apr 04 15:08:26 2018 -0700
+++ b/hgext/children.py Thu Apr 05 14:21:37 2018 +0530
@@ -22,6 +22,7 @@
logcmdutil,
pycompat,
registrar,
+ scmutil,
)
templateopts = cmdutil.templateopts
@@ -59,11 +60,11 @@
"""
opts = pycompat.byteskwargs(opts)
rev = opts.get('rev')
+ ctx = scmutil.revsingle(repo, rev)
if file_:
- fctx = repo.filectx(file_, changeid=rev)
+ fctx = repo.filectx(file_, changeid=ctx.rev())
childctxs = [fcctx.changectx() for fcctx in fctx.children()]
else:
- ctx = repo[rev]
childctxs = ctx.children()
displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
--- a/tests/test-children.t Wed Apr 04 15:08:26 2018 -0700
+++ b/tests/test-children.t Thu Apr 05 14:21:37 2018 +0530
@@ -63,11 +63,11 @@
hg children at revision 2 (other head)
$ hg children
- $ for i in null 0 1 2 3; do
- > echo "hg children -r $i"
+ $ for i in null 0 1 2 3 '2^'; do
+ > echo "hg children -r '$i'"
> hg children -r $i
> done
- hg children -r null
+ hg children -r 'null'
changeset: 0:4df8521a7374
user: test
date: Thu Jan 01 00:00:00 1970 +0000
@@ -80,20 +80,26 @@
date: Thu Jan 01 00:00:03 1970 +0000
summary: 3
- hg children -r 0
+ hg children -r '0'
changeset: 1:708c093edef0
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: 1
- hg children -r 1
+ hg children -r '1'
changeset: 2:8f5eea5023c2
user: test
date: Thu Jan 01 00:00:02 1970 +0000
summary: 2
- hg children -r 2
- hg children -r 3
+ hg children -r '2'
+ hg children -r '3'
+ hg children -r '2^'
+ changeset: 2:8f5eea5023c2
+ user: test
+ date: Thu Jan 01 00:00:02 1970 +0000
+ summary: 2
+
hg children -r 0 file0 (should be 2)
$ hg children -r 0 file0