~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

(Michael Hudson) clean up option.py and branch.py imports

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
 
from cStringIO import StringIO
19
 
 
20
18
from bzrlib.lazy_import import lazy_import
21
19
lazy_import(globals(), """
22
 
from warnings import warn
23
 
 
24
 
import bzrlib
25
20
from bzrlib import (
26
21
        bzrdir,
27
22
        cache_utf8,
30
25
        errors,
31
26
        lockdir,
32
27
        lockable_files,
33
 
        osutils,
34
28
        revision as _mod_revision,
35
29
        transport,
36
 
        tree,
37
30
        tsort,
38
31
        ui,
39
32
        urlutils,
40
33
        )
41
 
from bzrlib.config import BranchConfig, TreeConfig
42
 
from bzrlib.lockable_files import LockableFiles, TransportLock
 
34
from bzrlib.config import BranchConfig
43
35
from bzrlib.tag import (
44
36
    BasicTags,
45
37
    DisabledTags,
47
39
""")
48
40
 
49
41
from bzrlib.decorators import needs_read_lock, needs_write_lock
50
 
from bzrlib.errors import (BzrError, BzrCheckError, DivergedBranches,
51
 
                           HistoryMissing, InvalidRevisionId,
52
 
                           InvalidRevisionNumber, LockError, NoSuchFile,
53
 
                           NoSuchRevision, NotVersionedError,
54
 
                           NotBranchError, UninitializableFormat,
55
 
                           UnlistableStore, UnlistableBranch,
56
 
                           )
57
42
from bzrlib.hooks import Hooks
58
 
from bzrlib.symbol_versioning import (deprecated_function,
59
 
                                      deprecated_method,
60
 
                                      DEPRECATED_PARAMETER,
61
 
                                      deprecated_passed,
62
 
                                      zero_eight, zero_nine, zero_sixteen,
63
 
                                      zero_ninetyone,
 
43
from bzrlib.symbol_versioning import (deprecated_method,
 
44
                                      zero_sixteen,
64
45
                                      )
65
46
from bzrlib.trace import mutter, mutter_callsite, note, is_quiet
66
47
 
338
319
        assert isinstance(revno, int)
339
320
        rh = self.revision_history()
340
321
        if not (1 <= revno <= len(rh)):
341
 
            raise InvalidRevisionNumber(revno)
 
322
            raise errors.InvalidRevisionNumber(revno)
342
323
        return self.repository.get_revision_delta(rh[revno-1])
343
324
 
344
325
    @deprecated_method(zero_sixteen)
464
445
        common_index = min(self_len, other_len) -1
465
446
        if common_index >= 0 and \
466
447
            self_history[common_index] != other_history[common_index]:
467
 
            raise DivergedBranches(self, other)
 
448
            raise errors.DivergedBranches(self, other)
468
449
 
469
450
        if stop_revision is None:
470
451
            stop_revision = other_len
643
624
        Zero (the NULL revision) is considered invalid
644
625
        """
645
626
        if revno < 1 or revno > self.revno():
646
 
            raise InvalidRevisionNumber(revno)
 
627
            raise errors.InvalidRevisionNumber(revno)
647
628
 
648
629
    @needs_read_lock
649
630
    def clone(self, to_bzrdir, revision_id=None):
851
832
            transport = a_bzrdir.get_branch_transport(None)
852
833
            format_string = transport.get("format").read()
853
834
            return klass._formats[format_string]
854
 
        except NoSuchFile:
855
 
            raise NotBranchError(path=transport.base)
 
835
        except errors.NoSuchFile:
 
836
            raise errors.NotBranchError(path=transport.base)
856
837
        except KeyError:
857
838
            raise errors.UnknownFormatError(format=format_string)
858
839
 
1140
1121
                              _control_files=control_files,
1141
1122
                              a_bzrdir=a_bzrdir,
1142
1123
                              _repository=a_bzrdir.find_repository())
1143
 
        except NoSuchFile:
1144
 
            raise NotBranchError(path=transport.base)
 
1124
        except errors.NoSuchFile:
 
1125
            raise errors.NotBranchError(path=transport.base)
1145
1126
 
1146
1127
 
1147
1128
class BzrBranchFormat6(BzrBranchFormat5):
1548
1529
        for l in _locs:
1549
1530
            try:
1550
1531
                return self.control_files.get(l).read().strip('\n')
1551
 
            except NoSuchFile:
 
1532
            except errors.NoSuchFile:
1552
1533
                pass
1553
1534
        return None
1554
1535
 
1632
1613
        result.old_revno, result.old_revid = target.last_revision_info()
1633
1614
        try:
1634
1615
            target.update_revisions(self, stop_revision)
1635
 
        except DivergedBranches:
 
1616
        except errors.DivergedBranches:
1636
1617
            if not overwrite:
1637
1618
                raise
1638
1619
        if overwrite:
1771
1752
        else:
1772
1753
            try:
1773
1754
                self.control_files._transport.delete('bound')
1774
 
            except NoSuchFile:
 
1755
            except errors.NoSuchFile:
1775
1756
                return False
1776
1757
            return True
1777
1758
 
2088
2069
        new_branch.control_files._transport.delete('revision-history')
2089
2070
        try:
2090
2071
            branch.set_parent(None)
2091
 
        except NoSuchFile:
 
2072
        except errors.NoSuchFile:
2092
2073
            pass
2093
2074
        branch.set_bound_location(None)