Pārlūkot izejas kodu

New upstream release.

Jelmer Vernooij 13 gadi atpakaļ
vecāks
revīzija
0581d5eb3c
7 mainītis faili ar 90 papildinājumiem un 37 dzēšanām
  1. 4 1
      NEWS
  2. 3 3
      debian/changelog
  3. 50 13
      dulwich/index.py
  4. 1 1
      dulwich/server.py
  5. 22 0
      dulwich/tests/test_index.py
  6. 0 1
      dulwich/web.py
  7. 10 18
      setup.py

+ 4 - 1
NEWS

@@ -1,4 +1,4 @@
-0.8.2	UNRELEASED
+0.8.2	2011-12-18
 
  BUG FIXES
 
@@ -15,6 +15,9 @@
   * Properly abort connections when the determine_wants function
     raises an exception. (Jelmer Vernooij, #856769)
 
+  * Tweak xcodebuild hack to deal with more error output.
+    (Jelmer Vernooij, #903840)
+
  FEATURES
 
   * Add support for retrieving tarballs from remote servers.

+ 3 - 3
debian/changelog

@@ -1,9 +1,9 @@
-dulwich (0.8.1+bzr983-1) UNRELEASED; urgency=low
+dulwich (0.8.2-1) UNRELEASED; urgency=low
 
   * Fix Vcs URL.
-  * New upstream snapshot.
+  * New upstream release.
 
- -- Jelmer Vernooij <jelmer@debian.org>  Thu, 17 Nov 2011 04:37:28 +0100
+ -- Jelmer Vernooij <jelmer@debian.org>  Sun, 18 Dec 2011 21:35:03 +0100
 
 dulwich (0.8.1-1) unstable; urgency=low
 

+ 50 - 13
dulwich/index.py

@@ -275,19 +275,13 @@ class Index(object):
         :param want_unchanged: Whether unchanged files should be reported
         :return: Iterator over tuples with (oldpath, newpath), (oldmode, newmode), (oldsha, newsha)
         """
-        mine = set(self._byname.keys())
-        for (name, mode, sha) in object_store.iter_tree_contents(tree):
-            if name in mine:
-                if (want_unchanged or self.get_sha1(name) != sha or 
-                    self.get_mode(name) != mode):
-                    yield ((name, name), (mode, self.get_mode(name)), (sha, self.get_sha1(name)))
-                mine.remove(name)
-            else:
-                # Was removed
-                yield ((name, None), (mode, None), (sha, None))
-        # Mention added files
-        for name in mine:
-            yield ((None, name), (None, self.get_mode(name)), (None, self.get_sha1(name)))
+        def lookup_entry(path):
+            entry = self[path]
+            return entry[-2], entry[-6]
+        for (name, mode, sha) in changes_from_tree(self._byname.keys(),
+                lookup_entry, object_store, tree,
+                want_unchanged=want_unchanged):
+            yield (name, mode, sha)
 
     def commit(self, object_store):
         """Create a new tree from an index.
@@ -345,3 +339,46 @@ def commit_index(object_store, index):
     :return: Root tree sha.
     """
     return commit_tree(object_store, index.iterblobs())
+
+
+def changes_from_tree(names, lookup_entry, object_store, tree,
+        want_unchanged=False):
+    """Find the differences between the contents of a tree and
+    a working copy.
+
+    :param names: Iterable of names in the working copy
+    :param lookup_entry: Function to lookup an entry in the working copy
+    :param object_store: Object store to use for retrieving tree contents
+    :param tree: SHA1 of the root tree
+    :param want_unchanged: Whether unchanged files should be reported
+    :return: Iterator over tuples with (oldpath, newpath), (oldmode, newmode),
+        (oldsha, newsha)
+    """
+    other_names = set(names)
+    for (name, mode, sha) in object_store.iter_tree_contents(tree):
+        try:
+            (other_sha, other_mode) = lookup_entry(name)
+        except KeyError:
+            # Was removed
+            yield ((name, None), (mode, None), (sha, None))
+        else:
+            other_names.remove(name)
+            if (want_unchanged or other_sha != sha or other_mode != mode):
+                yield ((name, name), (mode, other_mode), (sha, other_sha))
+
+    # Mention added files
+    for name in other_names:
+        (other_sha, other_mode) = lookup_entry(name)
+        yield ((None, name), (None, other_mode), (None, other_sha))
+
+
+def index_entry_from_stat(stat_val, hex_sha, flags):
+    """Create a new index entry from a stat value.
+
+    :param stat_val: POSIX stat_result instance
+    :param hex_sha: Hex sha of the object
+    :param flags: Index flags
+    """
+    return (stat_val.st_ctime, stat_val.st_mtime, stat_val.st_dev,
+            stat_val.st_ino, stat_val.st_mode, stat_val.st_uid,
+            stat_val.st_gid, stat_val.st_size, hex_sha, flags)

+ 1 - 1
dulwich/server.py

@@ -799,7 +799,7 @@ def generate_info_refs(repo):
         if name == 'HEAD':
             continue
         sha = refs[name]
-        o = repo[sha]
+        o = repo.object_store[sha]
         if not o:
             continue
         yield '%s\t%s\n' % (sha, name)

+ 22 - 0
dulwich/tests/test_index.py

@@ -23,6 +23,7 @@ from cStringIO import (
     StringIO,
     )
 import os
+import posix
 import shutil
 import stat
 import struct
@@ -32,6 +33,7 @@ from dulwich.index import (
     Index,
     cleanup_mode,
     commit_tree,
+    index_entry_from_stat,
     read_index,
     write_cache_time,
     write_index,
@@ -169,3 +171,23 @@ class WriteCacheTimeTests(TestCase):
         f = StringIO()
         write_cache_time(f, 434343.000000021)
         self.assertEquals(struct.pack(">LL", 434343, 21), f.getvalue())
+
+
+class IndexEntryFromStatTests(TestCase):
+
+    def test_simple(self):
+        st = posix.stat_result((16877, 131078, 64769L,
+                154, 1000, 1000, 12288,
+                1323629595, 1324180496, 1324180496))
+        entry = index_entry_from_stat(st, "22" * 20, 0)
+        self.assertEquals(entry, (
+            1324180496,
+            1324180496,
+            64769L,
+            131078,
+            16877,
+            1000,
+            1000,
+            12288,
+            '2222222222222222222222222222222222222222',
+            0))

+ 0 - 1
dulwich/web.py

@@ -29,7 +29,6 @@ try:
 except ImportError:
     from dulwich._compat import parse_qs
 from dulwich import log_utils
-from dulwich.gzip import GzipConsumer
 from dulwich.protocol import (
     ReceivableProtocol,
     )

+ 10 - 18
setup.py

@@ -35,27 +35,19 @@ class DulwichDistribution(Distribution):
 
     pure = False
 
-def runcmd(cmd, env):
-    import subprocess
-    p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE, env=env)
-    out, err = p.communicate()
-    err = [e for e in err.splitlines()
-           if not e.startswith('Not trusting file') \
-              and not e.startswith('warning: Not importing')]
-    if err:
-        return ''
-    return out
-
-
 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
     # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
     # distutils.sysconfig
-    version = runcmd(['/usr/bin/xcodebuild', '-version'], {}).splitlines()[0]
-    # Also parse only first digit, because 3.2.1 can't be parsed nicely
-    if (version.startswith('Xcode') and
-        int(version.split()[1].split('.')[0]) >= 4):
-        os.environ['ARCHFLAGS'] = ''
+    import subprocess
+    p = subprocess.Popen(
+        ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE, env={})
+    out, err = p.communicate()
+    for l in out.splitlines():
+        # Also parse only first digit, because 3.2.1 can't be parsed nicely
+        if (l.startswith('Xcode') and
+            int(l.split()[1].split('.')[0]) >= 4):
+            os.environ['ARCHFLAGS'] = ''
 
 setup_kwargs = {}