changeset 16742:25558bcdfc93

(vc-user-login-name): New function. (vc-fetch-master-properties, vc-lock-from-permissions, vc-file-owner, vc-fetch-properties, vc-after-save, vc-mode-line, vc-status): Use `vc-user-login-name' instead of `user-login-name'.
author André Spiegel <spiegel@gnu.org>
date Thu, 26 Dec 1996 12:06:13 +0000
parents e4e15030dad3
children 612fe5713ede
files lisp/vc-hooks.el
diffstat 1 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/vc-hooks.el	Thu Dec 26 06:10:32 1996 +0000
+++ b/lisp/vc-hooks.el	Thu Dec 26 12:06:13 1996 +0000
@@ -289,7 +289,7 @@
       (vc-parse-buffer 
        (list '("^\001d D \\([^ ]+\\)" 1)
 	     (list (concat "^\001d D \\([^ ]+\\) .* " 
-			   (regexp-quote (user-login-name)) " ") 1))
+			   (regexp-quote (vc-user-login-name)) " ") 1))
        file
        '(vc-latest-version vc-your-latest-version)))
 
@@ -564,12 +564,22 @@
 	       (vc-file-setprop file 'vc-locking-user 'none))
 	      ((and (= (nth 2 attributes) (user-uid))
 		    (string-match ".rw..-..-." (nth 8 attributes)))
-	       (vc-file-setprop file 'vc-locking-user (user-login-name)))
+	       (vc-file-setprop file 'vc-locking-user (vc-user-login-name)))
 	      (nil)))))
 
+(defun vc-user-login-name (&optional uid)
+  ;; Return the name under which the user is logged in, as a string.
+  ;; (With optional argument UID, return the name of that user.)
+  ;; This function does the same as `user-login-name', but unlike
+  ;; that, it never returns nil.  If a UID cannot be resolved, that
+  ;; UID is returned as a string.
+  (or (user-login-name uid)
+      (and uid (number-to-string uid))
+      (number-to-string (user-uid))))
+
 (defun vc-file-owner (file)
   ;; Return who owns FILE (user name, as a string).
-  (user-login-name (nth 2 (file-attributes file))))
+  (vc-user-login-name (nth 2 (file-attributes file))))
 
 (defun vc-rcs-lock-from-diff (file)
   ;; Diff the file against the master version.  If differences are found,
@@ -686,7 +696,7 @@
 	     (list (concat "^\\([0-9]+\\.[0-9.]+\\)\n"
 			   "date[ \t]+\\([0-9.]+\\);[ \t]+"
 			   "author[ \t]+"
-			   (regexp-quote (user-login-name)) ";") 1 2))
+			   (regexp-quote (vc-user-login-name)) ";") 1 2))
        file
        '(vc-latest-version vc-your-latest-version))
       (if (get-buffer "*vc-info*")
@@ -853,7 +863,7 @@
 	     t)
 	 (not (vc-locking-user file))
 	 (eq (vc-checkout-model file) 'implicit)
-	 (vc-file-setprop file 'vc-locking-user (user-login-name))
+	 (vc-file-setprop file 'vc-locking-user (vc-user-login-name))
 	 (or (and (eq (vc-backend file) 'CVS) 
 		  (vc-file-setprop file 'vc-cvs-status nil))
 	     t)
@@ -876,7 +886,7 @@
     (and vc-type 
 	 (equal file (buffer-file-name))
 	 (vc-locking-user file)
-	 (not (string= (user-login-name) (vc-locking-user file)))
+	 (not (string= (vc-user-login-name) (vc-locking-user file)))
 	 (setq buffer-read-only t))
     ;; If the user is root, and the file is not owner-writable,
     ;; then pretend that we can't write it
@@ -914,7 +924,7 @@
 	   " @@")
 	  ((not locker)
 	   (concat "-" rev))
-	  ((string= locker (user-login-name))
+	  ((string= locker (vc-user-login-name))
 	   (concat ":" rev))
 	  (t 
 	   (concat ":" locker ":" rev)))))