This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8fd0a9e2d7e9: narrow: make restrictpatterns a little more 
idiomatic (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2192?vs=5508&id=5562

REVISION DETAIL
  https://phab.mercurial-scm.org/D2192

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowspec.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowspec.py b/hgext/narrow/narrowspec.py
--- a/hgext/narrow/narrowspec.py
+++ b/hgext/narrow/narrowspec.py
@@ -153,35 +153,34 @@
         repo = share._getsrcrepo(repo)
     repo.vfs.write(FILENAME, spec)
 
-def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes,
-                     invalid_includes=None):
+def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes):
     r""" Restricts the patterns according to repo settings,
     results in a logical AND operation
 
     :param req_includes: requested includes
     :param req_excludes: requested excludes
     :param repo_includes: repo includes
     :param repo_excludes: repo excludes
-    :param invalid_includes: an array to collect invalid includes
-    :return: include and exclude patterns
+    :return: include patterns, exclude patterns, and invalid include patterns.
 
     >>> restrictpatterns({'f1','f2'}, {}, ['f1'], [])
-    (set(['f1']), {})
+    (set(['f1']), {}, [])
     >>> restrictpatterns({'f1'}, {}, ['f1','f2'], [])
-    (set(['f1']), {})
+    (set(['f1']), {}, [])
     >>> restrictpatterns({'f1/fc1', 'f3/fc3'}, {}, ['f1','f2'], [])
-    (set(['f1/fc1']), {})
+    (set(['f1/fc1']), {}, [])
     >>> restrictpatterns({'f1_fc1'}, {}, ['f1','f2'], [])
-    ([], set(['path:.']))
+    ([], set(['path:.']), [])
     >>> restrictpatterns({'f1/../f2/fc2'}, {}, ['f1','f2'], [])
-    (set(['f2/fc2']), {})
+    (set(['f2/fc2']), {}, [])
     >>> restrictpatterns({'f1/../f3/fc3'}, {}, ['f1','f2'], [])
-    ([], set(['path:.']))
+    ([], set(['path:.']), [])
     >>> restrictpatterns({'f1/$non_exitent_var'}, {}, ['f1','f2'], [])
-    (set(['f1/$non_exitent_var']), {})
+    (set(['f1/$non_exitent_var']), {}, [])
     """
     res_excludes = set(req_excludes)
     res_excludes.update(repo_excludes)
+    invalid_includes = []
     if not req_includes:
         res_includes = set(repo_includes)
     elif 'path:.' not in repo_includes:
@@ -197,12 +196,12 @@
                     valid = True
                     res_includes.append(req_include)
                     break
-            if not valid and invalid_includes is not None:
+            if not valid:
                 invalid_includes.append(req_include)
         if len(res_includes) == 0:
             res_excludes = {'path:.'}
         else:
             res_includes = set(res_includes)
     else:
         res_includes = set(req_includes)
-    return res_includes, res_excludes
+    return res_includes, res_excludes, invalid_includes
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -134,7 +134,7 @@
         repo_includes, repo_excludes = repo.narrowpats
         includes = set(opts.get('include', []))
         excludes = set(opts.get('exclude', []))
-        includes, excludes = narrowspec.restrictpatterns(
+        includes, excludes, unused_invalid = narrowspec.restrictpatterns(
             includes, excludes, repo_includes, repo_excludes)
         if includes:
             opts['include'] = includes
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -346,10 +346,8 @@
     req_includes = set(kwargs.get('includepats', []))
     req_excludes = set(kwargs.get('excludepats', []))
 
-    invalid_includes = []
-    req_includes, req_excludes = narrowspec.restrictpatterns(
-        req_includes, req_excludes,
-        user_includes, user_excludes, invalid_includes)
+    req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns(
+        req_includes, req_excludes, user_includes, user_excludes)
 
     if invalid_includes:
         raise error.Abort(



To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to