From 37c21c268badc2602a827d2236027e235fff95e0 Mon Sep 17 00:00:00 2001 From: Michael Kelly Date: Sat, 13 Jun 2020 02:10:40 -0700 Subject: Add 'dest-path' to extend-project to support changing path This allows us to move the repository to a new location in the source tree without having to remove-project + add a new project tag. Change-Id: I4dba6151842e57f6f2b8fe60cda260ecea68b7b4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310962 Reviewed-by: Mike Frysinger Tested-by: Michael Kelly --- project.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 634d88c5..9ff9df0b 100644 --- a/project.py +++ b/project.py @@ -519,13 +519,7 @@ class Project(object): self.client = self.manifest = manifest self.name = name self.remote = remote - self.gitdir = gitdir.replace('\\', '/') - self.objdir = objdir.replace('\\', '/') - if worktree: - self.worktree = os.path.normpath(worktree).replace('\\', '/') - else: - self.worktree = None - self.relpath = relpath + self.UpdatePaths(relpath, worktree, gitdir, objdir) self.revisionExpr = revisionExpr if revisionId is None \ @@ -556,16 +550,6 @@ class Project(object): self.copyfiles = [] self.linkfiles = [] self.annotations = [] - self.config = GitConfig.ForRepository(gitdir=self.gitdir, - defaults=self.client.globalConfig) - - if self.worktree: - self.work_git = self._GitGetByExec(self, bare=False, gitdir=gitdir) - else: - self.work_git = None - self.bare_git = self._GitGetByExec(self, bare=True, gitdir=gitdir) - self.bare_ref = GitRefs(gitdir) - self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=objdir) self.dest_branch = dest_branch self.old_revision = old_revision @@ -573,6 +557,27 @@ class Project(object): # project containing repo hooks. self.enabled_repo_hooks = [] + def UpdatePaths(self, relpath, worktree, gitdir, objdir): + """Update paths used by this project""" + self.gitdir = gitdir.replace('\\', '/') + self.objdir = objdir.replace('\\', '/') + if worktree: + self.worktree = os.path.normpath(worktree).replace('\\', '/') + else: + self.worktree = None + self.relpath = relpath + + self.config = GitConfig.ForRepository(gitdir=self.gitdir, + defaults=self.manifest.globalConfig) + + if self.worktree: + self.work_git = self._GitGetByExec(self, bare=False, gitdir=self.gitdir) + else: + self.work_git = None + self.bare_git = self._GitGetByExec(self, bare=True, gitdir=self.gitdir) + self.bare_ref = GitRefs(self.gitdir) + self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=self.objdir) + @property def Derived(self): return self.is_derived -- cgit v1.2.3-54-g00ecf