~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tryconvert.py

  • Committer: Martin Pool
  • Date: 2005-06-30 08:40:59 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050630084059-d6eb6cb46972365b
Rename Weave.get_included to inclusions and getiter to get_iter

Refactor annotate() code 

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import bzrlib.branch
23
23
from weave import Weave
24
24
from weavefile import write_weave
25
 
import tempfile
26
 
import hotshot
27
 
 
28
 
def convert():
29
 
    WEAVE_NAME = "inventory.weave"
30
 
 
31
 
    wf = Weave()
32
 
 
33
 
    b = bzrlib.branch.find_branch('.')
34
 
 
35
 
    print 'converting...'
36
 
 
37
 
    parents = set()
38
 
    revno = 1
39
 
    for rev_id in b.revision_history():
40
 
        print revno
41
 
        inv_xml = b.inventory_store[rev_id].readlines()
42
 
        weave_id = wf.add(parents, inv_xml)
43
 
        parents.add(weave_id)
44
 
        revno += 1
45
 
 
46
 
    write_weave(wf, file(WEAVE_NAME, 'wb'))
47
 
 
48
 
 
49
 
 
50
 
 
51
 
prof_f = tempfile.NamedTemporaryFile()
52
 
 
53
 
prof = hotshot.Profile(prof_f.name)
54
 
 
55
 
prof.runcall(convert) 
56
 
prof.close()
57
 
 
58
 
import hotshot.stats
59
 
stats = hotshot.stats.load(prof_f.name)
60
 
#stats.strip_dirs()
61
 
stats.sort_stats('time')
62
 
## XXX: Might like to write to stderr or the trace file instead but
63
 
## print_stats seems hardcoded to stdout
64
 
stats.print_stats(20)
65
 
            
66
 
 
 
25
 
 
26
WEAVE_NAME = "inventory.weave"
 
27
 
 
28
wf = Weave()
 
29
 
 
30
b = bzrlib.branch.find_branch('.')
 
31
 
 
32
print 'converting...'
 
33
 
 
34
parents = set()
 
35
revno = 1
 
36
for rev_id in b.revision_history():
 
37
    print revno
 
38
    inv_xml = b.inventory_store[rev_id].readlines()
 
39
    weave_id = wf.add(parents, inv_xml)
 
40
    parents.add(weave_id)
 
41
    revno += 1
 
42
 
 
43
write_weave(wf, file(WEAVE_NAME, 'wb'))