annotate wrappers.py @ 261:141513b5173b

Stop breaking hg pull <path>.
author Augie Fackler <durin42@gmail.com>
date Sun, 12 Apr 2009 12:18:04 -0500
parents 87dc4d0dd048
children 3b3627611468
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import os
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 from mercurial import cmdutil as hgcmdutil
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 from mercurial import commands
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 from mercurial import patch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 from mercurial import hg
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 from mercurial import util as hgutil
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from mercurial import node
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 from svn import core
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 from svn import delta
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 import cmdutil
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 import hg_delta_editor
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 import stupid as stupidmod
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 import svnwrap
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 import util
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 import utility_commands
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 def parent(orig, ui, repo, *args, **opts):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 """show Mercurial & Subversion parents of the working dir or revision
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 if not opts.get('svn', False):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 return orig(ui, repo, *args, **opts)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 hge = hg_delta_editor.HgChangeReceiver(repo=repo)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 hge.revmap.iterkeys()))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 ha = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 if ha.node() == node.nullid:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 raise hgutil.Abort('No parent svn revision!')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 displayer.show(ha)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 def outgoing(orig, ui, repo, dest=None, *args, **opts):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 """show changesets not found in the Subversion repository
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 svnurl = repo.ui.expandpath(dest or 'default-push', dest or 'default')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 if not (cmdutil.issvnurl(svnurl) or opts.get('svn', False)):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 return orig(ui, repo, dest, *args, **opts)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 hge = hg_delta_editor.HgChangeReceiver(repo=repo)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 hge.revmap.iterkeys()))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 repo.parents()[0].node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 if not (o_r and len(o_r)):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 ui.status('no changes found\n')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 for node in reversed(o_r):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 displayer.show(repo[node])
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 def diff(orig, ui, repo, *args, **opts):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 """show a diff of the most recent revision against its parent from svn
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 if not opts.get('svn', False) or opts.get('change', None):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 return orig(ui, repo, *args, **opts)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 svn_commit_hashes = {}
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 hge = hg_delta_editor.HgChangeReceiver(repo=repo)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 hge.revmap.iterkeys()))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 if not opts.get('rev', None):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 parent = repo.parents()[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 parent.node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 if o_r:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 parent = repo[o_r[-1]].parents()[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 opts['rev'] = ['%s:.' % node.hex(parent.node()), ]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 node1, node2 = hgcmdutil.revpair(repo, opts['rev'])
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 baserev, _junk = svn_commit_hashes.get(node1, (-1, 'junk', ))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 newrev, _junk = svn_commit_hashes.get(node2, (-1, 'junk', ))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 it = patch.diff(repo, node1, node2,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 opts=patch.diffopts(ui, opts={'git': True,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 'show_function': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 'ignore_all_space': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 'ignore_space_change': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 'ignore_blank_lines': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 'unified': True,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 'text': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 }))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 ui.write(cmdutil.filterdiff(''.join(it), baserev, newrev))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 def push(orig, ui, repo, dest=None, *args, **opts):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 """push revisions starting at a specified head back to Subversion.
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 svnurl = repo.ui.expandpath(dest or 'default-push', dest or 'default')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 if not cmdutil.issvnurl(svnurl):
260
87dc4d0dd048 Forgot some return statements.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
96 return orig(ui, repo, dest=dest, *args, **opts)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 old_encoding = util.swap_out_encoding()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 hge = hg_delta_editor.HgChangeReceiver(repo=repo)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 svnurl = util.normalize_url(svnurl)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100 if svnurl != hge.url:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 raise hgutil.Abort('wrong subversion url!')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 hge.revmap.iterkeys()))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 user = opts.get('username', hgutil.getuser())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 passwd = opts.get('password', '')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 # Strategy:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108 # 1. Find all outgoing commits from this head
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 if len(repo.parents()) != 1:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 ui.status('Cowardly refusing to push branch merge')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 return 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112 workingrev = repo.parents()[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 outgoing = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, workingrev.node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 if not (outgoing and len(outgoing)):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115 ui.status('No revisions to push.')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 while outgoing:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 oldest = outgoing.pop(-1)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 old_ctx = repo[oldest]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 if len(old_ctx.parents()) != 1:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 ui.status('Found a branch merge, this needs discussion and '
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 'implementation.')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 return 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124 base_n = old_ctx.parents()[0].node()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 old_children = repo[base_n].children()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 svnbranch = repo[base_n].branch()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 oldtip = base_n
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 and c.node() in svn_commit_hashes]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 while samebranchchildren:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 oldtip = samebranchchildren[0].node()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 and c.node() in svn_commit_hashes]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 # 2. Commit oldest revision that needs to be pushed
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 base_revision = svn_commit_hashes[base_n][0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 try:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 cmdutil.commit_from_rev(ui, repo, old_ctx, hge, svnurl,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138 base_revision, user, passwd)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139 except cmdutil.NoFilesException:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 ui.warn("Could not push revision %s because it had no changes in svn.\n" %
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 old_ctx)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 return 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 # 3. Fetch revisions from svn
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 r = pull(None, ui, repo, True, stupid=opts.get('svn_stupid', False),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 username=user, password=passwd)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 assert not r or r == 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 # 4. Find the new head of the target branch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 repo = hg.repository(ui, hge.path)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 oldtipctx = repo[oldtip]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 replacement = [c for c in oldtipctx.children() if c not in old_children
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 and c.branch() == oldtipctx.branch()]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 assert len(replacement) == 1, 'Replacement node came back as: %r' % replacement
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 replacement = replacement[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 # 5. Rebase all children of the currently-pushing rev to the new branch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 heads = repo.heads(old_ctx.node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 for needs_transplant in heads:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 def extrafn(ctx, extra):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 if ctx.node() == oldest:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 return
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 extra['branch'] = ctx.branch()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161 utility_commands.rebase(ui, repo, extrafn=extrafn,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 sourcerev=needs_transplant, **opts)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163 repo = hg.repository(ui, hge.path)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 for child in repo[replacement.node()].children():
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 if rebasesrc in outgoing:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 while rebasesrc in outgoing:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168 rebsrcindex = outgoing.index(rebasesrc)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 outgoing = (outgoing[0:rebsrcindex] +
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 [child.node(), ] + outgoing[rebsrcindex+1:])
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 children = [c for c in child.children() if c.branch() == child.branch()]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 if children:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 child = children[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 hge = hg_delta_editor.HgChangeReceiver(hge.path, ui_=ui)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys()))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 util.swap_out_encoding(old_encoding)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182 def clone(orig, ui, source, dest=None, *args, **opts):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
183 '''clone Subversion repository to a local Mercurial repository.
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 If no destination directory name is specified, it defaults to the
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 basename of the source plus "-hg".
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
187
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
188 You can specify multiple paths for the location of tags using comma
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
189 separated values.
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
190 '''
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191 svnurl = ui.expandpath(source)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 if not cmdutil.issvnurl(svnurl):
260
87dc4d0dd048 Forgot some return statements.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
193 return orig(ui, source=source, dest=dest, *args, **opts)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
194
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 if not dest:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196 dest = hg.defaultdest(source) + '-hg'
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 ui.status("Assuming destination %s\n" % dest)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
198
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 if os.path.exists(dest):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 raise hgutil.Abort("destination '%s' already exists" % dest)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201 url = util.normalize_url(svnurl)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
202 res = -1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
203 try:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
204 try:
261
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
205 res = pull(None, ui, None, source=url, svn=None,
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
206 svn_stupid=opts.pop('svn_stupid', False),
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
207 create_new_dest=dest, **opts)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
208 except core.SubversionException, e:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
209 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
210 raise hgutil.Abort('It appears svn does not trust the ssl cert for this site.\n'
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 'Please try running svn ls on that url first.')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 raise
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213 finally:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 if os.path.exists(dest):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
215 repo = hg.repository(ui, dest)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
216 fp = repo.opener("hgrc", "w", text=True)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
217 fp.write("[paths]\n")
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
218 # percent needs to be escaped for ConfigParser
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
219 fp.write("default = %(url)s\nsvn = %(url)s\n" % {'url': svnurl.replace('%', '%%')})
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
220 fp.close()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
221 if (res is None or res == 0) and not opts.get('noupdate', False):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222 commands.update(ui, repo, repo['tip'].node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
223
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224 return res
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
225
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226
261
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
227 def pull(orig, ui, repo, source="default", *args, **opts):
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
228 """pull new revisions from Subversion
261
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
229
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
230 Also takes svn, svn_stupid, and create_new_dest kwargs.
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231 """
261
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
232 svn = opts.pop('svn', None)
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
233 svn_stupid = opts.pop('svn_stupid', False)
141513b5173b Stop breaking hg pull <path>.
Augie Fackler <durin42@gmail.com>
parents: 260
diff changeset
234 create_new_dest = opts.pop('create_new_dest', False)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
235 url = ((repo and repo.ui) or ui).expandpath(source)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236 if not (cmdutil.issvnurl(url) or svn or create_new_dest):
260
87dc4d0dd048 Forgot some return statements.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
237 return orig(ui, repo, source=source, *args, **opts)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
238 svn_url = url
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
239 svn_url = util.normalize_url(svn_url)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
240 old_encoding = util.swap_out_encoding()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
241 # TODO implement skipto support
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
242 skipto_rev = 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243 have_replay = not svn_stupid
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244 if have_replay and not callable(
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
245 delta.svn_txdelta_apply(None, None, None)[0]): #pragma: no cover
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
246 ui.status('You are using old Subversion SWIG bindings. Replay will not'
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
247 ' work until you upgrade to 1.5.0 or newer. Falling back to'
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
248 ' a slower method that may be buggier. Please upgrade, or'
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
249 ' contribute a patch to use the ctypes bindings instead'
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
250 ' of SWIG.\n')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
251 have_replay = False
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
252 initializing_repo = False
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
253 user = opts.get('username', hgutil.getuser())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
254 passwd = opts.get('password', '')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
255 svn = svnwrap.SubversionRepo(svn_url, user, passwd)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
256 author_host = "@%s" % svn.uuid
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
257 # TODO these should be configurable again, but I'm torn on how.
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
258 # Maybe this should be configured in .hg/hgrc for each repo? Seems vaguely reasonable.
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
259 tag_locations = ['tags', ]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 authors = opts.pop('svn_authors', None)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
261 filemap = opts.pop('svn_filemap', None)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
262 if repo:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
263 hg_editor = hg_delta_editor.HgChangeReceiver(repo=repo,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
264 subdir=svn.subdir,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
265 author_host=author_host,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
266 tag_locations=tag_locations,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
267 authors=authors,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
268 filemap=filemap)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
269 else:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
270 hg_editor = hg_delta_editor.HgChangeReceiver(ui_=ui,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
271 path=create_new_dest,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
272 subdir=svn.subdir,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
273 author_host=author_host,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
274 tag_locations=tag_locations,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
275 authors=authors,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
276 filemap=filemap)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
277 if os.path.exists(hg_editor.uuid_file):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
278 uuid = open(hg_editor.uuid_file).read()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
279 assert uuid == svn.uuid
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
280 start = hg_editor.last_known_revision()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
281 else:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
282 open(hg_editor.uuid_file, 'w').write(svn.uuid)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
283 open(hg_editor.svn_url_file, 'w').write(svn_url)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
284 initializing_repo = True
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 start = skipto_rev
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
286
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
287 if initializing_repo and start > 0:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
288 raise hgutil.Abort('Revision skipping at repository initialization '
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
289 'remains unimplemented.')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
290
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
291 # start converting revisions
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
292 for r in svn.revisions(start=start):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
293 valid = True
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
294 hg_editor.update_branch_tag_map_for_rev(r)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
295 for p in r.paths:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
296 if hg_editor._is_path_valid(p):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
297 valid = True
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
298 break
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
299 if valid:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
300 # got a 502? Try more than once!
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
301 tries = 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
302 converted = False
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
303 while not converted:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
304 try:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
305 util.describe_revision(ui, r)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
306 if have_replay:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
307 try:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
308 cmdutil.replay_convert_rev(hg_editor, svn, r)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
309 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
310 ui.status('%s\n' % e.message)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
311 stupidmod.print_your_svn_is_old_message(ui)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
312 have_replay = False
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
313 stupidmod.svn_server_pull_rev(ui, svn, hg_editor, r)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
314 else:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
315 stupidmod.svn_server_pull_rev(ui, svn, hg_editor, r)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
316 converted = True
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
317 except core.SubversionException, e: #pragma: no cover
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
318 if (e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
319 and '502' in str(e)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
320 and tries < 3):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
321 tries += 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
322 ui.status('Got a 502, retrying (%s)\n' % tries)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
323 else:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
324 raise hgutil.Abort(*e.args)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
325 util.swap_out_encoding(old_encoding)