[Top][All Lists]

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

patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added

From: Uwe Brauer
Subject: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
Date: Sun, 06 Sep 2015 20:55:34 +0200
User-agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/25.0.50 (gnu/linux)


The following patch adds a new functionality to vc-rcs-checkin:
The login user can be added optionally.

Rationale: suppose your files are under RCS version control and you
collaborate with somebody who does not use RCS. So when you check in his
changes, it comes in handy to add the user login. This way vc-annotate
distinguish between his and yours changes.

Of course you don't want this behavior always since the majority of a
typical RCS user are single managed and don't require to change the
user in every checkin. That is why I introduced some new variables and a
«toggling» function which allows to switch this feature on or off.

I find my implementation quite a kludge, so if somebody finds this
useful and wants to modify the code, please do.

Uwe Brauer

diff -u /home/oub/emacs/site-lisp/versch/add-ons/vc-rcs.el 
--- /home/oub/emacs/site-lisp/versch/add-ons/vc-rcs.el  2015-09-06 
16:19:54.780811291 +0200
+++ /home/oub/emacs/site-lisp/versch/add-ons/vc-rcs-new.el      2015-09-06 
16:27:04.662942964 +0200
@@ -106,6 +106,58 @@
   :group 'vc-rcs)
+;; new variable for changing the login user
+(defvar vc-rcs-ask-for-login nil
+  "*Variable which allows to change the login Id by a y-or-n question.")
+(defvar vc-rcs-login-user nil 
+  "*Variable which saves the value of the rcs user who checks in.")
+;; since changing the (login) user is not a frequent thing to do, the 
following functions
+;; toggle this behaviour on an off
+;; the following function was written by Adrian Kubala
+;; <address@hidden>
+(defun make-repeat-command (symbol command-list)
+  "Command changes with each repetition.
+SYMBOL is a symbol unique to this command."
+  (if (eq last-command symbol)
+      (set symbol (+ (eval symbol) 1))
+    (set symbol 0))
+  (if (>= (eval symbol) (length command-list))
+      (set symbol 0))
+  (call-interactively (nth (eval symbol) command-list))
+  (setq this-command symbol))
+(defun vc-rcs-set-for-login ()
+  (interactive)
+  (load-file "~/emacs/site-lisp/versch/vc-change-login.elc")
+  (setq vc-rcs-ask-for-login t)
+  (message "Now login will be changed when vc-rcs-checkin is called."))
+(defun vc-rcs-remove-for-login () 
+  (interactive)
+  (setq vc-rcs-ask-for-login nil)
+  (message "Now login will  *NOT* be changed when vc-rcs-checkin is called."))
+(defun vc-ask-login-or-not ()
+  (interactive)
+  (make-repeat-command 'vc-ask-login-or-not
+                      '(vc-rcs-set-for-login
+                         vc-rcs-remove-for-login)))
+;; end of toggling functions
 ;;; Properties of the backend
 (defun vc-rcs-revision-granularity () 'file)
@@ -309,9 +361,11 @@
 ;; It used to be possible to pass in a value for the variable rev, but
 ;; nothing in the rest of VC used this capability.  Removing it makes the
 ;; backend interface simpler for all modes.
+;; modified 
 (defun vc-rcs-checkin (files comment)
-  "RCS-specific version of `vc-backend-checkin'."
+  "RCS-specific version of `vc-backend-checkin'. If the variable
+vc-rcs-ask-for-login is set to t, function asks for user login.
+Useful for collaboration to distinguish different checkins."
   (let (rev (switches (vc-switches 'RCS 'checkin)))
     ;; Now operate on the files
     (dolist (file (vc-expand-dirs files 'RCS))
@@ -331,6 +385,12 @@
               ;; if available, use the secure check-in option
               (and (vc-rcs-release-p "5.6.4") "-j")
               (concat "-u" rev)
+              (if vc-rcs-ask-for-login 
+                  (if (y-or-n-p (format "Do you want to change the login  "))
+                      (progn
+                        (setq vc-rcs-login-user (read-string "Enter New login: 
+                        (concat "-w" vc-rcs-login-user))
+                    (concat "-m" comment)))
               (concat "-m" comment)
        (vc-file-setprop file 'vc-working-revision nil)

Diff finished.  Sun Sep  6 16:27:33 2015

reply via email to

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