~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/v08.py

  • Committer: Patch Queue Manager
  • Date: 2014-02-12 18:22:22 UTC
  • mfrom: (6589.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20140212182222-beouo25gaf1cny76
(vila) The XDG Base Directory Specification uses the XDG_CACHE_HOME,
 not XDG_CACHE_DIR. (Andrew Starr-Bochicchio)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2009 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
17
17
"""Serializer factory for reading and writing bundles.
18
18
"""
19
19
 
20
 
import os
 
20
from __future__ import absolute_import
21
21
 
22
 
from bzrlib import errors
 
22
from bzrlib import (
 
23
    errors,
 
24
    ui,
 
25
    )
23
26
from bzrlib.bundle.serializer import (BundleSerializer,
24
27
                                      _get_bundle_header,
25
28
                                     )
26
29
from bzrlib.bundle.serializer import binary_diff
27
 
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
 
30
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo)
28
31
from bzrlib.diff import internal_diff
29
 
from bzrlib.osutils import pathjoin
30
 
from bzrlib.progress import DummyProgress
31
32
from bzrlib.revision import NULL_REVISION
32
 
import bzrlib.ui
33
33
from bzrlib.testament import StrictTestament
34
34
from bzrlib.timestamp import (
35
35
    format_highres_date,
36
 
    unpack_highres_date,
37
 
)
 
36
    )
38
37
from bzrlib.textfile import text_file
39
38
from bzrlib.trace import mutter
40
39
 
119
118
        source.lock_read()
120
119
        try:
121
120
            self._write_main_header()
122
 
            pb = DummyProgress()
 
121
            pb = ui.ui_factory.nested_progress_bar()
123
122
            try:
124
123
                self._write_revisions(pb)
125
124
            finally:
126
 
                pass
127
 
                #pb.finished()
 
125
                pb.finished()
128
126
        finally:
129
127
            source.unlock()
130
128
 
183
181
 
184
182
        i_max = len(self.revision_ids)
185
183
        for i, rev_id in enumerate(self.revision_ids):
186
 
            pb.update("Generating revsion data", i, i_max)
 
184
            pb.update("Generating revision data", i, i_max)
187
185
            rev = self.source.get_revision(rev_id)
188
186
            if rev_id == last_rev_id:
189
187
                rev_tree = last_rev_tree
263
261
 
264
262
        def do_diff(file_id, old_path, new_path, action, force_binary):
265
263
            def tree_lines(tree, require_text=False):
266
 
                if file_id in tree:
 
264
                if tree.has_id(file_id):
267
265
                    tree_file = tree.get_file(file_id)
268
266
                    if require_text is True:
269
267
                        tree_file = text_file(tree_file)
289
287
 
290
288
        def finish_action(action, file_id, kind, meta_modified, text_modified,
291
289
                          old_path, new_path):
292
 
            entry = new_tree.inventory[file_id]
 
290
            entry = new_tree.root_inventory[file_id]
293
291
            if entry.revision != default_revision_id:
294
292
                action.add_utf8_property('last-changed', entry.revision)
295
293
            if meta_modified:
326
324
                          path, path)
327
325
 
328
326
        for path, file_id, kind in delta.unchanged:
329
 
            ie = new_tree.inventory[file_id]
330
 
            new_rev = getattr(ie, 'revision', None)
 
327
            new_rev = new_tree.get_file_revision(file_id)
331
328
            if new_rev is None:
332
329
                continue
333
 
            old_rev = getattr(old_tree.inventory[ie.file_id], 'revision', None)
 
330
            old_rev = old_tree.get_file_revision(file_id)
334
331
            if new_rev != old_rev:
335
 
                action = Action('modified', [ie.kind,
336
 
                                             new_tree.id2path(ie.file_id)])
337
 
                action.add_utf8_property('last-changed', ie.revision)
 
332
                action = Action('modified', [new_tree.kind(file_id),
 
333
                                             new_tree.id2path(file_id)])
 
334
                action.add_utf8_property('last-changed', new_rev)
338
335
                action.write(self.to_file)
339
336
 
340
337
 
553
550
        testament = StrictTestament.from_revision(repository, revision_id)
554
551
        return testament.as_sha1()
555
552
 
556
 
    def _testament_sha1(self, revision, inventory):
557
 
        return StrictTestament(revision, inventory).as_sha1()
 
553
    def _testament_sha1(self, revision, tree):
 
554
        return StrictTestament(revision, tree).as_sha1()