/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)
16
    
17
bt = wt.basis_tree()
18
file_id = wt.path2id(path)
19
file_weave = bt.get_weave(file_id)
20
for revision in file_weave.get_ancestry([bt.inventory[file_id].revision]):
21
    parents = file_weave.get_parents(revision)
22
    if single_parent:
23
        parents = parents[0:1]
24
    texts = file_weave.get_texts([revision] + parents)
25
    print revision
26
    patch_iter = MultiParent.from_texts(texts[0], texts[1:]).to_patch()
27
    sys.stdout.writelines(patch_iter)