Commit graph

637 commits

Author SHA1 Message Date
Joey Hess
1c0bd81ba6 addurl: Normalize badly encoded urls. 2012-02-09 14:19:58 -04:00
Joey Hess
ac97454659 improve error message 2012-02-08 15:49:42 -04:00
Joey Hess
ef013506cb addurl: Added a --file option
Can be used to specify what file the url is added to. This can be used to
override the default filename that is used when adding an url, which is
based on the url. Or, when the file already exists, the url is recorded as
another location of the file.
2012-02-08 15:35:29 -04:00
Joey Hess
a81297065d use "known" instead of "visible"
I think it's clearer, also it's the same length as "local" :)
2012-02-06 20:42:49 -04:00
Joey Hess
90ab17e153 remove old comment 2012-02-04 16:34:13 -04:00
Joey Hess
f1c7dc1212 fix touch and statfs to work on any files in any locale
Use withCAString rather than withCString.

XXX Actually, this only works in non-unicode locales when presented with
unicode characters. Help?
2012-02-04 12:44:51 -04:00
Joey Hess
44b115e0b1 Merge branch 'master' into ghc7.4
Conflicts:
	Utility/Misc.hs
2012-02-03 16:48:40 -04:00
Joey Hess
146c36ca54 IO exception rework
ghc 7.4 comaplains about use of System.IO.Error to catch exceptions.
Ok, use Control.Exception, with variants specialized to only catch IO
exceptions.
2012-02-03 16:47:24 -04:00
Joey Hess
d8fb97806c support all filename encodings with ghc 7.4
Under ghc 7.4, this seems to be able to handle all filename encodings
again. Including filename encodings that do not match the LANG setting.
I think this will not work with earlier versions of ghc, it uses some ghc
internals.

Turns out that ghc 7.4 has a special filesystem encoding that it uses when
reading/writing filenames (as FilePaths). This encoding is documented
to allow  "arbitrary undecodable bytes to be round-tripped through it".

So, to get FilePaths from eg, git ls-files, set the Handle that is reading
from git to use this encoding. Then things basically just work.

However, I have not found a way to make Text read using this encoding.
Text really does assume unicode. So I had to switch back to using String
when reading/writing data to git. Which is a pity, because it's some
percent slower, but at least it works.

Note that stdout and stderr also have to be set to this encoding, or
printing out filenames that contain undecodable bytes causes a crash.
IMHO this is a misfeature in ghc, that the user can pass you a filename,
which you can readFile, etc, but that default, putStr of filename may
cause a crash!

Git.CheckAttr gave me special trouble, because the filenames I got back
from git, after feeding them in, had further encoding breakage.
Rather than try to deal with that, I just zip up the input filenames
with the attributes. Which must be returned in the same order queried
for this to work.

Also of note is an apparent GHC bug I worked around in Git.CheckAttr. It
used to forkProcess and feed git from the child process.  Unfortunatly,
after this forkProcess, accessing the `files` variable from the parent
returns []. Not the value that was passed into the function. This screams
of a bad bug, that's clobbering a variable, but for now I just avoid
forkProcess there to work around it. That forkProcess was itself only added
because of a ghc bug, #624389. I've confirmed that the test case for that
bug doesn't reproduce it with ghc 7.4. So that's ok, except for the new ghc
bug I have not isolated and reported. Why does this simple bit of code
magnet the ghc bugs? :)

Also, the symlink touching code is currently broken, when used on utf-8
filenames in a non-utf-8 locale, or probably on any filename containing
undecodable bytes, and I temporarily commented it out.
2012-02-03 16:23:20 -04:00
Joey Hess
3d49258e5b attempt at a quick, utf-8 only fix to the ghc 7.4 problem
If you have only utf-8 filenames, and need to build git-annex with ghc 7.4,
this will work. But, it will crash on non-utf-8 filenames.
2012-02-01 16:16:08 -04:00
Joey Hess
a964012fc3 switch to the strict state monad
I had not realized what a memory leak the lazy state monad could be,
although I have not seen much evidence of actual leaking in git-annex.
However, if running git-annex on a great many files, this could matter.

The additional Utility.State.changeState adds even more strictness,
avoiding a problem I saw in github-backup where repeatedly modifying
state built up a huge pile of thunks.
2012-01-29 22:55:06 -04:00
Joey Hess
b81d662cbf Avoid repeated location log commits when a remote is receiving files.
Done by adding a oneshot mode, in which location log changes are written to
the journal, but not committed. Taking advantage of git-annex's existing
ability to recover in this situation.

This is used by git-annex-shell and other places where changes are made to
a remote's location log.
2012-01-28 15:41:52 -04:00
Joey Hess
61dbad505d fsck --from remote --fast
Avoids expensive file transfers, at the expense of checking file size
and/or contents.

Required some reworking of the remote code.
2012-01-20 13:23:11 -04:00
Joey Hess
f35a84fac7 use a different tmp file when fscking remote data
Since the content might be symlinked into place, it's not appropriate to
use withTmp here.
2012-01-19 16:56:07 -04:00
Joey Hess
06b0cb6224 add tmp flag parameter to retrieveKeyFile 2012-01-19 16:07:36 -04:00
Joey Hess
90319afa41 fsck --from
Fscking a remote is now supported. It's done by retrieving
the contents of the specified files from the remote, and checking them,
so can be an expensive operation.

