/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/fetch.py

  • Committer: Robey Pointer
  • Date: 2006-09-08 18:46:29 UTC
  • mto: This revision was merged to the branch mainline in revision 1996.
  • Revision ID: robey@lag.net-20060908184629-e3fc4c61ca21508c
pychecker is on crack; go back to using 'is None'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
33
 
34
34
import bzrlib
35
35
import bzrlib.errors as errors
36
 
from bzrlib.errors import (InstallFailed, NoSuchRevision,
37
 
                           MissingText)
 
36
from bzrlib.errors import (InstallFailed,
 
37
                           )
38
38
from bzrlib.trace import mutter
39
 
from bzrlib.progress import ProgressBar, ProgressPhase
40
 
from bzrlib.reconcile import RepoReconciler
 
39
from bzrlib.progress import ProgressPhase
41
40
from bzrlib.revision import NULL_REVISION
42
 
from bzrlib.symbol_versioning import *
 
41
from bzrlib.symbol_versioning import (deprecated_function,
 
42
        deprecated_method,
 
43
        zero_eight,
 
44
        )
43
45
 
44
46
 
45
47
# TODO: Avoid repeatedly opening weaves so many times.
124
126
        self.from_control = self.from_repository.control_weaves
125
127
        self.count_total = 0
126
128
        self.file_ids_names = {}
127
 
        pp = ProgressPhase('fetch phase', 4, self.pb)
 
129
        pp = ProgressPhase('Fetch phase', 4, self.pb)
128
130
        try:
 
131
            pp.next_phase()
129
132
            revs = self._revids_to_fetch()
130
133
            # something to do ?
131
134
            if revs:
144
147
        if self._last_revision is NULL_REVISION:
145
148
            # explicit limit of no revisions needed
146
149
            return None
147
 
        if (self._last_revision != None and
 
150
        if (self._last_revision is not None and
148
151
            self.to_repository.has_revision(self._last_revision)):
149
152
            return None
150
153
            
157
160
    def _fetch_weave_texts(self, revs):
158
161
        texts_pb = bzrlib.ui.ui_factory.nested_progress_bar()
159
162
        try:
160
 
            file_ids = self.from_repository.fileid_involved_by_set(revs)
 
163
            # fileids_altered_by_revision_ids requires reading the inventory
 
164
            # weave, we will need to read the inventory weave again when
 
165
            # all this is done, so enable caching for that specific weave
 
166
            inv_w = self.from_repository.get_inventory_weave()
 
167
            inv_w.enable_cache()
 
168
            file_ids = self.from_repository.fileids_altered_by_revision_ids(revs)
161
169
            count = 0
162
170
            num_file_ids = len(file_ids)
163
 
            for file_id in file_ids:
 
171
            for file_id, required_versions in file_ids.items():
164
172
                texts_pb.update("fetch texts", count, num_file_ids)
165
173
                count +=1
166
 
                try:
167
 
                    to_weave = self.to_weaves.get_weave(file_id,
168
 
                        self.to_repository.get_transaction())
169
 
                except errors.NoSuchFile:
170
 
                    # destination is empty, just copy it.
171
 
                    # this copies all the texts, which is useful and 
172
 
                    # on per-file basis quite cheap.
173
 
                    self.to_weaves.copy_multi(
174
 
                        self.from_weaves,
175
 
                        [file_id],
176
 
                        None,
177
 
                        self.from_repository.get_transaction(),
178
 
                        self.to_repository.get_transaction())
179
 
                else:
180
 
                    # destination has contents, must merge
181
 
                    from_weave = self.from_weaves.get_weave(file_id,
182
 
                        self.from_repository.get_transaction())
183
 
                    # we fetch all the texts, because texts do
184
 
                    # not reference anything, and its cheap enough
185
 
                    to_weave.join(from_weave)
 
174
                to_weave = self.to_weaves.get_weave_or_empty(file_id,
 
175
                    self.to_repository.get_transaction())
 
176
                from_weave = self.from_weaves.get_weave(file_id,
 
177
                    self.from_repository.get_transaction())
 
178
                # we fetch all the texts, because texts do
 
179
                # not reference anything, and its cheap enough
 
180
                to_weave.join(from_weave, version_ids=required_versions)
 
181
                # we don't need *all* of this data anymore, but we dont know
 
182
                # what we do. This cache clearing will result in a new read 
 
183
                # of the knit data when we do the checkout, but probably we
 
184
                # want to emit the needed data on the fly rather than at the
 
185
                # end anyhow.
 
186
                # the from weave should know not to cache data being joined,
 
187
                # but its ok to ask it to clear.
 
188
                from_weave.clear_cache()
 
189
                to_weave.clear_cache()
186
190
        finally:
187
191
            texts_pb.finished()
188
192
 
195
199
    
196
200
            child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
197
201
            try:
198
 
                # just merge, this is optimisable and its means we dont
 
202
                # just merge, this is optimisable and its means we don't
199
203
                # copy unreferenced data such as not-needed inventories.
200
204
                pb.update("fetch inventory", 1, 3)
201
205
                from_weave = self.from_repository.get_inventory_weave()
206
210
                # corrupt.
207
211
                to_weave.join(from_weave, pb=child_pb, msg='merge inventory',
208
212
                              version_ids=revs)
 
213
                from_weave.clear_cache()
209
214
            finally:
210
215
                child_pb.finished()
211
216
        finally:
277
282
 
278
283
 
279
284
class Fetcher(object):
280
 
    """Backwards compatability glue for branch.fetch()."""
 
285
    """Backwards compatibility glue for branch.fetch()."""
281
286
 
282
287
    @deprecated_method(zero_eight)
283
288
    def __init__(self, to_branch, from_branch, last_revision=None, pb=None):