Explorar o código

Import upstream version 0.6.2+bzr704

Jelmer Vernooij %!s(int64=14) %!d(string=hai) anos
pai
achega
1eecc016e2
Modificáronse 4 ficheiros con 27 adicións e 12 borrados
  1. 3 0
      NEWS
  2. 2 11
      dulwich/client.py
  3. 4 1
      dulwich/patch.py
  4. 18 0
      dulwich/tests/test_patch.py

+ 3 - 0
NEWS

@@ -11,6 +11,9 @@
   * Correct short-circuiting operation for no-op fetches in the server.
     (Dave Borowitz)
 
+  * Support parsing git mbox patches without a version tail, as generated by Mercurial. 
+    (Jelmer Vernooij)
+
 0.6.2	2010-10-16
 
  BUG FIXES

+ 2 - 11
dulwich/client.py

@@ -259,15 +259,6 @@ class GitClient(object):
         return refs
 
 
-def can_read(f):
-    """Check if a file descriptor is readable.
-
-    :param f: either the number of the file descriptor or a file-like
-             object which returns the fileno when f.fileno() is called.
-    """
-    return len(select.select([f], [], [], 0)[0]) > 0
-
-
 class TCPGitClient(GitClient):
     """A Git Client that works over TCP directly (i.e. git://)."""
 
@@ -288,7 +279,7 @@ class TCPGitClient(GitClient):
         proto = Protocol(rfile.read, wfile.write,
                          report_activity=self._report_activity)
         proto.send_cmd('git-%s' % cmd, path, 'host=%s' % self._host)
-        return proto, lambda: can_read(s)
+        return proto, lambda: _fileno_can_read(s)
 
 
 class SubprocessWrapper(object):
@@ -300,7 +291,7 @@ class SubprocessWrapper(object):
         self.write = proc.stdin.write
 
     def can_read(self):
-        return can_read(self.proc.stdout.fileno())
+        return _fileno_can_read(self.proc.stdout.fileno())
 
     def close(self):
         self.proc.stdin.close()

+ 4 - 1
dulwich/patch.py

@@ -179,5 +179,8 @@ def git_am_patch_split(f):
         if l == "-- \n":
             break
         diff += l
-    version = f.next().rstrip("\n")
+    try:
+        version = f.next().rstrip("\n")
+    except StopIteration:
+        version = None
     return c, diff, version

+ 18 - 0
dulwich/tests/test_patch.py

@@ -135,3 +135,21 @@ From: Jelmer Vernooy <jelmer@debian.org>
         c, diff, version = git_am_patch_split(StringIO(text))
         self.assertEquals("Jelmer Vernooy <jelmer@debian.org>", c.author)
         self.assertEquals('Added unit tests for dulwich.object_store.tree_lookup_path.\n\n* dulwich/tests/test_object_store.py\n  (TreeLookupPathTests): This test case contains a few tests that ensure the\n   tree_lookup_path function works as expected.\n', c.message)
+
+    def test_extract_no_version_tail(self):
+        text = """From ff643aae102d8870cac88e8f007e70f58f3a7363 Mon Sep 17 00:00:00 2001
+From: Jelmer Vernooij <jelmer@samba.org>
+Date: Thu, 15 Apr 2010 15:40:28 +0200
+Subject:  [Dulwich-users] [PATCH] Added unit tests for
+ dulwich.object_store.tree_lookup_path.
+
+From: Jelmer Vernooy <jelmer@debian.org>
+
+---
+ pixmaps/prey.ico |  Bin 9662 -> 9662 bytes
+ 1 files changed, 0 insertions(+), 0 deletions(-)
+ mode change 100755 => 100644 pixmaps/prey.ico
+
+"""
+        c, diff, version = git_am_patch_split(StringIO(text))
+        self.assertIs(None, version)