(Several optimisations are possible, to speed it up, of course.. This is
the slow and stupid remote fsck to start with.)

Still, if the remote is a special remote, or a git repository that you
cannot run fsck in locally, it's nice to have the ability to fsck it.

If you have any directory special remotes, now would be a good time to
fsck them, in case you were hit by the data loss bug fixed in the
previous release!
2012-01-19 15:24:05 -04:00
Joey Hess
d36525e974 convert fsckKey to a Maybe
This way it's clear when a backend does not implement its own fsck checks.
2012-01-19 13:51:30 -04:00
Joey Hess
abdacf58ed tweaks 2012-01-11 00:06:54 -04:00
Joey Hess
16e7178f20 reorg 2012-01-10 15:29:10 -04:00
Joey Hess
07cacbeee9 break module dependancy loop
A PITA but worth it to clean up the trust configuration code.
2012-01-10 13:32:38 -04:00
Joey Hess
7675b83efa map: Fix display of remote repos
A change to break local cycles made remote repos be dropped entirely.
2012-01-08 16:05:57 -04:00
Joey Hess
a35278430a log: Add --gource mode, which generates output usable by gource.
As part of this, I fixed up how log was getting the descriptions of
remotes.
2012-01-07 18:18:09 -04:00
Joey Hess
bdc49ddbdb typo 2012-01-07 00:45:01 -04:00
Joey Hess
dfa76069d4 reap zombies 2012-01-07 00:22:16 -04:00
Joey Hess
b8966433ef sped up git annex log rather a lot
See comment! Isn't git fun, always interesting approaches to optimise
things that seemed unfixably slow.
2012-01-07 00:15:01 -04:00
Joey Hess
945f56f348 cleanup
Broke out pure general functions etc.
2012-01-07 00:11:15 -04:00
Joey Hess
24b35113cf tweak 2012-01-06 23:43:18 -04:00
Joey Hess
64f9d00bed tweak 2012-01-06 21:51:39 -04:00
Joey Hess
2557bb8764 complete set of log options 2012-01-06 21:48:30 -04:00
Joey Hess
8e7de01047 log --before=date 2012-01-06 21:32:08 -04:00
Joey Hess
539f8c6f14 --boundry was not needed 2012-01-06 21:09:23 -04:00
Joey Hess
d8d72781af better data type 2012-01-06 18:58:35 -04:00
Joey Hess
3c88d57399 log --max-count=n 2012-01-06 17:48:02 -04:00
Joey Hess
078788a9e7 change log display
Including the file in the lines behaves better when limiting with --after,
since only files that changed in the time period are shown.

Still not fully happy with the line layout, but putting the +/- first
followed by the date seems a good change.
2012-01-06 17:36:13 -04:00
Joey Hess
9fb5f3edc7 log --after=date 2012-01-06 17:24:03 -04:00
Joey Hess
47646d44b7 use a zipper 2012-01-06 16:24:40 -04:00
Joey Hess
a3a9f87047 log: New command that displays the location log for file, showing each repository they were added to and removed from.
This needs to run git log on the location log files to get at all past
versions of the file, which tends to be a bit slow.

It would be possible to make a version optimised for showing the location
logs for every key. That would only need to run git log once, so would be
faster, but it would need to process an enormous amount of data, so
would not speed up the individual file case.

In the future it would be nice to support log --format. log --json also
doesn't work right yet.
2012-01-06 15:40:07 -04:00
Joey Hess
1f8a1058c9 tweak 2012-01-06 10:57:57 -04:00
Joey Hess
df21cbfdd2 look up --to and --from remote names only once
This will speed up commands like move and drop.
2012-01-06 04:06:13 -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
ad43f03626 per-command options
Finally commands can define their own options.

