[PATCH 1 of 3] extdiff: pass full paths of `dir1a` and `dir1b` to `_runperfilediff()`

Pulkit Goyal 7895pulkit at gmail.com
Tue Sep 1 12:18:51 UTC 2020


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1598691514 -19800
#      Sat Aug 29 14:28:34 2020 +0530
# Node ID e49d6016a24ce0ead59e32db68489de6c18c779d
# Parent  c25efc468a4939682031d2a16a3c897cf59f0fb9
# EXP-Topic extdiff-refactor
extdiff: pass full paths of `dir1a` and `dir1b` to `_runperfilediff()`

Earlier we were passing basename instead of the fullpath and then joining with
the tmproot. This is wrong because the user can choose `rev1a` as wdir and in
those cases, tmproot should not be joined with the path.

I am working on refactoring extdiff logic so that we can have options like `diff
--tool` and encountered this. Although this patch in itself makes no difference,
however in future when a new caller of `_runperfilediff()` will be added, it
will be useful to directly pass on the full paths instead.

Differential Revision: https://phab.mercurial-scm.org/D8969

diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -267,7 +267,7 @@ def _runperfilediff(
     waitprocs = []
     totalfiles = len(commonfiles)
     for idx, commonfile in enumerate(sorted(commonfiles)):
-        path1a = os.path.join(tmproot, dir1a, commonfile)
+        path1a = os.path.join(dir1a, commonfile)
         label1a = commonfile + rev1a
         if not os.path.isfile(path1a):
             path1a = pycompat.osdevnull
@@ -275,7 +275,7 @@ def _runperfilediff(
         path1b = b''
         label1b = b''
         if do3way:
-            path1b = os.path.join(tmproot, dir1b, commonfile)
+            path1b = os.path.join(dir1b, commonfile)
             label1b = commonfile + rev1b
             if not os.path.isfile(path1b):
                 path1b = pycompat.osdevnull
@@ -499,8 +499,8 @@ def diffrevs(
             confirm=opts.get(b'confirm'),
             commonfiles=common,
             tmproot=tmproot,
-            dir1a=dir1a,
-            dir1b=dir1b,
+            dir1a=os.path.join(tmproot, dir1a),
+            dir1b=os.path.join(tmproot, dir1b) if do3way else None,
             dir2root=dir2root,
             dir2=dir2,
             rev1a=rev1a,


More information about the Mercurial-devel mailing list