changeset 46133:dfe2760db2a6

extdiff: fix crash when showing diff from wdir() Differential Revision: https://phab.mercurial-scm.org/D9623
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 16 Dec 2020 22:30:07 -0800
parents 55542b213813
children 0a4d47f4337b
files hgext/extdiff.py tests/test-extdiff.t
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/extdiff.py	Wed Dec 16 22:16:05 2020 -0800
+++ b/hgext/extdiff.py	Wed Dec 16 22:30:07 2020 -0800
@@ -433,7 +433,7 @@
     #     ctx1a)
     dir1a_files = mod_a | rem_a | ((mod_b | add_b) - add_a)
     dir1a = snapshot(ui, repo, dir1a_files, ctx1a.node(), tmproot, subrepos)[0]
-    rev1a = b'@%d' % ctx1a.rev()
+    rev1a = b'' if ctx1a.rev() is None else b'@%d' % ctx1a.rev()
     if do3way:
         # file calculation criteria same as dir1a
         dir1b_files = mod_b | rem_b | ((mod_a | add_a) - add_b)
--- a/tests/test-extdiff.t	Wed Dec 16 22:16:05 2020 -0800
+++ b/tests/test-extdiff.t	Wed Dec 16 22:30:07 2020 -0800
@@ -73,6 +73,15 @@
   diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
   [1]
 
+Can show diff from working copy:
+  $ echo c >> a
+  $ hg falabala -r 'wdir()' -r 1
+  diffing "*\\extdiff.*\\a" "a.34eed99112ab\\a" (glob) (windows !)
+  diffing */extdiff.*/a a.34eed99112ab/a (glob) (no-windows !)
+  [1]
+  $ hg revert a
+  $ rm a.orig
+
 Specifying an empty revision should abort.
 
   $ hg extdiff -p diff --patch --rev 'ancestor()' --rev 1