(vc-p4-registered): Don't consider a file registered if its current

action or head action is "delete".

(vc-p4-register): If someone tries to register a file which is
currently open for delete, offer them the choice of reverting and
editing the file, possibly preserving its contents.

[git-p4: depot-paths = "//guest/Ben_Key/vc-p4/,//guest/jonathan_kamens/vc-p4/,//guest/magnus_henoch/vc-p4/": change = 1266]
This commit is contained in:
Jonathan Kamens 2002-01-09 18:15:43 -08:00
parent 1e65e958c7
commit 35d746c591

View file

@ -348,8 +348,11 @@ specify a starting date when you run C-u C-x v g."
(getenv "P4CONFIG")
(not (vc-p4-find-p4config (file-name-directory file))))
nil
(let ((fstat (p4-lowlevel-fstat file nil t)))
(if (not fstat)
(let* ((fstat (p4-lowlevel-fstat file nil t))
(action (cdr (or (assoc "action" fstat)
(assoc "headAction" fstat)))))
(if (or (not fstat)
(string= action "delete"))
nil
; This sets a bunch of VC properties
(vc-p4-state file fstat)
@ -471,7 +474,22 @@ special case of a Perforce file that is added but not yet committed."
(error "Can't specify revision when registering Perforce file."))
(if (and comment (not (string= comment "")))
(error "Can't specify comment when registering Perforce file."))
(p4-lowlevel-add file))
(let* ((fstat (p4-lowlevel-fstat file nil t))
(action (cdr (assoc "action" fstat))))
(if (string= action "delete")
(if (yes-or-no-p
"File already opened for delete; revert and edit it? ")
(progn
(if (yes-or-no-p "Preserve current contents? ")
(let ((tempfile (format "%s.vc-register~" file)))
(rename-file file tempfile)
(p4-lowlevel-revert file)
(delete-file file)
(rename-file tempfile file))
(p4-lowlevel-revert file))
(p4-lowlevel-edit file))
(error "File %s already opened for delete." file))
(p4-lowlevel-add file))))
(defun vc-p4-init-version ()
"Returns `1', the default initial version for Perforce files."