Page MenuHomePhabricator

D9047.id21488.diff
No OneTemporary

D9047.id21488.diff

diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_lastmodifiedquery_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_lastmodifiedquery_Method.php
--- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_lastmodifiedquery_Method.php
+++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_lastmodifiedquery_Method.php
@@ -21,23 +21,28 @@
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $result = array();
- foreach ($request->getValue('paths') as $path => $commit) {
+ $paths = $request->getValue('paths');
+ $results = $this->loadCommitsFromCache($paths);
+
+ foreach ($paths as $path => $commit) {
+ if (array_key_exists($path, $results)) {
+ continue;
+ }
list($hash) = $repository->execxLocalCommand(
'log -n1 --format=%%H %s -- %s',
$commit,
$path);
- $result[$path] = trim($hash);
+ $results[$path] = trim($hash);
}
- return $result;
+ return $results;
}
protected function getSVNResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $result = array();
+ $results = array();
foreach ($request->getValue('paths') as $path => $commit) {
$history_result = DiffusionQuery::callConduitWithDiffusionRequest(
$request->getUser(),
@@ -55,30 +60,93 @@
$history_array = DiffusionPathChange::newFromConduit(
$history_result['pathChanges']);
if ($history_array) {
- $result[$path] = head($history_array)
+ $results[$path] = head($history_array)
->getCommit()
->getCommitIdentifier();
}
}
- return $result;
+ return $results;
}
protected function getMercurialResult(ConduitAPIRequest $request) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
- $result = array();
- foreach ($request->getValue('paths') as $path => $commit) {
+ $paths = $request->getValue('paths');
+ $results = $this->loadCommitsFromCache($paths);
+
+ foreach ($paths as $path => $commit) {
+ if (array_key_exists($path, $results)) {
+ continue;
+ }
+
list($hash) = $repository->execxLocalCommand(
'log --template %s --limit 1 --removed --rev %s -- %s',
'{node}',
hgsprintf('reverse(ancestors(%s))', $commit),
nonempty(ltrim($path, '/'), '.'));
- $result[$path] = trim($hash);
+ $results[$path] = trim($hash);
+ }
+
+ return $results;
+ }
+
+ private function loadCommitsFromCache(array $map) {
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
+ $path_map = id(new DiffusionPathIDQuery(array_keys($map)))
+ ->loadPathIDs();
+
+ $commit_query = id(new DiffusionCommitQuery())
+ ->setViewer($drequest->getUser())
+ ->withRepository($repository)
+ ->withIdentifiers(array_values($map));
+ $commit_query->execute();
+
+ $commit_map = $commit_query->getIdentifierMap();
+ $commit_map = mpull($commit_map, 'getID');
+
+ $graph_cache = new PhabricatorRepositoryGraphCache();
+
+ $results = array();
+ foreach ($map as $path => $commit) {
+ $path_id = idx($path_map, $path);
+ if (!$path_id) {
+ continue;
+ }
+ $commit_id = idx($commit_map, $commit);
+ if (!$commit_id) {
+ continue;
+ }
+
+ $cache_result = $graph_cache->loadLastModifiedCommitID(
+ $commit_id,
+ $path_id);
+
+ if ($cache_result !== false) {
+ $results[$path] = $cache_result;
+ }
+ }
+
+ if ($results) {
+ $commits = id(new DiffusionCommitQuery())
+ ->setViewer($drequest->getUser())
+ ->withRepository($repository)
+ ->withIDs($results)
+ ->execute();
+ foreach ($results as $path => $id) {
+ $commit = idx($commits, $id);
+ if ($commit) {
+ $results[$path] = $commit->getCommitIdentifier();
+ } else {
+ unset($results[$path]);
+ }
+ }
}
- return $result;
+ return $results;
}
}
diff --git a/src/applications/diffusion/view/DiffusionBrowseTableView.php b/src/applications/diffusion/view/DiffusionBrowseTableView.php
--- a/src/applications/diffusion/view/DiffusionBrowseTableView.php
+++ b/src/applications/diffusion/view/DiffusionBrowseTableView.php
@@ -113,6 +113,7 @@
'uri' => (string)$request->generateURI(
array(
'action' => 'lastmodified',
+ 'stable' => true,
)),
'map' => $need_pull,
));
diff --git a/src/applications/repository/graphcache/PhabricatorRepositoryGraphCache.php b/src/applications/repository/graphcache/PhabricatorRepositoryGraphCache.php
--- a/src/applications/repository/graphcache/PhabricatorRepositoryGraphCache.php
+++ b/src/applications/repository/graphcache/PhabricatorRepositoryGraphCache.php
@@ -200,7 +200,7 @@
if ($prefix === null) {
$self = get_class($this);
$size = $this->getBucketSize();
- $prefix = "{$self}:{$size}:1:";
+ $prefix = "{$self}:{$size}:2:";
}
return $prefix.$bucket_key;

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 19, 1:22 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6723222
Default Alt Text
D9047.id21488.diff (5 KB)

Event Timeline