[PATCH STABLE] log: fix crash and bad filematcher lookup by -fr'wdir()' PATH

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH STABLE] log: fix crash and bad filematcher lookup by -fr'wdir()' PATH

Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara <[hidden email]>
# Date 1599802865 -32400
#      Fri Sep 11 14:41:05 2020 +0900
# Branch stable
# Node ID d4a83a7d132ace8e3cfe366d9ef56fb99f26ffab
# Parent  81b4e7c866ec83ac73e71ab791cb54ffcdfcd889
log: fix crash and bad filematcher lookup by -fr'wdir()' PATH

"-fr'wdir()' ADDED-PATH" is still wrong, which will be fixed in default
branch.

diff --git a/mercurial/dagop.py b/mercurial/dagop.py
--- a/mercurial/dagop.py
+++ b/mercurial/dagop.py
@@ -17,6 +17,7 @@ from . import (
     node,
     patch,
     pycompat,
+    scmutil,
     smartset,
 )
 
@@ -90,7 +91,7 @@ def filectxancestors(fctxs, followfirst=
     visitheap = []
 
     def addvisit(fctx):
-        rev = fctx.rev()
+        rev = scmutil.intrev(fctx)
         if rev not in visit:
             visit[rev] = set()
             heapq.heappush(visitheap, -rev)  # max heap
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -753,7 +753,7 @@ def _fileancestors(repo, revs, match, fo
     fcache = {}
 
     def filematcher(ctx):
-        return scmutil.matchfiles(repo, fcache.get(ctx.rev(), []))
+        return scmutil.matchfiles(repo, fcache.get(scmutil.intrev(ctx), []))
 
     def revgen():
         for rev, cs in dagop.filectxancestors(fctxs, followfirst=followfirst):
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -2263,6 +2263,51 @@ dirty:
    }
   ]
 
+follow files from wdir
+
+  $ hg cp d1/f1 f1-copy
+  $ hg stat --all
+  M d1/f1
+  A d1/f2
+  A f1-copy
+    d1/f1
+  R .d6/f1
+  C D2/f1
+  C D3.i/f1
+  C d4.hg/f1
+  C d5.d/f1
+
+  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d5.d/f1
+  == 2147483647 ==
+  
+  == 0 ==
+   d5.d/f1 |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
+
+  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d1/f1
+  == 2147483647 ==
+   d1/f1 |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
+  == 0 ==
+   d1/f1 |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
+
+ BROKEN: added file should exist in wdir
+  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d1/f2
+  abort: cannot follow nonexistent file: "d1/f2"
+  [255]
+
+ BROKEN: copied file should exist in wdir
+  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat f1-copy
+  abort: cannot follow nonexistent file: "f1-copy"
+  [255]
+
+  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat notfound
+  notfound: $ENOENT$
+
   $ hg revert -aqC
 
 Check that adding an arbitrary name shows up in log automatically
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH STABLE] log: fix crash and bad filematcher lookup by -fr'wdir()' PATH

Pierre-Yves David-2
This looks good to me.

On 9/11/20 10:12 AM, Yuya Nishihara wrote:

> # HG changeset patch
> # User Yuya Nishihara <[hidden email]>
> # Date 1599802865 -32400
> #      Fri Sep 11 14:41:05 2020 +0900
> # Branch stable
> # Node ID d4a83a7d132ace8e3cfe366d9ef56fb99f26ffab
> # Parent  81b4e7c866ec83ac73e71ab791cb54ffcdfcd889
> log: fix crash and bad filematcher lookup by -fr'wdir()' PATH
>
> "-fr'wdir()' ADDED-PATH" is still wrong, which will be fixed in default
> branch.
>
> diff --git a/mercurial/dagop.py b/mercurial/dagop.py
> --- a/mercurial/dagop.py
> +++ b/mercurial/dagop.py
> @@ -17,6 +17,7 @@ from . import (
>       node,
>       patch,
>       pycompat,
> +    scmutil,
>       smartset,
>   )
>  
> @@ -90,7 +91,7 @@ def filectxancestors(fctxs, followfirst=
>       visitheap = []
>  
>       def addvisit(fctx):
> -        rev = fctx.rev()
> +        rev = scmutil.intrev(fctx)
>           if rev not in visit:
>               visit[rev] = set()
>               heapq.heappush(visitheap, -rev)  # max heap
> diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
> --- a/mercurial/logcmdutil.py
> +++ b/mercurial/logcmdutil.py
> @@ -753,7 +753,7 @@ def _fileancestors(repo, revs, match, fo
>       fcache = {}
>  
>       def filematcher(ctx):
> -        return scmutil.matchfiles(repo, fcache.get(ctx.rev(), []))
> +        return scmutil.matchfiles(repo, fcache.get(scmutil.intrev(ctx), []))
>  
>       def revgen():
>           for rev, cs in dagop.filectxancestors(fctxs, followfirst=followfirst):
> diff --git a/tests/test-log.t b/tests/test-log.t
> --- a/tests/test-log.t
> +++ b/tests/test-log.t
> @@ -2263,6 +2263,51 @@ dirty:
>      }
>     ]
>  
> +follow files from wdir
> +
> +  $ hg cp d1/f1 f1-copy
> +  $ hg stat --all
> +  M d1/f1
> +  A d1/f2
> +  A f1-copy
> +    d1/f1
> +  R .d6/f1
> +  C D2/f1
> +  C D3.i/f1
> +  C d4.hg/f1
> +  C d5.d/f1
> +
> +  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d5.d/f1
> +  == 2147483647 ==
> +
> +  == 0 ==
> +   d5.d/f1 |  1 +
> +   1 files changed, 1 insertions(+), 0 deletions(-)
> +
> +
> +  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d1/f1
> +  == 2147483647 ==
> +   d1/f1 |  1 +
> +   1 files changed, 1 insertions(+), 0 deletions(-)
> +
> +  == 0 ==
> +   d1/f1 |  1 +
> +   1 files changed, 1 insertions(+), 0 deletions(-)
> +
> +
> + BROKEN: added file should exist in wdir
> +  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d1/f2
> +  abort: cannot follow nonexistent file: "d1/f2"
> +  [255]
> +
> + BROKEN: copied file should exist in wdir
> +  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat f1-copy
> +  abort: cannot follow nonexistent file: "f1-copy"
> +  [255]
> +
> +  $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat notfound
> +  notfound: $ENOENT$
> +
>     $ hg revert -aqC
>  
>   Check that adding an arbitrary name shows up in log automatically
> _______________________________________________
> Mercurial-devel mailing list
> [hidden email]
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

--
Pierre-Yves David
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel