sync: Use --force-broken to continue other projects

This adds a new flag -f/--force-broken that will allow the rest of
the sync process to continue instead of bailing when a particular
project fails to sync.

Change-Id: I23680f2ee7927410f7ed930b1d469424c9aa246e
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Andrei Warkentin 2010-07-02 17:58:31 -05:00 committed by Shawn O. Pearce
parent a0de6e8eab
commit 5df6de075e

View File

@ -70,6 +70,9 @@ The -s/--smart-sync option can be used to sync to a known good
build as specified by the manifest-server element in the current build as specified by the manifest-server element in the current
manifest. manifest.
The -f/--force-broken option can be used to proceed with syncing
other projects if a project sync fails.
SSH Connections SSH Connections
--------------- ---------------
@ -101,6 +104,9 @@ later is required to fix a server side protocol bug.
""" """
def _Options(self, p, show_smart=True): def _Options(self, p, show_smart=True):
p.add_option('-f', '--force-broken',
dest='force_broken', action='store_true',
help="continue sync even if a project fails to sync")
p.add_option('-l','--local-only', p.add_option('-l','--local-only',
dest='local_only', action='store_true', dest='local_only', action='store_true',
help="only update working tree, don't fetch") help="only update working tree, don't fetch")
@ -132,8 +138,11 @@ later is required to fix a server side protocol bug.
def _FetchHelper(self, opt, project, lock, fetched, pm, sem): def _FetchHelper(self, opt, project, lock, fetched, pm, sem):
if not project.Sync_NetworkHalf(quiet=opt.quiet): if not project.Sync_NetworkHalf(quiet=opt.quiet):
print >>sys.stderr, 'error: Cannot fetch %s' % project.name print >>sys.stderr, 'error: Cannot fetch %s' % project.name
sem.release() if opt.force_broken:
sys.exit(1) print >>sys.stderr, 'warn: --force-broken, continuing to sync'
else:
sem.release()
sys.exit(1)
lock.acquire() lock.acquire()
fetched.add(project.gitdir) fetched.add(project.gitdir)
@ -152,7 +161,10 @@ later is required to fix a server side protocol bug.
fetched.add(project.gitdir) fetched.add(project.gitdir)
else: else:
print >>sys.stderr, 'error: Cannot fetch %s' % project.name print >>sys.stderr, 'error: Cannot fetch %s' % project.name
sys.exit(1) if opt.force_broken:
print >>sys.stderr, 'warn: --force-broken, continuing to sync'
else:
sys.exit(1)
else: else:
threads = set() threads = set()
lock = _threading.Lock() lock = _threading.Lock()