[Python-modules-commits] [python-gitdb] 02/06: New upstream version 2.0.2

Takaki Taniguchi takaki at moszumanska.debian.org
Tue Jul 4 06:10:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

takaki pushed a commit to branch master
in repository python-gitdb.

commit 07cd77ba1f178c5c1e0153f47e06f22b6a610903
Author: TANIGUCHI Takaki <takaki at asis.media-as.org>
Date:   Tue Jul 4 14:58:47 2017 +0900

    New upstream version 2.0.2
---
 PKG-INFO                                      |  3 ++-
 README.rst                                    |  9 ++++-----
 gitdb/__init__.py                             |  2 +-
 gitdb/pack.py                                 | 12 ++++++++++++
 gitdb/test/db/test_pack.py                    | 11 +++++++++++
 gitdb/test/performance/test_pack.py           | 10 +++++-----
 gitdb/test/performance/test_pack_streaming.py |  6 +++---
 gitdb/test/performance/test_stream.py         | 11 ++++++-----
 gitdb/test/test_pack.py                       | 12 +++++++++---
 gitdb/util.py                                 | 27 +++++++++++++++++++++++----
 gitdb2.egg-info/PKG-INFO                      |  3 ++-
 setup.py                                      |  3 ++-
 12 files changed, 80 insertions(+), 29 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 7fbbde2..1187f7f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: gitdb2
-Version: 2.0.0
+Version: 2.0.2
 Summary: Git Object Database
 Home-page: https://github.com/gitpython-developers/gitdb
 Author: Sebastian Thiel
@@ -25,3 +25,4 @@ Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
diff --git a/README.rst b/README.rst
index 1b754d0..ca51dfa 100644
--- a/README.rst
+++ b/README.rst
@@ -43,8 +43,8 @@ Once the clone is complete, please be sure to initialize the submodules using
  cd gitdb
  git submodule update --init
 
-Run the tests with 
- 
+Run the tests with
+
  nosetests
 
 DEVELOPMENT
@@ -52,13 +52,12 @@ DEVELOPMENT
 
 .. image:: https://travis-ci.org/gitpython-developers/gitdb.svg?branch=master
     :target: https://travis-ci.org/gitpython-developers/gitdb
-
+.. image:: https://ci.appveyor.com/api/projects/status/2qa4km4ln7bfv76r/branch/master?svg=true&passingText=windows%20OK&failingText=windows%20failed
+    :target: https://ci.appveyor.com/project/ankostis/gitpython/branch/master)
 .. image:: https://coveralls.io/repos/gitpython-developers/gitdb/badge.png
     :target: https://coveralls.io/r/gitpython-developers/gitdb
-
 .. image:: http://www.issuestats.com/github/gitpython-developers/gitdb/badge/pr
     :target: http://www.issuestats.com/github/gitpython-developers/gitdb
-
 .. image:: http://www.issuestats.com/github/gitpython-developers/gitdb/badge/issue
     :target: http://www.issuestats.com/github/gitpython-developers/gitdb
 
diff --git a/gitdb/__init__.py b/gitdb/__init__.py
index bfa083b..4d58c40 100644
--- a/gitdb/__init__.py
+++ b/gitdb/__init__.py
@@ -29,7 +29,7 @@ _init_externals()
 __author__ = "Sebastian Thiel"
 __contact__ = "byronimo at gmail.com"
 __homepage__ = "https://github.com/gitpython-developers/gitdb"
-version_info = (2, 0, 0)
+version_info = (2, 0, 2)
 __version__ = '.'.join(str(i) for i in version_info)
 
 
diff --git a/gitdb/pack.py b/gitdb/pack.py
index 20a4515..115d943 100644
--- a/gitdb/pack.py
+++ b/gitdb/pack.py
@@ -266,6 +266,10 @@ class PackIndexFile(LazyMixin):
         super(PackIndexFile, self).__init__()
         self._indexpath = indexpath
 
+    def close(self):
+        mman.force_map_handle_removal_win(self._indexpath)
+        self._cursor = None
+        
     def _set_cache_(self, attr):
         if attr == "_packfile_checksum":
             self._packfile_checksum = self._cursor.map()[-40:-20]
@@ -527,6 +531,10 @@ class PackFile(LazyMixin):
     def __init__(self, packpath):
         self._packpath = packpath
 
+    def close(self):
+        mman.force_map_handle_removal_win(self._packpath)
+        self._cursor = None
+        
     def _set_cache_(self, attr):
         # we fill the whole cache, whichever attribute gets queried first
         self._cursor = mman.make_cursor(self._packpath).use_region()
@@ -668,6 +676,10 @@ class PackEntity(LazyMixin):
         self._index = self.IndexFileCls("%s.idx" % basename)            # PackIndexFile instance
         self._pack = self.PackFileCls("%s.pack" % basename)         # corresponding PackFile instance
 
+    def close(self):
+        self._index.close()
+        self._pack.close()
+
     def _set_cache_(self, attr):
         # currently this can only be _offset_map
         # TODO: make this a simple sorted offset array which can be bisected
diff --git a/gitdb/test/db/test_pack.py b/gitdb/test/db/test_pack.py
index a901581..9694238 100644
--- a/gitdb/test/db/test_pack.py
+++ b/gitdb/test/db/test_pack.py
@@ -10,16 +10,22 @@ from gitdb.test.db.lib import (
 from gitdb.db import PackedDB
 
 from gitdb.exc import BadObject, AmbiguousObjectName
+from gitdb.util import mman
 
 import os
 import random
+import sys
 
+from nose.plugins.skip import SkipTest
 
 class TestPackDB(TestDBBase):
 
     @with_rw_directory
     @with_packs_rw
     def test_writing(self, path):
+        if sys.platform == "win32":
+            raise SkipTest("FIXME: Currently fail on windows")
+
         pdb = PackedDB(path)
 
         # on demand, we init our pack cache
@@ -30,6 +36,11 @@ class TestPackDB(TestDBBase):
         # packs removed - rename a file, should affect the glob
         pack_path = pdb.entities()[0].pack().path()
         new_pack_path = pack_path + "renamed"
+        if sys.platform == "win32":
+            # While using this function, we are not allowed to have any handle
+            # to this path, which is currently not the case. The pack caching
+            # does still have a handle :-(
+            mman.force_map_handle_removal_win(pack_path)
         os.rename(pack_path, new_pack_path)
 
         pdb.update_cache(force=True)
diff --git a/gitdb/test/performance/test_pack.py b/gitdb/test/performance/test_pack.py
index bdd2b0a..fc8d9d5 100644
--- a/gitdb/test/performance/test_pack.py
+++ b/gitdb/test/performance/test_pack.py
@@ -36,7 +36,7 @@ class TestPackedDBPerformance(TestBigRepoR):
         sha_list = list(pdb.sha_iter())
         elapsed = time() - st
         ns = len(sha_list)
-        print("PDB: looked up %i shas by index in %f s ( %f shas/s )" % (ns, elapsed, ns / elapsed), file=sys.stderr)
+        print("PDB: looked up %i shas by index in %f s ( %f shas/s )" % (ns, elapsed, ns / (elapsed or 1)), file=sys.stderr)
 
         # sha lookup: best-case and worst case access
         pdb_pack_info = pdb._pack_info
@@ -51,7 +51,7 @@ class TestPackedDBPerformance(TestBigRepoR):
         del(pdb._entities)
         pdb.entities()
         print("PDB: looked up %i sha in %i packs in %f s ( %f shas/s )" %
-              (ns, len(pdb.entities()), elapsed, ns / elapsed), file=sys.stderr)
+              (ns, len(pdb.entities()), elapsed, ns / (elapsed or 1)), file=sys.stderr)
         # END for each random mode
 
         # query info and streams only
@@ -62,7 +62,7 @@ class TestPackedDBPerformance(TestBigRepoR):
                 pdb_fun(sha)
             elapsed = time() - st
             print("PDB: Obtained %i object %s by sha in %f s ( %f items/s )" %
-                  (max_items, pdb_fun.__name__.upper(), elapsed, max_items / elapsed), file=sys.stderr)
+                  (max_items, pdb_fun.__name__.upper(), elapsed, max_items / (elapsed or 1)), file=sys.stderr)
         # END for each function
 
         # retrieve stream and read all
@@ -78,7 +78,7 @@ class TestPackedDBPerformance(TestBigRepoR):
         elapsed = time() - st
         total_kib = total_size / 1000
         print("PDB: Obtained %i streams by sha and read all bytes totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" %
-              (max_items, total_kib, total_kib / elapsed, elapsed, max_items / elapsed), file=sys.stderr)
+              (max_items, total_kib, total_kib / (elapsed or 1), elapsed, max_items / (elapsed or 1)), file=sys.stderr)
 
     @skip_on_travis_ci
     def test_loose_correctness(self):
@@ -129,5 +129,5 @@ class TestPackedDBPerformance(TestBigRepoR):
             # END for each entity
             elapsed = time() - st
             print("PDB: verified %i objects (crc=%i) in %f s ( %f objects/s )" %
-                  (count, crc, elapsed, count / elapsed), file=sys.stderr)
+                  (count, crc, elapsed, count / (elapsed or 1)), file=sys.stderr)
         # END for each verify mode
diff --git a/gitdb/test/performance/test_pack_streaming.py b/gitdb/test/performance/test_pack_streaming.py
index f805e59..76f0f4a 100644
--- a/gitdb/test/performance/test_pack_streaming.py
+++ b/gitdb/test/performance/test_pack_streaming.py
@@ -52,14 +52,14 @@ class TestPackStreamingPerformance(TestBigRepoR):
         # END gather objects for pack-writing
         elapsed = time() - st
         print("PDB Streaming: Got %i streams by sha in in %f s ( %f streams/s )" %
-              (ni, elapsed, ni / elapsed), file=sys.stderr)
+              (ni, elapsed, ni / (elapsed or 1)), file=sys.stderr)
 
         st = time()
         PackEntity.write_pack((pdb.stream(sha) for sha in pdb.sha_iter()), ostream.write, object_count=ni)
         elapsed = time() - st
         total_kb = ostream.bytes_written() / 1000
         print(sys.stderr, "PDB Streaming: Wrote pack of size %i kb in %f s (%f kb/s)" %
-              (total_kb, elapsed, total_kb / elapsed), sys.stderr)
+              (total_kb, elapsed, total_kb / (elapsed or 1)), sys.stderr)
 
     @skip_on_travis_ci
     def test_stream_reading(self):
@@ -82,4 +82,4 @@ class TestPackStreamingPerformance(TestBigRepoR):
         elapsed = time() - st
         total_kib = total_size / 1000
         print(sys.stderr, "PDB Streaming: Got %i streams by sha and read all bytes totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" %
-              (ni, total_kib, total_kib / elapsed, elapsed, ni / elapsed), sys.stderr)
+              (ni, total_kib, total_kib / (elapsed or 1), elapsed, ni / (elapsed or 1)), sys.stderr)
diff --git a/gitdb/test/performance/test_stream.py b/gitdb/test/performance/test_stream.py
index bd66b26..92d28e4 100644
--- a/gitdb/test/performance/test_stream.py
+++ b/gitdb/test/performance/test_stream.py
@@ -9,7 +9,7 @@ from gitdb.test.performance.lib import TestBigRepoR
 from gitdb.db import LooseObjectDB
 from gitdb import IStream
 
-from gitdb.util import bin_to_hex
+from gitdb.util import bin_to_hex, remove
 from gitdb.fun import chunk_size
 
 from time import time
@@ -70,7 +70,7 @@ class TestObjDBPerformance(TestBigRepoR):
 
             size_kib = size / 1000
             print("Added %i KiB (filesize = %i KiB) of %s data to loose odb in %f s ( %f Write KiB / s)" %
-                  (size_kib, fsize_kib, desc, elapsed_add, size_kib / elapsed_add), file=sys.stderr)
+                  (size_kib, fsize_kib, desc, elapsed_add, size_kib / (elapsed_add or 1)), file=sys.stderr)
 
             # reading all at once
             st = time()
@@ -81,7 +81,7 @@ class TestObjDBPerformance(TestBigRepoR):
             stream.seek(0)
             assert shadata == stream.getvalue()
             print("Read %i KiB of %s data at once from loose odb in %f s ( %f Read KiB / s)" %
-                  (size_kib, desc, elapsed_readall, size_kib / elapsed_readall), file=sys.stderr)
+                  (size_kib, desc, elapsed_readall, size_kib / (elapsed_readall or 1)), file=sys.stderr)
 
             # reading in chunks of 1 MiB
             cs = 512 * 1000
@@ -101,8 +101,9 @@ class TestObjDBPerformance(TestBigRepoR):
 
             cs_kib = cs / 1000
             print("Read %i KiB of %s data in %i KiB chunks from loose odb in %f s ( %f Read KiB / s)" %
-                  (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / elapsed_readchunks), file=sys.stderr)
+                  (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / (elapsed_readchunks or 1)), file=sys.stderr)
 
             # del db file so we keep something to do
-            os.remove(db_file)
+            ostream = None  # To release the file handle (win)
+            remove(db_file)
         # END for each randomization factor
diff --git a/gitdb/test/test_pack.py b/gitdb/test/test_pack.py
index 601c0ea..24e2a31 100644
--- a/gitdb/test/test_pack.py
+++ b/gitdb/test/test_pack.py
@@ -188,7 +188,8 @@ class TestPack(TestBase):
 
         # pack writing - write all packs into one
         # index path can be None
-        pack_path = tempfile.mktemp('', "pack", rw_dir)
+        pack_path1 = tempfile.mktemp('', "pack1", rw_dir)
+        pack_path2 = tempfile.mktemp('', "pack2", rw_dir)
         index_path = tempfile.mktemp('', 'index', rw_dir)
         iteration = 0
 
@@ -196,7 +197,9 @@ class TestPack(TestBase):
             for obj in pack_objs:
                 obj.stream.seek(0)
         # END utility
