~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/commands.py

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
 
1
# Copyright (C) 2006 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
2
16
"""\
3
17
This is an attempt to take the internal delta object, and represent
4
18
it as a single-file text-only changeset.
8
22
 
9
23
import sys
10
24
 
11
 
from bzrlib.branch import Branch
12
 
from bzrlib.commands import Command, register_command
13
 
import bzrlib.errors as errors
 
25
from bzrlib.lazy_import import lazy_import
 
26
lazy_import(globals(), """
 
27
from bzrlib import (
 
28
    branch,
 
29
    errors,
 
30
    revision as _mod_revision,
 
31
    urlutils,
 
32
    )
 
33
""")
 
34
 
 
35
from bzrlib.commands import Command
14
36
from bzrlib.option import Option
15
 
from bzrlib.revision import (common_ancestor, MultipleRevisionSources,
16
 
                             NULL_REVISION)
17
37
from bzrlib.trace import note
18
 
from bzrlib import urlutils
19
38
 
20
39
 
21
40
class cmd_send_changeset(Command):
43
62
                raise BzrCommandError('We do not support rollup-changesets yet.')
44
63
            revision = revision[0]
45
64
 
46
 
        b = Branch.open_containing('.')
 
65
        b = branch.Branch.open_containing('.')
47
66
 
48
67
        if not to:
49
68
            try:
67
86
 
68
87
    bzr bundle-revisions
69
88
        - Generate a bundle relative to a remembered location
 
89
 
70
90
    bzr bundle-revisions BASE
71
91
        - Bundle to apply the current tree into BASE
 
92
 
72
93
    bzr bundle-revisions --revision A
73
94
        - Bundle to apply revision A to remembered location 
 
95
 
74
96
    bzr bundle-revisions --revision A..B
75
97
        - Bundle to transform A into B
76
98
    """
77
 
    takes_options = ['verbose', 'revision', 'remember',
 
99
    takes_options = ['revision', 'remember',
78
100
                     Option("output", help="write bundle to specified file",
79
101
                            type=unicode)]
80
102
    takes_args = ['base?']
81
103
    aliases = ['bundle']
 
104
    encoding_type = 'exact'
82
105
 
83
106
    def run(self, base=None, revision=None, output=None, remember=False):
84
107
        from bzrlib import user_encoding
85
108
        from bzrlib.bundle.serializer import write_bundle
86
109
 
87
 
        target_branch = Branch.open_containing(u'.')[0]
 
110
        target_branch = branch.Branch.open_containing(u'.')[0]
88
111
 
89
112
        if base is None:
90
113
            base_specified = False
118
141
                # we must format with 'ascii' to be safe
119
142
                note('Using saved location: %s',
120
143
                     urlutils.unescape_for_display(base, 'ascii'))
121
 
            base_branch = Branch.open(base)
 
144
            base_branch = branch.Branch.open(base)
122
145
 
123
146
            # We don't want to lock the same branch across
124
147
            # 2 different branches
132
155
                                                 ' to be specified.')
133
156
            target_branch.repository.fetch(base_branch.repository, 
134
157
                                           base_branch.last_revision())
135
 
            base_revision = common_ancestor(base_branch.last_revision(),
136
 
                                            target_revision,
137
 
                                            target_branch.repository)
138
 
 
 
158
            graph = target_branch.repository.get_graph()
 
159
            base_revision = graph.find_unique_lca(
 
160
                _mod_revision.ensure_null(base_branch.last_revision()),
 
161
                _mod_revision.ensure_null(target_revision))
139
162
 
140
163
        if output is not None:
141
164
            fileobj = file(output, 'wb')
159
182
        from read_changeset import read_changeset
160
183
        #from bzrlib.xml import serializer_v4
161
184
 
162
 
        b, relpath = Branch.open_containing('.')
 
185
        b, relpath = branch.Branch.open_containing('.')
163
186
 
164
187
        if filename is None or filename == '-':
165
188
            f = sys.stdin