◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ install:
- cat git/test/fixtures/.gitconfig >> ~/.gitconfig
script:
# Make sure we limit open handles to see if we are leaking them
- ulimit -n 110
- ulimit -n
- nosetests -v --with-coverage
- if [ "$TRAVIS_PYTHON_VERSION" == '3.4' ]; then flake8; fi
Expand Down
25 changes: 19 additions & 6 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from gitdb.util import join
from git.compat import (defenc, force_text, is_win)
import logging

log = logging.getLogger('git.remote')

Expand Down Expand Up @@ -494,12 +495,24 @@ def delete_url(self, url, **kwargs):

@property
def urls(self):
""":return: Iterator yielding all configured URL targets on a remote
as strings"""
remote_details = self.repo.git.remote("show", self.name)
for line in remote_details.split('\n'):
if ' Push URL:' in line:
yield line.split(': ')[-1]

@property
def refs(self):
Expand Down
3 changes: 0 additions & 3 deletions git/test/performance/lib.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
from git.test.lib import (
TestBase
)
from gitdb.test.lib import skip_on_travis_ci
import tempfile
import logging

Expand Down Expand Up @@ -43,8 +42,6 @@ class TestBigRepoR(TestBase):
#} END invariants

def setUp(self):
# This will raise on travis, which is what we want to happen early as to prevent us to do any work
skip_on_travis_ci(lambda *args: None)(self)
try:
super(TestBigRepoR, self).setUp()
except AttributeError:
Expand Down
2 changes: 2 additions & 0 deletions git/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

import tempfile

from git.test.lib import (
TestBase,
Expand Down Expand Up @@ -80,6 +81,7 @@ def test_lock_file(self):

# auto-release on destruction
del(other_lock_file)
lock_file._obtain_lock_or_raise()
lock_file._release_lock()

Expand Down
77 changes: 68 additions & 9 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,56 @@

#{ Utility Methods


def unbare_repo(func):
"""Methods with this decorator raise InvalidGitRepositoryError if they
Expand Down Expand Up @@ -555,9 +605,10 @@ class LockFile(object):
As we are a utility class to be derived from, we only use protected methods.

Locks will automatically be released on destruction"""
__slots__ = ("_file_path", "_owns_lock")

def __init__(self, file_path):
self._file_path = file_path
self._owns_lock = False

Expand All @@ -579,20 +630,21 @@ def _obtain_lock_or_raise(self):
:raise IOError: if a lock was already present or a lock file could not be written"""
if self._has_lock():
return
lock_file = self._lock_file_path()
if os.path.isfile(lock_file):
raise IOError("Lock for file %r did already exist, delete %r in case the lock is illegal" %
(self._file_path, lock_file))

try:
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
if is_win:
flags |= os.O_SHORT_LIVED
fd = os.open(lock_file, flags, 0)
os.close(fd)
except OSError as e:
raise IOError(str(e))

self._owns_lock = True

def _obtain_lock(self):
Expand All @@ -605,14 +657,21 @@ def _release_lock(self):
if not self._has_lock():
return

# if someone removed our file beforhand, lets just flag this issue
# instead of failing, to make it more usable.
lfp = self._lock_file_path()
try:
rmfile(lfp)
except OSError:
pass
self._owns_lock = False


class BlockingLockFile(LockFile):
Expand Down Expand Up @@ -647,7 +706,7 @@ def _obtain_lock(self):
try:
super(BlockingLockFile, self)._obtain_lock()
except IOError:
# synity check: if the directory leading to the lockfile is not
# readable anymore, raise an execption
curtime = time.time()
if not os.path.isdir(os.path.dirname(self._lock_file_path())):
Toggle all file notes Toggle all file annotations