The unified diff between revisions [d80dbd89..] and [ece019f1..] is displayed below. It can also be downloaded as a raw diff.
#
#
# rename "pristine.py"
# to "mkpristine.py"
#
# patch "mkpristine.py"
# from [0caf44bef70e2bc91b4c0c7de1aaafebe574ad22]
# to [7e4e7eba4604947dc68dc5728feb3b2c56ca4061]
#
============================================================
--- pristine.py 0caf44bef70e2bc91b4c0c7de1aaafebe574ad22
+++ mkpristine.py 7e4e7eba4604947dc68dc5728feb3b2c56ca4061
@@ -1,11 +1,13 @@
#!/usr/bin/env python2.4
+# vim:et:ts=4:
from sys import argv, exit, stdin, stdout, stderr
import random
from random import choice, randint
from itertools import izip, tee
from shutil import copyfile
-from os import environ, popen4
+from os import environ, WEXITSTATUS
+from popen2 import Popen3
def usage():
print>>stderr, "Usage: %s <database> <number of dbs to end up with> [optional seed]"
@@ -37,17 +39,32 @@ def monotone(db, args):
except KeyError:
MONOTONE = 'monotone'
- cmd = [MONOTONE, '-d', db] + args
- stdin, stdout = popen4(cmd, "r")
- return stdout
+ cmd = [MONOTONE, '-d', db, '--dump=mkpristine.dump'] + args
+ p = Popen3(cmd)
+ stdout = p.fromchild
+ lines = stdout.readlines()
+ w = p.wait()
+ exitcode = WEXITSTATUS(w)
+ if exitcode != 0:
+ print>>stderr
+ print>>stderr, "monotone process exited with status %d" % exitcode
+ print>>stderr, "cmd: %s" % ' '.join(cmd)
+ exit(3)
+ return lines
+
+
+def vacuum(db):
+ monotone(db, ['db', 'execute', 'vacuum'])
+
def get_num_revs(db):
m = monotone(db, ['auto', 'select', ''])
- return len( m.readlines() )
+ return len( m )
def remove_one_rev(db):
- leaves = [ l.strip() for l in monotone(db, ['auto', 'leaves']) ]
+ m = monotone(db, ['auto', 'leaves'])
+ leaves = map(lambda l: l.strip(), m)
if len(leaves) < 1:
print>>stderr, "Ran out of revs to remove"