diff options
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 41 |
1 files changed, 26 insertions, 15 deletions
| @@ -546,6 +546,18 @@ class Project(object): | |||
| 546 | # project containing repo hooks. | 546 | # project containing repo hooks. |
| 547 | self.enabled_repo_hooks = [] | 547 | self.enabled_repo_hooks = [] |
| 548 | 548 | ||
| 549 | def RelPath(self, local=True): | ||
| 550 | """Return the path for the project relative to a manifest. | ||
| 551 | |||
| 552 | Args: | ||
| 553 | local: a boolean, if True, the path is relative to the local | ||
| 554 | (sub)manifest. If false, the path is relative to the | ||
| 555 | outermost manifest. | ||
| 556 | """ | ||
| 557 | if local: | ||
| 558 | return self.relpath | ||
| 559 | return os.path.join(self.manifest.path_prefix, self.relpath) | ||
| 560 | |||
| 549 | def SetRevision(self, revisionExpr, revisionId=None): | 561 | def SetRevision(self, revisionExpr, revisionId=None): |
| 550 | """Set revisionId based on revision expression and id""" | 562 | """Set revisionId based on revision expression and id""" |
| 551 | self.revisionExpr = revisionExpr | 563 | self.revisionExpr = revisionExpr |
| @@ -2503,22 +2515,21 @@ class Project(object): | |||
| 2503 | mp = self.manifest.manifestProject | 2515 | mp = self.manifest.manifestProject |
| 2504 | ref_dir = mp.config.GetString('repo.reference') or '' | 2516 | ref_dir = mp.config.GetString('repo.reference') or '' |
| 2505 | 2517 | ||
| 2518 | def _expanded_ref_dirs(): | ||
| 2519 | """Iterate through the possible git reference directory paths.""" | ||
| 2520 | name = self.name + '.git' | ||
| 2521 | yield mirror_git or os.path.join(ref_dir, name) | ||
| 2522 | for prefix in '', self.remote.name: | ||
| 2523 | yield os.path.join(ref_dir, '.repo', 'project-objects', prefix, name) | ||
| 2524 | yield os.path.join(ref_dir, '.repo', 'worktrees', prefix, name) | ||
| 2525 | |||
| 2506 | if ref_dir or mirror_git: | 2526 | if ref_dir or mirror_git: |
| 2507 | if not mirror_git: | 2527 | found_ref_dir = None |
| 2508 | mirror_git = os.path.join(ref_dir, self.name + '.git') | 2528 | for path in _expanded_ref_dirs(): |
| 2509 | repo_git = os.path.join(ref_dir, '.repo', 'project-objects', | 2529 | if os.path.exists(path): |
| 2510 | self.name + '.git') | 2530 | found_ref_dir = path |
| 2511 | worktrees_git = os.path.join(ref_dir, '.repo', 'worktrees', | 2531 | break |
| 2512 | self.name + '.git') | 2532 | ref_dir = found_ref_dir |
| 2513 | |||
| 2514 | if os.path.exists(mirror_git): | ||
| 2515 | ref_dir = mirror_git | ||
| 2516 | elif os.path.exists(repo_git): | ||
| 2517 | ref_dir = repo_git | ||
| 2518 | elif os.path.exists(worktrees_git): | ||
| 2519 | ref_dir = worktrees_git | ||
| 2520 | else: | ||
| 2521 | ref_dir = None | ||
| 2522 | 2533 | ||
| 2523 | if ref_dir: | 2534 | if ref_dir: |
| 2524 | if not os.path.isabs(ref_dir): | 2535 | if not os.path.isabs(ref_dir): |
