aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorXue Fuqiao2013-09-04 08:31:13 +0800
committerXue Fuqiao2013-09-04 08:31:13 +0800
commit63191d9f2043d2e67657e85a7b3842805dd1dad6 (patch)
treecb390bbda4b775652b1fd58b09d2df8e0013fc4f /lisp
parent99191b89ff64172740add88e67f163619a07830c (diff)
downloademacs-63191d9f2043d2e67657e85a7b3842805dd1dad6.tar.gz
emacs-63191d9f2043d2e67657e85a7b3842805dd1dad6.zip
Some fixes for vc-ignore.
* 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/vc/vc-bzr.el15
-rw-r--r--lisp/vc/vc-git.el16
-rw-r--r--lisp/vc/vc-hg.el16
-rw-r--r--lisp/vc/vc-svn.el3
-rw-r--r--lisp/vc/vc.el73
6 files changed, 55 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5dfca6b8e2f..9292732dc4c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12013-09-04 Xue Fuqiao <xfq.free@gmail.com>
2
3 * vc/vc.el (vc-ignore): Rewrite.
4 (vc-default-ignore): New function.
5 (vc-default-ignore-completion-table): Use find-ignore-file.
6
7 * vc/vc-bzr.el (vc-bzr-ignore, vc-bzr-ignore-completion-table):
8 * vc/vc-git.el (vc-git-ignore, vc-git-ignore-completion-table):
9 * vc/vc-hg.el (vc-hg-ignore, vc-hg-ignore-completion-table):
10 Remove. Most code moved to vc.el.
11
12013-08-04 Xue Fuqiao <xfq.free@gmail.com> 122013-08-04 Xue Fuqiao <xfq.free@gmail.com>
2 13
3 * vc/vc.el (vc-ignore): Rewrite. 14 * vc/vc.el (vc-ignore): Rewrite.
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index e59a7dc5214..0d95fbed8c2 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -651,21 +651,6 @@ REV non-nil gets an error."
651 (vc-bzr-command "cat" t 0 file "-r" rev) 651 (vc-bzr-command "cat" t 0 file "-r" rev)
652 (vc-bzr-command "cat" t 0 file)))) 652 (vc-bzr-command "cat" t 0 file))))
653 653
654(defun vc-bzr-ignore (file &optional directory remove)
655 "Ignore FILE under Bazaar.
656If DIRECTORY is non-nil, the repository to use will be deduced by
657DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
658 (if remove
659 (if directory
660 (vc--remove-regexp file (vc-bzr-find-ignore-file directory))
661 (vc--remove-regexp file
662 (vc-bzr-find-ignore-file default-directory)))
663 (vc-bzr-command "ignore" t 0 file)))
664
665(defun vc-bzr-ignore-completion-table (file)
666 "Return the list of ignored files."
667 (vc--read-lines (vc-bzr-find-ignore-file file)))
668
669(defun vc-bzr-find-ignore-file (file) 654(defun vc-bzr-find-ignore-file (file)
670 "Return the root directory of the repository of FILE." 655 "Return the root directory of the repository of FILE."
671 (expand-file-name ".bzrignore" 656 (expand-file-name ".bzrignore"
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 472c42840af..07b7d15299f 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -680,22 +680,6 @@ It is based on `log-edit-mode', and has Git-specific extensions.")
680 nil 680 nil
681 "cat-file" "blob" (concat (if rev rev "HEAD") ":" fullname)))) 681 "cat-file" "blob" (concat (if rev rev "HEAD") ":" fullname))))
682 682
683(defun vc-git-ignore (file &optional directory remove)
684 "Ignore FILE under Git.
685If DIRECTORY is non-nil, the repository to use will be deduced by
686DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
687 (let (gitignore)
688 (if directory
689 (setq gitignore (vc-git-find-ignore-file directory))
690 (setq gitignore (vc-git-find-ignore-file default-directory)))
691 (if remove
692 (vc--remove-regexp file gitignore)
693 (vc--add-line file gitignore))))
694
695(defun vc-git-ignore-completion-table (file)
696 "Return the list of ignored files."
697 (vc--read-lines (vc-git-find-ignore-file file)))
698
699(defun vc-git-find-ignore-file (file) 683(defun vc-git-find-ignore-file (file)
700 "Return the root directory of the repository of FILE." 684 "Return the root directory of the repository of FILE."
701 (expand-file-name ".gitignore" 685 (expand-file-name ".gitignore"
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 68d98a60f98..211a0c131c9 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -459,22 +459,6 @@ REV is ignored."
459 (vc-hg-command buffer 0 file "cat" "-r" rev) 459 (vc-hg-command buffer 0 file "cat" "-r" rev)
460 (vc-hg-command buffer 0 file "cat")))) 460 (vc-hg-command buffer 0 file "cat"))))
461 461
462(defun vc-hg-ignore (file &optional directory remove)
463 "Ignore FILE under Mercurial.
464If DIRECTORY is non-nil, the repository to use will be deduced by
465DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
466 (let (hgignore)
467 (if directory
468 (setq hgignore (vc-hg-find-ignore-file directory))
469 (setq hgignore (vc-hg-find-ignore-file default-directory)))
470 (if remove
471 (vc--remove-regexp file hgignore)
472 (vc--add-line file hgignore))))
473
474(defun vc-hg-ignore-completion-table (file)
475 "Return the list of ignored files."
476 (vc--read-lines (vc-hg-find-ignore-file file)))
477
478(defun vc-hg-find-ignore-file (file) 462(defun vc-hg-find-ignore-file (file)
479 "Return the root directory of the repository of FILE." 463 "Return the root directory of the repository of FILE."
480 (expand-file-name ".hgignore" 464 (expand-file-name ".hgignore"
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index 0e020614fd2..38c3bd9970d 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -354,8 +354,7 @@ This is only possible if SVN is responsible for FILE's directory.")
354 354
355(defun vc-svn-ignore (file &optional directory remove) 355(defun vc-svn-ignore (file &optional directory remove)
356 "Ignore FILE under Subversion. 356 "Ignore FILE under Subversion.
357If DIRECTORY is non-nil, the repository to use will be deduced by 357FILE is a file wildcard, relative to the root directory of DIRECTORY."
358DIRECTORY; if REMOVE is non-nil, remove FILE from ignored files."
359 (vc-svn-command t 0 file "propedit" "svn:ignore")) 358 (vc-svn-command t 0 file "propedit" "svn:ignore"))
360 359
361(defun vc-svn-ignore-completion-table (file) 360(defun vc-svn-ignore-completion-table (file)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 9757d4a43be..007bbe86f34 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -497,17 +497,19 @@
497;; This function is used in `vc-stay-local-p' which backends can use 497;; This function is used in `vc-stay-local-p' which backends can use
498;; for their convenience. 498;; for their convenience.
499;; 499;;
500;; - ignore (file &optional remove) 500;; - ignore (file &optional directory)
501;; 501;;
502;; Ignore FILE under the current VCS. When called interactively and 502;; Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
503;; with a prefix argument, remove an ignored file. When called from 503;; FILE is a file wildcard.
504;; Lisp code, if REMOVE is non-nil, remove FILE from ignored files." 504;; When called interactively and with a prefix argument, remove FILE
505;; from ignored files.
506;; When called from Lisp code, if DIRECTORY is non-nil, the
507;; repository to use will be deduced by DIRECTORY.
505;; 508;;
506;; - ignore-completion-table 509;; - ignore-completion-table
507;; 510;;
508;; Return the completion table for files ignored by the current 511;; Return the completion table for files ignored by the version
509;; version control system, e.g., the entries in `.gitignore' and 512;; control system in `default-directory'.
510;; `.bzrignore'.
511;; 513;;
512;; - previous-revision (file rev) 514;; - previous-revision (file rev)
513;; 515;;
@@ -1342,33 +1344,44 @@ first backend that could register the file is used."
1342 (let ((vc-handled-backends (list backend))) 1344 (let ((vc-handled-backends (list backend)))
1343 (call-interactively 'vc-register))) 1345 (call-interactively 'vc-register)))
1344 1346
1345(defun vc-ignore (file &optional directory remove) 1347(defun vc-ignore (file &optional directory)
1346 "Ignore FILE under the VCS of DIRECTORY (default is `default-directory'). 1348 "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
1349FILE is a file wildcard.
1347When called interactively and with a prefix argument, remove FILE 1350When called interactively and with a prefix argument, remove FILE
1348from ignored files. 1351from ignored files.
1349When called from Lisp code, if DIRECTORY is non-nil, the 1352When called from Lisp code, if DIRECTORY is non-nil, the
1350repository to use will be deduced by DIRECTORY; if REMOVE is 1353repository to use will be deduced by DIRECTORY."
1351non-nil, remove FILE from ignored files."
1352 (interactive 1354 (interactive
1353 (if (null current-prefix-arg) 1355 (list (read-file-name "The file to ignore: ")
1354 (list (read-file-name "The file to ignore: ")) 1356 (completing-read
1355 (list 1357 "The file to remove: "
1356 (completing-read 1358 (vc-call-backend
1357 "The file to remove: " 1359 (vc-backend default-directory)
1358 (vc-call-backend 1360 'ignore-completion-table default-directory))))
1359 (vc-backend default-directory) 1361 (let* ((directory (or directory default-directory))
1360 'ignore-completion-table default-directory))))) 1362 (backend (vc-backend default-directory))
1361 (let (backend) 1363 (remove current-prefix-arg))
1362 (if directory 1364 (vc-call-backend backend 'ignore file directory remove)))
1363 (progn (setq backend (vc-backend default-directory)) 1365
1364 (vc-call-backend backend 'ignore file directory remove)) 1366(defun vc-default-ignore (backend file &optional directory remove)
1365 (setq backend (vc-backend directory)) 1367 "Ignore FILE under the VCS of DIRECTORY (default is `default-directory').
1366 (vc-call-backend backend 'ignore file default-directory remove)))) 1368FILE is a file wildcard, relative to the root directory of DIRECTORY.
1367 1369When called from Lisp code, if DIRECTORY is non-nil, the
1368(defun vc-default-ignore-completion-table (file) 1370repository to use will be deduced by DIRECTORY; if REMOVE is
1369 "Return the list of ignored files." 1371non-nil, remove FILE from ignored files.
1370 ;; Unused lexical argument `file' 1372Argument BACKEND is the backend you are using."
1371 nil) 1373 (let ((ignore
1374 (vc-call-backend backend 'find-ignore-file (or directory default-directory)))
1375 (pattern (file-relative-name
1376 (expand-file-name file) (file-name-directory file))))
1377 (if remove
1378 (vc--remove-regexp pattern ignore)
1379 (vc--add-line pattern ignore))))
1380
1381(defun vc-default-ignore-completion-table (backend file)
1382 "Return the list of ignored files under BACKEND."
1383 (vc--read-lines
1384 (vc-call-backend backend 'find-ignore-file file)))
1372 1385
1373(defun vc--read-lines (file) 1386(defun vc--read-lines (file)
1374 "Return a list of lines of FILE." 1387 "Return a list of lines of FILE."