An example of a visual diff program for Mercurial
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Wed Nov 1 15:45:47 CST 2006
On Wed, Nov 01, 2006 at 09:38:49AM -0800, Talin wrote:
> I hacked together a little "visual diff" program for Mercurial. You can
> see a screenshot here:
>
> http://viridia.org/hg/python/hermetic?f=45dbddc4f0aa;file=ViewDiffScreen.png;style=raw
it's very nice!
I can't really help because I'm not good at gui programming, but it would be
better if a scrolling in a window was completely synchronous with the other
(currently one "lags" behind the other)
I had to use the following patch to make it work on python2.4 with
current tip. (using contexts would be nicer and cleaner, our patch.py
needs that cleanup too)
thanks!
Benoit
diff -r 0d9230899167 viewdiff.py
--- a/viewdiff.py Wed Nov 01 09:23:14 2006 -0800
+++ b/viewdiff.py Wed Nov 01 22:38:37 2006 +0100
@@ -1,4 +1,3 @@ from __future__ import with_statement
-from __future__ import with_statement
import wx
import wx.lib.newevent
import os
@@ -135,14 +134,14 @@ class ChangeView( wx.Panel ):
r0 = self.diffs[ diffindex ][ 2 ]
r1 = self.diffs[ diffindex ][ 3 ]
else:
- r0 = self.diffs[ diffindex-1 ][ 3 ] if diffindex > 0 else 0
+ r0 = diffindex > 0 and self.diffs[ diffindex-1 ][ 3 ] or 0
r1 = self.diffs[ diffindex ][ 2 ]
else:
if after:
r0 = self.diffs[ diffindex ][ 0 ]
r1 = self.diffs[ diffindex ][ 1 ]
else:
- r0 = self.diffs[ diffindex-1 ][ 1 ] if diffindex > 0 else 0
+ r0 = diffindex > 0 and self.diffs[ diffindex-1 ][ 1 ] or 0
r1 = self.diffs[ diffindex ][ 0 ]
return r0 * self.line_height + \
@@ -367,7 +366,7 @@ class DiffPanel:
sizer = wx.FlexGridSizer( 3, 2, 0, 0 )
sizer.AddGrowableRow( 0 )
- sizer.AddGrowableCol( 1 if sb_side == self.Left else 0 )
+ sizer.AddGrowableCol( sb_side == self.Left and 1 or 0 )
self.box = wx.BoxSizer( wx.HORIZONTAL )
@@ -618,7 +617,7 @@ for manifest_entry in manifest:
print "Manifest Entry:",
pprint( manifest_entry )
-changes = repo.changes( node1, None )
+changes = repo.status( node1, None )[:5]
modified, added, removed, deleted, unknown = changes
manifest_entry = modified[ 0 ]
--
:wq
More information about the Mercurial
mailing list