[PATCH 13 of 13 sparse] merge: move getactivesparseprofiles() from sparse

Gregory Szorc gregory.szorc at gmail.com
Sat Jul 1 21:55:30 EDT 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1498947089 25200
#      Sat Jul 01 15:11:29 2017 -0700
# Node ID bc10d6f300786f4ef719f13c9b21670008604774
# Parent  ac5ef7ac57c2fb6f2a9d3ad1381e7705ebaf690f
merge: move getactivesparseprofiles() from sparse

Also includes some light formatting changes.

diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -212,7 +212,7 @@ def _setupupdates(ui):
             for file, flags, msg in actions:
                 dirstate.normal(file)
 
-        profiles = repo.getactiveprofiles()
+        profiles = mergemod.activesparseprofiles(repo)
         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
@@ -516,17 +516,6 @@ def _wraprepo(ui, repo):
 
             return result
 
-        def getactiveprofiles(self):
-            revs = [self.changelog.rev(node) for node in
-                    self.dirstate.parents() if node != nullid]
-
-            activeprofiles = set()
-            for rev in revs:
-                _, _, profiles = mergemod.sparsepatterns(self, rev)
-                activeprofiles.update(profiles)
-
-            return activeprofiles
-
         def writesparseconfig(self, include, exclude, profiles):
             raw = '%s[include]\n%s\n[exclude]\n%s\n' % (
                 ''.join(['%%include %s\n' % p for p in sorted(profiles)]),
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1844,3 +1844,13 @@ def sparsepatterns(repo, rev):
         includes.add('.hg*')
 
     return includes, excludes, profiles
+
+def activesparseprofiles(repo):
+    revs = [repo.changelog.rev(node) for node in
+            repo.dirstate.parents() if node != nullid]
+
+    profiles = set()
+    for rev in revs:
+        profiles.update(sparsepatterns(repo, rev)[2])
+
+    return profiles


More information about the Mercurial-devel mailing list