From 7cb3551dc7e3e8e675a32c7ad077cde759183f7d Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 20 Oct 2012 06:13:12 -0700 Subject: [PATCH] Fix two arc issues Summary: - I caused $parser to be reused in D3732 which I belived was safe, but actually isn't. We end up writing to the same changes. We should make it safe but there's some mess in Phabricator that needs to be cleaned up first. - One minor error code thing, variable is undefined. Test Plan: Ran `arc export --git` on a moved file, got a better result. Ran some command which made me hit the other case and didn't get a fatal anymore. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D3749 --- src/parser/ArcanistDiffParser.php | 7 +++++++ src/workflow/ArcanistDiffWorkflow.php | 1 + 2 files changed, 8 insertions(+) diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index 54a40361..f4a0cc5c 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -1158,7 +1158,14 @@ final class ArcanistDiffParser { if ($change->getNeedsSyntheticGitHunks()) { $diff = $repository_api->getRawDiffText($path, $moves = false); + // NOTE: We're reusing the parser and it doesn't reset change state + // between parses because there's an oddball SVN workflow in Phabricator + // which relies on being able to inject changes. + // TODO: Fix this. + $this->setChanges(array()); + $raw_changes = $this->parseDiff($diff); + foreach ($raw_changes as $raw_change) { if ($raw_change->getCurrentPath() == $path) { $change->setFileType($raw_change->getFileType()); diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 175a4a84..76437f31 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -588,6 +588,7 @@ EOTEXT try { $this->requireCleanWorkingCopy(); } catch (ArcanistUncommittedChangesException $ex) { + $repository_api = $this->getRepositoryAPI(); if ($repository_api instanceof ArcanistMercurialAPI) { // Some Mercurial users prefer to use it like SVN, where they don't