[PATCH 3 of 4 V2] revert: track added files with local modifications
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Sep 30 13:05:39 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1409359148 -7200
# Sat Aug 30 02:39:08 2014 +0200
# Node ID a58e6d9115fca974a01c41ee68fe4619c072792c
# Parent 9d3552b955c8cdffcb7e4d0bf88983abc2fede16
revert: track added files with local modifications
Those files need to be backed up but are currently not. We compute the set of
them to be able to use a different backup strategy in the next changeset.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2513,10 +2513,11 @@ def revert(ui, repo, ctx, parents, *pats
removed = set(changes[2])
_deleted = set(changes[3])
unknown = set(changes[4])
unknown.update(changes[5])
clean = set(changes[6])
+ modadded = set()
# split between files known in target manifest and the others
smf = set(mf)
# determine the exact nature of the deleted changesets
@@ -2543,10 +2544,13 @@ def revert(ui, repo, ctx, parents, *pats
clean |= dsremoved - removed
dsremoved &= removed
# distinct between dirstate remove and other
removed -= dsremoved
+ modadded = added & dsmodified
+ added -= modadded
+
# tell newly modified apart.
dsmodified &= modified
dsmodified |= modified & dsadded # dirstate added may needs backup
modified -= dsmodified
@@ -2641,10 +2645,12 @@ def revert(ui, repo, ctx, parents, *pats
(dsmodified, actions['revert'], backup),
# Added since target
(added, actions['remove'], discard),
# Added in working directory
(dsadded, actions['forget'], discard),
+ # Added since target, have local modification
+ (modadded, actions['remove'], discard),
# Added since target but file is missing in working directory
(deladded, actions['drop'], discard),
# Removed since target, before working copy parent
(removed, actions['add'], discard),
# Same as `removed` but an unknown file exists at the same path
More information about the Mercurial-devel
mailing list