/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-05 16:27:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5374.
  • Revision ID: john@arbash-meinel.com-20100805162735-172opvx34sr5gpbl
Find a case where we are wasting a bit of memory.

Specifically the 'build_details' tuple contains a lot of wasted references,
and we hold on to one of these for each record we are fetching.
And for something like 'bzr pack', that is all keys.

For just loading all text build details on my bzr+ repository, With:
locations = b.repository.texts._index.get_build_details(b.repository.texts.keys())
This drops the memory consumption from:
WorkingSize   77604KiB
 to
WorkingSize   64640KiB

Or around 10.6MB. I worked it out to a savings of about 80 bytes/record
on data that can have hundreds of thousands of records (in 32-bit).

Show diffs side-by-side

added added

removed removed

Lines of Context:
680
680
 
681
681
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
682
682
 
683
 
    internal_error = True
 
683
    internal_error = False
684
684
 
685
685
    def __init__(self, path, base, extra=None):
686
686
        BzrError.__init__(self)
782
782
 
783
783
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
784
784
 
 
785
    # use PathNotChild instead
 
786
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
785
787
    def __init__(self, branch, path):
786
788
        BzrError.__init__(self)
787
789
        self.branch = branch
947
949
    # original exception is available as e.original_error
948
950
    #
949
951
    # New code should prefer to raise specific subclasses
950
 
    def __init__(self, message):
951
 
        # Python 2.5 uses a slot for StandardError.message,
952
 
        # so use a different variable name.  We now work around this in
953
 
        # BzrError.__str__, but this member name is kept for compatability.
954
 
        self.msg = message
 
952
    def __init__(self, msg):
 
953
        self.msg = msg
955
954
 
956
955
 
957
956
class LockActive(LockError):
1041
1040
class LockContention(LockError):
1042
1041
 
1043
1042
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1044
 
    # TODO: show full url for lock, combining the transport and relative
1045
 
    # bits?
1046
1043
 
1047
1044
    internal_error = False
1048
1045
 
1180
1177
class InvalidRevisionSpec(BzrError):
1181
1178
 
1182
1179
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1183
 
            " %(branch)s%(extra)s")
 
1180
            " %(branch_url)s%(extra)s")
1184
1181
 
1185
1182
    def __init__(self, spec, branch, extra=None):
1186
1183
        BzrError.__init__(self, branch=branch, spec=spec)
 
1184
        self.branch_url = getattr(branch, 'user_url', str(branch))
1187
1185
        if extra:
1188
1186
            self.extra = '\n' + str(extra)
1189
1187
        else:
1380
1378
 
1381
1379
class WeaveParentMismatch(WeaveError):
1382
1380
 
1383
 
    _fmt = "Parents are mismatched between two revisions. %(message)s"
 
1381
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1384
1382
 
1385
1383
 
1386
1384
class WeaveInvalidChecksum(WeaveError):
1387
1385
 
1388
 
    _fmt = "Text did not match it's checksum: %(message)s"
 
1386
    _fmt = "Text did not match it's checksum: %(msg)s"
1389
1387
 
1390
1388
 
1391
1389
class WeaveTextDiffers(WeaveError):
1439
1437
 
1440
1438
class VersionedFileInvalidChecksum(VersionedFileError):
1441
1439
 
1442
 
    _fmt = "Text did not match its checksum: %(message)s"
 
1440
    _fmt = "Text did not match its checksum: %(msg)s"
1443
1441
 
1444
1442
 
1445
1443
class KnitError(InternalBzrError):
1925
1923
    _fmt = "Moving the root directory is not supported at this time"
1926
1924
 
1927
1925
 
 
1926
class TransformRenameFailed(BzrError):
 
1927
 
 
1928
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
 
1929
 
 
1930
    def __init__(self, from_path, to_path, why, errno):
 
1931
        self.from_path = from_path
 
1932
        self.to_path = to_path
 
1933
        self.why = why
 
1934
        self.errno = errno
 
1935
 
 
1936
 
1928
1937
class BzrMoveFailedError(BzrError):
1929
1938
 
1930
1939
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
2839
2848
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2840
2849
 
2841
2850
 
 
2851
class ShelvedChanges(UncommittedChanges):
 
2852
 
 
2853
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
 
2854
            ' (See bzr shelve --list).%(more)s')
 
2855
 
 
2856
 
2842
2857
class MissingTemplateVariable(BzrError):
2843
2858
 
2844
2859
    _fmt = 'Variable {%(name)s} is not available.'
3134
3149
    def __init__(self, bzrdir):
3135
3150
        self.bzrdir = bzrdir
3136
3151
 
 
3152
 
 
3153
class NoWhoami(BzrError):
 
3154
 
 
3155
    _fmt = ('Unable to determine your name.\n'
 
3156
        "Please, set your name with the 'whoami' command.\n"
 
3157
        'E.g. bzr whoami "Your Name <name@example.com>"')
 
3158
 
 
3159
 
 
3160
class InvalidPattern(BzrError):
 
3161
 
 
3162
    _fmt = ('Invalid pattern(s) found. %(msg)s')
 
3163
 
 
3164
    def __init__(self, msg):
 
3165
        self.msg = msg
 
3166
 
 
3167
 
 
3168
class RecursiveBind(BzrError):
 
3169
 
 
3170
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
 
3171
        'Please use `bzr unbind` to fix.')
 
3172
 
 
3173
    def __init__(self, branch_url):
 
3174
        self.branch_url = branch_url
 
3175