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

login
register
mail settings
Submitter via Mercurial-devel
Date June 18, 2017, 6:13 a.m.
Message ID <d8c3f47d162dafa18099.1497766434@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21472/
State Accepted
Headers show

Comments

via Mercurial-devel - June 18, 2017, 6:13 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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
Yuya Nishihara - June 18, 2017, 6:35 a.m.
On Sat, 17 Jun 2017 23:13:54 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@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()"

Queued these, thanks.

Patch

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