Moved --format and --print0 to be options only of find.
2012-01-05 23:11:07 -04:00
Joey Hess
a1aea174d7 fsck: Do backend-specific check before checking numcopies is satisfied.
This way, when a checksum check fails and the content is moved aside,
the numcopies check also warns if there are not enough copies.
2012-01-03 18:40:47 -04:00
Joey Hess
aa0882691b Added remote.name.annex-web-options configuration setting, which can be used to provide parameters to whichever of wget or curl git-annex uses (depends on which is available, but most of their important options suitable for use here are the same). 2012-01-02 14:20:20 -04:00
Joey Hess
508b427c7b tweak 2012-01-02 11:57:02 -04:00
Joey Hess
f0957426c5 skip local remotes that are not available (ie, not mounted)
With --fast, unavailable local remotes are filtered out of the fast set.
This way, if there are local remotes, --fast always acts only on them,
and if none are mounted, acts on nothing. This consistency is better
than --fast acting on different remotes depending on what's mounted.
2011-12-31 04:50:39 -04:00
Joey Hess
4a02c2ea62 type alias cleanup 2011-12-31 04:11:58 -04:00
Joey Hess
a2ec2d3760 refactor and check for a detached HEAD 2011-12-31 03:38:58 -04:00
Joey Hess
8a33573caf better filtering out of special remotes 2011-12-31 03:27:37 -04:00
Joey Hess
6cd4c7efcd never pick special remotes in --fast
even if they have the lowest cost, we cannot use them
2011-12-31 03:14:05 -04:00
Joey Hess
c61642ef0c remove unnecessary check
mergeLocal always creates the local sync branch, so no need to check that
it exists later.
2011-12-31 03:08:44 -04:00
Joey Hess
aa64b8ceaf refactor 2011-12-31 03:01:18 -04:00
Joey Hess
2998340abb really fix check that remote needs merged 2011-12-31 02:45:12 -04:00
Joey Hess
9a7a77488e tweak 2011-12-31 02:18:16 -04:00
Joey Hess
0396f9c795 tweak 2011-12-31 02:15:13 -04:00
Joey Hess
f2b584ad74 fix check that remote branch needs merged 2011-12-31 02:03:39 -04:00
Joey Hess
79231bcff0 minor cleanups
mergeFrom is never called on branches that don't exist anymore
2011-12-31 01:51:39 -04:00
Joey Hess
015a497914 avoid syncing remotes configured annex-ignore, unless explicitly specified 2011-12-31 01:42:42 -04:00
Joey Hess
e7d3e546c2 sync --fast: Selects some of the remotes with the lowest annex.cost and syncs those, in addition to any specified at the command line. 2011-12-30 21:17:36 -04:00
Joey Hess
a31b7d93c8 push when git-annex branch changed
I was too heavy-handed in optimising away pushes
2011-12-30 19:38:46 -04:00
Joey Hess
79872e360e automated syncing
Some changes to make automated syncing nicer. Merge from both the remote's
$branch and its synced/$branch; either could have new changes. Create
synced/$branch on the remote when pushing.
2011-12-30 19:24:57 -04:00
Joey Hess
f6f7ee7131 automatically create the syncbranch 2011-12-30 18:52:24 -04:00
Joey Hess
14d16b77b3 refactor 2011-12-30 18:37:55 -04:00
Joey Hess
52104dae6f refactor 2011-12-30 18:36:40 -04:00
Joey Hess
56488e807b check that synced/master exists before trying to use it
and a nice error message if syncing is not set up yet
2011-12-30 18:19:45 -04:00
Joey Hess
f2fa29bf3b check if branches are up-to-date before merging, pushing
This optimises away the need to run anything in some common cases.
It's particularly useful on push; no need to push if the tracking branch
we just pulled is the same as the branch we're going to push.
2011-12-30 18:04:01 -04:00
Joey Hess
9d85baa314 improve wording 2011-12-30 17:54:09 -04:00
Joey Hess
4400f65967 message cleanup 2011-12-30 17:38:38 -04:00
Joey Hess
556618a3ec avoid using Git.Ref.describe except for when generating user messages
The other uses of it can all be simplified using Git.Ref.base,
Git.Ref.under, and show.

In some cases, describe was being used to shorten the branch name
unnecessarily, and I instead pass the fully qualified name to git.
2011-12-30 17:01:03 -04:00
Joey Hess
5d17da5eb3 update to my indentation style 2011-12-30 16:24:30 -04:00
Joey Hess
5728bb58e0 force git-annex branch update after fetching remotes
git-annex normally only runs the branch update once per run, for speed, but
since this fetches new remote git-annex tracking branches, they need to be
merged in after that fetch. An earlier call to Remote.byName was causing
the update to run before the fetch sometimes, but it could have been
anything. Just force the update to happen in the right place.
2011-12-30 16:03:41 -04:00
Joachim Breitner
b6e7b40be4 By default, sync with all remotes having the synced/ branch 2011-12-29 20:50:57 +01:00
Joachim Breitner
0ee1141f30 Implement branch-syncing in Command.Sync
as described in the previous commit to the documentation. The loggin UI
is not great yet.
2011-12-29 18:37:30 +01:00
Joey Hess
b05c08b5c1 reorder less expensive terminal first
Out of general principles, it did not seem to actually speed it
up appreciably. (I suspect ghc is being smart.)
2011-12-23 13:19:28 -04:00
Joey Hess
fdf02986cf find --json 2011-12-23 01:08:19 -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
7892397020 improve output 2011-12-22 14:50:20 -04:00
Joey Hess
1c28237e0c map: --fast disables use of dot to display map
Generally useful, and allows the test suite to test it.
2011-12-20 16:42:35 -04:00
Joey Hess
87c1c103ea add back message 2011-12-16 16:56:31 -04:00
Joey Hess
95d2391f58 more partial function removal
Left a few Prelude.head's in where it was checked not null and too hard to
remove, etc.
2011-12-15 18:19:36 -04:00
Joey Hess
52fe8a17f3 remove leftover debug print 2011-12-15 13:12:17 -04:00
Joey Hess
09cd042775 Properly handle multiline git config values.
A crash on parsing was fixed a while ago. This adds support for fully
correctly parsing multiline git config values, using git config --null.

Since git-annex-shell configlist uses normal git config output, I left in
support for that too; the two forms of config output can be easily
identified by the parser. Since configlist only prints the annex.uuid
config, there's no risk of multiline values there, so no need to change it.
2011-12-15 12:48:27 -04:00
Joey Hess
ef28b3fef7 split out Git/Command.hs 2011-12-14 15:56:11 -04:00
Joey Hess
02f1bd2bf4 split more stuff out of Git.hs 2011-12-14 15:43:13 -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
543d0d2501 split out Git/Ref.hs 2011-12-12 18:30:33 -04:00
Joey Hess
6edaabd040 reinject: Add a sanity check for using an annexed file as the source file. 2011-12-12 13:43:52 -04:00
Joey Hess
4200b8038a separate operations 2011-12-10 12:21:22 -04:00
Joey Hess
fb8231f3a1 sync: New command that synchronises the local repository and default remote, by running git commit, pull, and push for you. 2011-12-09 20:27:22 -04:00
Joey Hess
28699c95a7 some work on avoiding partial functions
There are still hundreds of places that use partial functions head, tail,
init, and last.
2011-12-09 18:10:41 -04:00
Joey Hess
95e748cbd4 inverted logic 2011-12-09 13:38:28 -04:00
Joey Hess
252b2e92b0 cleanup 2011-12-09 13:31:51 -04:00
Joey Hess
14e9b87d44 unannex improvements
Added files don't have to be committed before they can be unannexed.

