# HG changeset patch # User Durham Goode # Date 2017-03-02 03:51:05 # Node ID c22253c4c1b8bdd414f227232499ae323bd2173f # Parent 23080c03a604737b7d32cb789b7526bbec125e08 revert: remove set(mf) because it's O(manifest) The revert code had a 'set(manifest)' line in it, which has a runtime equivalent to the size of the manifest. With alternative manifest implementations, like treemanifest, this can be extra expensive. Let's rewrite it to be O(changes) instead of O(manifest size). diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2976,11 +2976,11 @@ def revert(ui, repo, ctx, parents, *pats clean = set(changes.clean) modadded = set() - # split between files known in target manifest and the others - smf = set(mf) - # determine the exact nature of the deleted changesets - deladded = _deleted - smf + deladded = set(_deleted) + for path in _deleted: + if path in mf: + deladded.remove(path) deleted = _deleted - deladded # We need to account for the state of the file in the dirstate, @@ -3024,7 +3024,10 @@ def revert(ui, repo, ctx, parents, *pats # in case of merge, files that are actually added can be reported as # modified, we need to post process the result if p2 != nullid: - mergeadd = dsmodified - smf + mergeadd = set(dsmodified) + for path in dsmodified: + if path in mf: + mergeadd.remove(path) dsadded |= mergeadd dsmodified -= mergeadd