diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/forall.py | 4 | ||||
| -rw-r--r-- | subcmds/init.py | 2 | ||||
| -rw-r--r-- | subcmds/list.py | 38 | ||||
| -rw-r--r-- | subcmds/sync.py | 27 | ||||
| -rw-r--r-- | subcmds/upload.py | 4 |
5 files changed, 62 insertions, 13 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index 2ece95ed..b633b7d4 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
| @@ -143,14 +143,14 @@ terminal and are not redirected. | |||
| 143 | break | 143 | break |
| 144 | else: | 144 | else: |
| 145 | cn = None | 145 | cn = None |
| 146 | # pylint: disable-msg=W0631 | 146 | # pylint: disable=W0631 |
| 147 | if cn and cn in _CAN_COLOR: | 147 | if cn and cn in _CAN_COLOR: |
| 148 | class ColorCmd(Coloring): | 148 | class ColorCmd(Coloring): |
| 149 | def __init__(self, config, cmd): | 149 | def __init__(self, config, cmd): |
| 150 | Coloring.__init__(self, config, cmd) | 150 | Coloring.__init__(self, config, cmd) |
| 151 | if ColorCmd(self.manifest.manifestProject.config, cn).is_on: | 151 | if ColorCmd(self.manifest.manifestProject.config, cn).is_on: |
| 152 | cmd.insert(cmd.index(cn) + 1, '--color') | 152 | cmd.insert(cmd.index(cn) + 1, '--color') |
| 153 | # pylint: enable-msg=W0631 | 153 | # pylint: enable=W0631 |
| 154 | 154 | ||
| 155 | mirror = self.manifest.IsMirror | 155 | mirror = self.manifest.IsMirror |
| 156 | out = ForallColoring(self.manifest.manifestProject.config) | 156 | out = ForallColoring(self.manifest.manifestProject.config) |
diff --git a/subcmds/init.py b/subcmds/init.py index 007667e2..b6b98076 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -207,7 +207,7 @@ to update the working directory files. | |||
| 207 | 207 | ||
| 208 | try: | 208 | try: |
| 209 | self.manifest.Link(name) | 209 | self.manifest.Link(name) |
| 210 | except ManifestParseError, e: | 210 | except ManifestParseError as e: |
| 211 | print >>sys.stderr, "fatal: manifest '%s' not available" % name | 211 | print >>sys.stderr, "fatal: manifest '%s' not available" % name |
| 212 | print >>sys.stderr, 'fatal: %s' % str(e) | 212 | print >>sys.stderr, 'fatal: %s' % str(e) |
| 213 | sys.exit(1) | 213 | sys.exit(1) |
diff --git a/subcmds/list.py b/subcmds/list.py index 2be82570..6058a755 100644 --- a/subcmds/list.py +++ b/subcmds/list.py | |||
| @@ -13,13 +13,16 @@ | |||
| 13 | # See the License for the specific language governing permissions and | 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. | 14 | # limitations under the License. |
| 15 | 15 | ||
| 16 | import re | ||
| 17 | |||
| 16 | from command import Command, MirrorSafeCommand | 18 | from command import Command, MirrorSafeCommand |
| 17 | 19 | ||
| 18 | class List(Command, MirrorSafeCommand): | 20 | class List(Command, MirrorSafeCommand): |
| 19 | common = True | 21 | common = True |
| 20 | helpSummary = "List projects and their associated directories" | 22 | helpSummary = "List projects and their associated directories" |
| 21 | helpUsage = """ | 23 | helpUsage = """ |
| 22 | %prog [<project>...] | 24 | %prog [-f] [<project>...] |
| 25 | %prog [-f] -r str1 [str2]..." | ||
| 23 | """ | 26 | """ |
| 24 | helpDescription = """ | 27 | helpDescription = """ |
| 25 | List all projects; pass '.' to list the project for the cwd. | 28 | List all projects; pass '.' to list the project for the cwd. |
| @@ -27,6 +30,14 @@ List all projects; pass '.' to list the project for the cwd. | |||
| 27 | This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | 30 | This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. |
| 28 | """ | 31 | """ |
| 29 | 32 | ||
| 33 | def _Options(self, p, show_smart=True): | ||
| 34 | p.add_option('-r', '--regex', | ||
| 35 | dest='regex', action='store_true', | ||
| 36 | help="Filter the project list based on regex or wildcard matching of strings") | ||
| 37 | p.add_option('-f', '--fullpath', | ||
| 38 | dest='fullpath', action='store_true', | ||
| 39 | help="Display the full work tree path instead of the relative path") | ||
| 40 | |||
| 30 | def Execute(self, opt, args): | 41 | def Execute(self, opt, args): |
| 31 | """List all projects and the associated directories. | 42 | """List all projects and the associated directories. |
| 32 | 43 | ||
| @@ -35,14 +46,33 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
| 35 | discoverable. | 46 | discoverable. |
| 36 | 47 | ||
| 37 | Args: | 48 | Args: |
| 38 | opt: The options. We don't take any. | 49 | opt: The options. |
| 39 | args: Positional args. Can be a list of projects to list, or empty. | 50 | args: Positional args. Can be a list of projects to list, or empty. |
| 40 | """ | 51 | """ |
| 41 | projects = self.GetProjects(args) | 52 | if not opt.regex: |
| 53 | projects = self.GetProjects(args) | ||
| 54 | else: | ||
| 55 | projects = self.FindProjects(args) | ||
| 56 | |||
| 57 | def _getpath(x): | ||
| 58 | if opt.fullpath: | ||
| 59 | return x.worktree | ||
| 60 | return x.relpath | ||
| 42 | 61 | ||
| 43 | lines = [] | 62 | lines = [] |
| 44 | for project in projects: | 63 | for project in projects: |
| 45 | lines.append("%s : %s" % (project.relpath, project.name)) | 64 | lines.append("%s : %s" % (_getpath(project), project.name)) |
| 46 | 65 | ||
| 47 | lines.sort() | 66 | lines.sort() |
| 48 | print '\n'.join(lines) | 67 | print '\n'.join(lines) |
| 68 | |||
| 69 | def FindProjects(self, args): | ||
| 70 | result = [] | ||
| 71 | for project in self.GetProjects(''): | ||
| 72 | for arg in args: | ||
| 73 | pattern = re.compile(r'%s' % arg, re.IGNORECASE) | ||
| 74 | if pattern.search(project.name) or pattern.search(project.relpath): | ||
| 75 | result.append(project) | ||
| 76 | break | ||
| 77 | result.sort(key=lambda project: project.relpath) | ||
| 78 | return result | ||
diff --git a/subcmds/sync.py b/subcmds/sync.py index b83f2d4a..d565af7b 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -423,7 +423,7 @@ uncommitted changes are present' % project.relpath | |||
| 423 | # in the .netrc file. | 423 | # in the .netrc file. |
| 424 | print >>sys.stderr, 'No credentials found for %s in .netrc' % \ | 424 | print >>sys.stderr, 'No credentials found for %s in .netrc' % \ |
| 425 | parse_result.hostname | 425 | parse_result.hostname |
| 426 | except netrc.NetrcParseError, e: | 426 | except netrc.NetrcParseError as e: |
| 427 | print >>sys.stderr, 'Error parsing .netrc file: %s' % e | 427 | print >>sys.stderr, 'Error parsing .netrc file: %s' % e |
| 428 | 428 | ||
| 429 | if (username and password): | 429 | if (username and password): |
| @@ -470,11 +470,11 @@ uncommitted changes are present' % project.relpath | |||
| 470 | else: | 470 | else: |
| 471 | print >>sys.stderr, 'error: %s' % manifest_str | 471 | print >>sys.stderr, 'error: %s' % manifest_str |
| 472 | sys.exit(1) | 472 | sys.exit(1) |
| 473 | except (socket.error, IOError, xmlrpclib.Fault), e: | 473 | except (socket.error, IOError, xmlrpclib.Fault) as e: |
| 474 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % ( | 474 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % ( |
| 475 | self.manifest.manifest_server, e) | 475 | self.manifest.manifest_server, e) |
| 476 | sys.exit(1) | 476 | sys.exit(1) |
| 477 | except xmlrpclib.ProtocolError, e: | 477 | except xmlrpclib.ProtocolError as e: |
| 478 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % ( | 478 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % ( |
| 479 | self.manifest.manifest_server, e.errcode, e.errmsg) | 479 | self.manifest.manifest_server, e.errcode, e.errmsg) |
| 480 | sys.exit(1) | 480 | sys.exit(1) |
| @@ -511,12 +511,31 @@ uncommitted changes are present' % project.relpath | |||
| 511 | to_fetch.extend(all_projects) | 511 | to_fetch.extend(all_projects) |
| 512 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) | 512 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) |
| 513 | 513 | ||
| 514 | self._Fetch(to_fetch, opt) | 514 | fetched = self._Fetch(to_fetch, opt) |
| 515 | _PostRepoFetch(rp, opt.no_repo_verify) | 515 | _PostRepoFetch(rp, opt.no_repo_verify) |
| 516 | if opt.network_only: | 516 | if opt.network_only: |
| 517 | # bail out now; the rest touches the working tree | 517 | # bail out now; the rest touches the working tree |
| 518 | return | 518 | return |
| 519 | 519 | ||
| 520 | # Iteratively fetch missing and/or nested unregistered submodules | ||
| 521 | previously_missing_set = set() | ||
| 522 | while True: | ||
| 523 | self.manifest._Unload() | ||
| 524 | all_projects = self.GetProjects(args, missing_ok=True) | ||
| 525 | missing = [] | ||
| 526 | for project in all_projects: | ||
| 527 | if project.gitdir not in fetched: | ||
| 528 | missing.append(project) | ||
| 529 | if not missing: | ||
| 530 | break | ||
| 531 | # Stop us from non-stopped fetching actually-missing repos: If set of | ||
| 532 | # missing repos has not been changed from last fetch, we break. | ||
| 533 | missing_set = set(p.name for p in missing) | ||
| 534 | if previously_missing_set == missing_set: | ||
| 535 | break | ||
| 536 | previously_missing_set = missing_set | ||
| 537 | fetched.update(self._Fetch(missing, opt)) | ||
| 538 | |||
| 520 | if self.manifest.IsMirror: | 539 | if self.manifest.IsMirror: |
| 521 | # bail out now, we have no working tree | 540 | # bail out now, we have no working tree |
| 522 | return | 541 | return |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 685e3420..84a5e440 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -329,7 +329,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 329 | 329 | ||
| 330 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) | 330 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) |
| 331 | branch.uploaded = True | 331 | branch.uploaded = True |
| 332 | except UploadError, e: | 332 | except UploadError as e: |
| 333 | branch.error = e | 333 | branch.error = e |
| 334 | branch.uploaded = False | 334 | branch.uploaded = False |
| 335 | have_errors = True | 335 | have_errors = True |
| @@ -384,7 +384,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 384 | pending_proj_names = [project.name for (project, avail) in pending] | 384 | pending_proj_names = [project.name for (project, avail) in pending] |
| 385 | try: | 385 | try: |
| 386 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) | 386 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) |
| 387 | except HookError, e: | 387 | except HookError as e: |
| 388 | print >>sys.stderr, "ERROR: %s" % str(e) | 388 | print >>sys.stderr, "ERROR: %s" % str(e) |
| 389 | return | 389 | return |
| 390 | 390 | ||
