/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 breezy/plugins/fastimport/cache_manager.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-06 01:18:08 UTC
  • mfrom: (7143 work)
  • mto: This revision was merged to the branch mainline in revision 7151.
  • Revision ID: jelmer@jelmer.uk-20181106011808-y870f4vq0ork3ahu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from . import (
28
28
    branch_mapper,
29
29
    )
30
 
from .reftracker import (
 
30
from fastimport.reftracker import (
31
31
    RefTracker,
32
32
    )
33
33
from .helpers import (
123
123
        self.reftracker = RefTracker()
124
124
 
125
125
    def add_mark(self, mark, commit_id):
126
 
        assert mark[0] != ':'
 
126
        if mark.startswith(b':'):
 
127
            raise ValueError(mark)
127
128
        is_new = (mark in self.marks)
128
129
        self.marks[mark] = commit_id
129
130
        return is_new
134
135
        :param committish: A "committish" string
135
136
        :return: Bazaar revision id
136
137
        """
137
 
        assert committish[0] == ':'
138
 
        return self.marks[committish.lstrip(':')]
 
138
        if not committish.startswith(b':'):
 
139
            raise ValueError(committish)
 
140
        return self.marks[committish.lstrip(b':')]
139
141
 
140
142
    def dump_stats(self, note=trace.note):
141
143
        """Dump some statistics about what we cached."""
233
235
            self._sticky_memory_bytes += len(data)
234
236
            if self._sticky_memory_bytes > self._sticky_cache_size:
235
237
                self._flush_blobs_to_disk()
236
 
        elif data == '':
 
238
        elif data == b'':
237
239
            # Empty data is always sticky
238
240
            self._sticky_blobs[id] = data
239
241
        else:
266
268
                f.seek(offset)
267
269
                content = f.read(n_bytes)
268
270
            else:
269
 
                fp = open(fn, 'rb')
270
 
                try:
 
271
                with open(fn, 'rb') as fp:
271
272
                    content = fp.read()
272
 
                finally:
273
 
                    fp.close()
274
273
            self._decref(id, self._disk_blobs, fn)
275
274
            return content
276
275
        content = self._sticky_blobs[id]