diff options
Diffstat (limited to 'git/index')
-rw-r--r-- | git/index/base.py | 38 | ||||
-rw-r--r-- | git/index/fun.py | 6 | ||||
-rw-r--r-- | git/index/typ.py | 4 | ||||
-rw-r--r-- | git/index/util.py | 6 |
4 files changed, 27 insertions, 27 deletions
diff --git a/git/index/base.py b/git/index/base.py index 601f1c0e..197056b3 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -67,7 +67,7 @@ from gitdb.db import MemoryDB from gitdb.util import to_bin_sha from itertools import izip -__all__ = ( 'IndexFile', 'CheckoutError' ) +__all__ = ('IndexFile', 'CheckoutError') class IndexFile(LazyMixin, diff.Diffable, Serializable): @@ -177,7 +177,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): #} END serializable interface - def write(self, file_path = None, ignore_tree_extension_data=False): + def write(self, file_path=None, ignore_tree_extension_data=False): """Write the current state to our file path or to the given one :param file_path: @@ -322,7 +322,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # tmp file created in git home directory to be sure renaming # works - /tmp/ dirs could be on another device - tmp_index = tempfile.mktemp('','',repo.git_dir) + tmp_index = tempfile.mktemp('', '', repo.git_dir) arg_list.append("--index-output=%s" % tmp_index) arg_list.extend(treeish) @@ -409,7 +409,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): fprogress(filepath, True, item) return rval - def iter_blobs(self, predicate = lambda t: True): + def iter_blobs(self, predicate=lambda t: True): """ :return: Iterator yielding tuples of Blob objects and stages, tuple(stage, Blob) @@ -471,13 +471,13 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): for blob in iter_blobs: stage_null_key = (blob.path, 0) if stage_null_key in self.entries: - raise ValueError( "Path %r already exists at stage 0" % blob.path ) + raise ValueError("Path %r already exists at stage 0" % blob.path) # END assert blob is not stage 0 already # delete all possible stages for stage in (1, 2, 3): try: - del( self.entries[(blob.path, stage)]) + del(self.entries[(blob.path, stage)]) except KeyError: pass # END ignore key errors @@ -537,9 +537,9 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): if it is not within our git direcotory""" if not os.path.isabs(path): return path - relative_path = path.replace(self.repo.working_tree_dir+os.sep, "") + relative_path = path.replace(self.repo.working_tree_dir + os.sep, "") if relative_path == path: - raise ValueError("Absolute path %r is not in git repository at %r" % (path,self.repo.working_tree_dir)) + raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir)) return relative_path def _preprocess_add_items(self, items): @@ -653,7 +653,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): if paths and path_rewriter: for path in paths: abspath = os.path.abspath(path) - gitrelative_path = abspath[len(self.repo.working_tree_dir)+1:] + 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), to_native_path_linux(gitrelative_path)) @@ -689,14 +689,14 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # HANDLE ENTRIES if entries: - null_mode_entries = [ e for e in entries if e.mode == 0 ] + null_mode_entries = [e for e in entries if e.mode == 0] if null_mode_entries: raise ValueError("At least one Entry has a null-mode - please use index.remove to remove files for clarity") # END null mode should be remove # HANLDE ENTRY OBJECT CREATION # create objects if required, otherwise go with the existing shas - null_entries_indices = [ i for i,e in enumerate(entries) if e.binsha == Object.NULL_BIN_SHA ] + null_entries_indices = [i for i, e in enumerate(entries) if e.binsha == Object.NULL_BIN_SHA] if null_entries_indices: for ei in null_entries_indices: null_entry = entries[ei] @@ -711,7 +711,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # If we have to rewrite the entries, do so now, after we have generated # all object sha's if path_rewriter: - for i,e in enumerate(entries): + for i, e in enumerate(entries): entries[i] = BaseIndexEntry((e.mode, e.binsha, e.stage, path_rewriter(e))) # END for each entry # END handle path rewriting @@ -743,7 +743,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): may be absolute or relative paths, entries or blobs""" paths = list() for item in items: - if isinstance(item, (BaseIndexEntry,(Blob, Submodule))): + if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): paths.append(self._to_relative_path(item.path)) elif isinstance(item, basestring): paths.append(self._to_relative_path(item)) @@ -801,7 +801,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # process output to gain proper paths # rm 'path' - return [ p[4:-1] for p in removed_paths ] + return [p[4:-1] for p in removed_paths] @post_clear_cache @default_index @@ -847,7 +847,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # parse result - first 0:n/2 lines are 'checking ', the remaining ones # are the 'renaming' ones which we parse - for ln in xrange(len(mvlines)/2, len(mvlines)): + for ln in xrange(len(mvlines) / 2, len(mvlines)): tokens = mvlines[ln].split(' to ') assert len(tokens) == 2, "Too many tokens in %s" % mvlines[ln] @@ -881,7 +881,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): return Commit.create_from_tree(self.repo, tree, message, parent_commits, head) @classmethod - def _flush_stdin_and_wait(cls, proc, ignore_stdout = False): + def _flush_stdin_and_wait(cls, proc, ignore_stdout=False): proc.stdin.flush() proc.stdin.close() stdout = '' @@ -990,7 +990,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): proc = self.repo.git.checkout_index(*args, **kwargs) proc.wait() fprogress(None, True, None) - rval_iter = ( e.path for e in self.entries.itervalues() ) + rval_iter = (e.path for e in self.entries.itervalues()) handle_stderr(proc, rval_iter) return rval_iter else: @@ -1006,7 +1006,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): kwargs['as_process'] = True kwargs['istream'] = subprocess.PIPE proc = self.repo.git.checkout_index(args, **kwargs) - make_exc = lambda : GitCommandError(("git-checkout-index",)+tuple(args), 128, proc.stderr.read()) + make_exc = lambda: GitCommandError(("git-checkout-index",) + tuple(args), 128, proc.stderr.read()) checked_out_files = list() for path in paths: @@ -1143,7 +1143,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # if other is not None here, something is wrong if other is not None: - raise ValueError( "other must be None, Diffable.Index, a Tree or Commit, was %r" % other ) + raise ValueError("other must be None, Diffable.Index, a Tree or Commit, was %r" % other) # diff against working copy - can be handled by superclass natively return super(IndexFile, self).diff(other, paths, create_patch, **kwargs) diff --git a/git/index/fun.py b/git/index/fun.py index 2fb09675..aea7e50f 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -209,7 +209,7 @@ def write_tree_from_cache(entries, odb, sl, si=0): # enter recursion # ci - 1 as we want to count our current item as well - sha, tree_entry_list = write_tree_from_cache(entries, odb, slice(ci-1, xi), rbound+1) + sha, tree_entry_list = write_tree_from_cache(entries, odb, slice(ci - 1, xi), rbound + 1) tree_items_append((sha, S_IFDIR, base)) # skip ahead @@ -244,7 +244,7 @@ def aggressive_tree_merge(odb, tree_shas): # one and two way is the same for us, as we don't have to handle an existing # index, instrea - if len(tree_shas) in (1,2): + if len(tree_shas) in (1, 2): for entry in traverse_tree_recursive(odb, tree_shas[-1], ''): out_append(_tree_entry_to_baseindexentry(entry, 0)) # END for each entry @@ -265,7 +265,7 @@ def aggressive_tree_merge(odb, tree_shas): # 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 \ - ( base[1] != ours[1] and base[1] != theirs[1] and ours[1] != theirs[1] ): + (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)) out_append(_tree_entry_to_baseindexentry(ours, 2)) diff --git a/git/index/typ.py b/git/index/typ.py index 2dd82b62..8cc076a5 100644 --- a/git/index/typ.py +++ b/git/index/typ.py @@ -102,7 +102,7 @@ class BaseIndexEntry(tuple): return self[2] @classmethod - def from_blob(cls, blob, stage = 0): + def from_blob(cls, blob, stage=0): """:return: Fully equipped BaseIndexEntry at the given stage""" return cls((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path)) @@ -169,7 +169,7 @@ class IndexEntry(BaseIndexEntry): return IndexEntry((base.mode, base.binsha, base.flags, base.path, time, time, 0, 0, 0, 0, 0)) @classmethod - def from_blob(cls, blob, stage = 0): + 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)) diff --git a/git/index/util.py b/git/index/util.py index 289a3cb1..498c0513 100644 --- a/git/index/util.py +++ b/git/index/util.py @@ -3,7 +3,7 @@ import struct import tempfile import os -__all__ = ( 'TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir' ) +__all__ = ('TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir') #{ Aliases pack = struct.pack @@ -20,7 +20,7 @@ class TemporaryFileSwap(object): def __init__(self, file_path): self.file_path = file_path - self.tmp_file_path = self.file_path + tempfile.mktemp('','','') + self.tmp_file_path = self.file_path + tempfile.mktemp('', '', '') # it may be that the source does not exist try: os.rename(self.file_path, self.tmp_file_path) @@ -64,7 +64,7 @@ def default_index(func): def check_default_index(self, *args, **kwargs): if self._file_path != self._index_path(): - raise AssertionError( "Cannot call %r on indices that do not represent the default git index" % func.__name__ ) + raise AssertionError("Cannot call %r on indices that do not represent the default git index" % func.__name__) return func(self, *args, **kwargs) # END wrpaper method |