diff --git a/src/repository/api/base/ArcanistRepositoryAPI.php b/src/repository/api/base/ArcanistRepositoryAPI.php index 1b5c7d23..f40dab4a 100644 --- a/src/repository/api/base/ArcanistRepositoryAPI.php +++ b/src/repository/api/base/ArcanistRepositoryAPI.php @@ -42,6 +42,7 @@ abstract class ArcanistRepositoryAPI { protected $path; protected $diffLinesOfContext = 0x7FFF; + private $workingCopyIdentity; abstract public function getSourceControlSystemName(); @@ -54,6 +55,10 @@ abstract class ArcanistRepositoryAPI { return $this; } + public function getWorkingCopyIdentity() { + return $this->workingCopyIdentity; + } + public static function newAPIFromWorkingCopyIdentity( ArcanistWorkingCopyIdentity $working_copy) { @@ -68,11 +73,15 @@ abstract class ArcanistRepositoryAPI { // check if we're in an svn working copy list($err) = exec_manual('svn info'); if (!$err) { - return newv('ArcanistSubversionAPI', array($root)); + $api = newv('ArcanistSubversionAPI', array($root)); + $api->workingCopyIdentity = $working_copy; + return $api; } if (Filesystem::pathExists($root.'/.hg')) { - return newv('ArcanistMercurialAPI', array($root)); + $api = newv('ArcanistMercurialAPI', array($root)); + $api->workingCopyIdentity = $working_copy; + return $api; } $git_root = self::discoverGitBaseDirectory($root); @@ -83,7 +92,9 @@ abstract class ArcanistRepositoryAPI { "is '{$git_root}'. Move '.arcconfig' file to the working copy root."); } - return newv('ArcanistGitAPI', array($root)); + $api = newv('ArcanistGitAPI', array($root)); + $api->workingCopyIdentity = $working_copy; + return $api; } throw new ArcanistUsageException( diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 9f1bbe50..9a0ca790 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -130,6 +130,15 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $default_relative = $this->readScratchFile('default-relative-commit'); $do_write = false; + + if (!$default_relative) { + $working_copy = $this->getWorkingCopyIdentity(); + if ($working_copy) { + $default_relative = $working_copy->getConfig( + 'git.default-relative-commit'); + } + } + if (!$default_relative) { // TODO: Remove the history lesson soon.