29
29
help='Snapshots follow source'),
30
30
commands.Option('snapshot-interval', type=int,
31
31
help='take snapshots every x revisions'),
32
commands.Option('lsprof-timed', help='Use lsprof'),
33
32
commands.Option('outfile', type=unicode,
34
33
help='Write pseudo-knit to this file'),
35
34
commands.Option('memory', help='Use memory, not disk'),
37
36
commands.Option('single', help='use a single parent'),
38
37
commands.Option('verify', help='verify added texts'),
39
38
commands.Option('cache', help='Aggresively cache'),
39
commands.Option('size', help='Aggressive size'),
43
43
def run(self, file=None, sync_snapshots=False, snapshot_interval=26,
44
44
lsprof_timed=False, dump=False, extract=False, single=False,
45
verify=False, outfile=None, memory=False, cache=False):
47
wt, path = WorkingTree.open_containing('.')
48
file_weave = wt.branch.repository.get_inventory_weave()
50
wt, path = WorkingTree.open_containing(file)
51
file_id = wt.path2id(path)
52
bt = wt.branch.repository.revision_tree(wt.last_revision())
53
file_weave = bt.get_weave(file_id)
45
verify=False, outfile=None, memory=False, cache=False,
47
file_weave = get_file_weave(file)
54
48
url = file_weave.transport.abspath(file_weave.filename)
55
51
print >> sys.stderr, 'Importing: %s' % \
56
52
urlutils.local_path_from_url(url)
80
78
vf.import_versionedfile(file_weave, to_sync, single_parent=single,
81
79
verify=verify, no_cache=not cache)
81
snapshots = vf.select_by_size(len(snapshots))
82
for version_id in snapshots:
83
vf.make_snapshot(version_id)
86
print >> sys.stderr, "%d actual snapshots" % len(to_sync)
88
print >> sys.stderr, "%d actual snapshots" % len(vf._snapshots)
90
for revision_id in file_weave.get_ancestry(
91
[bt.inventory[file_id].revision]):
92
if vf.get_line_list([revision_id])[0] != \
93
file_weave.get_lines(revision_id):
94
open(revision_id + '.old', 'wb').writelines(
95
file_weave.get_lines(revision_id))
96
open(revision_id + '.new', 'wb').writelines(
97
vf.get_line_list(revision_id)[0])
99
revisions = file_weave.versions()[-1:]
101
from bzrlib.lsprof import profile
102
ret, stats = profile(vf.get_line_list, revisions)
106
print >> sys.stderr, revisions[0]
107
for x in range(1000):
109
vf.get_line_list(revisions)
110
print >> sys.stderr, time.clock() - start
112
for x in range(1000):
113
file_weave.get_line_list(revisions)
114
print >> sys.stderr, time.clock() - start
115
if memory and outfile is not None:
116
outvf = MultiVersionedFile(outfile)
92
if outfile is not None:
93
vf_file = MultiVersionedFile(outfile)
117
94
for version_id in vf.versions():
118
outvf.add_diff(vf.get_diff(version_id), version_id,
119
vf._parents[version_id])
95
vf_file.add_diff(vf.get_diff(version_id), version_id,
96
vf._parents[version_id])
121
100
if outfile is None:
105
class cmd_mp_extract(commands.Command):
108
commands.Option('lsprof-timed', help='Use lsprof'),
109
commands.Option('parallel', help='extract multiple versions at once'),
110
commands.Option('count', help='Number of cycles to do', type=int),
113
takes_args = ['filename', 'vfile?']
115
def run(self, filename, vfile=None, lsprof_timed=False, count=1000,
117
vf = MultiVersionedFile(filename)
119
revisions = list(vf.versions())
120
revisions = revisions[-count:]
121
print 'Testing extract time of %d revisions' % len(revisions)
123
revisions_list = [revisions]
125
revisions_list = [[r] for r in revisions]
127
for revisions in revisions_list:
128
vf = MultiVersionedFile(filename)
130
vf.get_line_list(revisions)
131
print >> sys.stderr, time.clock() - start
133
from bzrlib.lsprof import profile
135
ret, stats = profile(vf.get_line_list, revisions_list[-1][-1])
139
for revisions in revisions_list:
140
file_weave = get_file_weave(vfile)
141
file_weave.get_line_list(revisions)
142
print >> sys.stderr, time.clock() - start
145
def get_file_weave(filename=None, wt=None):
147
wt, path = WorkingTree.open_containing('.')
148
return wt.branch.repository.get_inventory_weave()
150
wt, path = WorkingTree.open_containing(filename)
151
file_id = wt.path2id(path)
152
bt = wt.branch.repository.revision_tree(wt.last_revision())
153
return bt.get_weave(file_id)
124
156
commands.register_command(cmd_mp_regen)
157
commands.register_command(cmd_mp_extract)
126
159
def test_suite():
127
160
from bzrlib.plugins.multiparent import test_multiparent