/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python2.4
from itertools import izip
import sys
import time

from bzrlib.workingtree import WorkingTree

from multiparent import MultiVersionedFile
single_parent = False
if len(sys.argv) > 1 and len(sys.argv) < 4:
    wt, path = WorkingTree.open_containing(sys.argv[-1])
    if len(sys.argv) == 3:
        assert sys.argv[1] == '--single'
        single_parent = True
else:
    print >> sys.stderr, 'Usage: mpknit [--single] FILENAME'
    sys.exit(3)

bt = wt.branch.repository.revision_tree(wt.last_revision())
file_id = wt.path2id(path)
file_weave = bt.get_weave(file_id)
file_weave.enable_cache()
vf = MultiVersionedFile()
ancestry = set(file_weave.get_ancestry([bt.inventory[file_id].revision]))
files = dict(izip(ancestry, file_weave.get_line_list(ancestry)))
while len(ancestry) > 0:
    added = set()
    for revision in ancestry:
        parents = file_weave.get_parents(revision)
        if [p for p in parents if p not in vf._diffs] != []:
            continue
        lines = files[revision]
        vf.add_version(lines, revision, parents)
        added.add(revision)
    ancestry = [r for r in ancestry if r not in added]
vf.clear_cache()
if False:
    for revision_id in file_weave.get_ancestry(
        [bt.inventory[file_id].revision]):
        if vf.get_line_list([revision_id])[0] != \
            file_weave.get_lines(revision_id):
            open(revision_id + '.old', 'wb').writelines(
                file_weave.get_lines(revision_id))
            open(revision_id + '.new', 'wb').writelines(
                vf.get_line_list(revision_id)[0])
if True:
    revisions = file_weave.get_ancestry(
            [bt.inventory[file_id].revision])[-1:]
    from bzrlib.lsprof import profile
    ret, stats = profile(vf.get_line_list, revisions)
    stats.sort()
    stats.pprint()
    start = time.clock()
    for x in range(1000):
        vf.clear_cache()
        vf.get_line_list(revisions)
    print time.clock() - start
    start = time.clock()
    for x in range(1000):
        file_weave.get_line_list(revisions)
    print time.clock() - start