From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#43464: 28.0.50; vc: Error calling vc-revert for repo root Date: Thu, 8 Oct 2020 01:47:29 +0300 Message-ID: References: <0b1c72d0-f8fb-a256-1563-1c43296c8edb@yandex.ru> <11761d79-1893-fdf3-843d-bea4a026fc7f@yandex.ru> <7b4d0bcf-c622-b2db-34d6-e587fe516f8d@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------79EA94F4F3860436BFC712D7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35146"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: 43464@debbugs.gnu.org To: Andrii Kolomoiets Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 08 00:48:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQIEF-00091l-28 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Oct 2020 00:48:11 +0200 Original-Received: from localhost ([::1]:37750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQIED-0007JW-HF for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Oct 2020 18:48:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQIE6-0007J8-6c for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2020 18:48:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kQIE5-00028A-KZ for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2020 18:48:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kQIE5-0006XB-IH for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2020 18:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Oct 2020 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43464 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 43464-submit@debbugs.gnu.org id=B43464.160211086425093 (code B ref 43464); Wed, 07 Oct 2020 22:48:01 +0000 Original-Received: (at 43464) by debbugs.gnu.org; 7 Oct 2020 22:47:44 +0000 Original-Received: from localhost ([127.0.0.1]:58298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQIDn-0006Wf-Vi for submit@debbugs.gnu.org; Wed, 07 Oct 2020 18:47:44 -0400 Original-Received: from mail-wm1-f53.google.com ([209.85.128.53]:34713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQIDi-0006WO-BR for 43464@debbugs.gnu.org; Wed, 07 Oct 2020 18:47:42 -0400 Original-Received: by mail-wm1-f53.google.com with SMTP id l15so5457733wmh.1 for <43464@debbugs.gnu.org>; Wed, 07 Oct 2020 15:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=GnhvDutm5JjDHpurP3rVNjBbUtIUp8G/8J1Z5v/jR7U=; b=LoHi/WpZHAnTscloOijuTH7LdpK9TWS/pRAWOjq598frYTpHAG8E/nAnfciNbV5e45 hSwO7kJx6AoL+/FcwJAC8s71TRnMg6VNgZVCifqfzn9woxt7qR0+3S6yxYe0m6JtOpSp GyNXsY+OJ+qv++f5P1v20TWbCdg7SZHxjBhQItzOOYh4ZAQfjWvSC/P+J2ktjDsj3ZAT TugaXS+clN3kVksp79dqGCk0Sgv9GK7gbgxodqX8DZ7f7pm7+VrZNM/76vV+O0gkV7v6 W4IaYDUUuP8Cy1xI1fNSGSNSYVkq/tS6Tbxv550O4P/RNOjjEuVoJSGb2nChL1zcGZ3r GEZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=GnhvDutm5JjDHpurP3rVNjBbUtIUp8G/8J1Z5v/jR7U=; b=lUXCujX82tJCq9EBrk54kmRIH7q7NT+SAKs9Lon7MKKS5uXEv4fg0zDXY0oKOTPWsC 0piDO2V+raxKjYCVcLFLSVUp751V6zBBC8dwZzjmn0N1u+lWxqd+Pw5KkAsqrPnwcg5c DEfs+oDrqOfyjpLqX+9dMQJ/2ZiAiYiGte2lhOKC2j+PdLhzwJY7fz1j7kkReLOIppUl XK77i37JeyFc+y5qy+b3puotTiTW6+eWtCzT9JPIkTcRmQ8M2etCDYlgxD9wNvhHHYQV WHrTOjvAWBFsJ2O+XJCleKmlqwrI3OlFIdMtItwlutapkJLNy8Mxfp5M9uFvppUPLY3A MYPg== X-Gm-Message-State: AOAM530NpmJ+rAd0qw1iSYB+vu3a8p67lK3Fg8CA9p91qFepMnhpqn7l xBQoQbUMLiCLeJc+rapiUSdXScrOkyNKJQ== X-Google-Smtp-Source: ABdhPJxPlvYAqQimrF2bp12eB834bkoKhMxunzKUZiF+L7FjqWAP9TZEKPovb7fOed+h7gycACe9lw== X-Received: by 2002:a05:600c:2902:: with SMTP id i2mr5374201wmd.31.1602110852168; Wed, 07 Oct 2020 15:47:32 -0700 (PDT) Original-Received: from [192.168.0.4] ([66.205.71.3]) by smtp.googlemail.com with ESMTPSA id f63sm4497966wme.38.2020.10.07.15.47.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Oct 2020 15:47:31 -0700 (PDT) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:190056 Archived-At: This is a multi-part message in MIME format. --------------79EA94F4F3860436BFC712D7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 07.10.2020 16:16, Andrii Kolomoiets wrote: > Dmitry Gutov writes: > >> On 05.10.2020 09:02, Andrii Kolomoiets wrote: >>> Dmitry Gutov writes: >>> >>>> Where is that vc-backend called from, in our scenario? >>> It's called from 'vc-call'. The 'vc-revert-file' used it twice >>> to call the 'make-version-backups-p' and the 'revert' backend functions. >> >> Then a change in vc-revert-file could be sufficient. > > Can you please advice me what this change should look like? Get rid of > calling 'vc-call'? Yes. How about the attached patch? > In this case the function 'vc-version-backup-file' > must be changed as well. Does it actually make sense to use it on a directory? >>>> Could we make do with changing that code to use vc-responsible-backend >>>> instead of vc-backend instead? If it's not a function called >>>> frequently. >>> I went a little different way and made the 'vc-backend' return >>> correct >>> backend for directories. In case you missed it somehow here is the link >>> to the message: >>> https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-09/msg02508.html >> >> Like I explained, it will create a cache entry that is never invalidated. > > In what way VC backend for directory could be changed? Like 'rm -rf .hg > && git init'? We can make the 'vc-backend' function to ignore cached > backend for directories. Though I think it's not efficient. Something like that. Or 'git init' inside a subdirectory. Not a frequent occurrence, but if we start using directories and files interchangeably in more places, we are likely to start caching other properties on them, too. So it's better to use a different function to detect which backend a directory belongs to. Also, your patch makes vc-registered work on directories. What does it mean to have a directory "registered"? It's not a well-defined notion, given that most of contemporary VC systems don't track directories, only the files inside them. --------------79EA94F4F3860436BFC712D7 Content-Type: text/x-patch; charset=UTF-8; name="vc-revert-dirs.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vc-revert-dirs.diff" diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 3852a64550..8efd9fd560 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2788,14 +2788,21 @@ vc-version-backup-file backup-file))))) (defun vc-revert-file (file) - "Revert FILE back to the repository working revision it was based on." + "Revert FILE back to the repository working revision it was based on. +FILE can be a plain file or a directory, and in the latter case +all files inside that directory will be reverted." (with-vc-properties (list file) - (let ((backup-file (vc-version-backup-file file))) + (let* ((dir (file-directory-p file)) + (backup-file (unless dir (vc-version-backup-file file)))) (when backup-file (copy-file backup-file file 'ok-if-already-exists) (vc-delete-automatic-version-backups file)) - (vc-call revert file backup-file)) + (vc-call-backend + (if dir + (vc-backend file) + (vc-responsible-backend file)) + 'revert file backup-file)) `((vc-state . up-to-date) (vc-checkout-time . ,(file-attribute-modification-time (file-attributes file))))) --------------79EA94F4F3860436BFC712D7--