mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
sync: Support upgrading manifest formats
If the manifest format changes during init or sync we need to do a full reparse of the manifest, and possibly allow the new object to reconfigure the local workspace to match its expectations. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
5f947bba69
commit
87bda12e85
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from error import ManifestParseError
|
||||||
from editor import Editor
|
from editor import Editor
|
||||||
from git_config import GitConfig
|
from git_config import GitConfig
|
||||||
from project import MetaProject
|
from project import MetaProject
|
||||||
@ -45,3 +46,6 @@ class Manifest(object):
|
|||||||
|
|
||||||
def SetMRefs(self, project):
|
def SetMRefs(self, project):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def Upgrade_Local(self, old):
|
||||||
|
raise ManifestParseError, 'unsupported upgrade path'
|
||||||
|
@ -22,6 +22,7 @@ from error import ManifestParseError
|
|||||||
from project import SyncBuffer
|
from project import SyncBuffer
|
||||||
from git_command import git_require, MIN_GIT_VERSION
|
from git_command import git_require, MIN_GIT_VERSION
|
||||||
from manifest_xml import XmlManifest
|
from manifest_xml import XmlManifest
|
||||||
|
from subcmds.sync import _ReloadManifest
|
||||||
|
|
||||||
class Init(InteractiveCommand, MirrorSafeCommand):
|
class Init(InteractiveCommand, MirrorSafeCommand):
|
||||||
common = True
|
common = True
|
||||||
@ -143,9 +144,17 @@ to update the working directory files.
|
|||||||
print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url
|
print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not is_new:
|
||||||
|
# Force the manifest to load if it exists, the old graph
|
||||||
|
# may be needed inside of _ReloadManifest().
|
||||||
|
#
|
||||||
|
self.manifest.projects
|
||||||
|
|
||||||
syncbuf = SyncBuffer(m.config)
|
syncbuf = SyncBuffer(m.config)
|
||||||
m.Sync_LocalHalf(syncbuf)
|
m.Sync_LocalHalf(syncbuf)
|
||||||
syncbuf.Finish()
|
syncbuf.Finish()
|
||||||
|
_ReloadManifest(self)
|
||||||
|
self._ApplyOptions(opt, is_new)
|
||||||
|
|
||||||
if not self.manifest.InitBranch():
|
if not self.manifest.InitBranch():
|
||||||
print >>sys.stderr, 'fatal: cannot create branch in manifest'
|
print >>sys.stderr, 'fatal: cannot create branch in manifest'
|
||||||
|
@ -215,8 +215,9 @@ uncommitted changes are present' % project.relpath
|
|||||||
mp.Sync_LocalHalf(syncbuf)
|
mp.Sync_LocalHalf(syncbuf)
|
||||||
if not syncbuf.Finish():
|
if not syncbuf.Finish():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
_ReloadManifest(self)
|
||||||
|
mp = self.manifest.manifestProject
|
||||||
|
|
||||||
self.GetManifest(reparse=True)
|
|
||||||
all = self.GetProjects(args, missing_ok=True)
|
all = self.GetProjects(args, missing_ok=True)
|
||||||
missing = []
|
missing = []
|
||||||
for project in all:
|
for project in all:
|
||||||
@ -243,6 +244,13 @@ uncommitted changes are present' % project.relpath
|
|||||||
if not syncbuf.Finish():
|
if not syncbuf.Finish():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def _ReloadManifest(cmd):
|
||||||
|
old = cmd.manifest
|
||||||
|
new = cmd.GetManifest(reparse=True)
|
||||||
|
|
||||||
|
if old.__class__ != new.__class__:
|
||||||
|
print >>sys.stderr, 'NOTICE: manifest format has changed ***'
|
||||||
|
new.Upgrade_Local(old)
|
||||||
|
|
||||||
def _PostRepoUpgrade(manifest):
|
def _PostRepoUpgrade(manifest):
|
||||||
for project in manifest.projects.values():
|
for project in manifest.projects.values():
|
||||||
|
Loading…
Reference in New Issue
Block a user