subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1442550 - in /subversion/trunk/subversion/tests/cmdline/svntest: actions.py tree.py wc.py
Date Tue, 05 Feb 2013 11:39:27 GMT
Author: rhuijben
Date: Tue Feb  5 11:39:26 2013
New Revision: 1442550

URL: http://svn.apache.org/viewvc?rev=1442550&view=rev
Log:
Start using new tree comparisons for status porcessing in the test suite.
This comparison type (introduced by gstein), allows more normalization steps,
such as those for moved paths, which I earlier left as a todo.

Note that while this handles the comparision nicely, the dump of the state
of a directory will still produce long paths in moved_* items.
(Luckily the item comparison failed step makes this easy to spot)

This should be fixed by adding a direct State dump, instead of trying to fix
the old trees.

* subversion/tests/cmdline/svntest/actions.py
  (run_and_verify_status): Rename argument. Use new comparision if passed,
    otherwise use the old code.
  (run_and_verify_unquiet_status): Handle like run_and_verify_status.

* subversion/tests/cmdline/svntest/tree.py
  (build_tree_from_status): Remove no longer needed argument.

* subversion/tests/cmdline/svntest/wc.py
  (State.normalize): Normalize moved_from and moved_to paths.
  (State.from_status): Keep exact moved_from and moved_to.
     Normalize '.' path to avoid breaking tests.

  (StateItem.__eq__): Remove unneeded tree conflict normalization.
     Ignore entry_*. Handle '-' wcrev like the tree comparison.

