summaryrefslogtreecommitdiff
path: root/git/index
diff options
context:
space:
mode:
Diffstat (limited to 'git/index')
-rw-r--r--git/index/__init__.py6
-rw-r--r--git/index/base.py16
-rw-r--r--git/index/fun.py9
-rw-r--r--git/index/typ.py3
4 files changed, 16 insertions, 18 deletions
diff --git a/git/index/__init__.py b/git/index/__init__.py
index 4a495c33..c5080d2e 100644
--- a/git/index/__init__.py
+++ b/git/index/__init__.py
@@ -1,4 +1,6 @@
"""Initialize the index package"""
-from base import *
-from typ import *
+from __future__ import absolute_import
+
+from .base import *
+from .typ import *
diff --git a/git/index/base.py b/git/index/base.py
index 051423bf..fdcfcd12 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -24,7 +24,6 @@ from util import (
git_working_dir
)
-import git.objects
import git.diff as diff
from git.exc import (
@@ -43,13 +42,11 @@ from git.objects import (
from git.objects.util import Serializable
from git.util import (
- IndexFileSHA1Writer,
LazyMixin,
LockedFD,
join_path_native,
file_contents_ro,
to_native_path_linux,
- to_native_path
)
from fun import (
@@ -418,9 +415,6 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
iterator. A default filter, the BlobFilter, allows you to yield blobs
only if they match a given list of paths. """
for entry in self.entries.itervalues():
- # TODO: is it necessary to convert the mode ? We did that when adding
- # it to the index, right ?
- mode = stat_mode_to_index_mode(entry.mode)
blob = entry.to_blob(self.repo)
blob.size = entry.size
output = (entry.stage, blob)
@@ -602,7 +596,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=None,
write=True):
"""Add files from the working tree, specific blobs or BaseIndexEntries
- to the index.
+ to the index.
:param items:
Multiple types of items are supported, types can be mixed within one call.
@@ -630,7 +624,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
must be a path relative to our repository.
If their sha is null ( 40*0 ), their path must exist in the file system
- relative to the git repository as an object will be created from
+ relative to the git repository as an object will be created from
the data at the path.
The handling now very much equals the way string paths are processed, except that
the mode you have set will be kept. This allows you to create symlinks
@@ -892,7 +886,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
:return:
Commit object representing the new commit"""
tree = self.write_tree()
- return Commit.create_from_tree(self.repo, tree, message, parent_commits, head, author=author, committer=committer)
+ return Commit.create_from_tree(self.repo, tree, message, parent_commits,
+ head, author=author, committer=committer)
@classmethod
def _flush_stdin_and_wait(cls, proc, ignore_stdout=False):
@@ -995,7 +990,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
if failed_files:
valid_files = list(set(iter_checked_out_files) - set(failed_files))
raise CheckoutError(
- "Some files could not be checked out from the index due to local modifications", failed_files, valid_files, failed_reasons)
+ "Some files could not be checked out from the index due to local modifications",
+ failed_files, valid_files, failed_reasons)
# END stderr handler
if paths is None:
diff --git a/git/index/fun.py b/git/index/fun.py
index 4750463c..eec90519 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -5,7 +5,6 @@ from stat import (
S_IFDIR,
S_IFLNK,
S_ISLNK,
- S_IFDIR,
S_ISDIR,
S_IFMT,
S_IFREG,
@@ -146,7 +145,7 @@ def read_cache(stream):
path = read(path_size)
real_size = ((tell() - beginoffset + 8) & ~7)
- data = read((beginoffset + real_size) - tell())
+ read((beginoffset + real_size) - tell())
entry = IndexEntry((mode, sha, flags, path, ctime, mtime, dev, ino, uid, gid, size))
# entry_key would be the method to use, but we safe the effort
entries[(path, entry.stage)] = entry
@@ -160,8 +159,8 @@ def read_cache(stream):
# 4 bytes length of chunk
# repeated 0 - N times
extension_data = stream.read(~0)
- assert len(extension_data) > 19, "Index Footer was not at least a sha on content as it was only %i bytes in size" % len(
- extension_data)
+ assert len(extension_data) > 19, "Index Footer was not at least a sha on content as it was only %i bytes in size"\
+ % len(extension_data)
content_sha = extension_data[-20:]
@@ -265,7 +264,7 @@ def aggressive_tree_merge(odb, tree_shas):
# it exists in all branches, if it was changed in both
# its a conflict, otherwise we take the changed version
# This should be the most common branch, so it comes first
- if( base[0] != ours[0] and base[0] != theirs[0] and ours[0] != theirs[0] ) or \
+ if(base[0] != ours[0] and base[0] != theirs[0] and ours[0] != theirs[0]) or \
(base[1] != ours[1] and base[1] != theirs[1] and ours[1] != theirs[1]):
# changed by both
out_append(_tree_entry_to_baseindexentry(base, 1))
diff --git a/git/index/typ.py b/git/index/typ.py
index a71fc2c6..222252c5 100644
--- a/git/index/typ.py
+++ b/git/index/typ.py
@@ -172,4 +172,5 @@ class IndexEntry(BaseIndexEntry):
def from_blob(cls, blob, stage=0):
""":return: Minimal entry resembling the given blob object"""
time = pack(">LL", 0, 0)
- return IndexEntry((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path, time, time, 0, 0, 0, 0, blob.size))
+ return IndexEntry((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path,
+ time, time, 0, 0, 0, 0, blob.size))