[PATCH 1 of 2] shelve: rewrite "x in y.children()" as "y in x.parents()"

Martin von Zweigbergk martinvonz at google.com
Sun Jun 18 02:13:54 EDT 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1497766179 25200
#      Sat Jun 17 23:09:39 2017 -0700
# Node ID d8c3f47d162dafa180996d3dfd8b59f1e901735b
# Parent  8e02829bec6135f4ec96bb68b54de2c3f56dbc09
shelve: rewrite "x in y.children()" as "y in x.parents()"

children() is slow

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -681,7 +681,7 @@
             raise
 
         shelvectx = repo['tip']
-        if not shelvectx in state.pendingctx.children():
+        if state.pendingctx not in shelvectx.parents():
             # rebase was a no-op, so it produced no child commit
             shelvectx = state.pendingctx
         else:
@@ -758,7 +758,7 @@
     # refresh ctx after rebase completes
     shelvectx = repo['tip']
 
-    if not shelvectx in tmpwctx.children():
+    if tmpwctx not in shelvectx.parents():
         # rebase was a no-op, so it produced no child commit
         shelvectx = tmpwctx
     return shelvectx


More information about the Mercurial-devel mailing list