"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
rmt_for_deletion=None
forremoteinrmts:
ifremote.url==psm.url:
rmt_for_deletion=remote
break
# END if urls match
# END for each remote
# if we didn't find a matching remote, but have exactly one,
# we can safely use this one
ifrmt_for_deletionisNone:
iflen(rmts) ==1:
rmt_for_deletion=rmts[0]
else:
# if we have not found any remote with the original url
# we may not have a name. This is a special case,
# and its okay to fail here
# Alternatively we could just generate a unique name and leave all
# existing ones in place
raiseInvalidGitRepositoryError(
"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
smm.delete_remote(rmt_for_deletion)
# NOTE: Currently we leave tags from the deleted remotes
# as well as separate tracking branches in the possibly totally
# changed repository ( someone could have changed the url to
# another project ). At some point, one might want to clean
# it up, but the danger is high to remove stuff the user
# has added explicitly
# rename the new remote back to what it was
smr.rename(orig_name)
# early on, we verified that the our current tracking branch
# exists in the remote. Now we have to assure that the
# sha we point to is still contained in the new remote
# tracking branch.
smsha=sm.binsha
found=False
rref=smr.refs[self.branch_name]
forcinrref.commit.traverse():
ifc.binsha==smsha:
found=True
break
# END traverse all commits in search for sha
# END for each commit
ifnotfound:
# adjust our internal binsha to use the one of the remote
# this way, it will be checked out in the next step
# This will change the submodule relative to us, so
# 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
# 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
# HANDLE PATH CHANGES
#####################
ifsm.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))
ifnotdry_run:
smm=sm.module()
smmr=smm.remotes
try:
tbr=git.Head.create(smm, sm.branch_name, logmsg='branch: Created from HEAD')