summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-20 22:13:45 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-20 22:13:45 +0100
commitbb0f3d78d6980a1d43f05cb17a8da57a196a34f3 (patch)
tree775ad298112ea19674e1e05a5ab21669f999ace7
parente4921139819c7949abaad6cc5679232a0fbb0632 (diff)
downloadgitpython-bb0f3d78d6980a1d43f05cb17a8da57a196a34f3.tar.gz
Fixed flake8 and a minor test regression.
The latter happened as now BadName is thrown, instead of BadObject. Changes.rst was marked accordingly
-rw-r--r--doc/source/changes.rst1
-rw-r--r--git/objects/submodule/base.py38
-rw-r--r--git/objects/submodule/root.py11
-rw-r--r--git/test/test_repo.py4
-rw-r--r--git/test/test_submodule.py4
-rw-r--r--git/util.py6
6 files changed, 34 insertions, 30 deletions
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index 2277c4b7..60fe9725 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -8,6 +8,7 @@ Changelog
* `[include]` sections in git configuration files are now respected
* Added `GitConfigParser.rename_section()`
* Added `Submodule.rename()`
+* **POSSIBLY BREAKING CHANGE**: As `rev_parse` will now throw `BadName` as well as `BadObject`, client code will have to catch both exception types.
* A list of all issues can be found here: https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.6+-+Features%22+
0.3.5 - Bugfixes
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index 7f06a7b1..4b2fc0c0 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -116,7 +116,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
except cp.NoSectionError:
raise ValueError("This submodule instance does not exist anymore in '%s' file"
% os.path.join(self.repo.working_tree_dir, '.gitmodules'))
- # end
+ # end
self._url = reader.get_value('url')
# git-python extension values - optional
self._branch_path = reader.get_value(self.k_head_option, git.Head.to_full_path(self.k_head_default))
@@ -411,7 +411,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
del(writer)
# we deliberatly assume that our head matches our index !
-
+
try:
repo.head.commit
parent_repo_is_empty = False
@@ -429,7 +429,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,
- force=False, keep_going=False):
+ force=False, keep_going=False):
"""Update the repository of this submodule to point to the checkout
we point at with the binsha of this instance.
@@ -444,14 +444,14 @@ class Submodule(util.IndexObject, Iterable, Traversable):
:param progress: UpdateProgress instance or None of no progress should be shown
:param dry_run: if True, the operation will only be simulated, but not performed.
All performed operations are read-only
- :param force:
+ :param force:
If True, we may reset heads even if the repository in question is dirty. Additinoally we will be allowed
- to set a tracking branch which is ahead of its remote branch back into the past or the location of the
+ to set a tracking branch which is ahead of its remote branch back into the past or the location of the
remote branch. This will essentially 'forget' commits.
- If False, local tracking branches that are in the future of their respective remote branches will simply
+ If False, local tracking branches that are in the future of their respective remote branches will simply
not be moved.
- :param keep_going: if True, we will ignore but log all errors, and keep going recursively.
- Unless dry_run is set as well, keep_going could cause subsequent/inherited errors you wouldn't see
+ :param keep_going: if True, we will ignore but log all errors, and keep going recursively.
+ Unless dry_run is set as well, keep_going could cause subsequent/inherited errors you wouldn't see
otherwise.
In conjunction with dry_run, it can be useful to anticipate all errors when updating submodules
:note: does nothing in bare repositories
@@ -487,7 +487,8 @@ class Submodule(util.IndexObject, Iterable, Traversable):
op |= BEGIN
# END handle start
- progress.update(op, i, len_rmts, prefix + "Fetching remote %s of submodule %r" % (remote, self.name))
+ progress.update(op, i, len_rmts, prefix + "Fetching remote %s of submodule %r"
+ % (remote, self.name))
#===============================
if not dry_run:
remote.fetch(progress=progress)
@@ -589,11 +590,11 @@ class Submodule(util.IndexObject, Iterable, Traversable):
base_commit = mrepo.merge_base(mrepo.head.commit, hexsha)
if len(base_commit) == 0 or base_commit[0].hexsha == hexsha:
if force:
- log.debug("Will force checkout or reset on local branch that is possibly in the future of" +
- "the commit it will be checked out to, effectively 'forgetting' new commits")
+ log.debug("Will force checkout or reset on local branch that is possibly in the future of"
+ + "the commit it will be checked out to, effectively 'forgetting' new commits")
else:
- log.info("Skipping %s on branch '%s' of submodule repo '%s' as it contains un-pushed commits",
- is_detached and "checkout" or "reset", mrepo.head, mrepo)
+ log.info("Skipping %s on branch '%s' of submodule repo '%s' as it contains "
+ + "un-pushed commits", is_detached and "checkout" or "reset", mrepo.head, mrepo)
may_reset = False
# end handle force
# end handle if we are in the future
@@ -619,7 +620,8 @@ class Submodule(util.IndexObject, Iterable, Traversable):
mrepo.head.reset(hexsha, index=True, working_tree=True)
# END handle checkout
# if we may reset/checkout
- progress.update(END | UPDWKTREE, 0, 1, prefix + "Done updating working tree for submodule %r" % self.name)
+ progress.update(END | UPDWKTREE, 0, 1, prefix + "Done updating working tree for submodule %r"
+ % self.name)
# END update to new commit only if needed
except Exception as err:
if not keep_going:
@@ -633,7 +635,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
# in dry_run mode, the module might not exist
if mrepo is not None:
for submodule in self.iter_items(self.module()):
- submodule.update(recursive, init, to_latest_revision, progress=progress, dry_run=dry_run,
+ submodule.update(recursive, init, to_latest_revision, progress=progress, dry_run=dry_run,
force=force, keep_going=keep_going)
# END handle recursive update
# END handle dry run
@@ -898,14 +900,14 @@ class Submodule(util.IndexObject, Iterable, Traversable):
"""Set this instance to use the given commit whose tree is supposed to
contain the .gitmodules blob.
- :param commit:
- Commit'ish reference pointing at the root_tree, or None to always point to the
+ :param commit:
+ Commit'ish reference pointing at the root_tree, or None to always point to the
most recent commit
:param check:
if True, relatively expensive checks will be performed to verify
validity of the submodule.
:raise ValueError: if the commit's tree didn't contain the .gitmodules blob.
- :raise ValueError:
+ :raise ValueError:
if the parent commit didn't store this submodule under the current path
:return: self"""
if commit is None:
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index dd023d46..7042e99c 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -85,13 +85,13 @@ class RootModule(Submodule):
Unless force_reset is specified, a local tracking branch will never be reset into its past, therefore
the remote branch must be in the future for this to have an effect.
:param force_reset: if True, submodules may checkout or reset their branch even if the repository has
- pending changes that would be overwritten, or if the local tracking branch is in the future of the
+ pending changes that would be overwritten, or if the local tracking branch is in the future of the
remote tracking branch and would be reset into its past.
:param progress: RootUpdateProgress instance or None if no progress should be sent
:param dry_run: if True, operations will not actually be performed. Progress messages
will change accordingly to indicate the WOULD DO state of the operation.
- :param keep_going: if True, we will ignore but log all errors, and keep going recursively.
- Unless dry_run is set as well, keep_going could cause subsequent/inherited errors you wouldn't see
+ :param keep_going: if True, we will ignore but log all errors, and keep going recursively.
+ Unless dry_run is set as well, keep_going could cause subsequent/inherited errors you wouldn't see
otherwise.
In conjunction with dry_run, it can be useful to anticipate all errors when updating submodules
:return: self"""
@@ -136,7 +136,7 @@ class RootModule(Submodule):
###################
rrsm = (spsms - ssms)
len_rrsm = len(rrsm)
-
+
for i, rsm in enumerate(rrsm):
op = REMOVE
if i == 0:
@@ -168,7 +168,8 @@ class RootModule(Submodule):
##############
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))
+ "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)
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index c583fcae..c32dbdbf 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -591,8 +591,8 @@ class TestRepo(TestBase):
commit = rev_parse(first_rev)
assert len(commit.parents) == 0
assert commit.hexsha == first_rev
- self.failUnlessRaises(BadObject, rev_parse, first_rev + "~")
- self.failUnlessRaises(BadObject, rev_parse, first_rev + "^")
+ self.failUnlessRaises(BadName, rev_parse, first_rev + "~")
+ self.failUnlessRaises(BadName, rev_parse, first_rev + "^")
# short SHA1
commit2 = rev_parse(first_rev[:20])
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
index b9502f75..6a03fe26 100644
--- a/git/test/test_submodule.py
+++ b/git/test/test_submodule.py
@@ -535,7 +535,7 @@ class TestSubmodule(TestBase):
touch(nsm_file)
nsm.module().index.add([nsm])
nsm.module().index.commit("added new file")
- rm.update(recursive=False, dry_run=True, progress=prog) # would not change head, and thus doens't fail
+ rm.update(recursive=False, dry_run=True, progress=prog) # would not change head, and thus doens't fail
# Everything we can do from now on will trigger the 'future' check, so no is_dirty() check will even run
# This would only run if our local branch is in the past and we have uncommitted changes
@@ -691,7 +691,7 @@ class TestSubmodule(TestBase):
def assert_exists(sm, value=True):
assert sm.exists() == value
assert sm.module_exists() == value
- # end
+ # end
# As git is backwards compatible itself, it would still recognize what we do here ... unless we really
# muss it up. That's the only reason why the test is still here ... .
diff --git a/git/util.py b/git/util.py
index 8cab0b99..06fefcc3 100644
--- a/git/util.py
+++ b/git/util.py
@@ -251,9 +251,9 @@ class RemoteProgress(object):
message = message[:-len(done_token)]
# END end message handling
- self.update(op_code,
- cur_count and float(cur_count),
- max_count and float(max_count),
+ self.update(op_code,
+ cur_count and float(cur_count),
+ max_count and float(max_count),
message)
# END for each sub line
return failed_lines