changeset 23301:c10dc5568069

context.status: wipe deleted/unknown/ignored fields when reversed It makes no sense to request reverse status (i.e. changes from the working copy to its parent) and then look at the deleted, unknown or ignored fields. If you do, you would get the result from the forward status (changes from parent to the working copy). Instead of giving a nonsensical answer to a nonsensical question, it seems a little saner to return empty lists. It might be best if we could prevent the caller accessing these lists, but it's doubtful it's worth the trouble.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 12 Nov 2014 21:19:07 -0800
parents f8b5c3e77d4b
children 24f67ad49da7
files mercurial/context.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Nov 12 23:50:21 2014 -0800
+++ b/mercurial/context.py	Wed Nov 12 21:19:07 2014 -0800
@@ -304,9 +304,12 @@
         r = ctx2._buildstatus(ctx1, r, match, listignored, listclean,
                               listunknown)
 
+        r = scmutil.status(*r)
         if reversed:
-            # reverse added and removed
-            r[1], r[2] = r[2], r[1]
+            # Reverse added and removed. Clear deleted, unknown and ignored as
+            # these make no sense to reverse.
+            r = scmutil.status(r.modified, r.removed, r.added, [], [], [],
+                               r.clean)
 
         if listsubrepos:
             for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
@@ -325,8 +328,7 @@
         for l in r:
             l.sort()
 
-        # we return a tuple to signify that this list isn't changing
-        return scmutil.status(*r)
+        return r
 
 
 def makememctx(repo, parents, text, user, date, branch, files, store,