diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 46 |
1 files changed, 44 insertions, 2 deletions
| @@ -504,7 +504,8 @@ class Project(object): | |||
| 504 | relpath, | 504 | relpath, |
| 505 | revisionExpr, | 505 | revisionExpr, |
| 506 | revisionId, | 506 | revisionId, |
| 507 | rebase = True): | 507 | rebase = True, |
| 508 | groups = None): | ||
| 508 | self.manifest = manifest | 509 | self.manifest = manifest |
| 509 | self.name = name | 510 | self.name = name |
| 510 | self.remote = remote | 511 | self.remote = remote |
| @@ -524,6 +525,7 @@ class Project(object): | |||
| 524 | self.revisionId = revisionId | 525 | self.revisionId = revisionId |
| 525 | 526 | ||
| 526 | self.rebase = rebase | 527 | self.rebase = rebase |
| 528 | self.groups = groups | ||
| 527 | 529 | ||
| 528 | self.snapshots = {} | 530 | self.snapshots = {} |
| 529 | self.copyfiles = [] | 531 | self.copyfiles = [] |
| @@ -645,6 +647,45 @@ class Project(object): | |||
| 645 | 647 | ||
| 646 | return heads | 648 | return heads |
| 647 | 649 | ||
| 650 | def MatchesGroups(self, manifest_groups): | ||
| 651 | """Returns true if the manifest groups specified at init should cause | ||
| 652 | this project to be synced. | ||
| 653 | Prefixing a manifest group with "-" inverts the meaning of a group. | ||
| 654 | All projects are implicitly labelled with "default" unless they are | ||
| 655 | explicitly labelled "-default". | ||
| 656 | If any non-inverted manifest groups are specified, the default label | ||
| 657 | is ignored. | ||
| 658 | Specifying only inverted groups implies "default". | ||
| 659 | """ | ||
| 660 | project_groups = self.groups | ||
| 661 | if not manifest_groups: | ||
| 662 | return not project_groups or not "-default" in project_groups | ||
| 663 | |||
| 664 | if not project_groups: | ||
| 665 | project_groups = ["default"] | ||
| 666 | elif not ("default" in project_groups or "-default" in project_groups): | ||
| 667 | project_groups.append("default") | ||
| 668 | |||
| 669 | plus_groups = [x for x in manifest_groups if not x.startswith("-")] | ||
| 670 | minus_groups = [x[1:] for x in manifest_groups if x.startswith("-")] | ||
| 671 | |||
| 672 | if not plus_groups: | ||
| 673 | plus_groups.append("default") | ||
| 674 | |||
| 675 | for group in minus_groups: | ||
| 676 | if group in project_groups: | ||
| 677 | # project was excluded by -group | ||
| 678 | return False | ||
| 679 | |||
| 680 | for group in plus_groups: | ||
| 681 | if group in project_groups: | ||
| 682 | # project was included by group | ||
| 683 | return True | ||
| 684 | |||
| 685 | # groups were specified that did not include this project | ||
| 686 | if plus_groups: | ||
| 687 | return False | ||
| 688 | return True | ||
| 648 | 689 | ||
| 649 | ## Status Display ## | 690 | ## Status Display ## |
| 650 | 691 | ||
| @@ -2091,7 +2132,8 @@ class MetaProject(Project): | |||
| 2091 | remote = RemoteSpec('origin'), | 2132 | remote = RemoteSpec('origin'), |
| 2092 | relpath = '.repo/%s' % name, | 2133 | relpath = '.repo/%s' % name, |
| 2093 | revisionExpr = 'refs/heads/master', | 2134 | revisionExpr = 'refs/heads/master', |
| 2094 | revisionId = None) | 2135 | revisionId = None, |
| 2136 | groups = None) | ||
| 2095 | 2137 | ||
| 2096 | def PreSync(self): | 2138 | def PreSync(self): |
| 2097 | if self.Exists: | 2139 | if self.Exists: |
