extdiff dies when it encounters dangling symlinks

timeless timeless at gmail.com
Thu Oct 15 20:56:52 UTC 2009


What follows is a testcase I built:

#!/bin/sh
mkdir hgextdiff-test
cd hgextdiff-test
hg init
hg patch -m 0 - <<EOF
diff --git a/0 b/0
new file mode 120000
--- /dev/null
+++ b/0
@@ -0,0 +1,1 @@
+missing
\ No newline at end of file
EOF
hg patch -m 1 - <<EOF
diff --git a/0 b/0
deleted file mode 120000
--- a/0
+++ /dev/null
@@ -1,1 +0,0 @@
-missing
\ No newline at end of file
diff --git a/1 b/1
new file mode 100644
--- /dev/null
+++ b/1
@@ -0,0 +1,1 @@
+1
diff --git a/2 b/2
new file mode 120000
--- /dev/null
+++ b/2
@@ -0,0 +1,1 @@
+missing
\ No newline at end of file
EOF
hg diff0 -r 0 --traceback

And this is a patch that seems to make the last line of the preceding
not die. I don't really know what to do with this. It's not really my
area.

Yes, this is basically an abandonware patch. Sorry.

User: timeless at mozdev.org
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -82,7 +82,8 @@ def snapshot(ui, repo, files, node, tmpr
             if 'x' in fctx.flags():
                 util.set_flags(dest, False, True)
         if node is None:
-            fns_and_mtime.append((dest, repo.wjoin(fn),
os.path.getmtime(dest)))
+            fns_and_mtime.append((dest, repo.wjoin(fn),
+                                 os.lstat(dest).st_mtime))
     return dirname, fns_and_mtime

 def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
@@ -146,7 +147,8 @@ def dodiff(ui, repo, diffcmd, diffopts,
         util.system(cmdline, cwd=tmproot)

         for copy_fn, working_fn, mtime in fns_and_mtime:
-            if os.path.getmtime(copy_fn) != mtime:
+            if (not os.path.islink(copy_fn)
+                and os.path.getmtime(copy_fn) != mtime):
                 ui.debug('file changed while diffing. '
                          'Overwriting: %s (src: %s)\n' % (working_fn, copy_fn))
                 util.copyfile(copy_fn, working_fn)



More information about the Mercurial-devel mailing list