[darcs-users] [patch289] Resolve issue1871: announceFiles should ... (and 1 more)

Eric Kow kowey at darcs.net
Wed Jun 30 18:24:02 UTC 2010


On Mon, Jun 28, 2010 at 14:49:55 +0000, Petr Ročkai wrote:
> Mon Jun 28 16:39:03 CEST 2010  Petr Rockai <me at mornfall.net>
>   * Resolve issue1871: announceFiles should not give empty list for ".".
> 
> Mon Jun 28 16:49:32 CEST 2010  Petr Rockai <me at mornfall.net>
>   * Resolve issue1845: fix "darcs record f" for f a removed, version-tracked file.

Applied, thanks!

Resolve issue1871: announceFiles should not give empty list for ".".
--------------------------------------------------------------------
> move ./tests/failing-issue1871-record-dot.sh ./tests/issue1871-record-dot.sh
> hunk ./src/Darcs/Commands/WhatsNew.lhs 123

Useful context:

   -- as opposed to just '.'
   areFileArgs :: [SubPath] -> Bool
   areFileArgs rps = concatMap toFilePath rps /= ""
  
   announceFiles :: (RepoPatch p) => Repository p C(r u t) -> [SubPath] -> String -> IO [SubPath]
   announceFiles repo files message =
       if (areFileArgs files) then do
         pristine <- readRecordedAndPending repo
         -- TODO this is slightly inefficient, since we should really somehow
         -- extract the unrecorded state as a side-effect of unrecordedChanges
         index <- readUnrecorded repo files
         nonboring <- restrictBoring index
         working <- applyTreeFilter nonboring `fmap` readPlainTree "."
         let paths = map (fn2fp . sp2fn) files
             check = virtualTreeIO (mapM exists $ map floatPath paths)
         (in_working, _) <- check working
         (in_pending, _) <- check pristine
>        mapM_ maybe_warn $ zip3 paths in_working in_pending
>        putStrLn $ message ++ " " ++ unwords (map show files)++":\n"
>        return [ path | (path, True) <- zip files in_working ]
> -     else return []
> +     else return files
       where maybe_warn (file, False, False) =
                 putStrLn $ "WARNING: File '"++file++"' does not exist!"
             maybe_warn (file, True, False) | LookForAdds `notElem` extractOptions repo =
                 putStrLn $ "WARNING: File '" ++ file ++ "' not in repository!"
             maybe_warn _ = return ()

The wider context is that announceFiles determines what what subset of files we
pass in on the command line actually exist in the working directory (and
pending below).

Future work:

* This function seems to be misnamed or is doing too much work.
  Maybe the user IO should be taken out?

* I was also confused by areFileArgs until I read the definition
  Wonder if there's a useful rename there...

Resolve issue1845: fix "darcs record f" for f a removed, version-tracked file.
------------------------------------------------------------------------------
> -      return [ path | (path, True) <- zip files in_working ]
> +      return [ path | (path, True) <- zip files (zipWith (||) in_working in_pending) ]

Couldn't see a simpler way to write this :-/ Oh well!

Note that issue1845 seems to be reporting a red herring.
I've added a message to the ticket indicating this.

> +. lib                           # Load some portability helpers.
> +rm -rf R                        # Another script may have left a mess.
> +darcs init      --repo R        # Create our test repos.
> +
> +cd R
> +echo 'Example content.' > f
> +darcs rec -lam "first"
> +rm -f f
> +set -o pipefail
> +echo n | darcs record f 2>&1 | tee log

Petr just taught me a new shell trick:

Bash manpage

  The return status of a pipeline is the exit status of the last command,
  unless the pipefail  option is  enabled.  If pipefail is enabled, the
  pipeline's return status is the value of the last (right‐ most) command to exit
  with a non-zero status, or zero if all commands exit  successfully.   If  the
  reserved  word  !  precedes a pipeline, the exit status of that pipeline is the
  logical negation of the exit status as described above.  The shell waits for
  all commands in the pipeline to  terminate before returning a value.
  
> +not grep "None of the files" log
> +cd ..

-- 
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: 198 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20100630/2618712a/attachment.pgp>


More information about the darcs-users mailing list