Previewing diffs with Mercurial and tkdiff

Just a quickie today.  I am merging some work I did from a really old Mercurial repository, into a much more recent repository.  Because of the big changes that have gone in, I am hand-merging.  I needed a way to easily browse diffs from the old work, so that I can manually cut/paste as needed into the new repository.  Here is a short script I wrote which uses Zenity to show a list of files with diffs, and when I double-click on the file, it brings up the diffs in tkdiff.


#!/bin/sh
while [ 1 ] ; do
FILELIST=`hg status -n`
FILE=`zenity --list --column="File to show diffs for" $FILELIST`
if [ -z "$FILE" ] ; then
exit 0
fi
hg cat $FILE > /tmp/hg.orig.$$
tkdiff /tmp/hg.orig.$$ `hg root`/$FILE
rm -f /tmp/hg.orig.$$
done

 

 

Comments:

Thanks a lot for this. Gave me a nice introduction to how simple zenity is, along with a very useful script to have :)

Posted by Sameer on August 14, 2008 at 10:22 AM EDT #

This was extra-sweet :-)
thanks!

(took some wrestling to install Zenity, but the upside is that now I have gtk+ on my system too...)

Incidentally, I've been scratching my head to achieve the same effect whilst doing a
hg diff -r 12 -r 34

kinda diff, but haven't got very far: do you have any suggestions/ideas as to how obtain the list of files that have changed between two revisions?

Posted by Marco Massenzio on January 15, 2010 at 11:33 AM EST #

ok -- so I've figured out that with:

hg diff -g --nodates -r50 -r56|grep -E '\^\\-{3}|\^\\+{3}'|grep -v '/dev/null'

one gets an output like:

+++ b/unittests/com/ibw/schools/client/shared/model/LabTest.java
--- a/unittests/com/ibw/schools/client/shared/model/LessonsTest.java
+++ b/unittests/com/ibw/schools/client/shared/model/LessonsTest.java
--- a/unittests/com/ibw/schools/server/data/impl/LessonsFileSystemDaoTest.java
+++ b/unittests/com/ibw/schools/server/data/impl/LessonsFileSystemDaoTest.java
--- a/unittests/com/ibw/schools/server/data/impl/PropertiesFilesystemDaoTest.java
+++ b/unittests/com/ibw/schools/server/data/impl/PropertiesFilesystemDaoTest.java

Now, if only I can figure out how to remove the '+++' a/ etc. and remove duplicates (some will not duplicate, for new / removed files) then it would just be a matter of cloning two tmp/ repos, hg update each to the respective revision and then execute the diff.

Posted by Marco Massenzio on January 15, 2010 at 11:36 AM EST #

Never mind that, I've answered my own question... see my blog entry at:
http://codetrips.blogspot.com/2010/01/visual-diff-for-mercurial.html

Thanks again!

Posted by Marco Massenzio on January 16, 2010 at 03:17 AM EST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

bytor

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today