log: do not accept string-matcher pattern as -u/-b/-B parameter
authorYuya Nishihara <yuya@tcha.org>
Tue, 01 Dec 2020 20:22:24 +0900
changeset 46042 1bf2b44c4007
parent 46041 9c0db3671008
child 46043 024f90fc01b5
log: do not accept string-matcher pattern as -u/-b/-B parameter I'm pretty sure this is a bug introduced after we've switched the filtering backend to revset matcher.
mercurial/logcmdutil.py
mercurial/scmutil.py
tests/test-glog-beautifygraph.t
tests/test-glog.t
tests/test-log-bookmark.t
tests/test-log.t
--- a/mercurial/logcmdutil.py	Tue Dec 01 19:32:36 2020 +0900
+++ b/mercurial/logcmdutil.py	Tue Dec 01 20:22:24 2020 +0900
@@ -898,13 +898,13 @@
 def _makerevset(repo, wopts, slowpath):
     """Return a revset string built from log options and file patterns"""
     opts = {
-        b'branch': [repo.lookupbranch(b) for b in wopts.branches],
+        b'branch': [b'literal:' + repo.lookupbranch(b) for b in wopts.branches],
         b'date': wopts.date,
         b'keyword': wopts.keywords,
         b'no_merges': wopts.no_merges,
         b'only_merges': wopts.only_merges,
         b'prune': wopts.prune_ancestors,
-        b'user': wopts.users,
+        b'user': [b'literal:' + v for v in wopts.users],
     }
 
     if wopts.filter_revisions_by_pats and slowpath:
--- a/mercurial/scmutil.py	Tue Dec 01 19:32:36 2020 +0900
+++ b/mercurial/scmutil.py	Tue Dec 01 20:22:24 2020 +0900
@@ -2310,6 +2310,7 @@
 def format_bookmark_revspec(mark):
     """Build a revset expression to select revisions reachable by a given
     bookmark"""
+    mark = b'literal:' + mark
     return revsetlang.formatspec(
         b"ancestors(bookmark(%s)) - "
         b"ancestors(head() and not bookmark(%s)) - "
--- a/tests/test-glog-beautifygraph.t	Tue Dec 01 19:32:36 2020 +0900
+++ b/tests/test-glog-beautifygraph.t	Tue Dec 01 20:22:24 2020 +0900
@@ -1588,19 +1588,19 @@
     (list
       (func
         (symbol 'user')
-        (string 'test'))
+        (string 'literal:test'))
       (func
         (symbol 'user')
-        (string 'not-a-user'))))
+        (string 'literal:not-a-user'))))
   <filteredset
     <spanset- 0:37>,
     <addset
       <filteredset
         <fullreposet+ 0:37>,
-        <user 'test'>>,
+        <user 'literal:test'>>,
       <filteredset
         <fullreposet+ 0:37>,
-        <user 'not-a-user'>>>>
+        <user 'literal:not-a-user'>>>>
   $ testlog -b not-a-branch
   abort: unknown revision 'not-a-branch'
   abort: unknown revision 'not-a-branch'
@@ -1611,28 +1611,28 @@
     (list
       (func
         (symbol 'branch')
-        (string 'default'))
+        (string 'literal:default'))
       (or
         (list
           (func
             (symbol 'branch')
-            (string 'branch'))
+            (string 'literal:branch'))
           (func
             (symbol 'branch')
-            (string 'branch'))))))
+            (string 'literal:branch'))))))
   <filteredset
     <spanset- 0:37>,
     <addset
       <filteredset
         <fullreposet+ 0:37>,
-        <branch 'default'>>,
+        <branch 'literal:default'>>,
       <addset
         <filteredset
           <fullreposet+ 0:37>,
-          <branch 'branch'>>,
+          <branch 'literal:branch'>>,
         <filteredset
           <fullreposet+ 0:37>,
-          <branch 'branch'>>>>>
+          <branch 'literal:branch'>>>>>
   $ testlog -k expand -k merge
   []
   (or
--- a/tests/test-glog.t	Tue Dec 01 19:32:36 2020 +0900
+++ b/tests/test-glog.t	Tue Dec 01 20:22:24 2020 +0900
@@ -1438,19 +1438,19 @@
     (list
       (func
         (symbol 'user')
-        (string 'test'))
+        (string 'literal:test'))
       (func
         (symbol 'user')
-        (string 'not-a-user'))))
+        (string 'literal:not-a-user'))))
   <filteredset
     <spanset- 0:37>,
     <addset
       <filteredset
         <fullreposet+ 0:37>,
-        <user 'test'>>,
+        <user 'literal:test'>>,
       <filteredset
         <fullreposet+ 0:37>,
-        <user 'not-a-user'>>>>
+        <user 'literal:not-a-user'>>>>
   $ testlog -b not-a-branch
   abort: unknown revision 'not-a-branch'
   abort: unknown revision 'not-a-branch'
@@ -1461,28 +1461,28 @@
     (list
       (func
         (symbol 'branch')
-        (string 'default'))
+        (string 'literal:default'))
       (or
         (list
           (func
             (symbol 'branch')
-            (string 'branch'))
+            (string 'literal:branch'))
           (func
             (symbol 'branch')
-            (string 'branch'))))))
+            (string 'literal:branch'))))))
   <filteredset
     <spanset- 0:37>,
     <addset
       <filteredset
         <fullreposet+ 0:37>,
-        <branch 'default'>>,
+        <branch 'literal:default'>>,
       <addset
         <filteredset
           <fullreposet+ 0:37>,
-          <branch 'branch'>>,
+          <branch 'literal:branch'>>,
         <filteredset
           <fullreposet+ 0:37>,
-          <branch 'branch'>>>>>
+          <branch 'literal:branch'>>>>>
   $ testlog -k expand -k merge
   []
   (or
--- a/tests/test-log-bookmark.t	Tue Dec 01 19:32:36 2020 +0900
+++ b/tests/test-log-bookmark.t	Tue Dec 01 20:22:24 2020 +0900
@@ -190,3 +190,9 @@
   $ hg log -B unknown
   abort: bookmark 'unknown' does not exist
   [255]
+
+Shouldn't accept string-matcher syntax:
+
+  $ hg log -B 're:.*'
+  abort: bookmark 're:.*' does not exist
+  [255]
--- a/tests/test-log.t	Tue Dec 01 19:32:36 2020 +0900
+++ b/tests/test-log.t	Tue Dec 01 20:22:24 2020 +0900
@@ -1378,6 +1378,14 @@
   1 k1
   0 k0
 
+ log -b/-u/-k shouldn't accept string-matcher syntax:
+
+  $ hg log -b 're:.*'
+  abort: unknown revision 're:.*'
+  [255]
+  $ hg log -k 're:.*'
+  $ hg log -u 're:.*'
+
  log FILE in ascending order, against dagrange:
 
   $ hg log -r1:: -T '{rev} {files}\n' f1 f2