Skip to content

Commit dec8bac

Browse files
author
epriestley
committedJan 24, 2011
Conduit: differential.creatediff
1 parent 2aaa95e commit dec8bac

19 files changed

+622
-10
lines changed
 

‎.arcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"project_id" : "phabricator",
3-
"conduit_uri" : "http://tools.epriestley-conduit.dev1557.facebook.com/api/",
3+
"conduit_uri" : "http://local.aphront.com/api/",
44
"lint_engine" : "PhutilLintEngine",
55
"unit_engine" : "PhutilUnitTestEngine",
66
"copyright_holder" : "Facebook, Inc.",

‎src/__phutil_library_map__.php

+13
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@
4747
'AphrontWebpageResponse' => 'aphront/response/webpage',
4848
'ConduitAPIMethod' => 'applications/conduit/method/base',
4949
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
50+
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
5051
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
5152
'ConduitException' => 'applications/conduit/protocol/exception',
5253
'DifferentialAction' => 'applications/differential/constants/action',
5354
'DifferentialChangeType' => 'applications/differential/constants/changetype',
55+
'DifferentialChangeset' => 'applications/differential/storage/changeset',
56+
'DifferentialDAO' => 'applications/differential/storage/base',
57+
'DifferentialDiff' => 'applications/differential/storage/diff',
58+
'DifferentialHunk' => 'applications/differential/storage/hunk',
5459
'DifferentialLintStatus' => 'applications/differential/constants/lintstatus',
60+
'DifferentialRevision' => 'applications/differential/storage/revision',
61+
'DifferentialRevisionControlSystem' => 'applications/differential/constants/revisioncontrolsystem',
5562
'DifferentialRevisionStatus' => 'applications/differential/constants/revisionstatus',
5663
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
5764
'LiskDAO' => 'storage/lisk/dao',
@@ -141,7 +148,13 @@
141148
'AphrontSideNavView' => 'AphrontView',
142149
'AphrontTableView' => 'AphrontView',
143150
'AphrontWebpageResponse' => 'AphrontResponse',
151+
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
144152
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
153+
'DifferentialChangeset' => 'DifferentialDAO',
154+
'DifferentialDAO' => 'PhabricatorLiskDAO',
155+
'DifferentialDiff' => 'DifferentialDAO',
156+
'DifferentialHunk' => 'DifferentialDAO',
157+
'DifferentialRevision' => 'DifferentialDAO',
145158
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
146159
'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
147160
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod {
20+
21+
public function getMethodDescription() {
22+
return "Create a new Differential diff.";
23+
}
24+
25+
public function defineParamTypes() {
26+
return array(
27+
'changes' => 'required list<dict>',
28+
'sourceMachine' => 'required string',
29+
'sourcePath' => 'required string',
30+
'branch' => 'required string',
31+
'sourceControlSystem' => 'required enum<svn, git>',
32+
'sourceControlPath' => 'required string',
33+
'sourceControlBaseRevision' => 'required string',
34+
'parentRevisionID' => 'optional revisionid',
35+
'creationMethod' => 'optional string',
36+
'ownerPHID' => 'optional phid',
37+
'arcanistProject' => 'optional string',
38+
'lintStatus' =>
39+
'required enum<none, skip, okay, warn, fail>',
40+
'unitStatus' =>
41+
'required enum<none, skip, okay, warn, fail>',
42+
);
43+
}
44+
45+
public function defineReturnType() {
46+
return 'nonempty dict';
47+
}
48+
49+
public function defineErrorTypes() {
50+
return array(
51+
);
52+
}
53+
54+
protected function execute(ConduitAPIRequest $request) {
55+
$change_data = $request->getValue('changes');
56+
57+
$changes = array();
58+
foreach ($change_data as $dict) {
59+
$changes[] = ArcanistDiffChange::newFromDictionary($dict);
60+
}
61+
62+
$diff = DifferentialDiff::newFromRawChanges($changes);
63+
$diff->setSourcePath($request->getValue('sourcePath'));
64+
$diff->setSourceMachine($request->getValue('sourceMachine'));
65+
66+
$diff->setBranch($request->getValue('branch'));
67+
$diff->setCreationMethod($request->getValue('creationMethod'));
68+
$diff->setOwnerPHID($request->getValue('ownerPHID'));
69+
70+
$parent_id = $request->getValue('parentRevisionID');
71+
if ($parent_id) {
72+
$parent_rev = id(new DifferentialRevision())->load($parent_id);
73+
if ($parent_rev) {
74+
if ($parent_rev->getStatus() != DifferentialRevisionStatus::COMMITTED) {
75+
$diff->setParentRevisionID($parent_id);
76+
}
77+
}
78+
}
79+
80+
$system = $request->getValue('sourceControlSystem');
81+
$diff->setSourceControlSystem($system);
82+
$diff->setSourceControlPath($request->getValue('sourceControlPath'));
83+
$diff->setSourceControlBaseRevision(
84+
$request->getValue('sourceControlBaseRevision'));
85+
86+
$diff->setArcanistProject($request->getValue('arcanistProject'));
87+
88+
switch ($request->getValue('lintStatus')) {
89+
case 'skip':
90+
$diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
91+
break;
92+
case 'okay':
93+
$diff->setLintStatus(DifferentialLintStatus::LINT_OKAY);
94+
break;
95+
case 'warn':
96+
$diff->setLintStatus(DifferentialLintStatus::LINT_WARN);
97+
break;
98+
case 'fail':
99+
$diff->setLintStatus(DifferentialLintStatus::LINT_FAIL);
100+
break;
101+
case 'none':
102+
default:
103+
$diff->setLintStatus(DifferentialLintStatus::LINT_NONE);
104+
break;
105+
}
106+
107+
switch ($request->getValue('unitStatus')) {
108+
case 'skip':
109+
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP);
110+
break;
111+
case 'okay':
112+
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_OKAY);
113+
break;
114+
case 'warn':
115+
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_WARN);
116+
break;
117+
case 'fail':
118+
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_FAIL);
119+
break;
120+
case 'none':
121+
default:
122+
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_NONE);
123+
break;
124+
}
125+
126+
$diff->save();
127+
128+
return array(
129+
'diffid' => $diff->getID(),
130+
'uri' => '?'//$diff->getURI(),
131+
);
132+
}
133+
134+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* This file is automatically generated. Lint this module to rebuild it.
4+
* @generated
5+
*/
6+
7+
8+
9+
phutil_require_module('arcanist', 'parser/diff/change');
10+
11+
phutil_require_module('phabricator', 'applications/conduit/method/base');
12+
phutil_require_module('phabricator', 'applications/differential/constants/lintstatus');
13+
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
14+
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
15+
phutil_require_module('phabricator', 'applications/differential/storage/diff');
16+
phutil_require_module('phabricator', 'applications/differential/storage/revision');
17+
18+
phutil_require_module('phutil', 'utils');
19+
20+
21+
phutil_require_source('ConduitAPI_differential_creatediff_Method.php');

