summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/branches.py2
-rw-r--r--subcmds/init.py21
-rw-r--r--subcmds/sync.py13
-rw-r--r--subcmds/upload.py5
4 files changed, 33 insertions, 8 deletions
diff --git a/subcmds/branches.py b/subcmds/branches.py
index c2e7c4b9..f714c1e8 100644
--- a/subcmds/branches.py
+++ b/subcmds/branches.py
@@ -139,7 +139,7 @@ is shown, then the branch appears in all projects.
139 if in_cnt < project_cnt: 139 if in_cnt < project_cnt:
140 fmt = out.write 140 fmt = out.write
141 paths = [] 141 paths = []
142 if in_cnt < project_cnt - in_cnt: 142 if in_cnt < project_cnt - in_cnt:
143 in_type = 'in' 143 in_type = 'in'
144 for b in i.projects: 144 for b in i.projects:
145 paths.append(b.project.relpath) 145 paths.append(b.project.relpath)
diff --git a/subcmds/init.py b/subcmds/init.py
index a44fb7a9..b1fcb69c 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -99,6 +99,10 @@ to update the working directory files.
99 g.add_option('--depth', type='int', default=None, 99 g.add_option('--depth', type='int', default=None,
100 dest='depth', 100 dest='depth',
101 help='create a shallow clone with given depth; see git clone') 101 help='create a shallow clone with given depth; see git clone')
102 g.add_option('--archive',
103 dest='archive', action='store_true',
104 help='checkout an archive instead of a git repository for '
105 'each project. See git archive.')
102 g.add_option('-g', '--groups', 106 g.add_option('-g', '--groups',
103 dest='groups', default='default', 107 dest='groups', default='default',
104 help='restrict manifest projects to ones with specified ' 108 help='restrict manifest projects to ones with specified '
@@ -198,6 +202,16 @@ to update the working directory files.
198 if opt.reference: 202 if opt.reference:
199 m.config.SetString('repo.reference', opt.reference) 203 m.config.SetString('repo.reference', opt.reference)
200 204
205 if opt.archive:
206 if is_new:
207 m.config.SetString('repo.archive', 'true')
208 else:
209 print('fatal: --archive is only supported when initializing a new '
210 'workspace.', file=sys.stderr)
211 print('Either delete the .repo folder in this workspace, or initialize '
212 'in another location.', file=sys.stderr)
213 sys.exit(1)
214
201 if opt.mirror: 215 if opt.mirror:
202 if is_new: 216 if is_new:
203 m.config.SetString('repo.mirror', 'true') 217 m.config.SetString('repo.mirror', 'true')
@@ -366,6 +380,13 @@ to update the working directory files.
366 if opt.reference: 380 if opt.reference:
367 opt.reference = os.path.expanduser(opt.reference) 381 opt.reference = os.path.expanduser(opt.reference)
368 382
383 # Check this here, else manifest will be tagged "not new" and init won't be
384 # possible anymore without removing the .repo/manifests directory.
385 if opt.archive and opt.mirror:
386 print('fatal: --mirror and --archive cannot be used together.',
387 file=sys.stderr)
388 sys.exit(1)
389
369 self._SyncManifest(opt) 390 self._SyncManifest(opt)
370 self._LinkManifest(opt.manifest_name) 391 self._LinkManifest(opt.manifest_name)
371 392
diff --git a/subcmds/sync.py b/subcmds/sync.py
index d1a06412..5e7385db 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -272,7 +272,7 @@ later is required to fix a server side protocol bug.
272 quiet=opt.quiet, 272 quiet=opt.quiet,
273 current_branch_only=opt.current_branch_only, 273 current_branch_only=opt.current_branch_only,
274 clone_bundle=not opt.no_clone_bundle, 274 clone_bundle=not opt.no_clone_bundle,
275 no_tags=opt.no_tags) 275 no_tags=opt.no_tags, archive=self.manifest.IsArchive)
276 self._fetch_times.Set(project, time.time() - start) 276 self._fetch_times.Set(project, time.time() - start)
277 277
278 # Lock around all the rest of the code, since printing, updating a set 278 # Lock around all the rest of the code, since printing, updating a set
@@ -315,7 +315,8 @@ later is required to fix a server side protocol bug.
315 quiet=opt.quiet, 315 quiet=opt.quiet,
316 current_branch_only=opt.current_branch_only, 316 current_branch_only=opt.current_branch_only,
317 clone_bundle=not opt.no_clone_bundle, 317 clone_bundle=not opt.no_clone_bundle,
318 no_tags=opt.no_tags): 318 no_tags=opt.no_tags,
319 archive=self.manifest.IsArchive):
319 fetched.add(project.gitdir) 320 fetched.add(project.gitdir)
320 else: 321 else:
321 print('error: Cannot fetch %s' % project.name, file=sys.stderr) 322 print('error: Cannot fetch %s' % project.name, file=sys.stderr)
@@ -363,7 +364,9 @@ later is required to fix a server side protocol bug.
363 pm.end() 364 pm.end()
364 self._fetch_times.Save() 365 self._fetch_times.Save()
365 366
366 self._GCProjects(projects) 367 if not self.manifest.IsArchive:
368 self._GCProjects(projects)
369
367 return fetched 370 return fetched
368 371
369 def _GCProjects(self, projects): 372 def _GCProjects(self, projects):
@@ -671,7 +674,7 @@ later is required to fix a server side protocol bug.
671 previously_missing_set = missing_set 674 previously_missing_set = missing_set
672 fetched.update(self._Fetch(missing, opt)) 675 fetched.update(self._Fetch(missing, opt))
673 676
674 if self.manifest.IsMirror: 677 if self.manifest.IsMirror or self.manifest.IsArchive:
675 # bail out now, we have no working tree 678 # bail out now, we have no working tree
676 return 679 return
677 680
@@ -791,7 +794,7 @@ class _FetchTimes(object):
791 def _Load(self): 794 def _Load(self):
792 if self._times is None: 795 if self._times is None:
793 try: 796 try:
794 f = open(self._path) 797 f = open(self._path, 'rb')
795 except IOError: 798 except IOError:
796 self._times = {} 799 self._times = {}
797 return self._times 800 return self._times
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 9ad55d79..56212408 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -349,8 +349,9 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
349 349
350 # Make sure our local branch is not setup to track a different remote branch 350 # Make sure our local branch is not setup to track a different remote branch
351 merge_branch = self._GetMergeBranch(branch.project) 351 merge_branch = self._GetMergeBranch(branch.project)
352 full_dest = 'refs/heads/%s' % destination 352 if destination:
353 if not opt.dest_branch and merge_branch and merge_branch != full_dest: 353 full_dest = 'refs/heads/%s' % destination
354 if not opt.dest_branch and merge_branch and merge_branch != full_dest:
354 print('merge branch %s does not match destination branch %s' 355 print('merge branch %s does not match destination branch %s'
355 % (merge_branch, full_dest)) 356 % (merge_branch, full_dest))
356 print('skipping upload.') 357 print('skipping upload.')