From 48237437e8c22b102c47f92e94c66a461574feb9 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 24 Feb 2021 22:17:00 -0800 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=98vc-p4-rename=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Perforce renaming and deleting and creating files are different things. In the latter situation any history is lost. --- p4-lowlevel.el | 17 +++++++++++++++++ vc-p4.el | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/p4-lowlevel.el b/p4-lowlevel.el index 74d46b0..f82b986 100644 --- a/p4-lowlevel.el +++ b/p4-lowlevel.el @@ -820,4 +820,21 @@ current ticket is displayed (if there is one) instead." (p4-not-logged-in-error (unless status (signal (car err) (cdr err))))))) +(cl-defun p4-lowlevel-rename (from-file to-file &key changelist preview server-only) + "Call ‘p4 move -r’ with arguments. +FROM-FILE is the source file. TO-FILE is the destination. +CHANGELIST specifies which changelist the operation should be +added to. If PREVIEW is specified, don’t actually do the +operation. If SERVER-ONLY is specified it means to do the move +only on the server and not touch the local files." + (let* ((changelist-args (and changelist `("-c" ,changelist))) + (preview-args (and preview '("-n"))) + (server-only-args (and server-only '("-k"))) + (args (append '("move" "-r") + changelist-args + preview-args + server-only-args + (list from-file to-file)))) + (p4-lowlevel-command-or-error args))) + (provide 'p4-lowlevel) diff --git a/vc-p4.el b/vc-p4.el index 8ee0a59..632856c 100644 --- a/vc-p4.el +++ b/vc-p4.el @@ -1057,4 +1057,8 @@ The difference to vc-do-command is that this function always invokes `p4'." (propertize (alist-get "Server address" extra-info nil nil #'string=) 'face 'font-lock-variable-name-face)))) +(defun vc-p4-rename (old new) + "Rename OLD to NEW in Perforce." + (p4-lowlevel-rename old new)) + (provide 'vc-p4)