unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-devel@gnu.org
Subject: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
Date: Sun, 06 Sep 2015 20:55:34 +0200	[thread overview]
Message-ID: <87d1xvv0m1.fsf@mat.ucm.es> (raw)

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

Hello

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vc-rcs.patch --]
[-- Type: text/x-diff, Size: 3107 bytes --]

diff -u /home/oub/emacs/site-lisp/versch/add-ons/vc-rcs.el /home/oub/emacs/site-lisp/versch/add-ons/vc-rcs-new.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)
 
 \f
+
+;; 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
+;; <adrian@sixfingeredman.net>
+
+(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)
 	       switches)
 	(vc-file-setprop file 'vc-working-revision nil)

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

             reply	other threads:[~2015-09-06 18:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-06 18:55 Uwe Brauer [this message]
2015-09-07 17:11 ` patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added Stefan Monnier
2015-09-07 20:46   ` Uwe Brauer
2015-09-07 22:30     ` Stefan Monnier
2015-09-08  9:03       ` Uwe Brauer
2015-09-08 12:38         ` Stefan Monnier
2015-09-09 12:36           ` Uwe Brauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d1xvv0m1.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).