From patchwork Tue May 6 23:33:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,8] localrepo: reverse contexts in status From: Sean Farley X-Patchwork-Id: 4646 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 06 May 2014 18:33:18 -0500 # HG changeset patch # User Sean Farley # Date 1397684088 18000 # Wed Apr 16 16:34:48 2014 -0500 # Node ID c8586e9a821d8abbc88438f2e78aa564e0b5e87a # Parent 0768cda8b5799dc803dc0ee27a832cd64e05f28a localrepo: reverse contexts in status This is a slight tweak to how localrepo.status calculates what files have changed. By forcing a changectx to be first operator and anything not a changectx to be the second operator, we can later exploit this to allow refactoring the status operation as a method of a context object. Furthermore, this change will speed up 'hg diff --reverse' when used with the working directory because the code will now hit a fast path without needing to calculate an unneeded second manifest. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1518,10 +1518,17 @@ class localrepository(object): return mf ctx1 = self[node1] ctx2 = self[node2] + # check if contexts are sent in reversed + reversed = False + if (not isinstance(ctx1, context.changectx) + and isinstance(ctx2, context.changectx)): + reversed = True + ctx1, ctx2 = ctx2, ctx1 + working = ctx2.rev() is None parentworking = working and ctx1 == self['.'] match = match or matchmod.always(self.root, self.getcwd()) listignored, listclean, listunknown = ignored, clean, unknown @@ -1620,10 +1627,14 @@ class localrepository(object): ' "%s"\n' % f) continue sane.append(f) modified = sane + if reversed: + added, removed = removed, added + deleted, unknown = unknown, deleted + r = modified, added, removed, deleted, unknown, ignored, clean if listsubrepos: for subpath, sub in scmutil.itersubrepos(ctx1, ctx2): if working: