[PATCH] minifileset: allow 'path:' patterns to have an explicit trailing slash
Matt Harbison
mharbison72 at gmail.com
Tue Feb 13 03:17:35 UTC 2018
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1518488713 18000
# Mon Feb 12 21:25:13 2018 -0500
# Node ID e99e6917138593d2dddf7e0f5506dbd3f6c87743
# Parent 9b5df6e19a4f308e14703a8136cd0530c1e1d1a9
minifileset: allow 'path:' patterns to have an explicit trailing slash
We allow for it on the command line, with `hg status`, for example. I thought
that I copied this "n.startswith(p) and (len(n) == pl or n[pl] == '/')" pattern
from somewhere, but I don't see it now.
diff --git a/mercurial/minifileset.py b/mercurial/minifileset.py
--- a/mercurial/minifileset.py
+++ b/mercurial/minifileset.py
@@ -26,7 +26,7 @@
raise error.ParseError(_('reserved character: %s') % c)
return lambda n, s: n.endswith(ext)
elif name.startswith('path:'): # directory or full path test
- p = name[5:] # prefix
+ p = name[5:] if name[-1] != '/' else name[5:-1] # prefix
pl = len(p)
f = lambda n, s: n.startswith(p) and (len(n) == pl or n[pl] == '/')
return f
diff --git a/tests/test-minifileset.py b/tests/test-minifileset.py
--- a/tests/test-minifileset.py
+++ b/tests/test-minifileset.py
@@ -25,6 +25,8 @@
check('"path:a" & (**.b | **.c)', [('a/b.b', 0), ('a/c.c', 0)], [('b/c.c', 0)])
check('(path:a & **.b) | **.c',
[('a/b.b', 0), ('a/c.c', 0), ('b/c.c', 0)], [])
+check('path:a/', [('a/b.b', 0), ('a/c.c', 0)], [('ab/c.c', 0)])
+check('path:a', [('a/b.b', 0), ('a/c.c', 0)], [('ab/c.c', 0)])
check('**.bin - size("<20B")', [('b.bin', 21)], [('a.bin', 11), ('b.txt', 21)])
More information about the Mercurial-devel
mailing list