mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Allow configuration of a weak per-project default relative commit
Summary: Allows you to set a default in .arcconfig. This default is overriden by any .arc/ setting. Test Plan: Ran "arc diff" with a .arcconfig setting but no .arc/ setting, got a diff against the specified relative commit. Reviewers: nh, btrahan Reviewed By: nh CC: aran Differential Revision: https://secure.phabricator.com/D2093
This commit is contained in:
parent
8971a91444
commit
bd7dc8abaa
2 changed files with 23 additions and 3 deletions
|
@ -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(
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue