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 02:38:35 +0200 Message-ID: <95da41e8-7a55-a15c-cfa7-d70366f9ee6b@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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C2C254D10BDE3CD80CBB2097" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="116180"; 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 02:39:40 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 1i38TT-000U5w-PT for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Aug 2019 02:39:39 +0200 Original-Received: from localhost ([::1]:44016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i38TS-0005zK-Ew for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Aug 2019 20:39:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37966) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i38St-0005yu-9a for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:39:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i38Sr-0000sf-W6 for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:39:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42593) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i38Sr-0000sZ-OT for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:39:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i38Sr-0001sw-LM for bug-gnu-emacs@gnu.org; Wed, 28 Aug 2019 20:39: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 00:39: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.15670391297228 (code B ref 37189); Thu, 29 Aug 2019 00:39:01 +0000 Original-Received: (at 37189) by debbugs.gnu.org; 29 Aug 2019 00:38:49 +0000 Original-Received: from localhost ([127.0.0.1]:51414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i38Sf-0001sV-CD for submit@debbugs.gnu.org; Wed, 28 Aug 2019 20:38:49 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:55267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i38Sc-0001sG-Fy for 37189@debbugs.gnu.org; Wed, 28 Aug 2019 20:38:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1567039118; bh=HFiclVDHG3FyTK2AfDCL25r2r07UAo9mXjx0hTxZPJE=; h=X-UI-Sender-Class:Subject:From:References:To:Date:In-Reply-To; b=BLtV9tt1JtCX1O5e/XOnSp+UepJM9sui7LlBM6T3my3qEei9pqjMyeh/45ExuX20R 73+5g2Kpub1d+nJVfZy8oZY/AyKoHIvNxv8yv6UP/9gwJx90kmFJQojGIGkaD1lxQu JhDI45Q3KyEglP+S5Ug4XYQBA5/0pYfCkkPbAkpU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.144.41.174]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MCKFk-1htonn3YiA-009M7Q for <37189@debbugs.gnu.org>; Thu, 29 Aug 2019 02:38:37 +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 512371942B08 for <37189@debbugs.gnu.org>; Thu, 29 Aug 2019 02:38:35 +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: <679942e8-abe9-b0fc-720d-75a54d8d0b5a@gmx.de> Content-Language: de-DE X-Provags-ID: V03:K1:dFVFtcDgAN+nXoyOm8HXfqIAVQm8G1GKeKFWU7nOy6hrxVBmbRE M/1gC5FX63dUvalBh071VQkVMWuI7odLinXcIdFsT4jnXGvOibH0G7ueEPkRmMKnAnLJaXl HV0pC1xBEs4nBPZU9yCdu56gs0kq6wjwbxM5q3rAK8hNM733UYxc1Jr1Jkkxt9g9YCPFf6D uTSwCP3ZqA0DXhVwG6Nvg== X-UI-Out-Filterresults: notjunk:1;V03:K0:nWCx/Hbfyrw=:cVFZqoX0S8cYBISsiPOuRO gGKfJpf8k7WtPF4cyY7jV1+qpltk/4p25obavXEvgJVu5dzLz6zNn8kEIQKoRXIYqdf6HoCBO ZTlQ54KrEVHWW1N/QEohYsRkNAPexIN3j3FcZACf5bjkG5rWWVcGDjyi23DRuy6SLIlFIfp4a AMCmkkNr2B90n57NmVhu4U1ymVT40m2UMm9P/HmdmqqFJ6RfHkvGuQpKubVSiUACDNR0SN6zV 0Y1PDTf3//qWcen3Cv2N063mHcU+8aMChOHhDSC1JqV8xpt6x7hxpBIHSn2DTeGpVNRZ+wdfx oeuvkSBeEtn4nhrxjNYzKwhTzTPjLcofEYm2sRFWUm6GN18CCcty2CbIA6CVYCDhqsypYYocp 1HkRlsk5GPncmURY+m9Neyz2BnsnJu22hHq62sLiVfBZ+s/2dHIQvac31Hwqanj1dlSn5EOWM 0+fTsfoLjsrQ6uf2Sc2LNXx5YE5IaPShx6QUpHLcUBaw1evufJ6cuHt3nEhGEU5O9Vhzq1/pW E6JEOqdJzxoBz8IwCV/HG4f3fHzpecRCulLD61lBx+/r952Nsu0jKjO5PzVJe0VOAFUig2EwJ Ke56FepW8TBIH8yvJEkqeK/CTQMyXWgLwc6vG7TyO5t4z6UkMpx3k8lhq8X37SdewVyYymIPf YFhZTFVqACtaXf6m/hZax9PjeWRENrsneHFbPibd+ICTaxT23L9WRnBcdMJfXEP9LWPYa20A4 vHGuNVhZFoV7uj/hI/LjjzTL89Srt3TS5E7COm7POeFCF2lsvfX7ZzaIfqMHS9qN3Hl5aMaz 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:166031 Archived-At: This is a multi-part message in MIME format. --------------C2C254D10BDE3CD80CBB2097 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Small fix for option remove. New version of patch attached. --------------C2C254D10BDE3CD80CBB2097 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 4f95f6de3ec429dc2db632514b43e3773e048505 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Thu, 29 Aug 2019 02:34:17 +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. =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..cf51833 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?") ign= ore) + (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 --------------C2C254D10BDE3CD80CBB2097--