From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#42966: 28.0.50; vc-dir: wrong backend Date: Sat, 17 Oct 2020 09:13:59 +0200 Message-ID: <875z79z5mw.fsf@gnus.org> References: <87d01imtwl.fsf@gnus.org> <3708c3db-df78-1a50-857a-595f2412e284@yandex.ru> <87v9fa44im.fsf@gnus.org> <1e9908c7-337d-9790-cd37-5232bc04233c@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7079"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Sam Steingold , 42966@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 17 09:17:57 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 1kTgTV-0001j0-HB for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Oct 2020 09:17:57 +0200 Original-Received: from localhost ([::1]:51034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kTgTU-0000Sa-Hz for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Oct 2020 03:17:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kTgQg-0006PO-O2 for bug-gnu-emacs@gnu.org; Sat, 17 Oct 2020 03:15:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kTgQf-0004cP-W3 for bug-gnu-emacs@gnu.org; Sat, 17 Oct 2020 03:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kTgQf-0004nW-Rd for bug-gnu-emacs@gnu.org; Sat, 17 Oct 2020 03:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Oct 2020 07:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42966 X-GNU-PR-Package: emacs Original-Received: via spool by 42966-submit@debbugs.gnu.org id=B42966.160291885218347 (code B ref 42966); Sat, 17 Oct 2020 07:15:01 +0000 Original-Received: (at 42966) by debbugs.gnu.org; 17 Oct 2020 07:14:12 +0000 Original-Received: from localhost ([127.0.0.1]:33127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kTgPs-0004lr-4U for submit@debbugs.gnu.org; Sat, 17 Oct 2020 03:14:12 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:36360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kTgPq-0004le-Te for 42966@debbugs.gnu.org; Sat, 17 Oct 2020 03:14:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yaq9+ePmnT14OgC42mUmBrCif/Ft0VWjMAmp4nKixaQ=; b=V/DTO7tMNEri9vs7zR1G2e3Oya O4EXp2b1I/gB/0LRxPUE4lvqOLZRQuCyI1P/oM0M/pjYc7a2lWad8qHTUChuQmEPoqcLpuV3TM9KG tIfwqQ/6Ady3Vypm/O/zWeysOyTQBcFLyJa5yN0bbbNTJQtKVR9kjcISIahw5HUulhYU=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTgPg-0000Xg-LT; Sat, 17 Oct 2020 09:14:04 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAKlBMVEVUUE1hXVjNybjb 2MWJhXuoo5Xu7Nb9/etEQD/BvKtva2aCfnVBPT3///+oZfybAAAAAWJLR0QN9rRh9QAAAAd0SU1F B+QKEQYQIJY1lUQAAADySURBVDjLY2BAAEYBRgZBIA2kwDSylCAQgEh0CbAMWBZdAiwmgEUCohqL BANOCUaSJYCewSEBk8IiIcCIQwJiE3YJbP6A6GCESygpO4CosDRFqGEwifTyCCDJWl5ehGaEWnkA kGQuDysTQJXghOpQq2RAlwjgCg3hSi8vwZRgLa9kLncuX4ApUVYqXr643AFVohNouaAgU3k5uuWs aSBXMU5L00LzBzyQGIgEHLgkRJcuEQllCQkNcQ3dgCKxLFxp0aQmI6VMtWkBKBKLZwpNDT2qqaka FIQqAXSdAJAAJmdGhlEwtAAsXwsgmAsFV61aBQBdBy4XxoN/QAAAACV0RVh0ZGF0ZTpjcmVhdGUA MjAyMC0xMC0xN1QwNjoxNjozMiswMDowMGbBCBIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMTAt MTdUMDY6MTY6MzIrMDA6MDAXnLCuAAAAAElFTkSuQmCC X-Now-Playing: Various's _1-8 Split Series_: "Merzbow - Ab Hunter" In-Reply-To: <1e9908c7-337d-9790-cd37-5232bc04233c@yandex.ru> (Dmitry Gutov's message of "Fri, 16 Oct 2020 17:44:20 +0300") 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:190761 Archived-At: And here's the benching with the patch applied: (benchmark-run 1000 (vc-responsible-backend "/tmp/git-dir/dir1/dir2/hg-dir/bar")) => (0.375446369 10 0.07836344099999998) (benchmark-run 100 (vc-responsible-backend "/ssh:stories:/tmp/git-dir/dir1/dir2/hg-dir/bar")) => (3.485639896 110 1.00616348) Er... the local version is now faster? Is a throw expensive, somehow? Probably not very significant. But as expected, the tramp version is slower, because it does more lookups remotely. But not hugely. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 39d0fab391..899f260089 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -979,12 +979,20 @@ vc-responsible-backend If NO-ERROR is nil, signal an error that no VC backend is responsible for the given file." (or (and (not (file-directory-p file)) (vc-backend file)) - (catch 'found - ;; First try: find a responsible backend. If this is for registration, - ;; it must be a backend under which FILE is not yet registered. - (dolist (backend vc-handled-backends) - (and (vc-call-backend backend 'responsible-p file) - (throw 'found backend)))) + ;; First try: find a responsible backend. If this is for registration, + ;; it must be a backend under which FILE is not yet registered. + (let ((dirs (delq nil + (mapcar + (lambda (backend) + (vc-call-backend backend 'responsible-p file)) + vc-handled-backends)))) + ;; Just a single response (or none); use it. + (if (< (length dirs) 2) + (car dirs) + ;; Several roots; we seem to have one vc inside another's + ;; directory. Choose the most specific. + (car (sort dirs (lambda (d1 d2) + (< (length d2) (length d1))))))) (unless no-error (error "No VC backend is responsible for %s" file)))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no