mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-23 12:09:09 +01:00
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
This commit is contained in:
parent
ce0a491bcd
commit
53691cdcf9
4 changed files with 42 additions and 4 deletions
|
@ -109,6 +109,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistPyFlakesLinter' => 'lint/linter/ArcanistPyFlakesLinter.php',
|
'ArcanistPyFlakesLinter' => 'lint/linter/ArcanistPyFlakesLinter.php',
|
||||||
'ArcanistPyLintLinter' => 'lint/linter/ArcanistPyLintLinter.php',
|
'ArcanistPyLintLinter' => 'lint/linter/ArcanistPyLintLinter.php',
|
||||||
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
|
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
|
||||||
|
'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php',
|
||||||
'ArcanistRepositoryAPIStateTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php',
|
'ArcanistRepositoryAPIStateTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php',
|
||||||
'ArcanistRubyLinter' => 'lint/linter/ArcanistRubyLinter.php',
|
'ArcanistRubyLinter' => 'lint/linter/ArcanistRubyLinter.php',
|
||||||
'ArcanistRubyLinterTestCase' => 'lint/linter/__tests__/ArcanistRubyLinterTestCase.php',
|
'ArcanistRubyLinterTestCase' => 'lint/linter/__tests__/ArcanistRubyLinterTestCase.php',
|
||||||
|
@ -232,6 +233,7 @@ phutil_register_library_map(array(
|
||||||
'ArcanistPhutilTestTerminatedException' => 'Exception',
|
'ArcanistPhutilTestTerminatedException' => 'Exception',
|
||||||
'ArcanistPyFlakesLinter' => 'ArcanistLinter',
|
'ArcanistPyFlakesLinter' => 'ArcanistLinter',
|
||||||
'ArcanistPyLintLinter' => 'ArcanistLinter',
|
'ArcanistPyLintLinter' => 'ArcanistLinter',
|
||||||
|
'ArcanistRepositoryAPIMiscTestCase' => 'ArcanistTestCase',
|
||||||
'ArcanistRepositoryAPIStateTestCase' => 'ArcanistTestCase',
|
'ArcanistRepositoryAPIStateTestCase' => 'ArcanistTestCase',
|
||||||
'ArcanistRubyLinter' => 'ArcanistLinter',
|
'ArcanistRubyLinter' => 'ArcanistLinter',
|
||||||
'ArcanistRubyLinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
'ArcanistRubyLinterTestCase' => 'ArcanistArcanistLinterTestCase',
|
||||||
|
|
|
@ -637,4 +637,19 @@ EODIFF;
|
||||||
$this->execxLocal('up');
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ArcanistRepositoryAPIMiscTestCase extends ArcanistTestCase {
|
||||||
|
|
||||||
|
public function testSVNFileEscapes() {
|
||||||
|
$input = array(
|
||||||
|
'.',
|
||||||
|
'x',
|
||||||
|
'x@2x.png',
|
||||||
|
);
|
||||||
|
|
||||||
|
$expect = array(
|
||||||
|
'.',
|
||||||
|
'x',
|
||||||
|
'x@2x.png@',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEqual(
|
||||||
|
$expect,
|
||||||
|
ArcanistSubversionAPI::escapeFileNamesForSVN($input));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -245,10 +245,8 @@ EOTEXT
|
||||||
$this->promptFileWarning($prefix, $prompt, $do_not_exist);
|
$this->promptFileWarning($prefix, $prompt, $do_not_exist);
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = array();
|
$files = array_keys($commit_paths);
|
||||||
foreach ($commit_paths as $file => $ignored) {
|
$files = ArcanistSubversionAPI::escapeFileNamesForSVN($files);
|
||||||
$files[] = $file.'@'; // make SVN accept commits like foo@2x.png
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($files)) {
|
if (empty($files)) {
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
|
|
Loading…
Add table
Reference in a new issue