diff hgext/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 9087f9997f42
children c6415195fa78
line wrap: on
line diff
--- a/hgext/sparse.py	Fri Jul 07 15:11:11 2017 -0400
+++ b/hgext/sparse.py	Sat Jul 08 14:01:32 2017 -0700
@@ -75,7 +75,6 @@
 from __future__ import absolute_import
 
 from mercurial.i18n import _
-from mercurial.node import nullid
 from mercurial import (
     cmdutil,
     commands,
@@ -448,23 +447,13 @@
 
 def _import(ui, repo, files, opts, force=False):
     with repo.wlock():
-        # load union of current active profile
-        revs = [repo.changelog.rev(node) for node in
-                repo.dirstate.parents() if node != nullid]
-
         # read current configuration
         raw = repo.vfs.tryread('sparse')
         oincludes, oexcludes, oprofiles = sparse.parseconfig(ui, raw)
         includes, excludes, profiles = map(
                 set, (oincludes, oexcludes, oprofiles))
 
-        # all active rules
-        aincludes, aexcludes, aprofiles = set(), set(), set()
-        for rev in revs:
-            rincludes, rexcludes, rprofiles = sparse.patternsforrev(repo, rev)
-            aincludes.update(rincludes)
-            aexcludes.update(rexcludes)
-            aprofiles.update(rprofiles)
+        aincludes, aexcludes, aprofiles = sparse.activeconfig(repo)
 
         # import rules on top; only take in rules that are not yet
         # part of the active rules.