From: epriestley Date: Mon, 28 Jan 2013 22:11:31 +0000 (-0800) Subject: Fix an escaping issue with "svn commit" X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=53691cdcf98a4d257040bade401815542bd39b05;p=arcanist.git Fix an escaping issue with "svn commit" Summary: Fixes T2438. We currently escape everything with '@', but SVN rejects that for '.' Test Plan: Unit tests. Performed this commit: $ svn st M . A x@123 $ arc commit --conduit-uri=http://local.aphront.com:8080/ --revision 53 Revision 'D53: asdf' has not been accepted. Commit this revision anyway? [y/N] y Committing 'D53: asdf'... Sending . Adding x@123 Transmitting file data . Committed revision 37. Done. I grepped for more '@' adding but couldn't find any. It's a bit tricky to grep for though, so it's possible I missed some. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran, mbishopim3 Maniphest Tasks: T2438 Differential Revision: https://secure.phabricator.com/D4703 --- diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 03370337..b71f0bb1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -109,6 +109,7 @@ phutil_register_library_map(array( 'ArcanistPyFlakesLinter' => 'lint/linter/ArcanistPyFlakesLinter.php', 'ArcanistPyLintLinter' => 'lint/linter/ArcanistPyLintLinter.php', 'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php', + 'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php', 'ArcanistRepositoryAPIStateTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php', 'ArcanistRubyLinter' => 'lint/linter/ArcanistRubyLinter.php', 'ArcanistRubyLinterTestCase' => 'lint/linter/__tests__/ArcanistRubyLinterTestCase.php', @@ -232,6 +233,7 @@ phutil_register_library_map(array( 'ArcanistPhutilTestTerminatedException' => 'Exception', 'ArcanistPyFlakesLinter' => 'ArcanistLinter', 'ArcanistPyLintLinter' => 'ArcanistLinter', + 'ArcanistRepositoryAPIMiscTestCase' => 'ArcanistTestCase', 'ArcanistRepositoryAPIStateTestCase' => 'ArcanistTestCase', 'ArcanistRubyLinter' => 'ArcanistLinter', 'ArcanistRubyLinterTestCase' => 'ArcanistArcanistLinterTestCase', diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index edb71a1b..672cd13e 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -637,4 +637,19 @@ EODIFF; $this->execxLocal('up'); } + public static function escapeFileNamesForSVN(array $files) { + // SVN interprets "x@1" as meaning "file x at revision 1", which is not + // intended for files named "sprite@2x.png" or similar. For files with an + // "@" in their names, escape them by adding "@" at the end, which SVN + // interprets as "at the working copy revision". There is a special case + // where ".@" means "fail with an error" instead of ". at the working copy + // revision", so avoid escaping "." into ".@". + foreach ($files as $k => $file) { + if (strpos($file, '@') !== false) { + $files[$k] = $file.'@'; + } + } + return $files; + } + } diff --git a/src/repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php b/src/repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php new file mode 100644 index 00000000..957a42b2 --- /dev/null +++ b/src/repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php @@ -0,0 +1,23 @@ +assertEqual( + $expect, + ArcanistSubversionAPI::escapeFileNamesForSVN($input)); + } + +} diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index 2802e7ac..ab687250 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -245,10 +245,8 @@ EOTEXT $this->promptFileWarning($prefix, $prompt, $do_not_exist); } - $files = array(); - foreach ($commit_paths as $file => $ignored) { - $files[] = $file.'@'; // make SVN accept commits like foo@2x.png - } + $files = array_keys($commit_paths); + $files = ArcanistSubversionAPI::escapeFileNamesForSVN($files); if (empty($files)) { throw new ArcanistUsageException(