changeset 37357:7c8524efd847

children: support specifying revision by revset Same reason as the previous patch. Differential Revision: https://phab.mercurial-scm.org/D3085
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 05 Apr 2018 14:21:37 +0530
parents 004e5c5821b2
children d5e1678026fd
files hgext/children.py tests/test-children.t
diffstat 2 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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