Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improved way of listing URLs in remote#528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
547e6f0
Replaced lock file code with flock()
expobrainSep 12, 2016
6dfc870
No need to create the lock file beforehand
expobrainSep 14, 2016
1e4eff1
Ignore cache dir of Py.test
expobrainSep 14, 2016
ae19557
Updated AUTHORS
expobrainSep 14, 2016
f0fcc07
Force GC collection
expobrainSep 19, 2016
26f9b9f
Merge remote-tracking branch 'upstream/master'
expobrainOct 6, 2016
d437f88
Fixed typo after merge
expobrainOct 6, 2016
ab7a872
Updated file locking for Windows platform
expobrainOct 7, 2016
c0b45fa
Updated setup to include Windows requirements
expobrainOct 7, 2016
4c9dd7f
Forgot to uncomment conditional import
expobrainOct 7, 2016
20b4f49
Fix syntax for Python 3.x
expobrainOct 7, 2016
ac9ac55
Merge pull request #513 from expobrain/master
ByronOct 9, 2016
e118818
imp(performance): execute performance tests on travis
ByronOct 10, 2016
9557508
fix(travis): increase ulimit
Oct 10, 2016
7642479
Improved way of listing URLs in remote
guyzmoOct 11, 2016
282824d
Updated AUTHORS file
guyzmoOct 12, 2016
32ca686
remote, #528: fix prev cmt, Git<2.7 miss `get-url`
ankostisOct 11, 2016
621c5e7
Fixed shadowing of potential exceptions.
guyzmoOct 12, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,3 +14,4 @@ nbproject
.DS_Store
/*egg-info
/.tox
.cache
2 changes: 1 addition & 1 deletion.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff 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 -n110
-ulimit -n128
-ulimit -n
-nosetests -v --with-coverage
-if [ "$TRAVIS_PYTHON_VERSION" == '3.4' ]; then flake8; fi
Expand Down
2 changes: 2 additions & 0 deletionsAUTHORS
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,5 +15,7 @@ Contributors are:
-Jonathan Chu <jonathan.chu _at_ me.com>
-Vincent Driessen <me _at_ nvie.com>
-Phil Elson <pelson _dot_ pub _at_ gmail.com>
-Daniele Esposti <daniele.esposti _at_ gmail.com>
-Bernard `Guyzmo` Pratz <guyzmo+gitpython+pub@m0g.net>

Portions derived from other open source works and are clearly marked.
25 changes: 19 additions & 6 deletionsgit/remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,6 +33,7 @@
from gitdb.util import join
from git.compat import (defenc, force_text, is_win)
import logging
from git.exc import GitCommandError

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

Expand DownExpand 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]
""":return: Iterator yielding all configured URL targets on a remote as strings"""
try:
remote_details = self.repo.git.remote("get-url", "--all", self.name)
for line in remote_details.split('\n'):
yield line
except GitCommandError as ex:
## We are on git < 2.7 (i.e TravisCI as of Oct-2016),
# so `get-utl` command does not exist yet!
# see: https://github.com/gitpython-developers/GitPython/pull/528#issuecomment-252976319
# and: http://stackoverflow.com/a/32991784/548792
#
if 'Unknown subcommand: get-url' in str(ex):
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]
else:
raise ex

@property
def refs(self):
Expand Down
3 changes: 0 additions & 3 deletionsgit/test/performance/lib.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
from git.test.lib import (
TestBase
)
from gitdb.test.lib import skip_on_travis_ci
import tempfile
import logging

Expand DownExpand 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 deletionsgit/test/test_util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

import tempfile
import gc

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

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

Expand Down
77 changes: 68 additions & 9 deletionsgit/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,56 @@

#{ Utility Methods

if platform.system() == 'Windows':
# This code is a derivative work of Portalocker http://code.activestate.com/recipes/65203/
import win32con
import win32file
import pywintypes

LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK
LOCK_SH = 0 # the default
LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY
LOCK_UN = 1 << 2

__overlapped = pywintypes.OVERLAPPED()

def flock(fd, flags=0):
hfile = win32file._get_osfhandle(fd)

if flags & LOCK_UN != 0:
# Unlock file descriptor
try:
win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)
except pywintypes.error as exc_value:
# error: (158, 'UnlockFileEx', 'The segment is already unlocked.')
# To match the 'posix' implementation, silently ignore this error
if exc_value[0] == 158:
pass
else:
# Q: Are there exceptions/codes we should be dealing with here?
raise

elif flags & LOCK_EX != 0:
# Lock file
try:
win32file.LockFileEx(hfile, flags, 0, -0x10000, __overlapped)
except pywintypes.error as exc_value:
if exc_value[0] == 33:
# error: (33, 'LockFileEx',
# 'The process cannot access the file because another process has locked
# a portion of the file.')
raise IOError(33, exc_value[2])
else:
# Q: Are there exceptions/codes we should be dealing with here?
raise

else:
raise NotImplementedError("Unsupported set of bitflags {}".format(bin(flags)))


else:
from fcntl import flock, LOCK_UN, LOCK_EX, LOCK_NB


def unbare_repo(func):
"""Methods with this decorator raise InvalidGitRepositoryError if they
Expand DownExpand 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")
__slots__ = ("_file_path", "_owns_lock", "_file_descriptor")

def __init__(self, file_path):
self._file_descriptor = None
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))

# Create file and lock
try:
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
flags = os.O_CREAT
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))

flock(fd, LOCK_EX | LOCK_NB)

self._file_descriptor = fd
self._owns_lock = True

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

fd = self._file_descriptor
lock_file = self._lock_file_path()

flock(fd, LOCK_UN)
os.close(fd)

# 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)
rmfile(lock_file)
except OSError:
pass

self._owns_lock = False
self._file_descriptor = None


class BlockingLockFile(LockFile):
Expand DownExpand 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
#sanity 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())):
Expand Down
7 changes: 7 additions & 0 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,7 @@
import logging
import os
import sys
import platform
from os import path

with open(path.join(path.dirname(__file__), 'VERSION')) as v:
Expand All@@ -21,6 +22,10 @@
with open('requirements.txt') as reqs_file:
requirements = reqs_file.read().splitlines()

if platform.system() == 'Windows':
with open('win32-requirements.txt') as reqs_file:
requirements += reqs_file.read().splitlines()


class build_py(_build_py):

Expand DownExpand Up@@ -65,6 +70,8 @@ def _stamp_version(filename):
print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)

install_requires = ['gitdb >= 0.6.4']
if platform.system() == 'Windows':
install_requires.append("pypiwin32 >= 219")
extras_require = {
':python_version == "2.6"': ['ordereddict'],
}
Expand Down
2 changes: 2 additions & 0 deletionswin32-requirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
-r requirements.txt
pypiwin32 >= 219

[8]ページ先頭

©2009-2025 Movatter.jp