diff -Nur --exclude=*.moc cervisia-0.6.0/README.CVS_EDIT_HACK cervisia-0.6.0-cvsedit/README.CVS_EDIT_HACK
--- cervisia-0.6.0/README.CVS_EDIT_HACK	Thu Jan  1 01:00:00 1970
+++ cervisia-0.6.0-cvsedit/README.CVS_EDIT_HACK	Fri Jun 16 14:30:42 2000
@@ -0,0 +1,48 @@
+This hack provides features required for working on "watched"
+projects. It was tested useing kde1 on linux only.
+
+
+Impact
+
+If a project is watched by people, it's necessary to run "cvs
+edit" before starting an edit session for two reasons: first, the
+notification sheme of CVS requires it to work properly, and
+second, the file permissions are readonly.
+
+
+Automagical CVS edit
+
+In case the config option "CVS edit automagically" is checked,
+cervisia checks file permissions before invoking the editor. In
+case of a readonly file, a "cvs edit <filename>" command is
+invoked before calling the editor. If "cvs edit" was successful,
+the file permissions grant read-write access now. If it failed, a
+messages will be printed on stdout.
+Since CVS sets the file permissions back to readonly after
+commiting the changes, a "cvs unedit" is not necessary, and will
+not be performed. To finish an edit session, you just need to
+commit.
+
+
+Installation
+
+Invoke "./configure" as usual. So far there is no "--enable-"
+style option for this hack. After that, you'll need to specify
+the use of this hack, otherwise the binary wouldn't include any
+modified code. To archive that, you'll need to define
+"CVS_EDIT_HACK", i.e. by running:
+make CPPFLAGS=-DCVS_EDIT_HACK
+instead of just runnig make.
+To activate the feature, you'll have to check the "CVS edit
+automagically" topic in the "Options" menu at run time.
+
+
+Feedback and Corrections
+
+Please don't bother Bernd Gehrmann with bug reports or complaints
+about this hack but send your comments to Steffen Dettmer
+<steffen@dett.de> if you feel a need.
+Keep in mind, that this is not an official Cervisia feature, at
+least so far. Additional, this beta code comes as-is without
+any warranties.
+
diff -Nur --exclude=*.moc cervisia-0.6.0/src/toplevel.cpp cervisia-0.6.0-cvsedit/src/toplevel.cpp
--- cervisia-0.6.0/src/toplevel.cpp	Fri Apr 14 00:15:53 2000
+++ cervisia-0.6.0-cvsedit/src/toplevel.cpp	Fri Jun 16 14:38:26 2000
@@ -13,6 +13,10 @@
  * You should have received a copy of the Artistic License with 
  * this Kit, in the file named "Artistic".  If not, I'll be glad
  * to provide one.
+ *
+ * Modified Apr 19 2000 by Steffen Dettmer <steffen@dett.de>
+ * All modifications are marked with CVS_EDIT_HACK
+ * See README.CVS_EDIT_HACK for details
  */
 
 
@@ -39,6 +43,16 @@
 #else
 #include <knewpanner.h>
 #endif
+#ifdef CVS_EDIT_HACK
+  #warning "compiling with CVS_EDIT_HACK"
+  /* for stat(2) */
+  #include <sys/stat.h>
+  #include <unistd.h>
+  #include <assert.h>
+#else
+  #warning "CVS_EDIT_HACK disabled"
+#endif
+
 #include <stdlib.h>
 #include <unistd.h>
 #include "logdlg.h"
@@ -293,7 +307,10 @@
     
     options_commitrecur = options->insertItem( i18n("&Commit recursively"),
                                                this, SLOT(slotCommitRecursive()) );
-
+#ifdef CVS_EDIT_HACK
+    options_autocvsedit = options->insertItem( i18n("CVS &edit automagically"),
+                                               this, SLOT(slotAutoCVSEdit()) );
+#endif
     options->insertSeparator();
     
     options_sett        = options->insertItem( i18n("&Settings..."),
@@ -465,14 +482,40 @@
                     command += " ";
                     command += filename;
                     command += "&";
-                    system(command);
+   #ifdef CVS_EDIT_HACK
+			if (opt_autoCVSEdit) {
+			  	if (prepareEdit(filename)) {
+					system(command);
+				} else {
+					printf("FATAL: CVS edit automagic FAILED!\n");
+				}
+			} else {
+				system(command);
+		   	}
+   #else
+			system(command);
+   #endif
+
                 }
 #else
 	    QString command = config->readEntry("Editor", "kwrite");
             command += " ";
 	    command += filename;
 	    command += "&";
+    #ifdef CVS_EDIT_HACK
+		if (opt_autoCVSEdit) {
+			if (prepareEdit(filename)) {
+			system(command);
+			} else {
+				printf("FATAL: CVS edit automagic FAILED!\n");
+			}
+		} else {
+			system(command);
+		}
+    #else
 	    system(command);
+    #endif
+
 #endif
 	}
 }
@@ -930,6 +973,13 @@
     options->setItemChecked(options_commitrecur, opt_commitRecursive);
 }
 
+#ifdef CVS_EDIT_HACK
+void TopLevel::slotAutoCVSEdit()
+{
+    opt_autoCVSEdit = !opt_autoCVSEdit;
+    options->setItemChecked(options_autocvsedit, opt_autoCVSEdit);
+}
+#endif
 
 void TopLevel::slotSettings()
 {
@@ -1225,6 +1275,11 @@
     opt_commitRecursive = config->readBoolEntry("Commit Recursive", false);
     options->setItemChecked(options_commitrecur, opt_commitRecursive);
 
+#ifdef CVS_EDIT_HACK
+    opt_autoCVSEdit = config->readBoolEntry("CVS Edit Automagically", false);
+    options->setItemChecked(options_autocvsedit, opt_autoCVSEdit);
+#endif
+
     int splitterpos1 = config->readNumEntry("Splitter Pos 1", 0);
     int splitterpos2 = config->readNumEntry("Splitter Pos 2", 0);
     if (splitterpos1)
@@ -1251,6 +1306,9 @@
     config->writeEntry("Prune Dirs", opt_pruneDirs);
     config->writeEntry("Update Recursive", opt_updateRecursive);
     config->writeEntry("Commit Recursive", opt_commitRecursive);
+#ifdef CVS_EDIT_HACK
+    config->writeEntry("CVS Edit Automagically", opt_autoCVSEdit);
+#endif
 #if QT_VERSION >= 200
     QValueList<int> sizes = splitter->sizes();
     config->writeEntry("Splitter Pos 1", sizes[0]);
@@ -1262,6 +1320,56 @@
     config->writeEntry("Current Directory", sandbox);
 }
 
+#ifdef CVS_EDIT_HACK
+bool TopLevel::prepareEdit(const QString &filename)
+{
+	/* checks file, if readonly it will run cvs edit */
+	struct stat stat_buf;
+	int ret_code;
+
+	/* stat file, return on error */
+	ret_code = stat(filename,&stat_buf);
+	if (ret_code != 0) {
+	   printf("Error %d on file %s\n", ret_code, (const char*) filename);
+	   perror("stat(2)");
+	   return false;
+	}
+
+	/* check for write access */
+	if (stat_buf.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) {
+	    return true;
+	} else {
+	    /* try to run "cvs edit" now, return on error */
+    	    QString command = "cvs edit ";
+	    command += filename;
+	    ret_code = system(command);
+		if (ret_code != 0) {
+			printf("Error %d calling %s,\n", ret_code,
+				(const char*) command);
+			perror("system(3)");
+			return false;
+		}
+
+		/* if "cvs edit" was successful, file should be writable now */
+		ret_code = stat(filename,&stat_buf);
+		if (ret_code != 0) {
+			printf("Error %d on file %s,\n", ret_code, 
+				(const char*) filename);
+			perror("stat(2)"); /* may be "success" ... */
+			return false;
+		}
+		if (stat_buf.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) {
+			return true; /* feature success */
+		} else {
+			printf("File %s is NOT writeable after cvs edit\n", 
+				(const char*)filename);
+			return false; /* failed for some reason */
+		}
+	}
+	assert( ("line should'n be reached!",false) );
+}
+#endif
+ 
 
 // Local Variables:
 // c-basic-offset: 4
diff -Nur --exclude=*.moc cervisia-0.6.0/src/toplevel.h cervisia-0.6.0-cvsedit/src/toplevel.h
--- cervisia-0.6.0/src/toplevel.h	Thu Apr 13 22:56:06 2000
+++ cervisia-0.6.0-cvsedit/src/toplevel.h	Fri Jun 16 14:30:42 2000
@@ -13,6 +13,10 @@
  * You should have received a copy of the Artistic License with 
  * this Kit, in the file named "Artistic".  If not, I'll be glad
  * to provide one.
+ *
+ * Modified Apr 19 2000 by Steffen Dettmer <steffen@dett.de>
+ * All modifications are marked with CVS_EDIT_HACK
+ * See README.CVS_EDIT_HACK for details 
  */
 
 
@@ -94,6 +98,12 @@
     void slotPruneDirs();
     void slotUpdateRecursive();
     void slotCommitRecursive();
+#ifdef CVS_EDIT_HACK
+    void slotAutoCVSEdit();
+#else
+    /* Since moc(1) is not #ifdef aware, we need to supply a dummy */
+    void slotAutoCVSEdit() { };
+#endif
     void slotSettings();
     void slotConfigureKeys();
     void slotHelp();
@@ -107,6 +117,10 @@
     void importOrCheckout(CheckoutDialog::ActionType action);
     void showJobStart(QString command);
 
+#ifdef CVS_EDIT_HACK
+	bool prepareEdit(const QString &filename); /* runs cvs edit for r/o files */
+#endif
+ 
     KAccel *accel;
     QPopupMenu *file, *recent, *view, *options, *repo, *advanced, *help;
     UpdateView *update;
@@ -128,6 +142,9 @@
     int repo_checkout, repo_import, repo_repos;
     int options_create, options_prune;
     int options_updaterecur, options_commitrecur;
+#ifdef CVS_EDIT_HACK
+	int options_autocvsedit;
+#endif
     int options_sett, options_keys;
     int help_help;
 
@@ -138,6 +155,9 @@
     QStrList recentFiles;
     bool opt_createDirs, opt_pruneDirs;
     bool opt_updateRecursive, opt_commitRecursive;
+#ifdef CVS_EDIT_HACK
+	bool opt_autoCVSEdit;
+#endif
 };
 
 #endif

