~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-06 20:45:48 UTC
  • mfrom: (4728.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091006204548-bjnc3z4k256ppimz
MutableTree.has_changes() does not require a tree parameter anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
636
636
        self.url = url
637
637
 
638
638
 
 
639
class UnstackableLocationError(BzrError):
 
640
 
 
641
    _fmt = "The branch '%(branch_url)s' cannot be stacked on '%(target_url)s'."
 
642
 
 
643
    def __init__(self, branch_url, target_url):
 
644
        BzrError.__init__(self)
 
645
        self.branch_url = branch_url
 
646
        self.target_url = target_url
 
647
 
 
648
 
639
649
class UnstackableRepositoryFormat(BzrError):
640
650
 
641
651
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
783
793
 
784
794
 
785
795
class IncompatibleRepositories(BzrError):
 
796
    """Report an error that two repositories are not compatible.
 
797
 
 
798
    Note that the source and target repositories are permitted to be strings:
 
799
    this exception is thrown from the smart server and may refer to a
 
800
    repository the client hasn't opened.
 
801
    """
786
802
 
787
803
    _fmt = "%(target)s\n" \
788
804
            "is not compatible with\n" \
1173
1189
class DivergedBranches(BzrError):
1174
1190
 
1175
1191
    _fmt = ("These branches have diverged."
1176
 
            " Use the merge command to reconcile them.")
 
1192
            " Use the missing command to see how.\n"
 
1193
            "Use the merge command to reconcile them.")
1177
1194
 
1178
1195
    def __init__(self, branch1, branch2):
1179
1196
        self.branch1 = branch1
1227
1244
            not_ancestor_id=not_ancestor_id)
1228
1245
 
1229
1246
 
1230
 
class InstallFailed(BzrError):
1231
 
 
1232
 
    def __init__(self, revisions):
1233
 
        revision_str = ", ".join(str(r) for r in revisions)
1234
 
        msg = "Could not install revisions:\n%s" % revision_str
1235
 
        BzrError.__init__(self, msg)
1236
 
        self.revisions = revisions
1237
 
 
1238
 
 
1239
1247
class AmbiguousBase(BzrError):
1240
1248
 
1241
1249
    def __init__(self, bases):
2004
2012
 
2005
2013
class BadConversionTarget(BzrError):
2006
2014
 
2007
 
    _fmt = "Cannot convert to format %(format)s.  %(problem)s"
 
2015
    _fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
 
2016
            "    %(problem)s"
2008
2017
 
2009
 
    def __init__(self, problem, format):
 
2018
    def __init__(self, problem, format, from_format=None):
2010
2019
        BzrError.__init__(self)
2011
2020
        self.problem = problem
2012
2021
        self.format = format
 
2022
        self.from_format = from_format or '(unspecified)'
2013
2023
 
2014
2024
 
2015
2025
class NoDiffFound(BzrError):
2091
2101
 
2092
2102
class OutOfDateTree(BzrError):
2093
2103
 
2094
 
    _fmt = "Working tree is out of date, please run 'bzr update'."
 
2104
    _fmt = "Working tree is out of date, please run 'bzr update'.%(more)s"
2095
2105
 
2096
 
    def __init__(self, tree):
 
2106
    def __init__(self, tree, more=None):
 
2107
        if more is None:
 
2108
            more = ''
 
2109
        else:
 
2110
            more = ' ' + more
2097
2111
        BzrError.__init__(self)
2098
2112
        self.tree = tree
 
2113
        self.more = more
2099
2114
 
2100
2115
 
2101
2116
class PublicBranchOutOfDate(BzrError):
2155
2170
        self.reason = reason
2156
2171
 
2157
2172
 
 
2173
class InconsistentDeltaDelta(InconsistentDelta):
 
2174
    """Used when we get a delta that is not valid."""
 
2175
 
 
2176
    _fmt = ("An inconsistent delta was supplied: %(delta)r"
 
2177
            "\nreason: %(reason)s")
 
2178
 
 
2179
    def __init__(self, delta, reason):
 
2180
        BzrError.__init__(self)
 
2181
        self.delta = delta
 
2182
        self.reason = reason
 
2183
 
 
2184
 
2158
2185
class UpgradeRequired(BzrError):
2159
2186
 
2160
2187
    _fmt = "To use this feature you must upgrade your branch at %(path)s."
2169
2196
    _fmt = "To use this feature you must upgrade your repository at %(path)s."
2170
2197
 
2171
2198
 
 
2199
class RichRootUpgradeRequired(UpgradeRequired):
 
2200
 
 
2201
    _fmt = ("To use this feature you must upgrade your branch at %(path)s to"
 
2202
           " a format which supports rich roots.")
 
2203
 
 
2204
 
2172
2205
class LocalRequiresBoundBranch(BzrError):
2173
2206
 
2174
2207
    _fmt = "Cannot perform local-only commits on unbound branches."
2175
2208
 
2176
2209
 
2177
 
class InvalidProgressBarType(BzrError):
2178
 
 
2179
 
    _fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
2180
 
            " is not a supported type Select one of: %(valid_types)s")
2181
 
 
2182
 
    def __init__(self, bar_type, valid_types):
2183
 
        BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
2184
 
 
2185
 
 
2186
2210
class UnsupportedOperation(BzrError):
2187
2211
 
2188
2212
    _fmt = ("The method %(mname)s is not supported on"
2779
2803
 
2780
2804
class UncommittedChanges(BzrError):
2781
2805
 
2782
 
    _fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
 
2806
    _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
 
2807
            ' (See bzr status).%(more)s')
2783
2808
 
2784
 
    def __init__(self, tree):
 
2809
    def __init__(self, tree, more=None):
 
2810
        if more is None:
 
2811
            more = ''
 
2812
        else:
 
2813
            more = ' ' + more
2785
2814
        import bzrlib.urlutils as urlutils
2786
2815
        display_url = urlutils.unescape_for_display(
2787
2816
            tree.bzrdir.root_transport.base, 'ascii')
2788
 
        BzrError.__init__(self, tree=tree, display_url=display_url)
 
2817
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2789
2818
 
2790
2819
 
2791
2820
class MissingTemplateVariable(BzrError):
2850
2879
    pass
2851
2880
 
2852
2881
 
2853
 
class NotATerminal(BzrError):
2854
 
 
2855
 
    _fmt = 'Unable to ask for a password without real terminal.'
2856
 
 
2857
 
 
2858
2882
class UnableEncodePath(BzrError):
2859
2883
 
2860
2884
    _fmt = ('Unable to encode %(kind)s path %(path)r in '
2902
2926
    _fmt = 'Cannot bind address "%(host)s:%(port)i": %(orig_error)s.'
2903
2927
 
2904
2928
    def __init__(self, host, port, orig_error):
 
2929
        # nb: in python2.4 socket.error doesn't have a useful repr
2905
2930
        BzrError.__init__(self, host=host, port=port,
2906
 
            orig_error=orig_error[1])
 
2931
            orig_error=repr(orig_error.args))
2907
2932
 
2908
2933
 
2909
2934
class UnknownRules(BzrError):
2965
2990
        BzrError.__init__(self, invalid_id=invalid_id)
2966
2991
 
2967
2992
 
 
2993
class JailBreak(BzrError):
 
2994
 
 
2995
    _fmt = "An attempt to access a url outside the server jail was made: '%(url)s'."
 
2996
 
 
2997
    def __init__(self, url):
 
2998
        BzrError.__init__(self, url=url)
 
2999
 
 
3000
 
2968
3001
class UserAbort(BzrError):
2969
3002
 
2970
3003
    _fmt = 'The user aborted the operation.'
3030
3063
 
3031
3064
    def __init__(self, repository):
3032
3065
        self.repository = repository
 
3066
 
 
3067
 
 
3068
class LossyPushToSameVCS(BzrError):
 
3069
 
 
3070
    _fmt = ("Lossy push not possible between %(source_branch)r and "
 
3071
            "%(target_branch)r that are in the same VCS.")
 
3072
 
 
3073
    internal_error = True
 
3074
 
 
3075
    def __init__(self, source_branch, target_branch):
 
3076
        self.source_branch = source_branch
 
3077
        self.target_branch = target_branch