darcs

Patch 282 Resolve issue 1176: caches interfere wit... (and 1 more)

Title Resolve issue 1176: caches interfere wit... (and 1 more)
Superseder Nosy List abuiles, kowey
Related Issues
Status accepted Assigned To
Milestone

Created on 2010-06-16.17:20:26 by abuiles, last changed 2011-05-10.21:36:48 by darcswatch. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch abuiles, 2010-06-16.17:20:26 text/x-darcs-patch
resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch abuiles, 2010-06-16.22:31:45 text/x-darcs-patch
unnamed abuiles, 2010-06-16.17:20:26
unnamed abuiles, 2010-06-16.17:49:52 text/html
unnamed abuiles, 2010-06-16.22:31:45
See mailing list archives for discussion on individual patches.
Messages
msg11462 (view) Author: abuiles Date: 2010-06-16.17:20:26
2 patches for repository http://darcs.net:

Tue Jun 15 09:44:02 COT 2010  builes.adolfo@googlemail.com
  * Resolve issue 1176: caches interfere with --remote-repo flag

Wed Jun 16 11:23:30 COT 2010  builes.adolfo@googlemail.com
  * Removes duplicated entries after any modification is done to the cache
Attachments
msg11463 (view) Author: abuiles Date: 2010-06-16.17:49:52
Sorry I forgot --subject here :(.

On Wed, Jun 16, 2010 at 12:20 PM, Adolfo Builes <bugs@darcs.net> wrote:

>
> New submission from Adolfo Builes <builes.adolfo@googlemail.com>:
>
> 2 patches for repository http://darcs.net:
>
> Tue Jun 15 09:44:02 COT 2010  builes.adolfo@googlemail.com
>  * Resolve issue 1176: caches interfere with --remote-repo flag
>
> Wed Jun 16 11:23:30 COT 2010  builes.adolfo@googlemail.com
>  * Removes duplicated entries after any modification is done to the cache
>
> ----------
> files: resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch,
> unnamed
> messages: 11462
> nosy: abuiles
> status: needs-review
> title: Resolve issue 1176: caches interfere wit... (and 1 more)
>
> __________________________________
> Darcs bug tracker <bugs@darcs.net>
> <http://bugs.darcs.net/patch282>
> __________________________________
Attachments
msg11464 (view) Author: kowey Date: 2010-06-16.20:50:40
On Wed, Jun 16, 2010 at 17:20:26 +0000, Adolfo Builes wrote:
> Tue Jun 15 09:44:02 COT 2010  builes.adolfo@googlemail.com
>   * Resolve issue 1176: caches interfere with --remote-repo flag

I already reviewed this, so I'll skip it.

> Wed Jun 16 11:23:30 COT 2010  builes.adolfo@googlemail.com
>   * Removes duplicated entries after any modification is done to the cache

Almost there.  Just one more change (to the haddock)

Removes duplicated entries after any modification is done to the cache
----------------------------------------------------------------------
> +-- | @modifyCache repository@ function@ modifies the cache of
> +--   @repository@ with @function@.  After the modification is done the
> +--   duplicated entries are removed and then the cache is sorted with
> +--   local < http < ssh

There are three problems with the haddock that I can see:

 - You have a syntax error in the top line (note that I never ask people
   to amend haddock syntax errors, A. because I'm so grateful they even
   bother to write them and B. because it's more efficient for me to
   just fix it, point it out and be done with it)

 - You are repeating the documentation for
   'Darcs.Repository.Cache.compareByLocality' when you
   could just as easily link to it.  Duplication is the root of all
   evil.  Imagine we one day decide to change 'compareByLocality' and we
   (inevitably) forget to update this haddock.  It's the kind of thing
   that's subtle, we'll never notice it for years until somebody does
   something wrong...

 - Your comment reveals too much about the implementation of the
   function.  Your job is not to tell me what the code says, but
   I as a user of the function can expect from it.
   
   In particular, X happens, then Y and Z is not entirely appropriate.
   The subtlety here is that (f . sort) is not the same as (sort . f).
   Maybe we should think about this on IRC

Can you fix these?  I think once you address the two key issues above,
I can just apply what you have and maybe do some minor cleaning up


> -  where dr       = DarcsRepository pristine newCache
> -        newCache = ( \ (Ca c) -> Ca $ sortBy compareByLocality c) $ f cache
> +  where dr                = DarcsRepository pristine $ nubAndSort $ f cache
> +        nubAndSort (Ca c) = Ca $ sortBy compareByLocality $ nub c

This seems fine.  I think the way I would written it was something like
the below (again with the Functor idea), but it could just be my taste,
which is flawed :-)
 
  dr = DarcsRepository pristine
     $ cmap (nub . sortBy compareByLocality .  f) cache
  cmap f (Ca c) = Ca (f c)

