diff options
author | Shawn O. Pearce <sop@google.com> | 2009-07-03 16:37:30 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-07-03 20:50:52 -0700 |
commit | 87bda12e85ffb98778d7ac881edb0210b74c0491 (patch) | |
tree | ccdbd92a16ccb4fe9409ee5b864c0e02412e942a | |
parent | 5f947bba69de81f58f1adef10225c04727fa0ed5 (diff) | |
download | git-repo-87bda12e85ffb98778d7ac881edb0210b74c0491.tar.gz |
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>
-rw-r--r-- | manifest.py | 4 | ||||
-rw-r--r-- | subcmds/init.py | 9 | ||||
-rw-r--r-- | subcmds/sync.py | 10 |
3 files changed, 22 insertions, 1 deletions
diff --git a/manifest.py b/manifest.py index a2fc9601..f737e866 100644 --- a/manifest.py +++ b/manifest.py | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | import os | 16 | import os |
17 | 17 | ||
18 | from error import ManifestParseError | ||
18 | from editor import Editor | 19 | from editor import Editor |
19 | from git_config import GitConfig | 20 | from git_config import GitConfig |
20 | from project import MetaProject | 21 | from project import MetaProject |
@@ -45,3 +46,6 @@ class Manifest(object): | |||
45 | 46 | ||
46 | def SetMRefs(self, project): | 47 | def SetMRefs(self, project): |
47 | pass | 48 | pass |
49 | |||
50 | def Upgrade_Local(self, old): | ||
51 | raise ManifestParseError, 'unsupported upgrade path' | ||
diff --git a/subcmds/init.py b/subcmds/init.py index 53c3a010..b5207fbf 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -22,6 +22,7 @@ from error import ManifestParseError | |||
22 | from project import SyncBuffer | 22 | from project import SyncBuffer |
23 | from git_command import git_require, MIN_GIT_VERSION | 23 | from git_command import git_require, MIN_GIT_VERSION |
24 | from manifest_xml import XmlManifest | 24 | from manifest_xml import XmlManifest |
25 | from subcmds.sync import _ReloadManifest | ||
25 | 26 | ||
26 | class Init(InteractiveCommand, MirrorSafeCommand): | 27 | class Init(InteractiveCommand, MirrorSafeCommand): |
27 | common = True | 28 | common = True |
@@ -143,9 +144,17 @@ to update the working directory files. | |||
143 | print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url | 144 | print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url |
144 | sys.exit(1) | 145 | sys.exit(1) |
145 | 146 | ||
147 | if not is_new: | ||
148 | # Force the manifest to load if it exists, the old graph | ||
149 | # may be needed inside of _ReloadManifest(). | ||
150 | # | ||
151 | self.manifest.projects | ||
152 | |||
146 | syncbuf = SyncBuffer(m.config) | 153 | syncbuf = SyncBuffer(m.config) |
147 | m.Sync_LocalHalf(syncbuf) | 154 | m.Sync_LocalHalf(syncbuf) |
148 | syncbuf.Finish() | 155 | syncbuf.Finish() |
156 | _ReloadManifest(self) | ||
157 | self._ApplyOptions(opt, is_new) | ||
149 | 158 | ||
150 | if not self.manifest.InitBranch(): | 159 | if not self.manifest.InitBranch(): |
151 | print >>sys.stderr, 'fatal: cannot create branch in manifest' | 160 | print >>sys.stderr, 'fatal: cannot create branch in manifest' |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 1537c9a2..5fc834d0 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -215,8 +215,9 @@ uncommitted changes are present' % project.relpath | |||
215 | mp.Sync_LocalHalf(syncbuf) | 215 | mp.Sync_LocalHalf(syncbuf) |
216 | if not syncbuf.Finish(): | 216 | if not syncbuf.Finish(): |
217 | sys.exit(1) | 217 | sys.exit(1) |
218 | _ReloadManifest(self) | ||
219 | mp = self.manifest.manifestProject | ||
218 | 220 | ||
219 | self.GetManifest(reparse=True) | ||
220 | all = self.GetProjects(args, missing_ok=True) | 221 | all = self.GetProjects(args, missing_ok=True) |
221 | missing = [] | 222 | missing = [] |
222 | for project in all: | 223 | for project in all: |
@@ -243,6 +244,13 @@ uncommitted changes are present' % project.relpath | |||
243 | if not syncbuf.Finish(): | 244 | if not syncbuf.Finish(): |
244 | sys.exit(1) | 245 | sys.exit(1) |
245 | 246 | ||
247 | def _ReloadManifest(cmd): | ||
248 | old = cmd.manifest | ||
249 | new = cmd.GetManifest(reparse=True) | ||
250 | |||
251 | if old.__class__ != new.__class__: | ||
252 | print >>sys.stderr, 'NOTICE: manifest format has changed ***' | ||
253 | new.Upgrade_Local(old) | ||
246 | 254 | ||
247 | def _PostRepoUpgrade(manifest): | 255 | def _PostRepoUpgrade(manifest): |
248 | for project in manifest.projects.values(): | 256 | for project in manifest.projects.values(): |