From 7aa7fff0c8860b72a2c7cdc7d4d0845245754d43 Mon Sep 17 00:00:00 2001 From: Xue Fuqiao Date: Tue, 30 Jul 2013 08:25:31 +0800 Subject: [PATCH] Add vc-ignore. * lisp/vc/vc.el (vc-ignore): New function. * lisp/vc/vc-svn.el (vc-svn-ignore): New function. * lisp/vc/vc-hg.el (vc-hg-ignore): New function. * lisp/vc/vc-git.el (vc-git-ignore): New function. * lisp/vc/vc-dir.el (vc-dir-mode-map): Add key binding for vc-dir-ignore (vc-dir-ignore): New function. * lisp/vc/vc-cvs.el (vc-cvs-ignore): New function. (cvs-append-to-ignore): Moved from pcvs.el. * lisp/vc/vc-bzr.el (vc-bzr-ignore): New function. * lisp/vc/pcvs.el (vc-cvs): Require 'vc-cvs. --- etc/NEWS | 6 ++++++ lisp/ChangeLog | 20 ++++++++++++++++++++ lisp/vc/pcvs.el | 20 +------------------- lisp/vc/vc-bzr.el | 6 ++++++ lisp/vc/vc-cvs.el | 22 ++++++++++++++++++++++ lisp/vc/vc-dir.el | 6 ++++++ lisp/vc/vc-git.el | 14 ++++++++++++++ lisp/vc/vc-hg.el | 12 ++++++++++++ lisp/vc/vc-svn.el | 6 ++++++ lisp/vc/vc.el | 6 ++++++ 10 files changed, 99 insertions(+), 19 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index feb45f43348..c472a2be8f3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -229,6 +229,12 @@ The default separator is changed to allow surrounding spaces around the comma. *** New variable `diary-from-outlook-function', used by the command `diary-from-outlook'. +** VC Directory Mode + +*** `D' displays diffs between VC-controlled whole tree revisions. +*** `L' lists the change log for the current VC controlled tree in a window. +*** `I' ignores the file under current version control system. + ** cl-lib *** New macro cl-tagbody. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 587c9b921c9..29cd88a9186 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,23 @@ +2013-07-30 Xue Fuqiao + + * vc/vc.el (vc-ignore): New function. + + * vc/vc-svn.el (vc-svn-ignore): New function. + + * vc/vc-hg.el (vc-hg-ignore): New function. + + * vc/vc-git.el (vc-git-ignore): New function. + + * vc/vc-dir.el (vc-dir-mode-map): Add key binding for vc-dir-ignore + (vc-dir-ignore): New function. + + * vc/vc-cvs.el (vc-cvs-ignore): New function. + (cvs-append-to-ignore): Moved from pcvs.el. + + * vc/vc-bzr.el (vc-bzr-ignore): New function. + + * vc/pcvs.el (vc-cvs): Require 'vc-cvs. + 2013-07-24 Juanma Barranquero * desktop.el (desktop-restoring-frames-p): Return a true boolean. diff --git a/lisp/vc/pcvs.el b/lisp/vc/pcvs.el index 208b93d9670..fb91185662a 100644 --- a/lisp/vc/pcvs.el +++ b/lisp/vc/pcvs.el @@ -122,6 +122,7 @@ (require 'pcvs-util) (require 'pcvs-parse) (require 'pcvs-info) +(require 'vc-cvs) ;;;; @@ -1970,25 +1971,6 @@ This command ignores files that are not flagged as `Unknown'." (declare-function vc-editable-p "vc" (file)) (declare-function vc-checkout "vc" (file &optional writable rev)) -(defun cvs-append-to-ignore (dir str &optional old-dir) - "Add STR to the .cvsignore file in DIR. -If OLD-DIR is non-nil, then this is a directory that we don't want -to hear about anymore." - (with-current-buffer - (find-file-noselect (expand-file-name ".cvsignore" dir)) - (when (ignore-errors - (and buffer-read-only - (eq 'CVS (vc-backend buffer-file-name)) - (not (vc-editable-p buffer-file-name)))) - ;; CVSREAD=on special case - (vc-checkout buffer-file-name t)) - (goto-char (point-max)) - (unless (bolp) (insert "\n")) - (insert str (if old-dir "/\n" "\n")) - (if cvs-sort-ignore-file (sort-lines nil (point-min) (point-max))) - (save-buffer))) - - (defun cvs-mode-find-file-other-window (e) "Select a buffer containing the file in another window." (interactive (list last-input-event)) diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 5e76d8464a5..5f026a2ecd9 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -651,6 +651,12 @@ REV non-nil gets an error." (vc-bzr-command "cat" t 0 file "-r" rev) (vc-bzr-command "cat" t 0 file)))) +(defun vc-bzr-ignore (file) + "Ignore FILE under Bazaar." + (interactive) + (vc-bzr-command "ignore" (get-buffer-create "*vc-ignore*") 0 + file)) + (defun vc-bzr-checkout (_file &optional _editable rev) (if rev (error "Operation not supported") ;; Else, there's nothing to do. diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 17b278d1ce4..3472673f46d 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -1226,6 +1226,28 @@ is non-nil." table (lambda () (vc-cvs-revision-table (car files)))))) table)) +(defun vc-cvs-ignore (file) + "Ignore FILE under CVS." + (interactive) + (cvs-append-to-ignore (file-name-directory file) file)) + +(defun cvs-append-to-ignore (dir str &optional old-dir) + "In DIR, add STR to the .cvsignore file. +If OLD-DIR is non-nil, then this is a directory that we don't want +to hear about anymore." + (with-current-buffer + (find-file-noselect (expand-file-name ".cvsignore" dir)) + (when (ignore-errors + (and buffer-read-only + (eq 'CVS (vc-backend buffer-file-name)) + (not (vc-editable-p buffer-file-name)))) + ;; CVSREAD=on special case + (vc-checkout buffer-file-name t)) + (goto-char (point-max)) + (unless (bolp) (insert "\n")) + (insert str (if old-dir "/\n" "\n")) + (if cvs-sort-ignore-file (sort-lines nil (point-min) (point-max))) + (save-buffer))) (provide 'vc-cvs) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 80f78496a43..4920e85c351 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -277,6 +277,7 @@ See `run-hooks'." (define-key map "Q" 'vc-dir-query-replace-regexp) (define-key map (kbd "M-s a C-s") 'vc-dir-isearch) (define-key map (kbd "M-s a M-C-s") 'vc-dir-isearch-regexp) + (define-key map "I" 'vc-dir-ignore) ;; Hook up the menu. (define-key map [menu-bar vc-dir-mode] @@ -789,6 +790,11 @@ with the command \\[tags-loop-continue]." (tags-query-replace from to delimited '(mapcar 'car (vc-dir-marked-only-files-and-states)))) +(defun vc-dir-ignore () + "Ignore the current file." + (interactive) + (vc-ignore (vc-dir-current-file))) + (defun vc-dir-current-file () (let ((node (ewoc-locate vc-ewoc))) (unless node diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index af5be361047..2183fef4e7d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -103,6 +103,8 @@ ;; - rename-file (old new) OK ;; - find-file-hook () NOT NEEDED +;;; Code: + (eval-when-compile (require 'cl-lib) (require 'vc) @@ -678,6 +680,18 @@ It is based on `log-edit-mode', and has Git-specific extensions.") nil "cat-file" "blob" (concat (if rev rev "HEAD") ":" fullname)))) +(defun vc-git-ignore (file) + "Ignore FILE under Git." + (interactive) + (with-temp-buffer + (insert-file-contents + (let (gitignore (concat (file-name-as-directory (vc-git-root + default-directory)) ".gitignore")) + (unless (search-forward file nil t) + (goto-char (point-max)) + (insert (concat "\n" file "\n")) + (write-region 1 (point-max) gitignore)))))) + (defun vc-git-checkout (file &optional _editable rev) (vc-git-command nil 0 file "checkout" (or rev "HEAD"))) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index a80a103c675..dd9ff003493 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -459,6 +459,18 @@ REV is ignored." (vc-hg-command buffer 0 file "cat" "-r" rev) (vc-hg-command buffer 0 file "cat")))) +(defun vc-hg-ignore (file) + "Ignore FILE under Mercurial." + (interactive) + (with-temp-buffer + (insert-file-contents + (let (hgignore (concat (file-name-as-directory (vc-hg-root + default-directory)) ".hgignore")) + (unless (search-forward file nil t) + (goto-char (point-max)) + (insert (concat "\n" file "\n")) + (write-region 1 (point-max) hgignore)))))) + ;; Modeled after the similar function in vc-bzr.el (defun vc-hg-checkout (file &optional _editable rev) "Retrieve a revision of FILE. diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el index 39b107b81b5..7851aac435e 100644 --- a/lisp/vc/vc-svn.el +++ b/lisp/vc/vc-svn.el @@ -352,6 +352,12 @@ This is only possible if SVN is responsible for FILE's directory.") (concat "-r" rev)) (vc-switches 'SVN 'checkout)))) +(defun vc-svn-ignore (file) + "Ignore FILE under Subversion." + (interactive) + (vc-svn-command (get-buffer-create "*vc-ignore*") 0 + file "propedit" "svn:ignore")) + (defun vc-svn-checkout (file &optional editable rev) (message "Checking out %s..." file) (with-current-buffer (or (get-file-buffer file) (current-buffer)) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 0308dd1ebd4..210e647ba65 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1332,6 +1332,12 @@ first backend that could register the file is used." (let ((vc-handled-backends (list backend))) (call-interactively 'vc-register))) +(defun vc-ignore (file) + "Ignore FILE under the current VCS." + (interactive "fIgnore file: ") + (let ((backend (vc-backend file))) + (vc-call-backend backend 'ignore file))) + (defun vc-checkout (file &optional writable rev) "Retrieve a copy of the revision REV of FILE. If WRITABLE is non-nil, make sure the retrieved file is writable. -- 2.39.2