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 a8022d9d..27dd877d 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) |
@@ -512,12 +512,31 @@ uncommitted changes are present' % project.relpath | |||
512 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) | 512 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) |
513 | self._fetch_times.Clear() | 513 | self._fetch_times.Clear() |
514 | 514 | ||
515 | self._Fetch(to_fetch, opt) | 515 | fetched = self._Fetch(to_fetch, opt) |
516 | _PostRepoFetch(rp, opt.no_repo_verify) | 516 | _PostRepoFetch(rp, opt.no_repo_verify) |
517 | if opt.network_only: | 517 | if opt.network_only: |
518 | # bail out now; the rest touches the working tree | 518 | # bail out now; the rest touches the working tree |
519 | return | 519 | return |
520 | 520 | ||
521 | # Iteratively fetch missing and/or nested unregistered submodules | ||
522 | previously_missing_set = set() | ||
523 | while True: | ||
524 | self.manifest._Unload() | ||
525 | all_projects = self.GetProjects(args, missing_ok=True) | ||
526 | missing = [] | ||
527 | for project in all_projects: | ||
528 | if project.gitdir not in fetched: | ||
529 | missing.append(project) | ||
530 | if not missing: | ||
531 | break | ||
532 | # Stop us from non-stopped fetching actually-missing repos: If set of | ||
533 | # missing repos has not been changed from last fetch, we break. | ||
534 | missing_set = set(p.name for p in missing) | ||
535 | if previously_missing_set == missing_set: | ||
536 | break | ||
537 | previously_missing_set = missing_set | ||
538 | fetched.update(self._Fetch(missing, opt)) | ||
539 | |||
521 | if self.manifest.IsMirror: | 540 | if self.manifest.IsMirror: |
522 | # bail out now, we have no working tree | 541 | # bail out now, we have no working tree |
523 | return | 542 | 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 | ||