Hi,

Second iteration of my patch for fixing issue #4395.
http://subversion.tigris.org/issues/show_bug.cgi?id=4395

The fix itself is actually unchanged, but I added a test case
which upgrades some working copies of different formats and
checks whether the "format" and "entries" files are present
and correct.

[[[
Fix issue 4395 by not deleting the format and entries file when we 
upgrade from an 1.7 working copy.

* subversion/libsvn_wc/upgrade.c
  (wipe_obsolete_files): Add a boolean parameter remove_format_entries
    declaring whether we should wipe format and entry files.
  (svn_wc__wipe_postupgrade): Pass TRUE for remove_format_entries to
    keep the old behavior for pre-1.7 working copies.
  (svn_wc__upgrade_sdb): Pass FALSE for remove_format_entries to keep
    the files when upgrading from an 1.7 (or newer) working copy.

* subversion/tests/cmdline/upgrade_tests.py
  (upgrade_dropped_status_entries_files): Add a new test case to check
    that the "entries" and "format" files are retained during upgrade.
]]]

Best regards

Markus Schaber

CODESYS® a trademark of 3S-Smart Software Solutions GmbH

Inspiring Automation Solutions

3S-Smart Software Solutions GmbH
Dipl.-Inf. Markus Schaber | Product Development Core Technology
Memminger Str. 151 | 87439 Kempten | Germany
Tel. +49-831-54031-979 | Fax +49-831-54031-50

E-Mail: m.scha...@codesys.com | Web: http://www.codesys.com | CODESYS store: 
http://store.codesys.com
CODESYS forum: http://forum.codesys.com

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade 
register: Kempten HRB 6186 | Tax ID No.: DE 167014915

> -----Ursprüngliche Nachricht-----
> Von: Markus Schaber [mailto:m.scha...@codesys.com]
> Gesendet: Freitag, 20. Juni 2014 12:36
> An: Subversion Dev (dev@subversion.apache.org)
> Betreff: [Patch] Fix for Issue #4395: 'svn upgrade' loses 1.6-client
> format files
> 
> Hi,
> 
> See attached my patch for fixing issue #4395.
> http://subversion.tigris.org/issues/show_bug.cgi?id=4395
> 
> [[[
> Fix issue 4395 by not deleting the format and entries file when we
> upgrade from an 1.7 working copy.
> 
> * subversion/libsvn_wc/upgrade.c
>   (wipe_obsolete_files): Add a boolean parameter
> remove_format_entries
>     declaring whether we should wipe format and entry files.
>   (svn_wc__wipe_postupgrade): Pass TRUE for remove_format_entries to
>     keep the old behavior for pre-1.7 working copies.
>   (svn_wc__upgrade_sdb): Pass FALSE for remove_format_entries to keep
>     the files when upgrading from an 1.7 (or newer) working copy.
> ]]]
> 
> 
> All tests still pass after applying that change, but it seems the
> change itself is not covered by any tests. Should I add a test case
> for it? If yes, how to get/create 1.6 and 1.7 working copies within
> the test suite?
> 
> 
> Best regards
> 
> Markus Schaber
> 
> CODESYS(r) a trademark of 3S-Smart Software Solutions GmbH
> 
> Inspiring Automation Solutions
> 
> 3S-Smart Software Solutions GmbH
> Dipl.-Inf. Markus Schaber | Product Development Core Technology
> Memminger Str. 151 | 87439 Kempten | Germany Tel. +49-831-54031-979 |
> Fax +49-831-54031-50
> 
> E-Mail: m.scha...@codesys.com | Web: http://www.codesys.com | CODESYS
> store: http://store.codesys.com CODESYS forum:
> http://forum.codesys.com
> 
> Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner |
> Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915

Index: subversion/libsvn_wc/upgrade.c
===================================================================
--- subversion/libsvn_wc/upgrade.c      (revision 1604170)
+++ subversion/libsvn_wc/upgrade.c      (working copy)
@@ -430,21 +430,24 @@
 
 /* Wipe out all the obsolete files/dirs from the administrative area.  */
 static void
