[darcs-devel] SelectChanges

David Roundy droundy at abridgegame.org
Tue Jul 12 04:39:16 PDT 2005


On Mon, Jul 11, 2005 at 11:54:27PM +0100, Ian Lynagh wrote:
> 
> Hi all,
> 
> I'm thinking about SelectChanges again. First commands that only work
> with named patches. I think here we want a general function that takes a
> list of patches and returns, in a WriteableDirectory monad, a list of
> patches that were selected and a list of patches that weren't.
> islast and isreversed are basically what I'm trying to get rid of here.

I'm a bit afraid that there is something I'm overlooking, but I don't
presently see a problem with getting rid of at least one of them.  I think
we do need a flag that controls whether we display the patch or its
inverse, but of course this would be a simpler flag to understand than
either islast or isreversed.  Alternatively, we could have a plugable
"patch display" function.

> Apply
> 
>     We have a file with patches that can be applied in order.
>     This list is the input.
> 
> Pull
> 
>     Take {list of patches in remote repo, earliest first} and remove
>     {all patches in our repo}. What is left if the input.
> 
> Push, Send
> 
>     As Pull, but with the repos reversed.

In all of these, the selected patches are "first" patches, and the patches
are displayed in their uninverted form.

> Rollback, Unpull, Unrecord, Unrevert, Record (ask about depends),
> AmendRecord (asking which patch to change)
> 
>     map invert {list of patches in repo, latest first} is the input.

So here you're suggesting to use a reversed list of inverted patches.  The
only trouble here is that we don't want to show the patch inverses in the
display.  On the other hand, since these are named patches, we can examine
them in SelectPatches and see if they are inverted, and if so invert them
back.  If we do this, however, we'll probably confuse the interface when a
patch contains actual inverted patches (as the old rollback used to
generate)... but this isn't a big issue.

So on named patches, I think your simplified interface should work.

> Now commands that work with primitive patches. These would potentially
> have extra abilities like "break the patch into pieces", "look for
> moves", "infer token replace", but we'd probably want that just to be a
> flag to the general function.
> 
> AmendRecord, Record
> 
>     The diff is the input.

These want "forward" input, and output the "first" patches.

> Revert
> 
>     The diff the other way round is the input.

In the case of revert, we want to display the patches as "forward" patches,
(i.e. if you added a file, you should be prompted to revert a file add, not
to revert a file remove... I'm pretty sure it's more intuitive that way.)
But, in the case of revert (like unpull and friends) you want the selected
patches to be the "last" ones, which is consistent with reversing and
inverting the sequence and then asking for the first ones.  So it seems we
need a flag to tell SelectPatches to display inverted patches for this.

There is also unrevert which deals with primitive patches.  It behaves like
AmendRecord and Record, but with the stored unrevert file as input.

> Have I missed anything that makes the situation more complex?

Not that I can see.

If you do rewrite SelectPatches (which would be great), it'd be really nice
to get some sort of a patch numbering scheme in place (perhaps just using
the Tag in the Tagged patch), as well as a patch-number-based interface,
which would be pipe-friendly.  I don't know if you followed the recent
discussion with the eclipse folks, but I really like the idea of being able
to say something like 10v to view patch #10, or 10y etc.  I think it'd be
nice interactively and very nice for programs interacting with darcs via a
bidirectional pipe.  Also key would be a command to query the current
status of a patch (returning something like "Y" or "N").
-- 
David Roundy
http://www.darcs.net




More information about the darcs-devel mailing list