]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix `arc diff x y` in SVN
authorepriestley <git@epriestley.com>
Wed, 9 Jan 2013 17:11:26 +0000 (09:11 -0800)
committerepriestley <git@epriestley.com>
Wed, 9 Jan 2013 17:11:26 +0000 (09:11 -0800)
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 <target /> 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

index 74ab37a505668b8292255794f13c9fd54a178bfd..1345f66445879fb8f06806b8c9ab162547c5999f 100644 (file)
@@ -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) {