Browse Source

Use PackData.filename attribute.

Jelmer Vernooij 11 years ago
parent
commit
19a7e0d218
3 changed files with 11 additions and 5 deletions
  1. 4 0
      dulwich/pack.py
  2. 1 1
      dulwich/server.py
  3. 6 4
      dulwich/tests/test_web.py

+ 4 - 0
dulwich/pack.py

@@ -980,6 +980,10 @@ class PackData(object):
             compute_size=_compute_object_size)
             compute_size=_compute_object_size)
         self.pack = None
         self.pack = None
 
 
+    @property
+    def filename(self):
+        return os.path.basename(self._filename)
+
     @classmethod
     @classmethod
     def from_file(cls, file, size):
     def from_file(cls, file, size):
         return cls(str(file), file=file, size=size)
         return cls(str(file), file=file, size=size)

+ 1 - 1
dulwich/server.py

@@ -919,7 +919,7 @@ def generate_info_refs(repo):
 def generate_objects_info_packs(repo):
 def generate_objects_info_packs(repo):
     """Generate an index for for packs."""
     """Generate an index for for packs."""
     for pack in repo.object_store.packs:
     for pack in repo.object_store.packs:
-        yield 'P pack-%s.pack\n' % pack.name()
+        yield 'P %s\n' % pack.data.filename
 
 
 
 
 def update_server_info(repo):
 def update_server_info(repo):

+ 6 - 4
dulwich/tests/test_web.py

@@ -254,12 +254,14 @@ class DumbHandlersTestCase(WebTestCase):
         self.assertFalse(self._req.cached)
         self.assertFalse(self._req.cached)
 
 
     def test_get_info_packs(self):
     def test_get_info_packs(self):
-        class TestPack(object):
+        class TestPackData(object):
+
             def __init__(self, sha):
             def __init__(self, sha):
-                self._sha = sha
+                self.filename = "pack-%s.pack" % sha
 
 
-            def name(self):
-                return self._sha
+        class TestPack(object):
+            def __init__(self, sha):
+                self.data = TestPackData(sha)
 
 
         packs = [TestPack(str(i) * 40) for i in xrange(1, 4)]
         packs = [TestPack(str(i) * 40) for i in xrange(1, 4)]