Przeglądaj źródła

New upstream release.

Jelmer Vernooij 14 lat temu
rodzic
commit
9135e6f33b

+ 4 - 1
HACKING

@@ -1,4 +1,7 @@
-Please follow PEP8 with regard to coding style.
+Where possible, please follow PEP8 with regard to coding style.
+
+Furthermore, triple-quotes should always be """, single quotes are ' unless using "
+would result in less escaping within the string.
 
 All functionality should be available in pure Python. Optional C
 implementations may be written for performance reasons, but should never

+ 1 - 1
Makefile

@@ -4,7 +4,7 @@ PYDOCTOR ?= pydoctor
 ifeq ($(shell $(PYTHON) -c "import sys; print sys.version_info >= (2, 7)"),True)
 TESTRUNNER ?= unittest
 else
-TESTRUNNER ?= unittest2
+TESTRUNNER ?= unittest2.__main__
 endif
 RUNTEST = PYTHONPATH=.:$(PYTHONPATH) $(PYTHON) -m $(TESTRUNNER)
 

+ 1 - 1
NEWS

@@ -1,4 +1,4 @@
-0.7.0	UNRELEASED
+0.7.0	2011-01-21
 
  FEATURES
 

+ 3 - 3
debian/changelog

@@ -1,10 +1,10 @@
-dulwich (0.6.2+bzr788-1) UNRELEASED; urgency=low
+dulwich (0.7.0-1) unstable; urgency=low
 
-  * New upstream snapshot.
+  * New upstream release.
    + Changes default test runner from nose to testtools.
   * Drop Pure- from the description.
 
- -- Jelmer Vernooij <jelmer@debian.org>  Tue, 28 Dec 2010 01:50:22 +0100
+ -- Jelmer Vernooij <jelmer@debian.org>  Fri, 21 Jan 2011 19:38:13 +0100
 
 dulwich (0.6.2+bzr702-1) unstable; urgency=low
 

+ 1 - 5
dulwich/__init__.py

@@ -21,10 +21,6 @@
 
 """Python implementation of the Git file formats and protocols."""
 
-
-import client
-import protocol
-import repo
-import server
+from dulwich import (client, protocol, repo, server)
 
 __version__ = (0, 7, 0)

+ 19 - 19
dulwich/client.py

@@ -45,8 +45,8 @@ def _fileno_can_read(fileno):
     """Check if a file descriptor is readable."""
     return len(select.select([fileno], [], [], 0)[0]) > 0
 
-COMMON_CAPABILITIES = ["ofs-delta"]
-FETCH_CAPABILITIES = ["multi_ack", "side-band-64k"] + COMMON_CAPABILITIES
+COMMON_CAPABILITIES = ['ofs-delta']
+FETCH_CAPABILITIES = ['multi_ack', 'side-band-64k'] + COMMON_CAPABILITIES
 SEND_CAPABILITIES = ['report-status'] + COMMON_CAPABILITIES
 
 # TODO(durin42): this doesn't correctly degrade if the server doesn't
@@ -68,7 +68,7 @@ class GitClient(object):
         self._fetch_capabilities = list(FETCH_CAPABILITIES)
         self._send_capabilities = list(SEND_CAPABILITIES)
         if thin_packs:
-            self._fetch_capabilities.append("thin-pack")
+            self._fetch_capabilities.append('thin-pack')
 
     def _connect(self, cmd, path):
         """Create a connection to the server.
@@ -89,7 +89,7 @@ class GitClient(object):
         refs = {}
         # Receive refs from server
         for pkt in proto.read_pkt_seq():
-            (sha, ref) = pkt.rstrip("\n").split(" ", 1)
+            (sha, ref) = pkt.rstrip('\n').split(' ', 1)
             if server_capabilities is None:
                 (ref, server_capabilities) = extract_capabilities(ref)
             refs[ref] = sha
@@ -162,11 +162,11 @@ class GitClient(object):
             new_sha1 = new_refs.get(refname, ZERO_SHA)
             if old_sha1 != new_sha1:
                 if sent_capabilities:
