Patchwork [6,of,6] log: fix --follow null parent not to include revision 0

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 6, 2015, 2:41 p.m.
Message ID <5d600a4458b379119cf8.1423233662@mimosa>
Download mbox | patch
Permalink /patch/7714/
State Accepted
Commit c260887cdbcd5396bae08f8b1f61a14be5bc283b
Headers show

Comments

Yuya Nishihara - Feb. 6, 2015, 2:41 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1423227219 -32400
#      Fri Feb 06 21:53:39 2015 +0900
# Node ID 5d600a4458b379119cf87e22501d05e18507c4e8
# Parent  6395a12bd90b4318639a413fd99521c7277d8b7d
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().
Matt Mackall - Feb. 6, 2015, 10:47 p.m.
On Fri, 2015-02-06 at 23:41 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1423227219 -32400
> #      Fri Feb 06 21:53:39 2015 +0900
> # Node ID 5d600a4458b379119cf87e22501d05e18507c4e8
> # Parent  6395a12bd90b4318639a413fd99521c7277d8b7d
> log: fix --follow null parent not to include revision 0

Queued for default, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1821,6 +1821,8 @@  def _logrevs(repo, opts):
     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:
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1767,6 +1767,13 @@  Test --follow and multiple files
   nodetag 1
   nodetag 0
 
+Test --follow null parent
+
+  $ hg up -q null
+  $ testlog -f
+  []
+  []
+
 Test --follow-first
 
   $ hg up -q 3
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -82,6 +82,10 @@  follow
   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
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -672,10 +672,17 @@  log -f -r null
   
 
 
+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)