You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/03/16 15:44:52 UTC

svn commit: r923776 - in /subversion/branches/1.6.x: ./ CHANGES STATUS subversion/svnlook/main.c subversion/tests/cmdline/svnlook_tests.py

Author: hwright
Date: Tue Mar 16 14:44:52 2010
New Revision: 923776

URL: http://svn.apache.org/viewvc?rev=923776&view=rev
Log:
Merge r917640, r918211 from trunk:

 * r917640, r918211
   Correctly handle invocations of 'svnlook plist --revprop' when
   used with '-t TXN_NAME' instead of '-r REV'.
   r918211 adds a regression test.
   Justification:
     Users are assuming that this works (and trying to employ the
     functionality in pre-commit hooks), but it clearly doesn't.
   Votes:
     +1: cmpilato, lgo, rhuijben

Modified:
    subversion/branches/1.6.x/   (props changed)
    subversion/branches/1.6.x/CHANGES   (props changed)
    subversion/branches/1.6.x/STATUS
    subversion/branches/1.6.x/subversion/svnlook/main.c
    subversion/branches/1.6.x/subversion/tests/cmdline/svnlook_tests.py

Propchange: subversion/branches/1.6.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 16 14:44:52 2010
@@ -58,4 +58,4 @@
 /subversion/branches/tc_url_rev:870696-870828
 /subversion/branches/tree-conflicts:864636-869499
 /subversion/branches/tree-conflicts-notify:870271-870353
-/subversion/trunk:875976,875980-875981,876054-876056,876092,876175,876299,876306,876427,876440,876450,876507,876571,879093,879688,880274-880275,880370,880450,880474,880525-880526,880552,881905,884842,886164,886197,888715,888979,889081,889840,891672,895514,895653,896522,898963,899826,899828,900797,901752,904594,905303,905326,906256,906305,922516
+/subversion/trunk:875976,875980-875981,876054-876056,876092,876175,876299,876306,876427,876440,876450,876507,876571,879093,879688,880274-880275,880370,880450,880474,880525-880526,880552,881905,884842,886164,886197,888715,888979,889081,889840,891672,895514,895653,896522,898963,899826,899828,900797,901752,904594,905303,905326,906256,906305,917640,918211,922516

Propchange: subversion/branches/1.6.x/CHANGES
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 16 14:44:52 2010
@@ -57,4 +57,4 @@
 /subversion/branches/tc_url_rev/CHANGES:870696-870828
 /subversion/branches/tree-conflicts/CHANGES:864636-869499
 /subversion/branches/tree-conflicts-notify/CHANGES:870271-870353
-/subversion/trunk/CHANGES:875962-901365,901752,904594,905303,905326,922516
+/subversion/trunk/CHANGES:875962-901365,901752,904594,905303,905326,917640,918211,922516

Modified: subversion/branches/1.6.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x/STATUS?rev=923776&r1=923775&r2=923776&view=diff
==============================================================================
--- subversion/branches/1.6.x/STATUS (original)
+++ subversion/branches/1.6.x/STATUS Tue Mar 16 14:44:52 2010
@@ -238,16 +238,6 @@ Approved changes:
    Votes:
      +1: neels, cmpilato, rhuijben
 
- * r917640, r918211
-   Correctly handle invocations of 'svnlook plist --revprop' when
-   used with '-t TXN_NAME' instead of '-r REV'.
-   r918211 adds a regression test.
-   Justification:
-     Users are assuming that this works (and trying to employ the
-     functionality in pre-commit hooks), but it clearly doesn't.
-   Votes:
-     +1: cmpilato, lgo, rhuijben
-
  * ^/subversion/branches/1.6.x-wc-ng-check-override
    Disable checks for WC-NG working copies while running the test suite.
    Justification:

Modified: subversion/branches/1.6.x/subversion/svnlook/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x/subversion/svnlook/main.c?rev=923776&r1=923775&r2=923776&view=diff
==============================================================================
--- subversion/branches/1.6.x/subversion/svnlook/main.c (original)
+++ subversion/branches/1.6.x/subversion/svnlook/main.c Tue Mar 16 14:44:52 2010
@@ -1613,11 +1613,16 @@ do_plist(svnlook_ctxt_t *c,
       SVN_ERR(verify_path(&kind, root, path, pool));
       SVN_ERR(svn_fs_node_proplist(&props, root, path, pool));
     }
-  else
+  else if (c->is_revision)
     {
       SVN_ERR(svn_fs_revision_proplist(&props, c->fs, c->rev_id, pool));
       revprop = TRUE;
     }
