Subject: bug#8389: feature proposal: chng login vc-rcs-checkin

From: Uwe Brauer <[email-masked]>
Date: Thu, 31 Mar 2011 16:15:38 +0200

Hello

When collaborating with someone I find it useful to use vc
(rcs) and change the login accordingly when I checkin a new
version. The following code does it, but maybe there are
more sophisticated versions possible.

Uwe Brauer 

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

(defun vc-rcs-checkin (file rev comment)
  "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."
;;(interactive "p")
  (let ((switches (vc-switches 'RCS 'checkin)))
    (let ((old-version (vc-workfile-version file)) new-version
		  (default-branch (vc-file-getprop file 'vc-rcs-default-branch)))
      ;; Force branch creation if an appropriate
      ;; default branch has been set.
      (and (not rev)
		   default-branch
		   (string-match (concat "^" (regexp-quote old-version) "\\.")
						 default-branch)
		   (setq rev default-branch)
		   (setq switches (cons "-f" switches)))
      (if (and (not rev) old-version)
          (setq rev (vc-branch-part old-version)))
      (apply 'vc-do-command nil 0 "ci" (vc-name file)
			 ;; if available, use the secure check-in option
			 (and (vc-rcs-release-p "5.6.4") "-j")
			 (concat (if vc-keep-workfiles "-u" "-r") rev)
			 (if vc-rcs-ask-for-login 
				 (if (y-or-n-p (format "Do you want to change the login  "))
					 (concat "-w" (read-string "Enter New login: "))
			   (concat "-m" comment)))
			 (concat "-m" comment)
			 switches)
      (vc-file-setprop file 'vc-workfile-version nil)

      ;; determine the new workfile version
      (set-buffer "*vc*")
      (goto-char (point-min))
      (when (or (re-search-forward
				 "new revision: \\([0-9.]+\\);" nil t)
				(re-search-forward
				 "reverting to previous revision \\([0-9.]+\\)" nil t))
		(setq new-version (match-string 1))
		(vc-file-setprop file 'vc-workfile-version new-version))

      ;; if we got to a different branch, adjust the default
      ;; branch accordingly
      (cond
       ((and old-version new-version
			 (not (string= (vc-branch-part old-version)
						   (vc-branch-part new-version))))
		(vc-rcs-set-default-branch file
								   (if (vc-trunk-p new-version) nil
									 (vc-branch-part new-version)))
		;; If this is an old RCS release, we might have
		;; to remove a remaining lock.
		(if (not (vc-rcs-release-p "5.6.2"))
			;; exit status of 1 is also accepted.
			;; It means that the lock was removed before.
			(vc-do-command nil 1 "rcs" (vc-name file)
						   (concat "-u" old-version))))))))

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/22.2/etc/DEBUG for instructions.

In GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2010-03-26 on palmer, modified by Ubuntu
Windowing system distributor `The X.Org Foundation', version 11.0.10600000
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim' '--with-x=yes' '--with-x-toolkit=athena' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  global-pabbrev-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
y C-x C-g C-g M-x e m a s c SPC r <backspace> <backspace> 
<backspace> c d SPC <backspace> <backspace> s c <backspace> 
<backspace> c s SPC r e p o r <tab> <M-backspace> b 
<help-echo> <tab> <M-backspace> <M-backspace> b u g 
SPC C-h <help-echo> a b <help-echo> u g <return> C-x 
o C-s e m a c s C-s C-x o M-x r e p o r t SPC e m <tab> 
<return>

Recent messages:
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

For information about GNU Emacs and the GNU system, type C-h C-a.
Quit [2 times]
Loading apropos...done
Type C-x 1 to remove help window.  
Mark saved where search started
Loading emacsbug...done