/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: 2019-11-03 18:21:46 UTC
  • mfrom: (7411.1.3 git-dumb-server)
  • Revision ID: breezy.the.bot@gmail.com-20191103182146-j91q9r2cyjy9hilp
Fix support for reading from a dumb git server.

Merged from https://code.launchpad.net/~jelmer/brz/git-dumb-server/+merge/375063

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
    )
81
81
 
82
82
from ..lock import LogicalLockResult
 
83
from ..trace import warning
83
84
 
84
85
 
85
86
class TransportRefsContainer(RefsContainer):
586
587
            return ret
587
588
 
588
589
    def _update_pack_cache(self):
589
 
        pack_files = set()
590
 
        pack_dir_contents = self._pack_names()
591
 
        for name in pack_dir_contents:
592
 
            if name.startswith("pack-") and name.endswith(".pack"):
593
 
                # verify that idx exists first (otherwise the pack was not yet
594
 
                # fully written)
595
 
                idx_name = os.path.splitext(name)[0] + ".idx"
596
 
                if idx_name in pack_dir_contents:
597
 
                    pack_files.add(os.path.splitext(name)[0])
598
 
 
 
590
        pack_files = set(self._pack_names())
599
591
        new_packs = []
600
592
        for basename in pack_files:
601
593
            pack_name = basename + ".pack"
604
596
                    size = self.pack_transport.stat(pack_name).st_size
605
597
                except TransportNotPossible:
606
598
                    f = self.pack_transport.get(pack_name)
 
599
                    # TODO(jelmer): Don't read entire file into memory?
 
600
                    f = BytesIO(f.read())
607
601
                    pd = PackData(pack_name, f)
608
602
                else:
609
603
                    pd = PackData(
622
616
        return new_packs
623
617
 
624
618
    def _pack_names(self):
 
619
        pack_files = []
625
620
        try:
626
 
            return self.pack_transport.list_dir(".")
 
621
            dir_contents = self.pack_transport.list_dir(".")
 
622
            for name in dir_contents:
 
623
                if name.startswith("pack-") and name.endswith(".pack"):
 
624
                    # verify that idx exists first (otherwise the pack was not yet
 
625
                    # fully written)
 
626
                    idx_name = os.path.splitext(name)[0] + ".idx"
 
627
                    if idx_name in dir_contents:
 
628
                        pack_files.append(os.path.splitext(name)[0])
627
629
        except TransportNotPossible:
628
630
            try:
629
631
                f = self.transport.get('info/packs')
630
632
            except NoSuchFile:
631
 
                # Hmm, warn about running 'git update-server-info' ?
632
 
                return iter([])
 
633
                warning('No info/packs on remote host;'
 
634
                        'run \'git update-server-info\' on remote.')
633
635
            else:
634
636
                with f:
635
 
                    return read_packs_file(f)
 
637
                    pack_files = [
 
638
                        os.path.splitext(name)[0]
 
639
                        for name in read_packs_file(f)]
636
640
        except NoSuchFile:
637
 
            return iter([])
 
641
            pass
 
642
        return pack_files
638
643
 
639
644
    def _remove_pack(self, pack):
640
645
        self.pack_transport.delete(os.path.basename(pack.index.path))