sync: Add support for --all and --unused.
This commit is contained in:
parent
58e6f033b9
commit
29c03145e6
6 changed files with 64 additions and 31 deletions
|
@ -53,13 +53,15 @@ gitAnnexOptions = commonOptions ++
|
|||
|
||||
-- Options for matching on annexed keys, rather than work tree files.
|
||||
keyOptions :: [Option]
|
||||
keyOptions =
|
||||
[ Option ['A'] ["all"] (NoArg (Annex.setFlag "all"))
|
||||
"operate on all versions of all files"
|
||||
, Option ['U'] ["unused"] (NoArg (Annex.setFlag "unused"))
|
||||
"operate on files found by last run of git-annex unused"
|
||||
, keyOption
|
||||
]
|
||||
keyOptions = [ allOption, unusedOption, keyOption]
|
||||
|
||||
allOption :: Option
|
||||
allOption = Option ['A'] ["all"] (NoArg (Annex.setFlag "all"))
|
||||
"operate on all versions of all files"
|
||||
|
||||
unusedOption :: Option
|
||||
unusedOption = Option ['U'] ["unused"] (NoArg (Annex.setFlag "unused"))
|
||||
"operate on files found by last run of git-annex unused"
|
||||
|
||||
keyOption :: Option
|
||||
keyOption = Option [] ["key"] (ReqArg (Annex.setField "key") paramKey)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
- the values a user passes to a command, and prepare actions operating
|
||||
- on them.
|
||||
-
|
||||
- Copyright 2010-2014 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2015 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -172,7 +172,17 @@ withNothing _ _ = error "This command takes no parameters."
|
|||
- Otherwise falls back to a regular CommandSeek action on
|
||||
- whatever params were passed. -}
|
||||
withKeyOptions :: Bool -> (Key -> CommandStart) -> CommandSeek -> CommandSeek
|
||||
withKeyOptions auto keyop fallbackop params = do
|
||||
withKeyOptions auto keyop = withKeyOptions' auto $ \getkeys -> do
|
||||
matcher <- Limit.getMatcher
|
||||
seekActions $ map (process matcher) <$> getkeys
|
||||
where
|
||||
process matcher k = ifM (matcher $ MatchingKey k)
|
||||
( keyop k
|
||||
, return Nothing
|
||||
)
|
||||
|
||||
withKeyOptions' :: Bool -> (Annex [Key] -> Annex ()) -> CommandSeek -> CommandSeek
|
||||
withKeyOptions' auto keyop fallbackop params = do
|
||||
bare <- fromRepo Git.repoIsLocalBare
|
||||
allkeys <- Annex.getFlag "all"
|
||||
unused <- Annex.getFlag "unused"
|
||||
|
@ -194,11 +204,7 @@ withKeyOptions auto keyop fallbackop params = do
|
|||
_ -> error "Can only specify one of file names, --all, --unused, --key, or --incomplete"
|
||||
where
|
||||
go True _ = error "Cannot use --auto with --all or --unused or --key or --incomplete"
|
||||
go False a = do
|
||||
matcher <- Limit.getMatcher
|
||||
seekActions $ map (process matcher) <$> a
|
||||
process matcher k = ifM (matcher $ MatchingKey k)
|
||||
( keyop k , return Nothing)
|
||||
go False getkeys = keyop getkeys
|
||||
incompletekeys = staleKeysPrune gitAnnexTmpObjectDir True
|
||||
|
||||
prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart]
|
||||
|
|
|
@ -58,6 +58,8 @@ syncOptions :: [Option]
|
|||
syncOptions =
|
||||
[ contentOption
|
||||
, messageOption
|
||||
, allOption
|
||||
, unusedOption
|
||||
]
|
||||
|
||||
contentOption :: Option
|
||||
|
@ -371,12 +373,19 @@ newer remote b = do
|
|||
seekSyncContent :: [Remote] -> Annex Bool
|
||||
seekSyncContent rs = do
|
||||
mvar <- liftIO newEmptyMVar
|
||||
mapM_ (go mvar) =<< seekHelper LsFiles.inRepo []
|
||||
-- Always start with the work tree; this ensures that preferred
|
||||
-- content expressions that match files match, even when in --all
|
||||
-- mode.
|
||||
seekworktree mvar []
|
||||
withKeyOptions' False (seekkeys mvar) (const noop) []
|
||||
liftIO $ not <$> isEmptyMVar mvar
|
||||
where
|
||||
go mvar f = ifAnnexed f
|
||||
(\v -> void (liftIO (tryPutMVar mvar ())) >> syncFile rs (Just f) v)
|
||||
noop
|
||||
seekworktree mvar = seekHelper LsFiles.inRepo >=>
|
||||
mapM_ (\f -> ifAnnexed f (go mvar (Just f)) noop)
|
||||
seekkeys mvar getkeys = mapM_ (go mvar Nothing) =<< getkeys
|
||||
go mvar af k = do
|
||||
void $ liftIO $ tryPutMVar mvar ()
|
||||
syncFile rs af k
|
||||
|
||||
syncFile :: [Remote] -> AssociatedFile -> Key -> Annex ()
|
||||
syncFile rs af k = do
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -34,6 +34,7 @@ git-annex (5.20150529) UNRELEASED; urgency=medium
|
|||
* debian/cabal-wrapper: Removed this hack which should not be needed anymore.
|
||||
* info: Added json output for "backend usage", "numcopies stats",
|
||||
"repositories containing these files", and "transfers in progress".
|
||||
* sync: Add support for --all and --unused.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Sat, 30 May 2015 02:07:18 -0400
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ those branches on the remote repositories. You can use standard git
|
|||
commands to do each of those steps by hand, or if you don't want to
|
||||
worry about the details, you can use sync.
|
||||
|
||||
The content of annexed objects is not synced by default, but the --content
|
||||
option (see below) can make that also be synchronized.
|
||||
|
||||
Merge conflicts are automatically handled by sync. When two conflicting
|
||||
versions of a file have been committed, both will be added to the tree,
|
||||
under different filenames. For example, file "foo" would be replaced
|
||||
|
@ -31,9 +34,12 @@ tree with changes made to the local repository. However, those changes
|
|||
are pushed to the remote, so they can be merged into its working tree
|
||||
by running "git annex sync" on the remote.
|
||||
|
||||
|
||||
# OPTIONS
|
||||
|
||||
* `--message=msg`
|
||||
|
||||
Use this option to specify a commit message.
|
||||
|
||||
* `--fast`
|
||||
|
||||
Only sync with the remotes with the lowest annex-cost value configured.
|
||||
|
@ -41,20 +47,29 @@ by running "git annex sync" on the remote.
|
|||
* `--content`
|
||||
|
||||
Normally, syncing does not transfer the contents of annexed files.
|
||||
This option causes the file contents to also be uploaded and downloaded
|
||||
as necessary.
|
||||
This option causes the content of files in the work tree
|
||||
to also be uploaded and downloaded as necessary.
|
||||
|
||||
By default, this tries to get each annexed file that the local repository
|
||||
does not yet have, and then copies each file to every remote that it is
|
||||
syncing with. This behavior can be overridden by configuring the preferred
|
||||
content of a repository. See [[git-annex-preferred-content]](1).
|
||||
By default, this tries to get each annexed file in the work tree
|
||||
that the local repository does not yet have, and then copies each
|
||||
file in the work tree to every remote that it is syncing with.
|
||||
This behavior can be overridden by configuring the preferred content
|
||||
of a repository. See [[git-annex-preferred-content]](1).
|
||||
|
||||
To make two repositories have the same set of files, you should use
|
||||
[[git-annex-mirror]](1) instead of this flag.
|
||||
* `--all`
|
||||
|
||||
* `--message=msg`
|
||||
This option, when combined with `--content`, makes all available versions
|
||||
of all files be synced, when preferred content settings allow.
|
||||
|
||||
Use this option to specify a commit message.
|
||||
Note that preferred content settings that use `include=` or `exclude=`
|
||||
will only match the version of files currently in the work tree, but not
|
||||
past versions of files.
|
||||
|
||||
* `--unused`
|
||||
|
||||
This option, when combined with `--content`, makes files
|
||||
found by last run of git-annex unused be synced, when preferred content
|
||||
settings allow.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
|
@ -62,8 +77,6 @@ by running "git annex sync" on the remote.
|
|||
|
||||
[[git-annex-preferred-content]](1)
|
||||
|
||||
[[git-annex-mirror]](1)
|
||||
|
||||
# AUTHOR
|
||||
|
||||
Joey Hess <id@joeyh.name>
|
||||
|
|
|
@ -18,3 +18,5 @@ Please add an `--all` option to the `sync` command
|
|||
Thanks
|
||||
|
||||
Andrew
|
||||
|
||||
> Implemented; [[done]]. --[[Joey]]
|
||||
|
|
Loading…
Add table
Reference in a new issue