[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]code simplifications to merge_tests.py take2

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-10-27 20:37:09 CEST

Hi All,
I could see similar such redundant expected_status tweaks across
merge_tests and other testcases too. I am posting the patch to clean
this up for merge_tests.py and will post the same for other testcase soon.

With regards
Kamesh Jayachandran

Index: subversion/tests/cmdline/merge_tests.py
===================================================================
--- subversion/tests/cmdline/merge_tests.py (revision 22138)
+++ subversion/tests/cmdline/merge_tests.py (working copy)
@@ -172,8 +172,7 @@
     })
 
   # Create expected status tree.
- expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.tweak('A/mu', wc_rev=2)
   expected_status.tweak('A/B/lambda', 'A/D/G/pi', 'A/D/G/tau', 'A/D/G/rho',
                         wc_rev=3)
@@ -397,8 +396,7 @@
     'A/B/F/foo' : Item(verb='Adding'),
     'A/B/F/foo2' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/Q' : Item(status=' ', wc_rev=2),
     'A/B/F/Q2' : Item(status=' ', wc_rev=2),
@@ -497,8 +495,7 @@
     'A/C/foo' : Item(verb='Adding'),
     'A/C/foo2' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/Q' : Item(status=' ', wc_rev=2),
     'A/B/F/Q2' : Item(status=' ', wc_rev=2),
@@ -540,8 +537,7 @@
   expected_output = wc.State(wc_dir, {
     'A/B2' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B2' : Item(status=' ', wc_rev=2),
     'A/B2/E' : Item(status=' ', wc_rev=2),
@@ -872,8 +868,7 @@
     'A/D/Q' : Item(verb='Adding'),
     'A/D/Q/newfile' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/D/Q' : Item(status=' ', wc_rev=2),
     'A/D/Q/pi' : Item(status=' ', wc_rev=2),
@@ -1136,8 +1131,7 @@
   svntest.main.file_append(rho_path, 'A new line in rho.\n')
 
   expected_output = wc.State(wc_dir, { rho_rel_path : Item(verb='Sending'), })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.tweak('A/D/G/rho', wc_rev=2)
   svntest.actions.run_and_verify_commit (wc_dir,
                                          expected_output,
@@ -1240,8 +1234,7 @@
 
   # Create expected status tree; all local revisions should be at 1,
   # but mu should be at revision 2.
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.tweak('A/mu', wc_rev=2)
   
   # Initial commit.
@@ -1333,8 +1326,7 @@
 
   # Create expected status tree; all local revisions should be at 1,
   # but mu should be at revision 2.
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.tweak('A/mu', wc_rev=2)
   expected_status.add({'A/zot' : Item(status=' ', wc_rev=2)})
   
@@ -1427,8 +1419,7 @@
   expected_output = svntest.wc.State(wc_dir, {
     'A/theta' : Item(verb='Adding (bin)'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/theta' : Item(status=' ', wc_rev=2),
     })
@@ -1445,8 +1436,7 @@
   expected_output = wc.State(wc_dir, {
     'A/theta' : Item(verb='Sending'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/theta' : Item(status=' ', wc_rev=3),
     })
@@ -1469,8 +1459,7 @@
     'A/theta' : Item(theta_contents + "some extra junk",
                      props={'svn:mime-type' : 'application/octet-stream'}),
     })
- expected_status = svntest.actions.get_virginal_state(short_other_wc, 3)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(short_other_wc, 1)
   expected_status.add({
     'A/theta' : Item(status='M ', wc_rev=2),
     })
@@ -1523,8 +1512,7 @@
   expected_output = svntest.wc.State(wc_dir, {
     "A/theta" : Item(verb="Adding (bin)"),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
- expected_status.tweak(wc_rev=1) # "and nothing else matters..."
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     "A/theta" : Item(status=" ", wc_rev=3),
     })
@@ -1672,8 +1660,7 @@
     'A/B/F/Q/bar' : Item(verb='Adding'),
     'A/B/F/foo' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/Q' : Item(status=' ', wc_rev=2),
     'A/B/F/Q/bar' : Item(status=' ', wc_rev=2),
@@ -2558,8 +2545,7 @@
   expected_output = wc.State(wc_dir, {
     'A/B/F/foo' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/foo' : Item(status=' ', wc_rev=2),
     })
@@ -2591,8 +2577,7 @@
   expected_output = svntest.wc.State(wc_dir, {
     'A/C/foo' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/foo' : Item(status=' ', wc_rev=2),
     'A/C/foo' : Item(status=' ', wc_rev=3),
@@ -2608,8 +2593,7 @@
   expected_output = svntest.wc.State(wc_dir, {
     'A/B/F/foo' : Item(verb='Deleting'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 4)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/C/foo' : Item(status=' ', wc_rev=3),
     })
@@ -2625,8 +2609,7 @@
   expected_output = wc.State(wc_dir, {
     'A/B/F/foo' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 5)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/foo' : Item(status=' ', wc_rev=5),
     'A/C/foo' : Item(status=' ', wc_rev=3),
@@ -2714,8 +2697,7 @@
   expected_output = wc.State(wc_dir, {
     'A/B/F/foo' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/B/F/foo' : Item(status=' ', wc_rev=2),
     })
@@ -3545,8 +3527,7 @@
   expected_output = svntest.wc.State(wc_dir, {
     'A/C/alpha' : Item(verb='Adding'),
     })
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.tweak(wc_rev=1)
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
   expected_status.add({
     'A/C/alpha' : Item(status=' ', wc_rev=2),
     })

[[[

Across our testsuite we could see code of the following nature
  expected_status = svntest.actions.get_virginal_state(sbox.wc_dir, some_num)
  expected_status.tweak(wc_rev=some_other_num)
which is functionally equivalent to
  expected_status = svntest.actions.get_virginal_state(sbox.wc_dir,
                                                       some_other_num)
This equivalent form avoids one loop over greek tree.

* subversion/tests/cmdline/merge_tests.py
  (textual_merges_galore):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 3 and
   changing it all back to 1. Better get it with '1' in one shot.
  (add_with_history):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
   Why to get the 'expected_status' tree with all 'wc_rev' set to 3 and
   changing it all back to 1. Better get it with '1' in one shot.
  (delete_file_and_dir):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_catches_nonexistent_target):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_one_file_helper):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_with_implicit_target_helper):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_with_prev):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_binary_file):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
   Why to get the 'expected_status' tree with all 'wc_rev' set to 3 and
   changing it all back to 1. Better get it with '1' in one shot.
   Why to get the 'expected_status' tree with all 'wc_rev' set to 3 and
   changing it all back to 1. Better get it with '1' in one shot.
  (three_way_merge_add_of_existing_binary_file):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 3 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_skips_obstructions):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_dir_replace):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
   Why to get the 'expected_status' tree with all 'wc_rev' set to 3 and
   changing it all back to 1. Better get it with '1' in one shot.
   Why to get the 'expected_status' tree with all 'wc_rev' set to 4 and
   changing it all back to 1. Better get it with '1' in one shot.
   Why to get the 'expected_status' tree with all 'wc_rev' set to 5 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_dir_branches):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.
  (merge_add_over_versioned_file_conflicts):
   Why to get the 'expected_status' tree with all 'wc_rev' set to 2 and
   changing it all back to 1. Better get it with '1' in one shot.

Patch by: Kamesh Jayachandran <kamesh@collab.net>
]]]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Oct 27 20:37:43 2006

This is an archived mail posted to the Subversion Dev mailing list.