merge git-annex branch in memory in read-only repository
authorJoey Hess <joeyh@joeyh.name>
Sun, 26 Dec 2021 18:28:42 +0000 (14:28 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 27 Dec 2021 17:21:15 +0000 (13:21 -0400)
commit6d7ecd9e5d1571d1dc7e59106f848abccdf7fd0e
treee65102a7f2c8a4ecd957308d411034414109a6f3
parentda6aa6e94479dbfbdf5aca22e971b2bc19a3e691
merge git-annex branch in memory in read-only repository

Improved support for using git-annex in a read-only repository, git-annex
branch information from remotes that cannot be merged into the git-annex
branch will now not crash it, but will be merged in memory.

To avoid this making git-annex behave one way in a read-only repository,
and another way when it can write, it's important that Annex.Branch.get
return the same thing (modulo log file compaction) in both cases.

This manages that mostly. There are some exceptions:

- When there is a transition in one of the remote git-annex branches
  that has not yet been applied to the local or other git-annex branches.
  Transitions are not handled.
- `git-annex log` runs git log on the git-annex branch, and so
  it will not be able to show information coming from the other, not yet
  merged branches.
- Annex.Branch.files only looks at files in the git-annex branch and not
  unmerged branches. This affects git-annex info output.
- Annex.Branch.hs.overBranchFileContents ditto. Affects --all and
  also importfeed (but importfeed cannot work in a read-only repo
  anyway).
- CmdLine.Seek.seekFilteredKeys when precaching location logs.
  Note use of Annex.Branch.fullname
- Database.ContentIdentifier.needsUpdateFromLog and updateFromLog

These warts make this not suitable to be merged yet.

This readonly code path is more expensive, since it has to query several
branches. The value does get cached, but still large queries will be
slower in a read-only repository when there are unmerged git-annex
branches.

When annex.merge-annex-branches=false, updateTo skips doing anything,
and so the read-only repository code does not get triggered. So a user who
is bothered by the extra work can set that.

Other writes to the repository can still result in permissions errors.
This includes the initial creation of the git-annex branch, and of course
any writes to the git-annex branch.

Sponsored-by: Dartmouth College's Datalad project
Annex/Branch.hs
Annex/BranchState.hs
Assistant/Sync.hs
Assistant/Threads/Merger.hs
CHANGELOG
Types/BranchState.hs