unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark Harig via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "eliz@gnu.org" <eliz@gnu.org>, "dgutov@yandex.ru" <dgutov@yandex.ru>
Cc: "58525@debbugs.gnu.org" <58525@debbugs.gnu.org>
Subject: bug#58525: 28.1: `vc-dir' (key sequence: C-x v d) fails when used with a CVS repository
Date: Mon, 17 Oct 2022 17:43:07 +0000 (UTC)	[thread overview]
Message-ID: <259751090.1922936.1666028587272@mail.yahoo.com> (raw)
In-Reply-To: <83pmeq1k9e.fsf@gnu.org>

> > From: Dmitry Gutov <dgutov@yandex.ru>
> >
> > On 17.10.2022 09:06, Eli Zaretskii wrote:
> > > AFAIK, the VC's support for CVS is based on detecting the CVS
> > > subdirectory of a directory where you invoke vc-dir.  If that
> > > subdirectory is not found, VC will assume the backend is not
> > > CVS.  In which case your assumptions seem to be mistaken.
> > >
> > > But I will let VC expert to chime in here, because I may be
> > > wrong or confused.
> >
> > Here's the basic logic:
> >
> > (defun vc-cvs-registered (f)
> >    "Return non-nil if file F is registered with CVS."
> >    (when (file-readable-p (expand-file-name
> >               "CVS/Entries" (file-name-directory f)))
> 
> >      ...
> 
> Thanks.  So after performing the steps in the original report, I do
> have ~/tmp3/project1/CVS/Entries here.

The `vc-cvs-registered' function is not called before the error
is triggered.

`vc-dir' calls `vc-responsible-backend'.

`vc-responsible-backend' contains the following expression:

> (let ((dirs (delq nil
>                   (mapcar
>                    (lambda (backend)
>                      (when-let ((dir (vc-call-backend
>                                       backend 'responsible-p file)))
>                        (cons backend dir)))
>                    vc-handled-backends))))
>   ;; Just a single response (or none); use it.
>   (if (< (length dirs) 2)
>       (caar dirs)
>     ;; Several roots; we seem to have one vc inside another's
>     ;; directory.  Choose the most specific.
>     (caar (sort dirs (lambda (d1 d2)
>                        (< (length (cdr d2)) (length (cdr d1))))))))

The value of `dirs' is set by the following expression:

> (dirs (delq nil
>             (mapcar
>              (lambda (backend)
>                (when-let ((dir (vc-call-backend
>                                 backend 'responsible-p file)))
>                  (cons backend dir)))
>              vc-handled-backends)))

On my system, the `mapcar' expression is returning the following
value:

> (nil (CVS . t) nil nil nil nil (Git . "~/") nil)

which is surprising and incorrect.

The `delq' expression then reduces this to:

> ((CVS . t) (Git . "~/"))

So, for some reason, the VC elisp code thinks that in
~/tmp3/project1, there is both a CVS and a Git VC backend
controlling the files that were checked out of the CVS
repository.

Because the Git cons contains "~/", I checked my home directory
for files named ".git" and found a directory created two years
ago.  I renamed that directory and re-ran `C-x v d'.  The
original error reported disappeared and `vc-dir' listed the CVS
status and files as expected.  I restored the directory in ~/ to
its original name (~/.git) and the error returned.

The problem appears to be a result of the function `vc-find-root'
finding the "~/.git" directory.  As its doc string says:

>   "Find the root of a checked out project.
> The function walks up the directory tree from FILE looking for
> WITNESS.  If WITNESS if not found, return nil, otherwise return
> the root."

So, after finding the CVS backend, the `mapcar' expression, above,
continues and checks for a Git backend, which it finds in the directory
that contains tmp3/project1, namely, ~, the home directory.  Because
it found ~/.git/, it sets the variable `dirs' to an erroneous value and
later logic fails because of this.

What is the solution to this problem?  What should the VC
functions (not just `vc-dir') do when they find more than one VC
backend indicator in the directory tree?  Should it issue an
error indicating more than one VC backend detected, (since files
cannot be under the control of multiple VC backends)?  Or, should
it stop after the "most local" VC backend is found and attempt to
use that?

The current behavior (issuing an obscure error message that gives
the user no clue as the what is causing the problem) should be
corrected.

(End.)





  reply	other threads:[~2022-10-17 17:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2011444375.1250404.1665768998367.ref@mail.yahoo.com>
2022-10-14 17:36 ` bug#58525: 28.1: `vc-dir' (key sequence: C-x v d) fails when used with a CVS repository Mark Harig via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-14 18:34   ` Eli Zaretskii
2022-10-16 22:06     ` Mark Harig via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-17  6:06       ` Eli Zaretskii
2022-10-17 13:00         ` Dmitry Gutov
2022-10-17 16:34           ` Eli Zaretskii
2022-10-17 17:43             ` Mark Harig via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-10-17 23:10               ` Dmitry Gutov
2022-10-18  1:06                 ` Mark Harig via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 12:04                   ` Dmitry Gutov
2022-10-18 15:39                     ` Mark Harig via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-18 15:58                       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=259751090.1922936.1666028587272@mail.yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=58525@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=idirectscm@aim.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).