~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave_commands.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-03-16 14:01:20 UTC
  • mfrom: (3280.2.5 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080316140120-i3yq8yr1l66m11h7
Start 1.4 development

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""builtin bzr commands relating to individual weave files
18
18
 
36
36
        from bzrlib.weavefile import read_weave
37
37
        from bzrlib.transport import get_transport
38
38
        from bzrlib import osutils
39
 
        vf = read_weave(file(filename, 'rb'))
 
39
        from bzrlib.knit import KnitVersionedFile
 
40
        if filename.endswith('.knit'):
 
41
            transport = get_transport(osutils.dirname(filename))
 
42
            relpath = osutils.basename(filename)[:-len('.knit')]
 
43
            vf = KnitVersionedFile(relpath, transport)
 
44
        else:
 
45
            vf = read_weave(file(filename, 'rb'))
40
46
        names = vf.versions()
41
47
        names.sort()
42
48
        print '\n'.join(names)
43
49
 
44
50
 
 
51
class cmd_weave_join(Command):
 
52
    """Join the contents of two weave files.
 
53
 
 
54
    The resulting weave is sent to stdout.
 
55
 
 
56
    This command is only intended for bzr developer use.
 
57
    """
 
58
 
 
59
    hidden = True
 
60
    takes_args = ['weave1', 'weave2']
 
61
 
 
62
    def run(self, weave1, weave2):
 
63
        from bzrlib.weavefile import read_weave, write_weave
 
64
        w1 = read_weave(file(weave1, 'rb'))
 
65
        w2 = read_weave(file(weave2, 'rb'))
 
66
        w1.join(w2)
 
67
        write_weave(w1, sys.stdout)
 
68
 
 
69
 
45
70
class cmd_weave_plan_merge(Command):
46
71
    """Show the plan for merging two versions within a weave"""
47
72
    hidden = True