[darcs-users] Re: File/Directory Metadata

Michael Conrad conradme at email.uc.edu
Sun Nov 14 20:15:02 UTC 2004


On Sunday, November 14, 2004, Mark Stosberg wrote:

> On 2004-11-14, Michael Conrad <conradme at email.uc.edu> wrote:
...
> > *** Minor instant brainstorm
> > What if darcs had the ability to run a script on applying a patch (as
> > suggested previously) and the meta tags were defined as environment
> > variables while running the script for a given file!  This would make it
> > trivial to set the permissions for a file:
> >
> >   #!/bin/sh
> >   chmod $unix_perm $CURRENT_FILE
>
> Something like this can be done with darcs now (although I haven't tried
it).
>
> 1. move the 'darcs' binary to 'darcs-bin'
> 2. Create a script named 'darcs' that adds the hooks you want.
>
> You wouldn't have access to $CURRENT_FILE and other bits as in your
> example, but you could run scripts like you want on the whole repo to
> 'fix' line endings and perms, etc.

Ok, well I've been giving it some thought, and I think all these features
that I've mentioned are possible with scripts.  Here's how it would work:

First, to maintain the metadata, I would create a file of the form
  .metadata.filename.meta-tag-name
and write the value of the tag into this file.  By using one file per tag,
they would never depend on eachother unless the tag itself changes.  I would
then make a script called
  darcsmeta [-r] <tag>[=<value>] <filename> [...]
which would operate on these files.

I would also need a scrit
  darcsmv <filename> [...] <destination>
that would run 'darcs mv' on files and additionally move all their meta tags
with them.

I would also write a script called
  darcsquerymeta [--current]
which would print all the metadata associated with a file or directory in
name=value format.  The 'current' switch would get these from the metadata
files in 'current'.

I would then write a darcs wrapper script as suggested by Mark which would
have 'preprocess' and 'postprocess' functions which would run before and
after every darcs command that operates on the working copy.  Postprocess
would go through and apply changes to the files based on the meta tags after
every darcs operation.  Preprocess would go through and undo any changes
that would be noticible to darcs (such as line endings) before every darcs
operation.  I would also need a flag in my darcsmeta script to check the
metadata of the 'current' copy, so that I know what operations to undo.

These functions would need to traverse the entire repo every time, since
darcs does also.  They would end up being invoked for every 'whatsnew',
every 'revert', every 'record', every 'apply', etc.

And, hopefully, everyone can smell the stench of this kluge from miles away,
making my case for why this should be at least partially built-in to darcs
:-)

-Mike





More information about the darcs-users mailing list