Patchwork D7545: py3: make a pycompat.osdevnull, use it in extdiff

login
register
mail settings
Submitter phabricator
Date Dec. 4, 2019, 7:09 p.m.
Message ID <44e2d1def42a3121db4a25bf36ecf285@localhost.localdomain>
Download mbox | patch
Permalink /patch/43582/
State Not Applicable
Headers show

Comments

phabricator - Dec. 4, 2019, 7:09 p.m.
Closed by commit rHG765a9c299c44: py3: make a pycompat.osdevnull, use it in extdiff (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7545?vs=18465&id=18470

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7545/new/

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

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

CHANGE DETAILS




To: spectral, #hg-reviewers, mharbison72
Cc: mharbison72, 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
@@ -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]
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -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
diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -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: