make segmentXargs preserve order
This commit is contained in:
parent
705112903e
commit
7b32e7acb5
2 changed files with 10 additions and 7 deletions
|
@ -290,7 +290,7 @@ handleAdds havelsof delayadd cs = returnWhen (null incomplete) $ do
|
||||||
-- files. The ls-files is run on a batch of files.
|
-- files. The ls-files is run on a batch of files.
|
||||||
findnew [] = return ([], noop)
|
findnew [] = return ([], noop)
|
||||||
findnew pending@(exemplar:_) = do
|
findnew pending@(exemplar:_) = do
|
||||||
let segments = segmentXargs $ map changeFile pending
|
let segments = segmentXargsUnordered $ map changeFile pending
|
||||||
rs <- liftAnnex $ forM segments $ \fs ->
|
rs <- liftAnnex $ forM segments $ \fs ->
|
||||||
inRepo (Git.LsFiles.notInRepo False fs)
|
inRepo (Git.LsFiles.notInRepo False fs)
|
||||||
let (newfiles, cleanup) = foldl'
|
let (newfiles, cleanup) = foldl'
|
||||||
|
@ -457,7 +457,7 @@ safeToAdd havelsof delayadd pending inprocess = do
|
||||||
-}
|
-}
|
||||||
findopenfiles keysources = ifM crippledFileSystem
|
findopenfiles keysources = ifM crippledFileSystem
|
||||||
( liftIO $ do
|
( liftIO $ do
|
||||||
let segments = segmentXargs $ map keyFilename keysources
|
let segments = segmentXargsUnordered $ map keyFilename keysources
|
||||||
concat <$> forM segments (\fs -> Lsof.query $ "--" : fs)
|
concat <$> forM segments (\fs -> Lsof.query $ "--" : fs)
|
||||||
, do
|
, do
|
||||||
tmpdir <- fromRepo gitAnnexTmpMiscDir
|
tmpdir <- fromRepo gitAnnexTmpMiscDir
|
||||||
|
|
|
@ -101,12 +101,15 @@ prop_idempotent_shellEscape s = [s] == (shellUnEscape . shellEscape) s
|
||||||
prop_idempotent_shellEscape_multiword :: [String] -> Bool
|
prop_idempotent_shellEscape_multiword :: [String] -> Bool
|
||||||
prop_idempotent_shellEscape_multiword s = s == (shellUnEscape . unwords . map shellEscape) s
|
prop_idempotent_shellEscape_multiword s = s == (shellUnEscape . unwords . map shellEscape) s
|
||||||
|
|
||||||
{- Segements a list of filenames into groups that are all below the manximum
|
{- Segments a list of filenames into groups that are all below the maximum
|
||||||
- command-line length limit. Does not preserve order. -}
|
- command-line length limit. -}
|
||||||
segmentXargs :: [FilePath] -> [[FilePath]]
|
segmentXargsOrdered :: [FilePath] -> [[FilePath]]
|
||||||
segmentXargs l = go l [] 0 []
|
segmentXargsOrdered = reverse . map reverse . segmentXargsUnordered
|
||||||
|
|
||||||
|
segmentXargsUnordered :: [FilePath] -> [[FilePath]]
|
||||||
|
segmentXargsUnordered l = go l [] 0 []
|
||||||
where
|
where
|
||||||
go [] c _ r = c:r
|
go [] c _ r = (c:r)
|
||||||
go (f:fs) c accumlen r
|
go (f:fs) c accumlen r
|
||||||
| len < maxlen && newlen > maxlen = go (f:fs) [] 0 (c:r)
|
| len < maxlen && newlen > maxlen = go (f:fs) [] 0 (c:r)
|
||||||
| otherwise = go fs (f:c) newlen r
|
| otherwise = go fs (f:c) newlen r
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue