Bug 1909 - extdiff dies when it encounters dangling symlinks
Summary: extdiff dies when it encounters dangling symlinks
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-15 09:19 UTC by Patrick Mézard
Modified: 2012-05-13 04:48 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Mézard 2009-11-15 09:19 UTC
From http://selenic.com/pipermail/mercurial-devel/2009-October/015988.html

Here is a standalone test script



--------
#!/bin/sh

echo "[extensions]" >> $HGRCPATH
echo "extdiff=" >> $HGRCPATH
echo "[extdiff]" >> $HGRCPATH
echo "cmd.falabala=echo" >> $HGRCPATH
echo "opts.falabala=diffing" >> $HGRCPATH

hg init repo
cd repo
hg patch -m 0 - <<EOF
diff --git a/a b/a
new file mode 120000
--- /dev/null
+++ b/a
@@ -0,0 +1,1 @@
+missing
\ No newline at end of file
EOF

hg patch -m 1 - <<EOF
diff --git a/a b/a
deleted file mode 120000
--- a/a
+++ /dev/null
@@ -1,1 +0,0 @@
-missing
\ No newline at end of file
diff --git a/b b/b
new file mode 100644
--- /dev/null
+++ b/b
@@ -0,0 +1,1 @@
+b
diff --git a/c b/c
new file mode 120000
--- /dev/null
+++ b/c
@@ -0,0 +1,1 @@
+missing
\ No newline at end of file
EOF

hg falabala -r 0 --traceback
--------


and here is timeless suggested fix:


User: timeless@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)
Comment 1 Patrick Mézard 2011-04-30 03:00 UTC
Fixed by http://hg.intevation.org/mercurial/crew/rev/3eb632d9cf42
Comment 2 Bugzilla 2012-05-12 09:04 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:04 EDT  ---

This bug was previously known as _bug_ 1909 at http://mercurial.selenic.com/bts/issue1909