Patchwork D9623: extdiff: fix crash when showing diff from wdir()

login
register
mail settings
Submitter phabricator
Date Dec. 17, 2020, 7:13 a.m.
Message ID <differential-rev-PHID-DREV-5opkktyqftshrpzs5kxw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47921/
State Superseded
Headers show

Comments

phabricator - Dec. 17, 2020, 7:13 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9623

AFFECTED FILES
  hgext/extdiff.py
  tests/test-extdiff.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-extdiff.t b/tests/test-extdiff.t
--- a/tests/test-extdiff.t
+++ b/tests/test-extdiff.t
@@ -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
diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -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)