Page MenuHomePhabricator

D7985.id.diff
No OneTemporary

D7985.id.diff

Index: src/applications/diffusion/controller/DiffusionCommitController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionCommitController.php
+++ src/applications/diffusion/controller/DiffusionCommitController.php
@@ -348,10 +348,8 @@
$change_list->setRenderURI('/diffusion/'.$callsign.'/diff/');
$change_list->setRepository($repository);
$change_list->setUser($user);
- // pick the first branch for "Browse in Diffusion" View Option
- $branches = $commit_data->getCommitDetail('seenOnBranches', array());
- $first_branch = reset($branches);
- $change_list->setBranch($first_branch);
+
+ // TODO: Try to setBranch() to something reasonable here?
$change_list->setStandaloneURI(
'/diffusion/'.$callsign.'/diff/');
Index: src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
===================================================================
--- src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
+++ src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
@@ -246,7 +246,7 @@
$repository,
$ref->getIdentifier(),
$ref->getEpoch(),
- $ref->getBranch());
+ $close_immediately = true);
}
}
@@ -319,56 +319,21 @@
return true;
}
- private function isKnownCommitOnAnyAutocloseBranch(
- PhabricatorRepository $repository,
- $target) {
-
- $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
- 'repositoryID = %d AND commitIdentifier = %s',
- $repository->getID(),
- $target);
-
- if (!$commit) {
- $callsign = $repository->getCallsign();
-
- $console = PhutilConsole::getConsole();
- $console->writeErr(
- "WARNING: Repository '%s' is missing commits ('%s' is missing from ".
- "history). Run '%s' to repair the repository.\n",
- $callsign,
- $target,
- "bin/repository discover --repair {$callsign}");
-
- return false;
- }
-
- $data = $commit->loadCommitData();
- if (!$data) {
- return false;
- }
-
- if ($repository->shouldAutocloseCommit($commit, $data)) {
- return true;
- }
-
- return false;
- }
-
private function recordCommit(
PhabricatorRepository $repository,
$commit_identifier,
$epoch,
- $branch = null) {
+ $close_immediately) {
$commit = new PhabricatorRepositoryCommit();
$commit->setRepositoryID($repository->getID());
$commit->setCommitIdentifier($commit_identifier);
$commit->setEpoch($epoch);
+ if ($close_immediately) {
+ $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE);
+ }
$data = new PhabricatorRepositoryCommitData();
- if ($branch) {
- $data->setCommitDetail('seenOnBranches', array($branch));
- }
try {
$commit->openTransaction();
@@ -419,43 +384,6 @@
}
}
- private function updateCommit(
- PhabricatorRepository $repository,
- $commit_identifier,
- $branch) {
-
- $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
- 'repositoryID = %d AND commitIdentifier = %s',
- $repository->getID(),
- $commit_identifier);
-
- if (!$commit) {
- // This can happen if the phabricator DB doesn't have the commit info,
- // or the commit is so big that phabricator couldn't parse it. In this
- // case we just ignore it.
- return;
- }
-
- $data = id(new PhabricatorRepositoryCommitData())->loadOneWhere(
- 'commitID = %d',
- $commit->getID());
- if (!$data) {
- $data = new PhabricatorRepositoryCommitData();
- $data->setCommitID($commit->getID());
- }
- $branches = $data->getCommitDetail('seenOnBranches', array());
- $branches[] = $branch;
- $data->setCommitDetail('seenOnBranches', $branches);
- $data->save();
-
- $this->insertTask(
- $repository,
- $commit,
- array(
- 'only' => true
- ));
- }
-
private function insertTask(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit,
@@ -566,6 +494,8 @@
return;
}
+ $branches = $this->sortBranches($repository, $branches);
+
$callsign = $repository->getCallsign();
$tracked_something = false;
@@ -586,7 +516,10 @@
}
$this->log("Looking for new commits.");
- $this->executeGitDiscoverCommit($repository, $commit, $name, false);
+ $this->executeGitDiscoverCommit(
+ $repository,
+ $commit,
+ $repository->shouldAutocloseBranch($name));
}
if (!$tracked_something) {
@@ -596,31 +529,29 @@
"Repository r{$repo_callsign} '{$repo_name}' has no tracked branches! ".
"Verify that your branch filtering settings are correct.");
}
+ }
+ /**
+ * Sort branches so we process closeable branches first. This makes the
+ * whole import process a little cheaper, since we can close these commits
+ * the first time through rather than catching them in the refs step.
+ */
+ private function sortBranches(
+ PhabricatorRepository $repository,
+ array $branches) {
- $this->log("Discovering commits on autoclose branches...");
+ $head_branches = array();
+ $tail_branches = array();
foreach ($branches as $name => $commit) {
- $this->log("Examining branch '{$name}', at {$commit}'.");
- if (!$repository->shouldTrackBranch($name)) {
- $this->log("Skipping, branch is untracked.");
- continue;
- }
-
- if (!$repository->shouldAutocloseBranch($name)) {
- $this->log("Skipping, branch is not autoclose.");
- continue;
- }
-
- if ($this->isKnownCommitOnAnyAutocloseBranch($repository, $commit)) {
- $this->log("Skipping, commit is known on an autoclose branch.");
- continue;
+ if ($repository->shouldAutocloseBranch($name)) {
+ $head_branches[$name] = $commit;
+ } else {
+ $tail_branches[$name] = $commit;
}
-
- $this->log("Looking for new autoclose commits.");
- $this->executeGitDiscoverCommit($repository, $commit, $name, true);
}
- }
+ return $head_branches + $tail_branches;
+ }
/**
@@ -629,8 +560,7 @@
private function executeGitDiscoverCommit(
PhabricatorRepository $repository,
$commit,
- $branch,
- $autoclose) {
+ $close_immediately) {
$discover = array($commit);
$insert = array($commit);
@@ -651,15 +581,9 @@
continue;
}
$seen_parent[$parent] = true;
- if ($autoclose) {
- $known = $this->isKnownCommitOnAnyAutocloseBranch(
- $repository,
- $parent);
- } else {
- $known = $this->isKnownCommit($repository, $parent);
- }
+ $known = $this->isKnownCommit($repository, $parent);
if (!$known) {
- $this->log("Discovered commit '{$parent}'.");
+ $this->log(pht('Discovered commit "%s".', $parent));
$discover[] = $parent;
$insert[] = $parent;
}
@@ -670,22 +594,14 @@
}
$n = count($insert);
- if ($autoclose) {
- $this->log("Found {$n} new autoclose commits on branch '{$branch}'.");
- } else {
- $this->log("Found {$n} new commits on branch '{$branch}'.");
- }
+ $this->log(pht('Found %d new commits.', new PhutilNumber($n)));
while (true) {
$target = array_pop($insert);
$epoch = $stream->getCommitDate($target);
$epoch = trim($epoch);
- if ($autoclose) {
- $this->updateCommit($repository, $target, $branch);
- } else {
- $this->recordCommit($repository, $target, $epoch, $branch);
- }
+ $this->recordCommit($repository, $target, $epoch, $close_immediately);
if (empty($insert)) {
break;
Index: src/applications/repository/storage/PhabricatorRepository.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepository.php
+++ src/applications/repository/storage/PhabricatorRepository.php
@@ -557,6 +557,9 @@
return true;
}
+ // TODO: Remove this eventually, it's no longer written to by the import
+ // pipeline (however, old tasks may still be queued which don't reflect
+ // the new data format).
$branches = $data->getCommitDetail('seenOnBranches', array());
foreach ($branches as $branch) {
if ($this->shouldAutocloseBranch($branch)) {

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 22, 11:27 PM (2 d, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7500411
Default Alt Text
D7985.id.diff (8 KB)

Event Timeline