bbatsov / projectile

Project Interaction Library for Emacs
https://docs.projectile.mx
GNU General Public License v3.0
4k stars 583 forks source link

Scan for the Fossil checkout database instead of the config or repo database #1022

Closed michaelbartnett closed 8 years ago

michaelbartnett commented 8 years ago

Same problem as #865, but I think projectile is doing the wrong thing here.

Expected behavior

Project without a VCS is able to list files when Fossil is installed, and there is a global fossil configuration database in the usual location.

Actual behavior

Projectile interprets Fossil's global configuration database as a VCS checkout since it's located at ~/.fossil:

https://www.fossil-scm.org/index.html/doc/trunk/www/tech_overview.wiki

This means that any non-VCS project created under my home directory can't list files correctly, reporting: current directory is not within an open checkout.

Steps to reproduce the problem

  1. Install Fossil
  2. Init a fossil repo somewhere so that the configuration database will be created

    $ mkdir -p ~/fossiltest; fossil init ~/fossiltest/repo.fossil
    project-id: 868fc417a7e390fdf7e08477818fb622f20a3dcd
    server-id:  db6776f380a9a3e01dac6560e1f7ffacd8daa686
    admin-user: michaelbartnett (initial password is "3f417d")
    $ ls ~/.fossil
    /Users/michaelbartnett/.fossil
    $ rm -Rf ~/fossiltest
  3. Start a new projectile project and a file in it

    $ mkdir ~/testproject
    $ touch ~/testproject/.projectile
    $ echo "test 1" > ~/testproject/test_1.txt
    $ echo "test 2" > ~/testproject/test_2.txt
    $ emacs ~/testproject/test_1.txt
  4. Try to open the other file in the project (C-c p f). Instead of a file list, you'll see this message that projectile forwards from fossil:

    current directory is not within an open checkout

    Environment & Version information

Note: fossil installed via homebrew. Probably not relevant.

Projectile version information

Projectile version: 20160623.23

Emacs version

GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, Carbon Version 157 AppKit 1265.21)

Operating system

MacOS 10.9.5

My Workaround

Special casing fossil in projectile-project-vcs to ignore a .fossil file if it's in the home directory worked for me. I don't know how portable using (expand-file-name "./" "~") is.

(defun projectile-project-vcs (&optional project-root)
  "Determine the VCS used by the project if any.
PROJECT-ROOT is the targeted directory.  If nil, use
`projectile-project-root'."
  (or project-root (setq project-root (projectile-project-root)))
  (cond
   ((projectile-file-exists-p (expand-file-name ".git" project-root)) 'git)
   ((projectile-file-exists-p (expand-file-name ".hg" project-root)) 'hg)
   ((projectile-file-exists-p (expand-file-name ".fossil" project-root)) 'fossil)
   ((projectile-file-exists-p (expand-file-name ".bzr" project-root)) 'bzr)
   ((projectile-file-exists-p (expand-file-name "_darcs" project-root)) 'darcs)
   ((projectile-file-exists-p (expand-file-name ".svn" project-root)) 'svn)
   ((projectile-locate-dominating-file project-root ".git") 'git)
   ((projectile-locate-dominating-file project-root ".hg") 'hg)

   ;; Changes
   ;; ((projectile-locate-dominating-file project-root ".fossil") 'fossil)
   ((let ((dominating-dir (projectile-locate-dominating-file project-root ".fossil")))
      (not (equal dominating-dir (expand-file-name "./" "~"))))
    'fossil)

   ((projectile-locate-dominating-file project-root ".bzr") 'bzr)
   ((projectile-locate-dominating-file project-root "_darcs") 'darcs)
   ((projectile-locate-dominating-file project-root ".svn") 'svn)
   (t 'none)))
npostavs commented 8 years ago

Shouldn't projectile be looking for _FOSSIL_ or .fslckout, instead of .fossil? See fossil_reserved_name in add.c.

michaelbartnett commented 8 years ago

That's the checkout database, which is different from the repository database.

The documentation implies that common practice is to name the repo database as "project-name.fossil": http://fossil-scm.org/index.html/doc/trunk/www/tech_overview.wiki

I don't use fossil often enough to know if people follow that convention or a different one.

npostavs commented 8 years ago

That's the checkout database,

Yes, exactly. The checkout, where all the code for your project is checked out. .fslckout is equivalent to the .svn directory, and ~/.fossil is like ~/.subversion.

Personally, I have my repository databases stored in one directory, as in fossil.d/project1-name.fossil, fossil.d/project2-name.fossil... That way I can run fossil serve --localauth fossil.d and get a list of all projects.

The documentation implies that common practice is to name the repo database as "project-name.fossil": http://fossil-scm.org/index.html/doc/trunk/www/tech_overview.wiki

I don't use fossil often enough to know if people follow that convention or a different one.

Regardless, I don't think anybody names it literally .fossil, as it seems projectile is searching for.

michaelbartnett commented 8 years ago

Oh! I see now, you're totally right. It should be looking for .fslckout or _FOSSIL_. Is _FOSSIL_ the name on windows?

npostavs commented 8 years ago

_FOSSIL_ is the older name, it was renamed to .fslckout at some point, not sure exactly when, but existing checkouts still use the older _FOSSIL_ name regardless of fossil version.