unannex no longer commits existing staged changes

unannex of the last file in a directory now works, before it failed because
git rm deleted the directory out from under it,
2011-12-09 13:07:31 -04:00
Joey Hess
3f5f28b487 factor out a stopUnless
code melt for lunch
2011-12-09 12:23:45 -04:00
Joey Hess
d64132a43a hslint 2011-12-09 01:57:13 -04:00
Joey Hess
8047bba5b9 add: If interrupted, add can leave files converted to symlinks but not yet added to git. Running the add again will now clean up this situtation. 2011-12-07 16:53:53 -04:00
Joey Hess
b6c8a0119a map: Fix a failure to detect a loop when both repositories are local and refer to each other with relative paths. 2011-12-04 12:23:10 -04:00
Joey Hess
b5930f6d07 add 2011-12-02 19:22:43 -04:00
Joey Hess
f0cc42685e fix display of dead repositories in status 2011-12-02 19:21:56 -04:00
Joey Hess
da9cd315be add support for using hashDirLower in addition to hashDirMixed
Supporting multiple directory hash types will allow converting to a
different one, without a flag day.

gitAnnexLocation now checks which of the possible locations have a file.
This means more statting of files. Several places currently use
gitAnnexLocation and immediately check if the returned file exists;
those need to be optimised.
2011-11-28 22:43:51 -04:00
Joey Hess
6869e6023e support .git/annex on a different disk than the rest of the repo
The only fully supported thing is to have the main repository on one disk,
and .git/annex on another. Only commands that move data in/out of the annex
will need to copy it across devices.

There is only partial support for putting arbitrary subdirectories of
.git/annex on different devices. For one thing, but this can require more
copies to be done. For example, when .git/annex/tmp is on one device, and
.git/annex/journal on another, every journal write involves a call to
mv(1). Also, there are a few places that make hard links between various
subdirectories of .git/annex with createLink, that are not handled.

In the common case without cross-device, the new moveFile is actually
faster than renameFile, avoiding an unncessary stat to check that a file
(not a directory) is being moved. Of course if a cross-device move is
needed, it is as slow as mv(1) of the data.
2011-11-28 16:17:55 -04:00
Joey Hess
2bf3addf49 Bugfix: dropunused did not drop keys with two spaces in their name. 2011-11-27 13:50:05 -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
0f0169fa99 comment update 2011-11-20 22:49:53 -04:00
Joey Hess
d675f1c82e status --json now shows most things
Left out the backend usage graph for now, and bad/temp directory sizes
are only displayed when present. Also, disk usage is returned as a string
with units, which I can see changing later.
2011-11-20 14:12:48 -04:00
Joey Hess
3905053a18 update comment to explain non-obvious temp file 2011-11-19 15:16:38 -04:00
Joey Hess
1b90918cec avoid error message when doing get --from on file not present on remote 2011-11-18 17:26:37 -04:00
Joey Hess
c50a5fbeb4 status: Include all special remotes in the list of repositories.
Special remotes do not always have a description listed in uuid.log,
and such ones were not listed before.
2011-11-18 13:22:48 -04:00
Joey Hess
c70b78d40a migrate: Don't fall over a stale temp file. 2011-11-17 18:29:28 -04:00
Joey Hess
d66fac1ec8 fix typo introduced with the Ref type 2011-11-17 18:17:34 -04:00
Joey Hess
9290095fc2 improve type signatures with a Ref newtype
In git, a Ref can be a Sha, or a Branch, or a Tag. I added type aliases for
those. Note that this does not prevent mixing up of eg, refs and branches
at the type level. Since git really doesn't care, except rare cases like
git update-ref, or git tag -d, that seems ok for now.

There's also a tree-ish, but let's just use Ref for it. A given Sha or Ref
may or may not be a tree-ish, depending on the object type, so there seems
no point in trying to represent it at the type level.
2011-11-16 02:41:46 -04:00
Joey Hess
2bb6b02948 When not run in a git repository, git-annex can still display a usage message, and "git annex version" even works.
Things that sound simple, but are made hard by the Annex monad being built
with the assumption that there will always be a git repo.
2011-11-16 00:49:09 -04:00
Joey Hess
9b71b5f26c fix display of semitrusted repos in status
semitrusted uuids rarely are listed in trust.log, so a special case
is needed to get a list of them. Take the difference of all known uuids
with non-semitrusted uuids.
2011-11-16 00:01:07 -04:00
Joey Hess
def0788698 show number of repos 2011-11-15 00:33:54 -04:00
Joey Hess
019373f827 better status output 2011-11-15 00:30:27 -04:00
Joey Hess
2412b7e689 fix exit status so json gets terminated properly 2011-11-14 19:29:35 -04:00
Joey Hess
bfe38f8ff1 status --json --fast for esc
* status: Fix --json mode (only the repository lists are currently
  displayed)
* status: --fast is back
2011-11-14 19:27:22 -04:00
Joey Hess
364981ad92 probably makes sense to list semitrusted before untrusted 2011-11-14 16:15:48 -04:00
Joey Hess
aa4fbbdd33 status: Now displays trusted, untrusted, and semitrusted repositories separately. 2011-11-14 16:14:17 -04:00
Joey Hess
04edae6791 Optimised union merging; now only runs git cat-file once. 2011-11-12 17:45:12 -04:00
Joey Hess
cea65b9e5b init: When run in an already initalized repository, and without a description specified, don't delete the old description. 2011-11-12 15:42:52 -04:00
Joey Hess
71b216d1fb map: Support remotes with /~/ and /~user/
More accurately, it was supported already when map uses git-annex-shell,
but not when it does not.

Note that the user name cannot be shell escaped using git-annex's current
approach for shell escaping. I tried and some shells like dash cannot
cd ~'joey'. Rest of directory is still shell escaped, not for security but
in case a directory has a space or other weird character.
2011-11-11 16:18:53 -04:00
Joey Hess
637b5feb45 lint 2011-11-11 01:52:58 -04:00
Joey Hess
b327227ba5 better limiting of start actions to only run whenAnnexed
Mostly only refactoring, but this does remove one redundant stat of the
symlink by copy.
2011-11-10 23:45:14 -04:00
Joey Hess
4389782628 tweak 2011-11-10 22:37:52 -04:00
Joey Hess
2de1e2c2ce Optimized copy --from and get --from to avoid checking the location log for files that are already present.
This can be a significant speedup when running in large trees that are
only missing a few files; it makes copy --from just as fast as get.
2011-11-10 21:32:42 -04:00
Joey Hess
992bf13382 lockContent in dropkey
This is needed for drop --from and move --from to check the lock,
as they do not use git-annex-shell inannex.
2011-11-09 19:47:04 -04:00
Joey Hess
d3e1a3619f safer inannex checking
git-annex-shell inannex now returns always 0, 1, or 100 (the last when
it's unclear if content is currently in the index due to it currently being
moved or dropped).

(Actual locking code still not yet written.)
2011-11-09 18:33:15 -04:00
Joey Hess
8ce7e73f74 reorg to allow taking content lock
The lock will only persist during the perform stage, so the content must
be removed from the annex then, rather than in the cleanup stage.

(No lock is actually taken yet.)
2011-11-09 16:54:18 -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
b11a63a860 clean up read/show abuse
Avoid ever using read to parse a non-haskell formatted input string.

show :: Key is arguably still show abuse, but displaying Keys as filenames
is just too useful to give up.
2011-11-08 00:17:54 -04:00
Joey Hess
faa4935047 Handle a case where an annexed file is moved into a gitignored directory, by having fix --force add its change. 2011-11-07 18:10:31 -04:00
Joey Hess
64bc4e4751 refactor 2011-11-07 16:13:06 -04:00
Joey Hess
63a292324d add a UUID type
Should have done this a long time ago.
2011-11-07 15:59:16 -04:00
Joey Hess
b08f7c428b better usage 2011-11-07 14:00:23 -04:00
Joey Hess
41eecb4601 Bugfix: In the past two releases, git-annex init has written the uuid.log in the wrong format, with the UUID and description flipped.
This is my own damn fault for not making UUID a real type, and then relying
on the type checker to ensure my refactoring was correct -- which it wasn't!

I should probably add code to clean up bogus entries in the uuid.log, but
right now I want to get the fix out there to prevent people experiencing
this bug.

I should also make UUID a real data type.
2011-11-07 12:47:41 -04:00
Joey Hess
c33313c50b tweak 2011-11-02 14:24:44 -04:00
Joey Hess
c643136e32 playing with >=>
Apparently in haskell if you teach a man to fish, he'll write
more pointfree code.
2011-10-31 23:39:55 -04:00
Joey Hess
3d2a9f8405 cleanup 2011-10-31 17:22:55 -04:00
Joey Hess
3d3e1c4c25 better command name 2011-10-31 15:18:41 -04:00
Joey Hess
09861cf4f7 cleanup 2011-10-31 15:12:02 -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
cc1ea8f844 Removed the setkey command, and added a setcontent command with a more useful interface. 2011-10-31 12:33:41 -04:00
Joey Hess
4e9be0d1f8 refactoring and cleanup
No code changes.
2011-10-30 00:28:22 -04:00
Joey Hess
ef5330120c bare cleanup 2011-10-29 19:30:48 -04:00
Joey Hess
22e9f445ab unused, dropunused: Now work in bare repositories.
Turned out I had already done all the work needed to support this when
unused started checking all branches.
2011-10-29 19:16:45 -04:00
Joey Hess
c102e63595 status: clean up for bare repositories
The backend usage graph shows present keys as well as keys found in the
repository tree, so it will also be populated for bare repositories.

Changed wording to "visible annex keys", which explains why it's 0 in
a bare repository (no keys visible as no tree), and also why it varies
depending on which branch is checked out. This seemed better than doing
something expensive to look up keys from the git-annex branch.
2011-10-29 19:06:49 -04:00
Joey Hess
61000904d7 refactor 2011-10-29 18:47:53 -04:00
Joey Hess
2566eb85fe fsck: Now works in bare repositories.
Checks location log information, and file contents.

Does not check that numcopies is satisfied, as .gitattributes information
about numcopies is not available in a bare repository. In practice, that
should not be a problem, since fsck is also run in a checkout and will
check numcopies there.
2011-10-29 18:03:28 -04:00
Joey Hess
fef2cf7398 refactor 2011-10-29 16:45:06 -04:00
Joey Hess
f97c783283 clean up check selection code
This new approach allows filtering out checks from the default set that are
not appropriate for a command, rather than having to list every check
that is appropriate. It also reduces some boilerplate.

Haskell does not define Eq for functions, so I had to go a long way around
with each check having a unique id. Meh.
2011-10-29 15:19:05 -04:00
Joey Hess
6c31e3a8c3 drop --from is now supported to remove file content from a remote. 2011-10-28 17:26:38 -04:00
Joey Hess
33e18d3d02 cleanup 2011-10-27 19:11:00 -04:00
Joey Hess
b955238ec7 Fail if --from or --to is passed to commands that do not support them. 2011-10-27 18:56:54 -04:00
Joey Hess
5b74b130a3 refactored and generalized pre-command sanity checking 2011-10-27 16:31:35 -04:00
Joey Hess
66194684ac uninit: Add guard against being run with the git-annex branch checked out. 2011-10-27 15:47:11 -04:00
Joey Hess
23f2a12816 broke up Utility 2011-10-16 00:50:12 -04:00
Joey Hess
91366c896d clean Annex stuff out of Utility/ 2011-10-16 00:04:26 -04:00
Joey Hess
ee9af605bc break out non-log stuff to separate module 2011-10-15 17:47:03 -04:00
Joey Hess
ec169f84b1 migrate: Copy url logs for keys when migrating. 2011-10-15 16:36:56 -04:00
Joey Hess
1a29b5b52e reorganize log modules
no code changes
2011-10-15 16:21:08 -04:00
Joey Hess
b505ba83e8 minor syntax changes 2011-10-11 14:43:45 -04:00
Joey Hess
6a6ea06cee rename 2011-10-05 16:02:51 -04:00
Joey Hess
cfe21e85e7 rename 2011-10-04 00:59:08 -04:00
Joey Hess
ff21fd4a65 factor out Annex exception handling module 2011-10-04 00:34:04 -04:00
Joey Hess
8ef2095fa0 factor out common imports
no code changes
2011-10-03 23:29:48 -04:00
Joey Hess
828f3f1b0c status: List all known repositories. 2011-09-30 03:20:24 -04:00
Joey Hess
15eccdf124 better output layout 2011-09-30 03:05:10 -04:00
Joey Hess
a7102ca4d5 list backends with more keys first, not last 2011-09-30 03:03:59 -04:00
Joey Hess
7ff89ccfee convert all git read/write functions to use ByteStrings
This yields a second or so speedup in unused, find, etc. Seems that even
when the ByteString is immediately split and then converted to Strings,
it's faster.

I may try to push ByteStrings out into more of git-annex gradually,
although I suspect most of the time-critical parts are already covered
now, and many of the rest rely on libraries that only support Strings.
2011-09-29 23:48:57 -04:00
Joey Hess
7c2c17f706 golfing 2011-09-28 20:19:10 -04:00
Joey Hess
8e4bd621b9 enable short-circuiting optimisatons 2011-09-28 17:38:41 -04:00
Joey Hess
b4d5c10fb7 refine new unused code
Fixed the laziness space leak, so it runs in 60 mb or so again. Slightly
faster due to using Data.Set.difference now, although this also makes it
use slightly more memory.

Also added display of the refs being checked, and made unused --from
also check all refs for things in the remote.
2011-09-28 17:35:47 -04:00
Joey Hess
297bc648b9 make unused check branches and tags too
needs time and space optimisation
2011-09-28 16:43:10 -04:00
Joey Hess
4bf1a5ef59 refactor 2011-09-23 18:13:24 -04:00
Joey Hess
d75da353b9 documentation/warning message update for future feature 2011-09-23 18:04:38 -04:00
Joey Hess
9f6b7935dd go go gadget hlint 2011-09-20 23:24:48 -04:00
Joey Hess
9d26192350 pull out pure code 2011-09-20 20:18:43 -04:00
Joey Hess
98fbeba0df bugfix
Different keys can have the same size, so can't make a Set of the sizes.

This version actually runs faster yet, too..
2011-09-20 20:14:17 -04:00
Joey Hess
9f5c7a246b status: Massively sped up; remove --fast mode.
Using Sets is the right thing; they have constant size lookup like my
SizeList, and logn insertation, which beats nub to death.

Runs faster than --fast mode did before, and gives accurate counts.

13 seconds total runtime with a warm cache in a repository with 40 thousand
keys.
2011-09-20 18:57:05 -04:00
Joey Hess
cabbefd9d2 status: In --fast mode, all status info is displayed now; but some of it is only approximate, and is marked as such. 2011-09-20 18:13:08 -04:00
Joey Hess
33cd1ffbfe make find show files meeting limits, even when not present
find: Rather than only showing files whose contents are present, when used
with --exclude --copies or --in, displays all files that match the
specified conditions.

Note that this is a behavior change for find --exclude! Old behavior
can be gotten with find --in . --exclude=...
2011-09-18 20:42:15 -04:00
Joey Hess
5ff04bf2af tweak 2011-09-15 16:59:52 -04:00
Joey Hess
35145202d2 remove command type definitions
These were a mistake, they make the type signatures harder to read and
less flexible. The CommandSeek, CommandStart, CommandPerform, and
CommandCleanup types were a good idea, but composing them with the
parameters expected is going too far.
2011-09-15 16:50:49 -04:00
Joey Hess
456b45b9b3 move annex.numcopies parsing into withNumCopies 2011-09-15 16:24:47 -04:00
Joey Hess
e47d1fd43e add error for move --auto
It probably does not make sense to enable auto mode for move. I cannot
think of a situation where it would make sense to try to use it.

A hypothetical auto mode for move would only differ from a normal
move in one case -- when both repositories have a file, move deletes it
from one, and this reduces the number of copies. So an auto mode would
either only let move work in that situation, or avoid removing the file
in that situation, depending on the number of copies. This would be
complex to implement, and is perhaps not a very obvious behavior.

The error is a good thing to have, so users don't expect it to do something
it does not.
2011-09-15 15:33:20 -04:00
Joey Hess
a0d3a343b5 copy --auto
Only does copy when numcopies is not yet satisfied.
2011-09-15 15:28:58 -04:00
Joey Hess
fe5e4bdc64 comment 2011-09-15 14:34:15 -04:00
Joey Hess
9fe3c6d211 clean up params in usage display 2011-09-15 14:33:37 -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
81984e60ac better var name 2011-09-15 12:37:27 -04:00
Joey Hess
5c96411314 fix synopsis 2011-09-15 12:36:27 -04:00
Joey Hess
59fe0b29a6 simplify 2011-09-14 16:01:40 -04:00
Joey Hess
11994ebb3d tweak 2011-09-14 15:33:21 -04:00
Joey Hess
5a1f10325f refactor 2011-09-14 13:48:39 -04:00
Joey Hess
949b3f69d0 optimize: A new subcommand that either gets or drops file content as needed to work toward meeting the configured numcopies setting.
This is currently rather simplistic, though still useful.
In the future, it could become smarter about what content is stored where,
etc.
2011-09-14 13:47:22 -04:00
Joey Hess
1ac6217c74 shorten synopsis 2011-09-14 13:32:46 -04:00
Joey Hess
e296da4bfe more newline fixes
Adds a missing newline when a longnote is followed by a endresult.

Multiple longnotes in a row will now be separated by a blank line, which
could be a bug or a feature depending on taste.

Removed several places where newlines were explicitly displayed after
longnotes.
2011-09-09 01:45:41 -04:00
Joey Hess
e4ba0934c2 fix / escape 2011-09-09 00:11:32 -04:00
Joey Hess
03d6209e1c addurl: Always use whole url as destination filename, rather than only its file component.
First, this ensures that git annex addurl, when run repeatedly with the
same url, doesn't create duplicate files, which it did before when it
fell back to the longer filename.

Secondly, the file part of an url is frequently not very descriptive on its
own.

