diff --git a/project.py b/project.py index 4f0345f8..d336f990 100644 --- a/project.py +++ b/project.py @@ -2167,6 +2167,22 @@ class MetaProject(Project): self.revisionExpr = base self.revisionId = None + def MetaBranchSwitch(self, target): + """ Prepare MetaProject for manifest branch switch + """ + + # detach and delete manifest branch, allowing a new + # branch to take over + syncbuf = SyncBuffer(self.config, detach_head = True) + self.Sync_LocalHalf(syncbuf) + syncbuf.Finish() + + return GitCommand(self, + ['branch', '-D', 'default'], + capture_stdout = True, + capture_stderr = True).Wait() == 0 + + @property def LastFetch(self): 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. shutil.rmtree(m.gitdir) sys.exit(1) + if opt.manifest_branch: + m.MetaBranchSwitch(opt.manifest_branch) + syncbuf = SyncBuffer(m.config) m.Sync_LocalHalf(syncbuf) syncbuf.Finish()