Patchwork [5,of,5,V2] extdiff: add some comments in diffrevs()

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

Comments

Pulkit Goyal - July 16, 2020, 9:56 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1594110672 -19800
#      Tue Jul 07 14:01:12 2020 +0530
# Node ID 77f72ad15b14b1a07ae3ccd67a950fe9a805aec5
# Parent  9d175a65a4bd6a4801df2d65257fa3c3319cfa4a
# EXP-Topic diff-refactor
extdiff: add some comments in diffrevs()

It was not obvious to understand the code so I added some comments.

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

Patch

diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -398,6 +398,8 @@  def diffrevs(
 ):
 
     subrepos = opts.get(b'subrepos')
+
+    # calculate list of files changed between both revs
     st = repo.status(node1a, node2, matcher, listsubrepos=subrepos)
     mod_a, add_a, rem_a = set(st.modified), set(st.added), set(st.removed)
     if do3way:
@@ -413,11 +415,18 @@  def diffrevs(
     common = modadd | rem_a | rem_b
     if not common:
         return 0
+
     # Always make a copy of node1a (and node1b, if applicable)
+    # dir1a should contain files which are:
+    #   * modified or removed from node1a to node2
+    #   * modified or added from node1b to node2
+    #     (except file added from node1a to node2 as they were not present in
+    #     node1a)
     dir1a_files = mod_a | rem_a | ((mod_b | add_b) - add_a)
     dir1a = snapshot(ui, repo, dir1a_files, node1a, tmproot, subrepos)[0]
     rev1a = b'@%d' % repo[node1a].rev()
     if do3way:
+        # file calculation criteria same as dir1a
         dir1b_files = mod_b | rem_b | ((mod_a | add_a) - add_b)
         dir1b = snapshot(ui, repo, dir1b_files, node1b, tmproot, subrepos)[0]
         rev1b = b'@%d' % repo[node1b].rev()