changeset 43790:765a9c299c44

py3: make a pycompat.osdevnull, use it in extdiff Differential Revision: https://phab.mercurial-scm.org/D7545
author Kyle Lippincott <spectral@google.com>
date Tue, 03 Dec 2019 17:17:57 -0800
parents aea70ca7dd85
children 29adf0a087a1
files hgext/extdiff.py mercurial/pycompat.py tests/test-extdiff.t
diffstat 3 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/extdiff.py	Tue Dec 03 17:10:10 2019 -0800
+++ b/hgext/extdiff.py	Tue Dec 03 17:17:57 2019 -0800
@@ -271,7 +271,7 @@
         path1a = os.path.join(tmproot, dir1a, commonfile)
         label1a = commonfile + rev1a
         if not os.path.isfile(path1a):
-            path1a = os.devnull
+            path1a = pycompat.osdevnull
 
         path1b = b''
         label1b = b''
@@ -279,7 +279,7 @@
             path1b = os.path.join(tmproot, dir1b, commonfile)
             label1b = commonfile + rev1b
             if not os.path.isfile(path1b):
-                path1b = os.devnull
+                path1b = pycompat.osdevnull
 
         path2 = os.path.join(dir2root, dir2, commonfile)
         label2 = commonfile + rev2
@@ -468,12 +468,12 @@
                 dir1a = os.path.join(tmproot, dir1a, common_file)
                 label1a = common_file + rev1a
                 if not os.path.isfile(dir1a):
-                    dir1a = os.devnull
+                    dir1a = pycompat.osdevnull
                 if do3way:
                     dir1b = os.path.join(tmproot, dir1b, common_file)
                     label1b = common_file + rev1b
                     if not os.path.isfile(dir1b):
-                        dir1b = os.devnull
+                        dir1b = pycompat.osdevnull
                 dir2 = os.path.join(dir2root, dir2, common_file)
                 label2 = common_file + rev2
         else:
--- a/mercurial/pycompat.py	Tue Dec 03 17:10:10 2019 -0800
+++ b/mercurial/pycompat.py	Tue Dec 03 17:17:57 2019 -0800
@@ -118,6 +118,7 @@
     osaltsep = os.altsep
     if osaltsep:
         osaltsep = osaltsep.encode('ascii')
+    osdevnull = os.devnull.encode('ascii')
 
     sysplatform = sys.platform.encode('ascii')
     sysexecutable = sys.executable
@@ -456,6 +457,7 @@
     ospardir = os.pardir
     ossep = os.sep
     osaltsep = os.altsep
+    osdevnull = os.devnull
     long = long
     stdin = sys.stdin
     stdout = sys.stdout
--- a/tests/test-extdiff.t	Tue Dec 03 17:10:10 2019 -0800
+++ b/tests/test-extdiff.t	Tue Dec 03 17:17:57 2019 -0800
@@ -515,3 +515,27 @@
   $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help td \
   > | grep "^      '"
         '\xa5\xa5'
+
+  $ cd $TESTTMP
+
+Test that diffing a single file works, even if that file is new
+
+  $ hg init testsinglefile
+  $ cd testsinglefile
+  $ echo a > a
+  $ hg add a
+  $ hg falabala
+  diffing * */a (glob)
+  [1]
+  $ hg ci -qm a
+  $ hg falabala -c .
+  diffing * */a (glob)
+  [1]
+  $ echo a >> a
+  $ hg falabala
+  diffing */a */a (glob)
+  [1]
+  $ hg ci -qm 2a
+  $ hg falabala -c .
+  diffing */a */a (glob)
+  [1]