hgext/sparse.py
changeset 33303 8b571495d811
parent 33302 36a415b5a4b2
child 33304 3e1accab7447
--- a/hgext/sparse.py	Thu Jul 06 12:20:53 2017 -0700
+++ b/hgext/sparse.py	Thu Jul 06 12:24:55 2017 -0700
@@ -510,14 +510,6 @@
 
             return result
 
-        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)]),
-                '\n'.join(sorted(include)),
-                '\n'.join(sorted(exclude)))
-            self.vfs.write("sparse", raw)
-            sparse.invalidatesignaturecache(self)
-
         def addtemporaryincludes(self, files):
             includes = self.gettemporaryincludes()
             for file in files:
@@ -722,7 +714,8 @@
                 newinclude.difference_update(pats)
                 newexclude.difference_update(pats)
 
-            repo.writesparseconfig(newinclude, newexclude, newprofiles)
+            sparse.writeconfig(repo, newinclude, newexclude, newprofiles)
+
             fcounts = map(
                 len, _refresh(ui, repo, oldstatus, oldsparsematch, force))
 
@@ -735,7 +728,7 @@
             _verbose_output(
                 ui, opts, profilecount, includecount, excludecount, *fcounts)
         except Exception:
-            repo.writesparseconfig(oldinclude, oldexclude, oldprofiles)
+            sparse.writeconfig(repo, oldinclude, oldexclude, oldprofiles)
             raise
     finally:
         wlock.release()
@@ -784,13 +777,13 @@
 
             oldstatus = repo.status()
             oldsparsematch = repo.sparsematch()
-            repo.writesparseconfig(includes, excludes, profiles)
+            sparse.writeconfig(repo, includes, excludes, profiles)
 
             try:
                 fcounts = map(
                     len, _refresh(ui, repo, oldstatus, oldsparsematch, force))
             except Exception:
-                repo.writesparseconfig(oincludes, oexcludes, oprofiles)
+                sparse.writeconfig(repo, oincludes, oexcludes, oprofiles)
                 raise
 
         _verbose_output(ui, opts, profilecount, includecount, excludecount,
@@ -804,7 +797,7 @@
         if includes or excludes:
             oldstatus = repo.status()
             oldsparsematch = repo.sparsematch()
-            repo.writesparseconfig(set(), set(), profiles)
+            sparse.writeconfig(repo, set(), set(), profiles)
             _refresh(ui, repo, oldstatus, oldsparsematch, force)
 
 def _refresh(ui, repo, origstatus, origsparsematch, force):