subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1099484 - in /subversion/trunk/subversion: libsvn_wc/copy.c tests/cmdline/stat_tests.py
Date Wed, 04 May 2011 15:24:38 GMT
Author: philip
Date: Wed May  4 15:24:38 2011
New Revision: 1099484

URL: http://svn.apache.org/viewvc?rev=1099484&view=rev
Log:
Fix issue 3774, the last_mod_time for copied files should be set
when the file is unmodified.

* subversion/libsvn_wc/copy.c
  (copy_versioned_file): If the source is unmodified then set the
   destination last_mod_time.

* subversion/tests/cmdline/stat_tests.py
  (wc_wc_copy_timestamp): New.
  (test_list): Add new test.

Modified:
    subversion/trunk/subversion/libsvn_wc/copy.c
    subversion/trunk/subversion/tests/cmdline/stat_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/copy.c?rev=1099484&r1=1099483&r2=1099484&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/copy.c (original)
+++ subversion/trunk/subversion/libsvn_wc/copy.c Wed May  4 15:24:38 2011
@@ -254,6 +254,29 @@ copy_versioned_file(svn_wc__db_t *db,
                                              tmp_dst_abspath, dst_abspath,
                                              scratch_pool, scratch_pool));
           work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+
+          if (disk_kind == svn_node_file)
+            {
+              svn_boolean_t modified;
+
+              /* It's faster to look for mods on the source now, as
+                 the timestamp might match, than to examine the
+                 destination later as the destination timestamp will
+                 never match. */
+              SVN_ERR(svn_wc__internal_file_modified_p(&modified, NULL, NULL,
+                                                       db, src_abspath,
+                                                       FALSE, FALSE,
+                                                       scratch_pool));
+              if (!modified)
+                {
+                  SVN_ERR(svn_wc__wq_build_record_fileinfo(&work_item,
+                                                           db, dst_abspath, 0,
+                                                           scratch_pool,
+                                                           scratch_pool));
+                  work_items = svn_wc__wq_merge(work_items, work_item,
+                                                scratch_pool);
+                }
+            }
         }
     }
 

Modified: subversion/trunk/subversion/tests/cmdline/stat_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/stat_tests.py?rev=1099484&r1=1099483&r2=1099484&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/stat_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/stat_tests.py Wed May  4 15:24:38 2011
@@ -1837,6 +1837,53 @@ def status_locked_deleted(sbox):
   svntest.actions.run_and_verify_svn(None, ['D    K  %s\n' % iota_path], [],
                                      'status', iota_path)
 
+@Issue(3774)
+def wc_wc_copy_timestamp(sbox):
+  "timestamp on wc-wc copies"
+
+  sbox.build(read_only=True)
+  wc_dir = sbox.wc_dir
+
+  time.sleep(1.1)
+  svntest.main.file_append(sbox.ospath('A/D/H/psi'), 'modified\n')
+  svntest.actions.run_and_verify_svn(None, None, [], 'copy',
+                                     sbox.ospath('A/D/H'),
+                                     sbox.ospath('A/D/H2'))
+
+  expected_output = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_output.tweak('A/D/H/psi', status='M ')
+  expected_output.add({
+      'A/D/H2'       : Item(status='A ', copied='+', wc_rev='-'),
+      'A/D/H2/chi'   : Item(status='  ', copied='+', wc_rev='-'),
+      'A/D/H2/omega' : Item(status='  ', copied='+', wc_rev='-'),
+      'A/D/H2/psi'   : Item(status='M ', copied='+', wc_rev='-'),
+      })
+  svntest.actions.run_and_verify_status(wc_dir, expected_output)
+
+  # Since copied chi is unmodified the text_timestamp should "match"
+  # the working file but it's not easy to confirm that directly.  We
+  # can confirm that the copied is different from the source.
+  chi_src_timestamp = get_text_timestamp(sbox.ospath('A/D/H/chi'))
+  chi_dst_timestamp1 = get_text_timestamp(sbox.ospath('A/D/H2/chi'))
+  if chi_src_timestamp == chi_dst_timestamp1:
+    raise svntest.Failure("chi timestamps should be different")
+
+  # Since copied psi is modified the text_timestamp should not "match"
+  # the working file, again difficult to confirm directly.  It happens
+  # that the current implementation leaves it equal to the source.
+  psi_src_timestamp = get_text_timestamp(sbox.ospath('A/D/H/psi'))
+  psi_dst_timestamp = get_text_timestamp(sbox.ospath('A/D/H2/psi'))
+  if psi_src_timestamp != psi_dst_timestamp:
+    raise svntest.Failure("psi timestamps should be the same")
+
+  # Cleanup repairs timestamps, so this should be a no-op.
+  svntest.actions.run_and_verify_svn(None, None, [], 'cleanup', wc_dir)
+  chi_dst_timestamp2 = get_text_timestamp(sbox.ospath('A/D/H2/chi'))
+  if chi_dst_timestamp2 != chi_dst_timestamp1:
+    raise svntest.Failure("chi timestamps should be the same")
+
+  svntest.actions.run_and_verify_status(wc_dir, expected_output)
+
 ########################################################################
 # Run the tests
 
@@ -1876,6 +1923,7 @@ test_list = [ None,
               status_with_tree_conflicts,
               status_nested_wc_old_format,
               status_locked_deleted,
+              wc_wc_copy_timestamp,
              ]
 
 if __name__ == '__main__':



Mime
View raw message