[darcs-users] darcs patch: Add get_unrecorded_in_files_unsorted fun... (and 6 more)

Eric Kow kowey at darcs.net
Sun Mar 22 20:35:37 UTC 2009


Hi Dmitry,

Is this one you could review?
Thanks!

On Sun, Mar 22, 2009 at 16:54:22 +0100, Reinier Lamers wrote:
> These changes make darcs make more use of the faster get_unrecorded_in_files
> function that I wrote during the hacking sprint in October. I have not heard
> of any bugs in that code.
> 
> The code for the remove command does some juggling with slurpies. Those 
> slurpies are going to be different because of the changes below, but I
> believe that the pieces that darcs actually looks at remain the same.
> 
> Fri Mar 20 23:08:29 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Add get_unrecorded_in_files_unsorted function
> 
> Fri Mar 20 23:18:32 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Make record look only at cmdline arg files, if any
> 
> Sat Mar 21 16:26:16 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Use get_unrecorded_in_files_unsorted in changes command
> 
> Sun Mar 22 15:50:04 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Use faster get_unrecorded_in_files in revert command
> 
> Sun Mar 22 15:50:47 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Add haddock comment to Darcs.Commands.Unrecord.generic_obliterate_cmd
> 
> Sun Mar 22 15:59:57 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Use faster get_unrecorded_in_files in amend-record command
> 
> Sun Mar 22 16:21:54 CET 2009  Reinier Lamers <tux_rocker at reinier.de>
>   * Use faster get_unrecorded_in_files in remove command

Add get_unrecorded_in_files_unsorted function
---------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090320220829
>  Ignore-this: c6dd241aea7a8bec83e3709e07db67c3
> ] hunk ./src/Darcs/Repository.hs 34
>                      slurp_recorded, slurp_recorded_and_unrecorded,
>                      withRecorded,
>                      get_unrecorded, get_unrecorded_unsorted, get_unrecorded_no_look_for_adds,
> -                    get_unrecorded_in_files,
> +                    get_unrecorded_in_files, get_unrecorded_in_files_unsorted,
>                      read_repo, sync_repo,
>                      prefsUrl,
>                      add_to_pending,
> hunk ./src/Darcs/Repository.hs 66
>       slurp_recorded, slurp_recorded_and_unrecorded,
>       withRecorded,
>       get_unrecorded, get_unrecorded_unsorted, get_unrecorded_no_look_for_adds,
> -     get_unrecorded_in_files,
> +     get_unrecorded_in_files, get_unrecorded_in_files_unsorted,
>       read_repo, sync_repo,
>       prefsUrl, checkPristineAgainstSlurpy,
>       add_to_pending,
> hunk ./src/Darcs/Repository/Internal.hs 33
>                      withRecorded,
>                      checkPristineAgainstSlurpy,
>                      get_unrecorded, get_unrecorded_unsorted, get_unrecorded_no_look_for_adds,
> -                    get_unrecorded_in_files,
> +                    get_unrecorded_in_files, get_unrecorded_in_files_unsorted,
>                      read_repo, sync_repo,
>                      prefsUrl, makePatchLazy,
>                      add_to_pending,
> hunk ./src/Darcs/Repository/Internal.hs 398
>  get_unrecorded_no_look_for_adds r paths = get_unrecorded_private (filter (/= LookForAdds)) r paths 
>  
>  get_unrecorded_unsorted :: RepoPatch p => Repository p C(r u t) -> IO (FL Prim C(r u))
> -get_unrecorded_unsorted r = get_unrecorded_private (AnyOrder:) r []
> +get_unrecorded_unsorted r = get_unrecorded_in_files_unsorted r []
>  
>  get_unrecorded :: RepoPatch p => Repository p C(r u t) -> IO (FL Prim C(r u))
>  get_unrecorded r = get_unrecorded_private id r []
> hunk ./src/Darcs/Repository/Internal.hs 403
>  
> +-- | Gets the unrecorded changes in the given paths in the current repository,
> +--   without sorting them for presentation to the user
> +get_unrecorded_in_files_unsorted :: RepoPatch p => Repository p C(r u t) -> [FileName] -> IO (FL Prim C(r u))
> +get_unrecorded_in_files_unsorted = get_unrecorded_private (AnyOrder:)
> +
>  -- | Gets the unrecorded changes in the given paths in the current repository.
>  get_unrecorded_in_files :: RepoPatch p => Repository p C(r u t) -> [FileName] -> IO (FL Prim C(r u))
>  get_unrecorded_in_files = get_unrecorded_private id 

Make record look only at cmdline arg files, if any
--------------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090320221832
>  Ignore-this: 1d88e419cc27ef94790e3944a6cd4c57
> ] hunk ./src/Darcs/Commands/Record.lhs 38
>  import Darcs.Lock ( readBinFile, writeBinFile, world_readable_temp, appendToFile, removeFileMayNotExist )
>  import Darcs.Hopefully ( info, n2pia )
>  import Darcs.Repository ( Repository, amInRepository, withRepoLock, ($-),
> -                          get_unrecorded, get_unrecorded_unsorted, withGutsOf,
> +                          get_unrecorded_in_files,
> +                          get_unrecorded_in_files_unsorted, withGutsOf,
>                      sync_repo, read_repo,
>                      slurp_recorded,
>                      tentativelyAddPatch, finalizeRepositoryChanges,
> hunk ./src/Darcs/Commands/Record.lhs 152
>      when (((not $ null non_existent_files) || (not $ null non_repo_files)) && null existing_files) $
>           fail "None of the files you specified exist!"
>      debugMessage "About to get the unrecorded changes."
> -    changes <- if All `elem` opts then get_unrecorded_unsorted repository
> -                                  else get_unrecorded repository
> +    let existing_fns = map sp2fn existing_files
> +    changes <- if All `elem` opts then get_unrecorded_in_files_unsorted repository existing_fns
> +                                  else get_unrecorded_in_files repository existing_fns
>      debugMessage "I've gotten unrecorded."
>      case allow_empty_with_askdeps changes of
>        Nothing -> do when (Pipe `elem` opts) $ do get_date opts

Use get_unrecorded_in_files_unsorted in changes command
-------------------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090321152616
>  Ignore-this: 3c8c091d76052765b4b47f0d20714fa9
> ] hunk ./src/Darcs/Commands/Changes.lhs 47
>                        )
>  import Darcs.RepoPath ( toFilePath, rootDirectory )
>  import Darcs.Patch.FileName ( fp2fn, fn2fp, norm_path )
> -import Darcs.Repository ( Repository, PatchSet, PatchInfoAnd, get_unrecorded_unsorted,
> +import Darcs.Repository ( Repository, PatchSet, PatchInfoAnd,
> +                          get_unrecorded_in_files_unsorted,
>                            withRepositoryDirectory, ($-), findRepository,
>                            read_repo )
>  import Darcs.Patch.Info ( to_xml, showPatchInfo )
> hunk ./src/Darcs/Commands/Changes.lhs 113
>    withRepositoryDirectory opts repodir $- \repository -> do
>    unless (Debug `elem` opts) $ setProgressMode False
>    files <- sort `fmap` fixSubPaths opts args
> -  unrec <- get_unrecorded_unsorted repository
> +  unrec <- get_unrecorded_in_files_unsorted repository (map (fp2fn . toFilePath) files)
>             `catch` \_ -> return identity -- this is triggered when repository is remote
>    let filez = map (fn2fp . norm_path . fp2fn) $ apply_to_filepaths (invert unrec) $ map toFilePath files
>        filtered_changes p = maybe_reverse $ get_changes_info opts filez p

Use faster get_unrecorded_in_files in revert command
----------------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090322145004
>  Ignore-this: 303dc260e3fe8f01019703449dad017f
> ] hunk ./src/Darcs/Commands/Revert.lhs 35
>                          list_registered_files, umask_option,
>                        )
>  import Darcs.Utils ( askUser )
> -import Darcs.RepoPath ( toFilePath )
> +import Darcs.RepoPath ( toFilePath, sp2fn )
>  import Darcs.Repository ( withRepoLock, ($-), withGutsOf,
> hunk ./src/Darcs/Commands/Revert.lhs 37
> -                    get_unrecorded, get_unrecorded_unsorted,
> +                    get_unrecorded_in_files,
> +                    get_unrecorded_in_files_unsorted,
>                      add_to_pending, sync_repo,
>                      applyToWorking,
>                      amInRepository, slurp_recorded,
> hunk ./src/Darcs/Commands/Revert.lhs 87
>  revert_cmd :: [DarcsFlag] -> [String] -> IO ()
>  revert_cmd opts args = withRepoLock opts $- \repository -> do
>    files <- sort `fmap` fixSubPaths opts args
> +  let files_fn = map sp2fn files
>    when (areFileArgs files) $
>         putStrLn $ "Reverting changes in "++unwords (map show files)++"..\n"
>    changes <- if All `elem` opts
> hunk ./src/Darcs/Commands/Revert.lhs 91
> -                   then get_unrecorded_unsorted repository
> -                   else get_unrecorded repository
> +                   then get_unrecorded_in_files_unsorted repository files_fn
> +                   else get_unrecorded_in_files repository files_fn
>    let pre_changed_files = apply_to_filepaths (invert changes) (map toFilePath files)
>    rec <- slurp_recorded repository
>    case unsafeUnseal $ choose_touching pre_changed_files changes of

Add haddock comment to Darcs.Commands.Unrecord.generic_obliterate_cmd
---------------------------------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090322145047
>  Ignore-this: 7fcf3661b99d39b7e61231c6ffb3e935
> ] hunk ./src/Darcs/Commands/Unrecord.lhs 282
>  obliterate_cmd :: [DarcsFlag] -> [String] -> IO ()
>  obliterate_cmd = generic_obliterate_cmd "obliterate"
>  
> -generic_obliterate_cmd :: String -> [DarcsFlag] -> [String] -> IO ()
> +-- | generic_obliterate_cmd is the function that executes the "obliterate" and
> +--   "unpull" commands.
> +generic_obliterate_cmd :: String      -- ^ The name under which the command is invoked (@unpull@ or @obliterate@)
> +                       -> [DarcsFlag] -- ^ The flags given on the command line
> +                       -> [String]    -- ^ Files given on the command line (unused)
> +                       -> IO ()
>  generic_obliterate_cmd cmdname opts _ = withRepoLock opts $- \repository -> do
>    let (logMessage,_,_) = loggers opts
>    pend <- get_unrecorded repository

Use faster get_unrecorded_in_files in amend-record command
----------------------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090322145957
>  Ignore-this: 9704a3d2c97698bb52b008ea9c7a326e
> ] hunk ./src/Darcs/Commands/AmendRecord.lhs 30
>  import Darcs.Flags ( DarcsFlag(Author, LogFile, PatchName,
>                                 EditLongComment, PromptLongComment) )
>  import Darcs.Lock ( world_readable_temp )
> -import Darcs.RepoPath ( toFilePath )
> +import Darcs.RepoPath ( toFilePath, sp2fn )
>  import Darcs.Hopefully ( PatchInfoAnd, n2pia, hopefully, info )
>  import Darcs.Repository ( withRepoLock, ($-), withGutsOf,
> hunk ./src/Darcs/Commands/AmendRecord.lhs 33
> -                    get_unrecorded, get_unrecorded_unsorted,
> +                    get_unrecorded_in_files, get_unrecorded_in_files_unsorted,
>                      tentativelyRemovePatches, tentativelyAddPatch, finalizeRepositoryChanges,
>                      sync_repo, amInRepository,
>                    )
> hunk ./src/Darcs/Commands/AmendRecord.lhs 130
>           putStrLn $ "Amending changes in "++unwords (map show files)++":\n"
>      with_selected_patch_from_repo "amend" repository opts $ \ (_ :> oldp) -> do
>          ch <- if All `elem` opts 
> -              then get_unrecorded_unsorted repository
> -              else get_unrecorded repository
> +              then get_unrecorded_in_files_unsorted repository (map sp2fn files)
> +              else get_unrecorded_in_files repository (map sp2fn files)
>          case ch of
>            NilFL | not edit_metadata -> putStrLn "No changes!"
>            _ -> do

Use faster get_unrecorded_in_files in remove command
----------------------------------------------------
> Reinier Lamers <tux_rocker at reinier.de>**20090322152154
>  Ignore-this: 35c52e64536de8d4797109dd12e438d9
> ] hunk ./src/Darcs/Commands/Remove.lhs 35
>                        )
>  import Darcs.RepoPath ( SubPath, toFilePath, sp2fn )
>  import Darcs.Repository ( Repository, withRepoLock, ($-), amInRepository,
> -                          slurp_pending, slurp_recorded, get_unrecorded, add_to_pending )
> +                          slurp_pending, slurp_recorded,
> +                          get_unrecorded_in_files, add_to_pending )
>  import Darcs.Patch ( RepoPatch, Prim, apply_to_slurpy, adddir, rmdir, addfile, rmfile )
>  import Darcs.Ordered ( FL(..), (+>+) )
>  import Darcs.SlurpDirectory ( slurp_removedir, slurp_removefile )
> hunk ./src/Darcs/Commands/Remove.lhs 83
>  make_remove_patch repository files =
>                            do s <- slurp_pending repository
>                               srecorded <- slurp_recorded repository
> -                             pend <- get_unrecorded repository
> +                             pend <- get_unrecorded_in_files repository (map sp2fn files)
>                               let sunrec = fromJust $ apply_to_slurpy pend srecorded
>                               wt <- filetype_function
>                               mrp wt s sunrec files
> 

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090322/336b03f9/attachment-0001.pgp>


More information about the darcs-users mailing list