Fix some warnings

This commit is contained in:
Tom Willemse 2021-02-27 15:11:22 -08:00
parent dcb212c410
commit a4c79a8ea3
2 changed files with 46 additions and 70 deletions

View file

@ -104,8 +104,7 @@ Returns the buffer containing the program output."
(temp-name " *p4-lowlevel-output*") (temp-name " *p4-lowlevel-output*")
(output-buffer (or output (p4-lowlevel-get-buffer-create temp-name))) (output-buffer (or output (p4-lowlevel-get-buffer-create temp-name)))
(my-default-directory default-directory)) (my-default-directory default-directory))
(save-excursion (with-current-buffer output-buffer
(set-buffer output-buffer)
(while (and my-default-directory (while (and my-default-directory
(not (file-exists-p my-default-directory)) (not (file-exists-p my-default-directory))
(not (string= "" my-default-directory))) (not (string= "" my-default-directory)))
@ -323,7 +322,7 @@ NOERROR is true, then returns nil rather than raising an error."
(cond (cond
(errors (setq return-value nil)) (errors (setq return-value nil))
((eq output-format 'string) ((eq output-format 'string)
(save-excursion (set-buffer output-buffer) (with-current-buffer output-buffer
(setq return-value (buffer-string))) (setq return-value (buffer-string)))
(kill-buffer output-buffer)) (kill-buffer output-buffer))
((or (eq output-format 'buffer) (bufferp output-format)) ((or (eq output-format 'buffer) (bufferp output-format))
@ -342,10 +341,8 @@ that buffer. Returns the buffer."
(let* ((output-alist (p4-lowlevel-command-or-error args)) (let* ((output-alist (p4-lowlevel-command-or-error args))
(output-buffer (if (bufferp buffer) buffer (output-buffer (if (bufferp buffer) buffer
(p4-lowlevel-get-buffer-create (p4-lowlevel-get-buffer-create
(concat " *p4-lowlevel-" buffer "*")))) (concat " *p4-lowlevel-" buffer "*")))))
text) (with-current-buffer output-buffer
(save-excursion
(set-buffer output-buffer)
(erase-buffer) (erase-buffer)
(insert (p4-lowlevel-lines-matching-tag "^\\(text\\|info\\)" output-alist)) (insert (p4-lowlevel-lines-matching-tag "^\\(text\\|info\\)" output-alist))
output-buffer))) output-buffer)))
@ -433,8 +430,7 @@ as the Perforce client to use."
(if (not buffer) (if (not buffer)
(setq buffer (p4-lowlevel-get-buffer-create (setq buffer (p4-lowlevel-get-buffer-create
" *p4-lowlevel-change*"))) " *p4-lowlevel-change*")))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(erase-buffer) (erase-buffer)
(insert (p4-lowlevel-info-lines alist)) (insert (p4-lowlevel-info-lines alist))
buffer)))) buffer))))
@ -741,8 +737,7 @@ Perforce client to use for the operation."
(setq buffer change-spec) (setq buffer change-spec)
(setq buffer (p4-lowlevel-get-buffer-create (setq buffer (p4-lowlevel-get-buffer-create
" *p4-lowlevel-submit-input*")) " *p4-lowlevel-submit-input*"))
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(erase-buffer) (erase-buffer)
(insert change-spec))) (insert change-spec)))
(p4-lowlevel-command-or-error args buffer))) (p4-lowlevel-command-or-error args buffer)))
@ -804,8 +799,7 @@ Argument NAME is passed directly to `get-buffer-create', so check
the documentation for that function to see its purpose." the documentation for that function to see its purpose."
(let ((buf (get-buffer-create name)) (let ((buf (get-buffer-create name))
(caller-default-directory default-directory)) (caller-default-directory default-directory))
(save-excursion (with-current-buffer buf
(set-buffer buf)
(setq default-directory caller-default-directory)) (setq default-directory caller-default-directory))
buf)) buf))

View file

@ -59,6 +59,8 @@
;;; Code: ;;; Code:
(require 'log-edit)
(eval-and-compile (eval-and-compile
(if (not (string-match "XEmacs" emacs-version)) (if (not (string-match "XEmacs" emacs-version))
(require 'vc-annotate)) (require 'vc-annotate))
@ -182,9 +184,9 @@ compare non-open files to the depot version."
(vc-file-setprop file 'vc-workfile-version haveRev) (vc-file-setprop file 'vc-workfile-version haveRev)
state))))) state)))))
(defun vc-p4-dir-status-files (dir files update-function) (defun vc-p4-dir-status-files (dir _files update-function)
"Find status information for files in the directory DIR. "Find status information for files in the directory DIR.
FILES is ignored. The UPDATE-FUNCTION is used to process the _FILES is ignored. The UPDATE-FUNCTION is used to process the
results of this function." results of this function."
;; XXX: this should be asynchronous. ;; XXX: this should be asynchronous.
(let ((lists (p4-lowlevel-fstat (let ((lists (p4-lowlevel-fstat
@ -208,9 +210,9 @@ results of this function."
(vc-p4-state file) (vc-p4-state file)
(vc-file-getprop file 'vc-workfile-version)) (vc-file-getprop file 'vc-workfile-version))
(defun vc-p4-previous-revision (file rev) (defun vc-p4-previous-revision (_file rev)
"Return the revision of FILE before REV. "Return the previous revision before REV.
If FILEs revision is 1, return that revision." _FILE is ignored."
(let ((newrev (1- (string-to-number rev)))) (let ((newrev (1- (string-to-number rev))))
(when (< 0 newrev) (when (< 0 newrev)
(number-to-string newrev)))) (number-to-string newrev))))
@ -221,9 +223,10 @@ If FILEs revision is 1, return that revision."
(string= (vc-file-getprop file 'vc-latest-version) (string= (vc-file-getprop file 'vc-latest-version)
(vc-file-getprop file 'vc-workfile-version))) (vc-file-getprop file 'vc-workfile-version)))
(defun vc-p4-checkout-model (file) (defun vc-p4-checkout-model (_file)
"Return the checkout model for Perforce (`announce'). "Return the checkout model for Perforce (`announce').
Perforce only has one checkout model for all files, so FILE is ignored." Perforce only has one checkout model for all files, so _FILE is
ignored."
'announce) 'announce)
(defun vc-p4-workfile-unchanged-p (file) (defun vc-p4-workfile-unchanged-p (file)
@ -324,8 +327,7 @@ Check in with comment COMMENT. Error if REV is non-nil."
(dolist (file files) (dolist (file files)
(if (vc-p4-has-unresolved-conflicts-p file) (if (vc-p4-has-unresolved-conflicts-p file)
(error "File %s has unresolved conflicts" file))) (error "File %s has unresolved conflicts" file)))
(save-excursion (with-current-buffer change-buffer
(set-buffer change-buffer)
(goto-char (point-min)) (goto-char (point-min))
(re-search-forward "^Description:\\s-*\n") (re-search-forward "^Description:\\s-*\n")
(kill-line 1) (kill-line 1)
@ -351,8 +353,7 @@ Check in with comment COMMENT. Error if REV is non-nil."
(defun vc-p4-checkout (file &optional rev) (defun vc-p4-checkout (file &optional rev)
"Checkout FILE from Perforce, optionally at revision REV." "Checkout FILE from Perforce, optionally at revision REV."
(let ((default-directory (file-name-directory file)) (let ((default-directory (file-name-directory file)))
buffer)
;; Make sure we've got all the current state of the file ;; Make sure we've got all the current state of the file
(vc-p4-state file) (vc-p4-state file)
(cond (cond
@ -366,9 +367,9 @@ Check in with comment COMMENT. Error if REV is non-nil."
(p4-lowlevel-edit file :client vc-p4-client)) (p4-lowlevel-edit file :client vc-p4-client))
(vc-p4-state file nil t)) (vc-p4-state file nil t))
(defun vc-p4-revert (file contents-done) (defun vc-p4-revert (file _contents-done)
"Revert FILE in Perforce. "Revert FILE in Perforce.
CONTENTS-DONE is ignored." _CONTENTS-DONE is ignored."
(let ((action (vc-file-getprop file 'vc-p4-action))) (let ((action (vc-file-getprop file 'vc-p4-action)))
(cond (cond
((null action) ((null action)
@ -434,9 +435,9 @@ otherwise this function will raise an error."
vc-p4-client))) vc-p4-client)))
(p4-lowlevel-reopen file :client vc-p4-client))) (p4-lowlevel-reopen file :client vc-p4-client)))
(defun vc-p4-print-log (files &optional buffer shortlog revision limit) (defun vc-p4-print-log (files &optional buffer shortlog _revision limit)
"Print Perforce log for FILES into BUFFER. "Print Perforce log for FILES into BUFFER.
If SHORTLOG is non-nil print a short version of the log. REVISION If SHORTLOG is non-nil print a short version of the log. _REVISION
is ignored. If LIMIT is non-nil only print that many log messages." is ignored. If LIMIT is non-nil only print that many log messages."
;; `log-view-mode' needs to have the file name in order to function ;; `log-view-mode' needs to have the file name in order to function
;; correctly. "p4 logview" does not print it, so we insert it here by ;; correctly. "p4 logview" does not print it, so we insert it here by
@ -493,9 +494,9 @@ is ignored. If LIMIT is non-nil only print that many log messages."
(goto-char start) (goto-char start)
(recenter 0)))))) (recenter 0))))))
(defun vc-p4-wash-log (file) (defun vc-p4-wash-log (_file)
"Remove all non-comment information from the log in the current buffer. "Remove all non-comment information from the log in the current buffer.
FILE is ignored." _FILE is ignored."
(goto-char (point-min)) (goto-char (point-min))
(delete-non-matching-lines "^\t")) (delete-non-matching-lines "^\t"))
@ -684,7 +685,7 @@ Annotate version VERSION if it's specified."
file)) file))
(starting-date (if current-prefix-arg (starting-date (if current-prefix-arg
(read-string "Starting date: (default none) "))) (read-string "Starting date: (default none) ")))
log-buffer times args) args)
(setq args (append (list buffer nil vc-p4-annotate-command nil) (setq args (append (list buffer nil vc-p4-annotate-command nil)
(if starting-date (if starting-date
(list "--after" starting-date)) (list "--after" starting-date))
@ -696,8 +697,7 @@ Annotate version VERSION if it's specified."
(defun vc-p4-read-output (buffer) (defun vc-p4-read-output (buffer)
"Read the first line of BUFFER and return it. "Read the first line of BUFFER and return it.
Read lines are deleted from buffer." Read lines are deleted from buffer."
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(goto-char (point-min)) (goto-char (point-min))
(forward-line) (forward-line)
(let ((line (buffer-substring (point-min) (point)))) (let ((line (buffer-substring (point-min) (point))))
@ -710,16 +710,14 @@ Read lines are deleted from buffer."
line))))) line)))))
;;; Adapted from p4.el ;;; Adapted from p4.el
(defun vc-p4-annotate-command-internal (file buffer &optional version) (defun vc-p4-annotate-command-internal (file buffer &optional _version)
"Execute \"p4 annotate\" on FILE, inserting the contents in BUFFER. "Execute \"p4 annotate\" on FILE, inserting the contents in BUFFER.
Optional argument VERSION is a version to annotate from." _VERSION is ignored."
;; XXX maybe not needed, but just in case. ;; XXX maybe not needed, but just in case.
(vc-setup-buffer buffer) (vc-setup-buffer buffer)
;; (with-current-buffer buffer ;; (with-current-buffer buffer
(let ((file-name file) (let ((file-name file)
(file-spec file) (file-spec file)
(blame-branch-regex
"^\\.\\.\\. \\.\\.\\. branch from \\(//[^#]*\\)#")
(blame-change-regex (blame-change-regex
(concat "^\\.\\.\\. #" "\\([0-9]+\\)" ;; revision (concat "^\\.\\.\\. #" "\\([0-9]+\\)" ;; revision
"\\s-+change\\s-+" "\\([0-9]+\\)" ;; change "\\s-+change\\s-+" "\\([0-9]+\\)" ;; change
@ -728,7 +726,6 @@ Optional argument VERSION is a version to annotate from."
"\\s-+by\\s-+" "\\([^ \t]+\\)" ;; author "\\s-+by\\s-+" "\\([^ \t]+\\)" ;; author
"@")) "@"))
head-name ; file spec of the head revision for this blame assignment head-name ; file spec of the head revision for this blame assignment
branch-p ; have we tracked into a branch?
cur-file ; file name of the current branch during blame assignment cur-file ; file name of the current branch during blame assignment
change ch-alist fullname head-rev headseen) change ch-alist fullname head-rev headseen)
@ -796,12 +793,7 @@ Optional argument VERSION is a version to annotate from."
(cons (cons
(cons ch (list rev date author cur-file)) ch-alist)) (cons ch (list rev date author cur-file)) ch-alist))
(if (not head-rev) (setq head-rev rev)) (if (not head-rev) (setq head-rev rev))
(setq headseen t)))) (setq headseen t)))))
;; not if we have entered a branch (this used to be used, isn't
;; right now - maybe again later:
(if (and headseen (looking-at blame-branch-regex))
(setq branch-p t)))
(forward-line)))) (forward-line))))
(if (< (length ch-alist) 1) (if (< (length ch-alist) 1)
@ -812,8 +804,7 @@ Optional argument VERSION is a version to annotate from."
(tmp-alst (copy-alist ch-alist))) (tmp-alst (copy-alist ch-alist)))
;; (p4-exec-p4 ch-buffer (list "print" "-q" (concat cur-file "@" base-ch)) t) ;; (p4-exec-p4 ch-buffer (list "print" "-q" (concat cur-file "@" base-ch)) t)
(vc-p4-command ch-buffer nil nil "print" "-q" (concat cur-file "@" base-ch)) (vc-p4-command ch-buffer nil nil "print" "-q" (concat cur-file "@" base-ch))
(save-excursion (with-current-buffer ch-buffer
(set-buffer ch-buffer)
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward ".*\n" nil t) (while (re-search-forward ".*\n" nil t)
(replace-match (concat base-ch "\n")))) (replace-match (concat base-ch "\n"))))
@ -838,7 +829,6 @@ Optional argument VERSION is a version to annotate from."
"diff2" (format "%s@%d" file1 ch-1) "diff2" (format "%s@%d" file1 ch-1)
(format "%s@%d" file2 ch-2)) (format "%s@%d" file2 ch-2))
(save-excursion (save-excursion
;;(set-buffer buffer)
(goto-char (point-max)) (goto-char (point-max))
(while (re-search-backward blame-revision-regex nil t) (while (re-search-backward blame-revision-regex nil t)
(let ((la (string-to-number (match-string 1))) (let ((la (string-to-number (match-string 1)))
@ -854,8 +844,7 @@ Optional argument VERSION is a version to annotate from."
(setq la (1+ la))) (setq la (1+ la)))
((string= op "d") ((string= op "d")
(setq ra (1+ ra)))) (setq ra (1+ ra))))
(save-excursion (with-current-buffer ch-buffer
(set-buffer ch-buffer)
(goto-line la) (goto-line la)
(let ((beg (point))) (let ((beg (point)))
(forward-line (1+ (- lb la))) (forward-line (1+ (- lb la)))
@ -876,9 +865,8 @@ Optional argument VERSION is a version to annotate from."
" *\\([0-9]+\\)" ;; change " *\\([0-9]+\\)" ;; change
" *\\([0-9]+\\)" ;; revision " *\\([0-9]+\\)" ;; revision
" ")) " "))
xth-rev xth-date xth-auth xth-file) xth-rev xth-date xth-auth)
(save-excursion (with-current-buffer buffer
(set-buffer buffer)
(goto-line 2) (goto-line 2)
(move-to-column 0) (move-to-column 0)
(insert (format "%10s %7s %6s %4s\n" "Date" "Author" "Change" "Rev")) (insert (format "%10s %7s %6s %4s\n" "Date" "Author" "Change" "Rev"))
@ -892,21 +880,16 @@ Optional argument VERSION is a version to annotate from."
(setq change-data (cdr (assq cnum ch-alist)) (setq change-data (cdr (assq cnum ch-alist))
xth-rev (nth 0 change-data) xth-rev (nth 0 change-data)
xth-date (nth 1 change-data) xth-date (nth 1 change-data)
xth-auth (nth 2 change-data) xth-auth (nth 2 change-data))
xth-file (nth 3 change-data))
(insert (insert
(format "%10s %7s %6d %4d " xth-date xth-auth cnum xth-rev)) (format "%10s %7s %6d %4d " xth-date xth-auth cnum xth-rev))
(move-to-column 0) (move-to-column 0)
(if (looking-at blame-index-regex) (if (looking-at blame-index-regex)
(let ((nth-cnum (match-string 3))
(nth-revn (match-string 4))
(nth-user (match-string 2)))
;; truncate the user name:
(let ((start (+ (match-beginning 2) 7)) (let ((start (+ (match-beginning 2) 7))
(end (match-end 2))) (end (match-end 2)))
(if (> end start) (if (> end start)
(delete-region start end)))))) (delete-region start end)))))
(setq old-cnum cnum) (setq old-cnum cnum)
(forward-line)))) (forward-line))))
@ -937,8 +920,9 @@ days. Moves the point to the end of the annotation."
(beginning-of-line) (beginning-of-line)
(if (looking-at vc-p4-annotate-re) (match-string-no-properties 3)))) (if (looking-at vc-p4-annotate-re) (match-string-no-properties 3))))
(defun vc-p4-previous-version (file rev) (defun vc-p4-previous-version (_file rev)
"Return the Perforce revision of FILE prior to REV." "Return the Perforce revision prior to REV.
_FILE is ignored."
(number-to-string (- (string-to-number rev) 1))) (number-to-string (- (string-to-number rev) 1)))
(defun vc-p4-find-p4config (&optional dirname) (defun vc-p4-find-p4config (&optional dirname)
@ -1015,10 +999,8 @@ sub-block within it."
"Search for P4 conflict markers in BUFFER and select the WHICH text of each. "Search for P4 conflict markers in BUFFER and select the WHICH text of each.
WHICH should be either 1, 2, or 3 to indicate the first, second or WHICH should be either 1, 2, or 3 to indicate the first, second or
third sub-block in each conflict block." third sub-block in each conflict block."
(let (block-list block-start block-end sub-start sub-end sublist subcount (let (block-list block-start block-end subcount replacement)
replacement) (with-current-buffer buffer
(save-excursion
(set-buffer buffer)
(while (setq block-list (vc-p4-has-unresolved-conflicts-p buffer)) (while (setq block-list (vc-p4-has-unresolved-conflicts-p buffer))
(setq block-start (car block-list) (setq block-start (car block-list)
block-end (cadr block-list) block-end (cadr block-list)