Tools for three way merge of Python source files?

Milton L. Hankins mlh at swl.msd.ray.com
Tue Apr 13 13:17:50 EDT 1999


Keywords: diff3, merge, three-way, 3-way

Are there tools to help with 3-way merges of Python sources and/or
indentation conversion?

I'm using Python on a Real Project and I need to do a 3-way merge. 
Certain whitespace characters must be ignored -- specifically, carriage
returns.  I have a diff tool which ignores blanks but then I run into
problems where a block of code has been indented further (inside a new
block).

I wish I could rely on the parser to catch this sort of thing, but it
won't detect all possible follies, such as this one:

<my file & ancestor are the same>
if foo:
  if bar:
    baz()
  else:
    frob()

<other file, important change>
if foo:
  if bar:
    baz()
else:
  frob()

Here, the merge result (using blank ignorance) would not incorporate
the changes from <other file>.

One correct solution seems to be to strip CR from CRLF.  But I'm
afraid of having too many conflicting sections (false negatives) where
the spacing difference is actually benign.  Perhaps I should just tell
my fellow developers not to change indentation unless they have to.

So, it also appears that I need a Python-aware indentation converter --
something that converts a source file to use a minimal number of tabs (or
perhaps spaces, as long as it were consistent) for block indents.

If anyone has had similar experiences or knows of a solution I'd love
to hear about it.  Email is preferred.  Thanks.


(I really hope this doesn't start Yet Another Whitespace War.)

--
             Milton L. Hankins               -=-  <mlh at swl.msd.ray.com>
Software Engineer, Raytheon Systems Company  -=-  RayComNet  7-225-4728
      http://amasts.msd.ray.com/~mlh         -=-  ><>  Isaiah 64:6  ><> 





More information about the Python-list mailing list