<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
public function pullDataFromConduit(ConduitClient $conduit) {
- $result = $conduit->callMethod(
+ $result = $conduit->callMethodSynchronous(
'differential.parsecommitmessage',
array(
'corpus' => $this->rawCorpus,
));
- $result = $result->resolve();
if (!empty($result['errors'])) {
throw new ArcanistDifferentialCommitMessageParserException(
$result['errors']);
),
),
'create' => array(
- 'help' => "(EXPERIMENTAL) Create a new revision.",
+ 'help' => "Always create a new revision.",
'conflicts' => array(
'edit' => '--create can not be used with --edit.',
'only' => '--create can not be used with --only.',
'preview' => '--create can not be used with --preview.',
+
+ 'update' => '--create can not be used with --update.',
),
),
+ 'update' => array(
+ 'param' => 'revision_id',
+ 'help' => "Always update a specific revision.",
+ ),
'nounit' => array(
'help' =>
"Do not run unit tests.",
return false;
}
+ if ($this->getArgument('update')) {
+ return false;
+ }
+
if ($this->isRawDiffSource()) {
return true;
}
*/
private function buildCommitMessage() {
$is_create = $this->getArgument('create');
+ $is_update = $this->getArgument('update');
$is_raw = $this->isRawDiffSource();
$message = null;
}
}
+ if ($is_update) {
+ return $this->getCommitMessageFromRevision($is_update);
+ }
+
if ($is_raw) {
return null;
}
}
+ /**
+ * @task message
+ */
+ private function getCommitMessageFromRevision($revision_id) {
+ $id = $this->normalizeRevisionID($revision_id);
+
+ $revision = $this->getConduit()->callMethodSynchronous(
+ 'differential.query',
+ array(
+ 'ids' => array($id),
+ ));
+ $revision = head($revision);
+
+ if (!$revision) {
+ throw new ArcanistUsageException(
+ "Revision '{$revision_id}' does not exist!");
+ }
+
+ if ($revision['authorPHID'] != $this->getUserPHID()) {
+ $rev_title = $revision['title'];
+ throw new ArcanistUsageException(
+ "You don't own revision D{$id} '{$rev_title}'. You can only update ".
+ "revisions you own.");
+ }
+
+ $message = $this->getConduit()->callMethodSynchronous(
+ 'differential.getcommitmessage',
+ array(
+ 'revision_id' => $id,
+ 'edit' => false,
+ ));
+
+ $obj = ArcanistDifferentialCommitMessage::newFromRawCorpus($message);
+ $obj->pullDataFromConduit($this->getConduit());
+
+ return $obj;
+ }
+
+
/**
* @task message
*/