2011-01-10 00:22:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Facebook, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2011-02-19 20:36:08 +01:00
|
|
|
/**
|
|
|
|
* Explicitly marks Differential revisions as "Committed".
|
|
|
|
*
|
|
|
|
* @group workflow
|
|
|
|
*/
|
2011-01-10 00:22:25 +01:00
|
|
|
class ArcanistMarkCommittedWorkflow extends ArcanistBaseWorkflow {
|
|
|
|
|
|
|
|
public function getCommandHelp() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
**mark-committed** __revision__
|
|
|
|
Supports: git, svn
|
|
|
|
Manually mark a revision as committed. You should not normally need
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
to do this; arc commit (svn), arc amend (git), arc merge (git, hg) or
|
|
|
|
repository tracking on the master remote repository should do it for
|
|
|
|
you. However, if these mechanisms have failed for some reason you can
|
|
|
|
use this command to manually change a revision status from "Accepted"
|
|
|
|
to "Committed".
|
2011-01-10 00:22:25 +01:00
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return array(
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
'finalize' => array(
|
|
|
|
'help' =>
|
|
|
|
"Mark committed only if the repository is untracked and the ".
|
|
|
|
"revision is accepted. Continue even if the mark can't happen. This ".
|
|
|
|
"is a soft version of 'mark-committed' used by other workflows.",
|
|
|
|
),
|
2011-01-10 00:22:25 +01:00
|
|
|
'*' => 'revision',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresConduit() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresAuthentication() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
public function requiresRepositoryAPI() {
|
|
|
|
// NOTE: Technically we only use this to generate the right message at
|
|
|
|
// the end, and you can even get the wrong message (e.g., if you run
|
|
|
|
// "arc mark-committed D123" from a git repository, but D123 is an SVN
|
|
|
|
// revision). We could be smarter about this, but it's just display fluff.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-10 00:22:25 +01:00
|
|
|
public function run() {
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
$is_finalize = $this->getArgument('finalize');
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
$conduit = $this->getConduit();
|
|
|
|
|
|
|
|
$revision_list = $this->getArgument('revision', array());
|
|
|
|
if (!$revision_list) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"mark-committed requires a revision number.");
|
|
|
|
}
|
|
|
|
if (count($revision_list) != 1) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"mark-committed requires exactly one revision.");
|
|
|
|
}
|
2011-10-26 01:34:15 +02:00
|
|
|
$revision_id = reset($revision_list);
|
|
|
|
$revision_id = $this->normalizeRevisionID($revision_id);
|
2011-01-10 00:22:25 +01:00
|
|
|
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
$revision = null;
|
2011-01-10 00:22:25 +01:00
|
|
|
try {
|
2011-10-26 01:34:15 +02:00
|
|
|
$revision = $conduit->callMethodSynchronous(
|
|
|
|
'differential.getrevision',
|
|
|
|
array(
|
|
|
|
'revision_id' => $revision_id,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} catch (Exception $ex) {
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
if (!$is_finalize) {
|
|
|
|
throw new ArcanistUsageException(
|
2011-10-26 01:34:15 +02:00
|
|
|
"Revision D{$revision_id} does not exist."
|
|
|
|
);
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
|
2011-10-26 01:34:15 +02:00
|
|
|
if (!$is_finalize && $revision['statusName'] != 'Accepted') {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Revision D{$revision_id} is not committable. You can only mark ".
|
|
|
|
"revisions which have been 'accepted' as committed."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
if ($revision) {
|
2011-10-26 05:03:41 +02:00
|
|
|
if (!$is_finalize && $revision['authorPHID'] != $this->getUserPHID()) {
|
2011-10-26 01:34:15 +02:00
|
|
|
$prompt = "You are not the author of revision D{$revision_id}, ".
|
|
|
|
'are you sure you want to mark it committed?';
|
|
|
|
if (!phutil_console_confirm($prompt)) {
|
|
|
|
throw new ArcanistUserAbortException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
$actually_mark = true;
|
|
|
|
if ($is_finalize) {
|
|
|
|
$project_info = $conduit->callMethodSynchronous(
|
|
|
|
'arcanist.projectinfo',
|
|
|
|
array(
|
|
|
|
'name' => $this->getWorkingCopy()->getProjectID(),
|
|
|
|
));
|
2011-11-11 01:02:40 +01:00
|
|
|
if ($project_info['tracked'] || $revision['statusName'] != 'Accepted') {
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
$actually_mark = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($actually_mark) {
|
2011-10-26 01:34:15 +02:00
|
|
|
$revision_name = $revision['title'];
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
|
|
|
|
echo "Marking revision D{$revision_id} '{$revision_name}' ".
|
|
|
|
"committed...\n";
|
|
|
|
|
|
|
|
$conduit->callMethodSynchronous(
|
|
|
|
'differential.markcommitted',
|
|
|
|
array(
|
|
|
|
'revision_id' => $revision_id,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
|
2011-10-26 01:34:15 +02:00
|
|
|
$status = $revision['statusName'];
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
if ($status == 'Accepted' || $status == 'Committed') {
|
|
|
|
// If this has already been attached to commits, don't show the
|
|
|
|
// "you can push this commit" message since we know it's been committed
|
|
|
|
// already.
|
2011-10-26 01:34:15 +02:00
|
|
|
$is_finalized = empty($revision['commits']);
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
} else {
|
|
|
|
$is_finalized = false;
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
|
Automatically detect when to mark revisions committed
Summary:
See D945. We have this kludgy "remote_hooks_installed" mess right now, but we
have enough information on the server nowadays to figure this out without it.
Also reduce code duplication by sharing the "mark-committed" workflow.
This causes "arc merge" to effect commit marks.
Test Plan:
In Git, Mercurial and SVN working copies ran like a million
amend/merge/commit/mark-committed commands with and without --finalize in
various states of revision completion.
This change is really hard to exhaustively test because of the number of
combinations of VCS, revision state, command, command flags, repository state
and tracking state. All the reasonable tests I could come up with worked
correctly, though.
Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 967
2011-09-27 18:37:11 +02:00
|
|
|
if ($is_finalized) {
|
|
|
|
$message = $this->getRepositoryAPI()->getFinalizedRevisionMessage();
|
|
|
|
echo phutil_console_wrap($message)."\n";
|
|
|
|
} else {
|
|
|
|
echo "Done.\n";
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|