GNOME Bugzilla – Bug 522521
Supporting list of file pairs to compare on command line
Last modified: 2009-08-15 18:40:50 UTC
Our SCM tools spits out a list of file pairs to a diff tool on the command line such as the following: difftool file1.orig file1.new file2.orig file2.new We'd like to use meld as the main diff tool for our SCM tools but it doesn't yet support this. I'm proposing we add a command line flag that would support this. I came up with '-p' or '--pairs' as name for the flag but that is certainly open to suggestions.
Created attachment 107321 [details] [review] Patch created by svn diff against r980.
I was informed by someone that there is a better way for our tools to handle this. Please see Bug #522529 for the updated proposal and patch.
I like the idea of flags for delimiters. e.g. meld --diff2 a.old a.new --diff3 a b c --vc ~/dev/a
Created attachment 108901 [details] [review] Adds --diff and --vc parameters for meld. Stephen, I like the opt delimiter idea as well. The flags would make it easy for us to write a wrapper script for our file format. I've created a patch that should do almost what you've suggested. The only difference is that the --diff parameter is a comma-separated list. I didn't see an easy way to use flags as delimiters with optparse. Example: meld --diff a,b --diff c,d,e --vc ./my/vc/path/ --vc ./my/vc/file The patch was created against r989.
I think we should use space as delimiter because that is the normal unix way, even though this makes the option handling more difficult. I think optparse has a callback option which would do the trick. A worse but easier option is to use separate --diff2 --diff3 switches.
Brian, any opinion on the two options? Optparse can do variable length args. See http://docs.python.org/lib/optparse-callback-example-6.html
I definitely think the variable length args option is best. I'll submit a patch for this soon.
Created attachment 119711 [details] [review] Adds --diff option that handles variable argument file list. Added --diff option that will take 1 to 3 arguments as files and perform a diff on them in a new tab. The --diff parameter can be used any number of times. Example: meld --diff a b --diff a b c --diff c
Created attachment 119729 [details] [review] Update of previous patch The previous patch works for me, but adds a lot of spurious whitespace changes. This is just an update of that patch without the whitespace.
Sorry, vim was set to auto clear trailing whitespace.
Thanks Brian, that's very clean. I applied it to svn. BTW I changed the "from" imports to the regular style because there was a conflict with copy.copy vs copy.