Пример #1
0
 def _pack_names(self):
     pack_files = []
     try:
         dir_contents = self.pack_transport.list_dir(".")
         for name in dir_contents:
             if name.startswith("pack-") and name.endswith(".pack"):
                 # verify that idx exists first (otherwise the pack was not yet
                 # fully written)
                 idx_name = os.path.splitext(name)[0] + ".idx"
                 if idx_name in dir_contents:
                     pack_files.append(os.path.splitext(name)[0])
     except TransportNotPossible:
         try:
             f = self.transport.get('info/packs')
         except NoSuchFile:
             warning('No info/packs on remote host;'
                     'run \'git update-server-info\' on remote.')
         else:
             with f:
                 pack_files = [
                     os.path.splitext(name)[0]
                     for name in read_packs_file(f)]
     except NoSuchFile:
         pass
     return pack_files
Пример #2
0
    def test_read_packs(self):
        self.assertEqual(
            ["pack-1.pack"],
            list(
                read_packs_file(
                    BytesIO(
                        b"""P pack-1.pack
"""
                    )
                )
            ),
        )
Пример #3
0
 def _pack_names(self):
     try:
         return self.pack_transport.list_dir(".")
     except TransportNotPossible:
         try:
             f = self.transport.get('info/packs')
         except NoSuchFile:
             # Hmm, warn about running 'git update-server-info' ?
             return iter([])
         else:
             with f:
                 return read_packs_file(f)
     except NoSuchFile:
         return iter([])
Пример #4
0
 def _pack_names(self):
     try:
         return self.pack_transport.list_dir(".")
     except TransportNotPossible:
         try:
             f = self.transport.get('info/packs')
         except NoSuchFile:
             # Hmm, warn about running 'git update-server-info' ?
             return iter([])
         else:
             # TODO(jelmer): Move to top-level after dulwich
             # 0.19.7 is released.
             from dulwich.object_store import read_packs_file
             with f:
                 return read_packs_file(f)
     except NoSuchFile:
         return iter([])
Пример #5
0
    def test_read_packs(self):
        self.assertEqual(["pack-1.pack"], list(read_packs_file(BytesIO(b"""P pack-1.pack
"""))))