[darcs-users] Code internals: reordering patches?

David Roundy droundy at abridgegame.org
Sun Nov 23 19:00:28 UTC 2003


On Sun, Nov 23, 2003 at 10:19:23AM -0800, Kevin Smith wrote:
> From that paragraph, I still don't understand why you would want to 
> sort a list that is already ordered. Hmmm. Let me try to reason it out...

It is ordered in order of application.  Sometimes wqe'd like the order to
make sense to a human, and that's what sortps does (or perhaps tries to do
would be more accurate).  Sorting is used in whatsnew, in record and in
revert (and maybe a few other places) so that you will get asked questions
about a given file all in sequence rather than jumping around.

> This whole concept still seems odd to me. How much of this sequencing is 
> important, and how much is just arbitrary? It seems that we would remove 
> directories before removing files below them, for example, which seems 
> wrong.

Mostly it is arbitrary, which is why I derive Ord rather than bothering to
define it myself.  Really the only important thing is that patches to a
given file show up in order.  You'd also like mv patches to come first, so
after you've renamed a file you'll be prompted according to its new name
rather than its old name (otherwise you could be easily confused,
especially if you've since added a new file with the old name).

> I guess I'm asking: If you could easily have finer grained control, such 
> as allowing two types to be "equal", or splitting directory adds and 
> removes into distinct types, would you specify a different ordering?

Well, it would be nice (for example) for directory adds to come last and
for directory removes to come first.  That the directory operation would
sort to being next to the file operations within that directory, which
would seem more intuitive to me than doing all the directory changes
first.

However, since old "merger" patches did (in principle) depend on the sort
order, I'd rather not change the ordering, as it would break backwards
compatibility.  On the other hand, I'm not sure that a merge has ever been
done in which the order of patches mattered... so perhaps no backwards
compatibility would be broken? The old patches are of type "merger 0.9",
and seem to have been eliminated around May of this year.

> If you skipped the sortps call, would darcs still work? Or would it
> actually break something?

Darcs would still work perfectly.  There was a time when I required the
sort for darcs to work, but that was a problem.  As far as I can tell,
there's no way to create a sort function that will always give the same
order for the same set of changes, regardless of their starting order.
-- 
David Roundy
http://www.abridgegame.org




More information about the darcs-users mailing list