Hi all,<br><br>The patch below allows that any changes done while doing an external diff are propagated back to the working directory... I haven't been able to run the tests (too much time to make it work in windows), so, if someone applies it, it would be nice if a unit-test could be added to check it too.
<br><br>The patch was generated against <a class="http" href="http://selenic.com/repo/hg">http://selenic.com/repo/hg</a><br><br>Cheers,<br><br>Fabio<br><br># HG changeset patch<br># User Fabio Zadrozny <fabiofz at gmail dot com>
<br># Date 1188174678 10800<br># Node ID b4ea50e512e7c170a2309fb195dd5bd310b0eae0<br># Parent bbdcdc7f170ed71911496f64e52554c030fe8a34<br>Propagating changes back to working dirs when changing files in external diff tool.
<br><br>diff -r bbdcdc7f170e -r b4ea50e512e7 hgext/extdiff.py<br>--- a/hgext/extdiff.py Mon Aug 20 21:10:45 2007 -0500<br>+++ b/hgext/extdiff.py Sun Aug 26 21:31:18 2007 -0300<br>@@ -84,13 +84,18 @@ def snapshot_wdir(ui, repo, files, tmpro
<br> '''snapshot files from working directory.<br> if not using snapshot, -I/-X does not work and recursive diff<br> in tools like kdiff3 and meld displays too many files.'''<br>- dirname =
os.path.basename(repo.root)<br>+ repo_root = repo.root<br>+ <br>+ dirname = os.path.basename(repo_root)<br> if dirname == "":<br> dirname = "root"<br> base = os.path.join(tmproot, dirname)
<br> os.mkdir(base)<br> ui.note(_('making snapshot of %d files from working dir\n') %<br> (len(files)))<br>+ <br>+ fns_and_mtime = []<br>+ <br> for fn in files:<br> wfn = util.pconvert
(fn)<br> ui.note(' %s\n' % wfn)<br>@@ -98,13 +103,27 @@ def snapshot_wdir(ui, repo, files, tmpro<br> destdir = os.path.dirname(dest)<br> if not os.path.isdir(destdir):<br> os.makedirs
(destdir)<br>+ <br> fp = open(dest, 'wb')<br> for chunk in util.filechunkiter(repo.wopener(wfn)):<br> fp.write(chunk)<br>- return dirname<br>+ fp.close()<br>+
<br>+ fns_and_mtime.append((dest, os.path.join(repo_root, fn), <br>+ os.path.getmtime(dest)))<br>+ <br>+ <br>+ return dirname, fns_and_mtime<br> <br> <br> def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
<br>+ '''Do the actuall diff:<br>+ <br>+ - copy to a temp structure if diffing 2 internal revisions<br>+ - copy to a temp structure if diffing working revision with <br>+ another one and more than 1 file is changed
<br>+ - just invoke the diff for a single file in the working dir<br>+ '''<br> node1, node2 = cmdutil.revpair(repo, opts['rev'])<br> files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
<br> modified, added, removed, deleted, unknown = repo.status(<br>@@ -119,11 +138,17 @@ def dodiff(ui, repo, diffcmd, diffopts, <br> dir1 = snapshot_node(ui, repo, modified + removed, node1, tmproot)<br> changes = len(modified) + len(removed) + len(added)
<br> <br>+ fns_and_mtime = []<br>+ <br> # If node2 in not the wc or there is >1 change, copy it<br> if node2:<br> dir2 = snapshot_node(ui, repo, modified + added, node2, tmproot)
<br> elif changes > 1:<br>- dir2 = snapshot_wdir(ui, repo, modified + added, tmproot)<br>+ #we only actually need to get the files to copy back to the working <br>+ #dir in this case (because the other cases are: diffing 2 revisions
<br>+ #or single file -- in which case the file is already directly passed <br>+ #to the diff tool).<br>+ dir2, fns_and_mtime = snapshot_wdir(ui, repo, modified + added, tmproot)<br> else:
<br> # This lets the diff tool open the changed file directly<br> dir2 = ''<br>@@ -146,6 +171,13 @@ def dodiff(ui, repo, diffcmd, diffopts, <br> util.shellquote(dir1), util.shellquote
(dir2)))<br> ui.debug('running %r in %s\n' % (cmdline, tmproot))<br> util.system(cmdline, cwd=tmproot)<br>+ <br>+ for copy_fn, working_fn, mtime in fns_and_mtime:<br>+ if os.path.getmtime
(copy_fn) != mtime:<br>+ ui.debug('File changed while diffing. '<br>+ 'Overwriting: %s (src: %s)\n' % (working_fn, copy_fn))<br>+ util.copyfile(copy_fn, working_fn)
<br>+ <br> return 1<br> finally:<br> ui.note(_('cleaning up temp directory\n'))<br><br>