/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bundle/commands.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-18 09:43:41 UTC
  • mto: (2778.5.1 vila)
  • mto: This revision was merged to the branch mainline in revision 2789.
  • Revision ID: v.ladeuil+lp@free.fr-20070718094341-edmgsog3el06yqow
Add performance analysis of missing.

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',
78
 
                     Option("output", help="write bundle to specified file",
79
 
                            type=unicode)]
 
99
    takes_options = ['revision', 'remember',
 
100
                     Option("output",
 
101
                            help="Write bundle to specified file.",
 
102
                            type=unicode),
 
103
                     ]
80
104
    takes_args = ['base?']
81
105
    aliases = ['bundle']
 
106
    encoding_type = 'exact'
82
107
 
83
108
    def run(self, base=None, revision=None, output=None, remember=False):
84
109
        from bzrlib import user_encoding
85
110
        from bzrlib.bundle.serializer import write_bundle
86
111
 
87
 
        target_branch = Branch.open_containing(u'.')[0]
 
112
        target_branch = branch.Branch.open_containing(u'.')[0]
88
113
 
89
114
        if base is None:
90
115
            base_specified = False
92
117
            base_specified = True
93
118
 
94
119
        if revision is None:
95
 
            target_revision = target_branch.last_revision()
 
120
            target_revision = _mod_revision.ensure_null(
 
121
                target_branch.last_revision())
96
122
        elif len(revision) < 3:
97
123
            target_revision = revision[-1].in_history(target_branch).rev_id
98
124
            if len(revision) == 2:
118
144
                # we must format with 'ascii' to be safe
119
145
                note('Using saved location: %s',
120
146
                     urlutils.unescape_for_display(base, 'ascii'))
121
 
            base_branch = Branch.open(base)
 
147
            base_branch = branch.Branch.open(base)
122
148
 
123
149
            # We don't want to lock the same branch across
124
150
            # 2 different branches
130
156
                elif remember:
131
157
                    raise errors.BzrCommandError('--remember requires a branch'
132
158
                                                 ' to be specified.')
 
159
            base_last_revision = _mod_revision.ensure_null(
 
160
                base_branch.last_revision())
133
161
            target_branch.repository.fetch(base_branch.repository, 
134
 
                                           base_branch.last_revision())
135
 
            base_revision = common_ancestor(base_branch.last_revision(),
136
 
                                            target_revision,
137
 
                                            target_branch.repository)
138
 
 
 
162
                base_last_revision)
 
163
            graph = target_branch.repository.get_graph()
 
164
            base_revision = graph.find_unique_lca(base_last_revision,
 
165
                                                  target_revision)
139
166
 
140
167
        if output is not None:
141
168
            fileobj = file(output, 'wb')
159
186
        from read_changeset import read_changeset
160
187
        #from bzrlib.xml import serializer_v4
161
188
 
162
 
        b, relpath = Branch.open_containing('.')
 
189
        b, relpath = branch.Branch.open_containing('.')
163
190
 
164
191
        if filename is None or filename == '-':
165
192
            f = sys.stdin