/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1616.1.7 by Martin Pool
New developer commands 'weave-list' and 'weave-join'.
1
# Copyright (C) 2006 by Canonical Ltd
2
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""builtin bzr commands relating to individual weave files
18
19
These should never normally need to be used by end users, but might be
20
of interest in debugging or data recovery.
21
"""
22
23
import sys
24
25
from bzrlib.commands import Command
26
27
class cmd_weave_list(Command):
28
    """List the revision ids present in a weave, in alphabetical order"""
29
30
    hidden = True
31
    takes_args = ['weave_filename']
32
33
    def run(self, weave_filename):
34
        from bzrlib.weavefile import read_weave
35
        weave = read_weave(file(weave_filename, 'rb'))
36
        names = weave.versions()
37
        names.sort()
38
        print '\n'.join(names)
39
40
41
class cmd_weave_join(Command):
42
    """Join the contents of two weave files.
43
44
    The resulting weave is sent to stdout.
45
46
    This command is only intended for bzr developer use.
47
    """
48
49
    hidden = True
50
    takes_args = ['weave1', 'weave2']
51
52
    def run(self, weave1, weave2):
53
        from bzrlib.weavefile import read_weave, write_weave
54
        w1 = read_weave(file(weave1, 'rb'))
55
        w2 = read_weave(file(weave2, 'rb'))
56
        w1.join(w2)
57
        write_weave(w1, sys.stdout)