# HG changeset patch # User Kyle Lippincott # Date 1575422277 28800 # Node ID 765a9c299c442610fc23429d559b5e4cfd332077 # Parent aea70ca7dd8508ae76a557529e2b1ed74465cd83 py3: make a pycompat.osdevnull, use it in extdiff Differential Revision: https://phab.mercurial-scm.org/D7545 diff -r aea70ca7dd85 -r 765a9c299c44 hgext/extdiff.py --- 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: diff -r aea70ca7dd85 -r 765a9c299c44 mercurial/pycompat.py --- 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 diff -r aea70ca7dd85 -r 765a9c299c44 tests/test-extdiff.t --- 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]