Forráskód Böngészése

Make refs/remotes/m management the manifest object's responsibility

I plan to have the new submodule manifest format use a different
layout for the m refs than the XML manifest format has used in
the past.  Thus we need to move the behavior management into the
manifest object, and out of the project, so we can change it.

Signed-off-by: Shawn O. Pearce <sop@google.com>
Shawn O. Pearce 16 éve
szülő
commit
cc6c79643e
4 módosított fájl, 14 hozzáadás és 7 törlés
  1. 0 1
      git_refs.py
  2. 7 0
      manifest.py
  3. 5 0
      manifest_xml.py
  4. 2 6
      project.py

+ 0 - 1
git_refs.py

@@ -21,7 +21,6 @@ HEAD    = 'HEAD'
 R_HEADS = 'refs/heads/'
 R_TAGS  = 'refs/tags/'
 R_PUB   = 'refs/published/'
-R_M     = 'refs/remotes/m/'
 
 
 class GitRefs(object):

+ 7 - 0
manifest.py

@@ -35,3 +35,10 @@ class Manifest(object):
   @property
   def IsMirror(self):
     return self.manifestProject.config.GetBoolean('repo.mirror')
+
+  @property
+  def projects(self):
+    return {}
+
+  def SetMRefs(self, project):
+    pass

+ 5 - 0
manifest_xml.py

@@ -29,6 +29,7 @@ from error import ManifestParseError
 
 MANIFEST_FILE_NAME = 'manifest.xml'
 LOCAL_MANIFEST_NAME = 'local_manifest.xml'
+R_M = 'refs/remotes/m/'
 
 class _Default(object):
   """Project defaults within the manifest."""
@@ -168,6 +169,10 @@ class XmlManifest(Manifest):
     self._Load()
     return self._default
 
+  def SetMRefs(self, project):
+    if self.branch:
+      project._InitAnyMRef(R_M + self.branch)
+
   def _Unload(self):
     self._loaded = False
     self._projects = {}

+ 2 - 6
project.py

@@ -27,7 +27,7 @@ from git_config import GitConfig, IsId
 from error import GitError, ImportError, UploadError
 from error import ManifestInvalidRevisionError
 
-from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M
+from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB
 
 def _lwrite(path, content):
   lock = '%s.lock' % path
@@ -598,7 +598,7 @@ class Project(object):
       return False
 
     if self.worktree:
-      self._InitMRef()
+      self.manifest.SetMRefs(self)
     else:
       self._InitMirrorHead()
       try:
@@ -1080,10 +1080,6 @@ class Project(object):
         remote.ResetFetch(mirror=True)
       remote.Save()
 
-  def _InitMRef(self):
-    if self.manifest.branch:
-      self._InitAnyMRef(R_M + self.manifest.branch)
-
   def _InitMirrorHead(self):
     self._InitAnyMRef(HEAD)