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

Re: Bitesized 576

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2001-12-14 02:16:09 CET

On Thu, Dec 13, 2001 at 11:33:13AM -0600, Karl Fogel wrote:
> Garrett Rooney <rooneg@electricjellyfish.net> writes:
> > i'll take a look at adding some tests tonight.
>
> Thanks!
>
> > > By the way, no need to mime-attach your log message and patch, just
> > > put them directly in the body of the message, it's easier that way. I
> > > just committed some changes to HACKING about this.
> >
> > i'll keep that in mind in the future.
>
> Great.
>
> Good luck, looking forward to next round (& as HACKING now says
> explicitly, this many rounds is normal and nothing to be discouraged
> by),

here's a new version, with a test case.

-garrett

* trunk/subversion/include/svn_error_codes.h
                                                                                
  (SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE): add new error type.
                                                                                
* trunk/subversion/client/cmdline/main.c
                                                                                
  (main): check if the log message is under version control and if so, error
out unless the user has specified --force, since it is almost certainly not
what they want to do.

* trunk/subversion/tests/client/cmdline/log_tests.py

  (versioned_log_message): new test for this functionality.

  also add it to the test_list and remove a comment that says this file
doesn't work and isn't run because it isn't in build.conf, since it does
work, is run, and is in build.conf.

Index: ./subversion/include/svn_error_codes.h
===================================================================
--- ./subversion/include/.svn/text-base/svn_error_codes.h.svn-base Wed Dec 5 19:12:53 2001
+++ ./subversion/include/svn_error_codes.h Thu Dec 6 20:51:51 2001
@@ -359,6 +359,10 @@
   SVN_ERRDEF (SVN_ERR_CL_ADM_DIR_RESERVED,
               "Attempted command in administrative dir")
 
+ SVN_ERRDEF (SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE,
+ "The log message is under version control. " \
+ "Use --force to override.")
+
   /* END Client errors */
   
 
Index: ./subversion/clients/cmdline/main.c
===================================================================
--- ./subversion/clients/cmdline/.svn/text-base/main.c.svn-base Thu Dec 13 18:44:07 2001
+++ ./subversion/clients/cmdline/main.c Thu Dec 13 18:44:07 2001
@@ -362,6 +362,7 @@
   apr_getopt_t *os;
   svn_cl__opt_state_t opt_state;
   const svn_cl__cmd_desc_t *subcommand = NULL;
+ svn_boolean_t log_under_version_control = FALSE;
 
   static const apr_getopt_option_t options[] =
   {
@@ -489,6 +490,14 @@
             svn_pool_destroy (pool);
             return EXIT_FAILURE;
           }
+ {
+ /* check that the file specified isn't versioned */
+ svn_wc_entry_t *ent = NULL;
+
+ err = svn_wc_entry(&ent, svn_stringbuf_create(opt_arg, pool), pool);
+ if (err == SVN_NO_ERROR && ent)
+ log_under_version_control = TRUE;
+ }
         break;
       case 'M':
         opt_state.modified = TRUE;
@@ -578,6 +587,15 @@
               return EXIT_FAILURE;
             }
         }
+ }
+
+ if (log_under_version_control && (! opt_state.force))
+ {
+ svn_handle_error(svn_error_create
+ (SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, 0, NULL,
+ pool, ""), stdout, FALSE);
+ svn_pool_destroy(pool);
+ return EXIT_FAILURE;
     }
 
   /* If we made it this far, then we definitely have the subcommand,
Index: ./subversion/tests/clients/cmdline/log_tests.py
===================================================================
--- ./subversion/tests/clients/cmdline/.svn/text-base/log_tests.py.svn-base Wed Dec 5 19:13:24 2001
+++ ./subversion/tests/clients/cmdline/log_tests.py Thu Dec 13 20:10:00 2001
@@ -2,14 +2,6 @@
 #
 # log_tests.py: testing "svn log"
 #
-# ######################################################################
-# ### ###
-# ### YO! THIS FILE DOESN'T WORK YET. DON'T TRY TO RUN IT. THIS ###
-# ### ISN'T A PROBLEM BECAUSE WE HAVEN'T ADDED IT TO THE TESTS LIST ###
-# ### IN BUILD.CONF YET. ###
-# ### ###
-# ######################################################################
-#
 # Subversion is a tool for revision control.
 # See http://subversion.tigris.org for more information.
 #
@@ -368,6 +360,63 @@
   os.chdir (was_cwd)
   return 0
 
+def versioned_log_message():
+ "'svn commit -F foo' when foo is a versioned file"
+
+ global wc_path
+
+ sbox = "versioned_log_message"
+
+ if svntest.actions.make_repo_and_wc (sbox): return 1
+
+ wc_path = os.path.join (svntest.main.general_wc_dir, sbox)
+ was_cwd = os.getcwd ()
+ os.chdir (wc_path)
+
+ iota_path = os.path.join ('iota')
+ mu_path = os.path.join ('A', 'mu')
+ log_path = os.path.join ('A', 'D', 'H', 'omega')
+
+ svntest.main.file_append (iota_path, "2")
+
+ # try to check in a change using a versioned file as your log entry.
+ stdout_lines, stderr_lines = svntest.main.run_svn ('ci', '-F', log_path)
+
+ # make sure we failed.
+ if (len(stderr_lines) <= 0):
+ os.chdir (was_cwd)
+ return 1
+
+ # force it. should not produce any errors.
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'ci', '-F', log_path, '--force')
+
+ if (len(stderr_lines) != 0):
+ os.chdir (was_cwd)
+ return 1
+
+ svntest.main.file_append (mu_path, "2")
+
+ # try the same thing, but specifying the file to commit explicitly.
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn ('ci', '-F', log_path, mu_path)
+
+ # make sure it failed.
+ if (len(stderr_lines) <= 0):
+ os.chdir (was_cwd)
+ return 1
+
+ # force it... should succeed.
+ stdout_lines, stderr_lines = \
+ svntest.main.run_svn (None, 'ci', '-F', log_path, '--force', mu_path)
+
+ if (len(stderr_lines) != 0):
+ os.chdir (was_cwd)
+ return 1
+
+ os.chdir (was_cwd)
+ return 0
+
 ########################################################################
 # Run the tests
 
@@ -375,6 +424,7 @@
 # list all tests here, starting with None:
 test_list = [ None,
               plain_log,
+ versioned_log_message,
              ]
 
 if __name__ == '__main__':

-- 
garrett rooney                     Unix was not designed to stop you from 
rooneg@electricjellyfish.net       doing stupid things, because that would  
http://electricjellyfish.net/      stop you from doing clever things.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:53 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.