[darcs-users] darcs patch: refactor of SelectChanges (and 1 more)

Florent Becker florent.becker at ens-lyon.org
Sun Oct 12 12:21:26 UTC 2008


trentbuck at gmail.com (Trent W. Buck) writes:

> Florent Becker <florent.becker at ens-lyon.org> writes:
>
>> trentbuck at gmail.com (Trent W. Buck) writes:
>> [About --dont-prompt-for-dependencies]
>>> Is it the opposite of --ask-deps?  If so, I suggest --no-ask-deps.
>>
>> It's not at all related to ask-deps (note that --no-ask-deps already
>> exists). Let me explain what it does in more details.
>>
>> Suppose you issue the following commands in a repository:
>>
>> touch toto
>> darcs record -am 'depended patch i dont care about'
>> echo titi > toto
>> darcs record -am 'patch i want'
>> touch tutu
>> darcs record -am 'patch i do not want'
>>
>> Suppose you try to darcs pull from this repository, in order to get the
>> 'patch i want', and want to use -p 'want' to choose interactively
>> between the last two patches. This could be realistic for instance if
>> there are many other unrelated patches in the repo, and maybe also
>> 'patch i want' in fact depends on many patches you don't care about.
>>
>> You have three possibilities
>>
>> 1/ With --prompt-for-dependencies (the default behaviour, which now has
>> its own flag).  You get asked about all three patches: the last two
>> ones, because they match the -p, and the first one because the second
>> depends on it. If the two matching patches depend on many patches, this
>> can get impratical, and counter-intuitive (why is darcs coming up with a
>> patch that does not patch the -p i gave?)
>>
>> 2/ With --no-deps: you only get to pull the last patch, because the
>> second one has a dependency that does not match the -p. This does not work
>> this case :-(
>>
>> 3/ The new --dont-prompt-for-deps. You get asked about only the last two
>> patches. If you answer 'y' to 'patch i want', then 'depended patch i
>> dont care about' gets silently pulled.
>
> Hmm, as a user, I'm not happy about any of these situations.  I see two
> problems:
>
> - it's not clear why darcs is asking to pull a non-matching patch; and
> - it's not clear which matching patch relates to the non-matching patch.
>
Yes, the first problem is easy (as far as i can tell), but the second is
harder. First, i'm not sure we currently have this information
available. Second, i'm not sure what the correct semantic would be, for
example if a given patch is depended upon by several patches.

> Immediately, I'd like (1) to be tweaked to point out that the
> non-matching patches are a dependency of some kind, which addresses the
> my first issue.  Here's a mockup:
>
>     $ darcs pull -p fred
>  *  A matching patch requires this non-matching patch.
>     Wed Oct  1 23:41:24 EST 2008  David Roundy <droundy at darcs.net>
>       * only  show 'diffing dir' when debugging.
>     Shall I pull this patch? (1/93)  [ynWsfvpxdaqjk], or ? for help:
>
> However I think what would be best from a user perspective is to ask
> questions in the opposite order.  For example, suppose we have three
> incoming patches A, B and C such that C depends on both A and B:
>
>     $ touch A B
>     $ darcs rec -lam A A
>     $ darcs rec -lam B B
>     $ rm A B
>     $ darcs rec -am C
>
> Then the user does "darcs pull -p C".  Here's a mockup of the
> interactions that I'd expect:
>
>     Pull C?  n
>     Done.  (No change.)
>
>     Pull C?  y
>     That patch has dependencies that you haven't pulled!
>     Pull them, too? yes to all
>     Done. (Pull A, B and C.)
>
>     Pull C?  y
>     That patch has dependencies that you haven't pulled!
>     Pull them, too? abort
>     Done. (No change.)
>
>     Pull C?  y
>     That patch has dependencies that you haven't pulled!
>     Pull them, too? ask
>     Pull A? y
>     Pull B? y
>     Done asking about dependencies.
>     (Here it would ask about other matching patches, e.g. C1).
>     Done. (No change.)
>
> In my mockup, the new --dont-prompt-for-deps corresponds to a "yes to
> all" response to the "Pull them, too?" question.

The problem I see is that SelectChanges' code really wants to ask only
once about each patch, and to ask about them in dependency order. I'm
also not sure what we can do within the limitations of the sequential
prompt/answer paradigm.

I think the right thing to do is:

 1/ add a 'last-exit' question, as proposed elsethread, so that
--dont-prompt-for-deps does not act that silently. In a
second time, add your 'that patch has dependencies, pull them?'
question, albeit in "an all or nothing" fashion. We could simply add a
warning "this patch has unpulled dependencies", show them when the user
hits 'v' (in addition to the patch), and offer him to either pull the
patch with all dependencies (with 'y'), or not (with 'w/n'). This is
what i see how to implement in the current state of darcs.

 2/ Work on making SelectChanges code callable from outside darcs, as a
lib, or as specialised darcs commands/flags (ie either
Darcs.SelectChanges.getDependenciesForSelection, or darcs pull --dry-run
--dont-prompt-for-deps --read-selection FILE) so that we can code a more
featureful (maybe graphical) UI outside of darcs. There we could get rid
of the sequential prompt/answer paradigm, and have richer interactions.

Florent



More information about the darcs-users mailing list