diff options
Diffstat (limited to 'git/index')
-rw-r--r-- | git/index/base.py | 72 | ||||
-rw-r--r-- | git/index/fun.py | 20 | ||||
-rw-r--r-- | git/index/typ.py | 6 | ||||
-rw-r--r-- | git/index/util.py | 6 |
4 files changed, 52 insertions, 52 deletions
diff --git a/git/index/base.py b/git/index/base.py index 870b2393..f11f4492 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -13,13 +13,13 @@ from cStringIO import StringIO from stat import S_ISLNK from typ import ( - BaseIndexEntry, - IndexEntry, + BaseIndexEntry, + IndexEntry, ) from util import ( TemporaryFileSwap, - post_clear_cache, + post_clear_cache, default_index, git_working_dir ) @@ -35,18 +35,18 @@ from git.exc import ( from git.objects import ( Blob, Submodule, - Tree, - Object, + Tree, + Object, Commit, ) from git.objects.util import Serializable from git.util import ( - IndexFileSHA1Writer, - LazyMixin, - LockedFD, - join_path_native, + IndexFileSHA1Writer, + LazyMixin, + LockedFD, + join_path_native, file_contents_ro, to_native_path_linux, to_native_path @@ -58,7 +58,7 @@ from fun import ( read_cache, aggressive_tree_merge, write_tree_from_cache, - stat_mode_to_index_mode, + stat_mode_to_index_mode, S_IFGITLINK ) @@ -121,12 +121,12 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): return # END exception handling - # Here it comes: on windows in python 2.5, memory maps aren't closed properly - # Hence we are in trouble if we try to delete a file that is memory mapped, + # Here it comes: on windows in python 2.5, memory maps aren't closed properly + # Hence we are in trouble if we try to delete a file that is memory mapped, # which happens during read-tree. # In this case, we will just read the memory in directly. # Its insanely bad ... I am disappointed ! - allow_mmap = (os.name != 'nt' or sys.version_info[1] > 5) + allow_mmap = (os.name != 'nt' or sys.version_info[1] > 5) stream = file_contents_ro(fd, stream=True, allow_mmap=allow_mmap) try: @@ -155,7 +155,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): pass # END exception handling - #{ Serializable Interface + #{ Serializable Interface def _deserialize(self, stream): """Initialize this instance with index values read from the given stream""" @@ -172,7 +172,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): entries = self._entries_sorted() write_cache(entries, stream, - (ignore_tree_extension_data and None) or self._extension_data) + (ignore_tree_extension_data and None) or self._extension_data) return self #} END serializable interface @@ -198,7 +198,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): :return: self""" # make sure we have our entries read before getting a write lock - # else it would be done when streaming. This can happen + # else it would be done when streaming. This can happen # if one doesn't change the index, but writes it right away self.entries lfd = LockedFD(file_path or self._file_path) @@ -257,17 +257,17 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): :param repo: The repository treeish are located in. :param tree_sha: - 20 byte or 40 byte tree sha or tree objects + 20 byte or 40 byte tree sha or tree objects :return: - New IndexFile instance. Its path will be undefined. - If you intend to write such a merged Index, supply an alternate file_path + New IndexFile instance. Its path will be undefined. + If you intend to write such a merged Index, supply an alternate file_path to its 'write' method.""" base_entries = aggressive_tree_merge(repo.odb, [to_bin_sha(str(t)) for t in tree_sha]) inst = cls(repo) # convert to entries dict - entries = dict(izip(((e.path, e.stage) for e in base_entries), + entries = dict(izip(((e.path, e.stage) for e in base_entries), (IndexEntry.from_base(e) for e in base_entries))) inst.entries = entries @@ -379,7 +379,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # END path exception handling # END for each path - def _write_path_to_stdin(self, proc, filepath, item, fmakeexc, fprogress, + def _write_path_to_stdin(self, proc, filepath, item, fmakeexc, fprogress, read_from_stdout=True): """Write path to proc.stdin and make sure it processes the item, including progress. @@ -418,7 +418,7 @@ 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 + # 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) @@ -504,7 +504,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): object database and return it. :return: Tree object representing this index - :note: The tree will be written even if one or more objects the tree refers to + :note: The tree will be written even if one or more objects the tree refers to does not yet exist in the object database. This could happen if you added Entries to the index directly. :raise ValueError: if there are no entries in the cache @@ -560,10 +560,10 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): return (paths, entries) @git_working_dir - def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=None, + 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. @@ -591,7 +591,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 @@ -654,8 +654,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): for path in paths: abspath = os.path.abspath(path) gitrelative_path = abspath[len(self.repo.working_tree_dir) + 1:] - blob = Blob(self.repo, Blob.NULL_BIN_SHA, - stat_mode_to_index_mode(os.stat(abspath).st_mode), + blob = Blob(self.repo, Blob.NULL_BIN_SHA, + stat_mode_to_index_mode(os.stat(abspath).st_mode), to_native_path_linux(gitrelative_path)) entries.append(BaseIndexEntry.from_blob(blob)) # END for each path @@ -674,7 +674,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): fprogress(filepath, False, filepath) istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream)) fprogress(filepath, True, filepath) - return BaseIndexEntry((stat_mode_to_index_mode(st.st_mode), + return BaseIndexEntry((stat_mode_to_index_mode(st.st_mode), istream.binsha, 0, to_native_path_linux(filepath))) # END utility method @@ -929,10 +929,10 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): Raise GitCommandError if error lines could not be parsed - this truly is an exceptional state - .. note:: The checkout is limited to checking out the files in the - index. Files which are not in the index anymore and exist in + .. note:: The checkout is limited to checking out the files in the + index. Files which are not in the index anymore and exist in the working tree will not be deleted. This behaviour is fundamentally - different to *head.checkout*, i.e. if you want git-checkout like behaviour, + different to *head.checkout*, i.e. if you want git-checkout like behaviour, use head.checkout instead of index.checkout. """ args = ["--index"] @@ -998,7 +998,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): paths = [paths] # make sure we have our entries loaded before we start checkout_index - # which will hold a lock on it. We try to get the lock as well during + # which will hold a lock on it. We try to get the lock as well during # our entries initialization self.entries @@ -1023,7 +1023,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): for entry in self.entries.itervalues(): if entry.path.startswith(dir): p = entry.path - self._write_path_to_stdin(proc, p, p, make_exc, + self._write_path_to_stdin(proc, p, p, make_exc, fprogress, read_from_stdout=False) checked_out_files.append(p) path_is_directory = True @@ -1032,7 +1032,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # END path exception handlnig if not path_is_directory: - self._write_path_to_stdin(proc, co_path, path, make_exc, + self._write_path_to_stdin(proc, co_path, path, make_exc, fprogress, read_from_stdout=False) checked_out_files.append(co_path) # END path is a file @@ -1066,7 +1066,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): :param paths: if given as an iterable of absolute or repository-relative paths, only these will be reset to their state at the given commit'ish. - The paths need to exist at the commit, otherwise an exception will be + The paths need to exist at the commit, otherwise an exception will be raised. :param kwargs: diff --git a/git/index/fun.py b/git/index/fun.py index aea7e50f..cf55064e 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -26,20 +26,20 @@ from git.objects.fun import ( from typ import ( BaseIndexEntry, IndexEntry, - CE_NAMEMASK, + CE_NAMEMASK, CE_STAGESHIFT ) CE_NAMEMASK_INV = ~CE_NAMEMASK from util import ( - pack, + pack, unpack ) from gitdb.base import IStream from gitdb.typ import str_tree_type -__all__ = ('write_cache', 'read_cache', 'write_tree_from_cache', 'entry_key', +__all__ = ('write_cache', 'read_cache', 'write_tree_from_cache', 'entry_key', 'stat_mode_to_index_mode', 'S_IFGITLINK') @@ -178,7 +178,7 @@ def write_tree_from_cache(entries, odb, sl, si=0): :param odb: object database to store the trees in :param si: start index at which we should start creating subtrees :param sl: slice indicating the range we should process on the entries list - :return: tuple(binsha, list(tree_entry, ...)) a tuple of a sha and a list of + :return: tuple(binsha, list(tree_entry, ...)) a tuple of a sha and a list of tree entries being a tuple of hexsha, mode, name""" tree_items = list() tree_items_append = tree_items.append @@ -214,7 +214,7 @@ def write_tree_from_cache(entries, odb, sl, si=0): # skip ahead ci = xi - # END handle bounds + # END handle bounds # END for each entry # finally create the tree @@ -233,8 +233,8 @@ def _tree_entry_to_baseindexentry(tree_entry, stage): def aggressive_tree_merge(odb, tree_shas): """ :return: list of BaseIndexEntries representing the aggressive merge of the given - trees. All valid entries are on stage 0, whereas the conflicting ones are left - on stage 1, 2 or 3, whereas stage 1 corresponds to the common ancestor tree, + trees. All valid entries are on stage 0, whereas the conflicting ones are left + on stage 1, 2 or 3, whereas stage 1 corresponds to the common ancestor tree, 2 to our tree and 3 to 'their' tree. :param tree_shas: 1, 2 or 3 trees as identified by their binary 20 byte shas If 1 or two, the entries will effectively correspond to the last given tree @@ -249,7 +249,7 @@ def aggressive_tree_merge(odb, tree_shas): out_append(_tree_entry_to_baseindexentry(entry, 0)) # END for each entry return out - # END handle single tree + # END handle single tree if len(tree_shas) > 3: raise ValueError("Cannot handle %i trees at once" % len(tree_shas)) @@ -277,11 +277,11 @@ def aggressive_tree_merge(odb, tree_shas): # either nobody changed it, or they did. In either # case, use theirs out_append(_tree_entry_to_baseindexentry(theirs, 0)) - # END handle modification + # END handle modification else: if ours[0] != base[0] or ours[1] != base[1]: - # they deleted it, we changed it, conflict + # they deleted it, we changed it, conflict out_append(_tree_entry_to_baseindexentry(base, 1)) out_append(_tree_entry_to_baseindexentry(ours, 2)) # else: diff --git a/git/index/typ.py b/git/index/typ.py index 8cc076a5..4a6f6a81 100644 --- a/git/index/typ.py +++ b/git/index/typ.py @@ -1,7 +1,7 @@ """Module with additional types used by the index""" from util import ( - pack, + pack, unpack ) @@ -108,7 +108,7 @@ class BaseIndexEntry(tuple): def to_blob(self, repo): """:return: Blob using the information of this index entry""" - return Blob(repo, self.binsha, self.mode, self.path) + return Blob(repo, self.binsha, self.mode, self.path) class IndexEntry(BaseIndexEntry): @@ -159,7 +159,7 @@ class IndexEntry(BaseIndexEntry): @classmethod def from_base(cls, base): - """ + """ :return: Minimal entry as created from the given BaseIndexEntry instance. Missing values will be set to null-like values diff --git a/git/index/util.py b/git/index/util.py index 498c0513..064a22ce 100644 --- a/git/index/util.py +++ b/git/index/util.py @@ -5,7 +5,7 @@ import os __all__ = ('TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir') -#{ Aliases +#{ Aliases pack = struct.pack unpack = struct.unpack @@ -35,7 +35,7 @@ class TemporaryFileSwap(object): # END temp file exists -#{ Decorators +#{ Decorators def post_clear_cache(func): """Decorator for functions that alter the index using the git command. This would @@ -73,7 +73,7 @@ def default_index(func): def git_working_dir(func): - """Decorator which changes the current working dir to the one of the git + """Decorator which changes the current working dir to the one of the git repository in order to assure relative paths are handled correctly""" def set_git_working_dir(self, *args, **kwargs): |