~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

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,
200
200
            self._validate_references_from_repository(repository)
201
201
        revision_info = self.get_revision_info(revision_id)
202
202
        inventory_revision_id = revision_id
203
 
        bundle_tree = BundleTree(repository.revision_tree(base), 
 
203
        bundle_tree = BundleTree(repository.revision_tree(base),
204
204
                                  inventory_revision_id)
205
205
        self._update_tree(bundle_tree, revision_id)
206
206
 
239
239
        for rev_info in self.revisions:
240
240
            checked[rev_info.revision_id] = True
241
241
            add_sha(rev_to_sha, rev_info.revision_id, rev_info.sha1)
242
 
                
 
242
 
243
243
        for (rev, rev_info) in zip(self.real_revisions, self.revisions):
244
244
            add_sha(inv_to_sha, rev_info.revision_id, rev_info.inventory_sha1)
245
245
 
247
247
        missing = {}
248
248
        for revision_id, sha1 in rev_to_sha.iteritems():
249
249
            if repository.has_revision(revision_id):
250
 
                testament = StrictTestament.from_revision(repository, 
 
250
                testament = StrictTestament.from_revision(repository,
251
251
                                                          revision_id)
252
252
                local_sha1 = self._testament_sha1_from_revision(repository,
253
253
                                                                revision_id)
254
254
                if sha1 != local_sha1:
255
 
                    raise BzrError('sha1 mismatch. For revision id {%s}' 
 
255
                    raise BzrError('sha1 mismatch. For revision id {%s}'
256
256
                            'local: %s, bundle: %s' % (revision_id, local_sha1, sha1))
257
257
                else:
258
258
                    count += 1
287
287
 
288
288
        # This is a mapping from each revision id to it's sha hash
289
289
        rev_to_sha1 = {}
290
 
        
 
290
 
291
291
        rev = self.get_revision(revision_id)
292
292
        rev_info = self.get_revision_info(revision_id)
293
293
        if not (rev.revision_id == rev_info.revision_id):
411
411
            revision = get_rev_id(last_modified, path, kind)
412
412
            if lines:
413
413
                do_patch(path, lines, encoding)
414
 
            
 
414
 
415
415
        valid_actions = {
416
416
            'renamed':renamed,
417
417
            'removed':removed,
539
539
        #renamed_r
540
540
        if old_path in self._renamed_r:
541
541
            return None
542
 
        return old_path 
 
542
        return old_path
543
543
 
544
544
    def new_path(self, old_path):
545
545
        """Get the new_path (path in the target_tree) for the file at old_path
565
565
        #renamed_r
566
566
        if new_path in self._renamed:
567
567
            return None
568
 
        return new_path 
 
568
        return new_path
569
569
 
570
570
    def path2id(self, path):
571
571
        """Return the id of the file present at path in the target tree."""
605
605
                return None
606
606
        new_path = self.id2path(file_id)
607
607
        return self.base_tree.path2id(new_path)
608
 
        
 
608
 
609
609
    def get_file(self, file_id):
610
610
        """Return a file-like object containing the new contents of the
611
611
        file given by file_id.
622
622
            patch_original = None
623
623
        file_patch = self.patches.get(self.id2path(file_id))
624
624
        if file_patch is None:
625
 
            if (patch_original is None and 
 
625
            if (patch_original is None and
626
626
                self.get_kind(file_id) == 'directory'):
627
627
                return StringIO()
628
628
            if patch_original is None: