Some fixes for vc-ignore.
authorXue Fuqiao <xfq.free@gmail.com>
Wed, 4 Sep 2013 00:31:13 +0000 (08:31 +0800)
committerXue Fuqiao <xfq.free@gmail.com>
Wed, 4 Sep 2013 00:31:13 +0000 (08:31 +0800)
* lisp/vc/vc.el (vc-ignore): Rewrite.
(vc-default-ignore): New function.
(vc-default-ignore-completion-table): Use find-ignore-file.

* lisp/vc/vc-bzr.el (vc-bzr-ignore, vc-bzr-ignore-completion-table):
* lisp/vc/vc-git.el (vc-git-ignore, vc-git-ignore-completion-table):
* lisp/vc/vc-hg.el (vc-hg-ignore, vc-hg-ignore-completion-table):
Remove.  Most code moved to vc.el.

* doc/emacs/maintaining.texi (VC Ignore): Mention `vc-ignore' with prefix argument.

doc/emacs/ChangeLog
doc/emacs/maintaining.texi
etc/NEWS
lisp/ChangeLog
lisp/vc/vc-bzr.el
lisp/vc/vc-git.el
lisp/vc/vc-hg.el
lisp/vc/vc-svn.el
lisp/vc/vc.el

index ad411e4..73de1ce 100644 (file)
@@ -1,3 +1,7 @@
+2013-09-04  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * maintaining.texi (VC Ignore): Mention `vc-ignore' with prefix argument.
+
 2013-07-31  Eli Zaretskii  <eliz@gnu.org>
 
        * emacs.texi (Top): Remove menu item for the removed "Disabling
index 5533754..4a61db5 100644 (file)
@@ -1043,12 +1043,14 @@ Ignore a file under current version control system.  (@code{vc-ignore}).
 
 @kindex C-x v G
 @findex vc-ignore
-  Many source trees contain some files that do not need to be versioned,
-such as editor backups, object or bytecode files, and built programs.
-You can simply not add them, but then they’ll always crop up as
-unknown files.  You can also tell the version control system to ignore
-these files by adding them to the ignore file at the top of the tree.
-@kbd{C-x v G} (@code{vc-ignore}) can help you do this.
+  Many source trees contain some files that do not need to be
+versioned, such as editor backups, object or bytecode files, and built
+programs.  You can simply not add them, but then they’ll always crop
+up as unknown files.  You can also tell the version control system to
+ignore these files by adding them to the ignore file at the top of the
+tree.  @kbd{C-x v G} (@code{vc-ignore}) can help you do this.  When
+called with a prefix argument, you can remove a file from the ignored
+file list.
 
 @node VC Directory Mode
 @subsection VC Directory Mode
index 60a846b..fd16a43 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -241,8 +241,9 @@ whole tree revisions.
 *** In VC directory mode, `L' lists the change log for the current VC
 controlled tree in a window.
 
-*** `C-x v G' (globally) and `G' (in VC directory mode) ignores a
-file under current version control system.
+*** `C-x v G' (globally) and `G' (in VC directory mode) ignores a file
+under current version control system.  When called with a prefix
+argument, you can remove a file from the ignored file list.
 
 ** cl-lib
 
index 5dfca6b..9292732 100644 (file)
@@ -1,3 +1,14 @@
+2013-09-04  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * vc/vc.el (vc-ignore): Rewrite.
+       (vc-default-ignore): New function.
+       (vc-default-ignore-completion-table): Use find-ignore-file.
+
+       * vc/vc-bzr.el (vc-bzr-ignore, vc-bzr-ignore-completion-table):
+       * vc/vc-git.el (vc-git-ignore, vc-git-ignore-completion-table):
+       * vc/vc-hg.el (vc-hg-ignore, vc-hg-ignore-completion-table):
+       Remove.  Most code moved to vc.el.
+
 2013-08-04  Xue Fuqiao  <xfq.free@gmail.com>
 
        * vc/vc.el (vc-ignore): Rewrite.
index e59a7dc..0d95fbe 100644 (file)
@@ -651,21 +651,6 @@ 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 &optional directory remove)
-  "Ignore FILE under Bazaar.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
-  (if remove
-      (if directory
-         (vc--remove-regexp file (vc-bzr-find-ignore-file directory))
-       (vc--remove-regexp file
-                          (vc-bzr-find-ignore-file default-directory)))
-    (vc-bzr-command "ignore" t 0 file)))
-
-(defun vc-bzr-ignore-completion-table (file)
-  "Return the list of ignored files."
-  (vc--read-lines (vc-bzr-find-ignore-file file)))
-
 (defun vc-bzr-find-ignore-file (file)
   "Return the root directory of the repository of FILE."
   (expand-file-name ".bzrignore"
index 472c428..07b7d15 100644 (file)
@@ -680,22 +680,6 @@ 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 &optional directory remove)
-  "Ignore FILE under Git.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
-  (let (gitignore)
-    (if directory
-       (setq gitignore (vc-git-find-ignore-file directory))
-      (setq gitignore (vc-git-find-ignore-file default-directory)))
-    (if remove
-       (vc--remove-regexp file gitignore)
-      (vc--add-line file gitignore))))
-
-(defun vc-git-ignore-completion-table (file)
-  "Return the list of ignored files."
-  (vc--read-lines (vc-git-find-ignore-file file)))
-
 (defun vc-git-find-ignore-file (file)
   "Return the root directory of the repository of FILE."
   (expand-file-name ".gitignore"
index 68d98a6..211a0c1 100644 (file)
@@ -459,22 +459,6 @@ REV is ignored."
         (vc-hg-command buffer 0 file "cat" "-r" rev)
       (vc-hg-command buffer 0 file "cat"))))
 
-(defun vc-hg-ignore (file &optional directory remove)
-  "Ignore FILE under Mercurial.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
-  (let (hgignore)
-    (if directory
-       (setq hgignore (vc-hg-find-ignore-file directory))
-      (setq hgignore (vc-hg-find-ignore-file default-directory)))
-    (if remove
-       (vc--remove-regexp file hgignore)
-      (vc--add-line file hgignore))))
-
-(defun vc-hg-ignore-completion-table (file)
-  "Return the list of ignored files."
-  (vc--read-lines (vc-hg-find-ignore-file file)))
-
 (defun vc-hg-find-ignore-file (file)
   "Return the root directory of the repository of FILE."
   (expand-file-name ".hgignore"
index 0e02061..38c3bd9 100644 (file)
@@ -354,8 +354,7 @@ This is only possible if SVN is responsible for FILE's directory.")
 
 (defun vc-svn-ignore (file &optional directory remove)
   "Ignore FILE under Subversion.
-If DIRECTORY is non-nil, the repository to use will be deduced by
-DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
+FILE is a file wildcard, relative to the root directory of DIRECTORY."
   (vc-svn-command t 0 file "propedit" "svn:ignore"))
 
 (defun vc-svn-ignore-completion-table (file)
index 9757d4a..007bbe8 100644 (file)
 ;;   This function is used in `vc-stay-local-p' which backends can use
 ;;   for their convenience.
 ;;
-;; - ignore (file &optional remove)
-;;
-;;   Ignore FILE under the current VCS.  When called interactively and
-;;   with a prefix argument, remove an ignored file.  When called from
-;;   Lisp code, if REMOVE is non-nil, remove FILE from ignored files."
+;; - ignore (file &optional directory)
+;;
+;;   Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
+;;   FILE is a file wildcard.
+;;   When called interactively and with a prefix argument, remove FILE
+;;   from ignored files.
+;;   When called from Lisp code, if DIRECTORY is non-nil, the
+;;   repository to use will be deduced by DIRECTORY.
 ;; 
 ;; - ignore-completion-table
 ;; 
-;;   Return the completion table for files ignored by the current
-;;   version control system, e.g., the entries in `.gitignore' and
-;;   `.bzrignore'.
+;;   Return the completion table for files ignored by the version
+;;   control system in `default-directory'.
 ;; 
 ;; - previous-revision (file rev)
 ;;
@@ -1342,33 +1344,44 @@ first backend that could register the file is used."
   (let ((vc-handled-backends (list backend)))
     (call-interactively 'vc-register)))
 
-(defun vc-ignore (file &optional directory remove)
+(defun vc-ignore (file &optional directory)
   "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
+FILE is a file wildcard.
 When called interactively and with a prefix argument, remove FILE
 from ignored files.
 When called from Lisp code, if DIRECTORY is non-nil, the
-repository to use will be deduced by DIRECTORY; if REMOVE is
-non-nil, remove FILE from ignored files."
+repository to use will be deduced by DIRECTORY."
   (interactive
-   (if (null current-prefix-arg)
-       (list (read-file-name "The file to ignore: "))
-     (list
-      (completing-read
-       "The file to remove: "
-       (vc-call-backend
-       (vc-backend default-directory)
-       'ignore-completion-table default-directory)))))
-  (let (backend)
-    (if directory
-       (progn (setq backend (vc-backend default-directory))
-              (vc-call-backend backend 'ignore file directory remove))
-      (setq backend (vc-backend directory))
-      (vc-call-backend backend 'ignore file default-directory remove))))
-
-(defun vc-default-ignore-completion-table (file)
-  "Return the list of ignored files."
-  ;; Unused lexical argument `file'
-  nil)
+   (list (read-file-name "The file to ignore: ")
+        (completing-read
+         "The file to remove: "
+         (vc-call-backend
+          (vc-backend default-directory)
+          'ignore-completion-table default-directory))))
+  (let* ((directory (or directory default-directory))
+        (backend (vc-backend default-directory))
+        (remove current-prefix-arg))
+    (vc-call-backend backend 'ignore file directory remove)))
+
+(defun vc-default-ignore (backend file &optional directory remove)
+  "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
+FILE is a file wildcard, relative to the root directory of DIRECTORY.
+When called from Lisp code, if DIRECTORY is non-nil, the
+repository to use will be deduced by DIRECTORY; if REMOVE is
+non-nil, remove FILE from ignored files.
+Argument BACKEND is the backend you are using."
+  (let ((ignore
+        (vc-call-backend backend 'find-ignore-file (or directory default-directory)))
+       (pattern (file-relative-name
+                 (expand-file-name file) (file-name-directory file))))
+    (if remove
+       (vc--remove-regexp pattern ignore)
+      (vc--add-line pattern ignore))))
+
+(defun vc-default-ignore-completion-table (backend file)
+  "Return the list of ignored files under BACKEND."
+  (vc--read-lines
+   (vc-call-backend backend 'find-ignore-file file)))
 
 (defun vc--read-lines (file)
   "Return a list of lines of FILE."