The uri scheme, auth, and port is intentionally left out, as clutter.
2011-09-07 19:04:51 -04:00
Joey Hess
3623d831d1 refactor 2011-09-06 17:45:47 -04:00
Joey Hess
6f98fd5391 whereis: Show untrusted locations separately and do not include in location count. 2011-09-06 16:59:53 -04:00
Joey Hess
5bc32c7f34 add json formatted list of remotes
Wherever a list of remotes is shown, --json now enables a json formatted
list.
2011-09-01 16:02:01 -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
55783d886d add explanation for why strictness is needed here 2011-08-31 19:50:08 -04:00
Joey Hess
f600444ab6 unused --remote: Reduced memory use to 1/4th what was used before.
Using a single strictness annotation, in just the right place.
Tried several others, none of which helped and some of which potentially
hurt. This is only the second time I've really had to deal with this in
a year of using haskell, which is, I suppose not that bad.
2011-08-31 19:13:02 -04:00
Joey Hess
d1154d0837 init: Make description an optional parameter. 2011-08-29 14:13:38 -04:00
Joey Hess
678726c10c code simplification thanks to applicative functors 2011-08-25 01:27:19 -04:00
Joey Hess
203148363f split groups of related functions out of Utility 2011-08-22 16:14:12 -04:00
Joey Hess
737b5d14c9 moved files around 2011-08-20 16:11:42 -04:00
Joey Hess
cf33eff684 git-annex-shell configlist should not be standalone
This makes it initialize the repository with a uuid, and list the uuid,
allowing automatic setup of bare repositories when git-annex is used.
2011-08-17 14:44:31 -04:00
Joey Hess
56f6923ccb Now "git annex init" only has to be run once
when a git repository is first being created. Clones will automatically
notice that git-annex is in use and automatically perform a basic
initalization. It's still recommended to run "git annex init" in any
clones, to describe them.
2011-08-17 14:44:31 -04:00
Joey Hess
a55faff08f reorg Remote/* 2011-08-16 20:49:54 -04:00
Joey Hess
4545a0e78c split out generic url stuff into a helper library from Remote.Web 2011-08-16 20:49:44 -04:00
Joey Hess
5000aba76e avoid namespace conflict 2011-08-16 20:47:48 -04:00
Joey Hess
dede05171b addurl: --fast can be used to avoid immediately downloading the url.
The tricky part about this is that to generate a key, the file must be
present already. Worked around by adding (back) an URL key type, which
is used for addurl --fast.
2011-08-06 14:57:22 -04:00
Joey Hess
00153eed48 unify elipsis handling
And add a simple dots-based progress display, currently only used in v2
upgrade.
2011-07-19 14:07:23 -04:00
Joey Hess
6c396a256c finished hlint pass 2011-07-15 12:47:14 -04:00
Joey Hess
9bb797c0ea unannex: only commit, no -a
-a is actually not needed; only commit staged changes
2011-07-14 17:18:53 -04:00
Joey Hess
ded2591124 unannex: Clean up use of git commit -a.
This was more complex than would be expected. unannex has to use git commit -a
since it's removing files from git; git commit filelist won't do.

Allow commands to be added to the Git queue that have no associated files,
and run such commands once.
2011-07-14 17:15:37 -04:00
Joey Hess
40c6ba99f5 add: Be even more robust to avoid ever leaving the file seemingly deleted.
A failure at any point after the file is annexed will result in an undo
that puts the original file back into place and wipes the location log.
2011-07-07 21:30:51 -04:00
Joey Hess
67dcc1f171 add: Avoid a failure mode that resulted in the file seemingly being deleted (content put in the annex but no symlink present). 2011-07-07 19:29:36 -04:00
Joey Hess
cab4ac247c rename 2011-07-05 20:36:43 -04:00
Joey Hess
c98b5cf36e rename 2011-07-05 20:24:10 -04:00
Joey Hess
6040d8aed1 factor out RemoteLog 2011-07-05 20:16:57 -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
d31b84c777 better display of thrown errors 2011-07-05 14:58:33 -04:00
Joey Hess
71c783bf24 uninit: Use unannex in --fast mode, to support unannexing multiple files that link to the same content. 2011-07-04 16:20:50 -04:00
Joey Hess
d7ce51af5a fix usage for setkey 2011-07-04 16:13:44 -04:00
Joey Hess
22a4f5b348 unannex: In --fast mode, file content is left in the annex, and a hard link made to it. 2011-07-04 16:06:28 -04:00
Joey Hess
5beb6bc76f uninit: delete .git/annex/ 2011-07-04 15:55:03 -04:00
Joey Hess
5c63b409d4 uninit: Delete the git-annex branch. 2011-07-04 15:50:30 -04:00
Joey Hess
ace9de37e8 download urls via tmp file, and support resuming 2011-07-01 18:59:40 -04:00
Joey Hess
6bddebdb79 add the addurl command 2011-07-01 17:15:46 -04:00
Joey Hess
cdbcd6f495 add web special remote
Generalized LocationLog to PresenceLog, and use a presence log to record
urls for the web special remote.
2011-07-01 15:30:42 -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
2cda9d0a0f generalized safeWriteFile to viaTmp 2011-06-30 00:46:39 -04:00
Joey Hess
06a1f5f742 factor out file list stuff from GitRepo
GitRepo is getting too large an interface; these all fit nicely into a
submodule.
2011-06-29 11:55:16 -04:00
Joey Hess
af45d42224 Merge branch 'master' into v3
Conflicts:
	debian/changelog
2011-06-29 11:42:35 -04:00
Joey Hess
b3aaf980e4 --force will cause add, etc, to operate on ignored files. 2011-06-29 11:42:00 -04:00
Joey Hess
7ee636f6dd avoid unnecessary read of trust.log 2011-06-23 13:39:04 -04:00
Joey Hess
89fd7b34ce unused command updates for branches
Now that branches are more likely, unused needs to more explicitly warn
that it does not look in them.
2011-06-23 12:23:25 -04:00
Joey Hess
af10b2854a v3 upgrade code works
but write the index file a lot, so slow
2011-06-23 02:30:20 -04:00
Joey Hess
aad73c5721 rewrite loggedkeys to use git-annex branch
That sucking sound is a whole page of code vanishing to be replaced with
  return . catMaybes . map (logFileKey . takeFileName) =<< Branch.files
What can I say, git is my database, and haskell my copilot.
2011-06-22 23:24:14 -04:00
Joey Hess
ad3770e0b2 add merge subcommand 2011-06-22 18:46:56 -04:00
Joey Hess
80302d0b46 improve bare repo handing
Many more commands can work in bare repos now, thanks to the git-annex
branch.
2011-06-22 18:32:41 -04:00
Joey Hess
944c51ba26 improve version checking for v3
Do not set annex.version whenever any command is run. Just do it in init.
This ensures that, if a repo has annex.version=3, it has a git-annex
branch, so we don't have to run a command every time to check for the
branch.

Remove the old ad-hoc logic for v0 and v1, to simplify version checking.
2011-06-22 18:07:45 -04:00
Joey Hess
4c4ebf2d75 store trust.log and remote.log in the git-annex branch
.. and I think that's everything that will use the branch
2011-06-22 17:08:51 -04:00
Joey Hess
1870186632 fixed logFile 2011-06-22 16:17:16 -04:00
Joey Hess
e0bd9d43a2 update for git-annex branch
stop changing gitattributes on init

create git-annex branch on init

ugly special case for init in a bare repository goes away, yay!

git annex init is also faster, at least in a large existing repo, as
it does not need to run the slow 'git add'
2011-06-22 16:03:26 -04:00