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 |
from itertools import izip |
3 |
import sys |
|
4 |
import time |
|
5 |
||
|
0.9.20
by Aaron Bentley
Convert to a plugin |
6 |
lazy_import(globals(), """ |
7 |
from bzrlib import commands
|
|
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
8 |
from bzrlib.workingtree import WorkingTree
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
9 |
from bzrlib.tests import TestUtil
|
10 |
from bzrlib import urlutils
|
|
11 |
||
|
0.9.25
by Aaron Bentley
More messy hacking |
12 |
from bzrlib.plugins.multiparent.multiparent import (
|
13 |
MultiVersionedFile,
|
|
14 |
gzip_string,
|
|
15 |
)
|
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
16 |
""") |
17 |
||
18 |
class cmd_mp_regen(commands.Command): |
|
19 |
"""Generate a multiparent versionedfile""" |
|
20 |
||
21 |
takes_args = ['file?'] |
|
22 |
takes_options = [commands.Option('sync-snapshots', |
|
23 |
help='Snapshots follow source'), |
|
24 |
commands.Option('snapshot-interval', type=int, |
|
25 |
help='take snapshots every x revisions'), |
|
26 |
commands.Option('lsprof-timed', help='Use lsprof'), |
|
27 |
commands.Option('dump', |
|
28 |
help='dump pseudo-knit to stdout'), |
|
29 |
commands.Option('extract', help='test extract time'), |
|
30 |
commands.Option('single', help='use a single parent'), |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
31 |
commands.Option('verify', help='verify added texts'), |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
32 |
]
|
33 |
hidden = True |
|
34 |
||
35 |
def run(self, file=None, sync_snapshots=False, snapshot_interval=26, |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
36 |
lsprof_timed=False, dump=False, extract=False, single=False, |
37 |
verify=False): |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
38 |
if file is None: |
39 |
wt, path = WorkingTree.open_containing('.') |
|
40 |
file_weave = wt.branch.repository.get_inventory_weave() |
|
41 |
else: |
|
42 |
wt, path = WorkingTree.open_containing(file) |
|
43 |
file_id = wt.path2id(path) |
|
44 |
bt = wt.branch.repository.revision_tree(wt.last_revision()) |
|
45 |
file_weave = bt.get_weave(file_id) |
|
46 |
url = file_weave.transport.abspath(file_weave.filename) |
|
47 |
print >> sys.stderr, 'Importing: %s' % \ |
|
48 |
urlutils.local_path_from_url(url) |
|
49 |
if sync_snapshots: |
|
50 |
print >> sys.stderr, 'Snapshots follow input' |
|
51 |
else: |
|
52 |
print >> sys.stderr, 'Snapshot interval: %d' % snapshot_interval |
|
53 |
vf = MultiVersionedFile(snapshot_interval) |
|
54 |
snapshots = set(r for r in file_weave.versions() if |
|
55 |
file_weave._index.get_method(r) == 'fulltext') |
|
56 |
if sync_snapshots: |
|
57 |
to_sync = snapshots |
|
58 |
else: |
|
|
0.9.23
by Aaron Bentley
handle snapshots all at once |
59 |
to_sync = vf.select_snapshots(file_weave) |
60 |
print >> sys.stderr, "%d fulltexts" % len(snapshots) |
|
|
0.9.25
by Aaron Bentley
More messy hacking |
61 |
print >> sys.stderr, "%d planned snapshots" % len(to_sync) |
|
0.9.23
by Aaron Bentley
handle snapshots all at once |
62 |
|
|
0.9.22
by Aaron Bentley
Fix restoration bug |
63 |
vf.import_versionedfile(file_weave, to_sync, single_parent=single, |
64 |
verify=verify) |
|
|
0.9.25
by Aaron Bentley
More messy hacking |
65 |
print >> sys.stderr, "%d actual snapshots" % len(to_sync) |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
66 |
vf.clear_cache() |
|
0.9.20
by Aaron Bentley
Convert to a plugin |
67 |
if False: |
68 |
for revision_id in file_weave.get_ancestry( |
|
69 |
[bt.inventory[file_id].revision]): |
|
70 |
if vf.get_line_list([revision_id])[0] != \ |
|
71 |
file_weave.get_lines(revision_id): |
|
72 |
open(revision_id + '.old', 'wb').writelines( |
|
73 |
file_weave.get_lines(revision_id)) |
|
74 |
open(revision_id + '.new', 'wb').writelines( |
|
75 |
vf.get_line_list(revision_id)[0]) |
|
76 |
if extract: |
|
77 |
revisions = file_weave.versions()[-1:] |
|
78 |
if lsprof_timed: |
|
79 |
from bzrlib.lsprof import profile |
|
80 |
ret, stats = profile(vf.get_line_list, revisions) |
|
81 |
stats.sort() |
|
82 |
stats.pprint() |
|
83 |
start = time.clock() |
|
84 |
print >> sys.stderr, revisions[0] |
|
85 |
for x in range(1000): |
|
86 |
vf.clear_cache() |
|
87 |
vf.get_line_list(revisions) |
|
88 |
print >> sys.stderr, time.clock() - start |
|
89 |
start = time.clock() |
|
90 |
for x in range(1000): |
|
91 |
file_weave.get_line_list(revisions) |
|
92 |
print >> sys.stderr, time.clock() - start |
|
93 |
if dump: |
|
94 |
revisions = file_weave.versions() |
|
95 |
||
96 |
for revision, diff in vf._diffs.iteritems(): |
|
|
0.9.25
by Aaron Bentley
More messy hacking |
97 |
sys.stdout.write(gzip_string(['version %s' % revision] + |
98 |
list(diff.to_patch()))) |
|
|
0.9.20
by Aaron Bentley
Convert to a plugin |
99 |
|
100 |
commands.register_command(cmd_mp_regen) |
|
101 |
def test_suite(): |
|
102 |
from bzrlib.plugins.multiparent import test_multiparent |
|
103 |
return TestUtil.TestLoader().loadTestsFromModule(test_multiparent) |