/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/bundle/serializer/v08.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 14:26:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105142658-vek3v6pzlxb751s2
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. 

@only_raises is evil and gave a hard time since any exception during
save_changes() was swallowed.

Possible improvements: 

- add some needs_write_lock decorators to crucial
  methods (_set_config_location ?) but keep locking the branch at higher levels

- decorate branch.unlock to call stack.save if last_lock() it True
  outside of @only_raises scope (evil decorator)

- add @needs_write_lock to stack.set and stack.remove (will probably get
  rid of most testing issues) we probably need a specialized decorator
  that can relay to the store and from there to the branch or whatever is
  needed. This will also helps bzr config to get it right. The
  get_mutable_section trick should not be needed anymore either.

- decorate branch.unlock to call stack.save if last_lock() it True outside
  of @only_raises scope (evil decorator)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
22
from bzrlib import (
23
23
    errors,
27
27
                                      _get_bundle_header,
28
28
                                     )
29
29
from bzrlib.bundle.serializer import binary_diff
30
 
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
 
30
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo)
31
31
from bzrlib.diff import internal_diff
32
 
from bzrlib.osutils import pathjoin
33
32
from bzrlib.revision import NULL_REVISION
34
33
from bzrlib.testament import StrictTestament
35
34
from bzrlib.timestamp import (
36
35
    format_highres_date,
37
 
    unpack_highres_date,
38
 
)
 
36
    )
39
37
from bzrlib.textfile import text_file
40
38
from bzrlib.trace import mutter
41
39
 
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)
553
551
        testament = StrictTestament.from_revision(repository, revision_id)
554
552
        return testament.as_sha1()
555
553
 
556
 
    def _testament_sha1(self, revision, inventory):
557
 
        return StrictTestament(revision, inventory).as_sha1()
 
554
    def _testament_sha1(self, revision, tree):
 
555
        return StrictTestament(revision, tree).as_sha1()