# HG changeset patch # User Ludovic Chabant # Date 1386712057 28800 # Node ID 957b269c6dfc0f3c749aa5292826b1e581e3f3be # Parent 87606db8c641cd812bce438660cd0a9197d65730 Don't run processes if we're using the command server. diff -r 87606db8c641 -r 957b269c6dfc wikked/scm/mercurial.py --- 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):