started migrate --update
This is most of the way there, but not quite working. The layout of migrate.tree/ needs to be changed to follow this approach. git log will list all the files in tree order, so the new layout needs to alternate old and new keys. Can that be done? git may not document tree order, or may not preserve it here. Alternatively, change to using git log --format=raw and extract the tree header from that, then use git diff --raw $tree:migrate.tree/old $tree:migrate.tree/new That will be a little more expensive, but only when there are lots of migrations. Sponsored-by: Joshua Antonishen on Patreon
This commit is contained in:
parent
d06aee7ce0
commit
f1ce15036f
9 changed files with 172 additions and 38 deletions
|
@ -28,21 +28,31 @@ cmd = withAnnexOptions [backendOption, annexedMatchingOptions, jsonOptions] $
|
|||
|
||||
data MigrateOptions = MigrateOptions
|
||||
{ migrateThese :: CmdParams
|
||||
, updateOption :: Bool
|
||||
, removeSize :: Bool
|
||||
}
|
||||
|
||||
optParser :: CmdParamsDesc -> Parser MigrateOptions
|
||||
optParser desc = MigrateOptions
|
||||
<$> cmdParams desc
|
||||
<*> switch
|
||||
( long "update"
|
||||
<> help "update for migrations performed elsewhere"
|
||||
)
|
||||
<*> switch
|
||||
( long "remove-size"
|
||||
<> help "remove size field from keys"
|
||||
)
|
||||
|
||||
seek :: MigrateOptions -> CommandSeek
|
||||
seek o = do
|
||||
withFilesInGitAnnex ww seeker =<< workTreeItems ww (migrateThese o)
|
||||
commitMigration
|
||||
seek o
|
||||
| updateOption o = do
|
||||
unless (null (migrateThese o)) $
|
||||
error "Cannot combine --update with files to migrate."
|
||||
commandAction update
|
||||
| otherwise = do
|
||||
withFilesInGitAnnex ww seeker =<< workTreeItems ww (migrateThese o)
|
||||
commitMigration
|
||||
where
|
||||
ww = WarnUnmatchLsFiles "migrate"
|
||||
seeker = AnnexedFileSeeker
|
||||
|
@ -131,3 +141,10 @@ perform onlyremovesize o file oldkey oldkeyrec oldbackend newbackend = go =<< ge
|
|||
| removeSize o = alterKey k $ \kd -> kd { keySize = Nothing }
|
||||
| otherwise = k
|
||||
afile = AssociatedFile (Just file)
|
||||
|
||||
update :: CommandStart
|
||||
update = starting "migrate" (ActionItemOther Nothing) (SeekInput []) $ do
|
||||
streamNewDistributedMigrations $ \oldkey newkey -> do
|
||||
liftIO $ print ("migrate", oldkey, newkey)
|
||||
next $ return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue