Преглед изворни кода

Abstract manifest branch creation from init to the manifest object

This permits the XML style manifest to use 'default', while other
types can use their own creation strategy for the current branch.

Signed-off-by: Shawn O. Pearce <sop@google.com>
Shawn O. Pearce пре 17 година
родитељ
комит
75b87c8a51
3 измењених фајлова са 12 додато и 4 уклоњено
  1. 3 0
      manifest.py
  2. 6 0
      manifest_xml.py
  3. 3 4
      subcmds/init.py

+ 3 - 0
manifest.py

@@ -40,5 +40,8 @@ class Manifest(object):
   def projects(self):
   def projects(self):
     return {}
     return {}
 
 
+  def InitBranch(self):
+    pass
+
   def SetMRefs(self, project):
   def SetMRefs(self, project):
     pass
     pass

+ 6 - 0
manifest_xml.py

@@ -169,6 +169,12 @@ class XmlManifest(Manifest):
     self._Load()
     self._Load()
     return self._default
     return self._default
 
 
+  def InitBranch(self):
+    m = self.manifestProject
+    if m.CurrentBranch is None:
+      return m.StartBranch('default')
+    return True
+
   def SetMRefs(self, project):
   def SetMRefs(self, project):
     if self.branch:
     if self.branch:
       project._InitAnyMRef(R_M + self.branch)
       project._InitAnyMRef(R_M + self.branch)

+ 3 - 4
subcmds/init.py

@@ -130,10 +130,9 @@ to update the working directory files.
     m.Sync_LocalHalf(syncbuf)
     m.Sync_LocalHalf(syncbuf)
     syncbuf.Finish()
     syncbuf.Finish()
 
 
-    if is_new or m.CurrentBranch is None:
-      if not m.StartBranch('default'):
-        print >>sys.stderr, 'fatal: cannot create default in manifest'
-        sys.exit(1)
+    if not self.manifest.InitBranch():
+      print >>sys.stderr, 'fatal: cannot create branch in manifest'
+      sys.exit(1)
 
 
   def _LinkManifest(self, name):
   def _LinkManifest(self, name):
     if not name:
     if not name: