From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Justin Bogner Newsgroups: gmane.emacs.devel Subject: Re: [patch] vc-find-root with invert Date: Mon, 21 Jul 2008 10:27:40 -0600 Message-ID: <4884B8FC.9040301@justinbogner.com> References: <486E5CE0.5090004@justinbogner.com> <486E668E.2050600@justinbogner.com> <20080705072126.GA936@tomas> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080306070303030804060604" X-Trace: ger.gmane.org 1216657686 11716 80.91.229.12 (21 Jul 2008 16:28:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Jul 2008 16:28:06 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 21 18:28:54 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KKyFp-0006Nk-Au for ged-emacs-devel@m.gmane.org; Mon, 21 Jul 2008 18:28:54 +0200 Original-Received: from localhost ([127.0.0.1]:44917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKyEv-0005yR-2I for ged-emacs-devel@m.gmane.org; Mon, 21 Jul 2008 12:27:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KKyEp-0005vG-2o for emacs-devel@gnu.org; Mon, 21 Jul 2008 12:27:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KKyEm-0005rN-Mf for emacs-devel@gnu.org; Mon, 21 Jul 2008 12:27:50 -0400 Original-Received: from [199.232.76.173] (port=40135 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KKyEm-0005r9-Gs for emacs-devel@gnu.org; Mon, 21 Jul 2008 12:27:48 -0400 Original-Received: from mx1.yottayotta.com ([198.161.246.32]:1705) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KKyEl-0004Ua-Hz for emacs-devel@gnu.org; Mon, 21 Jul 2008 12:27:48 -0400 Original-Received: from [192.168.1.2] (helo=edm-exchange.yottayotta.com) by mx1.yottayotta.com with esmtp (Exim 4.63) (envelope-from ) id 1KKyEj-0001mt-A4 for emacs-devel@gnu.org; Mon, 21 Jul 2008 10:27:45 -0600 Original-Received: from jbogner.edmonton.yottayotta.com ([10.0.3.192]) by edm-exchange.yottayotta.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 21 Jul 2008 10:27:40 -0600 User-Agent: Thunderbird 2.0.0.14 (X11/20080505) In-Reply-To: <20080705072126.GA936@tomas> X-OriginalArrivalTime: 21 Jul 2008 16:27:40.0878 (UTC) FILETIME=[B2249EE0:01C8EB4E] X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:101092 Archived-At: This is a multi-part message in MIME format. --------------080306070303030804060604 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit tomas@tuxteam.de wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Fri, Jul 04, 2008 at 03:52:48PM -0400, Stefan Monnier wrote: >>>>> Here's a patch that fixes a bug I've noticed in vc-find-root. When called > > [...] > >>> I believe that it's for systems like CVS, where each subdirectory under >>> version control has its own CVS directory. >> Sorry, but that doesn't help me ;-( >> Anyone has a more complete explanation? > > Reading the docstring, my guess would be: vc-find-root walks the dir > tree up _until_ it finds WITNESS (as an evidence for the VC tree's root > dir). Unless we have CVS or SVN or similar, where every subdir has > WITNESS, so the root would be the last up-tree directory having WITNESS. > > But I might be off-by-one ;-) > > Regards > - -- tomás > This is exactly correct, though in the current trunk there is a bug such that the function does not behave like this. The patch causes it to work as documented. The changes are actually quite small, to demonstrate, the same patch ignoring whitespace is attached, though the original should be applied so that the indentation is correct. --------------080306070303030804060604 Content-Type: text/x-diff; name="findroot-ignorews.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="findroot-ignorews.patch" diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cf0472e..aebc149 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -384,6 +384,11 @@ * textmodes/sgml-mode.el (sgml-font-lock-syntactic-keywords): Use syntax-ppss on a position *before* the char we want to change. +2008-07-04 Justin Bogner + + * vc-hooks.el (vc-find-root): + Find the directory when using invert, not the file itself. + 2008-07-04 Dan Nicolaescu * vc-dir.el (vc-dir-query-replace-regexp): New function. diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 2ccbdcc..0662961 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -327,6 +327,13 @@ The function walks up the directory tree from FILE looking for WITNESS. If WITNESS if not found, return nil, otherwise return the root. Optional arg INVERT non-nil reverses the sense of the check; the root is the last directory for which WITNESS *is* found." + (when (not (file-directory-p file)) + (setq file (file-name-directory file))) + ;; In the invert case, we should return nil if WITNESS doesn't exist + ;; in the first place. + (if (and invert + (not (file-exists-p (expand-file-name witness file)))) + nil ;; Represent /home/luser/foo as ~/foo so that we don't try to look for ;; witnesses in /home or in /. (setq file (abbreviate-file-name file)) @@ -359,7 +366,7 @@ the root is the last directory for which WITNESS *is* found." ;; (This occurs, for example, when placing dotfiles under RCS.) (when (and (not root) invert prev-file) (setq root prev-file)) - root)) + root))) ;; Access functions to file properties ;; (Properties should be _set_ using vc-file-setprop, but --------------080306070303030804060604--