~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/commands.py

  • Committer: Martin Pool
  • Date: 2006-06-20 07:55:43 UTC
  • mfrom: (1798 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1799.
  • Revision ID: mbp@sourcefrog.net-20060620075543-b10f6575d4a4fa32
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
from bzrlib.revision import (common_ancestor, MultipleRevisionSources,
16
16
                             NULL_REVISION)
17
17
from bzrlib.revisionspec import RevisionSpec
 
18
from bzrlib.trace import note
18
19
 
19
20
 
20
21
class cmd_send_changeset(Command):
64
65
 
65
66
    You can apply it to another tree using 'bzr merge'.
66
67
 
67
 
    bzr bundle
 
68
    bzr bundle-revisions
68
69
        - Bundle for the last commit
69
 
    bzr bundle BASE
 
70
    bzr bundle-revisions BASE
70
71
        - Bundle to apply the current tree into BASE
71
 
    bzr bundle --revision A
 
72
    bzr bundle-revisions --revision A
72
73
        - Bundle for revision A
73
 
    bzr bundle --revision A..B
 
74
    bzr bundle-revisions --revision A..B
74
75
        - Bundle to transform A into B
75
 
    bzr bundle --revision A..B BASE
 
76
    bzr bundle-revisions --revision A..B BASE
76
77
        - Bundle to transform revision A of BASE into revision B
77
78
          of the local tree
78
79
    """
79
 
    takes_options = ['verbose', 'revision']
 
80
    takes_options = ['verbose', 'revision',
 
81
                     Option("output", help="write bundle to specified file",
 
82
                            type=unicode)]
80
83
    takes_args = ['base?']
81
84
    aliases = ['bundle']
82
85
 
83
 
    def run(self, base=None, revision=None):
 
86
    def run(self, base=None, revision=None, output=None):
84
87
        from bzrlib import user_encoding
85
88
        from bzrlib.bundle.serializer import write_bundle
86
89
 
 
90
        target_branch = Branch.open_containing(u'.')[0]
 
91
 
87
92
        if base is None:
88
 
            base_branch = None
89
 
        else:
90
 
            base_branch = Branch.open(base)
 
93
            base = target_branch.get_parent()
 
94
            if base is None:
 
95
                raise errors.BzrCommandError("No base branch known or"
 
96
                                             " specified.")
 
97
            else:
 
98
                note('Using saved location: %s' % base)
 
99
        base_branch = Branch.open(base)
91
100
 
92
101
        # We don't want to lock the same branch across
93
102
        # 2 different branches
94
 
        target_branch = Branch.open_containing(u'.')[0]
95
 
        if base_branch is not None and target_branch.base == base_branch.base:
96
 
            base_branch = None
 
103
        if target_branch.base == base_branch.base:
 
104
            base_branch = target_branch 
97
105
 
98
106
        base_revision = None
99
107
        if revision is None:
132
140
            target_branch.repository.fetch(base_branch.repository, 
133
141
                                           revision_id=base_revision)
134
142
            del base_branch
 
143
 
 
144
        if output is not None:
 
145
            fileobj = file(output, 'wb')
 
146
        else:
 
147
            fileobj = sys.stdout
135
148
        write_bundle(target_branch.repository, target_revision, base_revision,
136
 
                     sys.stdout)
 
149
                     fileobj)
137
150
 
138
151
 
139
152
class cmd_verify_changeset(Command):