summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2021-11-18 22:40:18 +0000
committerLaMont Jones <lamontjones@google.com>2022-02-17 21:57:55 +0000
commitcc879a97c3e2614d19b15b4661c3cab4d33139c9 (patch)
tree69d225e9f0e9d79fec8f423d9c40c275f0bf3b8c /project.py
parent87cce68b28c34fa86895baa8d7f48307382e6c75 (diff)
downloadgit-repo-cc879a97c3e2614d19b15b4661c3cab4d33139c9.tar.gz
Add multi-manifest support with <submanifest> elementv2.22
To be addressed in another change: - a partial `repo sync` (with a list of projects/paths to sync) requires `--this-tree-only`. Change-Id: I6c7400bf001540e9d7694fa70934f8f204cb5f57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322657 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py41
1 files changed, 26 insertions, 15 deletions
diff --git a/project.py b/project.py
index ff91d189..480dac63 100644
--- a/project.py
+++ b/project.py
@@ -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):