Modified:
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py
    subversion/trunk/subversion/tests/cmdline/svntest/tree.py
    subversion/trunk/subversion/tests/cmdline/svntest/wc.py

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1442550&r1=1442549&r2=1442550&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Tue Feb  5 11:39:26 2013
@@ -1461,47 +1461,50 @@ def run_and_verify_commit(wc_dir_name, o
 
 # This function always passes '-q' to the status command, which
 # suppresses the printing of any unversioned or nonexistent items.
-def run_and_verify_status(wc_dir_name, output_tree,
+def run_and_verify_status(wc_dir_name, status_tree,
                           singleton_handler_a = None,
                           a_baton = None,
                           singleton_handler_b = None,
                           b_baton = None):
   """Run 'status' on WC_DIR_NAME and compare it with the
-  expected OUTPUT_TREE.  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will
+  expected STATUS_TREE.  SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will
   be passed to tree.compare_trees - see that function's doc string for
   more details.
   Returns on success, raises on failure."""
 
-  if isinstance(output_tree, wc.State):
-    output_state = output_tree
-    output_tree = output_tree.old_tree()
-  else:
-    output_state = None
-
   exit_code, output, errput = main.run_svn(None, 'status', '-v', '-u', '-q',
                                            wc_dir_name)
 
-  actual = tree.build_tree_from_status(output, wc_dir_name=wc_dir_name)
+  actual_status = svntest.wc.State.from_status(output)
 
   # Verify actual output against expected output.
-  try:
-    tree.compare_trees("status", actual, output_tree,
-                       singleton_handler_a, a_baton,
-                       singleton_handler_b, b_baton)
-  except tree.SVNTreeError:
-    verify.display_trees(None, 'STATUS OUTPUT TREE', output_tree, actual)
-    _log_tree_state("ACTUAL STATUS TREE:", actual, wc_dir_name)
-    raise
+  if isinstance(status_tree, wc.State):
+    try:
+      status_tree.compare_and_display('status', actual_status)
+    except tree.SVNTreeError:
+      _log_tree_state("ACTUAL STATUS TREE:", actual_status.old_tree(),
+                                             wc_dir_name)
+      raise
+  else:
+    actual_status = actual_status.old_tree()
+    try:
+      tree.compare_trees("status", actual_status, status_tree,
+                         singleton_handler_a, a_baton,
+                         singleton_handler_b, b_baton)
+    except tree.SVNTreeError:
+      verify.display_trees(None, 'STATUS OUTPUT TREE', status_tree, actual_status)
+      _log_tree_state("ACTUAL STATUS TREE:", actual_status, wc_dir_name)
+      raise
 
   # if we have an output State, and we can/are-allowed to create an
   # entries-based State, then compare the two.
-  if output_state:
-    entries_state = wc.State.from_entries(wc_dir_name)
-    if entries_state:
-      tweaked = output_state.copy()
+  if isinstance(status_tree, wc.State):
+    actual_entries = wc.State.from_entries(wc_dir_name)
+    if actual_entries:
+      tweaked = status_tree.copy()
       tweaked.tweak_for_entries_compare()
       try:
-        tweaked.compare_and_display('entries', entries_state)
+        tweaked.compare_and_display('entries', actual_entries)
       except tree.SVNTreeUnequal:
         ### do something more
         raise
@@ -1514,20 +1517,27 @@ def run_and_verify_unquiet_status(wc_dir
   expected STATUS_TREE.
   Returns on success, raises on failure."""
 
-  if isinstance(status_tree, wc.State):
-    status_tree = status_tree.old_tree()
-
   exit_code, output, errput = main.run_svn(None, 'status', '-v',
                                            '-u', wc_dir_name)
 
-  actual = tree.build_tree_from_status(output, wc_dir_name=wc_dir_name)
+  actual_status = svntest.wc.State.from_status(output)
 
   # Verify actual output against expected output.
-  try:
-    tree.compare_trees("UNQUIET STATUS", actual, status_tree)
-  except tree.SVNTreeError:
-    _log_tree_state("ACTUAL UNQUIET STATUS TREE:", actual, wc_dir_name)
-    raise
+  if isinstance(status_tree, wc.State):
+    try:
+      status_tree.compare_and_display('unquiet status', actual_status)
+    except tree.SVNTreeError:
+      _log_tree_state("ACTUAL STATUS TREE:",
+                      actual_status.normalize().old_tree(), wc_dir_name)
+      raise
+  else:
+    actual_status = actual_status.old_tree()
+    try:
+      tree.compare_trees("UNQUIET STATUS", actual_status, status_tree)
+    except tree.SVNTreeError:
+      _log_tree_state("ACTUAL UNQUIET STATUS TREE:", actual_status,
+                                                     wc_dir_name)
+      raise
 
 def run_and_verify_status_xml(expected_entries = [],
                               *args):

Modified: subversion/trunk/subversion/tests/cmdline/svntest/tree.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/tree.py?rev=1442550&r1=1442549&r2=1442550&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/tree.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/tree.py Tue Feb  5 11:39:26 2013
@@ -838,11 +838,10 @@ def build_tree_from_commit(lines):
 #             IFF columns non-empty.
 #
 
-def build_tree_from_status(lines, wc_dir_name=None):
+def build_tree_from_status(lines):
   "Return a tree derived by parsing the output LINES from 'st -vuq'."
 
-  return svntest.wc.State.from_status(lines,
-                                       wc_dir_name=wc_dir_name).old_tree()
+  return svntest.wc.State.from_status(lines).old_tree()
 
 
 # Parse merge "skipped" output

Modified: subversion/trunk/subversion/tests/cmdline/svntest/wc.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/wc.py?rev=1442550&r1=1442549&r2=1442550&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/wc.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/wc.py Tue Feb  5 11:39:26 2013
@@ -261,11 +261,22 @@ class State:
 
     base = to_relpath(os.path.normpath(self.wc_dir))
 
-    # TODO: We should probably normalize the paths in moved_from and moved_to.
-
     desc = dict([(repos_join(base, path), item)
                  for path, item in self.desc.items()])
 
+    for path, item in desc.copy().items():
+      if item.moved_from or item.moved_to:
+        i = item.copy()
+
+        if i.moved_from:
+          i.moved_from = to_relpath(os.path.normpath(
+                                        repos_join(base, i.moved_from)))
+        if i.moved_to:
+          i.moved_to = to_relpath(os.path.normpath(
+                                        repos_join(base, i.moved_to)))
+
+        desc[path] = i
+
     return State('', desc)
 
   def compare(self, other):
@@ -423,7 +434,7 @@ class State:
     return not self.__eq__(other)
 
   @classmethod
-  def from_status(cls, lines, wc_dir_name=None):
+  def from_status(cls, lines):
     """Create a State object from 'svn status' output."""
 
     def not_space(value):
@@ -445,21 +456,12 @@ class State:
         if ex_match:
           if ex_match.group('moved_from'):
             path = ex_match.group('moved_from')
-            if wc_dir_name and path.startswith(wc_dir_name + os.path.sep):
-              path = path[len(wc_dir_name) + 1:]
-            
             last.tweak(moved_from = to_relpath(path))
           elif ex_match.group('moved_to'):
             path = ex_match.group('moved_to')
-            if wc_dir_name and path.startswith(wc_dir_name + os.path.sep):
-              path = path[len(wc_dir_name) + 1:]
-            
             last.tweak(moved_to = to_relpath(path))
           elif ex_match.group('swapped_with'):
             path = ex_match.group('swapped_with')
-            if wc_dir_name and path.startswith(wc_dir_name + os.path.sep):
-              path = path[len(wc_dir_name) + 1:]
-            
             last.tweak(moved_to = to_relpath(path))
             last.tweak(moved_from = to_relpath(path))
 
@@ -472,6 +474,8 @@ class State:
       prev_treeconflict = None
 
       path = to_relpath(match.group('path'))
+      if path == '.':
+        path = ''
       if path in desc:
         prev_status = desc[path].status
         prev_treeconflict = desc[path].treeconflict
@@ -790,15 +794,14 @@ class StateItem:
     if not isinstance(other, StateItem):
       return False
     v_self = dict([(k, v) for k, v in vars(self).items()
-                   if not k.startswith('_')])
+                   if not k.startswith('_') and not k.startswith('entry_')])
     v_other = dict([(k, v) for k, v in vars(other).items()
-                    if not k.startswith('_')])
-    if self.treeconflict is None:
-      v_other = v_other.copy()
-      v_other['treeconflict'] = None
-    if other.treeconflict is None:
-      v_self = v_self.copy()
-      v_self['treeconflict'] = None
+                    if not k.startswith('_') and not k.startswith('entry_')])
+
+    if self.wc_rev == '0' and self.status == 'A ':
+      v_self['wc_rev'] = '-'
+    if other.wc_rev == '0' and other.status == 'A ':
+      v_other['wc_rev'] = '-'
     return v_self == v_other
 
   def __ne__(self, other):



Mime
View raw message