Patchwork [2,of,8] fileset: raise ProgrammingError for bad existing() calls

login
register
mail settings
Submitter Yuya Nishihara
Date June 16, 2018, 11:06 a.m.
Message ID <63809ae9c19bbec2df4b.1529147168@mimosa>
Download mbox | patch
Permalink /patch/32188/
State Accepted
Headers show

Comments

Yuya Nishihara - June 16, 2018, 11:06 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1529136005 -32400
#      Sat Jun 16 17:00:05 2018 +0900
# Node ID 63809ae9c19bbec2df4bed0003d2347ddf5c3ea1
# Parent  5cb39a368c803683fd8bc944480486a618ab785a
fileset: raise ProgrammingError for bad existing() calls

And glob out Py2/3 difference.

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -566,7 +566,8 @@  class matchctx(object):
     def filter(self, files):
         return [f for f in files if f in self.subset]
     def existing(self):
-        assert self._existingenabled, 'unexpected existing() invocation'
+        if not self._existingenabled:
+            raise error.ProgrammingError('unexpected existing() invocation')
         if self._status is not None:
             removed = set(self._status[3])
             unknown = set(self._status[4] + self._status[5])
diff --git a/tests/test-fileset.t b/tests/test-fileset.t
--- a/tests/test-fileset.t
+++ b/tests/test-fileset.t
@@ -446,7 +446,7 @@  Test detection of unintentional 'matchct
   > EOF
 
   $ fileset 'existingcaller()' 2>&1 | tail -1
-  AssertionError: unexpected existing() invocation
+  *ProgrammingError: *unexpected existing() invocation* (glob)
 
 Test 'revs(...)'
 ================