summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/download.py3
-rw-r--r--subcmds/forall.py6
-rw-r--r--subcmds/help.py3
-rw-r--r--subcmds/init.py78
-rw-r--r--subcmds/manifest.py81
-rw-r--r--subcmds/selfupdate.py1
-rw-r--r--subcmds/sync.py19
-rw-r--r--subcmds/upload.py22
8 files changed, 162 insertions, 51 deletions
diff --git a/subcmds/download.py b/subcmds/download.py
index a6f3aa45..61eadd54 100644
--- a/subcmds/download.py
+++ b/subcmds/download.py
@@ -36,6 +36,9 @@ makes it available in your project's local working directory.
36 pass 36 pass
37 37
38 def _ParseChangeIds(self, args): 38 def _ParseChangeIds(self, args):
39 if not args:
40 self.Usage()
41
39 to_get = [] 42 to_get = []
40 project = None 43 project = None
41 44
diff --git a/subcmds/forall.py b/subcmds/forall.py
index b66313d7..6bd867e7 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -169,6 +169,12 @@ terminal and are not redirected.
169 else: 169 else:
170 cwd = project.worktree 170 cwd = project.worktree
171 171
172 if not os.path.exists(cwd):
173 if (opt.project_header and opt.verbose) \
174 or not opt.project_header:
175 print >>sys.stderr, 'skipping %s/' % project.relpath
176 continue
177
172 if opt.project_header: 178 if opt.project_header:
173 stdin = subprocess.PIPE 179 stdin = subprocess.PIPE
174 stdout = subprocess.PIPE 180 stdout = subprocess.PIPE
diff --git a/subcmds/help.py b/subcmds/help.py
index c5979fd6..e2f3074c 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -94,6 +94,8 @@ See 'repo help --all' for a complete list of recognized commands.
94 body = getattr(cmd, bodyAttr) 94 body = getattr(cmd, bodyAttr)
95 except AttributeError: 95 except AttributeError:
96 return 96 return
97 if body == '' or body is None:
98 return
97 99
98 self.nl() 100 self.nl()
99 101
@@ -163,6 +165,7 @@ See 'repo help --all' for a complete list of recognized commands.
163 print >>sys.stderr, "repo: '%s' is not a repo command." % name 165 print >>sys.stderr, "repo: '%s' is not a repo command." % name
164 sys.exit(1) 166 sys.exit(1)
165 167
168 cmd.repodir = self.repodir
166 self._PrintCommandHelp(cmd) 169 self._PrintCommandHelp(cmd)
167 170
168 else: 171 else:
diff --git a/subcmds/init.py b/subcmds/init.py
index 75a58f11..cdbbfdf7 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -21,6 +21,9 @@ from command import InteractiveCommand, MirrorSafeCommand
21from error import ManifestParseError 21from error import ManifestParseError
22from project import SyncBuffer 22from project import SyncBuffer
23from git_command import git_require, MIN_GIT_VERSION 23from git_command import git_require, MIN_GIT_VERSION
24from manifest_submodule import SubmoduleManifest
25from manifest_xml import XmlManifest
26from subcmds.sync import _ReloadManifest
24 27
25class Init(InteractiveCommand, MirrorSafeCommand): 28class Init(InteractiveCommand, MirrorSafeCommand):
26 common = True 29 common = True
@@ -37,10 +40,6 @@ current working directory.
37The optional -b argument can be used to select the manifest branch 40The optional -b argument can be used to select the manifest branch
38to checkout and use. If no branch is specified, master is assumed. 41to checkout and use. If no branch is specified, master is assumed.
39 42
40The optional -m argument can be used to specify an alternate manifest
41to be used. If no manifest is specified, the manifest default.xml
42will be used.
43
44Switching Manifest Branches 43Switching Manifest Branches
45--------------------------- 44---------------------------
46 45
@@ -65,9 +64,15 @@ to update the working directory files.
65 g.add_option('-b', '--manifest-branch', 64 g.add_option('-b', '--manifest-branch',
66 dest='manifest_branch', 65 dest='manifest_branch',
67 help='manifest branch or revision', metavar='REVISION') 66 help='manifest branch or revision', metavar='REVISION')
68 g.add_option('-m', '--manifest-name', 67 g.add_option('-o', '--origin',
69 dest='manifest_name', default='default.xml', 68 dest='manifest_origin',
70 help='initial manifest file', metavar='NAME.xml') 69 help="use REMOTE instead of 'origin' to track upstream",
70 metavar='REMOTE')
71 if isinstance(self.manifest, XmlManifest) \
72 or not self.manifest.manifestProject.Exists:
73 g.add_option('-m', '--manifest-name',
74 dest='manifest_name', default='default.xml',
75 help='initial manifest file', metavar='NAME.xml')
71 g.add_option('--mirror', 76 g.add_option('--mirror',
72 dest='mirror', action='store_true', 77 dest='mirror', action='store_true',
73 help='mirror the forrest') 78 help='mirror the forrest')
@@ -85,30 +90,42 @@ to update the working directory files.
85 dest='no_repo_verify', action='store_true', 90 dest='no_repo_verify', action='store_true',
86 help='do not verify repo source code') 91 help='do not verify repo source code')
87 92
88 def _SyncManifest(self, opt): 93 def _ApplyOptions(self, opt, is_new):
89 m = self.manifest.manifestProject 94 m = self.manifest.manifestProject
90 is_new = not m.Exists
91 95
92 if is_new: 96 if is_new:
93 if not opt.manifest_url: 97 if opt.manifest_origin:
94 print >>sys.stderr, 'fatal: manifest url (-u) is required.' 98 m.remote.name = opt.manifest_origin
95 sys.exit(1)
96
97 if not opt.quiet:
98 print >>sys.stderr, 'Getting manifest ...'
99 print >>sys.stderr, ' from %s' % opt.manifest_url
100 m._InitGitDir()
101 99
102 if opt.manifest_branch: 100 if opt.manifest_branch:
103 m.revisionExpr = opt.manifest_branch 101 m.revisionExpr = opt.manifest_branch
104 else: 102 else:
105 m.revisionExpr = 'refs/heads/master' 103 m.revisionExpr = 'refs/heads/master'
106 else: 104 else:
105 if opt.manifest_origin:
106 print >>sys.stderr, 'fatal: cannot change origin name'
107 sys.exit(1)
108
107 if opt.manifest_branch: 109 if opt.manifest_branch:
108 m.revisionExpr = opt.manifest_branch 110 m.revisionExpr = opt.manifest_branch
109 else: 111 else:
110 m.PreSync() 112 m.PreSync()
111 113
114 def _SyncManifest(self, opt):
115 m = self.manifest.manifestProject
116 is_new = not m.Exists
117
118 if is_new:
119 if not opt.manifest_url:
120 print >>sys.stderr, 'fatal: manifest url (-u) is required.'
121 sys.exit(1)
122
123 if not opt.quiet:
124 print >>sys.stderr, 'Getting manifest ...'
125 print >>sys.stderr, ' from %s' % opt.manifest_url
126 m._InitGitDir()
127
128 self._ApplyOptions(opt, is_new)
112 if opt.manifest_url: 129 if opt.manifest_url:
113 r = m.GetRemote(m.remote.name) 130 r = m.GetRemote(m.remote.name)
114 r.url = opt.manifest_url 131 r.url = opt.manifest_url
@@ -118,6 +135,7 @@ to update the working directory files.
118 if opt.mirror: 135 if opt.mirror:
119 if is_new: 136 if is_new:
120 m.config.SetString('repo.mirror', 'true') 137 m.config.SetString('repo.mirror', 'true')
138 m.config.ClearCache()
121 else: 139 else:
122 print >>sys.stderr, 'fatal: --mirror not supported on existing client' 140 print >>sys.stderr, 'fatal: --mirror not supported on existing client'
123 sys.exit(1) 141 sys.exit(1)
@@ -127,14 +145,29 @@ to update the working directory files.
127 print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url 145 print >>sys.stderr, 'fatal: cannot obtain manifest %s' % r.url
128 sys.exit(1) 146 sys.exit(1)
129 147
148 if is_new and SubmoduleManifest.IsBare(m):
149 new = self.GetManifest(reparse=True, type=SubmoduleManifest)
150 if m.gitdir != new.manifestProject.gitdir:
151 os.rename(m.gitdir, new.manifestProject.gitdir)
152 new = self.GetManifest(reparse=True, type=SubmoduleManifest)
153 m = new.manifestProject
154 self._ApplyOptions(opt, is_new)
155
156 if not is_new:
157 # Force the manifest to load if it exists, the old graph
158 # may be needed inside of _ReloadManifest().
159 #
160 self.manifest.projects
161
130 syncbuf = SyncBuffer(m.config) 162 syncbuf = SyncBuffer(m.config)
131 m.Sync_LocalHalf(syncbuf) 163 m.Sync_LocalHalf(syncbuf)
132 syncbuf.Finish() 164 syncbuf.Finish()
165 _ReloadManifest(self)
166 self._ApplyOptions(opt, is_new)
133 167
134 if is_new or m.CurrentBranch is None: 168 if not self.manifest.InitBranch():
135 if not m.StartBranch('default'): 169 print >>sys.stderr, 'fatal: cannot create branch in manifest'
136 print >>sys.stderr, 'fatal: cannot create default in manifest' 170 sys.exit(1)
137 sys.exit(1)
138 171
139 def _LinkManifest(self, name): 172 def _LinkManifest(self, name):
140 if not name: 173 if not name:
@@ -216,7 +249,8 @@ to update the working directory files.
216 def Execute(self, opt, args): 249 def Execute(self, opt, args):
217 git_require(MIN_GIT_VERSION, fail=True) 250 git_require(MIN_GIT_VERSION, fail=True)
218 self._SyncManifest(opt) 251 self._SyncManifest(opt)
219 self._LinkManifest(opt.manifest_name) 252 if isinstance(self.manifest, XmlManifest):
253 self._LinkManifest(opt.manifest_name)
220 254
221 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: 255 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
222 self._ConfigureUser() 256 self._ConfigureUser()
diff --git a/subcmds/manifest.py b/subcmds/manifest.py
index 4374a9d0..dcd3df17 100644
--- a/subcmds/manifest.py
+++ b/subcmds/manifest.py
@@ -17,14 +17,25 @@ import os
17import sys 17import sys
18 18
19from command import PagedCommand 19from command import PagedCommand
20from manifest_submodule import SubmoduleManifest
21from manifest_xml import XmlManifest
22
23def _doc(name):
24 r = os.path.dirname(__file__)
25 r = os.path.dirname(r)
26 fd = open(os.path.join(r, 'docs', name))
27 try:
28 return fd.read()
29 finally:
30 fd.close()
20 31
21class Manifest(PagedCommand): 32class Manifest(PagedCommand):
22 common = False 33 common = False
23 helpSummary = "Manifest inspection utility" 34 helpSummary = "Manifest inspection utility"
24 helpUsage = """ 35 helpUsage = """
25%prog [-o {-|NAME.xml} [-r]] 36%prog [options]
26""" 37"""
27 _helpDescription = """ 38 _xmlHelp = """
28 39
29With the -o option, exports the current manifest for inspection. 40With the -o option, exports the current manifest for inspection.
30The manifest and (if present) local_manifest.xml are combined 41The manifest and (if present) local_manifest.xml are combined
@@ -35,23 +46,30 @@ in a Git repository for use during future 'repo init' invocations.
35 46
36 @property 47 @property
37 def helpDescription(self): 48 def helpDescription(self):
38 help = self._helpDescription + '\n' 49 help = ''
39 r = os.path.dirname(__file__) 50 if isinstance(self.manifest, XmlManifest):
40 r = os.path.dirname(r) 51 help += self._xmlHelp + '\n' + _doc('manifest_xml.txt')
41 fd = open(os.path.join(r, 'docs', 'manifest-format.txt')) 52 if isinstance(self.manifest, SubmoduleManifest):
42 for line in fd: 53 help += _doc('manifest_submodule.txt')
43 help += line
44 fd.close()
45 return help 54 return help
46 55
47 def _Options(self, p): 56 def _Options(self, p):
48 p.add_option('-r', '--revision-as-HEAD', 57 if isinstance(self.manifest, XmlManifest):
49 dest='peg_rev', action='store_true', 58 p.add_option('--upgrade',
50 help='Save revisions as current HEAD') 59 dest='upgrade', action='store_true',
51 p.add_option('-o', '--output-file', 60 help='Upgrade XML manifest to submodule')
52 dest='output_file', 61 p.add_option('-r', '--revision-as-HEAD',
53 help='File to save the manifest to', 62 dest='peg_rev', action='store_true',
54 metavar='-|NAME.xml') 63 help='Save revisions as current HEAD')
64 p.add_option('-o', '--output-file',
65 dest='output_file',
66 help='File to save the manifest to',
67 metavar='-|NAME.xml')
68
69 def WantPager(self, opt):
70 if isinstance(self.manifest, XmlManifest) and opt.upgrade:
71 return False
72 return True
55 73
56 def _Output(self, opt): 74 def _Output(self, opt):
57 if opt.output_file == '-': 75 if opt.output_file == '-':
@@ -64,13 +82,38 @@ in a Git repository for use during future 'repo init' invocations.
64 if opt.output_file != '-': 82 if opt.output_file != '-':
65 print >>sys.stderr, 'Saved manifest to %s' % opt.output_file 83 print >>sys.stderr, 'Saved manifest to %s' % opt.output_file
66 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
67 def Execute(self, opt, args): 105 def Execute(self, opt, args):
68 if args: 106 if args:
69 self.Usage() 107 self.Usage()
70 108
71 if opt.output_file is not None: 109 if isinstance(self.manifest, XmlManifest):
72 self._Output(opt) 110 if opt.upgrade:
73 return 111 self._Upgrade()
112 return
113
114 if opt.output_file is not None:
115 self._Output(opt)
116 return
74 117
75 print >>sys.stderr, 'error: no operation to perform' 118 print >>sys.stderr, 'error: no operation to perform'
76 print >>sys.stderr, 'error: see repo help manifest' 119 print >>sys.stderr, 'error: see repo help manifest'
diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py
index 4f46a129..46aa3a19 100644
--- a/subcmds/selfupdate.py
+++ b/subcmds/selfupdate.py
@@ -55,6 +55,7 @@ need to be performed by an end-user.
55 print >>sys.stderr, "error: can't update repo" 55 print >>sys.stderr, "error: can't update repo"
56 sys.exit(1) 56 sys.exit(1)
57 57
58 rp.bare_git.gc('--auto')
58 _PostRepoFetch(rp, 59 _PostRepoFetch(rp,
59 no_repo_verify = opt.no_repo_verify, 60 no_repo_verify = opt.no_repo_verify,
60 verbose = True) 61 verbose = True)
diff --git a/subcmds/sync.py b/subcmds/sync.py
index ceb81eaa..d89c2b8c 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -117,6 +117,8 @@ later is required to fix a server side protocol bug.
117 print >>sys.stderr, 'error: Cannot fetch %s' % project.name 117 print >>sys.stderr, 'error: Cannot fetch %s' % project.name
118 sys.exit(1) 118 sys.exit(1)
119 pm.end() 119 pm.end()
120 for project in projects:
121 project.bare_git.gc('--auto')
120 return fetched 122 return fetched
121 123
122 def UpdateProjectList(self): 124 def UpdateProjectList(self):
@@ -215,7 +217,14 @@ uncommitted changes are present' % project.relpath
215 # bail out now; the rest touches the working tree 217 # bail out now; the rest touches the working tree
216 return 218 return
217 219
218 self.manifest._Unload() 220 if mp.HasChanges:
221 syncbuf = SyncBuffer(mp.config)
222 mp.Sync_LocalHalf(syncbuf)
223 if not syncbuf.Finish():
224 sys.exit(1)
225 _ReloadManifest(self)
226 mp = self.manifest.manifestProject
227
219 all = self.GetProjects(args, missing_ok=True) 228 all = self.GetProjects(args, missing_ok=True)
220 missing = [] 229 missing = []
221 for project in all: 230 for project in all:
@@ -242,6 +251,14 @@ uncommitted changes are present' % project.relpath
242 if not syncbuf.Finish(): 251 if not syncbuf.Finish():
243 sys.exit(1) 252 sys.exit(1)
244 253
254def _ReloadManifest(cmd):
255 old = cmd.manifest
256 new = cmd.GetManifest(reparse=True)
257
258 if old.__class__ != new.__class__:
259 print >>sys.stderr, 'NOTICE: manifest format has changed ***'
260 new.Upgrade_Local(old)
261
245def _PostRepoUpgrade(manifest): 262def _PostRepoUpgrade(manifest):
246 for project in manifest.projects.values(): 263 for project in manifest.projects.values():
247 if project.Exists: 264 if project.Exists:
diff --git a/subcmds/upload.py b/subcmds/upload.py
index aea399b6..2ab6a484 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -55,11 +55,11 @@ added to the respective list of users, and emails are sent to any
55new users. Users passed as --reviewers must already be registered 55new users. Users passed as --reviewers must already be registered
56with the code review system, or the upload will fail. 56with the code review system, or the upload will fail.
57 57
58If the --replace option is passed the user can designate which 58If the --replace option (deprecated) is passed the user can designate
59existing change(s) in Gerrit match up to the commits in the branch 59which existing change(s) in Gerrit match up to the commits in the
60being uploaded. For each matched pair of change,commit the commit 60branch being uploaded. For each matched pair of change,commit the
61will be added as a new patch set, completely replacing the set of 61commit will be added as a new patch set, completely replacing the
62files and description associated with the change in Gerrit. 62set of files and description associated with the change in Gerrit.
63 63
64Configuration 64Configuration
65------------- 65-------------
@@ -92,7 +92,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
92 def _Options(self, p): 92 def _Options(self, p):
93 p.add_option('--replace', 93 p.add_option('--replace',
94 dest='replace', action='store_true', 94 dest='replace', action='store_true',
95 help='Upload replacement patchesets from this branch') 95 help='Upload replacement patchsets from this branch (deprecated)')
96 p.add_option('--re', '--reviewers', 96 p.add_option('--re', '--reviewers',
97 type='string', action='append', dest='reviewers', 97 type='string', action='append', dest='reviewers',
98 help='Request reviews from these people.') 98 help='Request reviews from these people.')
@@ -273,15 +273,19 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
273 have_errors = True 273 have_errors = True
274 274
275 print >>sys.stderr, '' 275 print >>sys.stderr, ''
276 print >>sys.stderr, '--------------------------------------------' 276 print >>sys.stderr, '----------------------------------------------------------------------'
277 277
278 if have_errors: 278 if have_errors:
279 for branch in todo: 279 for branch in todo:
280 if not branch.uploaded: 280 if not branch.uploaded:
281 print >>sys.stderr, '[FAILED] %-15s %-15s (%s)' % ( 281 if len(str(branch.error)) <= 30:
282 fmt = ' (%s)'
283 else:
284 fmt = '\n (%s)'
285 print >>sys.stderr, ('[FAILED] %-15s %-15s' + fmt) % (
282 branch.project.relpath + '/', \ 286 branch.project.relpath + '/', \
283 branch.name, \ 287 branch.name, \
284 branch.error) 288 str(branch.error))
285 print >>sys.stderr, '' 289 print >>sys.stderr, ''
286 290
287 for branch in todo: 291 for branch in todo: