Commit ba9b1eb2 authored by steve9000's avatar steve9000

*** empty log message ***

parent 6660070d
PROG := ./meld
TESTNUM := 8
PROG := ./meld #--profile
TESTNUM := 1
VERSION := $(shell grep "^version" meldapp.py | cut -d \" -f 2)
RELEASE := meld-$(VERSION)
......@@ -8,15 +8,16 @@ run : check rundiff
@echo
rundiff:
$(PROG) .
#$(PROG) ../old/meld-2003-02-17 . #../old/meld-2002-12-21
#$(PROG) .
#$(PROG) scratch*
#$(PROG) ../old/meld-2003-03-01 . #../old/meld-2002-12-21
#$(PROG) test/lao test/tzu test/tao
#$(PROG) hkBaseSystem.cpp hkBaseSystem.cpp
#$(PROG) test/file$(TESTNUM)*
# $(PROG) ../old/meld-2002-11-12 .
# $(PROG) {../old/oldmeld,../svnrepository/meld}/GNUmakefile
# $(PROG) test/1 test/2
# $(PROG) /zip/meld .
$(PROG) ntest/file$(TESTNUM)*
#$(PROG) ../old/meld-2002-11-12 .
#$(PROG) {../old/oldmeld,../svnrepository/meld}/GNUmakefile
#$(PROG) test/1 test/2
#$(PROG) /zip/meld .
check:
@check_release
......
......@@ -2,6 +2,8 @@
TODO
====
* bonobo component
* ensure gconf stuff working ok when keys missing/invalid
* make textview drop destination for files from file manager (but dont lose text d&d)
......
......@@ -6,6 +6,7 @@ import tempfile
import gobject
import shutil
import time
import copy
import gtk
import os
import re
......@@ -15,6 +16,7 @@ import gnomeglade
CVS_COMMAND = ["cvs", "-z3", "-q"]
################################################################################
#
# Local Functions
......@@ -159,6 +161,22 @@ def find(start):
dirs, files = _find(start)
return dirs+files
def commonprefix(dirs):
"Given a list of pathnames, returns the longest common leading component"
if not dirs: return ''
n = copy.copy(dirs)
for i in range(len(n)):
n[i] = n[i].split(os.sep)
prefix = n[0]
for item in n:
for i in range(len(prefix)):
if prefix[:i+1] <> item[:i+1]:
prefix = prefix[:i]
if i == 0: return ''
break
return os.sep.join(prefix)
################################################################################
#
# CommitDialog
......@@ -293,7 +311,7 @@ class CvsView(gnomeglade.Component):
self.emit("create-diff", [entry.path])
def run_cvs_diff(self, path):
patch = self._command(CVS_COMMAND + ["diff", "-u", path], 0)
patch = self._command(CVS_COMMAND + ["diff", "-u"], [path], 0)
if patch:
self.show_patch(patch)
else:
......@@ -369,6 +387,7 @@ class CvsView(gnomeglade.Component):
return 0
def set_location(self, location):
#location = os.path.abspath(location)
#print "1", location
if len(location) and location[-1]!="/":
location += "/"
......@@ -419,13 +438,15 @@ class CvsView(gnomeglade.Component):
# remove empty entries and remove trailing slashes
return map(lambda x: x[-1]!="/" and x or x[:-1], filter(lambda x: x!=None, ret))
def _command(self, command, refresh=1):
def _command(self, command, files, refresh=1):
def progress():
self.emit("working-hard", 1)
self.flushevents()
msg = " ".join(command)
self.statusbar.add_status(msg, timeout=0)
prefix = commonprefix(files)
r = misc.read_pipe(command, progress )
#r = "" print "***", prefix
self.statusbar.remove_status(msg)
self.emit("working-hard", 0)
if refresh:
......@@ -436,7 +457,7 @@ class CvsView(gnomeglade.Component):
files = self._get_selected_files()
if len(files):
return self._command(command + files, refresh)
return self._command(command, files, refresh)
else:
self.statusbar.add_status("Select some files first.")
return None
......
......@@ -6,31 +6,6 @@ import difflib
def _null_or_space(s):
return len(s) == 0 or s.isspace()
def _chunkify_and_filter(seq, txts):
"""Merge diff blocks if they are separated by only whitespace.
Also remove 'equal' blocks in the process"""
if len(seq) >= 2:
ret = []
i = 0
while i < len(seq):
s = seq[i]
if s[0] == "equal":
if _null_or_space( "".join(txts[1][s[1]:s[2]])):
if i > 0:
r = ret[-1]
ret[-1] = ["replace", r[1], s[2], r[3], s[4]]
i += 1
if i < len(seq) and len(ret):
s = seq[i]
r = ret[-1]
ret[-1] = ["replace", r[1], s[2], r[3], s[4]]
else:
ret.append(s)
i += 1
else:
ret = seq
return ret
################################################################################
#
# Differ
......@@ -38,28 +13,29 @@ def _chunkify_and_filter(seq, txts):
################################################################################
class Differ:
"""Utility class to hold diff2 or diff3 chunks"""
lookup = {"replace":"replace", "insert":"delete", "delete":"insert", "conflict":"conflict"}
lookup = {"replace":"replace",
"insert":"delete",
"delete":"insert",
"conflict":"conflict",
"equal":"equal"}
def __init__(self, *text):
#print "\n\ntext0\n", text[0]
#print "\n\ntext1\n", text[1]
# diffs are stored from text1 -> text0 and text1 -> text2 for consistency
textlines = map( lambda x: x.split("\n"), text)
textlines = text #map( lambda x: x.split("\n"), text)
if len(text)==0 or len(text)==1:
self.diffs = [[], []]
elif len(text)==2:
seq0 = difflib.SequenceMatcher(None, textlines[1], textlines[0]).get_opcodes()
seq0 = filter(lambda x: x[0]!="equal", seq0)
#seq0 = _chunkify_and_filter(seq0, textlines)
#seq0 = filter(lambda x: x[0]!="equal", seq0)
self.diffs = [seq0, []]
elif len(text)==3:
seq0 = difflib.SequenceMatcher(None, textlines[1], textlines[0]).get_opcodes()
seq0 = filter(lambda x: x[0]!="equal", seq0)
#seq0 = _chunkify_and_filter(seq0, textlines[:-1])
seq1 = difflib.SequenceMatcher(None, textlines[1], textlines[2]).get_opcodes()
seq1 = filter(lambda x: x[0]!="equal", seq1)
#seq1 = _chunkify_and_filter(seq1, textlines[1:])
self.diffs = self._merge_diffs(seq0, seq1, textlines)
else:
raise "Bad number of arguments to Differ constructor (%i)" % len(text)
......
......@@ -127,8 +127,10 @@ class FileDiff(gnomeglade.Component):
w.get_hadjustment().connect("value-changed", self._sync_hscroll )
self.textview[i].get_buffer().connect("insert-text", self.on_text_insert_text)
self.textview[i].get_buffer().connect("delete-range", self.on_text_delete_range)
self.textview[i].get_buffer().connect_after("insert-text", self.on_text_insert_text_after)
#self.textview[i].get_buffer().connect_after("delete-range", self.on_text_insert_text_after)
self.linediffs = diffutil.Differ()
self.linediffs = diffutil.Differ([[""],[""]])
load = lambda x: gnomeglade.load_pixbuf(misc.appdir("glade2/pixmaps/"+x), self.pixels_per_line)
self.pixbuf_apply0 = load("button_apply0.xpm")
self.pixbuf_apply1 = load("button_apply1.xpm")
......@@ -238,7 +240,70 @@ class FileDiff(gnomeglade.Component):
self.undosequence.add_action( BufferModifiedAction(buffer, self) )
self.undosequence.add_action( BufferInsertionAction(buffer, iter.get_offset(), text) )
self.undosequence.end_group()
self._queue_refresh()
def on_text_insert_text_after(self, buffer, iter, text, textlen):
line = iter.get_line()
#print line, buffer.get_text( buffer.get_iter_at_line(line), buffer.get_iter_at_line(line+1) )
#print line, iter.get_line_offset()
def foo(a, b):
print buffer.get_text( buffer.get_iter_at_line(a), buffer.get_iter_at_line(b) )
def foo2(a, b):
buf = self.textview[1].get_buffer()
print buf.get_text( buf.get_iter_at_line(a), buf.get_iter_at_line(b) )
prev = None
c = None
print "LINE", line
changes = self.linediffs.pair_changes(0, 1)
idx = 0
newlines = text.count("\n")
for c in changes:
#if c[1] > line:
#foo( prev[2], c[1], prev[4], c[3])
#break
if c[2] > line:
#print line, c[2], prev
#foo( c[1], c[2], c[3], c[4] )
break
prev = c
idx += 1
if c==None: return
print idx
loidx, hiidx = idx, idx
if prev == None:
prev = c
else:
loidx -= 1
try:
next = changes.next()
hiidx += 1
except StopIteration:
next = c
next = next[0], next[1], next[2] + newlines, next[3], next[4]
#print prev, next
print "<<<"
foo( prev[1], next[2] )
print "==="
foo2( prev[3], next[4] )
print ">>>"
txt0 = buffer.get_text( buffer.get_iter_at_line(prev[1]), buffer.get_iter_at_line(next[2]) ).split("\n")[:-1]
buf = self.textview[1].get_buffer()
txt1 = buf.get_text( buf.get_iter_at_line(prev[3]), buf.get_iter_at_line(next[4]) ).split("\n")[:-1]
#d = diffutil.Differ([txt0, txt1])
import difflib
ops = difflib.SequenceMatcher(None, txt1, txt0).get_opcodes()
rops = []
for o in ops:
rops.append( (o[0], prev[1]+o[1], prev[1]+o[2], prev[3]+o[3], prev[3]+o[4]) )
print self.linediffs.diffs[0][loidx:hiidx+1]
print rops
self.linediffs.diffs[0][loidx:hiidx+1] = rops
print "***", idx
#print d.diffs
self.linkmap[0].queue_draw()
self._highlight_buffer(0)
self._highlight_buffer(1)
def on_text_delete_range(self, buffer, iter0, iter1):
if not self.undosequence_busy:
self.undosequence.begin_group()
......@@ -247,7 +312,6 @@ class FileDiff(gnomeglade.Component):
text = buffer.get_text(iter0, iter1, 0)
self.undosequence.add_action( BufferDeletionAction(buffer, iter0.get_offset(), text) )
self.undosequence.end_group()
self._queue_refresh()
def undo(self):
if self.undosequence.can_undo():
......@@ -256,7 +320,6 @@ class FileDiff(gnomeglade.Component):
self.undosequence.undo()
finally:
self.undosequence_busy = 0
self._queue_refresh(0)
def redo(self):
if self.undosequence.can_redo():
self.undosequence_busy = 1
......@@ -265,7 +328,6 @@ class FileDiff(gnomeglade.Component):
finally:
self.undosequence_busy = 0
self.undosequence_busy = 0
self._queue_refresh(0)
#
# text buffer loading/saving
......@@ -398,7 +460,9 @@ class FileDiff(gnomeglade.Component):
for i in range(self.num_panes):
b = self.textview[i].get_buffer()
t = b.get_text(b.get_start_iter(), b.get_end_iter(), 0)
text.append(t)
t = t.replace(" ","")
t = t.replace("\t","")
text.append(t.split("\n"))
self.linediffs = apply(diffutil.Differ,text)
for i in range(self.num_panes-1):
self.linkmap[i].queue_draw()
......@@ -515,6 +579,7 @@ class FileDiff(gnomeglade.Component):
gc = area.meldgc.get_gc
for c in self.linediffs.single_changes(textindex):
if c[0] == "equal": continue
s,e = ( scaleit(c[1]), scaleit(c[2]+(c[1]==c[2])) )
s,e = math.floor(s), math.ceil(e)
window.draw_rectangle( gc(c[0]), 1, x0, s, x1, e-s)
......@@ -660,6 +725,7 @@ class FileDiff(gnomeglade.Component):
draw_style = self.prefs.draw_style
gc = area.meldgc.get_gc
for c in self.linediffs.pair_changes(which, which+1):
if c[0]=="equal": continue
f0,f1 = map( lambda l: l * self.pixels_per_line - madj.value, c[1:3] )
t0,t1 = map( lambda l: l * self.pixels_per_line - oadj.value, c[3:5] )
if f1<0 and t1<0: # find first visible chunk
......
......@@ -14,14 +14,14 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<ul>
<li>
<a href="http://sourceforge.net/projects/meld">Project Home</a>
</li>
<a href="http://sourceforge.net/projects/meld">Project Home</a>
</li>
<li>
<a href="http://sourceforge.net/project/showfiles.php?group_id=53725">Latest Version</a>
</li>
<a href="http://sourceforge.net/project/showfiles.php?group_id=53725">Latest Version</a>
</li>
<li>
<a href="http://sourceforge.net/mail/?group_id=53725">Mail</a>
</li>
<a href="http://sourceforge.net/mail/?group_id=53725">Mail</a>
</li>
</ul>
<h2>Command line usage</h2>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment