From 35d746c5915e912e22ef0bc785df2ba1de8966b9 Mon Sep 17 00:00:00 2001 From: Jonathan Kamens Date: Wed, 9 Jan 2002 18:15:43 -0800 Subject: [PATCH] (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] --- vc-p4.el | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/vc-p4.el b/vc-p4.el index 5d76880..2d9cb4c 100644 --- a/vc-p4.el +++ b/vc-p4.el @@ -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."