But you should probably ignore my comment above

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11465 (view) Author: abuiles Date: 2010-06-16.22:31:45
2 patches for repository http://darcs.net:

Tue Jun 15 09:44:02 COT 2010  builes.adolfo@googlemail.com
  * Resolve issue 1176: caches interfere with --remote-repo flag

Wed Jun 16 17:20:18 COT 2010  builes.adolfo@googlemail.com
  *  Remove duplicated entries after any modification is done to the cache
Attachments
msg11468 (view) Author: kowey Date: 2010-06-17.08:50:28
On Wed, Jun 16, 2010 at 22:31:45 +0000, Adolfo Builes wrote:
> Tue Jun 15 09:44:02 COT 2010  builes.adolfo@googlemail.com
>   * Resolve issue 1176: caches interfere with --remote-repo flag
> 
> Wed Jun 16 17:20:18 COT 2010  builes.adolfo@googlemail.com
>   *  Remove duplicated entries after any modification is done to the cache

Applied, thanks!  That's 3 bugs fixed!

 Remove duplicated entries after any modification is done to the cache
----------------------------------------------------------------------
> +-- | @'modifyCache' repository function@ modifies the cache of
> +--   @repository@ with @function@, remove duplicates and sort the results with 'compareByLocality'.

Note that I think the pattern is
  'foo' @arg1 arg2@
The tick marks makes foo a link (although I don't really understand why
we do this for the function itself) and the at sign acts as verbatim.
I've made a minor patch on top of yours to fix this.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11476 (view) Author: kowey Date: 2010-06-18.16:55:19
Hmm, that's funny.  This one was not tracked by darcswatch.
msg11509 (view) Author: darcswatch Date: 2010-06-21.18:05:55
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-5e1308ec71e72cc59ad1f4e4234c323bc4e7eb77
msg14364 (view) Author: darcswatch Date: 2011-05-10.21:36:48
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-5e1308ec71e72cc59ad1f4e4234c323bc4e7eb77
History
Date User Action Args
2010-06-16 17:20:26abuilescreate
2010-06-16 17:49:52abuilessetfiles: + unnamed
messages: + msg11463
2010-06-16 20:50:41koweysetnosy: + kowey
messages: + msg11464
2010-06-16 22:31:45abuilessetfiles: + resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch, unnamed
messages: + msg11465
2010-06-17 08:50:28koweysetmessages: + msg11468
2010-06-18 16:55:19koweysetstatus: needs-review -> accepted
messages: + msg11476
2010-06-18 17:00:21koweylinkpatch277 superseder
2010-06-21 18:05:55darcswatchsetmessages: + msg11509
2010-06-21 18:06:16darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-bc392877e2184740f3640e341617362d1c21b7ab
2011-05-10 20:05:39darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-bc392877e2184740f3640e341617362d1c21b7ab -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-bc392877e2184740f3640e341617362d1c21b7ab
2011-05-10 21:36:48darcswatchsetmessages: + msg14364