1212
1313class TestSubmodule (TestBase ):
1414
15- k_subm_current = "00ce31ad308ff4c7ef874d2fa64374f47980c85c "
15+ k_subm_current = "45c0f285a6d9d9214f8167742d12af2855f527fb "
1616 k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
1717 k_no_subm_tag = "0.1.6"
1818
@@ -33,7 +33,7 @@ def _do_base_tests(self, rwrepo):
3333 assert len (Submodule .list_items (rwrepo , self .k_no_subm_tag )) == 0
3434
3535 assert sm .path == 'lib/git/ext/gitdb'
36- assert sm .path == sm .name # for now, this is True
36+ assert sm .path != sm .name # in our case, we have ids there, which don't equal the path
3737 assert sm .url == 'git://gitorious.org/git-python/gitdb.git'
3838 assert sm .branch .name == 'master' # its unset in this case
3939 assert sm .parent_commit == rwrepo .head .commit
@@ -43,7 +43,7 @@ def _do_base_tests(self, rwrepo):
4343 # some commits earlier we still have a submodule, but its at a different commit
4444 smold = Submodule .iter_items (rwrepo , self .k_subm_changed ).next ()
4545 assert smold .binsha != sm .binsha
46- assert smold == sm # the name is still the same
46+ assert smold != sm # the name changed
4747
4848 # force it to reread its information
4949 del (smold ._url )
@@ -71,12 +71,11 @@ def _do_base_tests(self, rwrepo):
7171 self .failUnlessRaises (ValueError , smold .config_writer )
7272 # END handle bare repo
7373
74- # make the old into a new
74+ # make the old into a new - this doesn't work as the name changed
7575 prev_parent_commit = smold .parent_commit
76- assert smold .set_parent_commit (self .k_subm_current ) is smold
77- assert smold .parent_commit != prev_parent_commit
78- assert smold .binsha == sm .binsha
79- smold .set_parent_commit (prev_parent_commit )
76+ self .failUnlessRaises (ValueError , smold .set_parent_commit , self .k_subm_current )
77+ # the sha is properly updated
78+ smold .set_parent_commit (self .k_subm_changed + "~1" )
8079 assert smold .binsha != sm .binsha
8180
8281 # raises if the sm didn't exist in new parent - it keeps its
@@ -181,6 +180,10 @@ def _do_base_tests(self, rwrepo):
181180 csm .module ().head .ref .set_tracking_branch (None )
182181 sm .update (recursive = True , to_latest_revision = True )
183182
183+ # to_latest_revision changes the child submodule's commit, it needs an
184+ # update now
185+ csm .set_parent_commit (csm .repo .head .commit )
186+
184187 # undo the changes
185188 sm .module ().head .ref = smref
186189 csm .module ().head .ref .set_tracking_branch (csm_tracking_branch )
@@ -191,8 +194,8 @@ def _do_base_tests(self, rwrepo):
191194 self .failUnlessRaises (ValueError , csm .remove , module = False , configuration = False )
192195 # We have modified the configuration, hence the index is dirty, and the
193196 # deletion will fail
194- # NOTE: As we did a few updates in the meanwhile, the indices where reset
195- # Hence we restore some changes
197+ # NOTE: As we did a few updates in the meanwhile, the indices were reset
198+ # Hence we create some changes
196199 sm .config_writer ().set_value ("somekey" , "somevalue" )
197200 csm .config_writer ().set_value ("okey" , "ovalue" )
198201 self .failUnlessRaises (InvalidGitRepositoryError , sm .remove )
0 commit comments