summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/grep.py2
-rw-r--r--subcmds/init.py25
-rw-r--r--subcmds/sync.py36
-rw-r--r--subcmds/upload.py2
4 files changed, 30 insertions, 35 deletions
diff --git a/subcmds/grep.py b/subcmds/grep.py
index 0dc8f9f6..b067629a 100644
--- a/subcmds/grep.py
+++ b/subcmds/grep.py
@@ -51,7 +51,7 @@ Examples
51 51
52Look for a line that has '#define' and either 'MAX_PATH or 'PATH_MAX': 52Look for a line that has '#define' and either 'MAX_PATH or 'PATH_MAX':
53 53
54 repo grep -e '#define' --and -\( -e MAX_PATH -e PATH_MAX \) 54 repo grep -e '#define' --and -\\( -e MAX_PATH -e PATH_MAX \\)
55 55
56Look for a line that has 'NODE' or 'Unexpected' in files that 56Look for a line that has 'NODE' or 'Unexpected' in files that
57contain a line that matches both expressions: 57contain a line that matches both expressions:
diff --git a/subcmds/init.py b/subcmds/init.py
index b6b98076..48df9e89 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -147,7 +147,7 @@ to update the working directory files.
147 r.ResetFetch() 147 r.ResetFetch()
148 r.Save() 148 r.Save()
149 149
150 groups = re.split('[,\s]+', opt.groups) 150 groups = re.split(r'[,\s]+', opt.groups)
151 all_platforms = ['linux', 'darwin'] 151 all_platforms = ['linux', 'darwin']
152 platformize = lambda x: 'platform-' + x 152 platformize = lambda x: 'platform-' + x
153 if opt.platform == 'auto': 153 if opt.platform == 'auto':
@@ -313,6 +313,21 @@ to update the working directory files.
313 # We store the depth in the main manifest project. 313 # We store the depth in the main manifest project.
314 self.manifest.manifestProject.config.SetString('repo.depth', depth) 314 self.manifest.manifestProject.config.SetString('repo.depth', depth)
315 315
316 def _DisplayResult(self):
317 if self.manifest.IsMirror:
318 init_type = 'mirror '
319 else:
320 init_type = ''
321
322 print ''
323 print 'repo %shas been initialized in %s' % (init_type, self.manifest.topdir)
324
325 current_dir = os.getcwd()
326 if current_dir != self.manifest.topdir:
327 print 'If this is not the directory in which you want to initialize repo, please run:'
328 print ' rm -r %s/.repo' % self.manifest.topdir
329 print 'and try again.'
330
316 def Execute(self, opt, args): 331 def Execute(self, opt, args):
317 git_require(MIN_GIT_VERSION, fail=True) 332 git_require(MIN_GIT_VERSION, fail=True)
318 333
@@ -329,10 +344,4 @@ to update the working directory files.
329 344
330 self._ConfigureDepth(opt) 345 self._ConfigureDepth(opt)
331 346
332 if self.manifest.IsMirror: 347 self._DisplayResult()
333 init_type = 'mirror '
334 else:
335 init_type = ''
336
337 print ''
338 print 'repo %sinitialized in %s' % (init_type, self.manifest.topdir)
diff --git a/subcmds/sync.py b/subcmds/sync.py
index a4ca344a..15f69f7b 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -44,8 +44,9 @@ try:
44except ImportError: 44except ImportError:
45 multiprocessing = None 45 multiprocessing = None
46 46
47from git_command import GIT 47from git_command import GIT, git_require
48from git_refs import R_HEADS, HEAD 48from git_refs import R_HEADS, HEAD
49from main import WrapperModule
49from project import Project 50from project import Project
50from project import RemoteSpec 51from project import RemoteSpec
51from command import Command, MirrorSafeCommand 52from command import Command, MirrorSafeCommand
@@ -309,7 +310,8 @@ later is required to fix a server side protocol bug.
309 return fetched 310 return fetched
310 311
311 def _GCProjects(self, projects): 312 def _GCProjects(self, projects):
312 if multiprocessing: 313 has_dash_c = git_require((1, 7, 2))
314 if multiprocessing and has_dash_c:
313 cpu_count = multiprocessing.cpu_count() 315 cpu_count = multiprocessing.cpu_count()
314 else: 316 else:
315 cpu_count = 1 317 cpu_count = 1
@@ -537,7 +539,7 @@ uncommitted changes are present' % project.relpath
537 mp.PreSync() 539 mp.PreSync()
538 540
539 if opt.repo_upgraded: 541 if opt.repo_upgraded:
540 _PostRepoUpgrade(self.manifest) 542 _PostRepoUpgrade(self.manifest, quiet=opt.quiet)
541 543
542 if not opt.local_only: 544 if not opt.local_only:
543 mp.Sync_NetworkHalf(quiet=opt.quiet, 545 mp.Sync_NetworkHalf(quiet=opt.quiet,
@@ -562,31 +564,12 @@ uncommitted changes are present' % project.relpath
562 to_fetch.extend(all_projects) 564 to_fetch.extend(all_projects)
563 to_fetch.sort(key=self._fetch_times.Get, reverse=True) 565 to_fetch.sort(key=self._fetch_times.Get, reverse=True)
564 566
565 fetched = self._Fetch(to_fetch, opt) 567 self._Fetch(to_fetch, opt)
566 _PostRepoFetch(rp, opt.no_repo_verify) 568 _PostRepoFetch(rp, opt.no_repo_verify)
567 if opt.network_only: 569 if opt.network_only:
568 # bail out now; the rest touches the working tree 570 # bail out now; the rest touches the working tree
569 return 571 return
570 572
571 # Iteratively fetch missing and/or nested unregistered submodules
572 previously_missing_set = set()
573 while True:
574 self.manifest._Unload()
575 all_projects = self.GetProjects(args, missing_ok=True)
576 missing = []
577 for project in all_projects:
578 if project.gitdir not in fetched:
579 missing.append(project)
580 if not missing:
581 break
582 # Stop us from non-stopped fetching actually-missing repos: If set of
583 # missing repos has not been changed from last fetch, we break.
584 missing_set = set(p.name for p in missing)
585 if previously_missing_set == missing_set:
586 break
587 previously_missing_set = missing_set
588 fetched.update(self._Fetch(missing, opt))
589
590 if self.manifest.IsMirror: 573 if self.manifest.IsMirror:
591 # bail out now, we have no working tree 574 # bail out now, we have no working tree
592 return 575 return
@@ -611,7 +594,10 @@ uncommitted changes are present' % project.relpath
611 if self.manifest.notice: 594 if self.manifest.notice:
612 print self.manifest.notice 595 print self.manifest.notice
613 596
614def _PostRepoUpgrade(manifest): 597def _PostRepoUpgrade(manifest, quiet=False):
598 wrapper = WrapperModule()
599 if wrapper.NeedSetupGnuPG():
600 wrapper.SetupGnuPG(quiet)
615 for project in manifest.projects.values(): 601 for project in manifest.projects.values():
616 if project.Exists: 602 if project.Exists:
617 project.PostRepoUpgrade() 603 project.PostRepoUpgrade()
@@ -711,7 +697,7 @@ class _FetchTimes(object):
711 try: 697 try:
712 try: 698 try:
713 self._times = pickle.load(f) 699 self._times = pickle.load(f)
714 except: 700 except IOError:
715 try: 701 try:
716 os.remove(self._path) 702 os.remove(self._path)
717 except OSError: 703 except OSError:
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 84a5e440..39721ac2 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -297,7 +297,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
297 try: 297 try:
298 # refs/changes/XYZ/N --> XYZ 298 # refs/changes/XYZ/N --> XYZ
299 return refs.get(last_pub).split('/')[-2] 299 return refs.get(last_pub).split('/')[-2]
300 except: 300 except (AttributeError, IndexError):
301 return "" 301 return ""
302 302
303 def _UploadAndReport(self, opt, todo, original_people): 303 def _UploadAndReport(self, opt, todo, original_people):