From 579941b866f2abcfc104c29bd3b016c48e718a02 Mon Sep 17 00:00:00 2001 From: Edward Speyer Date: Wed, 7 Mar 2012 19:48:25 -0800 Subject: [PATCH] PhabricatorRepository: temporarily change the localPath Summary: I'm on a host where I have the PhabricatorRepositoryPullLocalDaemons tracking a remote repo. In my case, these end up as local git repos in /var/repo/$name. I'm working on another daemon that is going to automatically make changes and commit them back upstream. I figured it would be best to do this in a new local repo. I'll put these in /var/repo-clones/$name. It's nice to use the exec*() functions in PhabricatorRepository, so the approach I thought of was to load the PhabricatorRepository object from the database, then change its localPath to point at the /var/repo-clones/$name directory instead. I didn't really want to change the local-path detail with setDetail(), as that risks committing the change upstream. It's nice to use the repo's execLocalCommand() methods though, hence wanting to change the local path. Test Plan: None yet. Reviewers: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1821 --- .../storage/repository/PhabricatorRepository.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/applications/repository/storage/repository/PhabricatorRepository.php b/src/applications/repository/storage/repository/PhabricatorRepository.php index 66e2baa8cf..6c1fdb843a 100644 --- a/src/applications/repository/storage/repository/PhabricatorRepository.php +++ b/src/applications/repository/storage/repository/PhabricatorRepository.php @@ -33,6 +33,7 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO { protected $details = array(); private $sshKeyfile; + private $actualLocalPath; public function getConfiguration() { return array( @@ -117,7 +118,15 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO { } public function getLocalPath() { - return $this->getDetail('local-path'); + if (!$this->actualLocalPath) { + $this->actualLocalPath = $this->getDetail('local-path'); + } + return $this->actualLocalPath; + } + + // Lets you move the local-path for this instance + public function setLocalPath($path) { + $this->actualLocalPath = $path; } public function execRemoteCommand($pattern /*, $arg, ... */) {