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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-10-13 15:20:48 UTC
  • mfrom: (7131.2.2 packs-file)
  • Revision ID: breezy.the.bot@gmail.com-20181013152048-46569ct6orlhhkhn
Only read the .git/objects/info/packs file if the packs file isn't listable.

Merged from https://code.launchpad.net/~jelmer/brz/packs-file/+merge/356198

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
                return {}
165
165
            try:
166
166
                first_line = next(iter(f)).rstrip()
167
 
                if (first_line.startswith("# pack-refs") and " peeled" in
 
167
                if (first_line.startswith(b"# pack-refs") and b" peeled" in
168
168
                        first_line):
169
169
                    for sha, name, peeled in read_packed_refs_with_peeled(f):
170
170
                        self._packed_refs[name] = sha
600
600
 
601
601
    def _pack_names(self):
602
602
        try:
603
 
            f = self.transport.get('info/packs')
604
 
        except NoSuchFile:
605
603
            return self.pack_transport.list_dir(".")
606
 
        else:
607
 
            with f:
608
 
                ret = []
609
 
                for line in f.read().splitlines():
610
 
                    if not line:
611
 
                        continue
612
 
                    (kind, name) = line.split(b" ", 1)
613
 
                    if kind != b"P":
614
 
                        continue
615
 
                    ret.append(name)
616
 
                return ret
 
604
        except TransportNotPossible:
 
605
            try:
 
606
                f = self.transport.get('info/packs')
 
607
            except NoSuchFile:
 
608
                # Hmm, warn about running 'git update-server-info' ?
 
609
                return iter([])
 
610
            else:
 
611
                # TODO(jelmer): Move to top-level after dulwich
 
612
                # 0.19.7 is released.
 
613
                from dulwich.object_store import read_packs_file
 
614
                with f:
 
615
                    return read_packs_file(f)
 
616
        except NoSuchFile:
 
617
            return iter([])
617
618
 
618
619
    def _remove_pack(self, pack):
619
620
        self.pack_transport.delete(os.path.basename(pack.index.path))