diff options
author | Florian Vallee <florian.vallee@gmail.com> | 2012-06-07 17:19:26 +0200 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2012-06-13 10:00:57 -0700 |
commit | 5d016502ebc68bc054d85c98c6cdb51e0b63a1f5 (patch) | |
tree | da1b47c86049f771f2292c507de21064842809d7 | |
parent | 475a47d531bfe5ad82ec104189075df72a3143b7 (diff) | |
download | git-repo-5d016502ebc68bc054d85c98c6cdb51e0b63a1f5.tar.gz |
Fix switching manifest branches using repo init -b
See repo issue #46 :
https://code.google.com/p/git-repo/issues/detail?id=46
When using repo init -b on an already existing repository,
the next sync will try to rebase changes coming from the old manifest
branch onto the new, leading in the best case scenario to conflicts
and in the worst case scenario to an incorrect "mixed up" manifest.
This patch fixes this by deleting the "default" branch in the local
manifest repository when the -d init switch is used, thus forcing
repo to perform a fresh checkout of the new manifest branch
Change-Id: I379e4875ec5357d8614d1197b6afbe58f9606751
-rw-r--r-- | project.py | 16 | ||||
-rw-r--r-- | subcmds/init.py | 3 |
2 files changed, 19 insertions, 0 deletions
@@ -2167,6 +2167,22 @@ class MetaProject(Project): | |||
2167 | self.revisionExpr = base | 2167 | self.revisionExpr = base |
2168 | self.revisionId = None | 2168 | self.revisionId = None |
2169 | 2169 | ||
2170 | def MetaBranchSwitch(self, target): | ||
2171 | """ Prepare MetaProject for manifest branch switch | ||
2172 | """ | ||
2173 | |||
2174 | # detach and delete manifest branch, allowing a new | ||
2175 | # branch to take over | ||
2176 | syncbuf = SyncBuffer(self.config, detach_head = True) | ||
2177 | self.Sync_LocalHalf(syncbuf) | ||
2178 | syncbuf.Finish() | ||
2179 | |||
2180 | return GitCommand(self, | ||
2181 | ['branch', '-D', 'default'], | ||
2182 | capture_stdout = True, | ||
2183 | capture_stderr = True).Wait() == 0 | ||
2184 | |||
2185 | |||
2170 | @property | 2186 | @property |
2171 | def LastFetch(self): | 2187 | def LastFetch(self): |
2172 | try: | 2188 | try: |
diff --git a/subcmds/init.py b/subcmds/init.py index b359024d..a758fbb1 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -187,6 +187,9 @@ to update the working directory files. | |||
187 | shutil.rmtree(m.gitdir) | 187 | shutil.rmtree(m.gitdir) |
188 | sys.exit(1) | 188 | sys.exit(1) |
189 | 189 | ||
190 | if opt.manifest_branch: | ||
191 | m.MetaBranchSwitch(opt.manifest_branch) | ||
192 | |||
190 | syncbuf = SyncBuffer(m.config) | 193 | syncbuf = SyncBuffer(m.config) |
191 | m.Sync_LocalHalf(syncbuf) | 194 | m.Sync_LocalHalf(syncbuf) |
192 | syncbuf.Finish() | 195 | syncbuf.Finish() |