2014-02-11 08:15:33 +00:00
|
|
|
[[!toc]]
|
|
|
|
|
|
|
|
# metadata
|
|
|
|
|
2014-02-11 20:27:27 +00:00
|
|
|
Attach an arbitrary set of metadata to a key. This consists of any number
|
|
|
|
of fields. Each field has an unordered set of values. The special field
|
|
|
|
"tag" has as its values any tags that are set for the key.
|
2014-02-11 08:15:33 +00:00
|
|
|
|
|
|
|
Store in git-annex branch, next to location log files.
|
|
|
|
|
2014-02-11 20:27:27 +00:00
|
|
|
Storage needs to support union merging, including removing an old value
|
|
|
|
of a field, and adding a new value of a field.
|
2014-02-11 08:15:33 +00:00
|
|
|
|
|
|
|
# filtered branches
|
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
See [[tips/metadata_driven_views]]
|
2014-02-11 08:15:33 +00:00
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
The reason to use specially named filtered branches is because it makes
|
|
|
|
self-documenting how the repository is currently filtered.
|
2014-02-11 08:15:33 +00:00
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
TODO: Files not matching the view should be able to be included.
|
|
|
|
For example, it could make a "unsorted" directory containing files
|
|
|
|
without a tag when viewing by tag. If also viewing by author, the unsorted
|
|
|
|
directories nest.
|
2014-02-11 15:37:53 +00:00
|
|
|
|
|
|
|
## operations while on filtered branch
|
2014-02-11 08:15:33 +00:00
|
|
|
|
|
|
|
* If files are removed and git commit called, git-annex should remove the
|
2014-02-19 21:50:30 +00:00
|
|
|
relevant metadata from the files.
|
|
|
|
TODO: It's not clear that
|
2014-02-11 08:15:33 +00:00
|
|
|
removing a file should nuke all the metadata used to filter it into the
|
|
|
|
branch (especially if it's derived metadata like the year).
|
2014-02-19 21:50:30 +00:00
|
|
|
Currently, only metadata used for visible subdirs is added and removed
|
|
|
|
this way.
|
2014-02-11 08:15:33 +00:00
|
|
|
Also, this is not usable in direct mode because deleting the
|
|
|
|
file.. actually deletes it.
|
2014-02-19 21:50:30 +00:00
|
|
|
* If a file is moved into a new subdirectory while in a view branch,
|
2014-02-11 15:37:53 +00:00
|
|
|
a tag is added with the subdir name. This allows on the fly tagging.
|
2014-02-19 21:50:30 +00:00
|
|
|
**done**
|
|
|
|
* `git annex sync` should avoid pushing out the view branch, but
|
2014-02-11 08:15:33 +00:00
|
|
|
it should check if there are changes to the metadata pulled in, and update
|
|
|
|
the branch to reflect them.
|
2014-02-19 21:50:30 +00:00
|
|
|
* TODO: If `git annex add` adds a file, it gets all the metadata of the filter
|
2014-02-11 08:15:33 +00:00
|
|
|
branch it's added to. If it's in a relevent directory (like fosdem-2014),
|
|
|
|
it gets that metadata automatically recorded as well.
|
|
|
|
|
2014-02-20 17:00:05 +00:00
|
|
|
## automatically added metadata
|
|
|
|
|
|
|
|
TODO git annex add should automatically attach the current mtime of a file
|
|
|
|
when adding it.
|
|
|
|
|
|
|
|
Could also automatically attach permissions.
|
|
|
|
|
|
|
|
TODO A git hook could be run by git annex add to gather more metadata.
|
|
|
|
For example, by examining MP3 metadata.
|
|
|
|
|
|
|
|
Also auto add metadata when adding files to view branches. See below.
|
|
|
|
|
|
|
|
## derived metadata
|
|
|
|
|
|
|
|
This is probably not stored anywhere. It's computed on demand by a pure
|
|
|
|
function from the other metadata.
|
|
|
|
(Should be a general mechanism for this. (It probably generalizes to
|
|
|
|
sql queries if we want to go that far.))
|
|
|
|
|
|
|
|
### data metadata
|
|
|
|
|
|
|
|
TODO From the ctime, some additional
|
|
|
|
metadata is derived, at least year=yyyy and probably also month, etc.
|
|
|
|
|
|
|
|
### directory hierarchy metadata
|
|
|
|
|
2014-02-22 20:09:00 +00:00
|
|
|
From the original filename used in the master branch, when
|
2014-02-20 17:00:05 +00:00
|
|
|
constructing a view, generate fields. For example foo/bar/baz.mp3
|
2014-02-20 20:36:30 +00:00
|
|
|
would get /=foo, foo/=bar, foo/bar/=baz, and .=mp3.
|
2014-02-20 17:00:05 +00:00
|
|
|
|
2014-02-20 20:36:30 +00:00
|
|
|
Note that dir/=subdir allows a view to use `dir/=*` and only
|
2014-02-20 17:00:05 +00:00
|
|
|
match one level of subdirs with the glob. So is better than dir=foo/bar
|
|
|
|
as the metadata. (Alternatively, could do special glob matching.)
|
|
|
|
|
|
|
|
This allows using whatever directory hierarchy exists to inform the view,
|
|
|
|
without locking the view into using it.
|
|
|
|
|
|
|
|
Complication: When refining a view, it only looks at the filenames in
|
2014-02-22 20:09:00 +00:00
|
|
|
the view, so it has to map from
|
2014-02-20 17:00:05 +00:00
|
|
|
those filenames to derive the same metadata, unless there is persistent
|
|
|
|
storage. Luckily, the filenames used in the views currently include the
|
2014-02-22 20:09:00 +00:00
|
|
|
subdirs.
|
|
|
|
|
|
|
|
**done**!
|
2014-02-20 17:00:05 +00:00
|
|
|
|
2014-02-11 08:15:33 +00:00
|
|
|
# other uses for metadata
|
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
Uses are not limited to view branches.
|
2014-02-11 08:15:33 +00:00
|
|
|
|
|
|
|
`git annex checkoutmeta year=2014 talk` in a subdir of master could create the
|
|
|
|
same tree of files filter would. The user can then commit that if desired.
|
|
|
|
Or, they could run additional commands like `git annex fadd` to refine the
|
|
|
|
tree of files in the subdir.
|
|
|
|
|
2014-02-11 15:37:53 +00:00
|
|
|
Metadata can be used for configuring numcopies. One way would be a
|
|
|
|
numcopies=n value attached to a file. But perhaps better would be to make
|
|
|
|
the numcopies.log allow configuring numcopies based on which files have
|
|
|
|
other metadata.
|
|
|
|
|
2014-02-11 08:15:33 +00:00
|
|
|
Other programs could query git-annex for the metadata of files in the work
|
|
|
|
tree, and do whatever it wants with it.
|
|
|
|
|
|
|
|
# filenames
|
|
|
|
|
|
|
|
The hard part of this is actually getting a useful filename to put in the
|
2014-02-19 21:50:30 +00:00
|
|
|
view branch, since git-annex only has a key which the user will not
|
2014-02-11 08:15:33 +00:00
|
|
|
want to see.
|
|
|
|
|
|
|
|
* Could use filename metadata for the key, recorded by git-annex add (which
|
|
|
|
may not correspond to filenames being used in regular git branches like
|
|
|
|
master for the key).
|
2014-02-11 15:37:53 +00:00
|
|
|
* Could use the .map files to get a filename, but this is somewhat
|
2014-02-11 08:15:33 +00:00
|
|
|
arbitrary (.map can contain multiple filenames), and is only
|
|
|
|
currently supported in direct mode.
|
2014-02-19 21:50:30 +00:00
|
|
|
* Current approach: Have a reference branch (eg master) and walk it to
|
|
|
|
find filenames and
|
2014-02-13 15:39:03 +00:00
|
|
|
keys. Fine as long as it can be done efficiently. Also allows including
|
|
|
|
the subdirectory a file is in, potentially. cwebber points out that this
|
|
|
|
is essentially a form of tracking branch. Which implies it will need to
|
|
|
|
be updatable when the reference branch changes. Should be doable via
|
|
|
|
diff-tree.
|
2014-02-11 08:15:33 +00:00
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
Note that we have to take care to avoid generating conflicting filenames.
|
|
|
|
The current approach is to embed the full directory structure inside the
|
|
|
|
filename in the view branch.
|
2014-02-11 15:37:53 +00:00
|
|
|
|
2014-02-12 21:54:28 +00:00
|
|
|
## union merge properties
|
|
|
|
|
|
|
|
While the storage could just list all the current values of a field on a
|
|
|
|
line with a timestamp, that's not good enough. Two disconnected
|
|
|
|
repositories can make changes to the values of a field (setting and
|
|
|
|
unsetting tags for example) and when this is union merged back together,
|
|
|
|
the changes need to be able to be replayed in order to determine which
|
|
|
|
values we end up with.
|
|
|
|
|
|
|
|
To make that work, we log not only when a field is set to a value,
|
|
|
|
but when a value is unset as well.
|
|
|
|
|
|
|
|
For example, here two different remotes added tags, and then later
|
|
|
|
a tag was removed:
|
|
|
|
|
|
|
|
1287290776.765152s tag +foo +bar
|
|
|
|
1287290991.152124s tag +baz
|
|
|
|
1291237510.141453s tag -bar
|
|
|
|
|
2014-02-11 08:15:33 +00:00
|
|
|
# efficient metadata lookup
|
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
Looking up metadata for view generation so far requires traversing all keys
|
|
|
|
in the git-annex branch. This is slow. A fast cache is needed.
|
|
|
|
|
|
|
|
TODO
|
2014-02-11 15:37:53 +00:00
|
|
|
|
|
|
|
# direct mode issues
|
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
TODO (direct mode is currently not supported with view branches)
|
|
|
|
|
|
|
|
Checking out a view branch can result in any number of copies of a file
|
2014-02-11 15:37:53 +00:00
|
|
|
appearing in different directories. No problem in indirect mode, but
|
|
|
|
in direct mode these are real, expensive copies.
|
|
|
|
|
|
|
|
But, it's worth supporting direct mode!
|
|
|
|
|
|
|
|
So, possible approaches:
|
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
* Before checking out a view branch, calculate how much space will
|
2014-02-11 15:37:53 +00:00
|
|
|
be used by duplicates and refuse if not enough is free.
|
|
|
|
* Only check out one file, and omit the copies. Keep track of which
|
|
|
|
files were omitted, and make sure that when committing on the branch,
|
|
|
|
that metadata is not removed. Has the downside that files can seem
|
|
|
|
to randomly move around in the tree as their metadata changes.
|
2014-02-19 21:50:30 +00:00
|
|
|
* Disallow view branch checkouts that have duplicate files.
|
2014-02-11 15:40:09 +00:00
|
|
|
This would cripple it some, but perhaps not too badly?
|
2014-02-11 15:37:53 +00:00
|
|
|
|
|
|
|
# gotchas
|
|
|
|
|
2014-02-19 21:50:30 +00:00
|
|
|
* Checking out a view branch can remove the current subdir. May be worth
|
|
|
|
detecting when this happens and help the user.
|
|
|
|
**done**
|
2014-02-11 15:37:53 +00:00
|
|
|
|
|
|
|
* Git has a complex set of rules for what is legal in a ref name.
|
2014-02-19 21:50:30 +00:00
|
|
|
View branch names will need to filter out any illegal stuff. **done**
|
2014-02-11 15:37:53 +00:00
|
|
|
|
|
|
|
* Filesystems that are not case sensative (including case preserving OSX)
|
2014-02-19 21:50:30 +00:00
|
|
|
will cause problems if view branches try to use different cases for
|
2014-02-11 15:37:53 +00:00
|
|
|
2 directories representing the value of some metadata. But, users
|
|
|
|
probably want at least case-preserving metadata values.
|
|
|
|
|
|
|
|
Solution might be to compare metadata case-insensitively, and
|
|
|
|
pick one representation consistently, so if, for example an author
|
2014-02-19 21:50:30 +00:00
|
|
|
field uses mixed case, it will be used in the view branch.
|
2014-02-11 15:37:53 +00:00
|
|
|
|
|
|
|
Alternatively, it could escape `A` to `_A` when such a filesystem
|
|
|
|
is detected and avoid collisions that way (double `_` to escape it).
|
|
|
|
This latter option is ugly, but so are non-posix filesystems.. and it
|
|
|
|
also solves any similar issues with case-colliding filenames.
|
2014-02-19 21:50:30 +00:00
|
|
|
|
|
|
|
TODO: Check current state of this.
|
2014-02-20 16:34:11 +00:00
|
|
|
|
|
|
|
* Assistant needs to know about views, so it can update metadata when
|
|
|
|
files are moved around inside them. TODO
|
2014-02-20 16:37:28 +00:00
|
|
|
|
|
|
|
* What happens if git annex add or the assistant add a new file while on a
|
|
|
|
view? If the file is not also added to the master branch, it will be lost
|
|
|
|
when exiting the view. TODO
|
2014-02-22 20:37:13 +00:00
|
|
|
|
|
|
|
* The filename mangling can result in a filename in a view
|
|
|
|
that is too long for its containing filesystem. Should detect and do
|
|
|
|
something reasonable to avoid. TODO
|