subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1844987 - in /subversion/trunk/subversion: libsvn_client/revisions.c tests/cmdline/basic_tests.py
Date Sat, 27 Oct 2018 20:37:10 GMT
Author: brane
Date: Sat Oct 27 20:37:10 2018
New Revision: 1844987

URL: http://svn.apache.org/viewvc?rev=1844987&view=rev
Log:
Raise an error if someone tries to use -rPREV on a working copy at r0.

* subversion/libsvn_client/revisions.c (svn_client__get_revision_number):
   Check for r0 before returning the previous revision.

* subversion/tests/cmdline/basic_tests.py
  (diff_previous_revision_of_r0): New test case.
  (test_list): Add the new test case.

Fixes #4532

Modified:
    subversion/trunk/subversion/libsvn_client/revisions.c
    subversion/trunk/subversion/tests/cmdline/basic_tests.py

Modified: subversion/trunk/subversion/libsvn_client/revisions.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/revisions.c?rev=1844987&r1=1844986&r2=1844987&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/revisions.c (original)
+++ subversion/trunk/subversion/libsvn_client/revisions.c Sat Oct 27 20:37:10 2018
@@ -146,7 +146,14 @@ svn_client__get_revision_number(svn_revn
                                                           scratch_pool));
 
         if (revision->kind == svn_opt_revision_previous)
-          (*revnum)--;
+          {
+            if (*revnum == 0)
+              return svn_error_createf(
+                  SVN_ERR_CLIENT_BAD_REVISION, NULL,
+                  _("Path '%s' has no previous revision"),
+                  svn_dirent_local_style(local_abspath, scratch_pool));
+            --(*revnum);
+          }
       }
       break;
 

Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1844987&r1=1844986&r2=1844987&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Sat Oct 27 20:37:10 2018
@@ -3050,6 +3050,15 @@ def peg_rev_on_non_existent_wc_path(sbox
                                      'cat', '-r2', sbox.ospath('mu3') + '@3')
 
 
+@Issue(4532)
+def diff_previous_revision_of_r0(sbox):
+  """diff -rPREV on WC at revision 0"""
+
+  sbox.build(empty=True)
+  svntest.actions.run_and_verify_svn(None, 'svn: E195002: ',
+                                     'diff', '-rPREV', sbox.ospath(''))
+
+
 # With 'svn mkdir --parents' the target directory may already exist on disk.
 # In that case it was wrongly performing a recursive 'add' on its contents.
 def mkdir_parents_target_exists_on_disk(sbox):
@@ -3302,6 +3311,7 @@ test_list = [ None,
               rm_missing_with_case_clashing_ondisk_item,
               delete_conflicts_one_of_many,
               peg_rev_on_non_existent_wc_path,
+              diff_previous_revision_of_r0,
               mkdir_parents_target_exists_on_disk,
               plaintext_password_storage_disabled,
               filtered_ls,



Mime
View raw message