-        for ppath, ipath, num_obj in zip((pack_path, ) * 2, (index_path, None), (len(pack_objs), None)):
+        for ppath, ipath, num_obj in zip((pack_path1, pack_path2),
+                                         (index_path, None),
+                                         (len(pack_objs), None)):
             iwrite = None
             if ipath:
                 ifile = open(ipath, 'wb')
@@ -218,6 +221,7 @@ class TestPack(TestBase):
             assert pf.size() == len(pack_objs)
             assert pf.version() == PackFile.pack_version_default
             assert pf.checksum() == pack_sha
+            pf.close()
 
             # verify index
             if ipath is not None:
@@ -228,6 +232,7 @@ class TestPack(TestBase):
                 assert idx.packfile_checksum() == pack_sha
                 assert idx.indexfile_checksum() == index_sha
                 assert idx.size() == len(pack_objs)
+                idx.close()
             # END verify files exist
         # END for each packpath, indexpath pair
 
@@ -242,7 +247,8 @@ class TestPack(TestBase):
             # END for each crc mode
         # END for each info
         assert count == len(pack_objs)
-
+        entity.close()
+        
     def test_pack_64(self):
         # TODO: hex-edit a pack helping us to verify that we can handle 64 byte offsets
         # of course without really needing such a huge pack
diff --git a/gitdb/util.py b/gitdb/util.py
index 242be44..8a1819b 100644
--- a/gitdb/util.py
+++ b/gitdb/util.py
@@ -6,6 +6,7 @@ import binascii
 import os
 import mmap
 import sys
+import time
 import errno
 
 from io import BytesIO
@@ -58,7 +59,6 @@ chmod = os.chmod
 isdir = os.path.isdir
 isfile = os.path.isfile
 rename = os.rename
-remove = os.remove
 dirname = os.path.dirname
 basename = os.path.basename
 join = os.path.join
@@ -67,6 +67,25 @@ write = os.write
 close = os.close
 fsync = os.fsync
 
+
+def _retry(func, *args, **kwargs):
+    # Wrapper around functions, that are problematic on "Windows". Sometimes
+    # the OS or someone else has still a handle to the file
+    if sys.platform == "win32":
+        for _ in range(10):
+            try:
+                return func(*args, **kwargs)
+            except Exception:
+                time.sleep(0.1)
+        return func(*args, **kwargs)
+    else:
+        return func(*args, **kwargs)
+
+
+def remove(*args, **kwargs):
+    return _retry(os.remove, *args, **kwargs)
+
+
 # Backwards compatibility imports
 from gitdb.const import (
     NULL_BIN_SHA,
@@ -321,7 +340,7 @@ class LockedFD(object):
                 self._fd = os.open(self._filepath, os.O_RDONLY | binary)
             except:
                 # assure we release our lockfile
-                os.remove(self._lockfilepath())
+                remove(self._lockfilepath())
                 raise
             # END handle lockfile
         # END open descriptor for reading
@@ -365,7 +384,7 @@ class LockedFD(object):
             # on windows, rename does not silently overwrite the existing one
             if sys.platform == "win32":
                 if isfile(self._filepath):
-                    os.remove(self._filepath)
+                    remove(self._filepath)
                 # END remove if exists
             # END win32 special handling
             os.rename(lockfile, self._filepath)
@@ -376,7 +395,7 @@ class LockedFD(object):
             chmod(self._filepath, int("644", 8))
         else:
             # just delete the file so far, we failed
-            os.remove(lockfile)
+            remove(lockfile)
         # END successful handling
 
 #} END utilities
diff --git a/gitdb2.egg-info/PKG-INFO b/gitdb2.egg-info/PKG-INFO
index 7fbbde2..1187f7f 100644
--- a/gitdb2.egg-info/PKG-INFO
+++ b/gitdb2.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: gitdb2
-Version: 2.0.0
+Version: 2.0.2
 Summary: Git Object Database
 Home-page: https://github.com/gitpython-developers/gitdb
 Author: Sebastian Thiel
@@ -25,3 +25,4 @@ Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
diff --git a/setup.py b/setup.py
index f7e3761..2e673f6 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ from setuptools import setup
 __author__ = "Sebastian Thiel"
 __contact__ = "byronimo at gmail.com"
 __homepage__ = "https://github.com/gitpython-developers/gitdb"
-version_info = (2, 0, 0)
+version_info = (2, 0, 2)
 __version__ = '.'.join(str(i) for i in version_info)
 
 setup(
@@ -41,5 +41,6 @@ setup(
         "Programming Language :: Python :: 3.3",
         "Programming Language :: Python :: 3.4",
         "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
     ]
 )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-gitdb.git



More information about the Python-modules-commits mailing list