~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2006-06-15 05:36:34 UTC
  • mto: This revision was merged to the branch mainline in revision 1797.
  • Revision ID: mbp@sourcefrog.net-20060615053634-4fd52ba691855659
Clean up many exception classes.

Errors indicating a user error are now shown with is_user_error on the
exception; use this rather than hardcoding a list of exceptions that should be
handled this way.

Exceptions now inherit from BzrNewException where possible to use consistent
formatting method.

Remove rather obsolete docstring test on Branch.missing_revisions.

Remove dead code from find_merge_base.


Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from bzrlib.delta import compare_trees
32
32
import bzrlib.errors as errors
33
33
from bzrlib.errors import (BzrError, InvalidRevisionNumber, InvalidRevisionId,
34
 
                           NoSuchRevision, HistoryMissing, NotBranchError,
 
34
                           NoSuchRevision, NotBranchError,
35
35
                           DivergedBranches, LockError,
36
36
                           UninitializableFormat,
37
37
                           UnlistableStore,
300
300
        
301
301
        If self and other have not diverged, return a list of the revisions
302
302
        present in other, but missing from self.
303
 
 
304
 
        >>> from bzrlib.workingtree import WorkingTree
305
 
        >>> bzrlib.trace.silent = True
306
 
        >>> d1 = bzrdir.ScratchDir()
307
 
        >>> br1 = d1.open_branch()
308
 
        >>> wt1 = d1.open_workingtree()
309
 
        >>> d2 = bzrdir.ScratchDir()
310
 
        >>> br2 = d2.open_branch()
311
 
        >>> wt2 = d2.open_workingtree()
312
 
        >>> br1.missing_revisions(br2)
313
 
        []
314
 
        >>> wt2.commit("lala!", rev_id="REVISION-ID-1")
315
 
        >>> br1.missing_revisions(br2)
316
 
        [u'REVISION-ID-1']
317
 
        >>> br2.missing_revisions(br1)
318
 
        []
319
 
        >>> wt1.commit("lala!", rev_id="REVISION-ID-1")
320
 
        >>> br1.missing_revisions(br2)
321
 
        []
322
 
        >>> wt2.commit("lala!", rev_id="REVISION-ID-2A")
323
 
        >>> br1.missing_revisions(br2)
324
 
        [u'REVISION-ID-2A']
325
 
        >>> wt1.commit("lala!", rev_id="REVISION-ID-2B")
326
 
        >>> br1.missing_revisions(br2)
327
 
        Traceback (most recent call last):
328
 
        DivergedBranches: These branches have diverged.  Try merge.
329
303
        """
330
304
        self_history = self.revision_history()
331
305
        self_len = len(self_history)
572
546
        except NoSuchFile:
573
547
            raise NotBranchError(path=transport.base)
574
548
        except KeyError:
575
 
            raise errors.UnknownFormatError(format_string)
 
549
            raise errors.UnknownFormatError(format=format_string)
576
550
 
577
551
    @classmethod
578
552
    def get_default_format(klass):
872
846
                 stacklevel=2)
873
847
            if (not relax_version_check
874
848
                and not self._format.is_supported()):
875
 
                raise errors.UnsupportedFormatError(
876
 
                        'sorry, branch format %r not supported' % fmt,
877
 
                        ['use a different bzr version',
878
 
                         'or remove the .bzr directory'
879
 
                         ' and "bzr init" again'])
 
849
                raise errors.UnsupportedFormatError(format=fmt)
880
850
        if deprecated_passed(transport):
881
851
            warn("BzrBranch.__init__(transport=XXX...): The transport "
882
852
                 "parameter is deprecated as of bzr 0.8. "