[RFC/MERGE] Avoid syncing on incorrect lines during diff

Martin Pool mbp at canonical.com
Thu Jan 11 08:11:15 GMT 2007


On 10 Jan 2007, John Arbash Meinel <john at arbash-meinel.com> wrote:
> John Arbash Meinel wrote:
> > Martin Pool wrote:
> 
> I also found another very good example just today. I was changing the
> indentation of a section to bring it out of a try/finally, and move the
> try/finally somewhere else. I'm attaching the two forms of diff, and you
> probably can see why I like the new one better.

That certainly looks a lot better.

> I have a patch now which allows 2 parameters to PatienceSequenceMatcher.
> munge_func, which can be applied to every line (I recommend str.strip).
> And match_munged. Which changes the algorithm from my version to what
> Aaron proposed. Which is that we just run diff on the munged form, and
> then remove entries that don't actually match.

I will read it.

> I looked into what it would take to add something to the command line,
> but unfortunately it is pretty ugly. The problem is that cmd_diff calls
> diff_cmd_helper calls show_diff_trees calls _show_diff_trees, which uses
> a diff_function and passes it to InventoryEntry.diff() which then calls
> back into internal_diff, which then passes a class to unified_diff().
> 
> So the best I can come up with is that we would need a different
> 'internal_diff' function for the different permutations, and different
> classes or functions that return PatienceSequenceMatcher objects to pass
> to unified diff.

Yes, it is a bit complicated - I looked at this code before xmas when
trying to improve selective-file diff.  It could do with some
refactoring.

-- 
Martin



More information about the bazaar mailing list