Patchwork [2,of,5] revert: detect files added during a merge

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 15, 2014, 4:48 p.m.
Message ID <26ae04ea3c2496cf60ec.1408121324@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5430/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 15, 2014, 4:48 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1403627300 -3600
#      Tue Jun 24 17:28:20 2014 +0100
# Node ID 26ae04ea3c2496cf60ecd76d63134df577f17dd5
# Parent  2eb66256ddb71face40ed113a98fd465aa9579da
revert: detect files added during a merge

In case of merge, file that are actually added can be reported as modified. This
is currently handled by special case code. We detect it beforehand instead. This
will lets use remove the special case code at some point in the future.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2427,10 +2427,21 @@  def revert(ui, repo, ctx, parents, *pats
             # the backup system is currently unabled to handle (2).
             #
             # So we just put them all in the same group
             dsadded = added
 
+        # in case of merge, file that are actually added can be reported as
+        # modified we need to post process the result
+        if p2 != nullid:
+            if pmf is None:
+                # only need parent manifest in the merge case,
+                # so do not read by default
+                pmf = repo[parent].manifest()
+            mergeadd = dsmodified - set(pmf)
+            dsadded |= mergeadd
+            dsmodified -= mergeadd
+
         # if f is a rename, update `names` to also revert the source
         cwd = repo.getcwd()
         for f in dsadded:
             src = repo.dirstate.copied(f)
             if src and src not in names and repo.dirstate[src] == 'r':