Commit graph

233 commits

Author SHA1 Message Date
Joey Hess
0d5c402210 Add annex-trustlevel configuration settings, which can be used to override the trust level of a remote.
This overrides the trust.log, and is overridden by the command-line trust
parameters.

It would have been nicer to have Logs.Trust.trustMap just look up the
configuration for all remotes, but a dependency loop prevented that
(Remotes depends on Logs.Trust in several ways). So instead, look up
the configuration when building remotes, storing it in the same forcetrust
field used for the command-line trust parameters.
2012-01-09 23:31:44 -04:00
Joey Hess
0a36f92a31 more command-specific options
Made --from and --to command-specific options.

Added generic storage for values of command-specific options,
which allows removing some of the special case fields in AnnexState.

(Also added generic storage for command-specific flags, although there are
not yet any.)

Note that this storage uses a Map, so repeatedly looking up the same value
is slightly more expensive than looking up an AnnexState field. But, the
value can be looked up once in the seek stage, transformed as necessary,
and passed in a closure to the start stage, and this avoids that overhead.

Still, I'm hesitant to use this for things like force or fast flags.
It's probably best to reserve it for flags that are only used by a few
commands, or options like --from and --to that it's important only be
allowed to be used with commands that implement them, to avoid user
confusion.
2012-01-06 03:16:42 -04:00
Joey Hess
25e4b116c7 type alias 2011-12-31 04:19:10 -04:00
Joey Hess
4a02c2ea62 type alias cleanup 2011-12-31 04:11:58 -04:00
Joey Hess
6d4382a89e Merge branch 'new-monad-control' 2011-12-24 23:02:42 -04:00
Joey Hess
06bafae9e0 Format strings can be specified using the new --find option, to control what is output by git annex find. 2011-12-22 18:31:44 -04:00
Joey Hess
3d188d8db9 fix comment 2011-12-20 16:03:09 -04:00
Joey Hess
ee3b5b2a42 use Common in a few more modules 2011-12-20 14:37:53 -04:00
Joey Hess
13fff71f20 split out three modules from Git
Constructors and configuration make sense in separate modules.
A separate Git.Types is needed to avoid cycles.
2011-12-13 15:06:49 -04:00
Joey Hess
e04852c8af Merge branch 'master' into new-monad-control
Conflicts:
	git-annex.cabal
2011-12-11 16:55:36 -04:00
Joey Hess
e3f1568e0f Fix caching of decrypted ciphers, which failed when drop had to check multiple different encrypted special remotes. 2011-12-08 16:01:46 -04:00
Joey Hess
5e7e873853 the Annex newtype is back
Thanks to Bas van Dijk for providing the instance declarations I needed.
Grody stuff. Bas is talking about perhaps providing utility functions that
contain the ugly parts, so this code may be able to be removed using a
future version of monad-control.
2011-12-06 11:43:30 -04:00
Joey Hess
f3a2f60abc adjust to build with monad-control-0.3
I had to, I hope temporarily, lose my nice Annex newtype, and use a type
synonym. This because I cannot find a way to derive a MonadBaseControl
instance of the Annex newtype. I've emailed Bas van Dijk in hope he can
help get the newtype back.

Otherwise appears to build & work.
2011-12-05 22:51:37 -04:00
Joey Hess
7f7ae7a3b1 find: Support --print0
It would be nice if command-specific options were supported. The first
difficulty is that which command is being called is not known until after
getopt; but that could be worked around by finding the first non-dashed
parameter. Storing the settings without putting them in the annex monad is
the next difficulty; it could perhaps be handled by making the seek stage
pass applicable settings into the start stage (and from there on to perform
as needed). But that still leaves a problem, what data type to use to
represent the options between getopt and seek?
2011-11-22 14:06:31 -04:00
Joey Hess
30f1aeb13c golf 2011-11-12 14:24:07 -04:00
Joey Hess
56b8194470 cleanup 2011-11-09 01:33:20 -04:00
Joey Hess
bf460a0a98 reorder repo parameters last
Many functions took the repo as their first parameter. Changing it
consistently to be the last parameter allows doing some useful things with
currying, that reduce boilerplate.

In particular, g <- gitRepo is almost never needed now, instead
use inRepo to run an IO action in the repo, and fromRepo to get
a value from the repo.

This also provides more opportunities to use monadic and applicative
combinators.
2011-11-08 16:27:20 -04:00
Joey Hess
380839299e The fromkey command now takes the key as its first parameter. The --key option is no longer used. 2011-10-31 12:56:07 -04:00
Joey Hess
c30366e95a improve config reading when operating on remote on same host
Before the config was read each time onLocal was called, and entirely
redundantly since it's read for same-host remotes on startup.

