/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/git/cache.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-03 03:20:44 UTC
  • mfrom: (7018.3.10 git-fixes)
  • Revision ID: breezy.the.bot@gmail.com-20180703032044-t5a5w5y0tmzrbezc
Port a few more bits of the git plugin to python 3.

Merged from https://code.launchpad.net/~jelmer/brz/git-fixes2/+merge/348803

Show diffs side-by-side

added added

removed removed

Lines of Context:
297
297
        else:
298
298
            type_name = obj.type_name.decode('ascii')
299
299
            hexsha = obj.id
 
300
        if not isinstance(hexsha, bytes):
 
301
            raise TypeError(hexsha)
300
302
        if type_name == "commit":
301
303
            self._commit = obj
302
304
            if type(bzr_key_data) is not dict:
331
333
        return self._by_fileid[revision][fileid]
332
334
 
333
335
    def lookup_git_sha(self, sha):
 
336
        if not isinstance(sha, bytes):
 
337
            raise TypeError(sha)
334
338
        for entry in viewvalues(self._by_sha[sha]):
335
339
            yield entry
336
340
 
342
346
 
343
347
    def revids(self):
344
348
        for key, entries in viewitems(self._by_sha):
345
 
            for (type, type_data) in entries.values():
 
349
            for (type, type_data) in viewvalues(entries):
346
350
                if type == "commit":
347
351
                    yield type_data[0]
348
352
 
366
370
        else:
367
371
            type_name = obj.type_name.decode('ascii')
368
372
            hexsha = obj.id
 
373
        if not isinstance(hexsha, bytes):
 
374
            raise TypeError(hexsha)
369
375
        if type_name == "commit":
370
376
            self._commit = obj
371
377
            if type(bzr_key_data) is not dict:
515
521
        """List the SHA1s."""
516
522
        for table in ("blobs", "commits", "trees"):
517
523
            for (sha,) in self.db.execute("select sha1 from %s" % table):
518
 
                yield sha
 
524
                yield sha.encode('ascii')
519
525
 
520
526
 
521
527
class TdbCacheUpdater(CacheUpdater):
690
696
 
691
697
    def _keys(self):
692
698
        try:
 
699
            return self.db.keys()
 
700
        except AttributeError:  # python < 3
693
701
            return self.db.iterkeys()
694
 
        except AttributeError:
695
 
            return self.db.keys()
696
702
 
697
703
    def revids(self):
698
704
        """List the revision ids known."""