diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-11-14 11:36:51 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-11-14 11:38:57 +0900 |
| commit | c1b86a232383748811c6faf17f364e63e10f7dd4 (patch) | |
| tree | 8f28c8e8a922ffd4165f48a1988500070936bd39 /subcmds | |
| parent | 98ffba1401056e2d88d3f3898b6fbf5d7d3931a4 (diff) | |
| download | git-repo-c1b86a232383748811c6faf17f364e63e10f7dd4.tar.gz | |
Fix inconsistent indentation
The repo coding style is to indent at 2 characters, but there are
many places where this is not followed.
Enable pylint warning "W0311: Bad indentation" and make sure all
indentation is at multiples of 2 characters.
Change-Id: I68f0f64470789ce2429ab11104d15d380a63e6a8
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 168 | ||||
| -rw-r--r-- | subcmds/upload.py | 38 |
2 files changed, 103 insertions, 103 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index a64f2c45..df64ab09 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -197,62 +197,62 @@ later is required to fix a server side protocol bug. | |||
| 197 | help=SUPPRESS_HELP) | 197 | help=SUPPRESS_HELP) |
| 198 | 198 | ||
| 199 | def _FetchHelper(self, opt, project, lock, fetched, pm, sem, err_event): | 199 | def _FetchHelper(self, opt, project, lock, fetched, pm, sem, err_event): |
| 200 | """Main function of the fetch threads when jobs are > 1. | 200 | """Main function of the fetch threads when jobs are > 1. |
| 201 | 201 | ||
| 202 | Args: | 202 | Args: |
| 203 | opt: Program options returned from optparse. See _Options(). | 203 | opt: Program options returned from optparse. See _Options(). |
| 204 | project: Project object for the project to fetch. | 204 | project: Project object for the project to fetch. |
| 205 | lock: Lock for accessing objects that are shared amongst multiple | 205 | lock: Lock for accessing objects that are shared amongst multiple |
| 206 | _FetchHelper() threads. | 206 | _FetchHelper() threads. |
| 207 | fetched: set object that we will add project.gitdir to when we're done | 207 | fetched: set object that we will add project.gitdir to when we're done |
| 208 | (with our lock held). | 208 | (with our lock held). |
| 209 | pm: Instance of a Project object. We will call pm.update() (with our | 209 | pm: Instance of a Project object. We will call pm.update() (with our |
| 210 | lock held). | 210 | lock held). |
| 211 | sem: We'll release() this semaphore when we exit so that another thread | 211 | sem: We'll release() this semaphore when we exit so that another thread |
| 212 | can be started up. | 212 | can be started up. |
| 213 | err_event: We'll set this event in the case of an error (after printing | 213 | err_event: We'll set this event in the case of an error (after printing |
| 214 | out info about the error). | 214 | out info about the error). |
| 215 | """ | 215 | """ |
| 216 | # We'll set to true once we've locked the lock. | 216 | # We'll set to true once we've locked the lock. |
| 217 | did_lock = False | 217 | did_lock = False |
| 218 | 218 | ||
| 219 | # Encapsulate everything in a try/except/finally so that: | 219 | # Encapsulate everything in a try/except/finally so that: |
| 220 | # - We always set err_event in the case of an exception. | 220 | # - We always set err_event in the case of an exception. |
| 221 | # - We always make sure we call sem.release(). | 221 | # - We always make sure we call sem.release(). |
| 222 | # - We always make sure we unlock the lock if we locked it. | 222 | # - We always make sure we unlock the lock if we locked it. |
| 223 | try: | ||
| 223 | try: | 224 | try: |
| 224 | try: | 225 | start = time.time() |
| 225 | start = time.time() | 226 | success = project.Sync_NetworkHalf( |
| 226 | success = project.Sync_NetworkHalf( | 227 | quiet=opt.quiet, |
| 227 | quiet=opt.quiet, | 228 | current_branch_only=opt.current_branch_only, |
| 228 | current_branch_only=opt.current_branch_only, | 229 | clone_bundle=not opt.no_clone_bundle) |
| 229 | clone_bundle=not opt.no_clone_bundle) | 230 | self._fetch_times.Set(project, time.time() - start) |
| 230 | self._fetch_times.Set(project, time.time() - start) | 231 | |
| 231 | 232 | # Lock around all the rest of the code, since printing, updating a set | |
| 232 | # Lock around all the rest of the code, since printing, updating a set | 233 | # and Progress.update() are not thread safe. |
| 233 | # and Progress.update() are not thread safe. | 234 | lock.acquire() |
| 234 | lock.acquire() | 235 | did_lock = True |
| 235 | did_lock = True | 236 | |
| 236 | 237 | if not success: | |
| 237 | if not success: | 238 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) |
| 238 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) | 239 | if opt.force_broken: |
| 239 | if opt.force_broken: | 240 | print('warn: --force-broken, continuing to sync', |
| 240 | print('warn: --force-broken, continuing to sync', | 241 | file=sys.stderr) |
| 241 | file=sys.stderr) | 242 | else: |
| 242 | else: | 243 | raise _FetchError() |
| 243 | raise _FetchError() | ||
| 244 | 244 | ||
| 245 | fetched.add(project.gitdir) | 245 | fetched.add(project.gitdir) |
| 246 | pm.update() | 246 | pm.update() |
| 247 | except _FetchError: | 247 | except _FetchError: |
| 248 | err_event.set() | 248 | err_event.set() |
| 249 | except: | 249 | except: |
| 250 | err_event.set() | 250 | err_event.set() |
| 251 | raise | 251 | raise |
| 252 | finally: | 252 | finally: |
| 253 | if did_lock: | 253 | if did_lock: |
| 254 | lock.release() | 254 | lock.release() |
| 255 | sem.release() | 255 | sem.release() |
| 256 | 256 | ||
| 257 | def _Fetch(self, projects, opt): | 257 | def _Fetch(self, projects, opt): |
| 258 | fetched = set() | 258 | fetched = set() |
| @@ -379,36 +379,36 @@ later is required to fix a server side protocol bug. | |||
| 379 | if path not in new_project_paths: | 379 | if path not in new_project_paths: |
| 380 | # If the path has already been deleted, we don't need to do it | 380 | # If the path has already been deleted, we don't need to do it |
| 381 | if os.path.exists(self.manifest.topdir + '/' + path): | 381 | if os.path.exists(self.manifest.topdir + '/' + path): |
| 382 | project = Project( | 382 | project = Project( |
| 383 | manifest = self.manifest, | 383 | manifest = self.manifest, |
| 384 | name = path, | 384 | name = path, |
| 385 | remote = RemoteSpec('origin'), | 385 | remote = RemoteSpec('origin'), |
| 386 | gitdir = os.path.join(self.manifest.topdir, | 386 | gitdir = os.path.join(self.manifest.topdir, |
| 387 | path, '.git'), | 387 | path, '.git'), |
| 388 | worktree = os.path.join(self.manifest.topdir, path), | 388 | worktree = os.path.join(self.manifest.topdir, path), |
| 389 | relpath = path, | 389 | relpath = path, |
| 390 | revisionExpr = 'HEAD', | 390 | revisionExpr = 'HEAD', |
| 391 | revisionId = None, | 391 | revisionId = None, |
| 392 | groups = None) | 392 | groups = None) |
| 393 | 393 | ||
| 394 | if project.IsDirty(): | 394 | if project.IsDirty(): |
| 395 | print('error: Cannot remove project "%s": uncommitted changes' | 395 | print('error: Cannot remove project "%s": uncommitted changes' |
| 396 | 'are present' % project.relpath, file=sys.stderr) | 396 | 'are present' % project.relpath, file=sys.stderr) |
| 397 | print(' commit changes, then run sync again', | 397 | print(' commit changes, then run sync again', |
| 398 | file=sys.stderr) | 398 | file=sys.stderr) |
| 399 | return -1 | 399 | return -1 |
| 400 | else: | 400 | else: |
| 401 | print('Deleting obsolete path %s' % project.worktree, | 401 | print('Deleting obsolete path %s' % project.worktree, |
| 402 | file=sys.stderr) | 402 | file=sys.stderr) |
| 403 | shutil.rmtree(project.worktree) | 403 | shutil.rmtree(project.worktree) |
| 404 | # Try deleting parent subdirs if they are empty | 404 | # Try deleting parent subdirs if they are empty |
| 405 | project_dir = os.path.dirname(project.worktree) | 405 | project_dir = os.path.dirname(project.worktree) |
| 406 | while project_dir != self.manifest.topdir: | 406 | while project_dir != self.manifest.topdir: |
| 407 | try: | 407 | try: |
| 408 | os.rmdir(project_dir) | 408 | os.rmdir(project_dir) |
| 409 | except OSError: | 409 | except OSError: |
| 410 | break | 410 | break |
| 411 | project_dir = os.path.dirname(project_dir) | 411 | project_dir = os.path.dirname(project_dir) |
| 412 | 412 | ||
| 413 | new_project_paths.sort() | 413 | new_project_paths.sort() |
| 414 | fd = open(file_path, 'w') | 414 | fd = open(file_path, 'w') |
diff --git a/subcmds/upload.py b/subcmds/upload.py index a6ada337..219c5093 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -312,23 +312,23 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 312 | 312 | ||
| 313 | # Check if there are local changes that may have been forgotten | 313 | # Check if there are local changes that may have been forgotten |
| 314 | if branch.project.HasChanges(): | 314 | if branch.project.HasChanges(): |
| 315 | key = 'review.%s.autoupload' % branch.project.remote.review | 315 | key = 'review.%s.autoupload' % branch.project.remote.review |
| 316 | answer = branch.project.config.GetBoolean(key) | 316 | answer = branch.project.config.GetBoolean(key) |
| 317 | 317 | ||
| 318 | # if they want to auto upload, let's not ask because it could be automated | 318 | # if they want to auto upload, let's not ask because it could be automated |
| 319 | if answer is None: | 319 | if answer is None: |
| 320 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') | 320 | sys.stdout.write('Uncommitted changes in ' + branch.project.name + ' (did you forget to amend?). Continue uploading? (y/N) ') |
| 321 | a = sys.stdin.readline().strip().lower() | 321 | a = sys.stdin.readline().strip().lower() |
| 322 | if a not in ('y', 'yes', 't', 'true', 'on'): | 322 | if a not in ('y', 'yes', 't', 'true', 'on'): |
| 323 | print("skipping upload", file=sys.stderr) | 323 | print("skipping upload", file=sys.stderr) |
| 324 | branch.uploaded = False | 324 | branch.uploaded = False |
| 325 | branch.error = 'User aborted' | 325 | branch.error = 'User aborted' |
| 326 | continue | 326 | continue |
| 327 | 327 | ||
| 328 | # Check if topic branches should be sent to the server during upload | 328 | # Check if topic branches should be sent to the server during upload |
| 329 | if opt.auto_topic is not True: | 329 | if opt.auto_topic is not True: |
| 330 | key = 'review.%s.uploadtopic' % branch.project.remote.review | 330 | key = 'review.%s.uploadtopic' % branch.project.remote.review |
| 331 | opt.auto_topic = branch.project.config.GetBoolean(key) | 331 | opt.auto_topic = branch.project.config.GetBoolean(key) |
| 332 | 332 | ||
| 333 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) | 333 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) |
| 334 | branch.uploaded = True | 334 | branch.uploaded = True |
| @@ -355,11 +355,11 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 355 | print() | 355 | print() |
| 356 | 356 | ||
| 357 | for branch in todo: | 357 | for branch in todo: |
| 358 | if branch.uploaded: | 358 | if branch.uploaded: |
| 359 | print('[OK ] %-15s %s' % ( | 359 | print('[OK ] %-15s %s' % ( |
| 360 | branch.project.relpath + '/', | 360 | branch.project.relpath + '/', |
| 361 | branch.name), | 361 | branch.name), |
| 362 | file=sys.stderr) | 362 | file=sys.stderr) |
| 363 | 363 | ||
| 364 | if have_errors: | 364 | if have_errors: |
| 365 | sys.exit(1) | 365 | sys.exit(1) |
