diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-06 11:11:04 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-06 11:11:04 +0100 |
commit | a4d06724202afccd2b5c54f81bcf2bf26dea7fff (patch) | |
tree | b503ccd4b1ba0ee13e6a0311a9f6fae78011754f /lib/git/index.py | |
parent | 453995f70f93c0071c5f7534f58864414f01cfde (diff) | |
parent | 4114d19e2c02f3ffca9feb07b40d9475f36604cc (diff) | |
download | gitpython-a4d06724202afccd2b5c54f81bcf2bf26dea7fff.tar.gz |
Merge branch 'win_fixes'
* win_fixes:
Fixed commit.count method which now handles the paths case properly. It appears git-rev-list uses empty paths in some way, which is quite hard to specify on a shell, but easy if the process is spawned directly
test_remote: fixed test which assumed existance of local master tracking branch, it will now create it if necessary
Index tests adopted to windows - especially the symlink test needed adjustment, but it works as expected even on systems that do not support symlinks
ARGH: wb and rb is not the same as r and w on windows, hence reading of binary files went crazy as well as binary writing
test_commit: commit.count actually returned incorrect values on linux, namely 141 instead of 143. Manual checking showed that 143 is the correct number, on linux this will have to be fixed
helper: repo creation functions now handle errors on windows during os.remove by changing the mode to 777 and delete the file again. Otherwise the whole operation would fail on read-only files. Why is windows as it is ? Why does it do that to me ?
removed large-input test as it is totally dependent on the subprocess implementation in the end whether pipeing large input works. In general , input and output pipes are used, the shell is bypassed, hence there is no reason for a problem unless we are on a very rare platform. And if so, we can't do anything about it so why should there be a possibly failing test ? Problem is that the test would fail on windows in case it is not installed on c:\windows
repo.clone: Added plenty of special handling to allow drive letters to work as expected. Its quite terrible to see a two-line method inflate to 20
Fixed config module which forgot to call the superclass's initializer, finally causing failure in python 2.6
fixed test_repo to work on windows
cmd: added clear_cache method now used by test repo decorators to be sure persistent commands are killed before trying to remove the directory. Unfortunately, it still claims someone has opened the file. handle.exe does not show anyone, so what is happening here ? Is it just a windows odity ? If nothing helps I could just keep the temp data, but lets do some more testing first
git cmd on windows now runs without the shell, see diff for explanation
Fixed windows TASKKILL so it actually does something *silently*
Added utilities helping to create proper paths either with slashes or backslashes depending on the operating system
Diffstat (limited to 'lib/git/index.py')
-rw-r--r-- | lib/git/index.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/git/index.py b/lib/git/index.py index e368f531..45bf617f 100644 --- a/lib/git/index.py +++ b/lib/git/index.py @@ -19,7 +19,7 @@ import subprocess import git.diff as diff from git.objects import Blob, Tree, Object, Commit -from git.utils import SHA1Writer, LazyMixin, ConcurrentWriteOperation +from git.utils import SHA1Writer, LazyMixin, ConcurrentWriteOperation, join_path_native class _TemporaryFileSwap(object): @@ -36,7 +36,7 @@ class _TemporaryFileSwap(object): def __del__(self): if os.path.isfile(self.tmp_file_path): - if sys.platform == "win32" and os.path.exists(self.file_path): + if os.name == 'nt' and os.path.exists(self.file_path): os.remove(self.file_path) os.rename(self.tmp_file_path, self.file_path) # END temp file exists @@ -243,9 +243,10 @@ class IndexFile(LazyMixin, diff.Diffable): if attr == "entries": # read the current index # try memory map for speed - fp = open(self._file_path, "r") + fp = open(self._file_path, "rb") stream = fp try: + raise Exception() stream = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ) except Exception: pass @@ -254,13 +255,18 @@ class IndexFile(LazyMixin, diff.Diffable): try: self._read_from_stream(stream) finally: - fp.close() + pass + # make sure we close the stream ( possibly an mmap ) + # and the file + #stream.close() + #if stream is not fp: + # fp.close() # END read from default index on demand else: super(IndexFile, self)._set_cache_(attr) def _index_path(self): - return os.path.join(self.repo.path, "index") + return join_path_native(self.repo.path, "index") @property @@ -440,7 +446,7 @@ class IndexFile(LazyMixin, diff.Diffable): # as it considers existing entries. moving it essentially clears the index. # Unfortunately there is no 'soft' way to do it. # The _TemporaryFileSwap assure the original file get put back - index_handler = _TemporaryFileSwap(os.path.join(repo.path, 'index')) + index_handler = _TemporaryFileSwap(join_path_native(repo.path, 'index')) try: repo.git.read_tree(*arg_list, **kwargs) index = cls(repo, tmp_index) @@ -603,7 +609,7 @@ class IndexFile(LazyMixin, diff.Diffable): """ if not os.path.isabs(path): return path - relative_path = path.replace(self.repo.git.git_dir+"/", "") + relative_path = path.replace(self.repo.git.git_dir+os.sep, "") if relative_path == path: raise ValueError("Absolute path %r is not in git repository at %r" % (path,self.repo.git.git_dir)) return relative_path @@ -839,10 +845,10 @@ class IndexFile(LazyMixin, diff.Diffable): # create message stream tmp_file_path = tempfile.mktemp() - fp = open(tmp_file_path,"w") + fp = open(tmp_file_path,"wb") fp.write(str(message)) fp.close() - fp = open(tmp_file_path,"r") + fp = open(tmp_file_path,"rb") fp.seek(0) try: |