-                    proto.write_pkt_line("%s %s %s" % (old_sha1, new_sha1,
+                    proto.write_pkt_line('%s %s %s' % (old_sha1, new_sha1,
                                                             refname))
                 else:
                     proto.write_pkt_line(
-                      "%s %s %s\0%s" % (old_sha1, new_sha1, refname,
+                      '%s %s %s\0%s' % (old_sha1, new_sha1, refname,
                                         ' '.join(self._send_capabilities)))
                     sent_capabilities = True
             if new_sha1 not in have and new_sha1 != ZERO_SHA:
@@ -221,28 +221,28 @@ class GitClient(object):
             proto.write_pkt_line(None)
             return refs
         assert isinstance(wants, list) and type(wants[0]) == str
-        proto.write_pkt_line("want %s %s\n" % (
+        proto.write_pkt_line('want %s %s\n' % (
             wants[0], ' '.join(self._fetch_capabilities)))
         for want in wants[1:]:
-            proto.write_pkt_line("want %s\n" % want)
+            proto.write_pkt_line('want %s\n' % want)
         proto.write_pkt_line(None)
         have = graph_walker.next()
         while have:
-            proto.write_pkt_line("have %s\n" % have)
+            proto.write_pkt_line('have %s\n' % have)
             if can_read():
                 pkt = proto.read_pkt_line()
-                parts = pkt.rstrip("\n").split(" ")
-                if parts[0] == "ACK":
+                parts = pkt.rstrip('\n').split(' ')
+                if parts[0] == 'ACK':
                     graph_walker.ack(parts[1])
-                    assert parts[2] == "continue"
+                    assert parts[2] == 'continue'
             have = graph_walker.next()
-        proto.write_pkt_line("done\n")
+        proto.write_pkt_line('done\n')
         pkt = proto.read_pkt_line()
         while pkt:
-            parts = pkt.rstrip("\n").split(" ")
-            if parts[0] == "ACK":
-                graph_walker.ack(pkt.split(" ")[1])
-            if len(parts) < 3 or parts[2] != "continue":
+            parts = pkt.rstrip('\n').split(' ')
+            if parts[0] == 'ACK':
+                graph_walker.ack(pkt.split(' ')[1])
+            if len(parts) < 3 or parts[2] != 'continue':
                 break
             pkt = proto.read_pkt_line()
         # TODO(durin42): this is broken if the server didn't support the
@@ -256,7 +256,7 @@ class GitClient(object):
                 if progress is not None:
                     progress(pkt)
             else:
-                raise AssertionError("Invalid sideband channel %d" % channel)
+                raise AssertionError('Invalid sideband channel %d' % channel)
         return refs
 
 
@@ -323,7 +323,7 @@ class SSHVendor(object):
         if port is not None:
             args.extend(['-p', str(port)])
         if username is not None:
-            host = "%s@%s" % (username, host)
+            host = '%s@%s' % (username, host)
         args.append(host)
         proc = subprocess.Popen(args + command,
                                 stdin=subprocess.PIPE,

+ 2 - 0
dulwich/object_store.py

@@ -454,6 +454,7 @@ class DiskObjectStore(PackBasedObjectStore):
             if os.path.getsize(path) > 0:
                 return self.move_in_thin_pack(path)
             else:
+                os.remove(path)
                 return None
         return f, commit
 
@@ -471,6 +472,7 @@ class DiskObjectStore(PackBasedObjectStore):
             if os.path.getsize(path) > 0:
                 return self.move_in_pack(path)
             else:
+                os.remove(path)
                 return None
         return f, commit
 

+ 1 - 1
dulwich/pack.py

@@ -33,7 +33,7 @@ a pointer in to the corresponding packfile.
 try:
     from collections import defaultdict
 except ImportError:
-    from _compat import defaultdict
+    from dulwich._compat import defaultdict
 
 from cStringIO import (
     StringIO,

+ 2 - 1
dulwich/repo.py

@@ -243,7 +243,6 @@ class RefsContainer(object):
         :return: a tuple of (refname, sha), where refname is the name of the
             last reference in the symbolic reference chain
         """
-        self._check_refname(name)
         contents = SYMREF + name
         depth = 0
         while contents.startswith(SYMREF):
@@ -360,6 +359,7 @@ class DictRefsContainer(RefsContainer):
         if old_ref is not None and self._refs.get(name, None) != old_ref:
             return False
         realname, _ = self._follow(name)
+        self._check_refname(realname)
         self._refs[realname] = new_ref
         return True
 
@@ -574,6 +574,7 @@ class DiskRefsContainer(RefsContainer):
         :param new_ref: The new sha the refname will refer to.
         :return: True if the set was successful, False otherwise.
         """
+        self._check_refname(name)
         try:
             realname, _ = self._follow(name)
         except KeyError:

+ 10 - 10
dulwich/tests/__init__.py

@@ -21,27 +21,27 @@
 
 import doctest
 import os
-import unittest
 import shutil
 import subprocess
 import sys
 import tempfile
 
-try:
+
+if sys.version_info >= (2, 7):
     # If Python itself provides an exception, use that
+    import unittest
     from unittest import SkipTest as TestSkipped
-except ImportError:
+    from unittest import TestCase
+else:
     try:
+        import unittest2 as unittest
         from unittest2 import SkipTest as TestSkipped
+        from unittest2 import TestCase
     except ImportError:
+        import unittest
         from testtools.testcase import TestSkipped
-
-try:
-    from testtools.testcase import TestCase
-except ImportError:
-    from unittest import TestCase
-else:
-    TestCase.skipException = TestSkipped
+        from testtools.testcase import TestCase
+        TestCase.skipException = TestSkipped
 
 
 class BlackboxTestCase(TestCase):

+ 1 - 1
dulwich/tests/compat/server_utils.py

@@ -30,7 +30,7 @@ from dulwich.server import (
 from dulwich.tests.utils import (
     tear_down_repo,
     )
-from utils import (
+from dulwich.tests.compat.utils import (
     import_repo,
     run_git_or_fail,
     )

+ 10 - 8
dulwich/tests/compat/test_client.py

@@ -25,18 +25,20 @@ import signal
 import subprocess
 import tempfile
 
-from dulwich import client
-from dulwich import errors
-from dulwich import file
-from dulwich import index
-from dulwich import protocol
-from dulwich import objects
-from dulwich import repo
+from dulwich import (
+    client,
+    errors,
+    file,
+    index,
+    protocol,
+    objects,
+    repo,
+    )
 from dulwich.tests import (
     TestSkipped,
     )
 
-from utils import (
+from dulwich.tests.compat.utils import (
     CompatTestCase,
     check_for_daemon,
     import_repo_to_dir,

+ 1 - 1
dulwich/tests/compat/test_pack.py

@@ -32,7 +32,7 @@ from dulwich.tests.test_pack import (
     pack1_sha,
     PackTests,
     )
-from utils import (
+from dulwich.tests.compat.utils import (
     require_git_version,
     run_git_or_fail,
     )

+ 1 - 1
dulwich/tests/compat/test_repository.py

@@ -34,7 +34,7 @@ from dulwich.tests.utils import (
     tear_down_repo,
     )
 
-from utils import (
+from dulwich.tests.compat.utils import (
     run_git_or_fail,
     import_repo,
     CompatTestCase,

+ 2 - 2
dulwich/tests/compat/test_server.py

@@ -30,12 +30,12 @@ from dulwich.server import (
     DictBackend,
     TCPGitServer,
     )
-from server_utils import (
+from dulwich.tests.compat.server_utils import (
     ServerTests,
     ShutdownServerMixIn,
     NoSideBand64kReceivePackHandler,
     )
-from utils import (
+from dulwich.tests.compat.utils import (
     CompatTestCase,
     )
 

+ 1 - 1
dulwich/tests/compat/test_utils.py

@@ -23,7 +23,7 @@ from dulwich.tests import (
     TestCase,
     TestSkipped,
     )
-import utils
+from dulwich.tests.compat import utils
 
 
 class GitVersionTests(TestCase):

+ 2 - 2
dulwich/tests/compat/test_web.py

@@ -38,12 +38,12 @@ from dulwich.web import (
     HTTPGitRequestHandler,
     )
 
-from server_utils import (
+from dulwich.tests.compat.server_utils import (
     ServerTests,
     ShutdownServerMixIn,
     NoSideBand64kReceivePackHandler,
     )
-from utils import (
+from dulwich.utils import (
     CompatTestCase,
     )
 

+ 8 - 8
dulwich/tests/test_client.py

@@ -64,11 +64,11 @@ class GitClientTests(TestCase):
 
     def test_fetch_pack_none(self):
         self.rin.write(
-            "008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n"
-            "0000")
+            '008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n'
+            '0000')
         self.rin.seek(0)
-        self.client.fetch_pack("bla", lambda heads: [], None, None, None)
-        self.assertEquals(self.rout.getvalue(), "0000")
+        self.client.fetch_pack('bla', lambda heads: [], None, None, None)
+        self.assertEquals(self.rout.getvalue(), '0000')
 
     def test_get_transport_and_path_tcp(self):
         client, path = get_transport_and_path('git://foo.com/bar/baz')
@@ -132,12 +132,12 @@ class SSHGitClientTests(TestCase):
 
     def setUp(self):
         super(SSHGitClientTests, self).setUp()
-        self.client = SSHGitClient("git.samba.org")
+        self.client = SSHGitClient('git.samba.org')
 
     def test_default_command(self):
-        self.assertEquals("git-upload-pack", self.client._get_cmd_path("upload-pack"))
+        self.assertEquals('git-upload-pack', self.client._get_cmd_path('upload-pack'))
 
     def test_alternative_command_path(self):
-        self.client.alternative_paths["upload-pack"] = "/usr/lib/git/git-upload-pack"
-        self.assertEquals("/usr/lib/git/git-upload-pack", self.client._get_cmd_path("upload-pack"))
+        self.client.alternative_paths['upload-pack'] = '/usr/lib/git/git-upload-pack'
+        self.assertEquals('/usr/lib/git/git-upload-pack', self.client._get_cmd_path('upload-pack'))
 

+ 1 - 1
dulwich/tests/test_object_store.py

@@ -47,7 +47,7 @@ from dulwich.pack import (
 from dulwich.tests import (
     TestCase,
     )
-from utils import (
+from dulwich.tests.utils import (
     make_object,
     )
 

+ 10 - 2
dulwich/tests/test_repository.py

@@ -574,6 +574,8 @@ class RefsContainerTests(object):
         self._refs['refs/some/ref'] = '42d06bd4b77fed026b154d16493e5deab78f02ec'
         self.assertEqual('42d06bd4b77fed026b154d16493e5deab78f02ec',
                          self._refs['refs/some/ref'])
+        self.assertRaises(errors.RefFormatError, self._refs.__setitem__,
+                          'notrefs/foo', '42d06bd4b77fed026b154d16493e5deab78f02ec')
 
     def test_set_if_equals(self):
         nines = '9' * 40
@@ -650,6 +652,14 @@ class DictRefsContainerTests(RefsContainerTests, TestCase):
         TestCase.setUp(self)
         self._refs = DictRefsContainer(dict(_TEST_REFS))
 
+    def test_invalid_refname(self):
+        # FIXME: Move this test into RefsContainerTests, but requires
+        # some way of injecting invalid refs.
+        self._refs._refs["refs/stash"] = "00" * 20
+        expected_refs = dict(_TEST_REFS)
+        expected_refs["refs/stash"] = "00" * 20
+        self.assertEquals(expected_refs, self._refs.as_dict())
+
 
 class DiskRefsContainerTests(RefsContainerTests, TestCase):
 
@@ -748,8 +758,6 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
         self.assertEquals(
           ('refs/heads/master', '42d06bd4b77fed026b154d16493e5deab78f02ec'),
           self._refs._follow('refs/heads/master'))
-        self.assertRaises(errors.RefFormatError, self._refs._follow,
-                          'notrefs/foo')
         self.assertRaises(KeyError, self._refs._follow, 'refs/heads/loop')
 
     def test_delitem(self):

+ 1 - 1
dulwich/tests/test_server.py

@@ -46,7 +46,7 @@ from dulwich.server import (
     UploadPackHandler,
     )
 from dulwich.tests import TestCase
-from utils import (
+from dulwich.tests.utils import (
     make_commit,
     )
 

+ 3 - 1
dulwich/tests/test_web.py

@@ -56,7 +56,9 @@ from dulwich.web import (
     HTTPGitApplication,
     )
 
-from utils import make_object
+from dulwich.tests.utils import (
+    make_object,
+    )
 
 
 class TestHTTPGitRequest(HTTPGitRequest):