1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-04-01 23:18:14 +02:00

Fix various SVN escaping issues in arc patch

Summary: Followup to D4703. When we give paths to `svn`, we need to escape them if they contain an `@`.

Test Plan:
Created a patch full of modifications to files with `@` in their names, and applied it:

  $ arc patch --diff 192
  A         A@2xcopy2
  A         A@2xcopy
  D         A@2x
   OKAY  Successfully applied patch to the working copy.

Reviewers: chad, mbishopim3

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D4977
This commit is contained in:
epriestley 2013-02-15 14:53:25 -08:00
parent cd50b0884e
commit 0f57b8d2de
2 changed files with 18 additions and 11 deletions

View file

@ -644,18 +644,25 @@ EODIFF;
} }
public static function escapeFileNamesForSVN(array $files) { public static function escapeFileNamesForSVN(array $files) {
foreach ($files as $k => $file) {
$files[$k] = self::escapeFileNameForSVN($file);
}
return $files;
}
public static function escapeFileNameForSVN($file) {
// SVN interprets "x@1" as meaning "file x at revision 1", which is not // 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 // 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 // "@" in their names, escape them by adding "@" at the end, which SVN
// interprets as "at the working copy revision". There is a special case // interprets as "at the working copy revision". There is a special case
// where ".@" means "fail with an error" instead of ". at the working copy // where ".@" means "fail with an error" instead of ". at the working copy
// revision", so avoid escaping "." into ".@". // revision", so avoid escaping "." into ".@".
foreach ($files as $k => $file) {
if (strpos($file, '@') !== false) { if (strpos($file, '@') !== false) {
$files[$k] = $file.'@'; $file = $file.'@';
}
} }
return $files;
return $file;
} }
} }

View file

@ -578,8 +578,8 @@ EOTEXT
csprintf( csprintf(
'(cd %s; svn cp %s %s)', '(cd %s; svn cp %s %s)',
$repository_api->getPath(), $repository_api->getPath(),
$src, ArcanistSubversionAPI::escapeFileNameForSVN($src),
$dst)); ArcanistSubversionAPI::escapeFileNameForSVN($dst)));
} }
foreach ($deletes as $delete) { foreach ($deletes as $delete) {
@ -587,7 +587,7 @@ EOTEXT
csprintf( csprintf(
'(cd %s; svn rm %s)', '(cd %s; svn rm %s)',
$repository_api->getPath(), $repository_api->getPath(),
$delete)); ArcanistSubversionAPI::escapeFileNameForSVN($delete)));
} }
foreach ($symlinks as $symlink) { foreach ($symlinks as $symlink) {
@ -636,7 +636,7 @@ EOTEXT
csprintf( csprintf(
'(cd %s; svn add %s)', '(cd %s; svn add %s)',
$repository_api->getPath(), $repository_api->getPath(),
$add)); ArcanistSubversionAPI::escapeFileNameForSVN($add)));
} }
foreach ($propset as $path => $changes) { foreach ($propset as $path => $changes) {
@ -652,7 +652,7 @@ EOTEXT
'(cd %s; svn propdel %s %s)', '(cd %s; svn propdel %s %s)',
$repository_api->getPath(), $repository_api->getPath(),
$prop, $prop,
$path)); ArcanistSubversionAPI::escapeFileNameForSVN($path)));
} else { } else {
passthru( passthru(
csprintf( csprintf(
@ -660,7 +660,7 @@ EOTEXT
$repository_api->getPath(), $repository_api->getPath(),
$prop, $prop,
$value, $value,
$path)); ArcanistSubversionAPI::escapeFileNameForSVN($path)));
} }
} }
} }