# HG changeset patch
# User Denis Laxalde <de...@laxalde.org>
# Date 1518554320 -3600
#      Tue Feb 13 21:38:40 2018 +0100
# Node ID 4b8c889eb9d0b7ca6883b93dbd476323c94f677f
# Parent  75a4598a4375d80d240c19625e2c43a069ba9618
# EXP-Topic revert-interactive-pats
revert: precompute arguments of patch.diff() in _performrevert()

By factoring out arguments ordering for patch.diff() call, we can only
keep one diff = patch.diff(...) statement thus reducing code duplication.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2969,9 +2969,10 @@ def _performrevert(repo, parents, ctx, a
             operation = 'apply'
             reversehunks = False
         if reversehunks:
-            diff = patch.diff(repo, ctx.node(), None, m, opts=diffopts)
+            node1, node2 = ctx.node(), None
         else:
-            diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts)
+            node1, node2 = None, ctx.node()
+        diff = patch.diff(repo, node1, node2, m, opts=diffopts)
         originalchunks = patch.parsepatch(diff)
 
         try:
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to