+  else
+    {
+      SVN_ERR(svn_fs_txn_proplist(&props, c->txn, pool));
+      revprop = TRUE;
+    }
 
   if (xml)
     {
@@ -1631,8 +1636,16 @@ do_plist(svnlook_ctxt_t *c,
       if (revprop)
         {
           /* "<revprops ...>" */
-          svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "revprops",
-                                "rev", revstr, NULL);
+          if (c->is_revision)
+            {
+              svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "revprops",
+                                    "rev", revstr, NULL);
+            }
+          else
+            {
+              svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "revprops",
+                                    "txn", c->txn_name, NULL);
+            }
         }
       else
         {

Modified: subversion/branches/1.6.x/subversion/tests/cmdline/svnlook_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x/subversion/tests/cmdline/svnlook_tests.py?rev=923776&r1=923775&r2=923776&view=diff
==============================================================================
--- subversion/branches/1.6.x/subversion/tests/cmdline/svnlook_tests.py (original)
+++ subversion/branches/1.6.x/subversion/tests/cmdline/svnlook_tests.py Tue Mar 16 14:44:52 2010
@@ -533,6 +533,96 @@ def diff_binary(sbox):
     raise svntest.Failure("No 'Binary files differ' indication in "
                           "'svnlook diff' output.")
 
+#----------------------------------------------------------------------
+def verify_logfile(logfilename, expected_data):
+  if os.path.exists(logfilename):
+    fp = open(logfilename)
+  else:
+    raise svntest.verify.SVNUnexpectedOutput("hook logfile %s not found"\
+                                             % logfilename)
+
+  actual_data = fp.readlines()
+  fp.close()
+  os.unlink(logfilename)
+  svntest.verify.compare_and_display_lines('wrong hook logfile content',
+                                           'STDOUT',
+                                           expected_data, actual_data)
+
+def test_txn_flag(sbox):
+  "test 'svnlook * -t'"
+
+  sbox.build()
+  repo_dir = sbox.repo_dir
+  wc_dir = sbox.wc_dir
+  logfilepath = os.path.join(repo_dir, 'hooks.log')
+
+  # List changed dirs and files in this transaction
+  hook_template = """import sys,os,subprocess
+svnlook_bin=%s
+
+fp = open(os.path.join(sys.argv[1], 'hooks.log'), 'wb')
+def output_command(fp, cmd, opt):
+  command = [svnlook_bin, cmd, '-t', sys.argv[2], sys.argv[1]] + opt
+  process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
+  (output, errors) = process.communicate()
+  status = process.returncode
+  fp.write(output)
+  fp.write(errors)
+  return status
+
+for (svnlook_cmd, svnlook_opt) in %s:
+  output_command(fp, svnlook_cmd, svnlook_opt.split(' '))
+fp.close()"""
+  pre_commit_hook = svntest.main.get_pre_commit_hook_path(repo_dir)
+
+  # 1. svnlook 'changed' -t and 'dirs-changed' -t
+  hook_instance = hook_template % (repr(svntest.main.svnlook_binary),
+                                   repr([('changed', ''),
+                                         ('dirs-changed', '')]))
+  svntest.main.create_python_hook_script(pre_commit_hook,
+                                         hook_instance)
+
+  # Change files mu and rho
+  A_path = os.path.join(wc_dir, 'A')
+  mu_path = os.path.join(wc_dir, 'A', 'mu')
+  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
+  svntest.main.file_append(mu_path, 'appended mu text')
+  svntest.main.file_append(rho_path, 'new appended text for rho')
+
+  # commit, and check the hook's logfile
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'ci', '-m', 'log msg', wc_dir)
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'up', wc_dir)
+
+  expected_data = [ 'U   A/D/G/rho\n', 'U   A/mu\n', 'A/\n', 'A/D/G/\n' ]
+  verify_logfile(logfilepath, expected_data)
+
+  # 2. svnlook 'propget' -t, 'proplist' -t
+  # 2. Change a dir and revision property
+  hook_instance = hook_template % (repr(svntest.main.svnlook_binary),
+                                   repr([('propget', 'bogus_prop /A'),
+                                         ('propget', '--revprop bogus_rev_prop'),
+                                         ('proplist', '/A'),
+                                         ('proplist', '--revprop')]))
+  svntest.main.create_python_hook_script(pre_commit_hook,
+                                         hook_instance)
+
+  svntest.actions.run_and_verify_svn(None, None, [], 'propset',
+                                     'bogus_prop', 'bogus_val\n', A_path)
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'ci', '-m', 'log msg', wc_dir,
+                                     '--with-revprop', 'bogus_rev_prop=bogus_rev_val\n')
+  # Now check the logfile
+  expected_data = [ 'bogus_val\n',
+                    'bogus_rev_val\n',
+                    '  bogus_prop\n',
+                    '  svn:log\n', '  svn:author\n',
+                    #  internal property, not really expected
+                    '  svn:check-locks\n',
+                    '  bogus_rev_prop\n', '  svn:date\n']
+  verify_logfile(logfilepath, expected_data)
+
 ########################################################################
 # Run the tests
 
@@ -549,6 +639,7 @@ test_list = [ None,
               diff_ignore_whitespace,
               diff_ignore_eolstyle,
               diff_binary,
+              test_txn_flag,
              ]
 
 if __name__ == '__main__':