mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Conduit: differential.creatediff
This commit is contained in:
parent
2aaa95e640
commit
dec8bac3a3
19 changed files with 622 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"project_id" : "phabricator",
|
||||
"conduit_uri" : "http://tools.epriestley-conduit.dev1557.facebook.com/api/",
|
||||
"conduit_uri" : "http://local.aphront.com/api/",
|
||||
"lint_engine" : "PhutilLintEngine",
|
||||
"unit_engine" : "PhutilUnitTestEngine",
|
||||
"copyright_holder" : "Facebook, Inc.",
|
||||
|
|
|
@ -47,11 +47,18 @@ phutil_register_library_map(array(
|
|||
'AphrontWebpageResponse' => 'aphront/response/webpage',
|
||||
'ConduitAPIMethod' => 'applications/conduit/method/base',
|
||||
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
|
||||
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
||||
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
||||
'ConduitException' => 'applications/conduit/protocol/exception',
|
||||
'DifferentialAction' => 'applications/differential/constants/action',
|
||||
'DifferentialChangeType' => 'applications/differential/constants/changetype',
|
||||
'DifferentialChangeset' => 'applications/differential/storage/changeset',
|
||||
'DifferentialDAO' => 'applications/differential/storage/base',
|
||||
'DifferentialDiff' => 'applications/differential/storage/diff',
|
||||
'DifferentialHunk' => 'applications/differential/storage/hunk',
|
||||
'DifferentialLintStatus' => 'applications/differential/constants/lintstatus',
|
||||
'DifferentialRevision' => 'applications/differential/storage/revision',
|
||||
'DifferentialRevisionControlSystem' => 'applications/differential/constants/revisioncontrolsystem',
|
||||
'DifferentialRevisionStatus' => 'applications/differential/constants/revisionstatus',
|
||||
'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus',
|
||||
'LiskDAO' => 'storage/lisk/dao',
|
||||
|
@ -141,7 +148,13 @@ phutil_register_library_map(array(
|
|||
'AphrontSideNavView' => 'AphrontView',
|
||||
'AphrontTableView' => 'AphrontView',
|
||||
'AphrontWebpageResponse' => 'AphrontResponse',
|
||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||
'DifferentialChangeset' => 'DifferentialDAO',
|
||||
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
||||
'DifferentialDiff' => 'DifferentialDAO',
|
||||
'DifferentialHunk' => 'DifferentialDAO',
|
||||
'DifferentialRevision' => 'DifferentialDAO',
|
||||
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
|
||||
'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO',
|
||||
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Create a new Differential diff.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'changes' => 'required list<dict>',
|
||||
'sourceMachine' => 'required string',
|
||||
'sourcePath' => 'required string',
|
||||
'branch' => 'required string',
|
||||
'sourceControlSystem' => 'required enum<svn, git>',
|
||||
'sourceControlPath' => 'required string',
|
||||
'sourceControlBaseRevision' => 'required string',
|
||||
'parentRevisionID' => 'optional revisionid',
|
||||
'creationMethod' => 'optional string',
|
||||
'ownerPHID' => 'optional phid',
|
||||
'arcanistProject' => 'optional string',
|
||||
'lintStatus' =>
|
||||
'required enum<none, skip, okay, warn, fail>',
|
||||
'unitStatus' =>
|
||||
'required enum<none, skip, okay, warn, fail>',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'nonempty dict';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$change_data = $request->getValue('changes');
|
||||
|
||||
$changes = array();
|
||||
foreach ($change_data as $dict) {
|
||||
$changes[] = ArcanistDiffChange::newFromDictionary($dict);
|
||||
}
|
||||
|
||||
$diff = DifferentialDiff::newFromRawChanges($changes);
|
||||
$diff->setSourcePath($request->getValue('sourcePath'));
|
||||
$diff->setSourceMachine($request->getValue('sourceMachine'));
|
||||
|
||||
$diff->setBranch($request->getValue('branch'));
|
||||
$diff->setCreationMethod($request->getValue('creationMethod'));
|
||||
$diff->setOwnerPHID($request->getValue('ownerPHID'));
|
||||
|
||||
$parent_id = $request->getValue('parentRevisionID');
|
||||
if ($parent_id) {
|
||||
$parent_rev = id(new DifferentialRevision())->load($parent_id);
|
||||
if ($parent_rev) {
|
||||
if ($parent_rev->getStatus() != DifferentialRevisionStatus::COMMITTED) {
|
||||
$diff->setParentRevisionID($parent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$system = $request->getValue('sourceControlSystem');
|
||||
$diff->setSourceControlSystem($system);
|
||||
$diff->setSourceControlPath($request->getValue('sourceControlPath'));
|
||||
$diff->setSourceControlBaseRevision(
|
||||
$request->getValue('sourceControlBaseRevision'));
|
||||
|
||||
$diff->setArcanistProject($request->getValue('arcanistProject'));
|
||||
|
||||
switch ($request->getValue('lintStatus')) {
|
||||
case 'skip':
|
||||
$diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
|
||||
break;
|
||||
case 'okay':
|
||||
$diff->setLintStatus(DifferentialLintStatus::LINT_OKAY);
|
||||
break;
|
||||
case 'warn':
|
||||
$diff->setLintStatus(DifferentialLintStatus::LINT_WARN);
|
||||
break;
|
||||
case 'fail':
|
||||
$diff->setLintStatus(DifferentialLintStatus::LINT_FAIL);
|
||||
break;
|
||||
case 'none':
|
||||
default:
|
||||
$diff->setLintStatus(DifferentialLintStatus::LINT_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($request->getValue('unitStatus')) {
|
||||
case 'skip':
|
||||
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP);
|
||||
break;
|
||||
case 'okay':
|
||||
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_OKAY);
|
||||
break;
|
||||
case 'warn':
|
||||
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_WARN);
|
||||
break;
|
||||
case 'fail':
|
||||
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_FAIL);
|
||||
break;
|
||||
case 'none':
|
||||
default:
|
||||
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
$diff->save();
|
||||
|
||||
return array(
|
||||
'diffid' => $diff->getID(),
|
||||
'uri' => '?'//$diff->getURI(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('arcanist', 'parser/diff/change');
|
||||
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/lintstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/unitstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_differential_creatediff_Method.php');
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
final class DifferentialLintStatus {
|
||||
|
||||
const LINT_NO = 0;
|
||||
const LINT_WARNINGS = 1;
|
||||
const LINT_OKAY = 2;
|
||||
const LINT_NOT_APPLICABLE = 3;
|
||||
const LINT_NONE = 0;
|
||||
const LINT_OKAY = 1;
|
||||
const LINT_WARN = 2;
|
||||
const LINT_FAIL = 3;
|
||||
const LINT_SKIP = 4;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
final class DifferentialRevisionControlSystem {
|
||||
|
||||
const SVN = 'svn';
|
||||
const GIT = 'git';
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
phutil_require_source('DifferentialRevisionControlSystem.php');
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
final class DifferentialUnitStatus {
|
||||
|
||||
const UNIT_NO = 0;
|
||||
const UNIT_FAIL = 1;
|
||||
const UNIT_OKAY = 2;
|
||||
const UNIT_NO_TESTS = 3;
|
||||
const UNIT_NOT_APPLICABLE = 4;
|
||||
const UNIT_NONE = 0;
|
||||
const UNIT_OKAY = 1;
|
||||
const UNIT_WARN = 2;
|
||||
const UNIT_FAIL = 3;
|
||||
const UNIT_SKIP = 4;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
abstract class DifferentialDAO extends PhabricatorLiskDAO {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'differential';
|
||||
}
|
||||
|
||||
}
|
10
src/applications/differential/storage/base/__init__.php
Normal file
10
src/applications/differential/storage/base/__init__.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
phutil_require_module('phabricator', 'applications/base/storage/lisk');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialDAO.php');
|
|
@ -0,0 +1,129 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
class DifferentialChangeset extends DifferentialDAO {
|
||||
|
||||
protected $diffID;
|
||||
protected $oldFile;
|
||||
protected $fileName;
|
||||
protected $awayPaths;
|
||||
protected $changeType;
|
||||
protected $fileType;
|
||||
protected $metadata;
|
||||
protected $oldProperties;
|
||||
protected $newProperties;
|
||||
protected $addLines;
|
||||
protected $delLines;
|
||||
|
||||
protected function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_SERIALIZATION => array(
|
||||
'metadata' => self::SERIALIZATION_JSON,
|
||||
'oldProperties' => self::SERIALIZATION_JSON,
|
||||
'newProperties' => self::SERIALIZATION_JSON,
|
||||
'awayPaths' => self::SERIALIZATION_JSON,
|
||||
)) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function getAffectedLineCount() {
|
||||
return $this->getAddLines() + $this->getDelLines();
|
||||
}
|
||||
|
||||
public function getFileType() {
|
||||
return $this->fileType;
|
||||
}
|
||||
|
||||
public function getChangeType() {
|
||||
return $this->changeType;
|
||||
}
|
||||
|
||||
public function getDisplayFilename() {
|
||||
$name = $this->getFilename();
|
||||
if ($this->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
||||
$name .= '/';
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function addHunk(DifferentialHunk $hunk) {
|
||||
if (!isset($this->_hunks)) {
|
||||
$this->_hunks = array();
|
||||
}
|
||||
$this->_hunks[] = $hunk;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function attachHunks(array $hunks) {
|
||||
$this->_hunks = $hunks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHunks() {
|
||||
if (!isset($this->_hunks)) {
|
||||
throw new Exception("You must load hunks before accessing them.");
|
||||
}
|
||||
return $this->_hunks;
|
||||
}
|
||||
|
||||
public function loadHunks() {
|
||||
if (!$this->getID()) {
|
||||
return array();
|
||||
}
|
||||
return id(new DifferentialHunk())->loadAllWhere(
|
||||
'changesetID = %d',
|
||||
$this->getID());
|
||||
}
|
||||
|
||||
|
||||
public function delete() {
|
||||
$this->openTransaction();
|
||||
foreach ($this->loadHunks() as $hunk) {
|
||||
$hunk->delete();
|
||||
}
|
||||
$this->_hunks = array();
|
||||
$ret = parent::delete();
|
||||
$this->saveTransaction();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getSortKey() {
|
||||
$sort_key = $this->getFilename();
|
||||
// Sort files with ".h" in them first, so headers (.h, .hpp) come before
|
||||
// implementations (.c, .cpp, .cs).
|
||||
$sort_key = str_replace('.h', '.!h', $sort_key);
|
||||
return $sort_key;
|
||||
}
|
||||
|
||||
public function makeNewFile() {
|
||||
$file = array();
|
||||
foreach ($this->getHunks() as $hunk) {
|
||||
$file[] = $hunk->makeNewFile();
|
||||
}
|
||||
return implode("\n", $file);
|
||||
}
|
||||
|
||||
public function makeOldFile() {
|
||||
$file = array();
|
||||
foreach ($this->getHunks() as $hunk) {
|
||||
$file[] = $hunk->makeOldFile();
|
||||
}
|
||||
return implode("\n", $file);
|
||||
}
|
||||
|
||||
}
|
16
src/applications/differential/storage/changeset/__init__.php
Normal file
16
src/applications/differential/storage/changeset/__init__.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/hunk');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialChangeset.php');
|
103
src/applications/differential/storage/diff/DifferentialDiff.php
Normal file
103
src/applications/differential/storage/diff/DifferentialDiff.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
class DifferentialDiff extends DifferentialDAO {
|
||||
|
||||
protected $revisionID;
|
||||
protected $ownerPHID;
|
||||
|
||||
protected $sourceMachine;
|
||||
protected $sourcePath;
|
||||
|
||||
protected $sourceControlSystem;
|
||||
protected $sourceControlBaseRevision;
|
||||
protected $sourceControlPath;
|
||||
|
||||
protected $lintStatus;
|
||||
protected $unitStatus;
|
||||
|
||||
protected $lineCount;
|
||||
|
||||
protected $branch;
|
||||
|
||||
protected $parentRevisionID;
|
||||
protected $arcanistProject;
|
||||
protected $creationMethod;
|
||||
|
||||
public function loadChangesets() {
|
||||
if (!$this->getID()) {
|
||||
return array();
|
||||
}
|
||||
return id(new DifferentialChangeset())->loadAllWhere(
|
||||
'diffID = %d',
|
||||
$this->getID());
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$this->openTransaction();
|
||||
foreach ($this->loadChangesets() as $changeset) {
|
||||
$changeset->delete();
|
||||
}
|
||||
$ret = parent::delete();
|
||||
$this->saveTransaction();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function newFromRawChanges(array $changes) {
|
||||
$diff = new DifferentialDiff();
|
||||
|
||||
$lines = 0;
|
||||
foreach ($changes as $change) {
|
||||
$changeset = new DifferentialChangeset();
|
||||
$add_lines = 0;
|
||||
$del_lines = 0;
|
||||
foreach ($change->getHunks() as $hunk) {
|
||||
$dhunk = new Hunk();
|
||||
$dhunk->setOldOffset($hunk->getOldOffset());
|
||||
$dhunk->setOldLen($hunk->getOldLength());
|
||||
$dhunk->setNewOffset($hunk->getNewOffset());
|
||||
$dhunk->setNewLen($hunk->getNewLength());
|
||||
$dhunk->setChanges($hunk->getCorpus());
|
||||
$changeset->addHunk($dhunk);
|
||||
$add_lines += $hunk->getAddLines();
|
||||
$del_lines += $hunk->getDelLines();
|
||||
$lines += $add_lines + $del_lines;
|
||||
}
|
||||
$changeset->setHunkCount(count($change->getHunks()));
|
||||
|
||||
$changeset->setOldFile($change->getOldPath());
|
||||
$changeset->setNewFile($change->getCurrentPath());
|
||||
$changeset->setFilename($change->getCurrentPath());
|
||||
$changeset->setChangeType($change->getType());
|
||||
|
||||
$changeset->setFileType($change->getFileType());
|
||||
$changeset->setMetadata($change->getAllMetadata());
|
||||
$changeset->setOldProperties($change->getOldProperties());
|
||||
$changeset->setNewProperties($change->getNewProperties());
|
||||
$changeset->setAwayPaths($change->getAwayPaths());
|
||||
$changeset->setAddLines($add_lines);
|
||||
$changeset->setDelLines($del_lines);
|
||||
|
||||
$diff->addChangeset($changeset);
|
||||
}
|
||||
$diff->setLineCount($lines);
|
||||
|
||||
return $diff;
|
||||
}
|
||||
|
||||
}
|
15
src/applications/differential/storage/diff/__init__.php
Normal file
15
src/applications/differential/storage/diff/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialDiff.php');
|
|
@ -0,0 +1,52 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
class DifferentialHunk extends DifferentialDAO {
|
||||
|
||||
protected $changesetID;
|
||||
protected $changes;
|
||||
protected $oldOffset;
|
||||
protected $oldLen;
|
||||
protected $newOffset;
|
||||
protected $newLen;
|
||||
|
||||
public function makeNewFile() {
|
||||
return $this->makeContent($exclude = '-');
|
||||
}
|
||||
|
||||
public function makeOldFile() {
|
||||
return $this->makeContent($exclude = '+');
|
||||
}
|
||||
|
||||
public function makeChanges() {
|
||||
return $this->makeContent($exclude = ' ');
|
||||
}
|
||||
|
||||
final private function makeContent($exclude) {
|
||||
$results = array();
|
||||
$lines = explode("\n", $this->changes);
|
||||
foreach ($lines as $line) {
|
||||
if (isset($line[0]) && $line[0] == $exclude) {
|
||||
continue;
|
||||
}
|
||||
$results[] = substr($line, 1);
|
||||
}
|
||||
return implode("\n", $results);
|
||||
}
|
||||
|
||||
}
|
12
src/applications/differential/storage/hunk/__init__.php
Normal file
12
src/applications/differential/storage/hunk/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/base');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialHunk.php');
|
35
src/applications/differential/storage/revision/DifferentialRevision.php
Executable file
35
src/applications/differential/storage/revision/DifferentialRevision.php
Executable file
|
@ -0,0 +1,35 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
class DifferentialRevision extends DifferentialDAO {
|
||||
|
||||
protected $name;
|
||||
protected $status;
|
||||
|
||||
protected $summary;
|
||||
protected $testPlan;
|
||||
protected $revert;
|
||||
|
||||
protected $phid;
|
||||
protected $ownerPHID;
|
||||
|
||||
protected $dateCommitted;
|
||||
|
||||
protected $lineCount;
|
||||
|
||||
}
|
12
src/applications/differential/storage/revision/__init__.php
Normal file
12
src/applications/differential/storage/revision/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/base');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialRevision.php');
|
|
@ -78,6 +78,7 @@ function setup_aphront_basics() {
|
|||
date_default_timezone_set('America/Los_Angeles');
|
||||
}
|
||||
|
||||
phutil_load_library($libraries_root.'/arcanist/src');
|
||||
phutil_load_library($aphront_root.'/src');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue