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: *** GMX Spamverdacht *** Re: bug#37189: Acknowledgement (25.4.1: vc-hg-ignore implementation is missing) Date: Wed, 28 Aug 2019 03:46:53 +0200 Message-ID: <679942e8-abe9-b0fc-720d-75a54d8d0b5a@gmx.de> References: <1ba53ae2-42a4-3ab3-d4f2-2ceae565d198@gmx.de> <52917e6f-2f00-25cf-4353-dfb40287d0ea@gmx.de> <83pnkrdpb3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------9502C6ADCA8D0AB4A8A08F29" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="28976"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 Cc: 37189@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 28 03:48:37 2019 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 1i2n4e-0007KW-02 for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Aug 2019 03:48:36 +0200 Original-Received: from localhost ([::1]:60176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2n4c-0007Ra-Me for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Aug 2019 21:48:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37412) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2n47-0007RR-NR for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2019 21:48:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2n46-0001Jh-7y for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2019 21:48:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2n46-0001Jd-49 for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2019 21:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i2n46-0008TE-05 for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2019 21:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Aug 2019 01:48:01 +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.156695683632508 (code B ref 37189); Wed, 28 Aug 2019 01:48:01 +0000 Original-Received: (at 37189) by debbugs.gnu.org; 28 Aug 2019 01:47:16 +0000 Original-Received: from localhost ([127.0.0.1]:49662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i2n3L-0008SG-OZ for submit@debbugs.gnu.org; Tue, 27 Aug 2019 21:47:16 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:51717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i2n3J-0008Rz-5k for 37189@debbugs.gnu.org; Tue, 27 Aug 2019 21:47:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1566956818; bh=ze0lqPucFMrrfROgp2Mdm6xIuWlN4eRMomfFFcY4xkY=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=JvYERbbnmgyoF64Mm6TIxqoP9mIM2zNsCiHHrndWo8jSPhVDQS1ZW+iY60KvLw5VZ XVNELuYtWduyBRuUZx6nUiUSzagHrdKh3ZWAd5ovkkqRl6R/d5fjfpZiyTYmo8AVJJ RdQ004KwzVp3hGSkM37+w2vQvne8IpJ5JTJtTOQo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([91.11.63.178]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7Jza-1i8GA20qDc-007o8w; Wed, 28 Aug 2019 03:46:58 +0200 Original-Received: from [127.0.0.1] (sheckley.simul.de [127.0.0.1]) (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 129971940B9C; Wed, 28 Aug 2019 03:46:53 +0200 (CEST) Openpgp: preference=signencrypt Autocrypt: addr=Wolfgang.Scherer@gmx.de; prefer-encrypt=mutual; keydata= xsDiBEb46IgRBACMHOAb1KNo1Ylk+ebri+4R+bG4tyKlqBlrpv8D9/ZwRdXSGt+0DyCHoaAd 7KW7noHapLe87DunABOjKG4nqTGv+dRiWuUBlp3I4aYRFDVa3Da+XnIYkMHKqhK59VEHQCdp Km42nuLS7TS+n99at9YwzTG6VBdOlBKTlRFngOjVLwCg1RGXJ6X3EjS1FKCQeXziURVpWlkD /2zY6Ayhxi62TS84VjikXrrmjXykAAaAmMVEyKKYb9L5pGlqiZz9g/K9xw1EUoZTYuaufquD v4rAGR58K/3V4CYfJLEeshMWiaXHvMmlxMznlG16/um4MvmR8B3r+cx0nOPK1JBdD2qrkNnF Mw8FB+zouLFB4Gt2IUC5IlOmZ8OQA/4qdU53CItzWsCr9Nux4L0qUlRweSmCnV8xGQ2wP5XI MawIQxxREvSrsYDG8cNnYETMg4iQFfIktwAoxCJvuFAwIB6ZxHGF4Fc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gAv1TRtebMFKvowiRc4Y1QRS KzrA1Z1Gnj2KAG/wqyOgd4xWDQJyurgwHgAM5UiB/5BQ3p1Cs1Skm58Oe1CllWQKyZt7AkTQJ dt/dTeMYD2kBcMs2bacS4GtdRrSVvWML//9fmDY+traOj1F+L5ETaTKkdJU6G73CQBdakIL9a fU+P/wvRyMCfIUCdflhk3cXLJuwmhvb5bH591XpxvloBd4IPpyNvNb4ea5/u+oPhxBTCo17CV xmDrpGzrX/pJidF7xRO90ENjD0jrXojzXTwHzLYVIC0ziMk8TqxVC7kIwVKWT0Haf7m/pTD5z ciF4MdeSm1qv8InZMpzDqhC7Xu5q8P4zBJVEjOntVsQdK0/6LilXxlXFmX2N0/SrU/F+X5J7 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:165992 Archived-At: This is a multi-part message in MIME format. --------------9502C6ADCA8D0AB4A8A08F29 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Am 27.08.19 um 09:45 schrieb Eli Zaretskii: >> From: Wolfgang Scherer >> Date: Tue, 27 Aug 2019 01:25:59 +0200 >> >> +(defun vc-hg-ignore (file &optional directory remove) >> + "Ignore FILE of DIRECTORY (default is `default-directory'). >> + >> +FILE is a file wildcard, relative to the root directory of DIRECTORY.= > I think instead of "root directory of DIRECTORY" this should say "the > top-level directory of DIRECTORY's repository". I disagree. This comment is a modified version of the comment for `vc-default-ignore'. And the exact same phrase also pops up for `vc-svn-ignore': vc.el:1420:FILE is a file wildcard, relative to the root directory of DIR= ECTORY. vc-svn.el:356:FILE is a file wildcard, relative to the root directory of = DIRECTORY. Also `top level' only appears twice in the `vc-' files: vc-bzr.el:1070: A merge has been performed.\nA commit from the top-level = directory vc-cvs.el:904:;; at the top level for CVS. while the phrases `root', `root directory', `repository root' appear 23 times in strings and comments alone. The sentence is actually utterly false for `vc-default-ignore', since FILE is usually an absolute file path when called from a *vc-dir* buffer. With relative paths the code is still wrong and ends up as plain basename for the pattern. Since the implementation of `vc-hg-ignore' corresponds to the actual situation, I have changed the wording to reflect that using the term `project root'. > >> +If FILE matches the regular expression >> +`vc-hg-ignore-detect-wildcard', it is appended to .hgignore as >> +is. Otherwise, FILE is 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. > Our convention is to leave 2 spaces between sentences in comments and > doc strings. Done. >> +When called from Lisp code, if DIRECTORY is non-nil, the > "When called from Lisp" implies that this function can be called in > some other way, which is generally correct only with commands. But > this function is not a command, so I'm unsure what this means here. I agree, and I fixed the remove option, so it actually does what it says ;-) > Thanks. You're welcome. Oops, I had forgotten to include the variable `vc-hg-ignore-detect-wildcard'. So here is an overhauled patch. --------------9502C6ADCA8D0AB4A8A08F29 Content-Type: text/x-patch; name="0001-Provides-vc-hg-ignore-to-make-vc-ignore-work-correct.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Provides-vc-hg-ignore-to-make-vc-ignore-work-correct.pa"; filename*1="tch" =46rom ec04366f6f9ba813b66d62396b1cfa7f2a865a25 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Wed, 28 Aug 2019 03:42:22 +0200 Subject: [PATCH] Provides 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. --- lisp/vc/vc-hg.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 file changed, 60 insertions(+) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index f287adf..aad0bd3 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1153,6 +1153,48 @@ REV is ignored." (expand-file-name ".hgignore" (vc-hg-root file))) =20 +(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 of DIRECTORY (default is `default-directory'). +If FILE matches the regular expression +`vc-hg-ignore-detect-wildcard', it is appended to .hgignore +unmodified. +Otherwise, FILE is assumed to be relative to DIRECTORY and 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 root-dir (file-name-directory ignore)) + (setq file-path (expand-file-name file directory)) + (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. @@ -1451,6 +1493,24 @@ This function differs from vc-do-command in that i= t invokes (defun vc-hg-root (file) (vc-find-root file ".hg")) =20 +(defvar vc-hg--py-regexp-special-chars + (mapcar + (function + (lambda (_c) + (cons _c (concat "\\" (char-to-string _c))))) + (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 nothin= g else. +Ported from Python v3.7" + (mapconcat + (function + (lambda (_c) + (or (cdr (assq _c vc-hg--py-regexp-special-chars)) + (char-to-string _c)))) + string "")) + (provide 'vc-hg) =20 ;;; vc-hg.el ends here --=20 2.7.4 --------------9502C6ADCA8D0AB4A8A08F29--