‎src/applications/differential/constants/lintstatus/DifferentialLintStatus.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
final class DifferentialLintStatus {
2020

21-
const LINT_NO = 0;
22-
const LINT_WARNINGS = 1;
23-
const LINT_OKAY = 2;
24-
const LINT_NOT_APPLICABLE = 3;
21+
const LINT_NONE = 0;
22+
const LINT_OKAY = 1;
23+
const LINT_WARN = 2;
24+
const LINT_FAIL = 3;
2525
const LINT_SKIP = 4;
2626

2727
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
final class DifferentialRevisionControlSystem {
20+
21+
const SVN = 'svn';
22+
const GIT = 'git';
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* This file is automatically generated. Lint this module to rebuild it.
4+
* @generated
5+
*/
6+
7+
8+
9+
10+
phutil_require_source('DifferentialRevisionControlSystem.php');

‎src/applications/differential/constants/unitstatus/DifferentialUnitStatus.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
final class DifferentialUnitStatus {
2020

21-
const UNIT_NO = 0;
22-
const UNIT_FAIL = 1;
23-
const UNIT_OKAY = 2;
24-
const UNIT_NO_TESTS = 3;
25-
const UNIT_NOT_APPLICABLE = 4;
21+
const UNIT_NONE = 0;
22+
const UNIT_OKAY = 1;
23+
const UNIT_WARN = 2;
24+
const UNIT_FAIL = 3;
25+
const UNIT_SKIP = 4;
2626

2727
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
abstract class DifferentialDAO extends PhabricatorLiskDAO {
20+
21+
public function getApplicationName() {
22+
return 'differential';
23+
}
24+
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* This file is automatically generated. Lint this module to rebuild it.
4+
* @generated
5+
*/
6+
7+
phutil_require_module('phabricator', 'applications/base/storage/lisk');
8+
9+
10+
phutil_require_source('DifferentialDAO.php');

0 commit comments

Comments
 (0)
Failed to load comments.