mercurial/sparse.py
changeset 33303 8b571495d811
parent 33302 36a415b5a4b2
child 33304 3e1accab7447
--- a/mercurial/sparse.py	Thu Jul 06 12:20:53 2017 -0700
+++ b/mercurial/sparse.py	Thu Jul 06 12:24:55 2017 -0700
@@ -129,3 +129,23 @@
 
 def invalidatesignaturecache(repo):
     repo._sparsesignaturecache.clear()
+
+def writeconfig(repo, includes, excludes, profiles):
+    """Write the sparse config file given a sparse configuration."""
+    with repo.vfs('sparse', 'wb') as fh:
+        for p in sorted(profiles):
+            fh.write('%%include %s\n' % p)
+
+        if includes:
+            fh.write('[include]\n')
+            for i in sorted(includes):
+                fh.write(i)
+                fh.write('\n')
+
+        if excludes:
+            fh.write('[exclude]\n')
+            for e in sorted(excludes):
+                fh.write(e)
+                fh.write('\n')
+
+    invalidatesignaturecache(repo)