changeset 24064:c260887cdbcd

log: fix --follow null parent not to include revision 0 If p1 is null, ':.' is translated as '0:null'. But rangeset can't handle null, only revision 0 was visible. Because 'null' should not be listed implicitly, "log --follow" (without -r) should be empty if p1 is null. Test of "hg grep -f" is added for cmdutil.walkchangerevs().
author Yuya Nishihara <yuya@tcha.org>
date Fri, 06 Feb 2015 21:53:39 +0900
parents c98fa0ca4678
children d8837ad682dd
files mercurial/cmdutil.py tests/test-glog.t tests/test-grep.t tests/test-log.t
diffstat 4 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Feb 06 00:22:20 2015 +0900
+++ b/mercurial/cmdutil.py	Fri Feb 06 21:53:39 2015 +0900
@@ -1821,6 +1821,8 @@
     follow = opts.get('follow') or opts.get('follow_first')
     if opts.get('rev'):
         revs = scmutil.revrange(repo, opts['rev'])
+    elif follow and repo.dirstate.p1() == nullid:
+        revs = revset.baseset()
     elif follow:
         revs = repo.revs('reverse(:.)')
     else:
--- a/tests/test-glog.t	Fri Feb 06 00:22:20 2015 +0900
+++ b/tests/test-glog.t	Fri Feb 06 21:53:39 2015 +0900
@@ -1767,6 +1767,13 @@
   nodetag 1
   nodetag 0
 
+Test --follow null parent
+
+  $ hg up -q null
+  $ testlog -f
+  []
+  []
+
 Test --follow-first
 
   $ hg up -q 3
--- a/tests/test-grep.t	Fri Feb 06 00:22:20 2015 +0900
+++ b/tests/test-grep.t	Fri Feb 06 21:53:39 2015 +0900
@@ -82,6 +82,10 @@
   port:1:2:+:eggs:export
   port:0:1:+:spam:import
 
+  $ hg up -q null
+  $ hg grep -f port
+  [1]
+
   $ cd ..
   $ hg init t2
   $ cd t2
--- a/tests/test-log.t	Fri Feb 06 00:22:20 2015 +0900
+++ b/tests/test-log.t	Fri Feb 06 21:53:39 2015 +0900
@@ -672,10 +672,17 @@
   
 
 
+log -f with null parent
+
+  $ hg up -C null
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg log -f
+
+
 log -r .  with two parents
 
   $ hg up -C 3
-  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge tip
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)