A Portable Checkout including the database
(1.1) By xerusf on 2024-07-25 17:24:45 edited from 1.0 [source]
I have a checkout with the repository database in the same directory, and thought I could simply move it around.
So I moved the database with its sibling files from /opt/.fossil to /opt/project/.fossil
Before I could use cd /opt/project && fossil test-move-repository .fossil
, apparently I had to put a copy of the database in the original location, i.e. cp .fossil ..
which i could delete after issuing the command.
But now, the local-root
is still wrong and I cannot find out how to change it. Why can't fossil just use relative paths?
Found someone with similar, inconsistent behavior at https://fossil-scm.org/forum/forumpost/cc65a2b939355df6
(2.1) By Richard Hipp (drh) on 2024-07-25 17:57:36 edited from 2.0 in reply to 1.1 [link] [source]
You can move the check-out around. You just can't move the repository. The ".fslckout" file in the check-out contains the full pathname of the repository (among other things), which is how Fossil locates the repository.
We could store a relative pathname in .fslckout, but then if the repository is separate from the check-out (which is the usual case with Fossil) the link would be broken when the check-out moved.
Maybe you want to store the relative pathname in .fslckout only when the repository is in the check-out. Then it would work whenever you move the check-out. But it seems like a brittle and complicated solution to an unusual problem. I'm not yet sure we are seeing all the corner cases.
You can use the fossil test-move-repository command to adjust the pathname to the repository in the .fskckout file.
(3.1) By Richard Hipp (drh) on 2024-07-25 20:37:47 edited from 3.0 in reply to 1.1 [link] [source]
Here's an idea:
Suppose we continue to store the absolute pathname of the repository in .fslckout, as we always have. But, further suppose that if when we go to look up the repository, if we can't find it, we also look for a file with the same name in the root directory of the check-out.
Presumably xerusf's complaint comes up because he has had prior exposure
to Git, where the repository is the .git
directory in the checkout,
so he is used to being able to move the entire checkout around it it will
just work. Probably others are coming from Git had have the same old
habits. With the change outlined in the previous paragraph, things would
continue to work as former Git users expect.
What am I missing?
(4) By anonymous on 2024-07-25 22:38:13 in reply to 3.1 [link] [source]
Can putting the repo file in the working directory result in commiting the fossil repo to the fossil repo? I seem to remember this being a potential issue and why it's not suggested.
One possible workaround is to support the repo in the parent directory. This would work for USB where the repo and the working directory can share the root directory of the disk.
(5) By Richard Hipp (drh) on 2024-07-25 23:25:57 in reply to 4 [link] [source]
Fossil is careful not to commit it's own repository file.
(6) By Stephan Beal (stephan) on 2024-07-25 23:26:28 in reply to 4 [link] [source]
I seem to remember this being a potential issue and why it's not suggested.
It's not an issue per se but can lead to user errors which can corrupt a repo. Many years ago i did some C-style refactoring using a one-line perl script to replace some text throughout my project. Predictably, doing so corrupted my repo db through no fault of fossil's. Since then i adamantly keep repositories outside of my checkout dirs.
(7) By anonymous on 2024-07-26 09:57:37 in reply to 3.1 [link] [source]
That would be a good fit for me where I have many check-outs that remain checked-out forever and contains unversioned items also. The repository and check-out are always moved around together, and to not have to follow any additional steps will be excellent. Philip
(8) By Richard Hipp (drh) on 2024-07-26 10:28:39 in reply to 1.1 [link] [source]
Why can't fossil just use relative paths?
While developing and testing my proposal at (3.1) above, I discovered that the repository filename is stored as a relative path, or at least it usually is. And so my changes are not actually necessary.
If you open the check-out using:
fossil open ./myproject.fossil
Then the pathname stored is literally "./myproject.fossil
", in which
case you are free to move the checkout around all you want. Only if you
do this:
fossil open /full/path/to/myproject.fossil
Does the repository filename become absolute and locked into place. How did you open the repository in question? From the check-out, if you run:
fossil sql "SELECT value FROM vvar WHERE name='repository';"
What does it say?
(9) By Richard Hipp (drh) on 2024-07-26 10:43:01 in reply to 8 [link] [source]
Answering my own question: It appears that if you do
fossil open https://domain/repo
That it stores the absolute pathname. Perhaps if we just fix "fossil open" so that it sets the "repository" entry in VVAR to a relative pathname, that would suffice to resolve the problem, and the magic repository search algorithm proposed in (3.1) would not be necessary?
(10) By Richard Hipp (drh) on 2024-07-26 10:50:31 in reply to 9 [link] [source]
The proposal at (9) has now been checked in.