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.
|
-- Options for matching on annexed keys, rather than work tree files.
|
||||||
keyOptions :: [Option]
|
keyOptions :: [Option]
|
||||||
keyOptions =
|
keyOptions = [ allOption, unusedOption, keyOption]
|
||||||
[ Option ['A'] ["all"] (NoArg (Annex.setFlag "all"))
|
|
||||||
|
allOption :: Option
|
||||||
|
allOption = Option ['A'] ["all"] (NoArg (Annex.setFlag "all"))
|
||||||
"operate on all versions of all files"
|
"operate on all versions of all files"
|
||||||
, Option ['U'] ["unused"] (NoArg (Annex.setFlag "unused"))
|
|
||||||
|
unusedOption :: Option
|
||||||
|
unusedOption = Option ['U'] ["unused"] (NoArg (Annex.setFlag "unused"))
|
||||||
"operate on files found by last run of git-annex unused"
|
"operate on files found by last run of git-annex unused"
|
||||||
, keyOption
|
|
||||||
]
|
|
||||||
|
|
||||||
keyOption :: Option
|
keyOption :: Option
|
||||||
keyOption = Option [] ["key"] (ReqArg (Annex.setField "key") paramKey)
|
keyOption = Option [] ["key"] (ReqArg (Annex.setField "key") paramKey)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- the values a user passes to a command, and prepare actions operating
|
- the values a user passes to a command, and prepare actions operating
|
||||||
- on them.
|
- 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.
|
- 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
|
- Otherwise falls back to a regular CommandSeek action on
|
||||||
- whatever params were passed. -}
|
- whatever params were passed. -}
|
||||||
withKeyOptions :: Bool -> (Key -> CommandStart) -> CommandSeek -> CommandSeek
|
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
|
bare <- fromRepo Git.repoIsLocalBare
|
||||||
allkeys <- Annex.getFlag "all"
|
allkeys <- Annex.getFlag "all"
|
||||||
unused <- Annex.getFlag "unused"
|
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"
|
_ -> error "Can only specify one of file names, --all, --unused, --key, or --incomplete"
|
||||||
where
|
where
|
||||||
go True _ = error "Cannot use --auto with --all or --unused or --key or --incomplete"
|
go True _ = error "Cannot use --auto with --all or --unused or --key or --incomplete"
|
||||||
go False a = do
|
go False getkeys = keyop getkeys
|
||||||
matcher <- Limit.getMatcher
|
|
||||||
seekActions $ map (process matcher) <$> a
|
|
||||||
process matcher k = ifM (matcher $ MatchingKey k)
|
|
||||||
( keyop k , return Nothing)
|
|
||||||
incompletekeys = staleKeysPrune gitAnnexTmpObjectDir True
|
incompletekeys = staleKeysPrune gitAnnexTmpObjectDir True
|
||||||
|
|
||||||
prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart]
|
prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart]
|
||||||
|
|
|
@ -58,6 +58,8 @@ syncOptions :: [Option]
|
||||||
syncOptions =
|
syncOptions =
|
||||||
[ contentOption
|
[ contentOption
|
||||||
, messageOption
|
, messageOption
|
||||||
|
, allOption
|
||||||
|
, unusedOption
|
||||||
]
|
]
|
||||||
|
|
||||||
contentOption :: Option
|
contentOption :: Option
|
||||||
|
@ -371,12 +373,19 @@ newer remote b = do
|
||||||
seekSyncContent :: [Remote] -> Annex Bool
|
seekSyncContent :: [Remote] -> Annex Bool
|
||||||
seekSyncContent rs = do
|
seekSyncContent rs = do
|
||||||
mvar <- liftIO newEmptyMVar
|
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
|
liftIO $ not <$> isEmptyMVar mvar
|
||||||
where
|
where
|
||||||
go mvar f = ifAnnexed f
|
seekworktree mvar = seekHelper LsFiles.inRepo >=>
|
||||||
(\v -> void (liftIO (tryPutMVar mvar ())) >> syncFile rs (Just f) v)
|
mapM_ (\f -> ifAnnexed f (go mvar (Just f)) noop)
|
||||||
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 :: [Remote] -> AssociatedFile -> Key -> Annex ()
|
||||||
syncFile rs af k = do
|
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.
|
* debian/cabal-wrapper: Removed this hack which should not be needed anymore.
|
||||||
* info: Added json output for "backend usage", "numcopies stats",
|
* info: Added json output for "backend usage", "numcopies stats",
|
||||||
"repositories containing these files", and "transfers in progress".
|
"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
|
-- 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
|
commands to do each of those steps by hand, or if you don't want to
|
||||||
worry about the details, you can use sync.
|
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
|
Merge conflicts are automatically handled by sync. When two conflicting
|
||||||
versions of a file have been committed, both will be added to the tree,
|
versions of a file have been committed, both will be added to the tree,
|
||||||
under different filenames. For example, file "foo" would be replaced
|
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
|
are pushed to the remote, so they can be merged into its working tree
|
||||||
by running "git annex sync" on the remote.
|
by running "git annex sync" on the remote.
|
||||||
|
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
|
* `--message=msg`
|
||||||
|
|
||||||
|
Use this option to specify a commit message.
|
||||||
|
|
||||||
* `--fast`
|
* `--fast`
|
||||||
|
|
||||||
Only sync with the remotes with the lowest annex-cost value configured.
|
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`
|
* `--content`
|
||||||
|
|
||||||
Normally, syncing does not transfer the contents of annexed files.
|
Normally, syncing does not transfer the contents of annexed files.
|
||||||
This option causes the file contents to also be uploaded and downloaded
|
This option causes the content of files in the work tree
|
||||||
as necessary.
|
to also be uploaded and downloaded as necessary.
|
||||||
|
|
||||||
By default, this tries to get each annexed file that the local repository
|
By default, this tries to get each annexed file in the work tree
|
||||||
does not yet have, and then copies each file to every remote that it is
|
that the local repository does not yet have, and then copies each
|
||||||
syncing with. This behavior can be overridden by configuring the preferred
|
file in the work tree to every remote that it is syncing with.
|
||||||
content of a repository. See [[git-annex-preferred-content]](1).
|
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
|
* `--all`
|
||||||
[[git-annex-mirror]](1) instead of this flag.
|
|
||||||
|
|
||||||
* `--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
|
# SEE ALSO
|
||||||
|
|
||||||
|
@ -62,8 +77,6 @@ by running "git annex sync" on the remote.
|
||||||
|
|
||||||
[[git-annex-preferred-content]](1)
|
[[git-annex-preferred-content]](1)
|
||||||
|
|
||||||
[[git-annex-mirror]](1)
|
|
||||||
|
|
||||||
# AUTHOR
|
# AUTHOR
|
||||||
|
|
||||||
Joey Hess <id@joeyh.name>
|
Joey Hess <id@joeyh.name>
|
||||||
|
|
|
@ -18,3 +18,5 @@ Please add an `--all` option to the `sync` command
|
||||||
Thanks
|
Thanks
|
||||||
|
|
||||||
Andrew
|
Andrew
|
||||||
|
|
||||||
|
> Implemented; [[done]]. --[[Joey]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue