darcs

Patch 604 Resolve issue2054: option --boring does ... (and 2 more)

Title Resolve issue2054: option --boring does ... (and 2 more)
Superseder Nosy List scott
Related Issues darcs add -r --boring sometimes skips boring files, option --boring does not work with self-made boringfile
View: 1332, 2054
Status accepted Assigned To
Milestone

Created on 2011-05-09.05:55:28 by scott, last changed 2011-12-27.21:54:10 by ganesh. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
resolve-issue2054_-option-__boring-does-not-work-with-self_made-boringfile.dpatch scott, 2011-05-09.05:55:28 text/x-darcs-patch
unnamed scott, 2011-05-09.05:55:28
See mailing list archives for discussion on individual patches.
Messages
msg14018 (view) Author: scott Date: 2011-05-09.05:55:28
Resolving issue2054 (http://bugs.darcs.net/issue2054) to make the `--boring`
option to `whatsnew` ignore the boring file (as opposed to do nothing).

Since simply ignoring the boring file results in all files in darcsdir
being listed - which is illogical and dangerous - files in the darcsdir are
always discarded.

3 patches for repository http://darcs.net/screened:

Sun May  8 22:35:17 EDT 2011  Scott Lawrence <bytbox@gmail.com>
  * Resolve issue2054: option --boring does not work with self-made boringfile

Sun May  8 22:59:48 EDT 2011  Scott Lawrence <bytbox@gmail.com>
  * Fix warnings in new unrecordedChanges code via slight refactoring

Mon May  9 01:35:05 EDT 2011  Scott Lawrence <bytbox@gmail.com>
  * Ignore files in darcsdir, even with --boring
Attachments
msg14445 (view) Author: darcswatch Date: 2011-05-17.12:55:34
This patch bundle (with 3 patches) was just applied to the repository http://darcs.net/screened.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_screened.html#bundle-3f2aea71f162cabb9993002bffa374f19ae43d52
msg14455 (view) Author: mornfall Date: 2011-05-22.08:20:21
Hi,

some remarks inside.

Scott Lawrence <bugs@darcs.net> writes:
> hunk ./src/Darcs/Flags.hs 133
>                | otherwise = DefaultRemoteDarcs
>  
>  data UseIndex = UseIndex | IgnoreIndex
> -data ScanKnown = ScanKnown | ScanAll
> +data ScanKnown = ScanKnown | ScanAll | ScanAllWithBoring

Maybe just ScanBoring?

> hunk ./src/Darcs/Repository/State.hs 150
>                 (ScanKnown, IgnoreIndex) -> do
>                   guide <- expand current
>                   applyTreeFilter relevant <$> restrict guide <$> readPlainTree "."
> -               (ScanAll, _) -> do
> +               _ -> do
>                   index <- getIndex
>                   nonboring <- restrictBoring index
> hunk ./src/Darcs/Repository/State.hs 153
> -                 plain <- applyTreeFilter relevant <$> applyTreeFilter nonboring <$> readPlainTree "."
> +                 plain <- case scan of
> +                   ScanAll -> applyTreeFilter relevant <$> 
> +                     applyTreeFilter nonboring <$> readPlainTree "."
> +                   ScanAllWithBoring -> applyTreeFilter relevant <$>
> +                     readPlainTree "."
>                   return $ case useidx of
>                     UseIndex -> plain `overlay` index
>                     IgnoreIndex -> plain
> [Fix warnings in new unrecordedChanges code via slight refactoring
> Scott Lawrence <bytbox@gmail.com>**20110509025948
>  Ignore-this: 51ac5e312ba190c9819e96c8a7a5712f
> ] hunk ./src/Darcs/Repository/State.hs 145
>    let getIndex = I.updateIndex =<< (applyTreeFilter relevant <$> readIndex repo)
>        current = applyTreeFilter relevant all_current
>  
> -  working <- case (scan, useidx) of
> -               (ScanKnown, UseIndex) -> getIndex
> -               (ScanKnown, IgnoreIndex) -> do
> -                 guide <- expand current
> -                 applyTreeFilter relevant <$> restrict guide <$> readPlainTree "."
> -               _ -> do
> -                 index <- getIndex
> -                 nonboring <- restrictBoring index
> -                 plain <- case scan of
> -                   ScanAll -> applyTreeFilter relevant <$> 
> -                     applyTreeFilter nonboring <$> readPlainTree "."
> -                   ScanAllWithBoring -> applyTreeFilter relevant <$>
> -                     readPlainTree "."
> -                 return $ case useidx of
> -                   UseIndex -> plain `overlay` index
> -                   IgnoreIndex -> plain
> +  index <- getIndex
> +  working <- case scan of
> +    ScanKnown -> case useidx of
> +      UseIndex -> getIndex
> +      IgnoreIndex -> do
> +        guide <- expand current
> +        applyTreeFilter relevant <$> restrict guide <$> readPlainTree "."
> +    ScanAll -> do
> +      nonboring <- restrictBoring index
> +      plain <- applyTreeFilter relevant <$> applyTreeFilter nonboring <$> readPlainTree "."
> +      return $ case useidx of
> +        UseIndex -> plain `overlay` index
> +        IgnoreIndex -> plain
> +    ScanAllWithBoring -> do
> +      plain <- applyTreeFilter relevant <$> readPlainTree "."
> +      return $ case useidx of
> +        UseIndex -> plain `overlay` index
> +        IgnoreIndex -> plain

I liked the previous version with less repetition more.

>  
>    ft <- filetypeFunction
>    Sealed (diff :: FL (PrimOf p) C(x y)) <- (unFreeLeft `fmap` treeDiff ft current working) :: IO (Sealed (FL (PrimOf p) C(x)))
> [Ignore files in darcsdir, even with --boring
> Scott Lawrence <bytbox@gmail.com>**20110509053505
>  Ignore-this: f8d5c65b1e67992a086693b1bf092601
> ] hunk ./src/Darcs/Repository/Prefs.hs 34
>                     getCaches,
>                     binariesFileHelp, boringFileHelp,
>                     globalCacheDir,
> -                   globalPrefsDirDoc
> +                   globalPrefsDirDoc,
>                   ) where
>  
>  import System.IO.Error ( isDoesNotExistError )
> hunk ./src/Darcs/Repository/State.hs 38
>  import Prelude hiding ( filter )
>  import Control.Monad( when )
>  import Control.Applicative( (<$>) )
> -import Data.Maybe( isJust )
> +import Data.Maybe( isJust, isNothing )
>  import Data.List( union )
> hunk ./src/Darcs/Repository/State.hs 40
> -import Text.Regex( matchRegex )
> +import Text.Regex( mkRegex, matchRegex )
>  
>  import System.Directory( removeFile, doesFileExist, doesDirectoryExist, renameFile )
>  import System.FilePath ( (</>) )
> hunk ./src/Darcs/Repository/State.hs 115
>                                          _ -> True
>    return (TreeFilter restrictTree)
>  
> +restrictDarcsdir :: forall m . TreeFilter m
> +restrictDarcsdir = TreeFilter $ filter $ \p _ -> isNothing $
> +  matchRegex (mkRegex $ "(^|/)"++darcsdir++"($|/)") $ anchorPath "" p
> +

I don't like the use of regex for this. We already have a better way to
do the same thing, it should just be lifted out of restrictBoring:

boring' (AnchoredPath (Name x:_)) | x == BSC.pack darcsdir = False

>  -- | For a repository and an optional list of paths (when Nothing, take
>  -- everything) compute a (forward) list of prims (i.e. a patch) going from the
>  -- recorded state of the repository (pristine) to the unrecorded state of the
> hunk ./src/Darcs/Repository/State.hs 150
>        current = applyTreeFilter relevant all_current
>  
>    index <- getIndex
> -  working <- case scan of
> +  working <- applyTreeFilter restrictDarcsdir <$> case scan of
>      ScanKnown -> case useidx of
>        UseIndex -> getIndex
>        IgnoreIndex -> do

Yours,
   Petr

-- 
id' Ash = Ash; id' Dust = Dust; id' _ = undefined
msg14865 (view) Author: darcswatch Date: 2011-12-27.21:45:27
This patch bundle (with 3 patches) was just applied to the repository http://darcs.net/reviewed.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-3f2aea71f162cabb9993002bffa374f19ae43d52
msg14866 (view) Author: ganesh Date: 2011-12-27.21:54:10
I've pushed this to reviewed, along with a couple of followups to address 
some of Petr's review comments.

Thanks for the fix, Scott!
History
Date User Action Args
2011-05-09 05:55:28scottcreate
2011-05-09 05:57:52darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-3f2aea71f162cabb9993002bffa374f19ae43d52
2011-05-10 18:36:12darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-3f2aea71f162cabb9993002bffa374f19ae43d52 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-3f2aea71f162cabb9993002bffa374f19ae43d52
2011-05-17 12:55:35darcswatchsetstatus: needs-screening -> needs-review
messages: + msg14445
2011-05-22 08:20:22mornfallsetmessages: + msg14455
2011-12-27 21:02:43ganeshsetissues: + option --boring does not work with self-made boringfile
2011-12-27 21:36:27ganeshsetissues: + darcs add -r --boring sometimes skips boring files
2011-12-27 21:45:27darcswatchsetstatus: needs-review -> accepted
messages: + msg14865
2011-12-27 21:54:10ganeshsetmessages: + msg14866