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.
This commit is contained in:
Xue Fuqiao 2013-07-30 08:25:31 +08:00
parent 8121f08950
commit 7aa7fff0c8
10 changed files with 99 additions and 19 deletions

View file

@ -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.

View file

@ -1,3 +1,23 @@
2013-07-30 Xue Fuqiao <xfq.free@gmail.com>
* 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 <lekktu@gmail.com>
* desktop.el (desktop-restoring-frames-p): Return a true boolean.

View file

@ -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))

View file

@ -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.

View file

@ -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)

View file

@ -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

View file

@ -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")))

View file

@ -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.

View file

@ -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))

View file

@ -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.