monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] xxdiff "save as merged"


From: Martin Blais
Subject: Re: [Monotone-devel] xxdiff "save as merged"
Date: Tue, 16 May 2006 11:05:02 -0400

On 5/16/06, Nathaniel Smith <address@hidden> wrote:
> Then you will be happy to learn that the upcoming 3.2 version will
> include a lot of fresh Python code to write wrapper scripts around
> xxdiff.  This will make it *really easy* to write scripts that invoke
> it for specific developing processes.  All the old scripts have been
> refactored to use this new infrastructure, and since I now use
> Subversion a lot, new svn scripts have been written, tested and are
> included as well.   These should form good examples to write analogue
> scripts for Monotone.  Feel free to have a look, for example, at
> xx-svn-diff:

Hmm, I'm not sure what this actually means; we just have some script
compiled into monotone so it knows how to run xxdiff appropriately,
and the interface I see is that I run a merging command in monotone,
and up pops xxdiff.

I mean this (full gory details):
http://furius.ca/xxdiff/doc/xxdiff-scripts.html

There are also older documents on integration features if you're not
taking advantages of these, e.g. decision mode:
http://furius.ca/xxdiff/doc/xxdiff-integration.html
http://furius.ca/xxdiff/doc/xxdiff-secrets.html




Since we've got you here ;-), what I'd love to see in xxdiff is some
way to take some matching lines, and tell the tool to pretend that no,
really, they're unmatching lines.

The use case is something like (using --- to mark edges of files)

---
2006-05-12  Nathaniel Smith  <address@hidden>

        * monotone.texi: Re-sync the two copyright blocks.
---

versus

---
2006-05-12  Nathaniel Smith  <address@hidden>

        * ChangeLog: fix whitespace.
---

Here xxdiff of course notices that the first two lines are the same,
and give me a conflict on the last line.  Normally for conflicts like
this I use "s" to take both hunks and put them sequentially into the
output file, but here that doesn't work... the result would be:

---
2006-05-12  Nathaniel Smith  <address@hidden>

        * monotone.texi: Re-sync the two copyright blocks.
        * ChangeLog: fix whitespace.
---

But I want:

---
2006-05-12  Nathaniel Smith  <address@hidden>

        * monotone.texi: Re-sync the two copyright blocks.

2006-05-12  Nathaniel Smith  <address@hidden>

        * ChangeLog: fix whitespace.
---

And this would be easy if I could add the two leading lines to the
conflict hunk, if that makes sense.

The other similar case is even more annoying:
---
2006-05-12  Nathaniel Smith  <address@hidden>

        * monotone.texi: Re-sync the two copyright blocks.

2006-05-12  Nathaniel Smith  <address@hidden>

        * ChangeLog: fix whitespace.
---
2006-04-08  Matthew Gregan  <address@hidden>

        * monotone.cc: Oops, needed to include
        boost/filesystem/convenience.hpp too.

        * monotone.cc (cpp_main): Exclude .exe extension by using
        fs::basename rather than path.leaf().
---
Here, it will sometimes sync up on the empty line in the middle!  So
the second file ends up as two separate conflict hunks with one shared
line in the middle, and there's nothing to be done.  If I could turn
it into one larger hunk, all would be well.

I see, interesting case.  There are a few approaches to this problem:

A) Write a wrapper script, in Pytthon reusing my infrastructure (will
be easy peasy), that adds some kind of randomly generated unique
string at the end of the headers (something that does not distract too
much) in a way that hopefully plays nice with diff to get the result
you want, perform the merge, and have the script complete by
automatically removing the ids afterwards (you make your ids easily
detectable somehow).  You will have to experiment with diff to make
sure it works nicely. This is not very pretty though, because you wrap
up xxdiff for something simple, and I'm not sure if this will work for
all outputs -- diff can be capricious -- but it might.   (Somewhat
related to this idea is xx-sql-schemas, see web page.)


B) (a much cleaner solution, the best way to solve this)   Write a
specialized version of diff that does what you want, and outputs POSIX
diffs.  I suppose you would just parse your changelog file in chunks,
compare them char by char, and output diffs where they're different,
very simple to implement.   xxdiff does not compute diffs itself --
this allows people that use ClearCase to use the better cleardiff with
it -- so you can compute diffs any way you like.   Tell xxdiff to use
that diff program instead of GNU diff or whatever diff prog you're
using, I think you can do this like this, probably in an alias:

xxdiff -R 'Command.DiffFiles2: "mydiff"' changes.old changes.new

This is cleaner, because you'll get exactly what you want.  If you can
code this in Python using the xxdiff package I would be happy to
include your script in it.

(I want to add support for writing such alternative diff programs in
the Python package, I haven't had time yet.)




I guess a meta-point here is that it would be really nice to be able
to edit the files in place, for arbitrary resolutions, like e.g.
emerge allows :-).  But 95% of the cases where I need this are covered
by the case above.

That's a long-standing issue.  xxdiff will never be a full-fledged
editor, that's for sure, but I would like to support one-line editing
at some point.  There is just so much time...

Thanks.
cheers,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]