[PATCH 08 of 22] obsstore: do not load all markers to detect duplication

Jun Wu quark at fb.com
Sun Jun 4 19:59:20 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1496461782 25200
#      Fri Jun 02 20:49:42 2017 -0700
# Node ID e42031df2e3a0a3805c13ade577a083117d745aa
# Parent  8ac6041f2d9cddf3fdb743bc0ae5a02584d890ec
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r e42031df2e3a
obsstore: do not load all markers to detect duplication

This will make duplication detection something like O(newmarkers) instead of
O(obsstore).

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -633,8 +633,9 @@ class obsstore(object):
             raise error.Abort(_('creating obsolete markers is not enabled on '
                               'this repo'))
-        known = set(self._all)
+        known = set()
+        getsuccessors = self.successors.get
         new = []
         for m in markers:
-            if m not in known:
+            if m not in getsuccessors(m[0], ()) and m not in known:
                 known.add(m)
                 new.append(m)


More information about the Mercurial-devel mailing list