~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-17 08:59:19 UTC
  • mfrom: (5037.2.1 doc)
  • Revision ID: pqm@pqm.ubuntu.com-20100217085919-23vc62bvq8848q65
(mbp) rest markup fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
29
29
 
30
30
import os
31
31
import sys
 
32
import warnings
32
33
 
33
34
from bzrlib.lazy_import import lazy_import
34
35
lazy_import(globals(), """
354
355
                for subdir in sorted(subdirs, reverse=True):
355
356
                    pending.append(current_transport.clone(subdir))
356
357
 
 
358
    def list_branches(self):
 
359
        """Return a sequence of all branches local to this control directory.
 
360
 
 
361
        """
 
362
        try:
 
363
            return [self.open_branch()]
 
364
        except errors.NotBranchError:
 
365
            return []
 
366
 
357
367
    @staticmethod
358
368
    def find_branches(transport):
359
369
        """Find all branches under a transport.
371
381
            except errors.NoRepositoryPresent:
372
382
                pass
373
383
            else:
374
 
                return False, (None, repository)
375
 
            try:
376
 
                branch = bzrdir.open_branch()
377
 
            except errors.NotBranchError:
378
 
                return True, (None, None)
379
 
            else:
380
 
                return True, (branch, None)
381
 
        branches = []
382
 
        for branch, repo in BzrDir.find_bzrdirs(transport, evaluate=evaluate):
 
384
                return False, ([], repository)
 
385
            return True, (bzrdir.list_branches(), None)
 
386
        ret = []
 
387
        for branches, repo in BzrDir.find_bzrdirs(transport,
 
388
                                                  evaluate=evaluate):
383
389
            if repo is not None:
384
 
                branches.extend(repo.find_branches())
385
 
            if branch is not None:
386
 
                branches.append(branch)
387
 
        return branches
 
390
                ret.extend(repo.find_branches())
 
391
            if branches is not None:
 
392
                ret.extend(branches)
 
393
        return ret
388
394
 
389
395
    def destroy_repository(self):
390
396
        """Destroy the repository in this BzrDir"""
2609
2615
    def convert(self, to_convert, pb):
2610
2616
        """See Converter.convert()."""
2611
2617
        self.bzrdir = to_convert
2612
 
        self.pb = pb
2613
 
        ui.ui_factory.note('starting upgrade from format 4 to 5')
2614
 
        if isinstance(self.bzrdir.transport, local.LocalTransport):
2615
 
            self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2616
 
        self._convert_to_weaves()
2617
 
        return BzrDir.open(self.bzrdir.root_transport.base)
 
2618
        if pb is not None:
 
2619
            warnings.warn("pb parameter to convert() is deprecated")
 
2620
        self.pb = ui.ui_factory.nested_progress_bar()
 
2621
        try:
 
2622
            ui.ui_factory.note('starting upgrade from format 4 to 5')
 
2623
            if isinstance(self.bzrdir.transport, local.LocalTransport):
 
2624
                self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
 
2625
            self._convert_to_weaves()
 
2626
            return BzrDir.open(self.bzrdir.root_transport.base)
 
2627
        finally:
 
2628
            self.pb.finished()
2618
2629
 
2619
2630
    def _convert_to_weaves(self):
2620
2631
        ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2861
2872
    def convert(self, to_convert, pb):
2862
2873
        """See Converter.convert()."""
2863
2874
        self.bzrdir = to_convert
2864
 
        self.pb = pb
2865
 
        ui.ui_factory.note('starting upgrade from format 5 to 6')
2866
 
        self._convert_to_prefixed()
2867
 
        return BzrDir.open(self.bzrdir.root_transport.base)
 
2875
        pb = ui.ui_factory.nested_progress_bar()
 
2876
        try:
 
2877
            ui.ui_factory.note('starting upgrade from format 5 to 6')
 
2878
            self._convert_to_prefixed()
 
2879
            return BzrDir.open(self.bzrdir.root_transport.base)
 
2880
        finally:
 
2881
            pb.finished()
2868
2882
 
2869
2883
    def _convert_to_prefixed(self):
2870
2884
        from bzrlib.store import TransportStore
2903
2917
        from bzrlib.repofmt.weaverepo import RepositoryFormat7
2904
2918
        from bzrlib.branch import BzrBranchFormat5
2905
2919
        self.bzrdir = to_convert
2906
 
        self.pb = pb
 
2920
        self.pb = ui.ui_factory.nested_progress_bar()
2907
2921
        self.count = 0
2908
2922
        self.total = 20 # the steps we know about
2909
2923
        self.garbage_inventories = []
2989
3003
            'branch-format',
2990
3004
            BzrDirMetaFormat1().get_format_string(),
2991
3005
            mode=self.file_mode)
 
3006
        self.pb.finished()
2992
3007
        return BzrDir.open(self.bzrdir.root_transport.base)
2993
3008
 
2994
3009
    def make_lock(self, name):
3030
3045
    def convert(self, to_convert, pb):
3031
3046
        """See Converter.convert()."""
3032
3047
        self.bzrdir = to_convert
3033
 
        self.pb = pb
 
3048
        self.pb = ui.ui_factory.nested_progress_bar()
3034
3049
        self.count = 0
3035
3050
        self.total = 1
3036
3051
        self.step('checking repository format')
3044
3059
                ui.ui_factory.note('starting repository conversion')
3045
3060
                converter = CopyConverter(self.target_format.repository_format)
3046
3061
                converter.convert(repo, pb)
3047
 
        try:
3048
 
            branch = self.bzrdir.open_branch()
3049
 
        except errors.NotBranchError:
3050
 
            pass
3051
 
        else:
 
3062
        for branch in self.bzrdir.list_branches():
3052
3063
            # TODO: conversions of Branch and Tree should be done by
3053
3064
            # InterXFormat lookups/some sort of registry.
3054
3065
            # Avoid circular imports
3096
3107
                isinstance(self.target_format.workingtree_format,
3097
3108
                    workingtree_4.WorkingTreeFormat6)):
3098
3109
                workingtree_4.Converter4or5to6().convert(tree)
 
3110
        self.pb.finished()
3099
3111
        return to_convert
3100
3112
 
3101
3113