diff tests/test-log.t @ 46549:9842c00f0252 stable

log: fix handling of root (or empty) path provided by matcher (issue6478) Since 27d6956d386b "match: use '' instead of '.' for root directory", '.' should be translated to ''. We can't blame repo.file() about this because an empty string is invalid as a file path, but I found at least two callers (_makematcher() and revset.filelog()) would crash because of this path[0]. So let's make repo.file() accept an empty string. path[0] == b'/' wouldn't work on Python 3 anyways.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 02 Feb 2021 20:20:17 +0900
parents 1bf2b44c4007
children 6f4a481f182a
line wrap: on
line diff
--- a/tests/test-log.t	Thu Feb 25 15:18:00 2021 +0530
+++ b/tests/test-log.t	Tue Feb 02 20:20:17 2021 +0900
@@ -102,6 +102,41 @@
   summary:     c
   
 
+log empty path (or repo root) of slow path shouldn't crash (issue6478)
+
+  $ hg log -ql1 '' inexistent
+  4:7e4639b4691b
+  $ hg log -ql1 . inexistent
+  4:7e4639b4691b
+  $ hg log -ql1 "`pwd`" inexistent
+  4:7e4639b4691b
+
+  $ hg log -ql1 '' e
+  4:7e4639b4691b
+  $ hg log -ql1 . e
+  4:7e4639b4691b
+  $ hg log -ql1 "`pwd`" e
+  4:7e4639b4691b
+
+log -f empty path (or repo root) shouldn't crash
+
+  $ hg log -qfl1 '' inexistent
+  abort: cannot follow file not in parent revision: "inexistent"
+  [255]
+  $ hg log -qfl1 . inexistent
+  abort: cannot follow file not in parent revision: "inexistent"
+  [255]
+  $ hg log -qfl1 "`pwd`" inexistent
+  abort: cannot follow file not in parent revision: "inexistent"
+  [255]
+
+  $ hg log -qfl1 '' e
+  4:7e4639b4691b
+  $ hg log -qfl1 . e
+  4:7e4639b4691b
+  $ hg log -qfl1 "`pwd`" e
+  4:7e4639b4691b
+
 -X, with explicit path
 
   $ hg log a -X a