1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-11 07:11:03 +01:00

Support git svn dcommit in arc land

Test Plan:
  $ arc land # in Git SVN repository

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4123
This commit is contained in:
vrana 2012-12-07 18:13:32 -08:00
parent 7b2ce3a987
commit c68a048213
2 changed files with 42 additions and 23 deletions

View file

@ -859,20 +859,14 @@ abstract class ArcanistBaseWorkflow {
// TODO: Check commits since tracking branch. If empty then return false. // TODO: Check commits since tracking branch. If empty then return false.
$repository_phid = idx($this->getProjectInfo(), 'repositoryPHID'); $repository = $this->loadProjectRepository();
if ($repository_phid) { if ($repository) {
$repositories = $this->getConduit()->callMethodSynchronous( $callsign = $repository['callsign'];
'repository.query', $known_commits = $this->getConduit()->callMethodSynchronous(
array()); 'diffusion.getcommits',
$callsigns = ipull($repositories, 'callsign', 'phid'); array('commits' => array('r'.$callsign.$commit['commit'])));
$callsign = idx($callsigns, $repository_phid); if (ifilter($known_commits, 'error', $negate = true)) {
if ($callsign) { return false;
$known_commits = $this->getConduit()->callMethodSynchronous(
'diffusion.getcommits',
array('commits' => array('r'.$callsign.$commit['commit'])));
if (ifilter($known_commits, 'error', $negate = true)) {
return false;
}
} }
} }
@ -1432,6 +1426,20 @@ abstract class ArcanistBaseWorkflow {
return $this->projectInfo; return $this->projectInfo;
} }
protected function loadProjectRepository() {
$repository_phid = idx($this->getProjectInfo(), 'repositoryPHID');
if (!$repository_phid) {
return array();
}
$repositories = $this->getConduit()->callMethodSynchronous(
'repository.query',
array());
$repositories = ipull($repositories, null, 'phid');
return idx($repositories, $repository_phid, array());
}
protected function newInteractiveEditor($text) { protected function newInteractiveEditor($text) {
$editor = new PhutilInteractiveEditor($text); $editor = new PhutilInteractiveEditor($text);

View file

@ -7,6 +7,7 @@
*/ */
final class ArcanistLandWorkflow extends ArcanistBaseWorkflow { final class ArcanistLandWorkflow extends ArcanistBaseWorkflow {
private $isGit; private $isGit;
private $isGitSvn;
private $isHg; private $isHg;
private $oldBranch; private $oldBranch;
@ -170,6 +171,11 @@ EOTEXT
"'arc land' only supports git and mercurial."); "'arc land' only supports git and mercurial.");
} }
if ($this->isGit) {
$repository = $this->loadProjectRepository();
$this->isGitSvn = (idx($repository, 'vcs') == 'svn');
}
$branch = $this->getArgument('branch'); $branch = $this->getArgument('branch');
if (empty($branch)) { if (empty($branch)) {
$branch = $this->getBranchOrBookmark(); $branch = $this->getBranchOrBookmark();
@ -205,7 +211,9 @@ EOTEXT
} }
$this->ontoRemoteBranch = $this->onto; $this->ontoRemoteBranch = $this->onto;
if ($this->isGit) { if ($this->isGitSvn) {
$this->ontoRemoteBranch = 'trunk';
} else if ($this->isGit) {
$this->ontoRemoteBranch = $this->remote.'/'.$this->onto; $this->ontoRemoteBranch = $this->remote.'/'.$this->onto;
} }
@ -362,13 +370,14 @@ EOTEXT
if ($this->isGit) { if ($this->isGit) {
$repository_api->execxLocal('pull --ff-only'); $repository_api->execxLocal('pull --ff-only');
list($out) = $repository_api->execxLocal( if (!$this->isGitSvn) {
'log %s/%s..%s', list($out) = $repository_api->execxLocal(
$this->remote, 'log %s..%s',
$this->onto, $this->ontoRemoteBranch,
$this->onto); $this->onto);
if (strlen(trim($out))) { if (strlen(trim($out))) {
$local_ahead_of_remote = true; $local_ahead_of_remote = true;
}
} }
} else if ($this->isHg) { } else if ($this->isHg) {
// execManual instead of execx because outgoing returns // execManual instead of execx because outgoing returns
@ -549,7 +558,9 @@ EOTEXT
chdir($repository_api->getPath()); chdir($repository_api->getPath());
if ($this->isGit) { if ($this->isGitSvn) {
$err = phutil_passthru('git svn dcommit');
} else if ($this->isGit) {
$err = phutil_passthru( $err = phutil_passthru(
'git push %s %s', 'git push %s %s',
$this->remote, $this->remote,