manifest: move checkforbidden to module-level
There's no need for this function to be nested, so let's just define
it once instead of every time manifest.add() gets called.
--- a/mercurial/manifest.py Fri Sep 05 11:37:44 2014 -0700
+++ b/mercurial/manifest.py Thu Aug 07 09:46:05 2014 -0400
@@ -40,6 +40,15 @@
def flagsdiff(self, d2):
return dicthelpers.diff(self._flags, d2._flags, "")
+
+def checkforbidden(l):
+ """Check filenames for illegal characters."""
+ for f in l:
+ if '\n' in f or '\r' in f:
+ raise error.RevlogError(
+ _("'\\n' and '\\r' disallowed in filenames: %r") % f)
+
+
class manifest(revlog.revlog):
def __init__(self, opener):
# we expect to deal with not more than four revs at a time,
@@ -152,12 +161,6 @@
+ content for start, end, content in x)
return deltatext, newaddlist
- def checkforbidden(l):
- for f in l:
- if '\n' in f or '\r' in f:
- raise error.RevlogError(
- _("'\\n' and '\\r' disallowed in filenames: %r") % f)
-
# if we're using the cache, make sure it is valid and
# parented by the same node we're diffing against
if not (changed and p1 and (p1 in self._mancache)):