# HG changeset patch # User Matt Mackall # Date 2008-10-12 20:21:08 # Node ID 7b5c063b0b94afc77dae3e76f57341a19e974660 # Parent c57b30f1bc153ad70e96a6cc028dc271af1d9092 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. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -965,13 +965,24 @@ class localrepository(repo.repository): 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: diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1174,21 +1174,18 @@ def diff(repo, node1=None, node2=None, m 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