~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-04 04:33:24 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100804043324-1ldc2v2w1kza7ox4
get into the nitty gritty for the _key_to_sha1 function.

It doesn't seem to help to op-out of the actual unhexlify call, so at least
that doesn't seem to be the performance overhead.
We get down to around 19.9us for _key_to_sha1 across 120 keys, which is
0.166us per key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""bzr upgrade logic."""
18
18
 
19
19
 
20
 
from bzrlib.bzrdir import BzrDir, BzrDirFormat, format_registry
 
20
from bzrlib.bzrdir import BzrDir, format_registry
21
21
import bzrlib.errors as errors
22
22
from bzrlib.remote import RemoteBzrDir
23
 
from bzrlib.transport import get_transport
24
23
import bzrlib.ui as ui
25
24
 
26
25
 
29
28
    def __init__(self, url, format=None):
30
29
        self.format = format
31
30
        self.bzrdir = BzrDir.open_unsupported(url)
 
31
        # XXX: Change to cleanup
 
32
        warning_id = 'cross_format_fetch'
 
33
        saved_warning = warning_id in ui.ui_factory.suppressed_warnings
32
34
        if isinstance(self.bzrdir, RemoteBzrDir):
33
35
            self.bzrdir._ensure_real()
34
36
            self.bzrdir = self.bzrdir._real_bzrdir
35
37
        if self.bzrdir.root_transport.is_readonly():
36
38
            raise errors.UpgradeReadonly
37
39
        self.transport = self.bzrdir.root_transport
38
 
        self.convert()
 
40
        ui.ui_factory.suppressed_warnings.add(warning_id)
 
41
        try:
 
42
            self.convert()
 
43
        finally:
 
44
            if not saved_warning:
 
45
                ui.ui_factory.suppressed_warnings.remove(warning_id)
39
46
 
40
47
    def convert(self):
41
48
        try:
42
49
            branch = self.bzrdir.open_branch()
43
 
            if branch.bzrdir.root_transport.base != \
44
 
                self.bzrdir.root_transport.base:
 
50
            if branch.user_url != self.bzrdir.user_url:
45
51
                ui.ui_factory.note("This is a checkout. The branch (%s) needs to be "
46
52
                             "upgraded separately." %
47
 
                             branch.bzrdir.root_transport.base)
 
53
                             branch.user_url)
48
54
            del branch
49
55
        except (errors.NotBranchError, errors.IncompatibleRepositories):
50
56
            # might not be a format we can open without upgrading; see e.g.