darcs

Patch 277 Resolve issue 1176: caches interfere with --remote-rep...

Title Resolve issue 1176: caches interfere with --remote-rep...
Superseder Resolve issue 1176: caches interfere wit... (and 1 more)
View: 282
Nosy List abuiles, kowey
Related Issues
Status obsoleted Assigned To abuiles
Milestone

Created on 2010-06-10.21:46:22 by abuiles, last changed 2011-05-10.22:07:29 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-15.02:21:43 text/x-darcs-patch
resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch abuiles, 2010-06-10.21:46:22 text/x-darcs-patch
resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch abuiles, 2010-06-13.20:06:13 text/x-darcs-patch
resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch abuiles, 2010-06-15.15:12:42 text/x-darcs-patch
unnamed abuiles, 2010-06-10.21:46:22
unnamed abuiles, 2010-06-13.19:33:37 text/html
unnamed abuiles, 2010-06-13.20:06:13
unnamed abuiles, 2010-06-15.02:21:43
unnamed abuiles, 2010-06-15.02:22:25 text/html
unnamed abuiles, 2010-06-15.15:12:42
unnamed abuiles, 2010-06-15.15:50:01 text/html
unnamed abuiles, 2010-06-16.06:04:12 text/html
See mailing list archives for discussion on individual patches.
Messages
msg11361 (view) Author: abuiles Date: 2010-06-10.21:46:22
1 patch for repository http://darcs.net:

Thu Jun 10 16:28:29 COT 2010  builes.adolfo@googlemail.com
  * Resolve issue 1176: caches interfere with --remote-repo flag
Attachments
msg11362 (view) Author: kowey Date: 2010-06-10.22:12:37
On Thu, Jun 10, 2010 at 21:46:22 +0000, Adolfo Builes wrote:
> -      addLocal repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [Cache DarcsCache.Repo NotWritable r | r <- repos, isFile r ] ++ cache
> +      addLocal repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [Cache DarcsCache.Repo NotWritable r | r <- repos, isFile r ] ++
> +                                                                   [Cache DarcsCache.Repo NotWritable r | RemoteRepo r <- opts]  ++ cache

So in this code, we assume that the remote repository is more easily
accessible than the other entries in the sources file.  Is that
desirable?

Code-wise: it's probably good to make Cache DarcsCache.Repo NotWritable
a helper function.

Also on IRC, we'd discussed a possible simplification to this scheme
where we add *all* of the explicitly requested repositories (not just
the local ones) and then sort everything.  (Why?) What I would suggest
is doing something like that first and then building this patch on top
of that work.

Also, not related to this patch review, I claim that there is a real
world (in other words, not contrived) scenario in which you will
actually find both a remote-repo flag *and* some explicitly
requested repositories.  Can you find it?  It may be a useful exercise
to think about what that may me (It takes some more familiarity with
Darcs as a user than you may have, so don't worry if you don't find it,
but if you do find it, I think the "ah-hah!" moment may be moderately
rewarding...)

I also think it'd be useful if you could explain to me why we add the
explicitly requested repos and the remote repo to the these caches,
but not the defaultrepo.  I have a reason that makes sense to me, but
I'd like to see what you think just to double check.

>  compareByLocality (Cache _ _  x) (Cache _ _ y)
>    | isLocal x &&  isRemote y  = LT
>    | isRemote x && isLocal y = GT
> +  | isUrl x && isSsh y = LT
> +  | isSsh x && isUrl y = GT

That seems to make sense.  You may want to haddock this
function, maybe just saying the order things are sorted in,
ie.  local < http < ssh

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11395 (view) Author: abuiles Date: 2010-06-13.19:33:37
Hi Kowey



> I also think it'd be useful if you could explain to me why we add the
> explicitly requested repos and the remote repo to the these caches,
> but not the defaultrepo.  I have a reason that makes sense to me, but
> I'd like to see what you think just to double check.
>
>
 The defaultrepo appear as the "explicitly requested" when none is given as
argument, so it will be added to the caches too, however ,It would be
already there because the defaultrepo also is saved in sources. So

> why we add the explicitly requested repos and the remote repo to the these
> caches
>

Is basically a trick which would allows to avoid going to remote repos if we
have local ones in the list, or what was happening in 1176 that It would
first try the ones in the sources before the remote, and because the
previous default which was remote was there, you were asked for it even when
it wasn't what you were expecting.
Attachments
msg11398 (view) Author: abuiles Date: 2010-06-13.20:06:13
1 patch for repository http://darcs.net:

Sun Jun 13 14:50:59 COT 2010  builes.adolfo@googlemail.com
  * Resolve issue 1176: caches interfere with --remote-repo flag
Attachments
msg11399 (view) Author: kowey Date: 2010-06-13.20:23:58
On Sun, Jun 13, 2010 at 20:06:13 +0000, Adolfo Builes wrote:
> -      addLocal repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [Cache DarcsCache.Repo NotWritable r | r <- repos, isFile r ] ++ cache
> +      addRepos repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [ toCache r | r <- repos ] ++

Hmm, now you're adding all the explicitly requested repos (which is
fine), but you're sorting them... shouldn't these be sorted in locality
order?

> +      toCache r = Cache DarcsCache.Repo NotWritable r

Maybe this should be called toReadOnlyCache if you're amending anyway

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11420 (view) Author: abuiles Date: 2010-06-15.02:21:43
1 patch for repository http://darcs.net:

Mon Jun 14 21:07:26 COT 2010  builes.adolfo@googlemail.com
  *  Resolve issue 1176: caches interfere with --remote-repo flag
Attachments
msg11421 (view) Author: abuiles Date: 2010-06-15.02:22:25
Hi Eric

On Sun, Jun 13, 2010 at 3:27 PM, Eric Kow <kowey@darcs.net> wrote:

> On Sun, Jun 13, 2010 at 20:06:13 +0000, Adolfo Builes wrote:
> > -      addLocal repo repos = modifyCache repo $ \ (Ca cache) -> Ca $
> [Cache DarcsCache.Repo NotWritable r | r <- repos, isFile r ] ++ cache
> > +      addRepos repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [
> toCache r | r <- repos ] ++
>
> Hmm, now you're adding all the explicitly requested repos (which is
> fine), but you're sorting them... shouldn't these be sorted in locality
> order?
>
>
I realized I don't need to add "[ toCache r | RemoteRepo r <- opts]" since
that would be a contradiction  to what the manual says

  On the other hand, if any other repositories are supplied as command line
> arguments, this flag will be ignored (and the default repository may be
> overwritten).


And if not command line arguments are given so the repos content would be
the one you give it with --remote-repo :).

So actually to solved this problem is just question of having the sources
sorted as discussed: local < http < ssh.

What I did is that I put the function to keep the caches sorted in the
modifyCache function, so no matter what is done in the cache, it will be
always sorted.

And about the trivia I just dig in changes and ended up in Neil Mitchell's
blog, I see now the need  for --remote-repo ;).
I think the main point here is the fact that  explicitly passed rewrite you
default-repo and you don't want that to happen when the repo you are pulling
from is just  a mean to avoid firewalls, certainly we all have had that bad
experience of ssh port blocked, than happens in my university as well :S.
Attachments
msg11426 (view) Author: kowey Date: 2010-06-15.10:37:44
On Mon, Jun 14, 2010 at 21:24:55 -0500, Adolfo Builes wrote:
> I realized I don't need to add "[ toCache r | RemoteRepo r <- opts]" since
> that would be a contradiction  to what the manual says
> 
>   On the other hand, if any other repositories are supplied as command line
> > arguments, this flag will be ignored (and the default repository may be
> > overwritten).

That sounds right, but then how are you handling the issue1176 case,
where I supply --remote-repo and no explicit arguments?

> So actually to solved this problem is just question of having the sources
> sorted as discussed: local < http < ssh.

That does not sound like the whole picture.  So right now, the problem
is that the defaultrepo is in the sources, but the remote repo is not.
How should we deal with that?

> And about the trivia I just dig in changes and ended up in Neil Mitchell's
> blog, I see now the need  for --remote-repo ;).

:-)  I should have mentioned it

> I think the main point here is the fact that  explicitly passed rewrite you
> default-repo and you don't want that to happen when the repo you are pulling
> from is just  a mean to avoid firewalls, certainly we all have had that bad
> experience of ssh port blocked, than happens in my university as well :S.

Not sure I understand.  It wasn't just a means to avoid firewalls for
what it's worth. It's also about not having to type in your password (or
maybe use a slower ssh connection) when all you want to do is darcs
pull.

Thanks,

Eric

PS. In plain-text mode in mutt, your quoting structure seems a little
    weird, because the first line of what you're quoting is not quoted
    (which makes your messages slightly harder to read).

    I suspect it's something related to the gmail web interface, but I'm
    not sure :-/


-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11429 (view) Author: abuiles Date: 2010-06-15.15:12:42
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

Tue Jun 15 10:03:06 COT 2010  builes.adolfo@googlemail.com
  * Removing duplicated entries in addReposToCache
Attachments
msg11430 (view) Author: kowey Date: 2010-06-15.15:29:43
I'll apply this first patch, but I have question about the second one

Resolve issue 1176: caches interfere with --remote-repo flag
------------------------------------------------------------
> -      addLocal repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [Cache DarcsCache.Repo NotWritable r | r <- repos, isFile r ] ++ cache
> +      addReposToCache repos (Ca cache) = Ca $ [ toReadOnlyCache r | r <- repos ] ++  cache
> +      toReadOnlyCache = Cache DarcsCache.Repo NotWritable

Adolfo explained to me on IRC that the defaultrepo/remote repo are
actually treated as explicitly requested repos (via Darcs.RunCommand)
if no other arguments are passed.

So this looks fine.

I'll just say that

> +      addReposToCache repos (Ca cache) = Ca $ [ toReadOnlyCache r | r <- repos ] ++  cache

probably is cleaner written like

         addReposToCache repos (Ca cache) = Ca $ map toReadOnlyCache repos ++ cache

but I don't mind either way

> --- | Modifies the cache of a given repository with the function f
> +-- | Modifies the cache of a given repository with the function f.
> +--   No matter which modification is done over the cache, it always
> +--   returns a sorted cache where local < http < ssh
>  modifyCache :: FORALL(p r u t) (RepoPatch p)  => Repository p C(r u t) -> (Cache -> Cache) -> Repository p C(r u t)
> hunk ./src/Darcs/Repository/InternalTypes.hs 53
> -modifyCache (Repo dir opts rf (DarcsRepository pristine cache)) f =
> -  Repo dir opts rf (DarcsRepository pristine (f cache))
> -
> +modifyCache (Repo dir opts rf (DarcsRepository pristine cache)) f = Repo dir opts rf dr
> +  where dr       = DarcsRepository pristine newCache
> +        newCache = ( \ (Ca c) -> Ca $ sortBy compareByLocality c) $ f cache

Maybe Ca should be a Functor so you could just fmap (sortBy compareByLocality)
on it?  (This could end up being one of those really bad ideas)

Removing duplicated entries in addReposToCache
----------------------------------------------
> builes.adolfo@googlemail.com**20100615150306
>  Ignore-this: 47fbcc3221eee93719681bad059dafe2
> ] hunk ./src/Darcs/Commands/Pull.lhs 181
>        applyPatches opts' repository r
>      where
>        opts' = mergeOpts opts
> -      addReposToCache repos (Ca cache) = Ca $ [ toReadOnlyCache r | r <- repos ] ++  cache
> +      addReposToCache repos (Ca cache) = Ca $ nub $ [ toReadOnlyCache r | r <- repos ] ++  cache
>        toReadOnlyCache = Cache DarcsCache.Repo NotWritable

This seems like an improvement anyway, but why don't we nub in
modifyCache since we're happy to sort there?

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11431 (view) Author: abuiles Date: 2010-06-15.15:50:01
Hi


>
>
This seems like an improvement anyway, but why don't we nub in
> modifyCache since we're happy to sort there?
>
>
Yeah that totally makes sense, I will send it like a new patch, and the
stylistic changes will be other ( although I will think through about making
Ca a functor), I also want to apply some style suggestions from Petr.

btw: Is the quoting fixed ? I did a trick maybe It will work now.

Adolfo
Attachments
msg11458 (view) Author: abuiles Date: 2010-06-16.06:04:12
Hi Eric, a quick question with this one

I'll apply this first patch, but I have question about the second on



Should I wait for you to apply that change and then send the patch for the
nub in modifyCache ? I was trying to resend that particular patch ( the one
with nub in modifyCache ) and It would make me send also the patch "Resolve
issue 1176" again.

Adolfo
Attachments
msg11459 (view) Author: kowey Date: 2010-06-16.08:54:01
On Wed, Jun 16, 2010 at 01:06:55 -0500, Adolfo Builes wrote:
> Should I wait for you to apply that change and then send the patch for the
> nub in modifyCache ? I was trying to resend that particular patch ( the one
> with nub in modifyCache ) and It would make me send also the patch "Resolve
> issue 1176" again.

No need to wait; just send it again.  Darcs is smart enough to know I've
already applied the patch if you don't amend.

Yeah, there are some wishlist items for being able to co-operate more
with the patch tracker, but that's for some distant future, I expect.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
History
Date User Action Args
2010-06-10 21:46:22abuilescreate
2010-06-10 21:47:53darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-a415dda32f5058957d5ee4b74d5f9b9fecafc93a
2010-06-10 22:12:37koweysetnosy: + kowey
messages: + msg11362
2010-06-11 10:22:44koweysetstatus: needs-review -> review-in-progress
assignedto: abuiles
2010-06-13 19:33:38abuilessetfiles: + unnamed
messages: + msg11395
2010-06-13 20:06:13abuilessetfiles: + resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch, unnamed
messages: + msg11398
2010-06-13 20:23:58koweysetmessages: + msg11399
2010-06-15 02:21:43abuilessetfiles: + -resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch, unnamed
messages: + msg11420
2010-06-15 02:22:26abuilessetfiles: + unnamed
messages: + msg11421
2010-06-15 10:37:45koweysetmessages: + msg11426
2010-06-15 15:12:42abuilessetfiles: + resolve-issue-1176_-caches-interfere-with-__remote_repo-flag.dpatch, unnamed
messages: + msg11429
2010-06-15 15:29:43koweysetmessages: + msg11430
2010-06-15 15:50:01abuilessetfiles: + unnamed
messages: + msg11431
2010-06-16 06:04:12abuilessetfiles: + unnamed
messages: + msg11458
2010-06-16 08:54:01koweysetmessages: + msg11459
2010-06-18 17:00:21koweysetstatus: review-in-progress -> obsoleted
superseder: + Resolve issue 1176: caches interfere wit... (and 1 more)
2010-06-21 18:06:22darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-a415dda32f5058957d5ee4b74d5f9b9fecafc93a -> http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-fd74306a04542f6ff2055d7ac52b7491c7e22e96
2010-06-21 18:06:25darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-fd74306a04542f6ff2055d7ac52b7491c7e22e96 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-db88127c0ea04f8cb471926050c458d219581e21
2010-06-21 18:07:00darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-db88127c0ea04f8cb471926050c458d219581e21 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-ede63aba7b366688677ef5c3d8209f622c33480a
2011-05-10 19:05:43darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-ede63aba7b366688677ef5c3d8209f622c33480a -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-db88127c0ea04f8cb471926050c458d219581e21
2011-05-10 20:35:50darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-db88127c0ea04f8cb471926050c458d219581e21 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-a415dda32f5058957d5ee4b74d5f9b9fecafc93a
2011-05-10 21:05:51darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-a415dda32f5058957d5ee4b74d5f9b9fecafc93a -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-fd74306a04542f6ff2055d7ac52b7491c7e22e96
2011-05-10 22:07:29darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-fd74306a04542f6ff2055d7ac52b7491c7e22e96 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-ede63aba7b366688677ef5c3d8209f622c33480a