summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.py31
-rw-r--r--subcmds/init.py4
-rw-r--r--subcmds/start.py10
3 files changed, 35 insertions, 10 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.
diff --git a/subcmds/init.py b/subcmds/init.py
index d86c49ae..a32eaae0 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -131,7 +131,9 @@ default.xml will be used.
131 131
132 m.Sync_LocalHalf() 132 m.Sync_LocalHalf()
133 if is_new or m.CurrentBranch is None: 133 if is_new or m.CurrentBranch is None:
134 m.StartBranch('default') 134 if not m.StartBranch('default'):
135 print >>sys.stderr, 'fatal: cannot create default in manifest'
136 sys.exit(1)
135 137
136 def _LinkManifest(self, name): 138 def _LinkManifest(self, name):
137 if not name: 139 if not name:
diff --git a/subcmds/start.py b/subcmds/start.py
index 4eb3e476..deced7c2 100644
--- a/subcmds/start.py
+++ b/subcmds/start.py
@@ -47,5 +47,13 @@ the configuration data is set up properly.
47 print >>sys.stderr, "error: '%s' is not a valid name" % nb 47 print >>sys.stderr, "error: '%s' is not a valid name" % nb
48 sys.exit(1) 48 sys.exit(1)
49 49
50 err = []
50 for project in self.GetProjects(args[1:]): 51 for project in self.GetProjects(args[1:]):
51 project.StartBranch(nb) 52 if not project.StartBranch(nb):
53 err.append(project)
54
55 if err:
56 err.sort()
57 for p in err:
58 print >>sys.stderr, "error: cannot start in %s" % p.relpath
59 sys.exit(1)