bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for preserving edit on files when checking out


From: Darren Bowles
Subject: Patch for preserving edit on files when checking out
Date: Wed, 20 Apr 2005 17:15:54 +0100

Please find attached my cvs patch, with test added to sanity.sh.

As requested, the format is cvs diff -u

Ta,
Darren

Index: config.h.in
===================================================================
RCS file: /cvs/ccvs/config.h.in,v
retrieving revision 1.164
diff -u -r1.164 config.h.in
--- config.h.in 23 Mar 2005 00:04:26 -0000      1.164
+++ config.h.in 20 Apr 2005 13:43:42 -0000
@@ -735,6 +735,10 @@
 /* Define to 1 if you have the `__secure_getenv' function. */  #undef
HAVE___SECURE_GETENV
 
+/* Define if you want CVS to be able to preserve your edits on multiple
+   checkouts. */
+#undef KEEP_EDITING
+
 #if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')  #else
Index: configure
===================================================================
RCS file: /cvs/ccvs/configure,v
retrieving revision 1.382
diff -u -r1.382 configure
--- configure   18 Apr 2005 19:44:37 -0000      1.382
+++ configure   20 Apr 2005 13:44:23 -0000
@@ -37912,8 +37912,21 @@
       conftest$ac_exeext conftest.$ac_ext  fi
 
+# --enable-keep-editing Allow a user to keep their file edits, when 
+checking # out another copy of a repository.
 
+# check whether --enable-keep-editing was given if test 
+"${enable_keep_editing+set}" = set; then
+  enableval="$enable_keep_editing"
+else
+  enable_keep_editing=no
+fi;
 
+if test no != "$enable_keep_editing"; then
+  cat >>confdefs.h <<_ACEOF
+#define KEEP_EDITING 1
+_ACEOF
+fi;
 
 # What remote shell transport should our client cvs default to using?
 
Index: configure.in
===================================================================
RCS file: /cvs/ccvs/configure.in,v
retrieving revision 1.349
diff -u -r1.349 configure.in
--- configure.in        18 Apr 2005 19:44:37 -0000      1.349
+++ configure.in        20 Apr 2005 13:44:25 -0000
@@ -1362,6 +1362,136 @@
 dnl
 dnl end --enable-lock-compatibility
 dnl
+dnl
+dnl begin --enable-keep-editing
+dnl
+
+dnl
+dnl If you are using the edit facility and you checkout in more than 
+dnl one directory, you will lose you edit.  This option enables you to 
+dnl keep editing.
+dnl
+
+AC_ARG_ENABLE(
+  [keep-editing],
+  AC_HELP_STRING(
+    [--enable-keep-editing],
+    [Include code for preserving edits on multiple checkouts 
+(default)]), ,
+  [enable_keep_editing=no])
+
+if test yes = "$enable_keep_editing"; then
+  AC_DEFINE(
+    [KEEP_EDITING], [1],
+    [Define if you want CVS to be able to preserve your edits on 
+multiple checkouts.])
+
+dnl
+dnl end --enable-keep-editing
+dnl
+
+dnl
+dnl begin --enable-keep-editing
+dnl
+
+dnl
+dnl If you are using the edit facility and you checkout in more than 
+dnl one directory, you will lose you edit.  This option enables you to 
+dnl keep editing.
+dnl
+
+AC_ARG_ENABLE(
+  [keep-editing],
+  AC_HELP_STRING(
+    [--enable-keep-editing],
+    [Include code for preserving edits on multiple checkouts 
+(default)]), ,
+  [enable_keep_editing=no])
+
+if test yes = "$enable_keep_editing"; then
+  AC_DEFINE(
+    [KEEP_EDITING], [1],
+    [Define if you want CVS to be able to preserve your edits on 
+multiple checkouts.])
+
+dnl
+dnl end --enable-keep-editing
+dnl
+
+dnl
+dnl begin --enable-keep-editing
+dnl
+
+dnl
+dnl If you are using the edit facility and you checkout in more than 
+dnl one directory, you will lose you edit.  This option enables you to 
+dnl keep editing.
+dnl
+
+AC_ARG_ENABLE(
+  [keep-editing],
+  AC_HELP_STRING(
+    [--enable-keep-editing],
+    [Include code for preserving edits on multiple checkouts 
+(default)]), ,
+  [enable_keep_editing=no])
+
+if test yes = "$enable_keep_editing"; then
+  AC_DEFINE(
+    [KEEP_EDITING], [1],
+    [Define if you want CVS to be able to preserve your edits on 
+multiple checkouts.])
+
+dnl
+dnl end --enable-keep-editing
+dnl
+
+dnl
+dnl begin --enable-keep-editing
+dnl
+
+dnl
+dnl If you are using the edit facility and you checkout in more than 
+dnl one directory, you will lose you edit.  This option enables you to 
+dnl keep editing.
+dnl
+
+AC_ARG_ENABLE(
+  [keep-editing],
+  AC_HELP_STRING(
+    [--enable-keep-editing],
+    [Include code for preserving edits on multiple checkouts 
+(default)]), ,
+  [enable_keep_editing=no])
+
+if test yes = "$enable_keep_editing"; then
+  AC_DEFINE(
+    [KEEP_EDITING], [1],
+    [Define if you want CVS to be able to preserve your edits on 
+multiple checkouts.])
+
+dnl
+dnl end --enable-keep-editing
+dnl
+
+dnl
+dnl begin --enable-keep-editing
+dnl
+
+dnl
+dnl If you are using the edit facility and you checkout in more than 
+dnl one directory, you will lose you edit.  This option enables you to 
+dnl keep editing.
+dnl
+
+AC_ARG_ENABLE(
+  [keep-editing],
+  AC_HELP_STRING(
+    [--enable-keep-editing],
+    [Include code for preserving edits on multiple checkouts 
+(default)]), ,
+  [enable_keep_editing=no])
+
+if test yes = "$enable_keep_editing"; then
+  AC_DEFINE(
+    [KEEP_EDITING], [1],
+    [Define if you want CVS to be able to preserve your edits on 
+multiple checkouts.])
+
+dnl
+dnl end --enable-keep-editing
+dnl
+
 
 
 dnl
Index: src/main.c
===================================================================
RCS file: /cvs/ccvs/src/main.c,v
retrieving revision 1.244
diff -u -r1.244 main.c
--- src/main.c  17 Mar 2005 17:15:19 -0000      1.244
+++ src/main.c  20 Apr 2005 13:44:27 -0000
@@ -590,7 +590,6 @@
                (void) fputs ("\n", stdout);
 
                (void) fputs ("Specify the --help option for further
information about CVS\n", stdout);
-
                exit (0);
                break;
            case 'b':
Index: src/sanity.sh
===================================================================
RCS file: /cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1054
diff -u -r1.1054 sanity.sh
--- src/sanity.sh       8 Apr 2005 18:17:01 -0000       1.1054
+++ src/sanity.sh       20 Apr 2005 13:45:14 -0000
@@ -1627,6 +1627,7 @@
        # Watches, binary files, history browsing, &c.
        tests="${tests} devcom devcom2 devcom3 watch4 watch5"
         tests="${tests} edit-check"
+        tests="${tests} keep-editors-check"
        tests="${tests} unedit-without-baserev"
        tests="${tests} ignore ignore-on-branch binfiles binfiles2
binfiles3"
        tests="${tests} mcopy binwrap binwrap2"
@@ -16948,6 +16949,61 @@
          ;;
 
 
+        keep-editors-check)
+          # This tests the --keep-editing option
+         mkdir keep-editors; cd keep-editors
+
+         # do checkout
+         dotest keep-editors-0a "${testcvs} -q co -l ." ""
+
+         # add a new directory
+         mkdir first-dir
+
+         # and add to repository
+         dotest keep-editors-0b "${testcvs} add first-dir" \ "Directory

+${CVSROOT_DIRNAME}/first-dir added to the repository"
+
+         cd first-dir
+         
+         # Add file1 to the repository
+         touch file1
+         dotest keep-editors-1 "${testcvs} add file1" \ "${SPROG} add: 
+scheduling file .file1. for addition ${SPROG} add: use .${SPROG} 
+commit. to add this file permanently"
+         dotest keep-editors-2 "${testcvs} -q ci -m add" \ 
+"$CVSROOT_DIRNAME/first-dir/file1,v  <--  file1 initial revision: 1\.1"
+
+          # edit the file
+         dotest keep-editors-3 "${testcvs} edit file1" ''
+
+         # check we have CVS/Base/file1
+         dotest keep-editors-4 "test -f CVS/Base/file1" ''
+         if ${testcvs} status file1 >>${LOGFILE} 2>&1; then
+               pass keep-editors-5
+         else
+               fail keep-editors-5
+         fi
+
+         # This is the editor line we want to match against
+          editorsLineRE="file1 $username       [SMTWF][uoehra][neduit]
[JFAMSOND][aepuco][nbrylgptvc] [0-9 ][0-9] [0-9:]* [0-9][0-9][0-9][0-9]
-0000   $hostname       $TESTDIR/keep-editors/first-dir"
+
+         # Are we editing the file?
+         dotest keep-editors-6 "${testcvs} editors file1"
"${editorsLineRE}"
+         
+          # Checkout another copy of the repository to a different
directory
+         dotest keep-editors-7 "${testcvs} -q co -d second-dir
first-dir" 'U second-dir/file1'
+
+          # Without the --enable-keep-editing option, this test will
+          # fail, as the editor has been lost.
+          dotest keep-editors-8 "${testcvs} editors file1"
"${editorsLineRE}"
+
+         # Tidy up after tests
+         dokeep
+         cd ../..
+         rm -r keep-editors
+         modify_repo rm -rf $CVSROOT_DIRNAME/first-dir
+         ;;
 
         edit-check)
           # This tests the edit -c/-f and related features.
Index: src/update.c
===================================================================
RCS file: /cvs/ccvs/src/update.c,v
retrieving revision 1.252
diff -u -r1.252 update.c
--- src/update.c        17 Mar 2005 17:15:19 -0000      1.252
+++ src/update.c        20 Apr 2005 13:45:17 -0000
@@ -1345,6 +1345,9 @@
                }
            }
 
+/* The following code will not be included, if we have specified
+   the --enable-keep-editing option to ./configure. */ #ifndef 
+KEEP_EDITING
            {
                /* A newly checked out file is never under the spell
                   of "cvs edit".  If we think we were editing it @@
-1355,11 +1358,11 @@
                struct addremove_args args;
 
                editor_set (finfo->file, getcaller (), NULL);
-
                memset (&args, 0, sizeof args);
                args.remove_temp = 1;
                watch_modify_watchers (finfo->file, &args);
            }
+#endif
 
            /* set the time from the RCS file iff it was unknown before
*/
            set_time =




reply via email to

[Prev in Thread] Current Thread [Next in Thread]