~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-03-11 13:47:06 UTC
  • mfrom: (5051.3.16 use-branch-open)
  • Revision ID: pqm@pqm.ubuntu.com-20100311134706-kaerqhx3lf7xn6rh
(Jelmer) Pass colocated branch names further down the call stack.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Read in a bundle stream, and process it into a BundleReader object."""
18
18
 
27
27
    )
28
28
import bzrlib.errors
29
29
from bzrlib.bundle import apply_bundle
30
 
from bzrlib.errors import (TestamentMismatch, BzrError, 
 
30
from bzrlib.errors import (TestamentMismatch, BzrError,
31
31
                           MalformedHeader, MalformedPatches, NotABundle)
32
32
from bzrlib.inventory import (Inventory, InventoryEntry,
33
33
                              InventoryDirectory, InventoryFile,
159
159
    def get_base(self, revision):
160
160
        revision_info = self.get_revision_info(revision.revision_id)
161
161
        if revision_info.base_id is not None:
162
 
            if revision_info.base_id == NULL_REVISION:
163
 
                return None
164
 
            else:
165
 
                return revision_info.base_id
 
162
            return revision_info.base_id
166
163
        if len(revision.parent_ids) == 0:
167
164
            # There is no base listed, and
168
165
            # the lowest revision doesn't have a parent
169
166
            # so this is probably against the empty tree
170
 
            # and thus base truly is None
171
 
            return None
 
167
            # and thus base truly is NULL_REVISION
 
168
            return NULL_REVISION
172
169
        else:
173
170
            return revision.parent_ids[-1]
174
171
 
203
200
            self._validate_references_from_repository(repository)
204
201
        revision_info = self.get_revision_info(revision_id)
205
202
        inventory_revision_id = revision_id
206
 
        bundle_tree = BundleTree(repository.revision_tree(base), 
 
203
        bundle_tree = BundleTree(repository.revision_tree(base),
207
204
                                  inventory_revision_id)
208
205
        self._update_tree(bundle_tree, revision_id)
209
206
 
242
239
        for rev_info in self.revisions:
243
240
            checked[rev_info.revision_id] = True
244
241
            add_sha(rev_to_sha, rev_info.revision_id, rev_info.sha1)
245
 
                
 
242
 
246
243
        for (rev, rev_info) in zip(self.real_revisions, self.revisions):
247
244
            add_sha(inv_to_sha, rev_info.revision_id, rev_info.inventory_sha1)
248
245
 
250
247
        missing = {}
251
248
        for revision_id, sha1 in rev_to_sha.iteritems():
252
249
            if repository.has_revision(revision_id):
253
 
                testament = StrictTestament.from_revision(repository, 
 
250
                testament = StrictTestament.from_revision(repository,
254
251
                                                          revision_id)
255
252
                local_sha1 = self._testament_sha1_from_revision(repository,
256
253
                                                                revision_id)
257
254
                if sha1 != local_sha1:
258
 
                    raise BzrError('sha1 mismatch. For revision id {%s}' 
 
255
                    raise BzrError('sha1 mismatch. For revision id {%s}'
259
256
                            'local: %s, bundle: %s' % (revision_id, local_sha1, sha1))
260
257
                else:
261
258
                    count += 1
290
287
 
291
288
        # This is a mapping from each revision id to it's sha hash
292
289
        rev_to_sha1 = {}
293
 
        
 
290
 
294
291
        rev = self.get_revision(revision_id)
295
292
        rev_info = self.get_revision_info(revision_id)
296
293
        if not (rev.revision_id == rev_info.revision_id):
414
411
            revision = get_rev_id(last_modified, path, kind)
415
412
            if lines:
416
413
                do_patch(path, lines, encoding)
417
 
            
 
414
 
418
415
        valid_actions = {
419
416
            'renamed':renamed,
420
417
            'removed':removed,
542
539
        #renamed_r
543
540
        if old_path in self._renamed_r:
544
541
            return None
545
 
        return old_path 
 
542
        return old_path
546
543
 
547
544
    def new_path(self, old_path):
548
545
        """Get the new_path (path in the target_tree) for the file at old_path
568
565
        #renamed_r
569
566
        if new_path in self._renamed:
570
567
            return None
571
 
        return new_path 
 
568
        return new_path
572
569
 
573
570
    def path2id(self, path):
574
571
        """Return the id of the file present at path in the target tree."""
608
605
                return None
609
606
        new_path = self.id2path(file_id)
610
607
        return self.base_tree.path2id(new_path)
611
 
        
 
608
 
612
609
    def get_file(self, file_id):
613
610
        """Return a file-like object containing the new contents of the
614
611
        file given by file_id.
625
622
            patch_original = None
626
623
        file_patch = self.patches.get(self.id2path(file_id))
627
624
        if file_patch is None:
628
 
            if (patch_original is None and 
 
625
            if (patch_original is None and
629
626
                self.get_kind(file_id) == 'directory'):
630
627
                return StringIO()
631
628
            if patch_original is None: