Fix numerous style issues.
authorDave Borowitz <dborowitz@google.com>
Mon, 22 Mar 2010 21:40:31 +0000 (14:40 -0700)
committerDave Borowitz <dborowitz@google.com>
Fri, 30 Apr 2010 16:42:52 +0000 (09:42 -0700)
This largely fixes whitespace and imports, with a few typo fixes as
well. I only touched code that was previously touched by me, except in
the case of imports, where blame data is less useful.

Change-Id: Ie34063eb5abb3283a5b9b80fc902efca39159a97

dulwich/pack.py
dulwich/protocol.py
dulwich/repo.py
dulwich/server.py
dulwich/tests/test_object_store.py
dulwich/tests/test_repository.py
dulwich/tests/test_server.py
dulwich/tests/test_web.py
dulwich/web.py

index 3a2cd30282ebc6a98b17ccd798a3491839baaa4d..e52dc7cb81001797d1c18af23ed2d61afbbc9688 100644 (file)
@@ -65,15 +65,15 @@ from dulwich.file import GitFile
 from dulwich.lru_cache import (
     LRUSizeCache,
     )
 from dulwich.lru_cache import (
     LRUSizeCache,
     )
+from dulwich.misc import (
+    make_sha,
+    )
 from dulwich.objects import (
     ShaFile,
     hex_to_sha,
     sha_to_hex,
     object_header,
     )
 from dulwich.objects import (
     ShaFile,
     hex_to_sha,
     sha_to_hex,
     object_header,
     )
-from dulwich.misc import (
-    make_sha,
-    )
 
 supports_mmap_offset = (sys.version_info[0] >= 3 or
         (sys.version_info[0] == 2 and sys.version_info[1] >= 6))
 
 supports_mmap_offset = (sys.version_info[0] >= 3 or
         (sys.version_info[0] == 2 and sys.version_info[1] >= 6))
@@ -129,6 +129,7 @@ def read_zlib_chunks(read_some, dec_size, buffer_size=4096):
     comp_len = fed - len(obj.unused_data)
     return ret, comp_len, obj.unused_data
 
     comp_len = fed - len(obj.unused_data)
     return ret, comp_len, obj.unused_data
 
+
 def iter_sha1(iter):
     """Return the hexdigest of the SHA1 over a set of names.
 
 def iter_sha1(iter):
     """Return the hexdigest of the SHA1 over a set of names.
 
@@ -1383,7 +1384,7 @@ class Pack(object):
         for offset, type, obj, crc32 in self.data.iterobjects():
             assert isinstance(offset, int)
             yield ShaFile.from_raw_chunks(
         for offset, type, obj, crc32 in self.data.iterobjects():
             assert isinstance(offset, int)
             yield ShaFile.from_raw_chunks(
-                    *self.data.resolve_object(offset, type, obj))
+              *self.data.resolve_object(offset, type, obj))
 
 
 try:
 
 
 try:
index 0d83bb814e41b11c61895724648792dfafc82c77..340373c504f2fb1a40edba4329b8da79b555c30c 100644 (file)
@@ -36,6 +36,7 @@ SINGLE_ACK = 0
 MULTI_ACK = 1
 MULTI_ACK_DETAILED = 2
 
 MULTI_ACK = 1
 MULTI_ACK_DETAILED = 2
 
+
 class ProtocolFile(object):
     """
     Some network ops are like file ops. The file ops expect to operate on
 class ProtocolFile(object):
     """
     Some network ops are like file ops. The file ops expect to operate on
@@ -181,7 +182,7 @@ class ReceivableProtocol(Protocol):
 
     def __init__(self, recv, write, report_activity=None, rbufsize=_RBUFSIZE):
         super(ReceivableProtocol, self).__init__(self.read, write,
 
     def __init__(self, recv, write, report_activity=None, rbufsize=_RBUFSIZE):
         super(ReceivableProtocol, self).__init__(self.read, write,
-                                                report_activity)
+                                                 report_activity)
         self._recv = recv
         self._rbuf = StringIO()
         self._rbufsize = rbufsize
         self._recv = recv
         self._rbuf = StringIO()
         self._rbufsize = rbufsize
@@ -302,7 +303,7 @@ def extract_want_line_capabilities(text):
 def ack_type(capabilities):
     """Extract the ack type from a capabilities list."""
     if 'multi_ack_detailed' in capabilities:
 def ack_type(capabilities):
     """Extract the ack type from a capabilities list."""
     if 'multi_ack_detailed' in capabilities:
-      return MULTI_ACK_DETAILED
+        return MULTI_ACK_DETAILED
     elif 'multi_ack' in capabilities:
         return MULTI_ACK
     return SINGLE_ACK
     elif 'multi_ack' in capabilities:
         return MULTI_ACK
     return SINGLE_ACK
index 5b7599884429fb85004c31b22809a03ab3f33f38..983afc9f26c0946fd60abeec4b74a53ecefe4c8e 100644 (file)
@@ -26,12 +26,12 @@ import errno
 import os
 
 from dulwich.errors import (
 import os
 
 from dulwich.errors import (
-    MissingCommitError, 
+    MissingCommitError,
     NoIndexPresent,
     NoIndexPresent,
-    NotBlobError, 
-    NotCommitError, 
+    NotBlobError,
+    NotCommitError,
     NotGitRepository,
     NotGitRepository,
-    NotTreeError, 
+    NotTreeError,
     NotTagError,
     PackedRefsException,
     )
     NotTagError,
     PackedRefsException,
     )
@@ -570,7 +570,7 @@ def read_packed_refs(f):
             continue
         if l[0] == "^":
             raise PackedRefsException(
             continue
         if l[0] == "^":
             raise PackedRefsException(
-                "found peeled ref in packed-refs without peeled")
+              "found peeled ref in packed-refs without peeled")
         yield _split_ref_line(l)
 
 
         yield _split_ref_line(l)
 
 
@@ -667,8 +667,8 @@ class BaseRepo(object):
         if determine_wants is None:
             determine_wants = lambda heads: heads.values()
         target.object_store.add_objects(
         if determine_wants is None:
             determine_wants = lambda heads: heads.values()
         target.object_store.add_objects(
-            self.fetch_objects(determine_wants, target.get_graph_walker(),
-                progress))
+          self.fetch_objects(determine_wants, target.get_graph_walker(),
+                             progress))
         return self.get_refs()
 
     def fetch_objects(self, determine_wants, graph_walker, progress,
         return self.get_refs()
 
     def fetch_objects(self, determine_wants, graph_walker, progress,
@@ -691,8 +691,8 @@ class BaseRepo(object):
             return []
         haves = self.object_store.find_common_revisions(graph_walker)
         return self.object_store.iter_shas(
             return []
         haves = self.object_store.find_common_revisions(graph_walker)
         return self.object_store.iter_shas(
-            self.object_store.find_missing_objects(haves, wants, progress,
-                                                   get_tagged))
+          self.object_store.find_missing_objects(haves, wants, progress,
+                                                 get_tagged))
 
     def get_graph_walker(self, heads=None):
         if heads is None:
 
     def get_graph_walker(self, heads=None):
         if heads is None:
@@ -927,8 +927,8 @@ class Repo(BaseRepo):
         else:
             raise NotGitRepository(root)
         self.path = root
         else:
             raise NotGitRepository(root)
         self.path = root
-        object_store = DiskObjectStore(
-            os.path.join(self.controldir(), OBJECTDIR))
+        object_store = DiskObjectStore(os.path.join(self.controldir(),
+                                                    OBJECTDIR))
         refs = DiskRefsContainer(self.controldir())
         BaseRepo.__init__(self, object_store, refs)
 
         refs = DiskRefsContainer(self.controldir())
         BaseRepo.__init__(self, object_store, refs)
 
index f9dd7b2c6835cc272ec9dee27fce41bb459a077b..76344739f355fa3f24c6f525fd0792ce0aace570 100644 (file)
@@ -329,10 +329,10 @@ class ProtocolGraphWalker(object):
         while command != None:
             if command != 'want':
                 raise GitProtocolError(
         while command != None:
             if command != 'want':
                 raise GitProtocolError(
-                    'Protocol got unexpected command %s' % command)
+                  'Protocol got unexpected command %s' % command)
             if sha not in values:
                 raise GitProtocolError(
             if sha not in values:
                 raise GitProtocolError(
-                    'Client wants invalid object %s' % sha)
+                  'Client wants invalid object %s' % sha)
             want_revs.append(sha)
             command, sha = self.read_proto_line()
 
             want_revs.append(sha)
             command, sha = self.read_proto_line()
 
@@ -440,10 +440,10 @@ class ProtocolGraphWalker(object):
 
     def set_ack_type(self, ack_type):
         impl_classes = {
 
     def set_ack_type(self, ack_type):
         impl_classes = {
-            MULTI_ACK: MultiAckGraphWalkerImpl,
-            MULTI_ACK_DETAILED: MultiAckDetailedGraphWalkerImpl,
-            SINGLE_ACK: SingleAckGraphWalkerImpl,
-            }
+          MULTI_ACK: MultiAckGraphWalkerImpl,
+          MULTI_ACK_DETAILED: MultiAckDetailedGraphWalkerImpl,
+          SINGLE_ACK: SingleAckGraphWalkerImpl,
+          }
         self._impl = impl_classes[ack_type](self)
 
 
         self._impl = impl_classes[ack_type](self)
 
 
@@ -568,7 +568,6 @@ class ReceivePackHandler(Handler):
                           AssertionError, socket.error, zlib.error,
                           ObjectFormatException)
         status = []
                           AssertionError, socket.error, zlib.error,
                           ObjectFormatException)
         status = []
-        unpack_error = None
         # TODO: more informative error messages than just the exception string
         try:
             PackStreamCopier(self.proto.read, self.proto.recv, f).verify()
         # TODO: more informative error messages than just the exception string
         try:
             PackStreamCopier(self.proto.read, self.proto.recv, f).verify()
index 7dc9387b5ccbf7ef5471f78e429abef1b2b47945..f98d07eaaa24fdd30cc88c25a6c6c48aba75affa 100644 (file)
@@ -20,6 +20,7 @@
 """Tests for the object store interface."""
 
 
 """Tests for the object store interface."""
 
 
+import os
 import shutil
 import tempfile
 from unittest import TestCase
 import shutil
 import tempfile
 from unittest import TestCase
@@ -34,9 +35,6 @@ from dulwich.object_store import (
 from utils import (
     make_object,
     )
 from utils import (
     make_object,
     )
-import os
-import shutil
-import tempfile
 
 
 testobject = make_object(Blob, data="yummy data")
 
 
 testobject = make_object(Blob, data="yummy data")
index f9bbdfdefb8058237a7973792f149ed687cdc604..3048ca9effbb999870da304f9782ca706ff51ff4 100644 (file)
@@ -343,12 +343,12 @@ class PackedRefsFileTests(unittest.TestCase):
 
     def test_read_with_peeled(self):
         f = StringIO('%s ref/1\n%s ref/2\n^%s\n%s ref/4' % (
 
     def test_read_with_peeled(self):
         f = StringIO('%s ref/1\n%s ref/2\n^%s\n%s ref/4' % (
-            ONES, TWOS, THREES, FOURS))
+          ONES, TWOS, THREES, FOURS))
         self.assertEqual([
         self.assertEqual([
-            (ONES, 'ref/1', None),
-            (TWOS, 'ref/2', THREES),
-            (FOURS, 'ref/4', None),
-            ], list(read_packed_refs_with_peeled(f)))
+          (ONES, 'ref/1', None),
+          (TWOS, 'ref/2', THREES),
+          (FOURS, 'ref/4', None),
+          ], list(read_packed_refs_with_peeled(f)))
 
     def test_read_with_peeled_errors(self):
         f = StringIO('^%s\n%s ref/1' % (TWOS, ONES))
 
     def test_read_with_peeled_errors(self):
         f = StringIO('^%s\n%s ref/1' % (TWOS, ONES))
@@ -362,8 +362,8 @@ class PackedRefsFileTests(unittest.TestCase):
         write_packed_refs(f, {'ref/1': ONES, 'ref/2': TWOS},
                           {'ref/1': THREES})
         self.assertEqual(
         write_packed_refs(f, {'ref/1': ONES, 'ref/2': TWOS},
                           {'ref/1': THREES})
         self.assertEqual(
-            "# pack-refs with: peeled\n%s ref/1\n^%s\n%s ref/2\n" % (
-            ONES, THREES, TWOS), f.getvalue())
+          "# pack-refs with: peeled\n%s ref/1\n^%s\n%s ref/2\n" % (
+          ONES, THREES, TWOS), f.getvalue())
 
     def test_write_without_peeled(self):
         f = StringIO()
 
     def test_write_without_peeled(self):
         f = StringIO()
@@ -382,9 +382,9 @@ class RefsContainerTests(unittest.TestCase):
 
     def test_get_packed_refs(self):
         self.assertEqual({
 
     def test_get_packed_refs(self):
         self.assertEqual({
-            'refs/heads/packed': '42d06bd4b77fed026b154d16493e5deab78f02ec',
-            'refs/tags/refs-0.1': 'df6800012397fb85c56e7418dd4eb9405dee075c',
-            }, self._refs.get_packed_refs())
+          'refs/heads/packed': '42d06bd4b77fed026b154d16493e5deab78f02ec',
+          'refs/tags/refs-0.1': 'df6800012397fb85c56e7418dd4eb9405dee075c',
+          }, self._refs.get_packed_refs())
 
     def test_get_peeled_not_packed(self):
         # not packed
 
     def test_get_peeled_not_packed(self):
         # not packed
@@ -402,13 +402,13 @@ class RefsContainerTests(unittest.TestCase):
 
     def test_keys(self):
         self.assertEqual([
 
     def test_keys(self):
         self.assertEqual([
-            'HEAD',
-            'refs/heads/loop',
-            'refs/heads/master',
-            'refs/heads/packed',
-            'refs/tags/refs-0.1',
-            'refs/tags/refs-0.2',
-            ], sorted(list(self._refs.keys())))
+          'HEAD',
+          'refs/heads/loop',
+          'refs/heads/master',
+          'refs/heads/packed',
+          'refs/tags/refs-0.1',
+          'refs/tags/refs-0.2',
+          ], sorted(list(self._refs.keys())))
         self.assertEqual(['loop', 'master', 'packed'],
                          sorted(self._refs.keys('refs/heads')))
         self.assertEqual(['refs-0.1', 'refs-0.2'],
         self.assertEqual(['loop', 'master', 'packed'],
                          sorted(self._refs.keys('refs/heads')))
         self.assertEqual(['refs-0.1', 'refs-0.2'],
@@ -417,12 +417,12 @@ class RefsContainerTests(unittest.TestCase):
     def test_as_dict(self):
         # refs/heads/loop does not show up
         self.assertEqual({
     def test_as_dict(self):
         # refs/heads/loop does not show up
         self.assertEqual({
-            'HEAD': '42d06bd4b77fed026b154d16493e5deab78f02ec',
-            'refs/heads/master': '42d06bd4b77fed026b154d16493e5deab78f02ec',
-            'refs/heads/packed': '42d06bd4b77fed026b154d16493e5deab78f02ec',
-            'refs/tags/refs-0.1': 'df6800012397fb85c56e7418dd4eb9405dee075c',
-            'refs/tags/refs-0.2': '3ec9c43c84ff242e3ef4a9fc5bc111fd780a76a8',
-            }, self._refs.as_dict())
+          'HEAD': '42d06bd4b77fed026b154d16493e5deab78f02ec',
+          'refs/heads/master': '42d06bd4b77fed026b154d16493e5deab78f02ec',
+          'refs/heads/packed': '42d06bd4b77fed026b154d16493e5deab78f02ec',
+          'refs/tags/refs-0.1': 'df6800012397fb85c56e7418dd4eb9405dee075c',
+          'refs/tags/refs-0.2': '3ec9c43c84ff242e3ef4a9fc5bc111fd780a76a8',
+          }, self._refs.as_dict())
 
     def test_setitem(self):
         self._refs['refs/some/ref'] = '42d06bd4b77fed026b154d16493e5deab78f02ec'
 
     def test_setitem(self):
         self._refs['refs/some/ref'] = '42d06bd4b77fed026b154d16493e5deab78f02ec'
@@ -455,16 +455,16 @@ class RefsContainerTests(unittest.TestCase):
                          self._refs['HEAD'])
 
         self.assertTrue(self._refs.set_if_equals(
                          self._refs['HEAD'])
 
         self.assertTrue(self._refs.set_if_equals(
-            'HEAD', '42d06bd4b77fed026b154d16493e5deab78f02ec', nines))
+          'HEAD', '42d06bd4b77fed026b154d16493e5deab78f02ec', nines))
         self.assertEqual(nines, self._refs['HEAD'])
 
         # ensure symref was followed
         self.assertEqual(nines, self._refs['refs/heads/master'])
 
         self.assertFalse(os.path.exists(
         self.assertEqual(nines, self._refs['HEAD'])
 
         # ensure symref was followed
         self.assertEqual(nines, self._refs['refs/heads/master'])
 
         self.assertFalse(os.path.exists(
-            os.path.join(self._refs.path, 'refs', 'heads', 'master.lock')))
+          os.path.join(self._refs.path, 'refs', 'heads', 'master.lock')))
         self.assertFalse(os.path.exists(
         self.assertFalse(os.path.exists(
-            os.path.join(self._refs.path, 'HEAD.lock')))
+          os.path.join(self._refs.path, 'HEAD.lock')))
 
     def test_add_if_new(self):
         nines = '9' * 40
 
     def test_add_if_new(self):
         nines = '9' * 40
@@ -496,11 +496,11 @@ class RefsContainerTests(unittest.TestCase):
 
     def test_follow(self):
         self.assertEquals(
 
     def test_follow(self):
         self.assertEquals(
-            ('refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'),
-            self._refs._follow('HEAD'))
+          ('refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'),
+          self._refs._follow('HEAD'))
         self.assertEquals(
         self.assertEquals(
-            ('refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'),
-            self._refs._follow('refs/heads/master'))
+          ('refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'),
+          self._refs._follow('refs/heads/master'))
         self.assertRaises(KeyError, self._refs._follow, 'notrefs/foo')
         self.assertRaises(KeyError, self._refs._follow, 'refs/heads/loop')
 
         self.assertRaises(KeyError, self._refs._follow, 'notrefs/foo')
         self.assertRaises(KeyError, self._refs._follow, 'refs/heads/loop')
 
@@ -534,9 +534,9 @@ class RefsContainerTests(unittest.TestCase):
 
         # HEAD is a symref, so shouldn't equal its dereferenced value
         self.assertFalse(self._refs.remove_if_equals(
 
         # HEAD is a symref, so shouldn't equal its dereferenced value
         self.assertFalse(self._refs.remove_if_equals(
-            'HEAD', '42d06bd4b77fed026b154d16493e5deab78f02ec'))
+          'HEAD', '42d06bd4b77fed026b154d16493e5deab78f02ec'))
         self.assertTrue(self._refs.remove_if_equals(
         self.assertTrue(self._refs.remove_if_equals(
-            'refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'))
+          'refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'))
         self.assertRaises(KeyError, lambda: self._refs['refs/heads/master'])
 
         # HEAD is now a broken symref
         self.assertRaises(KeyError, lambda: self._refs['refs/heads/master'])
 
         # HEAD is now a broken symref
@@ -553,8 +553,8 @@ class RefsContainerTests(unittest.TestCase):
         self.assertEqual('df6800012397fb85c56e7418dd4eb9405dee075c',
                          self._refs['refs/tags/refs-0.1'])
         self.assertTrue(
         self.assertEqual('df6800012397fb85c56e7418dd4eb9405dee075c',
                          self._refs['refs/tags/refs-0.1'])
         self.assertTrue(
-            self._refs.remove_if_equals('refs/tags/refs-0.1',
-            'df6800012397fb85c56e7418dd4eb9405dee075c'))
+          self._refs.remove_if_equals('refs/tags/refs-0.1',
+          'df6800012397fb85c56e7418dd4eb9405dee075c'))
         self.assertRaises(KeyError, lambda: self._refs['refs/tags/refs-0.1'])
 
     def test_read_ref(self):
         self.assertRaises(KeyError, lambda: self._refs['refs/tags/refs-0.1'])
 
     def test_read_ref(self):
index e551f5b00dc9c96c4ba4586cb26937250557255d..7822bee24eca32afb7e74d8b13c95a010d1ae558 100644 (file)
@@ -45,6 +45,7 @@ FOUR = '4' * 40
 FIVE = '5' * 40
 SIX = '6' * 40
 
 FIVE = '5' * 40
 SIX = '6' * 40
 
+
 class TestProto(object):
 
     def __init__(self):
 class TestProto(object):
 
     def __init__(self):
@@ -218,12 +219,12 @@ class ProtocolGraphWalkerTestCase(TestCase):
         #  /
         # 1---2---4
         self._objects = {
         #  /
         # 1---2---4
         self._objects = {
-            ONE: TestCommit(ONE, [], 111),
-            TWO: TestCommit(TWO, [ONE], 222),
-            THREE: TestCommit(THREE, [ONE], 333),
-            FOUR: TestCommit(FOUR, [TWO], 444),
-            FIVE: TestCommit(FIVE, [THREE], 555),
-            }
+          ONE: TestCommit(ONE, [], 111),
+          TWO: TestCommit(TWO, [ONE], 222),
+          THREE: TestCommit(THREE, [ONE], 333),
+          FOUR: TestCommit(FOUR, [TWO], 444),
+          FIVE: TestCommit(FIVE, [THREE], 555),
+          }
 
         self._walker = ProtocolGraphWalker(
             TestUploadPackHandler(self._objects, TestProto()),
 
         self._walker = ProtocolGraphWalker(
             TestUploadPackHandler(self._objects, TestProto()),
@@ -256,13 +257,13 @@ class ProtocolGraphWalkerTestCase(TestCase):
 
     def test_read_proto_line(self):
         self._walker.proto.set_output([
 
     def test_read_proto_line(self):
         self._walker.proto.set_output([
-            'want %s' % ONE,
-            'want %s' % TWO,
-            'have %s' % THREE,
-            'foo %s' % FOUR,
-            'bar',
-            'done',
-            ])
+          'want %s' % ONE,
+          'want %s' % TWO,
+          'have %s' % THREE,
+          'foo %s' % FOUR,
+          'bar',
+          'done',
+          ])
         self.assertEquals(('want', ONE), self._walker.read_proto_line())
         self.assertEquals(('want', TWO), self._walker.read_proto_line())
         self.assertEquals(('have', THREE), self._walker.read_proto_line())
         self.assertEquals(('want', ONE), self._walker.read_proto_line())
         self.assertEquals(('want', TWO), self._walker.read_proto_line())
         self.assertEquals(('have', THREE), self._walker.read_proto_line())
@@ -275,9 +276,9 @@ class ProtocolGraphWalkerTestCase(TestCase):
         self.assertRaises(GitProtocolError, self._walker.determine_wants, {})
 
         self._walker.proto.set_output([
         self.assertRaises(GitProtocolError, self._walker.determine_wants, {})
 
         self._walker.proto.set_output([
-            'want %s multi_ack' % ONE,
-            'want %s' % TWO,
-            ])
+          'want %s multi_ack' % ONE,
+          'want %s' % TWO,
+          ])
         heads = {'ref1': ONE, 'ref2': TWO, 'ref3': THREE}
         self._walker.get_peeled = heads.get
         self.assertEquals([ONE, TWO], self._walker.determine_wants(heads))
         heads = {'ref1': ONE, 'ref2': TWO, 'ref3': THREE}
         self._walker.get_peeled = heads.get
         self.assertEquals([ONE, TWO], self._walker.determine_wants(heads))
@@ -312,11 +313,11 @@ class ProtocolGraphWalkerTestCase(TestCase):
             lines.append(line.rstrip())
 
         self.assertEquals([
             lines.append(line.rstrip())
 
         self.assertEquals([
-            '%s ref4' % FOUR,
-            '%s ref5' % FIVE,
-            '%s tag6^{}' % FIVE,
-            '%s tag6' % SIX,
-            ], sorted(lines))
+          '%s ref4' % FOUR,
+          '%s ref5' % FIVE,
+          '%s tag6^{}' % FIVE,
+          '%s tag6' % SIX,
+          ], sorted(lines))
 
         # ensure peeled tag was advertised immediately following tag
         for i, line in enumerate(lines):
 
         # ensure peeled tag was advertised immediately following tag
         for i, line in enumerate(lines):
@@ -359,11 +360,11 @@ class AckGraphWalkerImplTestCase(TestCase):
     def setUp(self):
         self._walker = TestProtocolGraphWalker()
         self._walker.lines = [
     def setUp(self):
         self._walker = TestProtocolGraphWalker()
         self._walker.lines = [
-            ('have', TWO),
-            ('have', ONE),
-            ('have', THREE),
-            ('done', None),
-            ]
+          ('have', TWO),
+          ('have', ONE),
+          ('have', THREE),
+          ('done', None),
+          ]
         self._impl = self.impl_cls(self._walker)
 
     def assertNoAck(self):
         self._impl = self.impl_cls(self._walker)
 
     def assertNoAck(self):
@@ -451,6 +452,7 @@ class SingleAckGraphWalkerImplTestCase(AckGraphWalkerImplTestCase):
         self.assertNextEquals(None)
         self.assertNak()
 
         self.assertNextEquals(None)
         self.assertNak()
 
+
 class MultiAckGraphWalkerImplTestCase(AckGraphWalkerImplTestCase):
 
     impl_cls = MultiAckGraphWalkerImpl
 class MultiAckGraphWalkerImplTestCase(AckGraphWalkerImplTestCase):
 
     impl_cls = MultiAckGraphWalkerImpl
@@ -488,17 +490,17 @@ class MultiAckGraphWalkerImplTestCase(AckGraphWalkerImplTestCase):
 
     def test_multi_ack_flush(self):
         self._walker.lines = [
 
     def test_multi_ack_flush(self):
         self._walker.lines = [
-            ('have', TWO),
-            (None, None),
-            ('have', ONE),
-            ('have', THREE),
-            ('done', None),
-            ]
+          ('have', TWO),
+          (None, None),
+          ('have', ONE),
+          ('have', THREE),
+          ('done', None),
+          ]
         self.assertNextEquals(TWO)
         self.assertNoAck()
 
         self.assertNextEquals(ONE)
         self.assertNextEquals(TWO)
         self.assertNoAck()
 
         self.assertNextEquals(ONE)
-        self.assertNak() # nak the flush-pkt
+        self.assertNak()  # nak the flush-pkt
 
         self._walker.done = True
         self._impl.ack(ONE)
 
         self._walker.done = True
         self._impl.ack(ONE)
@@ -563,17 +565,17 @@ class MultiAckDetailedGraphWalkerImplTestCase(AckGraphWalkerImplTestCase):
     def test_multi_ack_flush(self):
         # same as ack test but contains a flush-pkt in the middle
         self._walker.lines = [
     def test_multi_ack_flush(self):
         # same as ack test but contains a flush-pkt in the middle
         self._walker.lines = [
-            ('have', TWO),
-            (None, None),
-            ('have', ONE),
-            ('have', THREE),
-            ('done', None),
-            ]
+          ('have', TWO),
+          (None, None),
+          ('have', ONE),
+          ('have', THREE),
+          ('done', None),
+          ]
         self.assertNextEquals(TWO)
         self.assertNoAck()
 
         self.assertNextEquals(ONE)
         self.assertNextEquals(TWO)
         self.assertNoAck()
 
         self.assertNextEquals(ONE)
-        self.assertNak() # nak the flush-pkt
+        self.assertNak()  # nak the flush-pkt
 
         self._walker.done = True
         self._impl.ack(ONE)
 
         self._walker.done = True
         self._impl.ack(ONE)
@@ -602,12 +604,12 @@ class MultiAckDetailedGraphWalkerImplTestCase(AckGraphWalkerImplTestCase):
     def test_multi_ack_nak_flush(self):
         # same as nak test but contains a flush-pkt in the middle
         self._walker.lines = [
     def test_multi_ack_nak_flush(self):
         # same as nak test but contains a flush-pkt in the middle
         self._walker.lines = [
-            ('have', TWO),
-            (None, None),
-            ('have', ONE),
-            ('have', THREE),
-            ('done', None),
-            ]
+          ('have', TWO),
+          (None, None),
+          ('have', ONE),
+          ('have', THREE),
+          ('done', None),
+          ]
         self.assertNextEquals(TWO)
         self.assertNoAck()
 
         self.assertNextEquals(TWO)
         self.assertNoAck()
 
index c9d7d7015a3ba3f3ff873a7c2f71c7c66a339f60..8319974b69ce9f86426470e8c46e46773dda616a 100644 (file)
@@ -40,6 +40,7 @@ from dulwich.web import (
 
 class WebTestCase(TestCase):
     """Base TestCase that sets up some useful instance vars."""
 
 class WebTestCase(TestCase):
     """Base TestCase that sets up some useful instance vars."""
+
     def setUp(self):
         self._environ = {}
         self._req = HTTPGitRequest(self._environ, self._start_response)
     def setUp(self):
         self._environ = {}
         self._req = HTTPGitRequest(self._environ, self._start_response)
@@ -133,16 +134,24 @@ class DumbHandlersTestCase(WebTestCase):
             def __init__(self):
                 objects = [blob1, blob2, blob3, tag1]
                 self.repo = TestRepo(objects, {
             def __init__(self):
                 objects = [blob1, blob2, blob3, tag1]
                 self.repo = TestRepo(objects, {
-                    'HEAD': '000',
-                    'refs/heads/master': blob1.sha(),
-                    'refs/tags/tag-tag': blob2.sha(),
-                    'refs/tags/blob-tag': blob3.sha(),
-                    })
+                  'HEAD': '000',
+                  'refs/heads/master': blob1.sha(),
+                  'refs/tags/tag-tag': blob2.sha(),
+                  'refs/tags/blob-tag': blob3.sha(),
+                  })
 
             def open_repository(self, path):
                 assert path == '/'
                 return self.repo
 
 
             def open_repository(self, path):
                 assert path == '/'
                 return self.repo
 
+            def get_refs(self):
+                return {
+                  'HEAD': '000',
+                  'refs/heads/master': blob1.sha(),
+                  'refs/tags/tag-tag': tag1.sha(),
+                  'refs/tags/blob-tag': blob3.sha(),
+                  }
+
         mat = re.search('.*', '//info/refs')
         self.assertEquals(['111\trefs/heads/master\n',
                            '333\trefs/tags/blob-tag\n',
         mat = re.search('.*', '//info/refs')
         self.assertEquals(['111\trefs/heads/master\n',
                            '333\trefs/tags/blob-tag\n',
@@ -164,12 +173,12 @@ class SmartHandlersTestCase(WebTestCase):
         def handle(self):
             self.proto.write('handled input: %s' % self.proto.recv(1024))
 
         def handle(self):
             self.proto.write('handled input: %s' % self.proto.recv(1024))
 
-    def _MakeHandler(self, *args, **kwargs):
+    def _make_handler(self, *args, **kwargs):
         self._handler = self._TestUploadPackHandler(*args, **kwargs)
         return self._handler
 
     def services(self):
         self._handler = self._TestUploadPackHandler(*args, **kwargs)
         return self._handler
 
     def services(self):
-        return {'git-upload-pack': self._MakeHandler}
+        return {'git-upload-pack': self._make_handler}
 
     def test_handle_service_request_unknown(self):
         mat = re.search('.*', '/git-evil-handler')
 
     def test_handle_service_request_unknown(self):
         mat = re.search('.*', '/git-evil-handler')
@@ -262,13 +271,13 @@ class HTTPGitRequestTestCase(WebTestCase):
         self._req.respond(status=402, content_type='some/type',
                           headers=[('X-Foo', 'foo'), ('X-Bar', 'bar')])
         self.assertEquals(set([
         self._req.respond(status=402, content_type='some/type',
                           headers=[('X-Foo', 'foo'), ('X-Bar', 'bar')])
         self.assertEquals(set([
-            ('X-Foo', 'foo'),
-            ('X-Bar', 'bar'),
-            ('Content-Type', 'some/type'),
-            ('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT'),
-            ('Pragma', 'no-cache'),
-            ('Cache-Control', 'no-cache, max-age=0, must-revalidate'),
-            ]), set(self._headers))
+          ('X-Foo', 'foo'),
+          ('X-Bar', 'bar'),
+          ('Content-Type', 'some/type'),
+          ('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT'),
+          ('Pragma', 'no-cache'),
+          ('Cache-Control', 'no-cache, max-age=0, must-revalidate'),
+          ]), set(self._headers))
         self.assertEquals(402, self._status)
 
 
         self.assertEquals(402, self._status)
 
 
@@ -285,10 +294,10 @@ class HTTPGitApplicationTestCase(TestCase):
             return 'output'
 
         self._app.services = {
             return 'output'
 
         self._app.services = {
-            ('GET', re.compile('/foo$')): test_handler,
+          ('GET', re.compile('/foo$')): test_handler,
         }
         environ = {
         }
         environ = {
-            'PATH_INFO': '/foo',
-            'REQUEST_METHOD': 'GET',
-            }
+          'PATH_INFO': '/foo',
+          'REQUEST_METHOD': 'GET',
+          }
         self.assertEquals('output', self._app(environ, None))
         self.assertEquals('output', self._app(environ, None))
index c075a992996947554a1b720fa6dcdb72c19711ec..ee753b315052014f6b01733248b58e3128d6fa58 100644 (file)
@@ -184,6 +184,7 @@ class _LengthLimitedFile(object):
     Content-Length bytes are read. This behavior is required by the WSGI spec
     but not implemented in wsgiref as of 2.5.
     """
     Content-Length bytes are read. This behavior is required by the WSGI spec
     but not implemented in wsgiref as of 2.5.
     """
+
     def __init__(self, input, max_bytes):
         self._input = input
         self._bytes_avail = max_bytes
     def __init__(self, input, max_bytes):
         self._input = input
         self._bytes_avail = max_bytes
@@ -266,19 +267,19 @@ class HTTPGitRequest(object):
     def nocache(self):
         """Set the response to never be cached by the client."""
         self._cache_headers = [
     def nocache(self):
         """Set the response to never be cached by the client."""
         self._cache_headers = [
-            ('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT'),
-            ('Pragma', 'no-cache'),
-            ('Cache-Control', 'no-cache, max-age=0, must-revalidate'),
-            ]
+          ('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT'),
+          ('Pragma', 'no-cache'),
+          ('Cache-Control', 'no-cache, max-age=0, must-revalidate'),
+          ]
 
     def cache_forever(self):
         """Set the response to be cached forever by the client."""
         now = time.time()
         self._cache_headers = [
 
     def cache_forever(self):
         """Set the response to be cached forever by the client."""
         now = time.time()
         self._cache_headers = [
-            ('Date', date_time_string(now)),
-            ('Expires', date_time_string(now + 31536000)),
-            ('Cache-Control', 'public, max-age=31536000'),
-            ]
+          ('Date', date_time_string(now)),
+          ('Expires', date_time_string(now + 31536000)),
+          ('Cache-Control', 'public, max-age=31536000'),
+          ]
 
 
 class HTTPGitApplication(object):
 
 
 class HTTPGitApplication(object):
@@ -288,17 +289,17 @@ class HTTPGitApplication(object):
     """
 
     services = {
     """
 
     services = {
-        ('GET', re.compile('/HEAD$')): get_text_file,
-        ('GET', re.compile('/info/refs$')): get_info_refs,
-        ('GET', re.compile('/objects/info/alternates$')): get_text_file,
-        ('GET', re.compile('/objects/info/http-alternates$')): get_text_file,
-        ('GET', re.compile('/objects/info/packs$')): get_info_packs,
-        ('GET', re.compile('/objects/([0-9a-f]{2})/([0-9a-f]{38})$')): get_loose_object,
-        ('GET', re.compile('/objects/pack/pack-([0-9a-f]{40})\\.pack$')): get_pack_file,
-        ('GET', re.compile('/objects/pack/pack-([0-9a-f]{40})\\.idx$')): get_idx_file,
-
-        ('POST', re.compile('/git-upload-pack$')): handle_service_request,
-        ('POST', re.compile('/git-receive-pack$')): handle_service_request,
+      ('GET', re.compile('/HEAD$')): get_text_file,
+      ('GET', re.compile('/info/refs$')): get_info_refs,
+      ('GET', re.compile('/objects/info/alternates$')): get_text_file,
+      ('GET', re.compile('/objects/info/http-alternates$')): get_text_file,
+      ('GET', re.compile('/objects/info/packs$')): get_info_packs,
+      ('GET', re.compile('/objects/([0-9a-f]{2})/([0-9a-f]{38})$')): get_loose_object,
+      ('GET', re.compile('/objects/pack/pack-([0-9a-f]{40})\\.pack$')): get_pack_file,
+      ('GET', re.compile('/objects/pack/pack-([0-9a-f]{40})\\.idx$')): get_idx_file,
+
+      ('POST', re.compile('/git-upload-pack$')): handle_service_request,
+      ('POST', re.compile('/git-receive-pack$')): handle_service_request,
     }
 
     def __init__(self, backend, dumb=False):
     }
 
     def __init__(self, backend, dumb=False):