unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
@ 2015-09-06 18:55 Uwe Brauer
  2015-09-07 17:11 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Uwe Brauer @ 2015-09-06 18:55 UTC (permalink / raw)
  To: emacs-devel

[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
  2015-09-06 18:55 patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added Uwe Brauer
@ 2015-09-07 17:11 ` Stefan Monnier
  2015-09-07 20:46   ` Uwe Brauer
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-09-07 17:11 UTC (permalink / raw)
  To: emacs-devel

> +(defvar vc-rcs-ask-for-login nil
> +  "*Variable which allows to change the login Id by
> a y-or-n question.")

How 'bout instead making vc-rcs.el use the "Author:" header in the
commit message, instead of adding a config var plus a prompt?

Try

   grep "\"Author" lisp/vc/vc*.el

to see how other backends do it.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
  2015-09-07 17:11 ` Stefan Monnier
@ 2015-09-07 20:46   ` Uwe Brauer
  2015-09-07 22:30     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Uwe Brauer @ 2015-09-07 20:46 UTC (permalink / raw)
  To: emacs-devel

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

   >> +(defvar vc-rcs-ask-for-login nil
   >> +  "*Variable which allows to change the login Id by
   >> a y-or-n question.")

   > How 'bout instead making vc-rcs.el use the "Author:" header in the
   > commit message, instead of adding a config var plus a prompt?

   > Try

   >    grep "\"Author" lisp/vc/vc*.el


Sorry but your grep command returns an error :'(

In any case I presume you mean functions like this


(defun vc-hg-checkin (files comment)
  "Hg-specific version of `vc-backend-checkin'.
REV is ignored."
  (apply 'vc-hg-command nil 0 files
         (nconc (list "commit" "-m")
                (log-edit-extract-headers '(("Author" . "--user")
					    ("Date" . "--date"))
                                          comment))))


So it is log-edit-extract-headers

I will play around a bit not sure that will work easily.
Thanks.

   > to see how other backends do it.


   >         Stefan






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
  2015-09-07 20:46   ` Uwe Brauer
@ 2015-09-07 22:30     ` Stefan Monnier
  2015-09-08  9:03       ` Uwe Brauer
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-09-07 22:30 UTC (permalink / raw)
  To: emacs-devel

> In any case I presume you mean functions like this

> (defun vc-hg-checkin (files comment)
>   "Hg-specific version of `vc-backend-checkin'.
> REV is ignored."
>   (apply 'vc-hg-command nil 0 files
>          (nconc (list "commit" "-m")
>                 (log-edit-extract-headers '(("Author" . "--user")
> 					    ("Date" . "--date"))
>                                           comment))))

That's right.

> I will play around a bit not sure that will work easily.

At first sight, it seems that

                 (log-edit-extract-headers '(("Author" . "-w"))
                                           comment))))

might do the trick,


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
  2015-09-07 22:30     ` Stefan Monnier
@ 2015-09-08  9:03       ` Uwe Brauer
  2015-09-08 12:38         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Uwe Brauer @ 2015-09-08  9:03 UTC (permalink / raw)
  To: emacs-devel



   > That's right.


   > At first sight, it seems that

   >                  (log-edit-extract-headers '(("Author" . "-w"))
   >                                            comment))))

After thinking about it, I admit I don't understand this logic.

Git bzr, hg are server/client based with a common repository, in which
case this command makes sense.

But the situation I consider is entirely different. Maybe I have not
explained this well enough.

Suppose I have a latex file under RCS version control:
newpublication.tex 

However I collaborate with someone, who does not use RCS, but sends me
his modified version of this document.
I want to check this in into the RCS, but specifying a different author.

But the only way I see to do this, is to have a prompt asking for the
new user. 

How otherwise could the RCS system guess the author? the file I checked
in does not provide any information concerning the author whatsoever.

I am puzzled.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
  2015-09-08  9:03       ` Uwe Brauer
@ 2015-09-08 12:38         ` Stefan Monnier
  2015-09-09 12:36           ` Uwe Brauer
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-09-08 12:38 UTC (permalink / raw)
  To: emacs-devel

> How otherwise could the RCS system guess the author?

Because in the *VC-Log* buffer you write

  Author: TheOtherGuy

which log-edit-extract-headers then recognizes and turns into a
"-w TheOtherGuy" command line flag to "rcs ci".


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added
  2015-09-08 12:38         ` Stefan Monnier
@ 2015-09-09 12:36           ` Uwe Brauer
  0 siblings, 0 replies; 7+ messages in thread
From: Uwe Brauer @ 2015-09-09 12:36 UTC (permalink / raw)
  To: emacs-devel

>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

   >> How otherwise could the RCS system guess the author?
   > Because in the *VC-Log* buffer you write

   >   Author: TheOtherGuy

   > which log-edit-extract-headers then recognizes and turns into a
   > "-w TheOtherGuy" command line flag to "rcs ci".


Oops, you are right! thanks




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-09 12:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-06 18:55 patch against vc-rcs.el: vc-rcs-checkin: allows user login to be added Uwe Brauer
2015-09-07 17:11 ` 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

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).