changeset 141:957b269c6dfc

Don't run processes if we're using the command server.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 10 Dec 2013 13:47:37 -0800
parents 87606db8c641
children 7e4287d9b3bb
files wikked/scm/mercurial.py
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/wikked/scm/mercurial.py	Tue Dec 10 13:42:11 2013 -0800
+++ b/wikked/scm/mercurial.py	Tue Dec 10 13:47:37 2013 -0800
@@ -30,7 +30,7 @@
         # Make a Mercurial repo if there's none.
         if not os.path.isdir(os.path.join(self.root, '.hg')):
             logger.info("Creating Mercurial repository at: " + self.root)
-            self._run('init', self.root, norepo=True)
+            self._initRepo(self.root)
 
         # Create a `.hgignore` file is there's none.
         ignore_path = os.path.join(self.root, '.hgignore')
@@ -38,22 +38,12 @@
             logger.info("Creating `.hgignore` file.")
             with open(ignore_path, 'w') as f:
                 f.write('.wiki')
-            self._run('add', ignore_path)
-            self._run('commit', ignore_path, '-m', 'Created .hgignore.')
+            self.commit([ignore_path], "Created `.hgignore`.")
 
     def getSpecialFilenames(self):
         specials = ['.hg', '.hgignore', '.hgtags']
         return [os.path.join(self.root, d) for d in specials]
 
-    def _run(self, cmd, *args, **kwargs):
-        exe = [self.hg]
-        if 'norepo' not in kwargs or not kwargs['norepo']:
-            exe += ['-R', self.root]
-        exe.append(cmd)
-        exe += args
-        logger.debug("Running Mercurial: " + str(exe))
-        return subprocess.check_output(exe)
-
 
 class MercurialSourceControl(MercurialBaseSourceControl):
     def __init__(self, root):
@@ -135,6 +125,9 @@
         else:
             self._run('revert', '-a', '-C')
 
+    def _initRepo(self, path):
+        self._run('init', path, norepo=True)
+
     def _parseRevision(self, group):
         lines = group.split("\n")
 
@@ -168,6 +161,15 @@
 
         return rev
 
+    def _run(self, cmd, *args, **kwargs):
+        exe = [self.hg]
+        if 'norepo' not in kwargs or not kwargs['norepo']:
+            exe += ['-R', self.root]
+        exe.append(cmd)
+        exe += args
+        logger.debug("Running Mercurial: " + str(exe))
+        return subprocess.check_output(exe)
+
 
 class MercurialCommandServerSourceControl(MercurialBaseSourceControl):
     def __init__(self, root):