[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Tip of the day: Using wiggle to reduce merge conflicts

From: Øyvind A. Holm <sunny_at_sunbase.org>
Date: 2005-04-04 08:40:52 CEST

The "svn merge" command usually works fine, but when the
source/destination files contain big differences, conflicts easily
occur. The reason for this is sometimes because svn is comparing the
differences on a line-wise basis. The wiggle(1) program, however, is
able to merge changes on a word-wise basis, and therefore is able to
merge a lot more changes without creating conflicts.

As an example, I have this Perl project which contains some files, the
biggest of them is about 130 kilobytes. I was going to continue on a
feature I started on in May 2001, but never got finished. A lot of
changes happen in four years, so there were lots of conflicts, for
example on lines where the only difference was the indent level:

newbranch$ svn merge -r739:740 /path/to/repo/branches/oldbranch .

But, by using wiggle, another method is used: Create a diff, use
patch(1) to apply the merge, and clean up most of the mess with wiggle:

newbranch$ svn diff -r739:740 /path/to/repo/branches/oldbranch | patch -p0

If patch(1) is unable to patch the files properly, it creates a "reject
file" with the extension .rej . This file contains the troublesome parts
of the code and can be used by wiggle to patch changes on a word-wise
basis:

newbranch$ wiggle --replace index.cgi index.cgi.rej
14 unresolved conflicts found

Most of the conflicts were in old CVS keywords ($Id$ and such), but I'm
amazed how wiggle managed to apply the changes correctly, even to code
that was moved elsewhere in the file. This method also works very well
on files containing text which has been wordwrapped.

The wiggle program is just a "apt-get install wiggle" away if you're
using Debian testing or unstable, otherwise you can get it from

  http://cgi.cse.unsw.edu.au/~neilb/source/wiggle/

Happy patching from sunny256

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Apr 4 08:43:24 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.