/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.9.12 by Aaron Bentley
Make benchmarks for mp
1
#!/usr/bin/env python2.4
2
from itertools import izip
0.9.15 by Aaron Bentley
Make mpregen output a psuedo-knit
3
from StringIO import StringIO
0.9.12 by Aaron Bentley
Make benchmarks for mp
4
import sys
5
import time
6
0.9.15 by Aaron Bentley
Make mpregen output a psuedo-knit
7
from bzrlib.tuned_gzip import GzipFile
0.9.12 by Aaron Bentley
Make benchmarks for mp
8
from bzrlib.workingtree import WorkingTree
9
10
from multiparent import MultiVersionedFile
11
single_parent = False
12
if len(sys.argv) > 1 and len(sys.argv) < 4:
13
    wt, path = WorkingTree.open_containing(sys.argv[-1])
14
    if len(sys.argv) == 3:
15
        assert sys.argv[1] == '--single'
16
        single_parent = True
17
else:
18
    print >> sys.stderr, 'Usage: mpknit [--single] FILENAME'
19
    sys.exit(3)
20
21
bt = wt.branch.repository.revision_tree(wt.last_revision())
22
file_id = wt.path2id(path)
0.9.16 by Aaron Bentley
More control over snapshotting, disable caching for inventory
23
file_weave = wt.branch.repository.get_inventory_weave()
24
#file_weave = bt.get_weave(file_id)
0.9.17 by Aaron Bentley
Dynamically select snapshots based on all parents
25
#file_weave.enable_cache()
26
vf = MultiVersionedFile(25)
0.9.19 by Aaron Bentley
More tweakage
27
ft_set = set(r for r in file_weave.versions() if
28
             file_weave._index.get_method(r) == 'fulltext')
29
vf.import_versionedfile(file_weave)
0.9.16 by Aaron Bentley
More control over snapshotting, disable caching for inventory
30
print >> sys.stderr, file_weave
31
print >> sys.stderr, "%d fulltexts" % len(ft_set)
32
print >> sys.stderr, "%d snapshots" % len(vf._snapshots)
0.9.12 by Aaron Bentley
Make benchmarks for mp
33
vf.clear_cache()
34
if False:
35
    for revision_id in file_weave.get_ancestry(
36
        [bt.inventory[file_id].revision]):
37
        if vf.get_line_list([revision_id])[0] != \
38
            file_weave.get_lines(revision_id):
39
            open(revision_id + '.old', 'wb').writelines(
40
                file_weave.get_lines(revision_id))
41
            open(revision_id + '.new', 'wb').writelines(
42
                vf.get_line_list(revision_id)[0])
0.9.16 by Aaron Bentley
More control over snapshotting, disable caching for inventory
43
if True:
0.9.12 by Aaron Bentley
Make benchmarks for mp
44
    revisions = file_weave.get_ancestry(
45
            [bt.inventory[file_id].revision])[-1:]
46
    from bzrlib.lsprof import profile
47
    ret, stats = profile(vf.get_line_list, revisions)
48
    stats.sort()
49
    stats.pprint()
50
    start = time.clock()
0.9.16 by Aaron Bentley
More control over snapshotting, disable caching for inventory
51
    print revisions
0.9.12 by Aaron Bentley
Make benchmarks for mp
52
    for x in range(1000):
53
        vf.clear_cache()
54
        vf.get_line_list(revisions)
55
    print time.clock() - start
56
    start = time.clock()
57
    for x in range(1000):
58
        file_weave.get_line_list(revisions)
59
    print time.clock() - start
0.9.16 by Aaron Bentley
More control over snapshotting, disable caching for inventory
60
if False:
61
    revisions = file_weave.versions()
0.9.15 by Aaron Bentley
Make mpregen output a psuedo-knit
62
63
    for revision, diff in vf._diffs.iteritems():
64
        sio = StringIO()
65
        data_file = GzipFile(None, mode='wb', fileobj=sio)
66
        print >> data_file, 'version %s' % revision
67
        data_file.writelines(diff.to_patch())
68
        data_file.close()
69
        sys.stdout.write(sio.getvalue())