Also a minor bug fix: When rsyncing to a same-host remote, use the
rsync-options from the repository that the user ran git-annex in, not those of
the receiving repository.
2011-10-27 14:55:06 -04:00
Joey Hess
8ef2095fa0 factor out common imports
no code changes
2011-10-03 23:29:48 -04:00
Joey Hess
ad245a6375 refactor catfile code
split into generic IO code, and a thin Annex wrapper
2011-09-28 15:17:36 -04:00
Joey Hess
dd463a3100 rework annex-ignore handling
Only one place need to filter the list of remotes for ignored remotes:
keyPossibilities. Make the full list available to everything else.

This allows getting rid of the special case handing for --from and --to
to make ignored remotes not be ignored with those options.
2011-09-18 20:11:39 -04:00
Joey Hess
8a5a92480b refactor --exclude to use Utility.Matcher
This should change no behavior, but opens the poissibility to use the
matcher for other sorts of limits on which files git-annex processes.
2011-09-18 17:47:49 -04:00
Joey Hess
984c9fc052 remove optimize subcommand; use --auto instead
get, drop: Added --auto option, which decides whether to get/drop content
as needed to work toward the configured numcopies.

The problem with bundling it up in optimize was that I then found I wanted
to run an optmize that did not drop files, only got them. Considered adding
a --only-get switch to it, but that seemed wrong. Instead, let's make
existing subcommands optionally smarter.

Note that the only actual difference between drop and drop --auto is that
the latter does not even try to drop a file if it knows of not enough
copies, and does not print any error messages about files it was unable to
drop.

It might be nice to make get avoid asking git for attributes when not in
auto mode. For now it always asks for attributes.
2011-09-15 13:30:04 -04:00
Joey Hess
2f4d4d1c45 basic json support
This includes a generic JSONStream library built on top of Text.JSON
(somewhat hackishly).

It would be possible to stream out a single json document describing
all actions, but it's probably better for consumers if they can expect
one json document per line, so I did it that way instead.

Output from external programs used for transferring files is not
currently hidden when outputting json, which probably makes it not very
useful there. This may be dealt with if there is demand for json
output for --get or --move to be parsable.

The version, status, and find subcommands have hand-crafted output and
don't do json. The whereis subcommand needs to be modified to produce
useful json.
2011-09-01 15:22:06 -04:00
Joey Hess
57dd34c6be generalize quiet flag to output type
This will allow adding other styles of output.
2011-09-01 13:35:07 -04:00
Joey Hess
678726c10c code simplification thanks to applicative functors 2011-08-25 01:27:19 -04:00
Joey Hess
4c73d77b42 avoid the functor
fmap = liftM
2011-08-21 14:59:34 -04:00
Joey Hess
e3ca08fad8 drop an unnecessart liftIO
the liftM on its own can lift all the way into IO.
2011-08-19 14:36:52 -04:00
Joey Hess
021e8e1e0e make Annex an opaque data type
Was a type alias; using newtype has the benefit that type errors will
show "Annex foo" rather than two lines of internal type nonsense. Yay!
There should be no other effects to size or runtime.

I've tried to do this at least twice before (each time I read RWH chapter 10);
finally understood how to this time.. sorta.
2011-08-19 14:28:07 -04:00
Joey Hess
9f1577f746 remove unused backend machinery
The only remaining vestiage of backends is different types of keys. These
are still called "backends", mostly to avoid needing to change user interface
and configuration. But everything to do with storing keys in different
backends was gone; instead different types of remotes are used.

In the refactoring, lots of code was moved out of odd corners like
Backend.File, to closer to where it's used, like Command.Drop and
Command.Fsck. Quite a lot of dead code was removed. Several data structures
became simpler, which may result in better runtime efficiency. There should
be no user-visible changes.
2011-07-05 19:57:46 -04:00
Joey Hess
f0497312a7 rename GitQueue to Git.Queue 2011-06-30 13:25:37 -04:00
Joey Hess
f6063a094e renamed GitRepo to Git
It was always imported qualified as Git anyway
2011-06-30 13:21:39 -04:00
Joey Hess
69d3c1cec9 cache the trustmap
Doubles the speed of fsck, and speeds up drop as well.
2011-06-23 21:25:39 -04:00
Joey Hess
8166facaef Branch handling improvements
Support creating the branch.

Unified branch state into a single data type.

