This is an archive of the discontinued Mercurial Phabricator instance.

bdiff: add a xdiffblocks method
ClosedPublic

Authored by quark on Mar 3 2018, 3:07 PM.

Details

Summary

This is similar to bdiff.blocks, but uses xdiff as the backend.

The indent heuristic is turned on by default since it has little overhead
and improves diff quality significantly.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

quark created this revision.Mar 3 2018, 3:07 PM
quark updated this revision to Diff 6476.Mar 3 2018, 3:30 PM
indygreg accepted this revision.Mar 3 2018, 4:19 PM
indygreg added a subscriber: indygreg.
indygreg added inline comments.
mercurial/cext/bdiff.c
266

Calling PyList_Append() in tight loops can be a bit slow. It is faster to allocate an array of PyObject and then allocate a PyList of final size and call PyList_SET_ITEM to populate it. But we can optimize this later: this is definitely the easiest first implementation.

290

Does our C standard level allow to declare variables after non-declarations in blocks?

310

This exception type is nonsensical. But it is what blocks() uses. So not worth worrying about.

This revision is now accepted and ready to land.Mar 3 2018, 4:19 PM
quark added inline comments.Mar 3 2018, 4:25 PM
mercurial/cext/bdiff.c
290

Not sure. But the rest is C89. So I'll move this up.

310

It actually makes some sense - if the xdiff library is solid, then hunk_consumer returning -1 is the only reason things go wrong. And that's caused by NoMemory.

quark added inline comments.Mar 3 2018, 4:26 PM
mercurial/cext/bdiff.c
266

Ideally, xdiff could return how many lines the input string has. So we can preallocate. But it's not in the current xdiff API.

quark updated this revision to Diff 6480.Mar 3 2018, 4:31 PM
durin42 accepted this revision.Mar 3 2018, 6:12 PM
This revision was automatically updated to reflect the committed changes.