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: Thu, 29 Aug 2019 17:52:21 +0200 Message-ID: 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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BB93B7EA1E25CF4D3F739CCB" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="175867"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 To: 37189@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 29 17:53:35 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 1i3Mju-000jdr-HX for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Aug 2019 17:53:34 +0200 Original-Received: from localhost ([::1]:51362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3Mjt-0001oz-51 for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Aug 2019 11:53:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33044) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3MjP-0001ol-Gf for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2019 11:53:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3MjO-0000wr-62 for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2019 11:53:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i3MjO-0000wb-1J for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2019 11:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i3MjN-0002Ot-T3 for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2019 11:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Aug 2019 15:53: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.15670939509191 (code B ref 37189); Thu, 29 Aug 2019 15:53:01 +0000 Original-Received: (at 37189) by debbugs.gnu.org; 29 Aug 2019 15:52:30 +0000 Original-Received: from localhost ([127.0.0.1]:52828 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i3Mir-0002OB-Qr for submit@debbugs.gnu.org; Thu, 29 Aug 2019 11:52:30 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:40337) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i3Miq-0002Nv-A6 for 37189@debbugs.gnu.org; Thu, 29 Aug 2019 11:52:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1567093942; bh=SKwusrIAdD+k5fme6fG7cYM5lUdmpmAKz9rvvTdXw64=; h=X-UI-Sender-Class:Subject:From:To:References:Date:In-Reply-To; b=BHkEZM6CLsFL6hFtG/Zm6Dh4B7Cai5Q9iuaGX7rCeDTxZ6S1US/KqhM5lqfD1u2E4 48hGfI61mrgimmDhSgAnz4adMtatMLwXafS4f0bHw35Pt6QvqDba+0zd8PWyckENtz fEAgEzIP+SfMyJNZAJUMDbX+5Hfv1fBqD9uDCgVE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([91.11.52.253]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MDQic-1hssaZ3wDm-00AYhW for <37189@debbugs.gnu.org>; Thu, 29 Aug 2019 17:52:22 +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 55C531942B0A for <37189@debbugs.gnu.org>; Thu, 29 Aug 2019 17:52:21 +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 MawIQxxREvSrsYDG8cNnYETMg4iQFfIktwAoxCJvuFAwIB6ZxHGF4FcEZm64CXc2u7CmFLqt rVhXhIfMz9oEYC+HhGczGamn9ofbGTFd2hJEtPcQgWNR4f7+aKknmi2+OM0fV29sZmdhbmcg U2NoZXJlciA8d3NAc3ctYW10LndzPsJhBBMRAgAhBQJYmz3YAhsjBQsJCAcCBhUICQoLAgQW AgMBAh4BAheAAAoJEIUCr3Gr112VZZoAoLTBSTp1qGuNhLdXY04iaWCMYmHCAJ4kHPtQ6nTw kEq9qCHgVgXDaY7wjs7ATQRG+OiIEAQAhi0wjcxvA4tychg2NQuwBIf9LX/46l+74+QbewCn a4a+mw/9s5KY In-Reply-To: <95da41e8-7a55-a15c-cfa7-d70366f9ee6b@gmx.de> Content-Language: de-DE X-Provags-ID: V03:K1:l3k3yFrjC2xszHjSrDVqZm0LOENb7PhP2COZ2w3zz/6mWgpmBQh 2UuuOhgI/COlYU12++3XCf/d/ZRUxnTrMzJl+lDODkZo6ZH463IrXIvuoyLY1dJ1+RadUh7 tUedxtgnS9y9jRJ9Vz7LzcdV/MlAfHJJQulWNSk0znLCRA4t5qiOb8EIbOw2EkWTiVkzCDe oSTxuU3VzV8LwFs7ATJHw== X-UI-Out-Filterresults: notjunk:1;V03:K0:8KIS3uXDUWM=:+/mcNd4QgoDj3SiluFJS0N GZZaBuoEkTT8W4fMGg4/TRK+0wtBJz+umBSG5auxGImV/xf9eWgfZXH7KutRe3a03XI4YDjD1 LV5e1msMfWi/RBVgzimLXYZp9iSSFvXUbUJtqQD+H4uuekoAt59zeNwimYYFAUDISBdhof0Z+ jLRsLHJBAKl0Y54rEs51SzvfP9Su9kBGEiG1t10XAzpkd2URTlur9LbAufpr1v26MaeRQ49/L SfSKtRDScbqxEtgsYyM/WUkMlaOUPH3Z1ZKpJNM8UHwe032FrD3cMymf+qZC6/yUXzj3AKlOz xjo5IQEn5yi8wRX7gMHMCAElT5xjsCQJ2ti28xkdaeOJDTZv4GF/TlnT+Vvao7WAf2UFhoJ6n QW8uHcsoTEt3M86Ug7lA1VG/jprteKXXqz0N705EIiahvi/BpAi4PsWDY0jn31fq5TQJTZuSR YqF3dpHoEC12Guwr4zpsMh7Ff6GVQIVUy+iGiWoaw9seSQMnm/6fDZSj6yMYhhSI+HBXfhYNC n0wLF59qO4zNCeABa/OxoHawgt71h6Nau0/IC2zVdCIR8yJvdOMCKAbS9T9HUX65XWQh7jeL9 4nlXKwzo/QOWdY6GI4WvHNj/3v2OVHjNJFxB+oX2YVZ2xIt7kXk4oHzQx2WIN6MbUAS6Hr+gV wPDLt3J1g9xVriWAxeu3xRK2V8ShJ5DrrJzfHdjDO17NF2B1mRNhn9vz9lK0G1VB7PR5mMjP2 k3FACxMQsVEvvQePEQxrgvrShJwvmxRY3ZZ8Ujmup4bRokkLtyJA5nEEAc34FfhsmqFEtIe1 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:166052 Archived-At: This is a multi-part message in MIME format. --------------BB93B7EA1E25CF4D3F739CCB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit A unit test showed, that the removal regexp was faulty. New version of patch attached. --------------BB93B7EA1E25CF4D3F739CCB Content-Type: text/x-patch; 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 4fb25acadedc81a6d654bed89e816906aff07178 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Thu, 29 Aug 2019 17:49:54 +0200 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 f287adf..9cbd9d4 100644 =2D-- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1153,6 +1153,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 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 either relative to DIRECTORY or absolute. 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 root-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. @@ -1451,6 +1495,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 (_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 nothing= 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) ;;; vc-hg.el ends here =2D- 2.7.4 --------------BB93B7EA1E25CF4D3F739CCB--