~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2006-06-20 03:57:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: mbp@sourcefrog.net-20060620035711-400bb6b6bc6ff95b
Add pyflakes makefile target; fix many warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from copy import deepcopy
19
19
from cStringIO import StringIO
20
 
import errno
21
 
import os
22
 
import shutil
23
 
import sys
24
20
from unittest import TestSuite
25
21
from warnings import warn
26
22
 
30
26
from bzrlib.decorators import needs_read_lock, needs_write_lock
31
27
from bzrlib.delta import compare_trees
32
28
import bzrlib.errors as errors
33
 
from bzrlib.errors import (BzrError, InvalidRevisionNumber, InvalidRevisionId,
34
 
                           NoSuchRevision, HistoryMissing, NotBranchError,
35
 
                           DivergedBranches, LockError,
36
 
                           UninitializableFormat,
37
 
                           UnlistableStore,
38
 
                           UnlistableBranch, NoSuchFile, NotVersionedError,
 
29
from bzrlib.errors import (InvalidRevisionNumber,
 
30
                           NotBranchError,
 
31
                           DivergedBranches,
 
32
                           NoSuchFile,
39
33
                           NoWorkingTree)
40
 
import bzrlib.inventory as inventory
41
 
from bzrlib.inventory import Inventory
42
34
from bzrlib.lockable_files import LockableFiles, TransportLock
43
35
from bzrlib.lockdir import LockDir
44
 
from bzrlib.osutils import (isdir, quotefn,
45
 
                            rename, splitpath, sha_file,
46
 
                            file_kind, abspath, normpath, pathjoin,
47
 
                            safe_unicode,
 
36
from bzrlib.osutils import (
48
37
                            rmtree,
49
38
                            )
50
 
from bzrlib.repository import Repository
51
39
from bzrlib.revision import (
52
 
                             is_ancestor,
53
40
                             NULL_REVISION,
54
 
                             Revision,
55
41
                             )
56
 
from bzrlib.store import copy_all
57
 
from bzrlib.symbol_versioning import *
58
 
from bzrlib.textui import show_status
 
42
from bzrlib.symbol_versioning import (deprecated_function,
 
43
                                      deprecated_method,
 
44
                                      DEPRECATED_PARAMETER,
 
45
                                      deprecated_passed,
 
46
                                      zero_eight,
 
47
                                      )
59
48
from bzrlib.trace import mutter, note
60
 
import bzrlib.transactions as transactions
61
 
from bzrlib.transport import Transport, get_transport
62
 
from bzrlib.tree import EmptyTree, RevisionTree
63
 
import bzrlib.ui
 
49
from bzrlib.tree import EmptyTree
 
50
import bzrlib.ui as ui
64
51
import bzrlib.urlutils as urlutils
65
 
import bzrlib.xml5
66
52
 
67
53
 
68
54
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
219
205
        if self.base == from_branch.base:
220
206
            return (0, [])
221
207
        if pb is None:
222
 
            nested_pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
208
            nested_pb = ui.ui_factory.nested_progress_bar()
223
209
            pb = nested_pb
224
210
        else:
225
211
            nested_pb = None
361
347
        else:
362
348
            assert isinstance(stop_revision, int)
363
349
            if stop_revision > other_len:
364
 
                raise bzrlib.errors.NoSuchRevision(self, stop_revision)
 
350
                raise errors.NoSuchRevision(self, stop_revision)
365
351
        return other_history[self_len:stop_revision]
366
352
 
367
353
    def update_revisions(self, other, stop_revision=None):
564
550
        In particular this checks that revisions given in the revision-history
565
551
        do actually match up in the revision graph, and that they're all 
566
552
        present in the repository.
 
553
        
 
554
        Callers will typically also want to check the repository.
567
555
 
568
556
        :return: A BranchCheckResult.
569
557
        """
572
560
            try:
573
561
                revision = self.repository.get_revision(revision_id)
574
562
            except errors.NoSuchRevision, e:
575
 
                raise BzrCheckError("mainline revision {%s} not in repository"
576
 
                        % revision_id)
 
563
                raise errors.BzrCheckError("mainline revision {%s} not in repository"
 
564
                            % revision_id)
577
565
            # In general the first entry on the revision history has no parents.
578
566
            # But it's not illegal for it to have parents listed; this can happen
579
567
            # in imports from Arch when the parents weren't reachable.
580
568
            if mainline_parent_id is not None:
581
569
                if mainline_parent_id not in revision.parent_ids:
582
 
                    raise BzrCheckError("previous revision {%s} not listed among "
 
570
                    raise errors.BzrCheckError("previous revision {%s} not listed among "
583
571
                                        "parents of {%s}"
584
572
                                        % (mainline_parent_id, revision_id))
585
573
            mainline_parent_id = revision_id
899
887
        self._base = self._transport.base
900
888
        self._format = _format
901
889
        if _control_files is None:
902
 
            raise BzrBadParameterMissing('_control_files')
 
890
            raise ValueError('BzrBranch _control_files is None')
903
891
        self.control_files = _control_files
904
892
        if deprecated_passed(init):
905
893
            warn("BzrBranch.__init__(..., init=XXX): The init parameter is "
921
909
            if (not relax_version_check
922
910
                and not self._format.is_supported()):
923
911
                raise errors.UnsupportedFormatError(
924
 
                        'sorry, branch format %r not supported' % fmt,
 
912
                        'sorry, branch format %r not supported' % self._format,
925
913
                        ['use a different bzr version',
926
914
                         'or remove the .bzr directory'
927
915
                         ' and "bzr init" again'])
997
985
        FIXME: DELETE THIS METHOD when pre 0.8 support is removed.
998
986
        """
999
987
        if format is None:
1000
 
            format = BzrBranchFormat.find_format(self.bzrdir)
 
988
            format = BranchFormat.find_format(self.bzrdir)
1001
989
        self._format = format
1002
990
        mutter("got branch format %s", self._format)
1003
991
 
1152
1140
    @deprecated_method(zero_eight)
1153
1141
    def working_tree(self):
1154
1142
        """Create a Working tree object for this branch."""
1155
 
        from bzrlib.workingtree import WorkingTree
1156
1143
        from bzrlib.transport.local import LocalTransport
1157
1144
        if (self.base.find('://') != -1 or 
1158
1145
            not isinstance(self._transport, LocalTransport)):
1179
1166
 
1180
1167
    def get_parent(self):
1181
1168
        """See Branch.get_parent."""
1182
 
        import errno
1183
1169
        _locs = ['parent', 'pull', 'x-pull']
1184
1170
        assert self.base[-1] == '/'
1185
1171
        for l in _locs:
1186
1172
            try:
1187
 
                return urlutils.join(self.base[:-1], 
 
1173
                return urlutils.join(self.base[:-1],
1188
1174
                            self.control_files.get(l).read().strip('\n'))
1189
1175
            except NoSuchFile:
1190
1176
                pass
1418
1404
 
1419
1405
 
1420
1406
@deprecated_function(zero_eight)
1421
 
def ScratchBranch(*args, **kwargs):
1422
 
    """See bzrlib.bzrdir.ScratchDir."""
1423
 
    d = ScratchDir(*args, **kwargs)
1424
 
    return d.open_branch()
1425
 
 
1426
 
 
1427
 
@deprecated_function(zero_eight)
1428
1407
def is_control_file(*args, **kwargs):
1429
1408
    """See bzrlib.workingtree.is_control_file."""
1430
1409
    return bzrlib.workingtree.is_control_file(*args, **kwargs)