diff mercurial/sparse.py @ 33370:482320104672

sparse: refactor activeprofiles into a generic function (API) activeprofiles() is a special case of a more generic function. Furthermore, that generic function is essentially already implemented inline in the sparse extension. So, refactor activeprofiles() to a generic activeconfig(). Change the only consumer of activeprofiles() to use it. And have the inline implementation in the sparse extension use it.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 08 Jul 2017 14:01:32 -0700
parents ccb3e5399921
children c6415195fa78
line wrap: on
line diff
--- a/mercurial/sparse.py	Fri Jul 07 15:11:11 2017 -0400
+++ b/mercurial/sparse.py	Sat Jul 08 14:01:32 2017 -0700
@@ -124,15 +124,26 @@
 
     return includes, excludes, profiles
 
-def activeprofiles(repo):
+def activeconfig(repo):
+    """Determine the active sparse config rules.
+
+    Rules are constructed by reading the current sparse config and bringing in
+    referenced profiles from parents of the working directory.
+    """
     revs = [repo.changelog.rev(node) for node in
             repo.dirstate.parents() if node != nullid]
 
-    profiles = set()
+    allincludes = set()
+    allexcludes = set()
+    allprofiles = set()
+
     for rev in revs:
-        profiles.update(patternsforrev(repo, rev)[2])
+        includes, excludes, profiles = patternsforrev(repo, rev)
+        allincludes |= includes
+        allexcludes |= excludes
+        allprofiles |= set(profiles)
 
-    return profiles
+    return allincludes, allexcludes, allprofiles
 
 def configsignature(repo, includetemp=True):
     """Obtain the signature string for the current sparse configuration.
@@ -361,7 +372,7 @@
         for file, flags, msg in actions:
             dirstate.normal(file)
 
-    profiles = activeprofiles(repo)
+    profiles = activeconfig(repo)[2]
     changedprofiles = profiles & files
     # If an active profile changed during the update, refresh the checkout.
     # Don't do this during a branch merge, since all incoming changes should