From 57ec5a026dc5b603f39a3b6a33bc99a0bd0704f8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 9 Jan 2013 09:11:26 -0800 Subject: [PATCH] Fix `arc diff x y` in SVN Summary: D4186 added an "svn status --xml x y" form to getSVNStatus(), but the parser doesn't work for multiple files, since we get multiple elements in the XML output. So, curently, `arc diff` works (one target, all files) and `arc diff x` works (one target, x) but `arc diff x y` does not (more than one target, hits the exception). $ arc diff QUACK2 QUACK3 Exception Expected exactly one XML status target. Test Plan: Ran `arc diff QUACK2 QUACK3` in a working copy with modified QUACK2, QUACK3. Ran `arc diff`; `arc diff QUACK2`. Reviewers: vrana, btrahan, codeblock, JThramer Reviewed By: codeblock CC: aran Differential Revision: https://secure.phabricator.com/D4372 --- src/repository/api/ArcanistSubversionAPI.php | 69 ++++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index 74ab37a5..1345f664 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -80,48 +80,45 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { } $xml = new SimpleXMLElement($status); - if (count($xml->target) != 1) { - throw new Exception("Expected exactly one XML status target."); - } - $externals = array(); $files = array(); - $target = $xml->target[0]; - $this->svnBaseRevisions = array(); - foreach ($target->entry as $entry) { - $path = (string)$entry['path']; - $mask = 0; - - $props = (string)($entry->{'wc-status'}[0]['props']); - $item = (string)($entry->{'wc-status'}[0]['item']); - - $base = (string)($entry->{'wc-status'}[0]['revision']); - $this->svnBaseRevisions[$path] = $base; - - switch ($props) { - case 'none': - case 'normal': - break; - case 'modified': - $mask |= self::FLAG_MODIFIED; - break; - default: - throw new Exception("Unrecognized property status '{$props}'."); - } + foreach ($xml->target as $target) { + $this->svnBaseRevisions = array(); + foreach ($target->entry as $entry) { + $path = (string)$entry['path']; + $mask = 0; + + $props = (string)($entry->{'wc-status'}[0]['props']); + $item = (string)($entry->{'wc-status'}[0]['item']); + + $base = (string)($entry->{'wc-status'}[0]['revision']); + $this->svnBaseRevisions[$path] = $base; + + switch ($props) { + case 'none': + case 'normal': + break; + case 'modified': + $mask |= self::FLAG_MODIFIED; + break; + default: + throw new Exception("Unrecognized property status '{$props}'."); + } - $mask |= $this->parseSVNStatus($item); - if ($item == 'external') { - $externals[] = $path; - } + $mask |= $this->parseSVNStatus($item); + if ($item == 'external') { + $externals[] = $path; + } - // This is new in or around Subversion 1.6. - $tree_conflicts = (string)($entry->{'wc-status'}[0]['tree-conflicted']); - if ($tree_conflicts) { - $mask |= self::FLAG_CONFLICT; - } + // This is new in or around Subversion 1.6. + $tree_conflicts = ($entry->{'wc-status'}[0]['tree-conflicted']); + if ((string)$tree_conflicts) { + $mask |= self::FLAG_CONFLICT; + } - $files[$path] = $mask; + $files[$path] = $mask; + } } foreach ($files as $path => $mask) { -- 2.43.0