2011-01-10 00:22:25 +01:00
|
|
|
<?php
|
|
|
|
|
2011-02-19 20:36:08 +01:00
|
|
|
/**
|
|
|
|
* Interfaces with the VCS in the working copy.
|
|
|
|
*
|
2012-12-17 21:53:28 +01:00
|
|
|
* @task status Path Status
|
2011-02-19 20:36:08 +01:00
|
|
|
*/
|
2011-01-10 00:22:25 +01:00
|
|
|
abstract class ArcanistRepositoryAPI {
|
|
|
|
|
|
|
|
const FLAG_MODIFIED = 1;
|
|
|
|
const FLAG_ADDED = 2;
|
|
|
|
const FLAG_DELETED = 4;
|
|
|
|
const FLAG_UNTRACKED = 8;
|
|
|
|
const FLAG_CONFLICT = 16;
|
|
|
|
const FLAG_MISSING = 32;
|
|
|
|
const FLAG_UNSTAGED = 64;
|
|
|
|
const FLAG_UNCOMMITTED = 128;
|
|
|
|
const FLAG_EXTERNALS = 256;
|
|
|
|
|
2011-03-13 02:57:35 +01:00
|
|
|
// Occurs in SVN when you replace a file with a directory without telling
|
|
|
|
// SVN about it.
|
2011-01-10 00:22:25 +01:00
|
|
|
const FLAG_OBSTRUCTED = 512;
|
|
|
|
|
2011-03-13 02:57:35 +01:00
|
|
|
// Occurs in SVN when an update was interrupted or failed, e.g. you ^C'd it.
|
|
|
|
const FLAG_INCOMPLETE = 1024;
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
protected $path;
|
|
|
|
protected $diffLinesOfContext = 0x7FFF;
|
2012-06-14 21:02:41 +02:00
|
|
|
private $baseCommitExplanation = '???';
|
2013-10-19 01:10:06 +02:00
|
|
|
private $configurationManager;
|
Add a DSL for selecting base commits
Summary:
New optional mode. If you set 'base' in local, project or global config or pass '--base' to 'arc diff' or 'arc which', it switches to DSL mode.
In DSL mode, lists of rules from args, local, project and global config are resolved, in that order. Rules can manipulate the rule machine or resolve into actual commits. Provides support for some 'arc' rules (mostly machine manipulation) and 'git' rules (symbolic ref and merge-base).
Test Plan:
Ran unit tests. Also:
```$ arc which --show-base --base 'arc:prompt'
Against which commit? HEAD
HEAD
$ arc which --show-base --base 'git:HEAD'
HEAD
$ arc which --show-base --base 'git:fake'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'git:origin/master'
origin/master
$ arc which --show-base --base 'git:upstream'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'literal:derp'
derp
$ arc which --show-base --base 'arc:halt'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc set-config --local base git:origin/master
Set key 'base' = 'git:origin/master' in local config.
$ arc which --show-base
origin/master
$ arc which --show-base --base 'git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:yield, git:HEAD^'
origin/master
$ arc which --show-base --base 'arc:global, git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:global, git:merge-base(origin/master)'
3f4f8992fba8d1f142974da36a82bae900e247c0```
Reviewers: dschleimer, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1233
Differential Revision: https://secure.phabricator.com/D2748
2012-06-15 23:01:28 +02:00
|
|
|
private $baseCommitArgumentRules;
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
private $uncommittedStatusCache;
|
|
|
|
private $commitRangeStatusCache;
|
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
private $symbolicBaseCommit;
|
|
|
|
private $resolvedBaseCommit;
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
abstract public function getSourceControlSystemName();
|
|
|
|
|
|
|
|
public function getDiffLinesOfContext() {
|
|
|
|
return $this->diffLinesOfContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDiffLinesOfContext($lines) {
|
|
|
|
$this->diffLinesOfContext = $lines;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-04-04 01:06:43 +02:00
|
|
|
public function getWorkingCopyIdentity() {
|
2013-10-19 01:10:06 +02:00
|
|
|
return $this->configurationManager->getWorkingCopyIdentity();
|
2012-04-04 01:06:43 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 01:10:06 +02:00
|
|
|
public function getConfigurationManager() {
|
|
|
|
return $this->configurationManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function newAPIFromConfigurationManager(
|
|
|
|
ArcanistConfigurationManager $configuration_manager) {
|
|
|
|
|
|
|
|
$working_copy = $configuration_manager->getWorkingCopyIdentity();
|
|
|
|
|
|
|
|
if (!$working_copy) {
|
|
|
|
throw new Exception(
|
Fix working copy binding powers in weird edge cases
Summary:
Fixes T1277. The rules we use to figure out the root of the working copy get a bunch of edge cases wrong right now. A particularly troublesome one is when a user has a `/.arcconfig` or `/home/.arcconfig` or similar, which raises a completely useless and confusing error message (T1277).
Rewrite these rules to get all the edge cases correct and do reasonable things in the presence of stray `.arcconfig`. There are a bunch of comments, but basically the algorithm is:
- From the top, go down one directory at a time until we find ".svn", ".git", or ".hg".
- In Subversion, keep going down looking for ".arcconfig". In Git and Mercurial, look for ".arcconfig" only in the same directory.
- Now that we've figured out the VCS root (where the ".vcs" directory is) and the project root (where the ".arcconfig" file is, if it exists), build an identity.
This logic was also spread across three different places. Consolidate it into one and add some logging so we can figure out what's going wrong if users run into trouble.
Test Plan:
- Ran VCS (`arc list`) and non-VCS (`arc help`) commands in Git, Mercurial, and Subversions roots and subdirectories. Also ran them in non-VCS directories. Ran them with and without .arcconfig. All the outputs seemed completely reasonable.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T1277
Differential Revision: https://secure.phabricator.com/D7686
2013-12-03 19:32:31 +01:00
|
|
|
pht(
|
2014-05-23 22:53:05 +02:00
|
|
|
'Trying to create a RepositoryAPI without a working copy!'));
|
2013-10-19 01:10:06 +02:00
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
$root = $working_copy->getProjectRoot();
|
Fix working copy binding powers in weird edge cases
Summary:
Fixes T1277. The rules we use to figure out the root of the working copy get a bunch of edge cases wrong right now. A particularly troublesome one is when a user has a `/.arcconfig` or `/home/.arcconfig` or similar, which raises a completely useless and confusing error message (T1277).
Rewrite these rules to get all the edge cases correct and do reasonable things in the presence of stray `.arcconfig`. There are a bunch of comments, but basically the algorithm is:
- From the top, go down one directory at a time until we find ".svn", ".git", or ".hg".
- In Subversion, keep going down looking for ".arcconfig". In Git and Mercurial, look for ".arcconfig" only in the same directory.
- Now that we've figured out the VCS root (where the ".vcs" directory is) and the project root (where the ".arcconfig" file is, if it exists), build an identity.
This logic was also spread across three different places. Consolidate it into one and add some logging so we can figure out what's going wrong if users run into trouble.
Test Plan:
- Ran VCS (`arc list`) and non-VCS (`arc help`) commands in Git, Mercurial, and Subversions roots and subdirectories. Also ran them in non-VCS directories. Ran them with and without .arcconfig. All the outputs seemed completely reasonable.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T1277
Differential Revision: https://secure.phabricator.com/D7686
2013-12-03 19:32:31 +01:00
|
|
|
switch ($working_copy->getVCSType()) {
|
|
|
|
case 'svn':
|
2012-12-21 03:04:59 +01:00
|
|
|
$api = new ArcanistSubversionAPI($root);
|
Fix working copy binding powers in weird edge cases
Summary:
Fixes T1277. The rules we use to figure out the root of the working copy get a bunch of edge cases wrong right now. A particularly troublesome one is when a user has a `/.arcconfig` or `/home/.arcconfig` or similar, which raises a completely useless and confusing error message (T1277).
Rewrite these rules to get all the edge cases correct and do reasonable things in the presence of stray `.arcconfig`. There are a bunch of comments, but basically the algorithm is:
- From the top, go down one directory at a time until we find ".svn", ".git", or ".hg".
- In Subversion, keep going down looking for ".arcconfig". In Git and Mercurial, look for ".arcconfig" only in the same directory.
- Now that we've figured out the VCS root (where the ".vcs" directory is) and the project root (where the ".arcconfig" file is, if it exists), build an identity.
This logic was also spread across three different places. Consolidate it into one and add some logging so we can figure out what's going wrong if users run into trouble.
Test Plan:
- Ran VCS (`arc list`) and non-VCS (`arc help`) commands in Git, Mercurial, and Subversions roots and subdirectories. Also ran them in non-VCS directories. Ran them with and without .arcconfig. All the outputs seemed completely reasonable.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T1277
Differential Revision: https://secure.phabricator.com/D7686
2013-12-03 19:32:31 +01:00
|
|
|
break;
|
|
|
|
case 'hg':
|
|
|
|
$api = new ArcanistMercurialAPI($root);
|
|
|
|
break;
|
|
|
|
case 'git':
|
|
|
|
$api = new ArcanistGitAPI($root);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new Exception(
|
|
|
|
pht(
|
2014-05-23 22:53:05 +02:00
|
|
|
'The current working directory is not part of a working copy for '.
|
|
|
|
'a supported version control system (Git, Subversion or '.
|
|
|
|
'Mercurial).'));
|
2012-11-26 23:45:50 +01:00
|
|
|
}
|
|
|
|
|
Fix working copy binding powers in weird edge cases
Summary:
Fixes T1277. The rules we use to figure out the root of the working copy get a bunch of edge cases wrong right now. A particularly troublesome one is when a user has a `/.arcconfig` or `/home/.arcconfig` or similar, which raises a completely useless and confusing error message (T1277).
Rewrite these rules to get all the edge cases correct and do reasonable things in the presence of stray `.arcconfig`. There are a bunch of comments, but basically the algorithm is:
- From the top, go down one directory at a time until we find ".svn", ".git", or ".hg".
- In Subversion, keep going down looking for ".arcconfig". In Git and Mercurial, look for ".arcconfig" only in the same directory.
- Now that we've figured out the VCS root (where the ".vcs" directory is) and the project root (where the ".arcconfig" file is, if it exists), build an identity.
This logic was also spread across three different places. Consolidate it into one and add some logging so we can figure out what's going wrong if users run into trouble.
Test Plan:
- Ran VCS (`arc list`) and non-VCS (`arc help`) commands in Git, Mercurial, and Subversions roots and subdirectories. Also ran them in non-VCS directories. Ran them with and without .arcconfig. All the outputs seemed completely reasonable.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T1277
Differential Revision: https://secure.phabricator.com/D7686
2013-12-03 19:32:31 +01:00
|
|
|
$api->configurationManager = $configuration_manager;
|
|
|
|
return $api;
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
Basic Mercurial support for Arcanist
Summary:
There's a lot of ground left to cover but this makes "arc diff" work (on one
trivial diff) in my sandbox, at least, and supports parsing of Mercurial native
diffs (which are unified + a custom header). Piles of missing features, still.
Some of this is blocked by me not understanding the mercurial model well yet.
This is also a really good opportunity for cleanup (especially, reducing the
level of "instanceof" in the diff workflow), I'll try to do a bunch of that in
followup diffs.
Test Plan: Ran "arc diff" in a mercurial repository, got a diff out of it.
Reviewed By: aran
Reviewers: Makinde, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock, fratrik
Differential Revision: 792
2011-08-09 18:00:29 +02:00
|
|
|
public function __construct($path) {
|
2011-01-10 00:22:25 +01:00
|
|
|
$this->path = $path;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPath($to_file = null) {
|
|
|
|
if ($to_file !== null) {
|
2012-03-25 18:32:20 +02:00
|
|
|
return $this->path.DIRECTORY_SEPARATOR.
|
|
|
|
ltrim($to_file, DIRECTORY_SEPARATOR);
|
2011-01-10 00:22:25 +01:00
|
|
|
} else {
|
2012-03-25 18:32:20 +02:00
|
|
|
return $this->path.DIRECTORY_SEPARATOR;
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
/* -( Path Status )-------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
abstract protected function buildUncommittedStatus();
|
|
|
|
abstract protected function buildCommitRangeStatus();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of uncommitted paths in the working copy that have been changed
|
|
|
|
* or are affected by other status effects, like conflicts or untracked
|
|
|
|
* files.
|
|
|
|
*
|
|
|
|
* Convenience methods @{method:getUntrackedChanges},
|
|
|
|
* @{method:getUnstagedChanges}, @{method:getUncommittedChanges},
|
|
|
|
* @{method:getMergeConflicts}, and @{method:getIncompleteChanges} allow
|
|
|
|
* simpler selection of paths in a specific state.
|
|
|
|
*
|
|
|
|
* This method returns a map of paths to bitmasks with status, using
|
|
|
|
* `FLAG_` constants. For example:
|
|
|
|
*
|
|
|
|
* array(
|
|
|
|
* 'some/uncommitted/file.txt' => ArcanistRepositoryAPI::FLAG_UNSTAGED,
|
|
|
|
* );
|
|
|
|
*
|
|
|
|
* A file may be in several states. Not all states are possible with all
|
|
|
|
* version control systems.
|
|
|
|
*
|
|
|
|
* @return map<string, bitmask> Map of paths, see above.
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getUncommittedStatus() {
|
|
|
|
if ($this->uncommittedStatusCache === null) {
|
2013-01-29 00:15:18 +01:00
|
|
|
$status = $this->buildUncommittedStatus();
|
2012-12-17 21:53:28 +01:00
|
|
|
ksort($status);
|
|
|
|
$this->uncommittedStatusCache = $status;
|
|
|
|
}
|
|
|
|
return $this->uncommittedStatusCache;
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getUntrackedChanges() {
|
|
|
|
return $this->getUncommittedPathsWithMask(self::FLAG_UNTRACKED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getUnstagedChanges() {
|
|
|
|
return $this->getUncommittedPathsWithMask(self::FLAG_UNSTAGED);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getUncommittedChanges() {
|
|
|
|
return $this->getUncommittedPathsWithMask(self::FLAG_UNCOMMITTED);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getMergeConflicts() {
|
|
|
|
return $this->getUncommittedPathsWithMask(self::FLAG_CONFLICT);
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getIncompleteChanges() {
|
|
|
|
return $this->getUncommittedPathsWithMask(self::FLAG_INCOMPLETE);
|
2011-03-13 02:57:35 +01:00
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
2014-01-03 21:23:34 +01:00
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getMissingChanges() {
|
|
|
|
return $this->getUncommittedPathsWithMask(self::FLAG_MISSING);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
/**
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
private function getUncommittedPathsWithMask($mask) {
|
2011-01-10 00:22:25 +01:00
|
|
|
$match = array();
|
2012-12-17 21:53:28 +01:00
|
|
|
foreach ($this->getUncommittedStatus() as $path => $flags) {
|
2011-01-10 00:22:25 +01:00
|
|
|
if ($flags & $mask) {
|
2012-12-17 21:53:28 +01:00
|
|
|
$match[] = $path;
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $match;
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of paths affected by the commits in the current commit range.
|
|
|
|
*
|
|
|
|
* See @{method:getUncommittedStatus} for a description of the return value.
|
|
|
|
*
|
|
|
|
* @return map<string, bitmask> Map from paths to status.
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getCommitRangeStatus() {
|
|
|
|
if ($this->commitRangeStatusCache === null) {
|
|
|
|
$status = $this->buildCommitRangeStatus();
|
|
|
|
ksort($status);
|
|
|
|
$this->commitRangeStatusCache = $status;
|
|
|
|
}
|
|
|
|
return $this->commitRangeStatusCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of paths affected by commits in the current commit range, or
|
|
|
|
* uncommitted changes in the working copy. See @{method:getUncommittedStatus}
|
|
|
|
* or @{method:getCommitRangeStatus} to retreive smaller parts of the status.
|
|
|
|
*
|
|
|
|
* See @{method:getUncommittedStatus} for a description of the return value.
|
|
|
|
*
|
|
|
|
* @return map<string, bitmask> Map from paths to status.
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function getWorkingCopyStatus() {
|
|
|
|
$range_status = $this->getCommitRangeStatus();
|
|
|
|
$uncommitted_status = $this->getUncommittedStatus();
|
|
|
|
|
|
|
|
$result = new PhutilArrayWithDefaultValue($range_status);
|
|
|
|
foreach ($uncommitted_status as $path => $mask) {
|
|
|
|
$result[$path] |= $mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = $result->toArray();
|
|
|
|
ksort($result);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drops caches after changes to the working copy. By default, some queries
|
|
|
|
* against the working copy are cached. They
|
|
|
|
*
|
|
|
|
* @return this
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
final public function reloadWorkingCopy() {
|
|
|
|
$this->uncommittedStatusCache = null;
|
|
|
|
$this->commitRangeStatusCache = null;
|
|
|
|
|
|
|
|
$this->didReloadWorkingCopy();
|
2012-12-17 21:54:08 +01:00
|
|
|
$this->reloadCommitRange();
|
2012-12-17 21:53:28 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook for implementations to dirty working copy caches after the working
|
|
|
|
* copy has been updated.
|
|
|
|
*
|
|
|
|
* @return this
|
|
|
|
* @task status
|
|
|
|
*/
|
|
|
|
protected function didReloadWorkingCopy() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-28 18:46:42 +01:00
|
|
|
/**
|
|
|
|
* Fetches the original file data for each path provided.
|
|
|
|
*
|
|
|
|
* @return map<string, string> Map from path to file data.
|
|
|
|
*/
|
|
|
|
public function getBulkOriginalFileData($paths) {
|
|
|
|
$filedata = array();
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
$filedata[$path] = $this->getOriginalFileData($path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $filedata;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches the current file data for each path provided.
|
|
|
|
*
|
|
|
|
* @return map<string, string> Map from path to file data.
|
|
|
|
*/
|
|
|
|
public function getBulkCurrentFileData($paths) {
|
|
|
|
$filedata = array();
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
$filedata[$path] = $this->getCurrentFileData($path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $filedata;
|
|
|
|
}
|
2012-12-17 21:53:28 +01:00
|
|
|
|
2012-11-09 08:22:29 +01:00
|
|
|
/**
|
|
|
|
* @return Traversable
|
|
|
|
*/
|
|
|
|
abstract public function getAllFiles();
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
abstract public function getBlame($path);
|
2012-12-17 21:53:28 +01:00
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
abstract public function getRawDiffText($path);
|
2011-01-11 22:02:38 +01:00
|
|
|
abstract public function getOriginalFileData($path);
|
|
|
|
abstract public function getCurrentFileData($path);
|
2011-08-24 03:48:55 +02:00
|
|
|
abstract public function getLocalCommitInformation();
|
2011-12-03 01:21:14 +01:00
|
|
|
abstract public function getSourceControlBaseRevision();
|
2012-03-09 23:40:47 +01:00
|
|
|
abstract public function getCanonicalRevisionName($string);
|
2012-11-07 09:50:17 +01:00
|
|
|
abstract public function getBranchName();
|
|
|
|
abstract public function getSourceControlPath();
|
2012-06-04 21:30:50 +02:00
|
|
|
abstract public function isHistoryDefaultImmutable();
|
|
|
|
abstract public function supportsAmend();
|
2011-12-03 01:21:14 +01:00
|
|
|
abstract public function getWorkingCopyRevision();
|
2012-03-16 21:40:33 +01:00
|
|
|
abstract public function updateWorkingCopy();
|
2012-06-12 21:39:15 +02:00
|
|
|
abstract public function getMetadataPath();
|
2012-01-24 17:07:38 +01:00
|
|
|
abstract public function loadWorkingCopyDifferentialRevisions(
|
|
|
|
ConduitClient $conduit,
|
|
|
|
array $query);
|
Allow `arc` to identify repositories without "project_id"
Summary:
Ref T4343. Continues the process of reducing the prominence of Arcanist Projects. Primarily:
- Query Phabricator to identify the working copy based on explicit configuration, or guess based on heuristics.
- Enhance `arc which` to explain the process to the user.
- The `project_id` key is no longer required in `.arcconfig`.
Minor/cleanup changes:
- Rename `project_id` to `project.name` (consistency, clarity).
- Rename `conduit_uri` to `phabricator.uri` (consistency, clairty).
- These both need documentation updates.
- Add `repository.callsign` to explicitly bind to a repository.
- Updated `.arcconfig` for the new values.
- Fix a unit test which broke a while ago when we fixed a rare definition of "unstaged".
- Make `getRepositoryUUID()` generic so we can get rid of one `instanceof`.
Test Plan:
- Ran `arc which`.
- Ran `arc diff`.
- This doesn't really change anything, so the only real risk is version compatibility breaks. This //does// introduce such a break, but the window is very narrow: if you upgrade `arc` after this commit, and try to diff against a Phabricator which was updated after yesterday (D8068) but before D8072 lands, the lookup will work so we'll add `repositoryPHID` to the `differential.creatediff` call, but it won't exist in Phabricator yet. This window is so narrow that I'm not going to try to fix it, as I'd guess there is a significant chance that no users will be affected. I don't see a clever way to fix it that doesn't involve a lot of work, either.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T4343
Differential Revision: https://secure.phabricator.com/D8073
2014-01-27 00:31:30 +01:00
|
|
|
abstract public function getRemoteURI();
|
|
|
|
|
2011-09-15 03:44:54 +02:00
|
|
|
|
2012-11-30 02:40:07 +01:00
|
|
|
public function getUnderlyingWorkingCopyRevision() {
|
|
|
|
return $this->getWorkingCopyRevision();
|
|
|
|
}
|
|
|
|
|
2012-11-09 08:26:27 +01:00
|
|
|
public function getChangedFiles($since_commit) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-11-20 19:43:19 +01:00
|
|
|
public function getAuthor() {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-11-15 21:33:36 +01:00
|
|
|
public function addToCommit(array $paths) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
abstract public function supportsLocalCommits();
|
|
|
|
|
2012-11-15 21:33:36 +01:00
|
|
|
public function doCommit($message) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2013-04-16 22:32:12 +02:00
|
|
|
public function amendCommit($message = null) {
|
2012-06-04 21:30:50 +02:00
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-04-23 23:09:29 +02:00
|
|
|
public function getAllBranches() {
|
|
|
|
// TODO: Implement for Mercurial/SVN and make abstract.
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2012-03-07 22:02:53 +01:00
|
|
|
public function hasLocalCommit($commit) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-07-01 20:06:05 +02:00
|
|
|
public function getCommitMessage($commit) {
|
2012-01-13 04:03:11 +01:00
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-05-11 15:07:33 +02:00
|
|
|
public function getCommitSummary($commit) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2011-09-15 03:44:54 +02:00
|
|
|
public function getAllLocalChanges() {
|
Add an "arc merge" workflow
Summary:
This should support conservative rewrite policies in git fairly well, under an
assumed workflow of:
- Develop in local branches, never rewrite history.
- Commit with "-m" or by typing a brief, non-template commit message
describing the checkpoint.
- Provide rich information in the web console (reviewers, etc.)
- Finalize with "git checkout master && arc merge branch && git push" or some
flavor thereof.
This supports Mercurial somewhat. The major problem is that "hg merge" fails if
the local is a fastforward of the remote, at which point there's nowhere we can
throw the commit message. Oh well. Just push it and we'll do our best to link
them up based on local commit info.
I am increasingly forming an opinion that Mercurial is "saftey-scissors git".
But also maybe I have no clue what I'm doing. I just don't understand why anyone
would think it's a good idea to have a trunk consisting of ~50% known-broken
revisions, random checkpoint parts, whitespace changes, typo fixes, etc. If you
use git with branching you can avoid this by making a trunk out of merges or
with rebase/amend, but there seems to be no way to have "one commit = one idea"
in any real sense in Mercurial.
Test Plan: Execute "arc merge" in git and mercurial.
Reviewers: fratrik, Makinde, aran, jungejason, tuomaspelkonen
Reviewed By: Makinde
CC: aran, epriestley, Makinde
Differential Revision: 860
2011-08-26 01:02:03 +02:00
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract public function supportsLocalBranchMerge();
|
|
|
|
|
|
|
|
public function performLocalBranchMerge($branch, $message) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFinalizedRevisionMessage() {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
2011-09-15 03:44:54 +02:00
|
|
|
}
|
|
|
|
|
2012-07-01 20:06:05 +02:00
|
|
|
public function execxLocal($pattern /* , ... */) {
|
2012-03-03 01:47:34 +01:00
|
|
|
$args = func_get_args();
|
|
|
|
return $this->buildLocalFuture($args)->resolvex();
|
|
|
|
}
|
|
|
|
|
2012-07-01 20:06:05 +02:00
|
|
|
public function execManualLocal($pattern /* , ... */) {
|
2012-03-03 01:47:34 +01:00
|
|
|
$args = func_get_args();
|
|
|
|
return $this->buildLocalFuture($args)->resolve();
|
|
|
|
}
|
|
|
|
|
2012-07-01 20:06:05 +02:00
|
|
|
public function execFutureLocal($pattern /* , ... */) {
|
2012-03-25 18:32:20 +02:00
|
|
|
$args = func_get_args();
|
|
|
|
return $this->buildLocalFuture($args);
|
|
|
|
}
|
|
|
|
|
2012-03-03 01:47:34 +01:00
|
|
|
abstract protected function buildLocalFuture(array $argv);
|
|
|
|
|
2013-03-21 23:51:39 +01:00
|
|
|
public function canStashChanges() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function stashChanges() {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function unstashChanges() {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
Revenge of the git relative commit default
Summary:
The default of "arc diff" to "arc diff HEAD^" in git is universally confusing to everyone not at Facebook.
Drive the default with configuration instead. Even at Facebook, "origin/trunk" (or whatever) is probably a better default than "HEAD^".
See D863 for the last attempt at this.
NOTE: This is contentious!
Test Plan: Ran "arc diff", got prompted to set a default. Ran "arc diff" from a zero-commit repo, got sensible behavior
Reviewers: btrahan, vrana, nh, jungejason, tuomaspelkonen
Reviewed By: btrahan
CC: aran, epriestley, zeeg, davidreuss
Maniphest Tasks: T651
Differential Revision: https://secure.phabricator.com/D1861
2012-04-03 01:52:20 +02:00
|
|
|
|
|
|
|
/* -( Scratch Files )------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to read a scratch file, if it exists and is readable.
|
|
|
|
*
|
|
|
|
* @param string Scratch file name.
|
|
|
|
* @return mixed String for file contents, or false for failure.
|
|
|
|
* @task scratch
|
|
|
|
*/
|
|
|
|
public function readScratchFile($path) {
|
|
|
|
$full_path = $this->getScratchFilePath($path);
|
|
|
|
if (!$full_path) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Filesystem::pathExists($full_path)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$result = Filesystem::readFile($full_path);
|
|
|
|
} catch (FilesystemException $ex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to write a scratch file, if there's somewhere to put it and we can
|
|
|
|
* write there.
|
|
|
|
*
|
|
|
|
* @param string Scratch file name to write.
|
|
|
|
* @param string Data to write.
|
|
|
|
* @return bool True on success, false on failure.
|
|
|
|
* @task scratch
|
|
|
|
*/
|
|
|
|
public function writeScratchFile($path, $data) {
|
|
|
|
$dir = $this->getScratchFilePath('');
|
|
|
|
if (!$dir) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Filesystem::pathExists($dir)) {
|
|
|
|
try {
|
|
|
|
Filesystem::createDirectory($dir);
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Filesystem::writeFile($this->getScratchFilePath($path), $data);
|
|
|
|
} catch (FilesystemException $ex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to remove a scratch file.
|
|
|
|
*
|
|
|
|
* @param string Scratch file name to remove.
|
|
|
|
* @return bool True if the file was removed successfully.
|
|
|
|
* @task scratch
|
|
|
|
*/
|
|
|
|
public function removeScratchFile($path) {
|
|
|
|
$full_path = $this->getScratchFilePath($path);
|
|
|
|
if (!$full_path) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Filesystem::remove($full_path);
|
|
|
|
} catch (FilesystemException $ex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a human-readable description of the scratch file location.
|
|
|
|
*
|
|
|
|
* @param string Scratch file name.
|
|
|
|
* @return mixed String, or false on failure.
|
|
|
|
* @task scratch
|
|
|
|
*/
|
|
|
|
public function getReadableScratchFilePath($path) {
|
|
|
|
$full_path = $this->getScratchFilePath($path);
|
|
|
|
if ($full_path) {
|
|
|
|
return Filesystem::readablePath(
|
|
|
|
$full_path,
|
|
|
|
$this->getPath());
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the path to a scratch file, if possible.
|
|
|
|
*
|
|
|
|
* @param string Scratch file name.
|
|
|
|
* @return mixed File path, or false on failure.
|
|
|
|
* @task scratch
|
|
|
|
*/
|
|
|
|
public function getScratchFilePath($path) {
|
2012-06-12 21:39:15 +02:00
|
|
|
$new_scratch_path = Filesystem::resolvePath(
|
|
|
|
'arc',
|
|
|
|
$this->getMetadataPath());
|
|
|
|
|
|
|
|
static $checked = false;
|
|
|
|
if (!$checked) {
|
|
|
|
$checked = true;
|
|
|
|
$old_scratch_path = $this->getPath('.arc');
|
|
|
|
// we only want to do the migration once
|
|
|
|
// unfortunately, people have checked in .arc directories which
|
|
|
|
// means that the old one may get recreated after we delete it
|
|
|
|
if (Filesystem::pathExists($old_scratch_path) &&
|
|
|
|
!Filesystem::pathExists($new_scratch_path)) {
|
|
|
|
Filesystem::createDirectory($new_scratch_path);
|
|
|
|
$existing_files = Filesystem::listDirectory($old_scratch_path, true);
|
|
|
|
foreach ($existing_files as $file) {
|
|
|
|
$new_path = Filesystem::resolvePath($file, $new_scratch_path);
|
|
|
|
$old_path = Filesystem::resolvePath($file, $old_scratch_path);
|
|
|
|
Filesystem::writeFile(
|
|
|
|
$new_path,
|
|
|
|
Filesystem::readFile($old_path));
|
|
|
|
}
|
|
|
|
Filesystem::remove($old_scratch_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Filesystem::resolvePath($path, $new_scratch_path);
|
Revenge of the git relative commit default
Summary:
The default of "arc diff" to "arc diff HEAD^" in git is universally confusing to everyone not at Facebook.
Drive the default with configuration instead. Even at Facebook, "origin/trunk" (or whatever) is probably a better default than "HEAD^".
See D863 for the last attempt at this.
NOTE: This is contentious!
Test Plan: Ran "arc diff", got prompted to set a default. Ran "arc diff" from a zero-commit repo, got sensible behavior
Reviewers: btrahan, vrana, nh, jungejason, tuomaspelkonen
Reviewed By: btrahan
CC: aran, epriestley, zeeg, davidreuss
Maniphest Tasks: T651
Differential Revision: https://secure.phabricator.com/D1861
2012-04-03 01:52:20 +02:00
|
|
|
}
|
|
|
|
|
Add a DSL for selecting base commits
Summary:
New optional mode. If you set 'base' in local, project or global config or pass '--base' to 'arc diff' or 'arc which', it switches to DSL mode.
In DSL mode, lists of rules from args, local, project and global config are resolved, in that order. Rules can manipulate the rule machine or resolve into actual commits. Provides support for some 'arc' rules (mostly machine manipulation) and 'git' rules (symbolic ref and merge-base).
Test Plan:
Ran unit tests. Also:
```$ arc which --show-base --base 'arc:prompt'
Against which commit? HEAD
HEAD
$ arc which --show-base --base 'git:HEAD'
HEAD
$ arc which --show-base --base 'git:fake'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'git:origin/master'
origin/master
$ arc which --show-base --base 'git:upstream'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'literal:derp'
derp
$ arc which --show-base --base 'arc:halt'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc set-config --local base git:origin/master
Set key 'base' = 'git:origin/master' in local config.
$ arc which --show-base
origin/master
$ arc which --show-base --base 'git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:yield, git:HEAD^'
origin/master
$ arc which --show-base --base 'arc:global, git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:global, git:merge-base(origin/master)'
3f4f8992fba8d1f142974da36a82bae900e247c0```
Reviewers: dschleimer, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1233
Differential Revision: https://secure.phabricator.com/D2748
2012-06-15 23:01:28 +02:00
|
|
|
|
|
|
|
/* -( Base Commits )------------------------------------------------------- */
|
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
abstract public function supportsCommitRanges();
|
|
|
|
|
|
|
|
final public function setBaseCommit($symbolic_commit) {
|
|
|
|
if (!$this->supportsCommitRanges()) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->symbolicBaseCommit = $symbolic_commit;
|
|
|
|
$this->reloadCommitRange();
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-06-11 23:37:01 +02:00
|
|
|
public function setHeadCommit($symbolic_commit) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
final public function getBaseCommit() {
|
|
|
|
if (!$this->supportsCommitRanges()) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->resolvedBaseCommit === null) {
|
|
|
|
$commit = $this->buildBaseCommit($this->symbolicBaseCommit);
|
|
|
|
$this->resolvedBaseCommit = $commit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->resolvedBaseCommit;
|
|
|
|
}
|
|
|
|
|
2014-06-11 23:37:01 +02:00
|
|
|
public function getHeadCommit() {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:54:08 +01:00
|
|
|
final public function reloadCommitRange() {
|
|
|
|
$this->resolvedBaseCommit = null;
|
|
|
|
$this->baseCommitExplanation = null;
|
|
|
|
|
|
|
|
$this->didReloadCommitRange();
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function didReloadCommitRange() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildBaseCommit($symbolic_commit) {
|
|
|
|
throw new ArcanistCapabilityNotSupportedException($this);
|
|
|
|
}
|
Add a DSL for selecting base commits
Summary:
New optional mode. If you set 'base' in local, project or global config or pass '--base' to 'arc diff' or 'arc which', it switches to DSL mode.
In DSL mode, lists of rules from args, local, project and global config are resolved, in that order. Rules can manipulate the rule machine or resolve into actual commits. Provides support for some 'arc' rules (mostly machine manipulation) and 'git' rules (symbolic ref and merge-base).
Test Plan:
Ran unit tests. Also:
```$ arc which --show-base --base 'arc:prompt'
Against which commit? HEAD
HEAD
$ arc which --show-base --base 'git:HEAD'
HEAD
$ arc which --show-base --base 'git:fake'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'git:origin/master'
origin/master
$ arc which --show-base --base 'git:upstream'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'literal:derp'
derp
$ arc which --show-base --base 'arc:halt'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc set-config --local base git:origin/master
Set key 'base' = 'git:origin/master' in local config.
$ arc which --show-base
origin/master
$ arc which --show-base --base 'git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:yield, git:HEAD^'
origin/master
$ arc which --show-base --base 'arc:global, git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:global, git:merge-base(origin/master)'
3f4f8992fba8d1f142974da36a82bae900e247c0```
Reviewers: dschleimer, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1233
Differential Revision: https://secure.phabricator.com/D2748
2012-06-15 23:01:28 +02:00
|
|
|
|
|
|
|
public function getBaseCommitExplanation() {
|
|
|
|
return $this->baseCommitExplanation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setBaseCommitExplanation($explanation) {
|
|
|
|
$this->baseCommitExplanation = $explanation;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function resolveBaseCommitRule($rule, $source) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setBaseCommitArgumentRules($base_commit_argument_rules) {
|
|
|
|
$this->baseCommitArgumentRules = $base_commit_argument_rules;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseCommitArgumentRules() {
|
|
|
|
return $this->baseCommitArgumentRules;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function resolveBaseCommit() {
|
2013-10-19 01:10:06 +02:00
|
|
|
$base_commit_rules = array(
|
|
|
|
'runtime' => $this->getBaseCommitArgumentRules(),
|
|
|
|
'local' => '',
|
|
|
|
'project' => '',
|
|
|
|
'user' => '',
|
|
|
|
'system' => '',
|
|
|
|
);
|
|
|
|
$all_sources = $this->configurationManager->getConfigFromAllSources('base');
|
|
|
|
|
|
|
|
$base_commit_rules = $all_sources + $base_commit_rules;
|
Add a DSL for selecting base commits
Summary:
New optional mode. If you set 'base' in local, project or global config or pass '--base' to 'arc diff' or 'arc which', it switches to DSL mode.
In DSL mode, lists of rules from args, local, project and global config are resolved, in that order. Rules can manipulate the rule machine or resolve into actual commits. Provides support for some 'arc' rules (mostly machine manipulation) and 'git' rules (symbolic ref and merge-base).
Test Plan:
Ran unit tests. Also:
```$ arc which --show-base --base 'arc:prompt'
Against which commit? HEAD
HEAD
$ arc which --show-base --base 'git:HEAD'
HEAD
$ arc which --show-base --base 'git:fake'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'git:origin/master'
origin/master
$ arc which --show-base --base 'git:upstream'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'literal:derp'
derp
$ arc which --show-base --base 'arc:halt'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc set-config --local base git:origin/master
Set key 'base' = 'git:origin/master' in local config.
$ arc which --show-base
origin/master
$ arc which --show-base --base 'git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:yield, git:HEAD^'
origin/master
$ arc which --show-base --base 'arc:global, git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:global, git:merge-base(origin/master)'
3f4f8992fba8d1f142974da36a82bae900e247c0```
Reviewers: dschleimer, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1233
Differential Revision: https://secure.phabricator.com/D2748
2012-06-15 23:01:28 +02:00
|
|
|
|
|
|
|
$parser = new ArcanistBaseCommitParser($this);
|
2013-10-19 01:10:06 +02:00
|
|
|
$commit = $parser->resolveBaseCommit($base_commit_rules);
|
Add a DSL for selecting base commits
Summary:
New optional mode. If you set 'base' in local, project or global config or pass '--base' to 'arc diff' or 'arc which', it switches to DSL mode.
In DSL mode, lists of rules from args, local, project and global config are resolved, in that order. Rules can manipulate the rule machine or resolve into actual commits. Provides support for some 'arc' rules (mostly machine manipulation) and 'git' rules (symbolic ref and merge-base).
Test Plan:
Ran unit tests. Also:
```$ arc which --show-base --base 'arc:prompt'
Against which commit? HEAD
HEAD
$ arc which --show-base --base 'git:HEAD'
HEAD
$ arc which --show-base --base 'git:fake'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'git:origin/master'
origin/master
$ arc which --show-base --base 'git:upstream'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc which --show-base --base 'literal:derp'
derp
$ arc which --show-base --base 'arc:halt'
Usage Exception: None of the rules in your 'base' configuration matched a valid commit. Adjust rules or specify which commit you want to use explicitly.
$ arc set-config --local base git:origin/master
Set key 'base' = 'git:origin/master' in local config.
$ arc which --show-base
origin/master
$ arc which --show-base --base 'git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:yield, git:HEAD^'
origin/master
$ arc which --show-base --base 'arc:global, git:HEAD^'
HEAD^
$ arc which --show-base --base 'arc:global, git:merge-base(origin/master)'
3f4f8992fba8d1f142974da36a82bae900e247c0```
Reviewers: dschleimer, vrana
Reviewed By: dschleimer
CC: aran
Maniphest Tasks: T1233
Differential Revision: https://secure.phabricator.com/D2748
2012-06-15 23:01:28 +02:00
|
|
|
|
|
|
|
return $commit;
|
|
|
|
}
|
|
|
|
|
Allow `arc` to identify repositories without "project_id"
Summary:
Ref T4343. Continues the process of reducing the prominence of Arcanist Projects. Primarily:
- Query Phabricator to identify the working copy based on explicit configuration, or guess based on heuristics.
- Enhance `arc which` to explain the process to the user.
- The `project_id` key is no longer required in `.arcconfig`.
Minor/cleanup changes:
- Rename `project_id` to `project.name` (consistency, clarity).
- Rename `conduit_uri` to `phabricator.uri` (consistency, clairty).
- These both need documentation updates.
- Add `repository.callsign` to explicitly bind to a repository.
- Updated `.arcconfig` for the new values.
- Fix a unit test which broke a while ago when we fixed a rare definition of "unstaged".
- Make `getRepositoryUUID()` generic so we can get rid of one `instanceof`.
Test Plan:
- Ran `arc which`.
- Ran `arc diff`.
- This doesn't really change anything, so the only real risk is version compatibility breaks. This //does// introduce such a break, but the window is very narrow: if you upgrade `arc` after this commit, and try to diff against a Phabricator which was updated after yesterday (D8068) but before D8072 lands, the lookup will work so we'll add `repositoryPHID` to the `differential.creatediff` call, but it won't exist in Phabricator yet. This window is so narrow that I'm not going to try to fix it, as I'd guess there is a significant chance that no users will be affected. I don't see a clever way to fix it that doesn't involve a lot of work, either.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T4343
Differential Revision: https://secure.phabricator.com/D8073
2014-01-27 00:31:30 +01:00
|
|
|
public function getRepositoryUUID() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|