manifest: move checkforbidden to module-level
authorAugie Fackler <raf@durin42.com>
Thu, 07 Aug 2014 09:46:05 -0400
changeset 22408 dc97e04c12ad
parent 22407 d259322a394b
child 22409 8f09b785b59b
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.
mercurial/manifest.py
--- 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)):