bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.9.20
by Aaron Bentley
Convert to a plugin |
1 |
from bzrlib.lazy_import import lazy_import |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
2 |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
3 |
lazy_import(globals(), """ |
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
4 |
import (
|
5 |
errno,
|
|
6 |
os,
|
|
7 |
sys,
|
|
8 |
time,
|
|
9 |
)
|
|
10 |
||
11 |
from bzrlib import (
|
|
12 |
commands,
|
|
13 |
urlutils
|
|
14 |
)
|
|
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
15 |
from bzrlib.workingtree import WorkingTree
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
16 |
from bzrlib.tests import TestUtil
|
17 |
||
|
0.9.25
by Aaron Bentley
More messy hacking |
18 |
from bzrlib.plugins.multiparent.multiparent import (
|
19 |
MultiVersionedFile,
|
|
|
0.9.31
by Aaron Bentley
Allow selecting MemoryVersionedFile from commandline |
20 |
MultiMemoryVersionedFile,
|
|
0.9.25
by Aaron Bentley
More messy hacking |
21 |
)
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
22 |
""") |
23 |
||
24 |
class cmd_mp_regen(commands.Command): |
|
25 |
"""Generate a multiparent versionedfile""" |
|
26 |
||
27 |
takes_args = ['file?'] |
|
28 |
takes_options = [commands.Option('sync-snapshots', |
|
29 |
help='Snapshots follow source'), |
|
30 |
commands.Option('snapshot-interval', type=int, |
|
31 |
help='take snapshots every x revisions'), |
|
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
32 |
commands.Option('outfile', type=unicode, |
33 |
help='Write pseudo-knit to this file'), |
|
|
0.9.31
by Aaron Bentley
Allow selecting MemoryVersionedFile from commandline |
34 |
commands.Option('memory', help='Use memory, not disk'), |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
35 |
commands.Option('extract', help='test extract time'), |
36 |
commands.Option('single', help='use a single parent'), |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
37 |
commands.Option('verify', help='verify added texts'), |
|
0.9.33
by Aaron Bentley
Enable caching commandline param |
38 |
commands.Option('cache', help='Aggresively cache'), |
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
39 |
commands.Option('size', help='Aggressive size'), |
|
0.9.35
by Aaron Bentley
Add build ranking |
40 |
commands.Option('build', help='Aggressive build'), |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
41 |
]
|
42 |
hidden = True |
|
43 |
||
44 |
def run(self, file=None, sync_snapshots=False, snapshot_interval=26, |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
45 |
lsprof_timed=False, dump=False, extract=False, single=False, |
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
46 |
verify=False, outfile=None, memory=False, cache=False, |
|
0.9.35
by Aaron Bentley
Add build ranking |
47 |
size=False, build=False): |
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
48 |
file_weave = get_file_weave(file) |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
49 |
url = file_weave.transport.abspath(file_weave.filename) |
50 |
print >> sys.stderr, 'Importing: %s' % \ |
|
51 |
urlutils.local_path_from_url(url) |
|
52 |
if sync_snapshots: |
|
53 |
print >> sys.stderr, 'Snapshots follow input' |
|
54 |
else: |
|
55 |
print >> sys.stderr, 'Snapshot interval: %d' % snapshot_interval |
|
|
0.9.31
by Aaron Bentley
Allow selecting MemoryVersionedFile from commandline |
56 |
if not memory: |
57 |
if outfile is None: |
|
58 |
filename = 'pknit' |
|
59 |
else: |
|
60 |
filename = outfile |
|
61 |
vf = MultiVersionedFile(filename, snapshot_interval) |
|
62 |
else: |
|
63 |
vf = MultiMemoryVersionedFile(snapshot_interval) |
|
64 |
vf.destroy() |
|
|
0.9.35
by Aaron Bentley
Add build ranking |
65 |
old_snapshots = set(r for r in file_weave.versions() if |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
66 |
file_weave._index.get_method(r) == 'fulltext') |
67 |
if sync_snapshots: |
|
|
0.9.35
by Aaron Bentley
Add build ranking |
68 |
to_sync = old_snapshots |
69 |
elif size or build: |
|
70 |
assert memory |
|
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
71 |
to_sync = set() |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
72 |
else: |
|
0.9.23
by Aaron Bentley
handle snapshots all at once |
73 |
to_sync = vf.select_snapshots(file_weave) |
|
0.9.35
by Aaron Bentley
Add build ranking |
74 |
print >> sys.stderr, "%d fulltext(s)" % len(old_snapshots) |
|
0.9.25
by Aaron Bentley
More messy hacking |
75 |
print >> sys.stderr, "%d planned snapshots" % len(to_sync) |
|
0.9.23
by Aaron Bentley
handle snapshots all at once |
76 |
|
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
77 |
try: |
78 |
vf.import_versionedfile(file_weave, to_sync, single_parent=single, |
|
|
0.9.33
by Aaron Bentley
Enable caching commandline param |
79 |
verify=verify, no_cache=not cache) |
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
80 |
if size: |
81 |
snapshots = vf.select_by_size(len(snapshots)) |
|
82 |
for version_id in snapshots: |
|
83 |
vf.make_snapshot(version_id) |
|
|
0.9.35
by Aaron Bentley
Add build ranking |
84 |
if build: |
85 |
ranking = vf.get_build_ranking() |
|
86 |
snapshots = ranking[:len(snapshots) -\ |
|
87 |
len(vf._snapshots)] |
|
88 |
for version_id in snapshots: |
|
89 |
old_len = len(vf._snapshots) |
|
90 |
#vf.make_snapshot(version_id)
|
|
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
91 |
except: |
|
0.9.31
by Aaron Bentley
Allow selecting MemoryVersionedFile from commandline |
92 |
vf.destroy() |
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
93 |
raise
|
94 |
try: |
|
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
95 |
print >> sys.stderr, "%d actual snapshots" % len(vf._snapshots) |
|
0.9.33
by Aaron Bentley
Enable caching commandline param |
96 |
if not cache: |
97 |
vf.clear_cache() |
|
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
98 |
if memory: |
99 |
if outfile is not None: |
|
100 |
vf_file = MultiVersionedFile(outfile) |
|
|
0.9.32
by Aaron Bentley
Allow specifying --outfile and --memory |
101 |
for version_id in vf.versions(): |
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
102 |
vf_file.add_diff(vf.get_diff(version_id), version_id, |
103 |
vf._parents[version_id]) |
|
104 |
else: |
|
105 |
vf_file = vf |
|
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
106 |
finally: |
107 |
if outfile is None: |
|
|
0.9.31
by Aaron Bentley
Allow selecting MemoryVersionedFile from commandline |
108 |
vf.destroy() |
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
109 |
else: |
110 |
vf_file.save() |
|
111 |
||
112 |
class cmd_mp_extract(commands.Command): |
|
113 |
||
114 |
takes_options = [ |
|
115 |
commands.Option('lsprof-timed', help='Use lsprof'), |
|
116 |
commands.Option('parallel', help='extract multiple versions at once'), |
|
117 |
commands.Option('count', help='Number of cycles to do', type=int), |
|
118 |
]
|
|
119 |
||
120 |
takes_args = ['filename', 'vfile?'] |
|
121 |
||
122 |
def run(self, filename, vfile=None, lsprof_timed=False, count=1000, |
|
123 |
parallel=False): |
|
124 |
vf = MultiVersionedFile(filename) |
|
125 |
vf.load() |
|
126 |
revisions = list(vf.versions()) |
|
127 |
revisions = revisions[-count:] |
|
128 |
print 'Testing extract time of %d revisions' % len(revisions) |
|
129 |
if parallel: |
|
130 |
revisions_list = [revisions] |
|
131 |
else: |
|
132 |
revisions_list = [[r] for r in revisions] |
|
133 |
start = time.clock() |
|
134 |
for revisions in revisions_list: |
|
135 |
vf = MultiVersionedFile(filename) |
|
136 |
vf.load() |
|
137 |
vf.get_line_list(revisions) |
|
138 |
print >> sys.stderr, time.clock() - start |
|
139 |
if lsprof_timed: |
|
140 |
from bzrlib.lsprof import profile |
|
141 |
vf.clear_cache() |
|
142 |
ret, stats = profile(vf.get_line_list, revisions_list[-1][-1]) |
|
143 |
stats.sort() |
|
144 |
stats.pprint() |
|
145 |
start = time.clock() |
|
146 |
for revisions in revisions_list: |
|
147 |
file_weave = get_file_weave(vfile) |
|
148 |
file_weave.get_line_list(revisions) |
|
149 |
print >> sys.stderr, time.clock() - start |
|
150 |
||
151 |
||
152 |
def get_file_weave(filename=None, wt=None): |
|
153 |
if filename is None: |
|
154 |
wt, path = WorkingTree.open_containing('.') |
|
155 |
return wt.branch.repository.get_inventory_weave() |
|
156 |
else: |
|
157 |
wt, path = WorkingTree.open_containing(filename) |
|
158 |
file_id = wt.path2id(path) |
|
159 |
bt = wt.branch.repository.revision_tree(wt.last_revision()) |
|
160 |
return bt.get_weave(file_id) |
|
161 |
||
|
0.9.20
by Aaron Bentley
Convert to a plugin |
162 |
|
163 |
commands.register_command(cmd_mp_regen) |
|
|
0.9.34
by Aaron Bentley
Implement save, load, snapshot-by-size |
164 |
commands.register_command(cmd_mp_extract) |
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
165 |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
166 |
def test_suite(): |
167 |
from bzrlib.plugins.multiparent import test_multiparent |
|
168 |
return TestUtil.TestLoader().loadTestsFromModule(test_multiparent) |