changeset 692:42879fddf727

push: simplify code for remapping rebased node ids
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Fri, 10 Sep 2010 07:50:40 +0200
parents a45365f1492a
children 03dca55abec9
files hgsubversion/wrappers.py
diffstat 1 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -201,17 +201,12 @@ def push(repo, dest, force, revs):
             repo = hg.repository(ui, meta.path)
             newtipctx = repo[newtip]
             # Rewrite the node ids in outgoing to their rebased versions.
-            for child in newtipctx.children():
-                rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
-                if rebasesrc in outgoing:
-                    while rebasesrc in outgoing:
-                        rebsrcindex = outgoing.index(rebasesrc)
-                        outgoing = (outgoing[0:rebsrcindex] +
-                                    [child.node(), ] + outgoing[rebsrcindex+1:])
-                        children = [c for c in child.children() if c.branch() == child.branch()]
-                        if children:
-                            child = children[0]
-                        rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
+            rebasemap = dict()
+            for child in newtipctx.descendants():
+                rebasesrc = child.extra().get('rebase_source')
+                if rebasesrc:
+                    rebasemap[node.bin(rebasesrc)] = child.node()
+            outgoing = [rebasemap.get(n) or n for n in outgoing]
         # TODO: stop constantly creating the SVNMeta instances.
         meta = repo.svnmeta(svn.uuid)
         hashes = meta.revmap.hashes()