/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-04 12:50:55 UTC
  • mfrom: (7027.2.8 git-fixes)
  • Revision ID: breezy.the.bot@gmail.com-20180704125055-8nni25pn2439p48v
Fix eol handling in knits on Python 3, port fastimport plugin to Python 3.

Merged from https://code.launchpad.net/~jelmer/brz/fastimport-fixes/+merge/348924

Show diffs side-by-side

added added

removed removed

Lines of Context:
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]