requires: move requires file writing func from localrepo to scmutil
The logic to read a requires file resides in scmutil, so it's only logical that
the logic to write the file should be there too.
And now I've typed logic too many times it no longer looks like a word.
Logically.
--- a/mercurial/localrepo.py Sun May 03 12:28:15 2015 -0400
+++ b/mercurial/localrepo.py Mon Apr 13 18:11:47 2015 -0400
@@ -353,10 +353,7 @@
self.svfs.options['usetreemanifest'] = usetreemanifest
def _writerequirements(self):
- reqfile = self.vfs("requires", "w")
- for r in sorted(self.requirements):
- reqfile.write("%s\n" % r)
- reqfile.close()
+ scmutil.writerequires(self.vfs, self.requirements)
def _checknested(self, path):
"""Determine if path is a legal nested repository."""
--- a/mercurial/scmutil.py Sun May 03 12:28:15 2015 -0400
+++ b/mercurial/scmutil.py Mon Apr 13 18:11:47 2015 -0400
@@ -1011,6 +1011,12 @@
" for more information"))
return requirements
+def writerequires(opener, requirements):
+ reqfile = opener("requires", "w")
+ for r in sorted(requirements):
+ reqfile.write("%s\n" % r)
+ reqfile.close()
+
class filecachesubentry(object):
def __init__(self, path, stat):
self.path = path