-wipe_obsolete_files(const char *wcroot_abspath, apr_pool_t *scratch_pool)
+wipe_obsolete_files(const char *wcroot_abspath, svn_boolean_t 
remove_format_entries, apr_pool_t *scratch_pool)
 {
   /* Zap unused files.  */
+  if (remove_format_entries)
+  {
+    svn_error_clear(svn_io_remove_file2(
+                      svn_wc__adm_child(wcroot_abspath,
+                                        SVN_WC__ADM_FORMAT,
+                                        scratch_pool),
+                      TRUE, scratch_pool));
+    svn_error_clear(svn_io_remove_file2(
+                      svn_wc__adm_child(wcroot_abspath,
+                                        SVN_WC__ADM_ENTRIES,
+                                        scratch_pool),
+                      TRUE, scratch_pool));
+  }
   svn_error_clear(svn_io_remove_file2(
                     svn_wc__adm_child(wcroot_abspath,
-                                      SVN_WC__ADM_FORMAT,
-                                      scratch_pool),
-                    TRUE, scratch_pool));
-  svn_error_clear(svn_io_remove_file2(
-                    svn_wc__adm_child(wcroot_abspath,
-                                      SVN_WC__ADM_ENTRIES,
-                                      scratch_pool),
-                    TRUE, scratch_pool));
-  svn_error_clear(svn_io_remove_file2(
-                    svn_wc__adm_child(wcroot_abspath,
                                       ADM_EMPTY_FILE,
                                       scratch_pool),
                     TRUE, scratch_pool));
@@ -564,7 +567,7 @@
                                                          iterpool),
                                        TRUE, NULL, NULL, iterpool));
   else
-    wipe_obsolete_files(dir_abspath, scratch_pool);
+    wipe_obsolete_files(dir_abspath, TRUE, scratch_pool);
 
   if (delete_dir)
     {
@@ -1977,7 +1980,7 @@
 #endif
 
   /* Zap anything that might be remaining or escaped our notice.  */
-  wipe_obsolete_files(wcroot_abspath, scratch_pool);
+  wipe_obsolete_files(wcroot_abspath, FALSE, scratch_pool);
 
   return SVN_NO_ERROR;
 }
Index: subversion/tests/cmdline/upgrade_tests.py
===================================================================
--- subversion/tests/cmdline/upgrade_tests.py   (revision 1604170)
+++ subversion/tests/cmdline/upgrade_tests.py   (working copy)
@@ -1438,6 +1438,39 @@
   # svn: warning: W200033: sqlite[S5]: database is locked
   svntest.actions.run_and_verify_svn(None, None, [], 'upgrade', sbox.wc_dir)
 
+@Issue(4395)
+def upgrade_dropped_status_entries_files(sbox):  
+  "upgrade dropped entries and status files"
+  
+  # We try to test several SVN versions with and without the 1.7.x 
+  # wc db structure.
+  files_to_test = (
+    ('wc-3x-1.4.6.tar.bz2', 'wc-1.4.6'),
+    ('upgrade_1_5.tar.bz2', None),
+    ('wc-3x-1.6.12.tar.bz2', 'wc-1.6.12'),
+    ('upgrade_from_1_7_wc.tar.bz2', None),
+  )
+  
+  for packedwc, wcdir in files_to_test:
+    replace_sbox_with_tarfile(sbox, packedwc, dir = wcdir)
+    
+    svntest.actions.run_and_verify_svn(None, None, [], 'upgrade', sbox.wc_dir)
+    
+    entrypath = os.path.join(sbox.wc_dir, ".svn/entries")
+    formatpath = os.path.join(sbox.wc_dir, ".svn/entries")
+    
+    for filepath in (entrypath, formatpath):
+      if not os.path.isfile(filepath):
+        raise svntest.Failure("Upgrade of %s: File %s is missing" %
+                    (packedwc, filepath))
+        
+      if int(open(filepath).read().rstrip()) != 12:
+        raise svntest.Failure("Upgrade of %s: File %s doesn't denote format 
12" %
+                    (packedwc, filepath))
+    
+  
+  
+  
 ########################################################################
 # Run the tests
 
@@ -1494,6 +1527,7 @@
               iprops_upgrade1_6,
               changelist_upgrade_1_6,
               upgrade_1_7_dir_external,
+              upgrade_dropped_status_entries_files,
              ]
 
 

Reply via email to