diff options
Diffstat (limited to 'git/objects')
-rw-r--r-- | git/objects/__init__.py | 2 | ||||
-rw-r--r-- | git/objects/base.py | 13 | ||||
-rw-r--r-- | git/objects/commit.py | 55 | ||||
-rw-r--r-- | git/objects/fun.py | 5 | ||||
-rw-r--r-- | git/objects/submodule/base.py | 118 | ||||
-rw-r--r-- | git/objects/submodule/root.py | 97 | ||||
-rw-r--r-- | git/objects/submodule/util.py | 6 | ||||
-rw-r--r-- | git/objects/tag.py | 8 | ||||
-rw-r--r-- | git/objects/tree.py | 24 | ||||
-rw-r--r-- | git/objects/util.py | 20 |
10 files changed, 185 insertions, 163 deletions
diff --git a/git/objects/__init__.py b/git/objects/__init__.py index 088dd699..0b40934c 100644 --- a/git/objects/__init__.py +++ b/git/objects/__init__.py @@ -18,4 +18,4 @@ from commit import * from tree import * __all__ = [name for name, obj in locals().items() - if not (name.startswith('_') or inspect.ismodule(obj))] + if not (name.startswith('_') or inspect.ismodule(obj))] diff --git a/git/objects/base.py b/git/objects/base.py index 0fcd25d6..50647a3a 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -6,10 +6,10 @@ from git.util import LazyMixin, join_path_native, stream_copy from util import get_object_type_by_name from gitdb.util import ( - hex_to_bin, - bin_to_hex, - basename - ) + hex_to_bin, + bin_to_hex, + basename +) import gitdb.typ as dbtyp @@ -62,7 +62,7 @@ class Object(LazyMixin): if sha1 == cls.NULL_BIN_SHA: # the NULL binsha is always the root commit return get_object_type_by_name('commit')(repo, sha1) - #END handle special case + # END handle special case oinfo = repo.odb.info(sha1) inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha) inst.size = oinfo.size @@ -157,7 +157,8 @@ class IndexObject(Object): def _set_cache_(self, attr): if attr in IndexObject.__slots__: # they cannot be retrieved lateron ( not without searching for them ) - raise AttributeError("path and mode attributes must have been set during %s object creation" % type(self).__name__) + raise AttributeError( + "path and mode attributes must have been set during %s object creation" % type(self).__name__) else: super(IndexObject, self)._set_cache_(attr) # END hanlde slot attribute diff --git a/git/objects/commit.py b/git/objects/commit.py index 453afe66..c6adcc94 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -5,11 +5,11 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php from git.util import ( - Actor, - Iterable, - Stats, - finalize_process - ) + Actor, + Iterable, + Stats, + finalize_process +) from git.diff import Diffable from tree import Tree from gitdb import IStream @@ -17,19 +17,19 @@ from cStringIO import StringIO import base from gitdb.util import ( - hex_to_bin - ) + hex_to_bin +) from util import ( - Traversable, - Serializable, - parse_date, - altz_to_utctz_str, - parse_actor_and_date - ) + Traversable, + Serializable, + parse_date, + altz_to_utctz_str, + parse_actor_and_date +) from time import ( - time, - altzone - ) + time, + altzone +) import os import sys @@ -339,9 +339,9 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): # CREATE NEW COMMIT new_commit = cls(repo, cls.NULL_BIN_SHA, tree, - author, author_time, author_offset, - committer, committer_time, committer_offset, - message, parent_commits, conf_encoding) + author, author_time, author_offset, + committer, committer_time, committer_offset, + message, parent_commits, conf_encoding) stream = StringIO() new_commit._serialize(stream) @@ -384,8 +384,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): c = self.committer fmt = "%s %s <%s> %s %s\n" write(fmt % ("author", aname, a.email, - self.authored_date, - altz_to_utctz_str(self.author_tz_offset))) + self.authored_date, + altz_to_utctz_str(self.author_tz_offset))) # encode committer aname = c.name @@ -393,8 +393,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): aname = aname.encode(self.encoding) # END handle unicode in name write(fmt % ("committer", aname, c.email, - self.committed_date, - altz_to_utctz_str(self.committer_tz_offset))) + self.committed_date, + altz_to_utctz_str(self.committer_tz_offset))) if self.encoding != self.default_encoding: write("encoding %s\n" % self.encoding) @@ -457,7 +457,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): is_next_header = False while True: sigbuf = readline() - if sigbuf == "": break + if sigbuf == "": + break if sigbuf[0:1] != " ": buf = sigbuf.strip() is_next_header = True @@ -472,14 +473,16 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): try: self.author.name = self.author.name.decode(self.encoding) except UnicodeDecodeError: - print >> sys.stderr, "Failed to decode author name '%s' using encoding %s" % (self.author.name, self.encoding) + print >> sys.stderr, "Failed to decode author name '%s' using encoding %s" % ( + self.author.name, self.encoding) # END handle author's encoding # decode committer name try: self.committer.name = self.committer.name.decode(self.encoding) except UnicodeDecodeError: - print >> sys.stderr, "Failed to decode committer name '%s' using encoding %s" % (self.committer.name, self.encoding) + print >> sys.stderr, "Failed to decode committer name '%s' using encoding %s" % ( + self.committer.name, self.encoding) # END handle author's encoding # a stream from our data simply gives us the plain message diff --git a/git/objects/fun.py b/git/objects/fun.py index 21b89fca..416a52e6 100644 --- a/git/objects/fun.py +++ b/git/objects/fun.py @@ -2,7 +2,7 @@ from stat import S_ISDIR __all__ = ('tree_to_stream', 'tree_entries_from_data', 'traverse_trees_recursive', - 'traverse_tree_recursive') + 'traverse_tree_recursive') def tree_to_stream(entries, write): @@ -167,7 +167,8 @@ def traverse_trees_recursive(odb, tree_shas, path_prefix): # if we are a directory, enter recursion if is_dir: - out.extend(traverse_trees_recursive(odb, [((ei and ei[0]) or None) for ei in entries], path_prefix + name + '/')) + out.extend(traverse_trees_recursive( + odb, [((ei and ei[0]) or None) for ei in entries], path_prefix + name + '/')) else: out_append(tuple(_to_full_path(e, path_prefix) for e in entries)) # END handle recursion diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 14e1c930..e3d58077 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -1,27 +1,27 @@ import util from util import ( - mkhead, - sm_name, - sm_section, - unbare_repo, - SubmoduleConfigParser, - find_first_remote_branch - ) + mkhead, + sm_name, + sm_section, + unbare_repo, + SubmoduleConfigParser, + find_first_remote_branch +) from git.objects.util import Traversable from StringIO import StringIO # need a dict to set bloody .name field from git.util import ( - Iterable, - join_path_native, - to_native_path_linux, - RemoteProgress, - rmtree - ) + Iterable, + join_path_native, + to_native_path_linux, + RemoteProgress, + rmtree +) from git.config import SectionConstraint from git.exc import ( - InvalidGitRepositoryError, - NoSuchPathError - ) + InvalidGitRepositoryError, + NoSuchPathError +) import stat import git @@ -160,7 +160,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): try: fp_module = cls._sio_modules(parent_commit) except KeyError: - raise IOError("Could not find %s file in the tree of parent commit %s" % (cls.k_modules_file, parent_commit)) + raise IOError("Could not find %s file in the tree of parent commit %s" % + (cls.k_modules_file, parent_commit)) # END handle exceptions # END handle non-bare working tree @@ -237,7 +238,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): # like it ... if url != None: url = to_native_path_linux(url) - #END assure url correctness + # END assure url correctness # INSTANTIATE INTERMEDIATE SM sm = cls(repo, cls.NULL_BIN_SHA, cls.k_default_mode, path, name) @@ -260,7 +261,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): branch_is_default = branch is None if has_module and url is not None: if url not in [r.url for r in sm.module().remotes]: - raise ValueError("Specified URL '%s' does not match any remote url of the repository at '%s'" % (url, sm.abspath)) + raise ValueError( + "Specified URL '%s' does not match any remote url of the repository at '%s'" % (url, sm.abspath)) # END check url # END verify urls match @@ -307,7 +309,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): return sm def update(self, recursive=False, init=True, to_latest_revision=False, progress=None, - dry_run=False): + dry_run=False): """Update the repository of this submodule to point to the checkout we point at with the binsha of this instance. @@ -327,20 +329,20 @@ class Submodule(util.IndexObject, Iterable, Traversable): :return: self""" if self.repo.bare: return self - #END pass in bare mode + # END pass in bare mode if progress is None: progress = UpdateProgress() - #END handle progress + # END handle progress prefix = '' if dry_run: prefix = "DRY-RUN: " - #END handle prefix + # END handle prefix # to keep things plausible in dry-run mode if dry_run: mrepo = None - #END init mrepo + # END init mrepo # ASSURE REPO IS PRESENT AND UPTODATE ##################################### @@ -352,19 +354,19 @@ class Submodule(util.IndexObject, Iterable, Traversable): op = FETCH if i == 0: op |= BEGIN - #END handle start + # END handle start progress.update(op, i, len_rmts, prefix + "Fetching remote %s of submodule %r" % (remote, self.name)) #=============================== if not dry_run: remote.fetch(progress=progress) - #END handle dry-run + # END handle dry-run #=============================== if i == len_rmts - 1: op |= END - #END handle end + # END handle end progress.update(op, i, len_rmts, prefix + "Done fetching remote of submodule %r" % self.name) - #END fetch new data + # END fetch new data except InvalidGitRepositoryError: if not init: return self @@ -383,10 +385,11 @@ class Submodule(util.IndexObject, Iterable, Traversable): # don't check it out at first - nonetheless it will create a local # branch according to the remote-HEAD if possible - progress.update(BEGIN | CLONE, 0, 1, prefix + "Cloning %s to %s in submodule %r" % (self.url, module_path, self.name)) + progress.update(BEGIN | CLONE, 0, 1, prefix + "Cloning %s to %s in submodule %r" % + (self.url, module_path, self.name)) if not dry_run: mrepo = git.Repo.clone_from(self.url, module_path, n=True) - #END handle dry-run + # END handle dry-run progress.update(END | CLONE, 0, 1, prefix + "Done cloning to %s" % module_path) if not dry_run: @@ -406,15 +409,15 @@ class Submodule(util.IndexObject, Iterable, Traversable): mrepo.head.ref.set_tracking_branch(remote_branch) except IndexError: print >> sys.stderr, "Warning: Failed to checkout tracking branch %s" % self.branch_path - #END handle tracking branch + # END handle tracking branch # NOTE: Have to write the repo config file as well, otherwise # the default implementation will be offended and not update the repository # Maybe this is a good way to assure it doesn't get into our way, but # we want to stay backwards compatible too ... . Its so redundant ! self.repo.config_writer().set_value(sm_section(self.name), 'url', self.url) - #END handle dry_run - #END handle initalization + # END handle dry_run + # END handle initalization # DETERMINE SHAS TO CHECKOUT ############################ @@ -423,7 +426,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): if mrepo is not None: # mrepo is only set if we are not in dry-run mode or if the module existed is_detached = mrepo.head.is_detached - #END handle dry_run + # END handle dry_run if mrepo is not None and to_latest_revision: msg_base = "Cannot update to latest revision in repository at %r as " % mrepo.working_dir @@ -434,7 +437,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): binsha = rcommit.binsha hexsha = rcommit.hexsha else: - print >> sys.stderr, "%s a tracking branch was not set for local branch '%s'" % (msg_base, mrepo.head.ref) + print >> sys.stderr, "%s a tracking branch was not set for local branch '%s'" % ( + msg_base, mrepo.head.ref) # END handle remote ref else: print >> sys.stderr, "%s there was no local tracking branch" % msg_base @@ -444,7 +448,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): # update the working tree # handles dry_run if mrepo is not None and mrepo.head.commit.binsha != binsha: - progress.update(BEGIN | UPDWKTREE, 0, 1, prefix + "Updating working tree at %s for submodule %r to revision %s" % (self.path, self.name, hexsha)) + progress.update(BEGIN | UPDWKTREE, 0, 1, prefix + + "Updating working tree at %s for submodule %r to revision %s" % (self.path, self.name, hexsha)) if not dry_run: if is_detached: # NOTE: for now we force, the user is no supposed to change detached @@ -458,7 +463,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): # branch - this should be prevented when setting the branch option mrepo.head.reset(hexsha, index=True, working_tree=True) # END handle checkout - #END handle dry_run + # END handle dry_run progress.update(END | UPDWKTREE, 0, 1, prefix + "Done updating working tree for submodule %r" % self.name) # END update to new commit only if needed @@ -470,7 +475,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): for submodule in self.iter_items(self.module()): submodule.update(recursive, init, to_latest_revision, progress=progress, dry_run=dry_run) # END handle recursive update - #END handle dry run + # END handle dry run # END for each submodule return self @@ -498,7 +503,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): """ if module + configuration < 1: raise ValueError("You must specify to move at least the module or the configuration of the submodule") - #END handle input + # END handle input module_path = to_native_path_linux(module_path) if module_path.endswith('/'): @@ -508,7 +513,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): # VERIFY DESTINATION if module_path == self.path: return self - #END handle no change + # END handle no change dest_path = join_path_native(self.repo.working_tree_dir, module_path) if os.path.isfile(dest_path): @@ -520,25 +525,25 @@ class Submodule(util.IndexObject, Iterable, Traversable): # if the target item already exists, fail if configuration and tekey in index.entries: raise ValueError("Index entry for target path did alredy exist") - #END handle index key already there + # END handle index key already there # remove existing destination if module: if os.path.exists(dest_path): if len(os.listdir(dest_path)): raise ValueError("Destination module directory was not empty") - #END handle non-emptyness + # END handle non-emptyness if os.path.islink(dest_path): os.remove(dest_path) else: os.rmdir(dest_path) - #END handle link + # END handle link else: # recreate parent directories # NOTE: renames() does that now pass - #END handle existance + # END handle existance # END handle module # move the module into place if possible @@ -547,7 +552,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): if module and os.path.exists(cur_path): os.renames(cur_path, dest_path) renamed_module = True - #END move physical module + # END move physical module # rename the index entry - have to manipulate the index directly as # git-mv cannot be used on submodules ... yeah @@ -561,7 +566,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): index.entries[tekey] = nentry except KeyError: raise InvalidGitRepositoryError("Submodule's entry at %r did not exist" % (self.path)) - #END handle submodule doesn't exist + # END handle submodule doesn't exist # update configuration writer = self.config_writer(index=index) # auto-write @@ -574,7 +579,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): os.renames(dest_path, cur_path) # END undo module renaming raise - #END handle undo rename + # END handle undo rename return self @@ -623,16 +628,17 @@ class Submodule(util.IndexObject, Iterable, Traversable): method = rmtree elif os.path.exists(mp): raise AssertionError("Cannot forcibly delete repository as it was neither a link, nor a directory") - #END handle brutal deletion + # END handle brutal deletion if not dry_run: assert method method(mp) - #END apply deletion method + # END apply deletion method else: # verify we may delete our module mod = self.module() if mod.is_dirty(untracked_files=True): - raise InvalidGitRepositoryError("Cannot delete module at %s with any modifications, unless force is specified" % mod.working_tree_dir) + raise InvalidGitRepositoryError( + "Cannot delete module at %s with any modifications, unless force is specified" % mod.working_tree_dir) # END check for dirt # figure out whether we have new commits compared to the remotes @@ -648,13 +654,14 @@ class Submodule(util.IndexObject, Iterable, Traversable): # END for each remote ref # not a single remote branch contained all our commits if num_branches_with_new_commits == len(rrefs): - raise InvalidGitRepositoryError("Cannot delete module at %s as there are new commits" % mod.working_tree_dir) + raise InvalidGitRepositoryError( + "Cannot delete module at %s as there are new commits" % mod.working_tree_dir) # END handle new commits # have to manually delete references as python's scoping is # not existing, they could keep handles open ( on windows this is a problem ) if len(rrefs): del(rref) - #END handle remotes + # END handle remotes del(rrefs) del(remote) # END for each remote @@ -683,7 +690,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): del(index.entries[index.entry_key(self.path, 0)]) except KeyError: pass - #END delete entry + # END delete entry index.write() # now git config - need the config intact, otherwise we can't query @@ -796,7 +803,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): if hasattr(self, attr): loc[attr] = getattr(self, attr) # END if we have the attribute cache - #END for each attr + # END for each attr self._clear_cache() try: @@ -907,7 +914,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): entry = index.entries[index.entry_key(p, 0)] sm = Submodule(repo, entry.binsha, entry.mode, entry.path) except KeyError: - raise InvalidGitRepositoryError("Gitmodule path %r did not exist in revision of parent commit %s" % (p, parent_commit)) + raise InvalidGitRepositoryError( + "Gitmodule path %r did not exist in revision of parent commit %s" % (p, parent_commit)) # END handle keyerror # END handle critical error diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index 581c5a7c..f68f7567 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -1,7 +1,7 @@ from base import Submodule, UpdateProgress from util import ( - find_first_remote_branch - ) + find_first_remote_branch +) from git.exc import InvalidGitRepositoryError import git @@ -13,7 +13,8 @@ __all__ = ["RootModule", "RootUpdateProgress"] class RootUpdateProgress(UpdateProgress): """Utility class which adds more opcodes to the UpdateProgress""" - REMOVE, PATHCHANGE, BRANCHCHANGE, URLCHANGE = [1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)] + REMOVE, PATHCHANGE, BRANCHCHANGE, URLCHANGE = [ + 1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)] _num_op_codes = UpdateProgress._num_op_codes + 4 __slots__ = tuple() @@ -38,15 +39,15 @@ class RootModule(Submodule): def __init__(self, repo): # repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None) super(RootModule, self).__init__( - repo, - binsha=self.NULL_BIN_SHA, - mode=self.k_default_mode, - path='', - name=self.k_root_name, - parent_commit=repo.head.commit, - url='', - branch_path=git.Head.to_full_path(self.k_head_default) - ) + repo, + binsha=self.NULL_BIN_SHA, + mode=self.k_default_mode, + path='', + name=self.k_root_name, + parent_commit=repo.head.commit, + url='', + branch_path=git.Head.to_full_path(self.k_head_default) + ) def _clear_cache(self): """May not do anything""" @@ -55,7 +56,7 @@ class RootModule(Submodule): #{ Interface def update(self, previous_commit=None, recursive=True, force_remove=False, init=True, - to_latest_revision=False, progress=None, dry_run=False): + to_latest_revision=False, progress=None, dry_run=False): """Update the submodules of this repository to the current HEAD commit. This method behaves smartly by determining changes of the path of a submodules repository, next to changes to the to-be-checked-out commit or the branch to be @@ -84,7 +85,7 @@ class RootModule(Submodule): if progress is None: progress = RootUpdateProgress() - #END assure progress is set + # END assure progress is set prefix = '' if dry_run: @@ -100,11 +101,11 @@ class RootModule(Submodule): previous_commit = repo.commit(repo.head.log_entry(-1).oldhexsha) if previous_commit.binsha == previous_commit.NULL_BIN_SHA: raise IndexError - #END handle initial commit + # END handle initial commit except IndexError: # in new repositories, there is no previous commit previous_commit = cur_commit - #END exception handling + # END exception handling else: previous_commit = repo.commit(previous_commit) # obtain commit object # END handle previous commit @@ -122,7 +123,7 @@ class RootModule(Submodule): op = REMOVE if i == 0: op |= BEGIN - #END handle begin + # END handle begin # fake it into thinking its at the current commit to allow deletion # of previous module. Trigger the cache to be updated before that @@ -130,11 +131,11 @@ class RootModule(Submodule): rsm._parent_commit = repo.head.commit if not dry_run: rsm.remove(configuration=False, module=True, force=force_remove) - #END handle dry-run + # END handle dry-run if i == len_rrsm - 1: op |= END - #END handle end + # END handle end progress.update(op, i, len_rrsm, prefix + "Done removing submodule %r" % rsm.name) # END for each removed submodule @@ -147,15 +148,17 @@ class RootModule(Submodule): psm = psms[csm.name] sm = sms[csm.name] - #PATH CHANGES + # PATH CHANGES ############## if sm.path != psm.path and psm.module_exists(): - progress.update(BEGIN | PATHCHANGE, i, len_csms, prefix + "Moving repository of submodule %r from %s to %s" % (sm.name, psm.abspath, sm.abspath)) + progress.update(BEGIN | PATHCHANGE, i, len_csms, prefix + + "Moving repository of submodule %r from %s to %s" % (sm.name, psm.abspath, sm.abspath)) # move the module to the new path if not dry_run: psm.move(sm.path, module=True, configuration=False) - #END handle dry_run - progress.update(END | PATHCHANGE, i, len_csms, prefix + "Done moving repository of submodule %r" % sm.name) + # END handle dry_run + progress.update( + END | PATHCHANGE, i, len_csms, prefix + "Done moving repository of submodule %r" % sm.name) # END handle path changes if sm.module_exists(): @@ -171,7 +174,8 @@ class RootModule(Submodule): # don't do anything if we already have the url we search in place if len([r for r in rmts if r.url == sm.url]) == 0: - progress.update(BEGIN | URLCHANGE, i, len_csms, prefix + "Changing url of submodule %r from %s to %s" % (sm.name, psm.url, sm.url)) + progress.update(BEGIN | URLCHANGE, i, len_csms, prefix + + "Changing url of submodule %r from %s to %s" % (sm.name, psm.url, sm.url)) if not dry_run: assert nn not in [r.name for r in rmts] @@ -181,7 +185,8 @@ class RootModule(Submodule): # If we have a tracking branch, it should be available # in the new remote as well. if len([r for r in smr.refs if r.remote_head == sm.branch_name]) == 0: - raise ValueError("Submodule branch named %r was not available in new submodule remote at %r" % (sm.branch_name, sm.url)) + raise ValueError( + "Submodule branch named %r was not available in new submodule remote at %r" % (sm.branch_name, sm.url)) # END head is not detached # now delete the changed one @@ -204,8 +209,9 @@ class RootModule(Submodule): # and its okay to fail here # Alternatively we could just generate a unique name and leave all # existing ones in place - raise InvalidGitRepositoryError("Couldn't find original remote-repo at url %r" % psm.url) - #END handle one single remote + raise InvalidGitRepositoryError( + "Couldn't find original remote-repo at url %r" % psm.url) + # END handle one single remote # END handle check we found a remote orig_name = rmt_for_deletion.name @@ -241,11 +247,12 @@ class RootModule(Submodule): # the user will be able to commit the change easily print >> sys.stderr, "WARNING: Current sha %s was not contained in the tracking branch at the new remote, setting it the the remote's tracking branch" % sm.hexsha sm.binsha = rref.commit.binsha - #END reset binsha + # END reset binsha - #NOTE: All checkout is performed by the base implementation of update - #END handle dry_run - progress.update(END | URLCHANGE, i, len_csms, prefix + "Done adjusting url of submodule %r" % (sm.name)) + # NOTE: All checkout is performed by the base implementation of update + # END handle dry_run + progress.update( + END | URLCHANGE, i, len_csms, prefix + "Done adjusting url of submodule %r" % (sm.name)) # END skip remote handling if new url already exists in module # END handle url @@ -254,7 +261,8 @@ class RootModule(Submodule): if sm.branch_path != psm.branch_path: # finally, create a new tracking branch which tracks the # new remote branch - progress.update(BEGIN | BRANCHCHANGE, i, len_csms, prefix + "Changing branch of submodule %r from %s to %s" % (sm.name, psm.branch_path, sm.branch_path)) + progress.update(BEGIN | BRANCHCHANGE, i, len_csms, prefix + + "Changing branch of submodule %r from %s to %s" % (sm.name, psm.branch_path, sm.branch_path)) if not dry_run: smm = sm.module() smmr = smm.remotes @@ -263,7 +271,7 @@ class RootModule(Submodule): except OSError: # ... or reuse the existing one tbr = git.Head(smm, sm.branch_path) - #END assure tracking branch exists + # END assure tracking branch exists tbr.set_tracking_branch(find_first_remote_branch(smmr, sm.branch_name)) # figure out whether the previous tracking branch contains @@ -273,19 +281,20 @@ class RootModule(Submodule): tbr = find_first_remote_branch(smmr, psm.branch_name) if len(smm.git.cherry(tbr, psm.branch)) == 0: psm.branch.delete(smm, psm.branch) - #END delete original tracking branch if there are no changes + # END delete original tracking branch if there are no changes except InvalidGitRepositoryError: # ignore it if the previous branch couldn't be found in the # current remotes, this just means we can't handle it pass # END exception handling - #NOTE: All checkout is done in the base implementation of update - #END handle dry_run + # NOTE: All checkout is done in the base implementation of update + # END handle dry_run - progress.update(END | BRANCHCHANGE, i, len_csms, prefix + "Done changing branch of submodule %r" % sm.name) - #END handle branch - #END handle + progress.update( + END | BRANCHCHANGE, i, len_csms, prefix + "Done changing branch of submodule %r" % sm.name) + # END handle branch + # END handle # END for each common submodule # FINALLY UPDATE ALL ACTUAL SUBMODULES @@ -293,7 +302,7 @@ class RootModule(Submodule): for sm in sms: # update the submodule using the default method sm.update(recursive=False, init=init, to_latest_revision=to_latest_revision, - progress=progress, dry_run=dry_run) + progress=progress, dry_run=dry_run) # update recursively depth first - question is which inconsitent # state will be better in case it fails somewhere. Defective branch @@ -303,10 +312,10 @@ class RootModule(Submodule): # the module would exist by now if we are not in dry_run mode if sm.module_exists(): type(self)(sm.module()).update(recursive=True, force_remove=force_remove, - init=init, to_latest_revision=to_latest_revision, - progress=progress, dry_run=dry_run) - #END handle dry_run - #END handle recursive + init=init, to_latest_revision=to_latest_revision, + progress=progress, dry_run=dry_run) + # END handle dry_run + # END handle recursive # END for each submodule to update def module(self): diff --git a/git/objects/submodule/util.py b/git/objects/submodule/util.py index bbdf5e1e..01bd03b3 100644 --- a/git/objects/submodule/util.py +++ b/git/objects/submodule/util.py @@ -5,7 +5,7 @@ from StringIO import StringIO import weakref __all__ = ('sm_section', 'sm_name', 'mkhead', 'unbare_repo', 'find_first_remote_branch', - 'SubmoduleConfigParser') + 'SubmoduleConfigParser') #{ Utilities @@ -33,7 +33,7 @@ def unbare_repo(func): def wrapper(self, *args, **kwargs): if self.repo.bare: raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__) - #END bare method + # END bare method return func(self, *args, **kwargs) # END wrapper wrapper.__name__ = func.__name__ @@ -48,7 +48,7 @@ def find_first_remote_branch(remotes, branch_name): except IndexError: continue # END exception handling - #END for remote + # END for remote raise InvalidGitRepositoryError("Didn't find remote branch %r in any of the given remotes", branch_name) #} END utilities diff --git a/git/objects/tag.py b/git/objects/tag.py index 3fd7a4d4..3c379579 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -7,9 +7,9 @@ import base from gitdb.util import hex_to_bin from util import ( - get_object_type_by_name, - parse_actor_and_date - ) + get_object_type_by_name, + parse_actor_and_date +) __all__ = ("TagObject", ) @@ -21,7 +21,7 @@ class TagObject(base.Object): __slots__ = ("object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message") def __init__(self, repo, binsha, object=None, tag=None, - tagger=None, tagged_date=None, tagger_tz_offset=None, message=None): + tagger=None, tagged_date=None, tagger_tz_offset=None, message=None): """Initialize a tag object with additional data :param repo: repository this object is located in diff --git a/git/objects/tree.py b/git/objects/tree.py index cc3699f5..9f63e4e3 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -11,13 +11,13 @@ from submodule.base import Submodule import git.diff as diff from fun import ( - tree_entries_from_data, - tree_to_stream - ) + tree_entries_from_data, + tree_to_stream +) from gitdb.util import ( - to_bin_sha, - ) + to_bin_sha, +) __all__ = ("TreeModifier", "Tree") @@ -125,11 +125,11 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): tree_id = 004 _map_id_to_type = { - commit_id: Submodule, - blob_id: Blob, - symlink_id: Blob - # tree id added once Tree is defined - } + commit_id: Submodule, + blob_id: Blob, + symlink_id: Blob + # tree id added once Tree is defined + } def __init__(self, repo, binsha, mode=tree_id << 12, path=None): super(Tree, self).__init__(repo, binsha, mode, path) @@ -212,8 +212,8 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): return TreeModifier(self._cache) def traverse(self, predicate=lambda i, d: True, - prune=lambda i, d: False, depth=-1, branch_first=True, - visit_once=False, ignore_self=1): + prune=lambda i, d: False, depth=-1, branch_first=True, + visit_once=False, ignore_self=1): """For documentation, see util.Traversable.traverse Trees are set to visit_once = False to gain more performance in the traversal""" return super(Tree, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self) diff --git a/git/objects/util.py b/git/objects/util.py index f6daca0f..f36bf296 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -5,9 +5,9 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php """Module for general utility functions""" from git.util import ( - IterableList, - Actor - ) + IterableList, + Actor +) import re from collections import deque as Deque @@ -17,8 +17,8 @@ import time import os __all__ = ('get_object_type_by_name', 'parse_date', 'parse_actor_and_date', - 'ProcessStreamAdapter', 'Traversable', 'altz_to_utctz_str', 'utctz_to_altz', - 'verify_utctz', 'Actor') + 'ProcessStreamAdapter', 'Traversable', 'altz_to_utctz_str', 'utctz_to_altz', + 'verify_utctz', 'Actor') #{ Functions @@ -89,9 +89,9 @@ def verify_utctz(offset): if offset[0] not in "+-": raise fmt_exc if offset[1] not in digits or \ - offset[2] not in digits or \ - offset[3] not in digits or \ - offset[4] not in digits: + offset[2] not in digits or \ + offset[3] not in digits or \ + offset[4] not in digits: raise fmt_exc # END for each char return offset @@ -238,8 +238,8 @@ class Traversable(object): return out def traverse(self, predicate=lambda i, d: True, - prune=lambda i, d: False, depth=-1, branch_first=True, - visit_once=True, ignore_self=1, as_edge=False): + prune=lambda i, d: False, depth=-1, branch_first=True, + visit_once=True, ignore_self=1, as_edge=False): """:return: iterator yieling of items found when traversing self :param predicate: f(i,d) returns False if item i at depth d should not be included in the result |