~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-25 21:50:11 UTC
  • mfrom: (0.11.3 tools)
  • mto: This revision was merged to the branch mainline in revision 3659.
  • Revision ID: john@arbash-meinel.com-20080825215011-de9esmzgkue3e522
Merge in Lukáš's helper scripts.
Update the packaging documents to describe how to do the releases
using bzr-builddeb to package all distro platforms
simultaneously.

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