summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-09-29 01:07:41 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-09-29 01:46:15 +0200
commit395955609dfd711cc4558e2b618450f3514b28c1 (patch)
tree9ee15a36cbc05f9b509aedbda2373cfc0ace2d17
parentf1d2d0683afa6328b6015c6a3aa6a6912a055756 (diff)
downloadgitpython-395955609dfd711cc4558e2b618450f3514b28c1.tar.gz
FIX hook TC on PY3+Win & indeterministic lock timing.
+ Cannot `index.path` into ENV, it is bytes! + The hook TC never runs on linux! + Unblock removal of odbfile in perf-large streams TC. + Attempt to unblock removal of submodule file by intensive cleaning. more unblock files
-rw-r--r--.appveyor.yml34
-rw-r--r--git/compat.py10
-rw-r--r--git/index/fun.py5
-rw-r--r--git/objects/submodule/base.py2
-rw-r--r--git/test/performance/test_streams.py3
-rw-r--r--git/test/test_util.py5
6 files changed, 41 insertions, 18 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 8ca22ea9..3a8c76aa 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -5,32 +5,36 @@ environment:
CYGWIN64_GIT_PATH: "C:\\cygwin64\\bin;%GIT_DAEMON_PATH%"
matrix:
+ ## MINGW
+ #
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7"
GIT_PATH: "%GIT_DAEMON_PATH%"
- - PYTHON: "C:\\Miniconda-x64"
- PYTHON_VERSION: "2.7"
- IS_CONDA: "yes"
- GIT_PATH: "%CYGWIN_GIT_PATH%"
-
- PYTHON: "C:\\Python34-x64"
PYTHON_VERSION: "3.4"
GIT_PATH: "%GIT_DAEMON_PATH%"
- - PYTHON: "C:\\Python34-x64"
- PYTHON_VERSION: "3.4"
- GIT_PATH: "%CYGWIN_GIT_PATH%"
-
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5"
GIT_PATH: "%GIT_DAEMON_PATH%"
- - PYTHON: "C:\\Python35-x64"
- PYTHON_VERSION: "3.5"
- GIT_PATH: "%CYGWIN64_GIT_PATH%"
- PYTHON: "C:\\Miniconda35-x64"
PYTHON_VERSION: "3.5"
IS_CONDA: "yes"
GIT_PATH: "%GIT_DAEMON_PATH%"
+ ## Cygwin
+ #
+ - PYTHON: "C:\\Miniconda-x64"
+ PYTHON_VERSION: "2.7"
+ IS_CONDA: "yes"
+ GIT_PATH: "%CYGWIN_GIT_PATH%"
+ - PYTHON: "C:\\Python34-x64"
+ PYTHON_VERSION: "3.4"
+ GIT_PATH: "%CYGWIN_GIT_PATH%"
+ - PYTHON: "C:\\Python35-x64"
+ PYTHON_VERSION: "3.5"
+ GIT_PATH: "%CYGWIN64_GIT_PATH%"
+
+
install:
- set PATH=%PYTHON%;%PYTHON%\Scripts;%GIT_PATH%;%PATH%
@@ -44,9 +48,9 @@ install:
- IF "%IS_CONDA%"=="yes" (
conda info -a &
- conda install --yes --quiet pip
+ conda install --yes --quiet pip
)
- - pip install nose ddt wheel coveralls
+ - pip install nose ddt wheel coveralls
- IF "%PYTHON_VERSION%"=="2.7" (
pip install mock
)
@@ -73,7 +77,7 @@ install:
build: false
test_script:
- - nosetests -v
+ - nosetests
#on_success:
# - IF "%PYTHON_VERSION%"=="3.4" (coveralls)
diff --git a/git/compat.py b/git/compat.py
index d6be6ede..e760575d 100644
--- a/git/compat.py
+++ b/git/compat.py
@@ -66,6 +66,16 @@ def safe_decode(s):
raise TypeError('Expected bytes or text, but got %r' % (s,))
+def safe_encode(s):
+ """Safely decodes a binary string to unicode"""
+ if isinstance(s, unicode):
+ return s.encode(defenc)
+ elif isinstance(s, bytes):
+ return s
+ elif s is not None:
+ raise TypeError('Expected bytes or text, but got %r' % (s,))
+
+
def with_metaclass(meta, *bases):
"""copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15"""
class metaclass(meta):
diff --git a/git/index/fun.py b/git/index/fun.py
index 0179625a..74ac929e 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -41,10 +41,13 @@ from .util import (
from gitdb.base import IStream
from gitdb.typ import str_tree_type
from git.compat import (
+ PY3,
defenc,
force_text,
force_bytes,
is_posix,
+ safe_encode,
+ safe_decode,
)
S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule
@@ -69,7 +72,7 @@ def run_commit_hook(name, index):
return
env = os.environ.copy()
- env['GIT_INDEX_FILE'] = index.path
+ env['GIT_INDEX_FILE'] = safe_decode(index.path) if PY3 else safe_encode(index.path)
env['GIT_EDITOR'] = ':'
try:
cmd = subprocess.Popen(hp,
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index eea091f8..fb5f774d 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -848,6 +848,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
# finally delete our own submodule
if not dry_run:
+ self._clear_cache()
wtd = mod.working_tree_dir
del(mod) # release file-handles (windows)
rmtree(wtd)
@@ -855,6 +856,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
# END handle force
if not dry_run and os.path.isdir(git_dir):
+ self._clear_cache()
rmtree(git_dir)
# end handle separate bare repository
# END handle module deletion
diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py
index 4b1738cd..8194547c 100644
--- a/git/test/performance/test_streams.py
+++ b/git/test/performance/test_streams.py
@@ -87,6 +87,9 @@ class TestObjDBPerformance(TestBigRepoR):
% (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / elapsed_readchunks), file=sys.stderr)
# del db file so git has something to do
+ ostream = None
+ import gc
+ gc.collect()
os.remove(db_file)
# VS. CGIT
diff --git a/git/test/test_util.py b/git/test/test_util.py
index eae9fbc7..36fb5be3 100644
--- a/git/test/test_util.py
+++ b/git/test/test_util.py
@@ -90,10 +90,11 @@ class TestUtils(TestBase):
wait_lock = BlockingLockFile(my_file, 0.05, wait_time)
self.failUnlessRaises(IOError, wait_lock._obtain_lock)
elapsed = time.time() - start
- extra_time = 0.2
+ extra_time = 0.02
if is_win:
+ # for Appveyor
extra_time *= 6 # NOTE: Indeterministic failures here...
- self.assertLess(elapsed, wait_time + 0.02)
+ self.assertLess(elapsed, wait_time + extra_time)
def test_user_id(self):
assert '@' in get_user_id()