Patchwork [4,of,5,V2] extdiff: add comments and minor variable renames diffpatch()

login
register
mail settings
Submitter Pulkit Goyal
Date July 16, 2020, 9:56 a.m.
Message ID <9d175a65a4bd6a4801df.1594893409@workspace>
Download mbox | patch
Permalink /patch/46763/
State Accepted
Headers show

Comments

Pulkit Goyal - July 16, 2020, 9:56 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1594108617 -19800
#      Tue Jul 07 13:26:57 2020 +0530
# Node ID 9d175a65a4bd6a4801df2d65257fa3c3319cfa4a
# Parent  9d17a3f106a78059d3d315d577490182653a2075
# EXP-Topic diff-refactor
extdiff: add comments and minor variable renames diffpatch()

Some variable names were now confusing as we refactored the code in a separate
function. For example, `node1a` leads to ideas why `1a` and not `1`. The
variable storing path to patch file was named as `dirX` instead of `fileX`.
Renamed these variables and added couple of comments.

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

Patch

diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -350,32 +350,32 @@  def _runperfilediff(
                 proc.wait()
 
 
-def diffpatch(ui, repo, node1a, node2, tmproot, matcher, cmdline):
+def diffpatch(ui, repo, node1, node2, tmproot, matcher, cmdline):
     template = b'hg-%h.patch'
+    # write patches to temporary files
     with formatter.nullformatter(ui, b'extdiff', {}) as fm:
         cmdutil.export(
             repo,
-            [repo[node1a].rev(), repo[node2].rev()],
+            [repo[node1].rev(), repo[node2].rev()],
             fm,
             fntemplate=repo.vfs.reljoin(tmproot, template),
             match=matcher,
         )
-    label1a = cmdutil.makefilename(repo[node1a], template)
+    label1 = cmdutil.makefilename(repo[node1], template)
     label2 = cmdutil.makefilename(repo[node2], template)
-    dir1a = repo.vfs.reljoin(tmproot, label1a)
-    dir2 = repo.vfs.reljoin(tmproot, label2)
-    dir1b = None
-    label1b = None
+    file1 = repo.vfs.reljoin(tmproot, label1)
+    file2 = repo.vfs.reljoin(tmproot, label2)
     cmdline = formatcmdline(
         cmdline,
         repo.root,
-        parent1=dir1a,
-        plabel1=label1a,
-        parent2=dir1b,
-        plabel2=label1b,
-        child=dir2,
         # no 3way while comparing patches
         do3way=False,
+        parent1=file1,
+        plabel1=label1,
+        # while comparing patches, there is no second parent
+        parent2=None,
+        plabel2=None,
+        child=file2,
         clabel=label2,
     )
     ui.debug(b'running %r in %s\n' % (pycompat.bytestr(cmdline), tmproot))