Only commit changes when the index has been changed.
2011-06-22 15:58:30 -04:00
Joey Hess
78a325b093 add a small cache of the most recently accessed item from the git-annex branch
This will speed up typical cases like git-annex get, which currently
has to read the location log once, then read it a second time in order to
add a line to it. Since these reads now involve more than just reading
in a file, it seemed good to add a cache layer.

Only the most recent thing needs to be cached, because git-annex has
good locality; it operates on one file at a time, and only cares
about one item from the branch per file.
2011-06-22 14:18:49 -04:00
Joey Hess
c03af0ed0c code to update a git-annex branch
There is no suitable git hook to run code when pulling changes that
might need to be merged into the git-annex branch. The post-merge hook
is only run when changes are merged into HEAD, and it's possible,
and indeed likely that many pulls will only have changes in git-annex,
but not in HEAD, and not trigger it.

So, git-annex will have to take care to update the branch before reading
from it, to make sure it has merged in current info from remotes. Happily,
this can be done quite inexpensively, just a git-show-ref to list
branches, and a minimalized git-log to see if there are unmerged changes
on the branches. To further speed up, it will be done only once per
git-annex run, max.
2011-06-21 14:33:59 -04:00
Joey Hess
bc731ba6e0 pointless golfing 2011-06-20 21:37:18 -04:00
Joey Hess
703c437bd9 rename modules for data types into Types/ directory 2011-06-01 21:56:04 -04:00
Joey Hess
971ab27e78 better types allowed breaking module dep loop 2011-06-01 19:11:27 -04:00
Joey Hess
a8fb97d2ce Add --trust, --untrust, and --semitrust options. 2011-06-01 17:57:31 -04:00
Joey Hess
3d567aa64f Add --numcopies option. 2011-06-01 16:49:17 -04:00
Joey Hess
cd83541872 --backend now overrides any backend configured in .gitattributes files. 2011-05-18 19:34:46 -04:00
Joey Hess
6aab88fa25 more monadic operator use 2011-05-15 15:27:49 -04:00
Joey Hess
33d23a4ef9 Control.Monad.State import fix for debian stable
It doesn't export `state` there, so hiding it fails. Just list explicitly
what we use.
2011-04-26 19:42:40 -04:00
Joey Hess
43639f69f6 ghc7
* Update Debian build dependencies for ghc 7.
* Debian package is now built with S3 support. Thanks Joachim Breitner for
  making this possible, also thanks Greg Heartsfield for working to improve
  the hS3 library for git-annex.

Also hid a conflicting new symbol from Control.Monad.State
2011-04-21 02:22:40 -04:00
Joey Hess
9fe7e6be70 add cipher field to AnnexState 2011-04-16 16:41:46 -04:00
Joey Hess
bc51387e6d Periodically flush git command queue, to avoid boating memory usage too much.
Since the queue is flushed in between subcommand actions being run,
there should be no issues with actions that expect to queue up some stuff
and have it run after they do other stuff. So I didn't have to audit for
such assumptions.
2011-04-07 13:59:31 -04:00
Joey Hess
6b5918c295 some reorg and further remote generalization 2011-03-27 21:43:25 -04:00
Joey Hess
f30320aa75 add remotes slot to Annex
This required parameterizing the type for Remote, to avoid a cycle.
2011-03-27 16:17:56 -04:00
Joey Hess
c21998722c fast mode
Add --fast flag, that can enable less expensive, but also less thurough versions of some commands.

* Add --fast flag, that can enable less expensive, but also less thurough
  versions of some commands.
* fsck: In fast mode, avoid checking checksums.
* unused: In fast mode, just show all existing temp files as unused,
  and avoid expensive scan for other unused content.
2011-03-22 17:41:06 -04:00
Joey Hess
bc21502b9a use queue when upgrading, flushing every so often
Added a cheap way to query the size of a queue.

runQueueAt is not the default yet only because there may be some code that
expects to be able to queue some suff, do something else, and run the whole
queue at the end.

10240 is an arbitrary size for the queue. If we assume annexed
filenames are between 10 and 255 characters long, then the queue will
build up between 100kb and 2550kb long commands. The max command line
length on linux is somewhere above 20k, so this is a fairly good balance --
the queue will buffer only a few megabytes of stuff and a minimal number
of commands will be run by xargs.

Also, insert queue items strictly, this should save memory.
2011-03-16 15:10:15 -04:00
Joey Hess
4594bd51c1 rename file 2011-03-15 22:04:50 -04:00
Joey Hess
aad1372880 move repoConfig out of Remotes 2011-03-05 15:31:46 -04:00
Joey Hess
4cd96ad2db rename 2011-02-28 16:25:31 -04:00
Joey Hess
fcdc4797a9 use ShellParam type
So, I have a type checked safe handling of filenames starting with dashes,
throughout the code.
2011-02-28 16:18:55 -04:00
Joey Hess
dd0f662849 hello, liftM 2011-02-19 17:00:40 -04:00
Joey Hess
616d1d4a20 rename TypeInternals to BackendTypes
Now that it only contains types used by the backends
2011-01-26 00:37:50 -04:00
Joey Hess
6a97b10fcb rework config storage
Moved away from a map of flags to storing config directly in the AnnexState
structure. Got rid of most accessor functions in Annex.

This allowed supporting multiple --exclude flags.
2011-01-26 00:17:38 -04:00
Joey Hess
082b022f9a successfully split Annex and AnnexState out of TypeInternals 2011-01-25 21:49:04 -04:00
Joey Hess
109a719b03 parameterize Backend type
This allows the Backend type to not depend on the Annex type, and
so the Annex type can later be moved out of TypeInternals.
2011-01-25 21:02:34 -04:00
Joey Hess
8d6da87eec better types 2011-01-11 18:13:26 -04:00
Joey Hess
eac433a84a use git-annex-shell configlist 2010-12-31 15:46:33 -04:00
Joey Hess
6a5be9d53c rename some stuff and prepare to break out more into Command/* 2010-12-30 14:19:16 -04:00
Joey Hess
c281747b0e add queueRun 2010-11-08 16:40:02 -04:00
Joey Hess
ab4de45491 Add annex.version, which will be used to automate upgrades. 2010-11-08 14:39:12 -04:00
Joey Hess
a3519c365f hlinted a few files 2010-11-06 17:07:11 -04:00
Joey Hess
99c522edef finished adding support for annex.ssh-options 2010-11-01 00:04:53 -04:00
Joey Hess
00d4c7cd01 simplify evals 2010-10-31 23:24:16 -04:00
Joey Hess
1576c48c80 more Wall cleaning 2010-10-31 14:32:18 -04:00
Joey Hess
045b051ec1 got rid of almost all 'return ()' 2010-10-28 12:40:05 -04:00
Joey Hess
833d4b342e copyright statements 2010-10-27 16:53:54 -04:00
Joey Hess
ef26076a5a add git queue to Annex monad
not used anywhere just yet..
2010-10-26 15:59:50 -04:00
Joey Hess
19fde4960d new fromkey subcommand, for registering urls, etc
had to redo Annex monad's flag storage
2010-10-21 16:30:16 -04:00
Joey Hess
f3dcc8489d gratuitous rename 2010-10-18 02:06:27 -04:00
Joey Hess
98676928c8 prune 2010-10-17 12:09:52 -04:00
Joey Hess
b471822cfe move supportedBackends list into annex monad
This was necessary so the File backend could import Backend w/o a cycle.

Moved code that checks whether enough backends have a file into File
backend.
2010-10-17 11:47:36 -04:00
Joey Hess
909f619c07 tweaks 2010-10-16 16:20:49 -04:00
Joey Hess
bbbe9858fe avoid empty commits 2010-10-14 23:52:45 -04:00
Joey Hess
29039fdf97 add flags, and change to subcommand style 2010-10-14 21:10:59 -04:00
Joey Hess
aa2f4bd810 bug 2010-10-14 16:13:43 -04:00
Joey Hess
6f3572e47f more reorg, spiffed up state monad 2010-10-14 03:18:11 -04:00
Joey Hess
4c1d8b9689 more namespace cleanup 2010-10-14 02:41:54 -04:00
Joey Hess
48643b68b3 convert GitRepo to qualified import 2010-10-14 02:36:41 -04:00
Joey Hess
eda80e44c5 add module that only exports abstract types 2010-10-14 02:12:41 -04:00
Joey Hess
89654751da bugfix 2010-10-13 21:35:10 -04:00
Joey Hess
b160748516 use a state monad
enormous reworking
2010-10-13 21:28:47 -04:00
Joey Hess
f87c5ed949 copying almost working 2010-10-13 16:21:50 -04:00
Joey Hess
e28ff5bdaf almost able to get files from remotes now! 2010-10-13 15:55:18 -04:00
Joey Hess
77055f5ff8 move some stuff out of IO 2010-10-13 14:51:09 -04:00
Joey Hess
771a6b36e1 cost ordering 2010-10-13 14:40:56 -04:00
Joey Hess
1dbf36bf9a cleanup3 2010-10-13 03:51:55 -04:00
Joey Hess
ff998a9a67 cleanup2 2010-10-13 03:46:40 -04:00
Joey Hess
99b2029236 key conversion back from file bugfixes 2010-10-13 03:41:12 -04:00
Joey Hess
cc5cf0093e cleanup 2010-10-13 03:30:51 -04:00
Joey Hess
4b801b265a error handling 2010-10-13 03:20:05 -04:00
Joey Hess
d1071bd1fe autobugfixing!
Converted Key to a real data type and caught all the places where I used
an unconverted filename as a key.

Had to loose some sanity checks around whether something is already
annexed, but I guess I can add those back other ways.
2010-10-13 02:31:24 -04:00
Joey Hess
4ecebfb218 bugfx 2010-10-13 01:43:24 -04:00
Joey Hess
3a18b6d2ae bugfix 2010-10-13 01:42:39 -04:00
Joey Hess
3e65384f06 fix relative symlink 2 2010-10-13 01:36:20 -04:00
Joey Hess
67ae9d7fa1 relative symlink to annexed file 2010-10-13 00:58:59 -04:00
Joey Hess
14d7b2ac13 update 2010-10-13 00:45:09 -04:00
Joey Hess
208bba8d30 got rid of the .git-annex/key.backend files 2010-10-13 00:42:46 -04:00
Joey Hess
b7858ada03 bugfixes 2010-10-12 20:04:36 -04:00
Joey Hess
3b89924f53 record annexed files in log 2010-10-12 18:25:41 -04:00
Joey Hess
10992b90c9 avoid redownload 2010-10-12 17:56:29 -04:00
Joey Hess
a36c39ad0a getting files via http working! 2010-10-12 17:26:34 -04:00
Joey Hess
cad916d926 hookup annexgetfile 2010-10-12 16:52:01 -04:00
Joey Hess
603e01e96c simplify some function signatures using state 2010-10-12 16:20:41 -04:00
Joey Hess
2ac47a3a59 thread State thru to backends 2010-10-12 16:06:10 -04:00
Joey Hess
759f146d0f update 2010-10-12 15:52:18 -04:00
Joey Hess
d257bad93c uuid type 2010-10-12 15:48:00 -04:00
Joey Hess
e53900a545 stub 2010-10-12 15:44:54 -04:00
Joey Hess
4fbdb197d5 correctness 2010-10-12 13:12:47 -04:00
Joey Hess
dc1d5e6831 update 2010-10-12 13:10:07 -04:00
Joey Hess
ea5d7fe07a add uuid 2010-10-12 13:02:41 -04:00
Joey Hess
8f069bd287 tweak 2010-10-12 02:40:09 -04:00
Joey Hess
92bf408c66 faddle 2010-10-12 00:53:42 -04:00
Joey Hess
cd1e39b127 moved config reading into GitRepo 2010-10-11 23:22:38 -04:00
Joey Hess
104fe9132a cleanup 2010-10-11 18:15:05 -04:00
Joey Hess
ebc3fbe9ae explicit exports 2010-10-11 17:52:46 -04:00
Joey Hess
af82586adf split up Types 2010-10-11 17:19:55 -04:00
Joey Hess
779ebba961 adjust merge config
*.log will merge, but foo.$backend files will not
2010-10-11 00:22:50 -04:00
Joey Hess
2bd3eea031 add git config lookups for annex.name, annex.backends, etc 2010-10-11 00:19:38 -04:00
Joey Hess
c5d7ca0a5a use Data.Time instead of Data.DateTime
The latter has shady rounding. The new module is a bit harder to use, but
worth it, it adds subsecond timestamps too.
2010-10-10 22:22:53 -04:00
Joey Hess
200bc6fdb8 better option handling
multiple-file support for all modes
2010-10-10 21:00:42 -04:00
Joey Hess
344f13394f update 2010-10-10 19:53:31 -04:00
Joey Hess
586266e444 robustness 2010-10-10 19:00:08 -04:00
Joey Hess
026adce5a0 update 2010-10-10 18:25:31 -04:00
Joey Hess
e5514e0cb0 update 2010-10-10 18:05:37 -04:00
Joey Hess
dce9c2e080 convert GitRepo to struct with constructor 2010-10-10 16:06:36 -04:00
Joey Hess
4631927a5c fix storing files in .git/annex by key 2010-10-10 15:21:17 -04:00
Joey Hess
f4d2a05e86 got annexing working 2010-10-10 15:04:07 -04:00