Page MenuHomePhabricator

D10226.id24634.diff
No OneTemporary

D10226.id24634.diff

diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
@@ -135,12 +135,6 @@
$futures = array();
foreach ($this->refs as $ref) {
- // TODO: There was a note about `--rev 'a b'` not working for branches
- // with spaces in their names in older code, but I suspect this was
- // misidentified and resulted from the branch name being interpeted as
- // a revset. Use hgsprintf() to avoid that. If this doesn't break for a
- // bit, remove this comment. Otherwise, consider `-b %s --limit 1`.
-
$futures[$ref] = $repository->getLocalCommandFuture(
'log --template=%s --rev %s',
'{node}',
diff --git a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
@@ -63,6 +63,7 @@
}
}
$all_closing_heads = array_unique($all_closing_heads);
+ $all_closing_heads = $this->removeMissingCommits($all_closing_heads);
foreach ($maps as $type => $refs) {
$cursor_group = idx($cursor_groups, $type, array());
@@ -105,6 +106,35 @@
return $this;
}
+ /**
+ * Remove commits which no longer exist in the repository from a list.
+ *
+ * After a force push and garbage collection, we may have branch cursors which
+ * point at commits which no longer exist. This can make commands issued later
+ * fail. See T5839 for discussion.
+ *
+ * @param list<string> List of commit identifiers.
+ * @return list<string> List with nonexistent identifiers removed.
+ */
+ private function removeMissingCommits(array $identifiers) {
+ if (!$identifiers) {
+ return array();
+ }
+
+ $resolved = id(new DiffusionLowLevelResolveRefsQuery())
+ ->setRepository($this->getRepository())
+ ->withRefs($identifiers)
+ ->execute();
+
+ foreach ($identifiers as $key => $identifier) {
+ if (empty($resolved[$identifier])) {
+ unset($identifiers[$key]);
+ }
+ }
+
+ return $identifiers;
+ }
+
private function updateCursors(
array $cursors,
array $new_refs,
diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementUpdateWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementUpdateWorkflow.php
--- a/src/applications/repository/management/PhabricatorRepositoryManagementUpdateWorkflow.php
+++ b/src/applications/repository/management/PhabricatorRepositoryManagementUpdateWorkflow.php
@@ -42,6 +42,7 @@
public function execute(PhutilArgumentParser $args) {
$this->setVerbose($args->getArg('verbose'));
+ $console = PhutilConsole::getConsole();
$repos = $this->loadRepositories($args, 'repos');
if (count($repos) !== 1) {
@@ -103,6 +104,11 @@
$lock->unlock();
+ $console->writeOut(
+ pht(
+ 'Updated repository **%s**.',
+ $repository->getMonogram())."\n");
+
return 0;
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 9:28 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6730273
Default Alt Text
D10226.id24634.diff (3 KB)

Event Timeline