changeset 7090:7b5c063b0b94

diff: pass contexts to status Allow status() to take contexts as well as nodes. This lets us avoid unpacking manifests multiple times and intelligently unpack manifests in revision order. Also, we can avoid unpacking manifests at all when there are no changes in the working directory.
author Matt Mackall <mpm@selenic.com>
date Sun, 12 Oct 2008 15:21:08 -0500
parents c57b30f1bc15
children 12b35ae03365
files mercurial/localrepo.py mercurial/patch.py
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Oct 12 15:21:08 2008 -0500
+++ b/mercurial/localrepo.py	Sun Oct 12 15:21:08 2008 -0500
@@ -965,13 +965,24 @@
                     del mf[fn]
             return mf
 
-        ctx1 = self[node1]
-        ctx2 = self[node2]
+        if isinstance(node1, context.changectx):
+            ctx1 = node1
+        else:
+            ctx1 = self[node1]
+        if isinstance(node2, context.changectx):
+            ctx2 = node2
+        else:
+            ctx2 = self[node2]
+
         working = ctx2 == self[None]
         parentworking = working and ctx1 == self['.']
         match = match or match_.always(self.root, self.getcwd())
         listignored, listclean, listunknown = ignored, clean, unknown
 
+        # load earliest manifest first for caching reasons
+        if not working and ctx2.rev() < ctx1.rev():
+            ctx2.manifest()
+
         if not parentworking:
             def bad(f, msg):
                 if f not in ctx1:
--- a/mercurial/patch.py	Sun Oct 12 15:21:08 2008 -0500
+++ b/mercurial/patch.py	Sun Oct 12 15:21:08 2008 -0500
@@ -1174,21 +1174,18 @@
             flcache[f] = flctx._filelog
         return flctx
 
-    # reading the data for node1 early allows it to play nicely
-    # with repo.status and the revlog cache.
     ctx1 = repo[node1]
-    # force manifest reading
-    man1 = ctx1.manifest()
-    date1 = util.datestr(ctx1.date())
+    ctx2 = repo[node2]
 
     if not changes:
-        changes = repo.status(node1, node2, match=match)
+        changes = repo.status(ctx1, ctx2, match=match)
     modified, added, removed = changes[:3]
 
     if not modified and not added and not removed:
         return
 
-    ctx2 = repo[node2]
+    date1 = util.datestr(ctx1.date())
+    man1 = ctx1.manifest()
 
     if repo.ui.quiet:
         r = None