New submission from Ben Franksen <[email protected]>: 1 patch for repository https://darcs.net/screened:
patch 212609904f656ab12ded73ce43a33fdd61f3c004 Author: Ben Franksen <[email protected]> Date: Tue Nov 29 01:38:29 CET 2022 * remove unused listInventoriesRepoDir and listPatchesLocalBucketed These functions were used by the old `optimize clean` command and are now obsolete. This enables further cleanups, since we no longer have to handle plain versus bucketed layout. ---------- files: patch-preview.txt, remove-unused-listinventoriesrepodir-and-listpatcheslocalbucketed.dpatch messages: 24154 nosy: bfrk status: needs-screening title: remove unused listInventoriesRepoDir and listPatchesLo... __________________________________ Darcs bug tracker <[email protected]> <https://bugs.darcs.net/patch2447> __________________________________
[remove unused listInventoriesRepoDir and listPatchesLocalBucketed Ben Franksen <[email protected]>**20221129003829 Ignore-this: 5e46da17e470fab2d87e12347ebf166ac6b51a0711a4cc02d6e0b8211cd261d995ec714654816504 These functions were used by the old `optimize clean` command and are now obsolete. This enables further cleanups, since we no longer have to handle plain versus bucketed layout. ] hunk ./src/Darcs/Repository/Traverse.hs 5 - , listInventoriesRepoDir - , listPatchesLocalBucketed hunk ./src/Darcs/Repository/Traverse.hs 10 -import Data.Maybe ( fromJust ) hunk ./src/Darcs/Repository/Traverse.hs 33 - ( tentativeHashedInventory + ( tentativeHashedInventoryPath hunk ./src/Darcs/Repository/Traverse.hs 35 - , inventoriesDir hunk ./src/Darcs/Repository/Traverse.hs 39 -import Darcs.Repository.Prefs ( globalCacheDir ) hunk ./src/Darcs/Repository/Traverse.hs 44 - , bucketFolder hunk ./src/Darcs/Repository/Traverse.hs 47 -import Darcs.Util.Global ( darcsdir, debugMessage ) +import Darcs.Util.Global ( debugMessage ) hunk ./src/Darcs/Repository/Traverse.hs 55 --- | The way patchfiles, inventories, and pristine trees are stored. --- 'PlainLayout' means all files are in the same directory. 'BucketedLayout' --- means we create a second level of subdirectories, such that all files whose --- hash starts with the same two letters are in the same directory. --- Currently, only the global cache uses 'BucketedLayout' while repositories --- use the 'PlainLayout'. -data DirLayout = PlainLayout | BucketedLayout - hunk ./src/Darcs/Repository/Traverse.hs 105 - hs <- (specialPatches ++) <$> listPatchesLocal PlainLayout darcsdir darcsdir + hs <- (specialPatches ++) <$> listPatchesLocal hunk ./src/Darcs/Repository/Traverse.hs 110 --- The first argument can be readInventory or readInventoryLocal. --- The second argument specifies whether the files are expected --- to be stored in plain or in bucketed format. --- The third argument is the directory of the parent inventory files. --- The fourth argument is the directory of the head inventory file. -listInventoriesWith - :: (FilePath -> IO Inventory) - -> DirLayout - -> String -> String -> IO [String] -listInventoriesWith readInv dirformat baseDir startDir = do - mbStartingWithInv <- getStartingWithHash startDir tentativeHashedInventory - followStartingWiths mbStartingWithInv +-- The argument can be 'readInventory' or 'readInventoryLocal'. +listInventoriesWith :: (FilePath -> IO Inventory) -> IO [String] +listInventoriesWith readInv = do + mbNextInv <- getParent tentativeHashedInventoryPath + withCurrentDirectory inventoriesDirPath (follow mbNextInv) hunk ./src/Darcs/Repository/Traverse.hs 116 - getStartingWithHash dir file = inventoryParent <$> readInv (dir </> file) - - invDir = baseDir </> inventoriesDir - nextDir dir = case dirformat of - BucketedLayout -> invDir </> bucketFolder dir - PlainLayout -> invDir - - followStartingWiths Nothing = return [] - followStartingWiths (Just hash) = do - let startingWith = encodeValidHash hash - mbNextInv <- getStartingWithHash (nextDir startingWith) startingWith - (startingWith :) <$> followStartingWiths mbNextInv + getParent path = inventoryParent <$> readInv path + follow Nothing = return [] + follow (Just hash) = do + let parentFileName = encodeValidHash hash + mbNextInv <- getParent parentFileName + (parentFileName :) <$> follow mbNextInv hunk ./src/Darcs/Repository/Traverse.hs 126 -listInventories = - listInventoriesWith readInventory PlainLayout darcsdir darcsdir +listInventories = listInventoriesWith readInventory hunk ./src/Darcs/Repository/Traverse.hs 131 -listInventoriesLocal = - listInventoriesWith readInventoryLocal PlainLayout darcsdir darcsdir +listInventoriesLocal = listInventoriesWith readInventoryLocal hunk ./src/Darcs/Repository/Traverse.hs 133 --- | Return a list of the inventories hashes. --- The argument @repoDir@ is the directory of the repository from which --- we are going to read the head inventory file. --- The rest of hashed files are read from the global cache. -listInventoriesRepoDir :: String -> IO [String] -listInventoriesRepoDir repoDir = do - gCacheDir' <- globalCacheDir - let gCacheInvDir = fromJust gCacheDir' - listInventoriesWith - readInventoryLocal - BucketedLayout - gCacheInvDir - (repoDir </> darcsdir) - hunk ./src/Darcs/Repository/Traverse.hs 138 --- --- * The first argument specifies whether the files are expected --- to be stored in plain or in bucketed format. --- * The second argument is the directory of the parent inventory. --- * The third argument is the directory of the head inventory. -listPatchesLocal :: DirLayout -> String -> String -> IO [String] -listPatchesLocal dirformat baseDir startDir = do - inventory <- readInventory (startDir </> tentativeHashedInventory) +listPatchesLocal :: IO [String] +listPatchesLocal = do + inventory <- readInventory tentativeHashedInventoryPath hunk ./src/Darcs/Repository/Traverse.hs 145 - invDir = baseDir </> inventoriesDir - nextDir dir = - case dirformat of - BucketedLayout -> invDir </> bucketFolder dir - PlainLayout -> invDir + invDir = inventoriesDirPath hunk ./src/Darcs/Repository/Traverse.hs 149 - inv <- readInventoryLocal (nextDir startingWith </> startingWith) + inv <- readInventoryLocal (invDir </> startingWith) hunk ./src/Darcs/Repository/Traverse.hs 153 --- |listPatchesLocalBucketed is similar to listPatchesLocal, but --- it read the inventory directory under @darcsDir@ in bucketed format. -listPatchesLocalBucketed :: String -> String -> IO [String] -listPatchesLocalBucketed = listPatchesLocal BucketedLayout -
remove-unused-listinventoriesrepodir-and-listpatcheslocalbucketed.dpatch
Description: application/darcs-patch
_______________________________________________ darcs-devel mailing list [email protected] https://lists.darcs.net/mailman/listinfo/darcs-devel
