[PATCH 3 of 3 V2] obsolete: avoid using revset language to compute the obsolete revset

Jun Wu quark at fb.com
Sat Feb 18 03:56:10 EST 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1487408120 28800
#      Sat Feb 18 00:55:20 2017 -0800
# Node ID 286567ff59dbf6cc5645f878b8b223c94c3e4116
# Parent  432992303718ec631b81a351795071c34cfe68f6
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 286567ff59db
obsolete: avoid using revset language to compute the obsolete revset

This is part of a refactoring that moves some phase query optimization from
revset.py to phases.py. See previous patches for the motivation.

Now we have APIs in phasecache to get the non-public set efficiently, let's
use it directly instead of going through the "not public()" revset language
in "obsolete()" computation.

This patch was meaured using:

  for i in 'public()' 'not public()' 'draft()' 'not draft()'; do
      hg perfrevset "$i"; hg perfrevset "$i" --hidden;
  done

and no noticeable (> 1%) performance difference was observed.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1121,5 +1121,5 @@ def _computeobsoleteset(repo):
     obs = set()
     getnode = repo.changelog.node
-    notpublic = repo.revs("not public()")
+    notpublic = repo._phasecache.getrevset(repo, (phases.draft, phases.secret))
     for r in notpublic:
         if getnode(r) in repo.obsstore.successors:


More information about the Mercurial-devel mailing list