summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-10 16:21:18 -0700
committerShawn O. Pearce <sop@google.com>2009-04-10 16:21:18 -0700
commit0a389e94de32151189b7064d96eaaa0aa6cdb4a3 (patch)
tree526a877b54a070746b7a0ae8b5657baa9e7aed0e /project.py
parent2675c3f8b5865edff4fe6ec60187b32deef5041d (diff)
downloadgit-repo-0a389e94de32151189b7064d96eaaa0aa6cdb4a3.tar.gz
Make 'repo start' restartable upon failures
If `repo start foo` fails due to uncommitted and unmergeable changes in a single project, we have switched half of the projects over to the new target branches, but didn't on the one that failed to move. This change improves the situation by doing three things differently: - We keep going when we encounter an error, so other projects that can successfully switch still switch. - We ignore projects whose current branch is already on the requested name; they are logically already setup. - We checkout the branch if it already exists, rather than trying to recreate the branch. Bug: REPO-22 Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py31
1 files changed, 23 insertions, 8 deletions
diff --git a/project.py b/project.py
index 48ab8475..06240b7e 100644
--- a/project.py
+++ b/project.py
@@ -748,16 +748,31 @@ class Project(object):
748 def StartBranch(self, name): 748 def StartBranch(self, name):
749 """Create a new branch off the manifest's revision. 749 """Create a new branch off the manifest's revision.
750 """ 750 """
751 branch = self.GetBranch(name) 751 try:
752 branch.remote = self.GetRemote(self.remote.name) 752 self.bare_git.rev_parse(R_HEADS + name)
753 branch.merge = self.revision 753 exists = True
754 except GitError:
755 exists = False;
756
757 if exists:
758 if name == self.CurrentBranch:
759 return True
760 else:
761 cmd = ['checkout', name, '--']
762 return GitCommand(self, cmd).Wait() == 0
754 763
755 rev = branch.LocalMerge
756 cmd = ['checkout', '-b', branch.name, rev]
757 if GitCommand(self, cmd).Wait() == 0:
758 branch.Save()
759 else: 764 else:
760 raise GitError('%s checkout %s ' % (self.name, rev)) 765 branch = self.GetBranch(name)
766 branch.remote = self.GetRemote(self.remote.name)
767 branch.merge = self.revision
768
769 rev = branch.LocalMerge
770 cmd = ['checkout', '-b', branch.name, rev]
771 if GitCommand(self, cmd).Wait() == 0:
772 branch.Save()
773 return True
774 else:
775 return False
761 776
762 def CheckoutBranch(self, name): 777 def CheckoutBranch(self, name):
763 """Checkout a local topic branch. 778 """Checkout a local topic branch.