diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/forall.py | 4 | ||||
| -rw-r--r-- | subcmds/list.py | 38 | ||||
| -rw-r--r-- | subcmds/sync.py | 21 |
3 files changed, 56 insertions, 7 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/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 d16605ff..28c154a0 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -503,12 +503,31 @@ uncommitted changes are present' % project.relpath | |||
| 503 | to_fetch.append(rp) | 503 | to_fetch.append(rp) |
| 504 | to_fetch.extend(all_projects) | 504 | to_fetch.extend(all_projects) |
| 505 | 505 | ||
| 506 | self._Fetch(to_fetch, opt) | 506 | fetched = self._Fetch(to_fetch, opt) |
| 507 | _PostRepoFetch(rp, opt.no_repo_verify) | 507 | _PostRepoFetch(rp, opt.no_repo_verify) |
| 508 | if opt.network_only: | 508 | if opt.network_only: |
| 509 | # bail out now; the rest touches the working tree | 509 | # bail out now; the rest touches the working tree |
| 510 | return | 510 | return |
| 511 | 511 | ||
| 512 | # Iteratively fetch missing and/or nested unregistered submodules | ||
| 513 | previously_missing_set = set() | ||
| 514 | while True: | ||
| 515 | self.manifest._Unload() | ||
| 516 | all = self.GetProjects(args, missing_ok=True) | ||
| 517 | missing = [] | ||
| 518 | for project in all: | ||
| 519 | if project.gitdir not in fetched: | ||
| 520 | missing.append(project) | ||
| 521 | if not missing: | ||
| 522 | break | ||
| 523 | # Stop us from non-stopped fetching actually-missing repos: If set of | ||
| 524 | # missing repos has not been changed from last fetch, we break. | ||
| 525 | missing_set = set(p.name for p in missing) | ||
| 526 | if previously_missing_set == missing_set: | ||
| 527 | break | ||
| 528 | previously_missing_set = missing_set | ||
| 529 | fetched.update(self._Fetch(missing, opt)) | ||
| 530 | |||
| 512 | if self.manifest.IsMirror: | 531 | if self.manifest.IsMirror: |
| 513 | # bail out now, we have no working tree | 532 | # bail out now, we have no working tree |
| 514 | return | 533 | return |
