[PATCH 2 of 4] revert: prefix variable names for dirstate status with "ds"

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Aug 13 15:13:52 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1403620543 -3600
#      Tue Jun 24 15:35:43 2014 +0100
# Node ID f92a82e1addd276b8a05488410c506e41c88bc4e
# Parent  da0fc935abb80656cfb7e315589c05bd57a3e9d2
revert: prefix variable names for dirstate status with "ds"

As we are going to introduce status again other revision we needs to distinguish
between data from dirstate status and the other one. We prefix the existing data
with "ds" to highlight this.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2367,18 +2367,18 @@ def revert(ui, repo, ctx, parents, *pats
         targetsubs = sorted(s for s in ctx.substate if m(s))
 
         # Find status of all file in `names`. (Against working directory parent)
         m = scmutil.matchfiles(repo, names)
         changes = repo.status(node1=parent, match=m)[:4]
-        modified, added, removed, deleted = map(set, changes)
+        dsmodified, dsadded, dsremoved, dsdeleted = map(set, changes)
 
         # if f is a rename, update `names` to also revert the source
         cwd = repo.getcwd()
-        for f in added:
+        for f in dsadded:
             src = repo.dirstate.copied(f)
             if src and src not in names and repo.dirstate[src] == 'r':
-                removed.add(src)
+                dsremoved.add(src)
                 names[src] = (repo.pathto(src, cwd), True)
 
         ## computation of the action to performs on `names` content.
 
         def removeforget(abs):
@@ -2387,18 +2387,18 @@ def revert(ui, repo, ctx, parents, *pats
             return _('removing %s\n')
 
         # split between files known in target manifest and the others
         smf = set(mf)
 
-        missingmodified = modified - smf
-        modified -= missingmodified
-        missingadded = added - smf
-        added -= missingadded
-        missingremoved = removed - smf
-        removed -= missingremoved
-        missingdeleted = deleted - smf
-        deleted -= missingdeleted
+        missingmodified = dsmodified - smf
+        dsmodified -= missingmodified
+        missingadded = dsadded - smf
+        dsadded -= missingadded
+        missingremoved = dsremoved - smf
+        dsremoved -= missingremoved
+        missingdeleted = dsdeleted - smf
+        dsdeleted -= missingdeleted
 
         # action to be actually performed by revert
         # (<list of file>, message>) tuple
         actions = {'revert': ([], _('reverting %s\n')),
                    'add': ([], _('adding %s\n')),
@@ -2408,17 +2408,17 @@ def revert(ui, repo, ctx, parents, *pats
         disptable = (
             # dispatch table:
             #   file state
             #   action
             #   make backup
-            (modified,         (actions['revert'],   True)),
+            (dsmodified,       (actions['revert'],   True)),
             (missingmodified,  (actions['remove'],   True)),
-            (added,            (actions['revert'],   True)),
+            (dsadded,          (actions['revert'],   True)),
             (missingadded,     (actions['remove'],   False)),
-            (removed,          (actions['undelete'], True)),
+            (dsremoved,        (actions['undelete'], True)),
             (missingremoved,   (None,                False)),
-            (deleted,          (actions['revert'],   False)),
+            (dsdeleted,        (actions['revert'],   False)),
             (missingdeleted,   (actions['remove'],   False)),
             )
 
         for abs, (rel, exact) in sorted(names.items()):
             # hash on file in target manifest (or None if missing from target)


More information about the Mercurial-devel mailing list