comparison push_cmd.py @ 152:1fde85a10f9e

push: Fix the bad implementation that required modifying the dirstate to push.
author Augie Fackler <durin42@gmail.com>
date Mon, 22 Dec 2008 21:22:11 -0600
parents 2decec74ad0c
children fdc249cd1a0a
comparison
equal deleted inserted replaced
151:2decec74ad0c 152:1fde85a10f9e
22 ui_=ui) 22 ui_=ui)
23 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), 23 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
24 hge.revmap.iterkeys())) 24 hge.revmap.iterkeys()))
25 # Strategy: 25 # Strategy:
26 # 1. Find all outgoing commits from this head 26 # 1. Find all outgoing commits from this head
27 outgoing = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) 27 if len(repo.parents()) != 1:
28 ui.status('Cowardly refusing to push branch merge')
29 return 1
30 workingrev = repo.parents()[0]
31 outgoing = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, workingrev.node())
28 if not (outgoing and len(outgoing)): 32 if not (outgoing and len(outgoing)):
29 ui.status('No revisions to push.') 33 ui.status('No revisions to push.')
30 return 0 34 return 0
31 if len(repo.parents()) != 1:
32 ui.status('Cowardly refusing to push branch merge')
33 return 1
34 while outgoing: 35 while outgoing:
35 oldest = outgoing.pop(-1) 36 oldest = outgoing.pop(-1)
36 old_ctx = repo[oldest] 37 old_ctx = repo[oldest]
37 if len(old_ctx.parents()) != 1: 38 if len(old_ctx.parents()) != 1:
38 ui.status('Found a branch merge, this needs discussion and ' 39 ui.status('Found a branch merge, this needs discussion and '
67 for needs_transplant in heads: 68 for needs_transplant in heads:
68 def extrafn(ctx, extra): 69 def extrafn(ctx, extra):
69 if ctx.node() == oldest: 70 if ctx.node() == oldest:
70 return 71 return
71 extra['branch'] = ctx.branch() 72 extra['branch'] = ctx.branch()
72 hg.clean(repo, needs_transplant) 73 utility_commands.rebase_commits(ui, repo, hg_repo_path,
73 utility_commands.rebase_commits(ui, repo, hg_repo_path, extrafn=extrafn, **opts) 74 extrafn=extrafn,
75 sourcerev=needs_transplant,
76 **opts)
74 repo = hg.repository(ui, hge.path) 77 repo = hg.repository(ui, hge.path)
75 for child in repo[replacement.node()].children(): 78 for child in repo[replacement.node()].children():
76 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid))) 79 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
77 if rebasesrc in outgoing: 80 if rebasesrc in outgoing:
78 rebsrcindex = outgoing.index(rebasesrc) 81 while rebasesrc in outgoing:
79 outgoing = outgoing[0:rebsrcindex] + [child.node(), ] + outgoing[rebsrcindex+1:] 82 rebsrcindex = outgoing.index(rebasesrc)
83 outgoing = (outgoing[0:rebsrcindex] +
84 [child.node(), ] + outgoing[rebsrcindex+1:])
85 children = [c for c in child.children() if c.branch() == child.branch()]
86 if children:
87 child = children[0]
88 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
80 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) 89 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui)
81 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) 90 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys()))
82 merc_util._encoding = oldencoding 91 merc_util._encoding = oldencoding
83 return 0 92 return 0
84 93