summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--subcmds/manifest.py37
1 files changed, 35 insertions, 2 deletions
diff --git a/subcmds/manifest.py b/subcmds/manifest.py
index 7a8b2ee8..dcd3df17 100644
--- a/subcmds/manifest.py
+++ b/subcmds/manifest.py
@@ -17,6 +17,7 @@ import os
17import sys 17import sys
18 18
19from command import PagedCommand 19from command import PagedCommand
20from manifest_submodule import SubmoduleManifest
20from manifest_xml import XmlManifest 21from manifest_xml import XmlManifest
21 22
22def _doc(name): 23def _doc(name):
@@ -54,6 +55,9 @@ in a Git repository for use during future 'repo init' invocations.
54 55
55 def _Options(self, p): 56 def _Options(self, p):
56 if isinstance(self.manifest, XmlManifest): 57 if isinstance(self.manifest, XmlManifest):
58 p.add_option('--upgrade',
59 dest='upgrade', action='store_true',
60 help='Upgrade XML manifest to submodule')
57 p.add_option('-r', '--revision-as-HEAD', 61 p.add_option('-r', '--revision-as-HEAD',
58 dest='peg_rev', action='store_true', 62 dest='peg_rev', action='store_true',
59 help='Save revisions as current HEAD') 63 help='Save revisions as current HEAD')
@@ -62,6 +66,11 @@ in a Git repository for use during future 'repo init' invocations.
62 help='File to save the manifest to', 66 help='File to save the manifest to',
63 metavar='-|NAME.xml') 67 metavar='-|NAME.xml')
64 68
69 def WantPager(self, opt):
70 if isinstance(self.manifest, XmlManifest) and opt.upgrade:
71 return False
72 return True
73
65 def _Output(self, opt): 74 def _Output(self, opt):
66 if opt.output_file == '-': 75 if opt.output_file == '-':
67 fd = sys.stdout 76 fd = sys.stdout
@@ -73,12 +82,36 @@ in a Git repository for use during future 'repo init' invocations.
73 if opt.output_file != '-': 82 if opt.output_file != '-':
74 print >>sys.stderr, 'Saved manifest to %s' % opt.output_file 83 print >>sys.stderr, 'Saved manifest to %s' % opt.output_file
75 84
85 def _Upgrade(self):
86 old = self.manifest
87
88 if isinstance(old, SubmoduleManifest):
89 print >>sys.stderr, 'error: already upgraded'
90 sys.exit(1)
91
92 old._Load()
93 for p in old.projects.values():
94 if not os.path.exists(p.gitdir) \
95 or not os.path.exists(p.worktree):
96 print >>sys.stderr, 'fatal: project "%s" missing' % p.relpath
97 sys.exit(1)
98
99 new = SubmoduleManifest(old.repodir)
100 new.FromXml_Local_1(old, checkout=False)
101 new.FromXml_Definition(old)
102 new.FromXml_Local_2(old)
103 print >>sys.stderr, 'upgraded manifest; commit result manually'
104
76 def Execute(self, opt, args): 105 def Execute(self, opt, args):
77 if args: 106 if args:
78 self.Usage() 107 self.Usage()
79 108
80 if isinstance(self.manifest, XmlManifest) \ 109 if isinstance(self.manifest, XmlManifest):
81 and opt.output_file is not None: 110 if opt.upgrade:
111 self._Upgrade()
112 return
113
114 if opt.output_file is not None:
82 self._Output(opt) 115 self._Output(opt)
83 return 116 return
84 117