Commit graph

51 commits

Author SHA1 Message Date
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
1a96d4ab35 use bracket to reset environment
In case the exception is caught higher up, don't leave the environment
dirty.
2011-10-04 00:19:42 -04:00
Joey Hess
8ef2095fa0 factor out common imports
no code changes
2011-10-03 23:29:48 -04:00
Joey Hess
003a604a6e drop the lock on error 2011-10-03 18:20:29 -04:00
Joey Hess
2636ea79c3 avoid taking journal lock unnecessarily 2011-10-03 17:29:28 -04:00
Joey Hess
d357556141 Add locking to avoid races when changing the git-annex branch. 2011-10-03 16:32:36 -04:00
Joey Hess
f77979b8b5 improved git-annex branch changing
All changes to files in the branch are now made via pure functions that
transform the old file into the new. This will allow adding locking
to prevent read/write races. It also makes the code nicer, and purer.

I noticed a behavior change, really a sort of bug fix. Before,
'git annex untrust foo --trust bar' would change both trust levels
permanantly, now the --trust doesn't get stored.
2011-10-03 15:41:25 -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
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
ad245a6375 refactor catfile code
split into generic IO code, and a thin Annex wrapper
2011-09-28 15:17:36 -04:00
Joey Hess
6dc23b889e one more hlint 2011-09-20 23:26:35 -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
4c73d77b42 avoid the functor
fmap = liftM
2011-08-21 14:59:34 -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
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
e784757376 hlint tweaks
Did all sources except Remotes/* and Command/*
2011-07-15 03:12:05 -04:00
Joey Hess
44e973dd09 fork a process to feed git hash-object
This is another workaround for bug #624389. I hope it will fix
http://git-annex.branchable.com/bugs/problem_with_upgrade_v2_-__62___v3/
2011-07-05 13:26:59 -04:00
Joey Hess
591e293f43 simplify git cat-file startup 2011-07-02 19:22:11 -04:00
Joey Hess
f626512b07 further improved git cat-file error handling 2011-07-02 19:16:28 -04:00
Joey Hess
896726cde4 rename GitUnionMerge to Git.UnionMerge
Also, moved commit function into Git proper, it's not union merge specific.
2011-06-30 13:32:47 -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
5fe02f2807 more robust git cat-file output parser
Only remaining ugliness is the handling of error messages for files that
are not present on the branch.
2011-06-30 13:12:51 -04:00
Joey Hess
d72fb5acc2 Fix encoding of utf-8 etc when storing the description of repository and other content.
Write files in raw mode, to avoid mangling the encoding of content
provided.

Note: This was a longstanding problem, it was not introduced in v3.
2011-06-30 00:35:51 -04:00
Joey Hess
b089fba7b4 use ByteString for hGet
Avoids the crazy low-level hGetBuf stuff. Also slightly faster.
2011-06-29 23:56:47 -04:00
Joey Hess
899ecbfba1 improve git cat-file code
Now it reads the size specified, rather than using the sentinal hack to
determine EOF.

It still depends on error messages to handle files that are not present.
2011-06-29 22:19:40 -04:00
Joey Hess
e1c18ddec4 Sped back up fsck, copy --from etc
All commands that often have to read a lot of information from
the git-annex branch should now be nearly as fast as before
the branch was introduced.

Before fsck was taking approximatly 3 hours, now it's running in 8 minutes.

The code is very nasty. It should be rewritten to read the header line
from git cat-file, and then read the specified number of bytes of content.
2011-06-29 21:47:31 -04:00
Joey Hess
e8068f2ffb tweaks 2011-06-28 14:14:49 -04:00
Joey Hess
c90652f015 Always ensure git-annex branch exists. 2011-06-26 22:43:48 -04:00
Joey Hess
ad38c0dfad better setup of git-annex branch pushing on upgrade 2011-06-24 11:59:34 -04:00
Joey Hess
ab9b971f8f simplified to use existing functions 2011-06-23 17:37:23 -04:00
Joey Hess
1686f60f84 commit after merge if any journal files were staged 2011-06-23 16:44:26 -04:00
Joey Hess
7981eb4cb5 fix consistency, and partially close a race during merge
Only "partially" because the journal is not locked during the merge, so
there's a small window where a different git-annex process could write info
to the journal that overwrites info taken from the merge.

That could be dealt with by locking, but the lock would really need to be
around the whole git-annex, to only let one run at a time. Otherwise, even
with the journal locked during the merge, another git-annex could already
be running, generate an overwriting change, and only store it in the journal
after the merge was complete. And similarly, two git-annex processes could
fight and overwrite each other's information independant of any merging.

So, a toplevel lock for git-annex may get added; it's something I've
considered before, as these potential, unlikely problems are not new.
(OTOH, fsck will deal with such problems.)
2011-06-23 16:05:02 -04:00
Joey Hess
780ee5ff6d fix bootstrapping, broken by move of .git/annex/index 2011-06-23 15:38:52 -04:00
Joey Hess
aec4709c3f fix gotcha with closed stderr and --debug 2011-06-23 13:38:52 -04:00
Joey Hess
1b21dd99c5 rename git-annex index file 2011-06-23 12:11:09 -04:00
Joey Hess
5f494154a3 add journaling to speed up changes to the git-annex branch
git is slow when the index file is large and has to be rewritten each time
a file is changed. To speed this up, added a journal where changes are
recorded before being fed into the index file and committed to the
git-annex branch. The entire journal can be fed into git with just 2
commands, and only one write of the index file.
2011-06-23 11:37:26 -04:00
Joey Hess
23e765b67c update re git-annex branch direct modification 2011-06-23 09:56:04 -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
a4ef0e4da4 bugfix: restore index file env var
This fixes precommit, since in that hook, git sets the env var to write
to the lock file, which avoids git add failing due to the presence of the
lock file. (Took me a good hour and a half of confusion to figure this out.)

Test suite now passes 100%! Only the upgrade code still remains to be
written.
2011-06-22 22:56:27 -04:00
Joey Hess
36109a286e squelched git-cat-file's error message when file DNE
This seemed much too hard to do. I just wanted to close stderr
when running it.
2011-06-22 19:48:04 -04:00
Joey Hess
2035b22a01 better branch display 2011-06-22 17:47:06 -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
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
7a693394f4 allow for union merges between a tree and the content in the index
This is needed for robust handling of the git-annex branch. Since changes
are staged to its index as git-annex runs, and committed at the end,
it's possible that git-annex is interrupted, and leaves a dirty index.

When it next runs, it needs to be able to merge the git-annex branch
as necessary, without losing the existing changes in the index.

Note that this assumes that the git-annex branch is only modified by
git-annex. Any changes to it will be lost when git-annex updates the
branch. I don't see a good, inexpensive way to find changes in
the git-annex branch that arn't in the index, and union merging the
git-annex branch into the index every time would likewise be expensive.
2011-06-21 20:12:53 -04:00
Joey Hess
5e0adb2637 fixes
make commit commit to the right branch

when getting content from the branch, update first
2011-06-21 19:11:55 -04:00
Joey Hess
40ec8a9726 Branch module complete
Refactored some code that it needs into GitRepo.
2011-06-21 17:52:39 -04:00
Joey Hess
7e7428f173 refactor 2011-06-21 16:08:09 -04:00