/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.9.6 by Aaron Bentley
Add mpknit command
1
#!/usr/bin/env python2.4
2
import sys
3
4
from bzrlib.workingtree import WorkingTree 
5
6
from multiparent import MultiParent
7
single_parent = False
8
if len(sys.argv) > 1 and len(sys.argv) < 4:
9
    wt, path = WorkingTree.open_containing(sys.argv[-1])
10
    if len(sys.argv) == 3:
11
        assert sys.argv[1] == '--single'
12
        single_parent = True
13
else:
14
    print >> sys.stderr, 'Usage: mpknit [--single] FILENAME'
15
    sys.exit(3)
0.10.1 by Aaron Bentley
Tree locking's always a good idea
16
wt.lock_read()
17
try:
18
    bt = wt.basis_tree()
19
    file_id = wt.path2id(path)
20
    file_weave = bt.get_weave(file_id)
21
    for revision in file_weave.get_ancestry([bt.inventory[file_id].revision]):
22
        parents = file_weave.get_parents(revision)
23
        if single_parent:
24
            parents = parents[0:1]
25
        texts = file_weave.get_texts([revision] + parents)
26
        print revision
27
        patch_iter = MultiParent.from_texts(texts[0], texts[1:]).to_patch()
28
        sys.stdout.writelines(patch_iter)
29
finally:
30
    wt.unlock()