darcs

Patch 289 Resolve issue1871: announceFiles should ... (and 1 more)

Title Resolve issue1871: announceFiles should ... (and 1 more)
Superseder Nosy List kowey, mornfall
Related Issues
Status accepted Assigned To
Milestone

Created on 2010-06-28.14:38:29 by mornfall, last changed 2011-05-10.20:05:57 by darcswatch. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
resolve-issue1871_-announcefiles-should-not-give-empty-list-for-____.dpatch mornfall, 2010-06-28.14:38:29 text/x-darcs-patch
resolve-issue1871_-announcefiles-should-not-give-empty-list-for-____.dpatch mornfall, 2010-06-28.14:49:55 text/x-darcs-patch
unnamed mornfall, 2010-06-28.14:38:29
unnamed mornfall, 2010-06-28.14:49:55
See mailing list archives for discussion on individual patches.
Messages
msg11616 (view) Author: mornfall Date: 2010-06-28.14:38:29
Mostly trivia, but cuts down on 2.5-eligible bugs.

Yours,
   Petr.

2 patches for repository darcs-unstable@darcs.net:darcs:

Mon Jun 28 16:39:03 CEST 2010  Petr Rockai <me@mornfall.net>
  * Resolve issue1871: announceFiles should not give empty list for ".".

Mon Jun 28 16:39:14 CEST 2010  Petr Rockai <me@mornfall.net>
  * Fix "darcs record f" for f being a removed, version-tracked file.
Attachments
msg11619 (view) Author: mornfall Date: 2010-06-28.14:49:55
Amended, since the latter issue seems to exist in the tracker as well
(1845. Hopefully I am reading it right...)

2 patches for repository darcs-unstable@darcs.net:darcs:

Mon Jun 28 16:39:03 CEST 2010  Petr Rockai <me@mornfall.net>
  * Resolve issue1871: announceFiles should not give empty list for ".".

Mon Jun 28 16:49:32 CEST 2010  Petr Rockai <me@mornfall.net>
  * Resolve issue1845: fix "darcs record f" for f a removed, version-tracked file.
Attachments
msg11644 (view) Author: kowey Date: 2010-06-30.18:21:07
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@mornfall.net>
>   * Resolve issue1871: announceFiles should not give empty list for ".".
> 
> Mon Jun 28 16:49:32 CEST 2010  Petr Rockai <me@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
msg11648 (view) Author: darcswatch Date: 2010-06-30.18:42:34
This patch bundle (with 2 patches) was just applied to the repository http://darcs.net/.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-de2c4b60f6d3fc76c4ad8b5789fabcbdbda32e80
msg14239 (view) Author: darcswatch Date: 2011-05-10.20:05:57
This patch bundle (with 2 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-de2c4b60f6d3fc76c4ad8b5789fabcbdbda32e80
History
Date User Action Args
2010-06-28 14:38:29mornfallcreate
2010-06-28 14:39:24darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-0359034821098d15c881261e02bf3434c2de4301
2010-06-28 14:49:55mornfallsetfiles: + resolve-issue1871_-announcefiles-should-not-give-empty-list-for-____.dpatch, unnamed
messages: + msg11619
2010-06-28 14:52:02darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-0359034821098d15c881261e02bf3434c2de4301 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-de2c4b60f6d3fc76c4ad8b5789fabcbdbda32e80
2010-06-30 18:21:07koweysetnosy: + kowey
messages: + msg11644
2010-06-30 18:42:34darcswatchsetstatus: needs-review -> accepted
messages: + msg11648
2011-05-10 18:05:47darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-de2c4b60f6d3fc76c4ad8b5789fabcbdbda32e80 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-0359034821098d15c881261e02bf3434c2de4301
2011-05-10 20:05:57darcswatchsetmessages: + msg14239