1
#!/usr/bin/env python2.4
2
from itertools import izip
6
from bzrlib.workingtree import WorkingTree
8
from multiparent import MultiVersionedFile
10
if len(sys.argv) > 1 and len(sys.argv) < 4:
11
wt, path = WorkingTree.open_containing(sys.argv[-1])
12
if len(sys.argv) == 3:
13
assert sys.argv[1] == '--single'
16
print >> sys.stderr, 'Usage: mpknit [--single] FILENAME'
19
bt = wt.branch.repository.revision_tree(wt.last_revision())
20
file_id = wt.path2id(path)
21
file_weave = bt.get_weave(file_id)
22
file_weave.enable_cache()
23
vf = MultiVersionedFile()
24
ancestry = set(file_weave.get_ancestry([bt.inventory[file_id].revision]))
25
files = dict(izip(ancestry, file_weave.get_line_list(ancestry)))
26
while len(ancestry) > 0:
28
for revision in ancestry:
29
parents = file_weave.get_parents(revision)
30
if [p for p in parents if p not in vf._diffs] != []:
32
lines = files[revision]
33
vf.add_version(lines, revision, parents)
35
ancestry = [r for r in ancestry if r not in added]
38
for revision_id in file_weave.get_ancestry(
39
[bt.inventory[file_id].revision]):
40
if vf.get_line_list([revision_id])[0] != \
41
file_weave.get_lines(revision_id):
42
open(revision_id + '.old', 'wb').writelines(
43
file_weave.get_lines(revision_id))
44
open(revision_id + '.new', 'wb').writelines(
45
vf.get_line_list(revision_id)[0])
47
revisions = file_weave.get_ancestry(
48
[bt.inventory[file_id].revision])[-1:]
49
from bzrlib.lsprof import profile
50
ret, stats = profile(vf.get_line_list, revisions)
56
vf.get_line_list(revisions)
57
print time.clock() - start
60
file_weave.get_line_list(revisions)
61
print time.clock() - start