From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?G=C3=B6ktu=C4=9F?= Kayaalp Newsgroups: gmane.emacs.bugs Subject: bug#24082: [PATCH] Use =?UTF-8?Q?=E2=80=98cvs_?= =?UTF-8?Q?update=E2=80=99?= instead =?UTF-8?Q?=E2=80=98cvs_?= =?UTF-8?Q?status=E2=80=99?= for CVS *vc-dir* buffers Date: Sun, 28 Aug 2016 23:17:57 +0300 Message-ID: <874m64wsui.fsf@xi.bootis> References: <874m7crwv4.fsf@xi.bootis> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1472414930 24099 195.159.176.226 (28 Aug 2016 20:08:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 Aug 2016 20:08:50 +0000 (UTC) To: 24082@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 28 22:08:45 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1be6Np-0005m6-HS for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Aug 2016 22:08:45 +0200 Original-Received: from localhost ([::1]:40779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1be6Nn-00082R-3Q for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Aug 2016 16:08:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1be6ND-0007Rx-4G for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 16:08:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1be6N8-00013y-OK for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 16:08:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1be6N8-00013n-Kc for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 16:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1be6N8-0004U0-Go for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 16:08:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <874m7crwv4.fsf@xi.bootis> Resent-From: =?UTF-8?Q?G=C3=B6ktu=C4=9F?= Kayaalp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Aug 2016 20:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24082 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 24082-submit@debbugs.gnu.org id=B24082.147241484017150 (code B ref 24082); Sun, 28 Aug 2016 20:08:02 +0000 Original-Received: (at 24082) by debbugs.gnu.org; 28 Aug 2016 20:07:20 +0000 Original-Received: from localhost ([127.0.0.1]:43073 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1be6MS-0004SY-FD for submit@debbugs.gnu.org; Sun, 28 Aug 2016 16:07:20 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:36470) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1be6MQ-0004SP-6E for 24082@debbugs.gnu.org; Sun, 28 Aug 2016 16:07:18 -0400 Original-Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 47262FB89F for <24082@debbugs.gnu.org>; Sun, 28 Aug 2016 22:07:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter15-d.gandi.net Original-Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 5pFCXWEiQuLx for <24082@debbugs.gnu.org>; Sun, 28 Aug 2016 22:07:14 +0200 (CEST) X-Originating-IP: 78.181.205.50 Original-Received: from localhost (unknown [78.181.205.50]) (Authenticated sender: self@gkayaalp.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 91E1EFB8A3 for <24082@debbugs.gnu.org>; Sun, 28 Aug 2016 22:07:13 +0200 (CEST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122749 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, attached is a patch that fixes bug#24082. The reason of the bug was that, in function =E2=80=98vc-cvs-after-dir-statu= s=E2=80=99, the CVS status line =E2=80=98cvs status: Examining =E2=80=99 was exclu= ded when the function narrows to match, and when it tries to set the local variable =E2=80=98subdir=E2=80=99, as it does not find this line, it skips setting i= t. As =E2=80=98subdir=E2=80=99 defaults to =E2=80=98default-directory=E2=80=99, w= hich is previously set to repo root (i.e. the argument to function =E2=80=98vc-dir=E2=80=99, when =E2= =80=98subdir=E2=80=99 is used to construct the relative path to file, concatenating it with the already-known file base name, it returns the basename, i.e. in the form =E2=80=98name.ext=E2=80=99, with no directory path. This because = it constructs the relative path like =E2=80=98(file-relative-name basename subdir)=E2=80= =99. The patch uses =E2=80=98cvs update=E2=80=99 command instead. The implement= ation was already there, commented out. I enabled and corrected it. The result is more correct than the =E2=80=98cvs status=E2=80=99 approach, i.e. includ= es unregistered and missing, and is faster compared to =E2=80=98cvs status=E2= =80=99 way. PS.: Please have me in CC when updating, I'm not subscribed to bug-gnu-emacs. --=20 =C4=B0. G=C3=B6ktu=C4=9F Kayaalp. http://gkayaalp.com/ --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=bug-24082.patch Content-Description: patch for #24082 diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 5019871..fa385ae 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -944,103 +944,32 @@ state." (t 'edited)))))))) (defun vc-cvs-after-dir-status (update-function) - ;; Heavily inspired by vc-cvs-parse-status. AKA a quick hack. - ;; This needs a lot of testing. - (let ((status nil) - (status-str nil) - (file nil) - (result nil) - (missing nil) - (ignore-next nil) - (subdir default-directory)) + (let ((result nil) + (translation '((?? . unregistered) + (?A . added) + (?C . conflict) + (?M . edited) + (?P . needs-merge) + (?R . removed) + (?U . needs-update)))) (goto-char (point-min)) - (while - ;; Look for either a file entry, an unregistered file, or a - ;; directory change. - (re-search-forward - "\\(^=+\n\\([^=c?\n].*\n\\|\n\\)+\\)\\|\\(\\(^?? .*\n\\)+\\)\\|\\(^cvs status: \\(Examining\\|nothing\\) .*\n\\)" - nil t) - ;; FIXME: get rid of narrowing here. - (narrow-to-region (match-beginning 0) (match-end 0)) - (goto-char (point-min)) - ;; The subdir - (when (looking-at "cvs status: Examining \\(.+\\)") - (setq subdir (expand-file-name (match-string 1)))) - ;; Unregistered files - (while (looking-at "? \\(.*\\)") - (setq file (file-relative-name - (expand-file-name (match-string 1) subdir))) - (push (list file 'unregistered) result) - (forward-line 1)) - (when (looking-at "cvs status: nothing known about") - ;; We asked about a non existent file. The output looks like this: - - ;; cvs status: nothing known about `lisp/v.diff' - ;; =================================================================== - ;; File: no file v.diff Status: Unknown - ;; - ;; Working revision: No entry for v.diff - ;; Repository revision: No revision control file - ;; - - ;; Due to narrowing in this iteration we only see the "cvs - ;; status:" line, so just set a flag so that we can ignore the - ;; file in the next iteration. - (setq ignore-next t)) - ;; A file entry. - (when (re-search-forward "^File: \\(no file \\)?\\(.*[^ \t]\\)[ \t]+Status: \\(.*\\)" nil t) - (setq missing (match-string 1)) - (setq file (file-relative-name - (expand-file-name (match-string 2) subdir))) - (setq status-str (match-string 3)) - (setq status - (cond - ((string-match "Up-to-date" status-str) 'up-to-date) - ((string-match "Locally Modified" status-str) 'edited) - ((string-match "Needs Merge" status-str) 'needs-merge) - ((string-match "Needs \\(Checkout\\|Patch\\)" status-str) - (if missing 'missing 'needs-update)) - ((string-match "Locally Added" status-str) 'added) - ((string-match "Locally Removed" status-str) 'removed) - ((string-match "File had conflicts " status-str) 'conflict) - ((string-match "Unknown" status-str) 'unregistered) - (t 'edited))) - (if ignore-next - (setq ignore-next nil) - (unless (eq status 'up-to-date) - (push (list file status) result)))) - (goto-char (point-max)) - (widen)) - (funcall update-function result)) - ;; Alternative implementation: use the "update" command instead of - ;; the "status" command. - ;; (let ((result nil) - ;; (translation '((?? . unregistered) - ;; (?A . added) - ;; (?C . conflict) - ;; (?M . edited) - ;; (?P . needs-merge) - ;; (?R . removed) - ;; (?U . needs-update)))) - ;; (goto-char (point-min)) - ;; (while (not (eobp)) - ;; (if (looking-at "^[ACMPRU?] \\(.*\\)$") - ;; (push (list (match-string 1) - ;; (cdr (assoc (char-after) translation))) - ;; result) - ;; (cond - ;; ((looking-at "cvs update: warning: \\(.*\\) was lost") - ;; ;; Format is: - ;; ;; cvs update: warning: FILENAME was lost - ;; ;; U FILENAME - ;; (push (list (match-string 1) 'missing) result) - ;; ;; Skip the "U" line - ;; (forward-line 1)) - ;; ((looking-at "cvs update: New directory `\\(.*\\)' -- ignored") - ;; (push (list (match-string 1) 'unregistered) result)))) - ;; (forward-line 1)) - ;; (funcall update-function result))) - ) + (while (not (eobp)) + (if (looking-at "^[ACMPRU?] \\(.*\\)$") + (push (list (match-string 1) + (cdr (assoc (char-after) translation))) + result) + (cond + ((looking-at "cvs update: warning: \\(.*\\) was lost") + ;; Format is: + ;; cvs update: warning: FILENAME was lost + ;; U FILENAME + (push (list (match-string 1) 'missing) result) + ;; Skip the "U" line + (forward-line 1)) + ((looking-at "cvs update: New directory `\\(.*\\)' -- ignored") + (push (list (match-string 1) 'unregistered) result)))) + (forward-line 1)) + (funcall update-function result))) ;; Based on vc-cvs-dir-state-heuristic from Emacs 22. ;; FIXME does not mention unregistered files. @@ -1078,15 +1007,12 @@ Query all files in DIR if files is nil." (let ((local (vc-cvs-stay-local-p dir))) (if (and (not files) local (not (eq local 'only-file))) (vc-cvs-dir-status-heuristic dir update-function) - (if (not files) (setq files (vc-expand-dirs (list dir) 'CVS))) - (vc-cvs-command (current-buffer) 'async files "-f" "status") - ;; Alternative implementation: use the "update" command instead of - ;; the "status" command. - ;; (vc-cvs-command (current-buffer) 'async - ;; (file-relative-name dir) - ;; "-f" "-n" "update" "-d" "-P") - (vc-run-delayed - (vc-cvs-after-dir-status update-function))))) + (if (not files) (setq files (vc-expand-dirs (list dir) 'CVS)))) + (vc-cvs-command (current-buffer) 'async + (file-relative-name dir) + "-f" "-n" "-q" "update") + (vc-run-delayed + (vc-cvs-after-dir-status update-function)))) (defun vc-cvs-file-to-string (file) "Read the content of FILE and return it as a string." --=-=-=--