1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-02-23 03:59:24 +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:
epriestley 2013-01-28 14:11:31 -08:00
parent ce0a491bcd
commit 53691cdcf9
4 changed files with 42 additions and 4 deletions

View file

@ -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',

View file

@ -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;
}
} }

View file

@ -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));
}
}

View file

@ -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(