Permalink
Browse files

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
  • Loading branch information...
1 parent 8971a91 commit bd7dc8abaa7bb4c066f4c69a56ab35b871c8ae3f @epriestley epriestley committed Apr 3, 2012
Showing with 23 additions and 3 deletions.
  1. +14 −3 src/repository/api/base/ArcanistRepositoryAPI.php
  2. +9 −0 src/repository/api/git/ArcanistGitAPI.php
@@ -42,6 +42,7 @@
protected $path;
protected $diffLinesOfContext = 0x7FFF;
+ private $workingCopyIdentity;
abstract public function getSourceControlSystemName();
@@ -54,6 +55,10 @@ public function setDiffLinesOfContext($lines) {
return $this;
}
+ public function getWorkingCopyIdentity() {
+ return $this->workingCopyIdentity;
+ }
+
public static function newAPIFromWorkingCopyIdentity(
ArcanistWorkingCopyIdentity $working_copy) {
@@ -68,11 +73,15 @@ public static function newAPIFromWorkingCopyIdentity(
// 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 @@ public static function newAPIFromWorkingCopyIdentity(
"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 @@ public function getRelativeCommit() {
$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.

0 comments on commit bd7dc8a

Please sign in to comment.