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,
|
|
20 |
)
|
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
21 |
""") |
22 |
||
23 |
class cmd_mp_regen(commands.Command): |
|
24 |
"""Generate a multiparent versionedfile""" |
|
25 |
||
26 |
takes_args = ['file?'] |
|
27 |
takes_options = [commands.Option('sync-snapshots', |
|
28 |
help='Snapshots follow source'), |
|
29 |
commands.Option('snapshot-interval', type=int, |
|
30 |
help='take snapshots every x revisions'), |
|
31 |
commands.Option('lsprof-timed', help='Use lsprof'), |
|
|
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.20
by Aaron Bentley
Convert to a plugin |
34 |
commands.Option('extract', help='test extract time'), |
35 |
commands.Option('single', help='use a single parent'), |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
36 |
commands.Option('verify', help='verify added texts'), |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
37 |
]
|
38 |
hidden = True |
|
39 |
||
40 |
def run(self, file=None, sync_snapshots=False, snapshot_interval=26, |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
41 |
lsprof_timed=False, dump=False, extract=False, single=False, |
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
42 |
verify=False, outfile=None): |
43 |
if outfile is None: |
|
44 |
filename = 'pknit' |
|
45 |
else: |
|
46 |
filename = outfile |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
47 |
if file is None: |
48 |
wt, path = WorkingTree.open_containing('.') |
|
49 |
file_weave = wt.branch.repository.get_inventory_weave() |
|
50 |
else: |
|
51 |
wt, path = WorkingTree.open_containing(file) |
|
52 |
file_id = wt.path2id(path) |
|
53 |
bt = wt.branch.repository.revision_tree(wt.last_revision()) |
|
54 |
file_weave = bt.get_weave(file_id) |
|
55 |
url = file_weave.transport.abspath(file_weave.filename) |
|
56 |
print >> sys.stderr, 'Importing: %s' % \ |
|
57 |
urlutils.local_path_from_url(url) |
|
58 |
if sync_snapshots: |
|
59 |
print >> sys.stderr, 'Snapshots follow input' |
|
60 |
else: |
|
61 |
print >> sys.stderr, 'Snapshot interval: %d' % snapshot_interval |
|
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
62 |
try: |
63 |
os.unlink(filename) |
|
64 |
except OSError, e: |
|
65 |
if e.errno != errno.ENOENT: |
|
66 |
raise
|
|
67 |
vf = MultiVersionedFile(filename, snapshot_interval) |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
68 |
snapshots = set(r for r in file_weave.versions() if |
69 |
file_weave._index.get_method(r) == 'fulltext') |
|
70 |
if sync_snapshots: |
|
71 |
to_sync = snapshots |
|
72 |
else: |
|
|
0.9.23
by Aaron Bentley
handle snapshots all at once |
73 |
to_sync = vf.select_snapshots(file_weave) |
74 |
print >> sys.stderr, "%d fulltexts" % len(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, |
|
79 |
verify=verify) |
|
80 |
except: |
|
81 |
try: |
|
82 |
os.unlink(filename) |
|
83 |
except OSError, e: |
|
84 |
if e.errno != errno.ENOENT: |
|
85 |
raise
|
|
86 |
raise
|
|
87 |
try: |
|
88 |
print >> sys.stderr, "%d actual snapshots" % len(to_sync) |
|
89 |
vf.clear_cache() |
|
90 |
if False: |
|
91 |
for revision_id in file_weave.get_ancestry( |
|
92 |
[bt.inventory[file_id].revision]): |
|
93 |
if vf.get_line_list([revision_id])[0] != \ |
|
94 |
file_weave.get_lines(revision_id): |
|
95 |
open(revision_id + '.old', 'wb').writelines( |
|
96 |
file_weave.get_lines(revision_id)) |
|
97 |
open(revision_id + '.new', 'wb').writelines( |
|
98 |
vf.get_line_list(revision_id)[0]) |
|
99 |
if extract: |
|
100 |
revisions = file_weave.versions()[-1:] |
|
101 |
if lsprof_timed: |
|
102 |
from bzrlib.lsprof import profile |
|
103 |
ret, stats = profile(vf.get_line_list, revisions) |
|
104 |
stats.sort() |
|
105 |
stats.pprint() |
|
106 |
start = time.clock() |
|
107 |
print >> sys.stderr, revisions[0] |
|
108 |
for x in range(1000): |
|
109 |
vf.clear_cache() |
|
110 |
vf.get_line_list(revisions) |
|
111 |
print >> sys.stderr, time.clock() - start |
|
112 |
start = time.clock() |
|
113 |
for x in range(1000): |
|
114 |
file_weave.get_line_list(revisions) |
|
115 |
print >> sys.stderr, time.clock() - start |
|
116 |
finally: |
|
117 |
if outfile is None: |
|
118 |
try: |
|
119 |
os.unlink() |
|
120 |
except OSError, e: |
|
121 |
if e.errno != ENOENT: |
|
122 |
raise
|
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
123 |
|
124 |
commands.register_command(cmd_mp_regen) |
|
|
0.9.30
by Aaron Bentley
Split into MultiVersionedFile and MultiMemoryVersionedFile |
125 |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
126 |
def test_suite(): |
127 |
from bzrlib.plugins.multiparent import test_multiparent |
|
128 |
return TestUtil.TestLoader().loadTestsFromModule(test_multiparent) |