From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Wolfgang Scherer Newsgroups: gmane.emacs.bugs Subject: bug#37189: 25.4.1: vc-hg-ignore implementation is missing Date: Sun, 5 Jan 2020 18:25:23 +0100 Message-ID: <16b9be3c-3643-c967-ab82-2ebbfa7bde8e@gmx.de> References: <1ba53ae2-42a4-3ab3-d4f2-2ceae565d198@gmx.de> <52917e6f-2f00-25cf-4353-dfb40287d0ea@gmx.de> <83pnkrdpb3.fsf@gnu.org> <679942e8-abe9-b0fc-720d-75a54d8d0b5a@gmx.de> <95da41e8-7a55-a15c-cfa7-d70366f9ee6b@gmx.de> <412195c1-e196-12af-933b-0312f5075847@yandex.ru> <57825d73-27a4-d5f5-8198-a172796a558a@gmx.de> <878smmwa7z.fsf@hase.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1907E8813182B953A5CB58ED" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="20004"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 Cc: 37189@debbugs.gnu.org, Dmitry Gutov To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 05 18:26:38 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1io9fi-00051q-13 for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Jan 2020 18:26:38 +0100 Original-Received: from localhost ([::1]:43928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io9fg-0002ut-NV for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Jan 2020 12:26:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35729) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io9f9-0002tX-In for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2020 12:26:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io9f8-0001Bb-Aj for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2020 12:26:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1io9f8-0001BX-6l for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2020 12:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1io9f8-0002xa-3B for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2020 12:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Jan 2020 17:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37189 X-GNU-PR-Package: emacs Original-Received: via spool by 37189-submit@debbugs.gnu.org id=B37189.157824513411342 (code B ref 37189); Sun, 05 Jan 2020 17:26:02 +0000 Original-Received: (at 37189) by debbugs.gnu.org; 5 Jan 2020 17:25:34 +0000 Original-Received: from localhost ([127.0.0.1]:44561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1io9ef-0002wr-Pq for submit@debbugs.gnu.org; Sun, 05 Jan 2020 12:25:34 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:38913) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1io9ee-0002wf-7U for 37189@debbugs.gnu.org; Sun, 05 Jan 2020 12:25:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1578245124; bh=vhNQI3HkLEkd40GBi+cfVZpd96itl5QEEIrWmO+/r5o=; h=X-UI-Sender-Class:From:Subject:To:Cc:References:Date:In-Reply-To; b=f069sFJjyNcQbRvWvKzyj/dNafEgqEmFEjcRxGQflTbgzx5BTG3880J/Z6xslF5Ye 2UUjB4in45b15fWqbjBl2KCrr/lZ3TFdjYJRvRy5qtRIfM1Y0w/IyoaLT7FWrxi2S9 HIdiXqkLr42oRqXcu+OduKDIgU+ca0KbxQUO3QBk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.160.210.52]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MhU9j-1jInmJ1F5f-00eZRr; Sun, 05 Jan 2020 18:25:24 +0100 Original-Received: from [192.168.33.54] (p57A0D234.dip0.t-ipconnect.de [87.160.210.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sheckley.simul.de (Postfix) with ESMTPSA id 881C51940BA1; Sun, 5 Jan 2020 18:25:23 +0100 (CET) Autocrypt: addr=wolfgang.scherer@gmx.de; keydata= mQGiBEb46IgRBACMHOAb1KNo1Ylk+ebri+4R+bG4tyKlqBlrpv8D9/ZwRdXSGt+0DyCHoaAd 7KW7noHapLe87DunABOjKG4nqTGv+dRiWuUBlp3I4aYRFDVa3Da+XnIYkMHKqhK59VEHQCdp Km42nuLS7TS+n99at9YwzTG6VBdOlBKTlRFngOjVLwCg1RGXJ6X3EjS1FKCQeXziURVpWlkD /2zY6Ayhxi62TS84VjikXrrmjXykAAaAmMVEyKKYb9L5pGlqiZz9g/K9xw1EUoZTYuaufquD v4rAGR58K/3V4CYfJLEeshMWiaXHvMmlxMznlG16/um4MvmR8B3r+cx0nOPK1JBdD2qrkNnF Mw8FB+zouLFB4Gt2IUC5IlOmZ8OQA/4qdU53CItzWsCr9Nux4L0qUlRweSmCnV8xGQ2wP5XI MawIQxxREvSrsYDG8cNnYETMg4iQFfIktwAoxCJvuFAwIB6ZxHGF4FcEZm64CXc2u7CmFLqt rVhXhIfMz9oEYC+HhGczGamn9ofbGTFd2hJEtPcQgWNR4f7+aKknmi2+OLQqV29sZmdhbmcg U2NoZXJlciA8V29sZmdhbmcuU2NoZXJlckBnbXguZGU+iGAEExECACAFAkb46IgCGyMGCwkI BwMCBBUCCAMEFgIDAQIeAQIXgAAKCRCFAq9xq9ddlenRAKDSHzk7esbwdo8uGVP8nZtdGA7/ yQCeLoBx4xTFASiFdNE7LQoSFAARRnC5AQ0ERvjoiBAEAIYtMI3MbwOLcnIYNjULsASH/S1/ +Opfu+PkG3sAp2uGvpsP/bOSmKixrWDLrt/ In-Reply-To: <878smmwa7z.fsf@hase.home> Content-Language: en-US X-Provags-ID: V03:K1:meS+gC6piOT7+hQBqzQAS1PSrc1/0xgxyrfLFHJ9bMht3CyYuut BklGI4siWkznd0vA7tUJdPisWlyXClVbUNTJ39+W78nHmlkp6mTh5cuiGa6tXj06LFD7vWX JpXNFirD4hWix6zIuDsrpgOesVd76l/h6XLwbpkPI+fwxm9u/8YWNaaKCZHdeAFD4ZjmA8O 6IwgI0idWD49Y7M2lR7pA== X-UI-Out-Filterresults: notjunk:1;V03:K0:dvZdDIPIwm8=:/QB1X7Ovr4gvim97RvcGJk K6lSyjkHcGpASE/c2uIBoII/dSSElYaiI3P6SVEDuu0O1PUzuI0NIrYZQXMoWty7N4R8JDab0 yUKwpBcQGa/T5XRnULbwFnOCanRlsh9E3Lpj9e2H3GG2jMHp+xsVnr5Ez/lIBSDu2Ym9ePOPC 6oCNAEbMXnEuBhyQhX3ZcKXX2mrDOM8mA1APidxvRjsrOf/L93sGS/RJS0K/NDbAjZHjzTTN5 I+lr8MziBEoscK2hkt4liL9rqajkjZpPpDeYL7f9H7hKGe/T6a3UMox76sToWOTetNVHeq6gU tudCCkxP/HCx4yQO7K/HO7JtVvRjlhI1CsV6QqwcYbPlzI5ssYsfocfJ2IAvA2IrgNcUjXPiD K1Uc5a1ybdCJ96S3Ql4b4xb2kfLX6MO975RtJ7TKjb62xPJrj0BAm6n9qNROwq/kwq01c2spG bM1o0DWBcdOtow8VZAirLYpSrBbSaRClzcvX1p350DpblEgSvb+r498UZuk8SSrb6Eb0+IAty 9w3C+h3PCSjl2lACf1YmTAApdcB4cQAp8b3MMsvABABJL4QUaJidFwH4yWpoFJd3L/uMDBn6h 2r5EZHDsEGxId4dAbiTKAeUZx2z3FxwnV3Jf3/TCC7yprR1WnL2czj3ybw9sfsYDFN2qgh4sj fJMSoDRRRGtJ7vywZCZbiEsMyQ6q1vRuteeRE8CDYWmhw3uDzJzle7P1oYyMkznZUyWfglLkD QEpMTdFFGUrJbgpD59xAYc97T6BHTHE0b07rL5haYKRup6AVEzVtgznsB/27gRod0SSZYNra 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: 209.51.188.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:174198 Archived-At: This is a multi-part message in MIME format. --------------1907E8813182B953A5CB58ED Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Am 05.01.20 um 09:58 schrieb Andreas Schwab: > That contains a lot of spurious whitespace differences. You are right, that is not intended. Sometimes muscle memory just invokes my whitespace cleaner. Corrected patch attached. --------------1907E8813182B953A5CB58ED Content-Type: text/x-patch; charset=UTF-8; name="0001-Provide-vc-hg-ignore-to-make-vc-ignore-work-correctl.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Provide-vc-hg-ignore-to-make-vc-ignore-work-correctl.pa"; filename*1="tch" =46rom f01b089eda1be46e65a2d68b3c3ed389a61c5084 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Sun, 5 Jan 2020 18:09:42 +0100 Subject: [PATCH] Provide vc-hg-ignore to make vc-ignore work correctly * lisp/vc/vc-hg.el: (vc-hg-ignore) Ignore file of directory. Add filepath relative to directory of Mercurial .hgignore file. The filepath is quoted according to the active ignore syntax (Bug#37189). (vc-hg--py-regexp-quote) Quote string as regexp to match exactly string. =2D-- lisp/vc/vc-hg.el | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++= +++++ 1 file changed, 62 insertions(+) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index eac9a6f..633da22 100644 =2D-- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1212,6 +1212,50 @@ REV is ignored." (expand-file-name ".hgignore" (vc-hg-root file))) +(defvar vc-hg-ignore-detect-wildcard "[*^$]" + "Regular expresssion to detect wildcards in an ignored file + specification.") + +(defun vc-hg-ignore (file &optional directory remove) + "Ignore FILE under Mercurial. +FILE is either absolute or relative to DIRECTORY (default is +`default-directory'). +If FILE matches the regular expression +`vc-hg-ignore-detect-wildcard', it is processed unmodified. +Otherwise, FILE is converted to a path relative to the project +root of DIRECTORY. It is then further escaped/expanded according +to the active syntax in .hgignore. If the syntax is `regexp', +FILE is quoted as anchored literal Python regexp and if FILE is a +directory, the trailing `$' is omitted. Otherwise, if the syntax +is `glob', FILE is used unquoted and if FILE is a directory, a +`*' is appended. +If REMOVE is non-nil, remove the pattern derived from FILE from +ignored files." + (let ((ignore (vc-hg-find-ignore-file (or directory default-directory))= ) + (pattern file) + root-dir file-path syntax) + (unless (string-match vc-hg-ignore-detect-wildcard pattern) + (setq file-path (expand-file-name file directory)) + (setq root-dir (file-name-directory ignore)) + (when (not (string=3D (substring file-path 0 (length root-dir)) roo= t-dir)) + (error "Ignore spec %s is not below project root %s" file-path ro= ot-dir)) + (setq pattern (substring file-path (length root-dir))) + (save-match-data + (with-current-buffer (find-file-noselect ignore) + (goto-char (point-max)) + (setq syntax + (if (re-search-backward "^ *syntax: *\\(regexp\\|glob\\)$= " nil t) + (match-string 1) + "regexp"))) + (setq pattern + (if (string=3D syntax "regexp") + (concat "^" (vc-hg--py-regexp-quote pattern) + (and (not (file-directory-p file-path)) "$")) + (concat pattern (and (file-directory-p file-path) "*"))))= )) + (if remove + (vc--remove-regexp (concat "^" (regexp-quote pattern ) "\\(\n\\|$= \\)") ignore) + (vc--add-line pattern ignore)))) + ;; Modeled after the similar function in vc-bzr.el (defun vc-hg-checkout (file &optional rev) "Retrieve a revision of FILE. @@ -1522,6 +1566,24 @@ This function differs from vc-do-command in that it= invokes (defun vc-hg-root (file) (vc-find-root file ".hg")) +(defvar vc-hg--py-regexp-special-chars + (mapcar + (function + (lambda (ch) + (cons ch (concat "\\" (char-to-string ch))))) + (append "()[]{}?*+-|^$\\.&~# \t\n\r\v\f" nil)) + "Characters that have special meaning in Python regular expressions.") + +(defun vc-hg--py-regexp-quote (string) + "Return a Python regexp string which matches exactly STRING and nothing= else. +Ported from Python v3.7" + (mapconcat + (function + (lambda (ch) + (or (cdr (assq ch vc-hg--py-regexp-special-chars)) + (char-to-string ch)))) + string "")) + (provide 'vc-hg) ;;; vc-hg.el ends here =2D- 2.7.4 --------------1907E8813182B953A5CB58ED--