##// END OF EJS Templates
extdiff: copy back files to the working directory if the size changed...
Matt Harbison -
r32212:affd753d default
parent child Browse files
Show More
@@ -101,7 +101,7 b' def snapshot(ui, repo, files, node, tmpr'
101 dirname = '%s.%s' % (dirname, short(node))
101 dirname = '%s.%s' % (dirname, short(node))
102 base = os.path.join(tmproot, dirname)
102 base = os.path.join(tmproot, dirname)
103 os.mkdir(base)
103 os.mkdir(base)
104 fns_and_mtime = []
104 fnsandstat = []
105
105
106 if node is not None:
106 if node is not None:
107 ui.note(_('making snapshot of %d files from rev %s\n') %
107 ui.note(_('making snapshot of %d files from rev %s\n') %
@@ -124,9 +124,8 b' def snapshot(ui, repo, files, node, tmpr'
124 if node is None:
124 if node is None:
125 dest = os.path.join(base, wfn)
125 dest = os.path.join(base, wfn)
126
126
127 fns_and_mtime.append((dest, repo.wjoin(fn),
127 fnsandstat.append((dest, repo.wjoin(fn), os.lstat(dest)))
128 os.lstat(dest).st_mtime))
128 return dirname, fnsandstat
129 return dirname, fns_and_mtime
130
129
131 def dodiff(ui, repo, cmdline, pats, opts):
130 def dodiff(ui, repo, cmdline, pats, opts):
132 '''Do the actual diff:
131 '''Do the actual diff:
@@ -199,7 +198,7 b' def dodiff(ui, repo, cmdline, pats, opts'
199 dir1b = None
198 dir1b = None
200 rev1b = ''
199 rev1b = ''
201
200
202 fns_and_mtime = []
201 fnsandstat = []
203
202
204 # If node2 in not the wc or there is >1 change, copy it
203 # If node2 in not the wc or there is >1 change, copy it
205 dir2root = ''
204 dir2root = ''
@@ -212,8 +211,8 b' def dodiff(ui, repo, cmdline, pats, opts'
212 #the working dir in this case (because the other cases
211 #the working dir in this case (because the other cases
213 #are: diffing 2 revisions or single file -- in which case
212 #are: diffing 2 revisions or single file -- in which case
214 #the file is already directly passed to the diff tool).
213 #the file is already directly passed to the diff tool).
215 dir2, fns_and_mtime = snapshot(ui, repo, modadd, None, tmproot,
214 dir2, fnsandstat = snapshot(ui, repo, modadd, None, tmproot,
216 subrepos)
215 subrepos)
217 else:
216 else:
218 # This lets the diff tool open the changed file directly
217 # This lets the diff tool open the changed file directly
219 dir2 = ''
218 dir2 = ''
@@ -249,7 +248,7 b' def dodiff(ui, repo, cmdline, pats, opts'
249 dir2 = repo.vfs.reljoin(tmproot, label2)
248 dir2 = repo.vfs.reljoin(tmproot, label2)
250 dir1b = None
249 dir1b = None
251 label1b = None
250 label1b = None
252 fns_and_mtime = []
251 fnsandstat = []
253
252
254 # Function to quote file/dir names in the argument string.
253 # Function to quote file/dir names in the argument string.
255 # When not operating in 3-way mode, an empty string is
254 # When not operating in 3-way mode, an empty string is
@@ -275,8 +274,13 b' def dodiff(ui, repo, cmdline, pats, opts'
275 ui.debug('running %r in %s\n' % (cmdline, tmproot))
274 ui.debug('running %r in %s\n' % (cmdline, tmproot))
276 ui.system(cmdline, cwd=tmproot, blockedtag='extdiff')
275 ui.system(cmdline, cwd=tmproot, blockedtag='extdiff')
277
276
278 for copy_fn, working_fn, mtime in fns_and_mtime:
277 for copy_fn, working_fn, st in fnsandstat:
279 if os.lstat(copy_fn).st_mtime != mtime:
278 cpstat = os.lstat(copy_fn)
279 # Some tools copy the file and attributes, so mtime may not detect
280 # all changes. A size check will detect more cases, but not all.
281 # The only certain way to detect every case is to diff all files,
282 # which could be expensive.
283 if cpstat.st_mtime != st.st_mtime or cpstat.st_size != st.st_size:
280 ui.debug('file changed while diffing. '
284 ui.debug('file changed while diffing. '
281 'Overwriting: %s (src: %s)\n' % (working_fn, copy_fn))
285 'Overwriting: %s (src: %s)\n' % (working_fn, copy_fn))
282 util.copyfile(copy_fn, working_fn)
286 util.copyfile(copy_fn, working_fn)
@@ -324,8 +324,11 b' Test with revsets:'
324
324
325 Fallback to merge-tools.tool.executable|regkey
325 Fallback to merge-tools.tool.executable|regkey
326 $ mkdir dir
326 $ mkdir dir
327 $ cat > 'dir/tool.sh' << EOF
327 $ cat > 'dir/tool.sh' << 'EOF'
328 > #!/bin/sh
328 > #!/bin/sh
329 > # Mimic a tool that syncs all attrs, including mtime
330 > cp $1/a $2/a
331 > touch -r $1/a $2/a
329 > echo "** custom diff **"
332 > echo "** custom diff **"
330 > EOF
333 > EOF
331 #if execbit
334 #if execbit
@@ -344,6 +347,9 b' of $tool (and fail).'
344 $ tool=`pwd`/dir/tool.sh
347 $ tool=`pwd`/dir/tool.sh
345 #endif
348 #endif
346
349
350 $ cat a
351 changed
352 edited
347 $ hg --debug tl --config extdiff.tl= --config merge-tools.tl.executable=$tool
353 $ hg --debug tl --config extdiff.tl= --config merge-tools.tl.executable=$tool
348 making snapshot of 2 files from rev * (glob)
354 making snapshot of 2 files from rev * (glob)
349 a
355 a
@@ -354,8 +360,11 b' of $tool (and fail).'
354 running '$TESTTMP/a/dir/tool.bat a.* a' in */extdiff.* (glob) (windows !)
360 running '$TESTTMP/a/dir/tool.bat a.* a' in */extdiff.* (glob) (windows !)
355 running '$TESTTMP/a/dir/tool.sh a.* a' in */extdiff.* (glob) (no-windows !)
361 running '$TESTTMP/a/dir/tool.sh a.* a' in */extdiff.* (glob) (no-windows !)
356 ** custom diff **
362 ** custom diff **
363 file changed while diffing. Overwriting: $TESTTMP/a/a (src: */extdiff.*/a/a) (glob)
357 cleaning up temp directory
364 cleaning up temp directory
358 [1]
365 [1]
366 $ cat a
367 a
359
368
360 $ cd ..
369 $ cd ..
361
370
General Comments 0
You need to be logged in to leave comments. Login now