annotate hgsubversion/wrappers.py @ 438:e8f13bd20467

pushmod: split push functions out into separate module
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Tue, 16 Jun 2009 09:12:20 +0200
parents 7c576ae19d80
children 80909328aef1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
1 from hgext import rebase as hgrebase
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
2
257
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 patch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 from mercurial import hg
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 from mercurial import util as hgutil
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 from mercurial import node
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
8 from mercurial import i18n
257
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
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
14 import svnmeta
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
15 import replay
438
e8f13bd20467 pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
16 import pushmod
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 import stupid as stupidmod
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 import svnwrap
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 import util
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20
366
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
21 pullfuns = {
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
22 True: replay.convert_rev,
366
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
23 False: stupidmod.convert_rev,
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
24 }
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
25
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
26 revmeta = [
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
27 ('revision', 'revnum'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
28 ('user', 'author'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
29 ('date', 'date'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
30 ('message', 'message'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
31 ]
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
32
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
33 def parents(orig, ui, repo, *args, **opts):
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 """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
35 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 if not opts.get('svn', False):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 return orig(ui, repo, *args, **opts)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
38 meta = svnmeta.SVNMeta(repo)
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
39 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
40 ha = cmdutil.parentrev(ui, repo, meta, hashes)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 if ha.node() == node.nullid:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 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
43 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
44 displayer.show(ha)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
48 def incoming(orig, ui, repo, source='default', **opts):
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
49 """show incoming revisions from Subversion
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
50 """
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
51
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
52 source, revs, checkout = hg.parseurl(ui.expandpath(source))
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
53 other = hg.repository(ui, source)
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
54 if 'subversion' not in other.capabilities:
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
55 return orig(ui, repo, source, **opts)
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
56
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
57 user, passwd = util.getuserpass(opts)
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
58 svn = svnwrap.SubversionRepo(other.svnurl, user, passwd)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
59 meta = svnmeta.SVNMeta(repo)
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
60
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
61 ui.status('incoming changes from %s\n' % other.svnurl)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
62 for r in svn.revisions(start=meta.revmap.seen):
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
63 ui.status('\n')
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
64 for label, attr in revmeta:
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
65 l1 = label + ':'
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
66 val = str(getattr(r, attr)).strip()
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
67 if not ui.verbose:
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
68 val = val.split('\n')[0]
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
69 ui.status('%s%s\n' % (l1.ljust(13), val))
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
70
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
71
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
72 def outgoing(repo, dest=None, heads=None, force=False):
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 """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
74 """
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
75 assert dest.capable('subversion')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 283
diff changeset
77 # split off #rev; TODO implement --revision/#rev support
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
78 svnurl, revs, checkout = hg.parseurl(dest.svnurl, heads)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
79 meta = svnmeta.SVNMeta(repo)
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
80 parent = repo.parents()[0].node()
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
81 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
82 return util.outgoing_revisions(repo, hashes, parent)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 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
86 """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
87 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 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
89 return orig(ui, repo, *args, **opts)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
90 meta = svnmeta.SVNMeta(repo)
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
91 hashes = meta.revmap.hashes()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 if not opts.get('rev', None):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 parent = repo.parents()[0]
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
94 o_r = util.outgoing_revisions(repo, hashes, parent.node())
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 if o_r:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 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
97 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
98 node1, node2 = hgcmdutil.revpair(repo, opts['rev'])
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
99 baserev, _junk = hashes.get(node1, (-1, 'junk'))
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
100 newrev, _junk = hashes.get(node2, (-1, 'junk'))
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 it = patch.diff(repo, node1, node2,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 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
103 'show_function': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 'ignore_all_space': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 'ignore_space_change': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106 'ignore_blank_lines': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 'unified': True,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108 'text': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 }))
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 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
111
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
112 def push(repo, dest, force, revs):
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 """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
114 """
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
115 assert not revs, 'designated revisions for push remains unimplemented.'
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
116 ui = repo.ui
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
117 svnurl = util.normalize_url(repo.ui.expandpath(dest.svnurl))
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 old_encoding = util.swap_out_encoding()
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 283
diff changeset
119 # split of #rev; TODO: implement --rev/#rev support
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
120 svnurl, revs, checkout = hg.parseurl(svnurl, revs)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
121 # TODO: do credentials specified in the URL still work?
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
122 user = repo.ui.config('hgsubversion', 'username')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
123 passwd = repo.ui.config('hgsubversion', 'password')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
124 svn = svnwrap.SubversionRepo(svnurl, user, passwd)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
125 meta = svnmeta.SVNMeta(repo, svn.uuid)
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
126
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 # Strategy:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 # 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
129 if len(repo.parents()) != 1:
271
5278817fe8a1 Add newlines to ui.status calls where needed
Daniel Tang <dytang@cs.purdue.edu>
parents: 269
diff changeset
130 ui.status('Cowardly refusing to push branch merge\n')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 return 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 workingrev = repo.parents()[0]
267
f000b2392fc2 Push status messages, remove svn flag from opts before passing on
Luke Opperman <luke@loppear.com>
parents: 266
diff changeset
133 ui.status('searching for changes\n')
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
134 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
135 outgoing = util.outgoing_revisions(repo, hashes, workingrev.node())
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 if not (outgoing and len(outgoing)):
267
f000b2392fc2 Push status messages, remove svn flag from opts before passing on
Luke Opperman <luke@loppear.com>
parents: 266
diff changeset
137 ui.status('no changes found\n')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139 while outgoing:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 oldest = outgoing.pop(-1)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 old_ctx = repo[oldest]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 if len(old_ctx.parents()) != 1:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 ui.status('Found a branch merge, this needs discussion and '
271
5278817fe8a1 Add newlines to ui.status calls where needed
Daniel Tang <dytang@cs.purdue.edu>
parents: 269
diff changeset
144 'implementation.\n')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 return 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 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
147 old_children = repo[base_n].children()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 svnbranch = repo[base_n].branch()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 oldtip = base_n
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
151 and c.node() in hashes]
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 while samebranchchildren:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 oldtip = samebranchchildren[0].node()
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
155 and c.node() in hashes]
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 # 2. Commit oldest revision that needs to be pushed
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
157 base_revision = hashes[base_n][0]
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 try:
438
e8f13bd20467 pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
159 pushmod.commit(ui, repo, old_ctx, meta, svnurl,
e8f13bd20467 pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
160 base_revision, user, passwd)
e8f13bd20467 pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
161 except pushmod.NoFilesException:
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 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
163 old_ctx)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 return 1
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 # 3. Fetch revisions from svn
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
166 # TODO: this probably should pass in the source explicitly - rev too?
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
167 r = repo.pull(dest, force=force)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168 assert not r or r == 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 # 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
170 oldtipctx = repo[oldtip]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 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
172 and c.branch() == oldtipctx.branch()]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 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
174 replacement = replacement[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 # 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
176 heads = repo.heads(old_ctx.node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 for needs_transplant in heads:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 def extrafn(ctx, extra):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179 if ctx.node() == oldest:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180 return
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181 extra['branch'] = ctx.branch()
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
182 # TODO: can we avoid calling our own rebase wrapper here?
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
183 rebase(hgrebase.rebase, ui, repo, svn=True, svnextrafn=extrafn,
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
184 svnsourcerev=needs_transplant)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
185 repo = hg.repository(ui, meta.path)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 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
187 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
188 if rebasesrc in outgoing:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
189 while rebasesrc in outgoing:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
190 rebsrcindex = outgoing.index(rebasesrc)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191 outgoing = (outgoing[0:rebsrcindex] +
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 [child.node(), ] + outgoing[rebsrcindex+1:])
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193 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
194 if children:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 child = children[0]
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
197 # TODO: stop constantly creating the SVNMeta instances.
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
198 meta = svnmeta.SVNMeta(meta.repo, svn.uuid)
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
199 hashes = meta.revmap.hashes()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 util.swap_out_encoding(old_encoding)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
202
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
203
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
204 def pull(repo, source, heads=[], force=False):
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
205 """pull new revisions from Subversion"""
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
206 assert source.capable('subversion')
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
207 svn_url = source.svnurl
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
208
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
209 # Split off #rev
344
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
210 svn_url, heads, checkout = hg.parseurl(svn_url, heads)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 old_encoding = util.swap_out_encoding()
341
cfbd0e563af9 wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
212
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213 # TODO implement skipto support
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 skipto_rev = 0
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
215 try:
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
216 stopat_rev = int(checkout or 0)
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
217 except ValueError:
344
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
218 raise hgutil.Abort('unrecognised Subversion revision %s: '
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
219 'only numbers work.' % checkout)
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
220
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
221 have_replay = not repo.ui.configbool('hgsubversion', 'stupid')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222 if have_replay and not callable(
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
223 delta.svn_txdelta_apply(None, None, None)[0]): #pragma: no cover
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
224 repo.ui.status('You are using old Subversion SWIG bindings. Replay '
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
225 'will not work until you upgrade to 1.5.0 or newer. '
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
226 'Falling back to a slower method that may be buggier. '
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
227 'Please upgrade, or contribute a patch to use the '
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
228 'ctypes bindings instead of SWIG.\n')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
229 have_replay = False
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
230 elif not have_replay:
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
231 repo.ui.note('fetching stupidly...\n')
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
232
341
cfbd0e563af9 wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
233 # TODO: do credentials specified in the URL still work?
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
234 user = repo.ui.config('hgsubversion', 'username')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
235 passwd = repo.ui.config('hgsubversion', 'password')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236 svn = svnwrap.SubversionRepo(svn_url, user, passwd)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
237 meta = svnmeta.SVNMeta(repo, svn.uuid, svn.subdir)
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
238
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
239 start = max(meta.revmap.seen, skipto_rev)
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
240 initializing_repo = meta.revmap.seen <= 0
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 329
diff changeset
241 ui = repo.ui
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
242
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243 if initializing_repo and start > 0:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244 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
245 'remains unimplemented.')
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
246
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
247 revisions = 0
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
248 try:
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
249 try:
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
250 # start converting revisions
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
251 for r in svn.revisions(start=start, stop=stopat_rev):
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
252 if (r.author is None and
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
253 r.message == 'This is an empty revision for padding.'):
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
254 continue
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
255 tbdelta = meta.update_branch_tag_map_for_rev(r)
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
256 # got a 502? Try more than once!
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
257 tries = 0
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
258 converted = False
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
259 while not converted:
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
260 try:
431
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
261
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
262 msg = r.message.strip()
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
263 if not msg:
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
264 msg = util.default_commit_msg
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
265 else:
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
266 msg = [s.strip() for s in msg.splitlines() if s][0]
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
267 w = hgutil.termwidth()
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
268 bits = (r.revnum, r.author, msg)
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
269 ui.status(('[r%d] %s: %s\n' % bits)[:w])
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
270
432
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
271 close = pullfuns[have_replay](ui, meta, svn, r, tbdelta)
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
272 if tbdelta['tags'][0] or tbdelta['tags'][1]:
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
273 meta.committags(tbdelta['tags'], r, close)
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
274 for branch, parent in close.iteritems():
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
275 if parent in (None, node.nullid):
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
276 continue
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
277 meta.delbranch(branch, parent, r)
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
278
418
92beeefeaf93 save metadata from one place
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
279 meta.save()
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
280 converted = True
431
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
281
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
282 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
283 ui.status('%s\n' % e.message)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
284 stupidmod.print_your_svn_is_old_message(ui)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
285 have_replay = False
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
286 except core.SubversionException, e: #pragma: no cover
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
287 if (e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
288 and '502' in str(e)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
289 and tries < 3):
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
290 tries += 1
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
291 ui.status('Got a 502, retrying (%s)\n' % tries)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
292 else:
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
293 raise hgutil.Abort(*e.args)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
294 revisions += 1
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
295 except KeyboardInterrupt:
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
296 pass
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
297 finally:
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
298 util.swap_out_encoding(old_encoding)
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
299
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
300 if revisions == 0:
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
301 ui.status(i18n._("no changes found\n"))
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
302 return 0
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
303 else:
341
cfbd0e563af9 wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
304 ui.status("pulled %d revisions\n" % revisions)
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
305
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
306 def rebase(orig, ui, repo, **opts):
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
307 """rebase current unpushed revisions onto the Subversion head
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
308
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
309 This moves a line of development from making its own head to the top of
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
310 Subversion development, linearizing the changes. In order to make sure you
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
311 rebase on top of the current top of Subversion work, you should probably run
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
312 'hg svn pull' before running this.
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
313
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
314 Also looks for svnextrafn and svnsourcerev in **opts.
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
315 """
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
316 if not opts.get('svn', False):
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
317 return orig(ui, repo, **opts)
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
318 def extrafn2(ctx, extra):
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
319 """defined here so we can add things easily.
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
320 """
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
321 extra['branch'] = ctx.branch()
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
322 extrafn = opts.get('svnextrafn', extrafn2)
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
323 sourcerev = opts.get('svnsourcerev', repo.parents()[0].node())
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
324 meta = svnmeta.SVNMeta(repo)
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
325 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
326 o_r = util.outgoing_revisions(repo, hashes, sourcerev=sourcerev)
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
327 if not o_r:
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
328 ui.status('Nothing to rebase!\n')
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
329 return 0
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
330 if len(repo[sourcerev].children()):
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
331 ui.status('Refusing to rebase non-head commit like a coward\n')
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
332 return 0
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
333 parent_rev = repo[o_r[-1]].parents()[0]
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
334 target_rev = parent_rev
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
335 p_n = parent_rev.node()
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
336 exhausted_choices = False
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
337 while target_rev.children() and not exhausted_choices:
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
338 for c in target_rev.children():
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
339 exhausted_choices = True
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
340 n = c.node()
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
341 if (n in hashes and hashes[n][1] == hashes[p_n][1]):
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
342 target_rev = c
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
343 exhausted_choices = False
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
344 break
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
345 if parent_rev == target_rev:
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
346 ui.status('Already up to date!\n')
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
347 return 0
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
348 return orig(ui, repo, dest=node.hex(target_rev.node()),
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
349 base=node.hex(sourcerev),
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
350 extrafn=extrafn)
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
351
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
352
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
353 optionmap = {
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
354 'tagpaths': ('hgsubversion', 'tagpaths'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
355 'authors': ('hgsubversion', 'authormap'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
356 'filemap': ('hgsubversion', 'filemap'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
357 'stupid': ('hgsubversion', 'stupid'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
358 'defaulthost': ('hgsubversion', 'defaulthost'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
359 'defaultauthors': ('hgsubversion', 'defaultauthors'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
360 'usebranchnames': ('hgsubversion', 'usebranchnames'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
361 }
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
362
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
363 dontretain = { 'hgsubversion': set(['authormap', 'filemap']) }
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
364
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
365 def clone(orig, ui, source, dest=None, **opts):
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
366 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
367 Some of the options listed below only apply to Subversion
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
368 %(target)s. See 'hg help %(extension)s' for more information on
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
369 them as well as other ways of customising the conversion process.
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
370 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
371
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
372 for opt, (section, name) in optionmap.iteritems():
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
373 if opt in opts and opts[opt]:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
374 ui.setconfig(section, name, str(opts.pop(opt)))
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
375
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
376 # this must be kept in sync with mercurial/commands.py
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
377 srcrepo, dstrepo = hg.clone(hgcmdutil.remoteui(ui, opts), source, dest,
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
378 pull=opts.get('pull'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
379 stream=opts.get('uncompressed'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
380 rev=opts.get('rev'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
381 update=not opts.get('noupdate'))
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
382
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
383 if dstrepo.local() and srcrepo.capable('subversion'):
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
384 fd = dstrepo.opener("hgrc", "a", text=True)
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
385 for section in set(s for s, v in optionmap.itervalues()):
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
386 config = dict(ui.configitems(section))
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
387 for name in dontretain[section]:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
388 config.pop(name, None)
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
389
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
390 if config:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
391 fd.write('\n[%s]\n' % section)
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
392 map(fd.write, ('%s = %s\n' % p for p in config.iteritems()))
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
393
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
394
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
395 def generic(orig, ui, repo, *args, **opts):
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
396 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
397 Subversion %(target)s can be used for %(command)s. See 'hg help
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
398 %(extension)s' for more on the conversion process.
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
399 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
400 for opt, (section, name) in optionmap.iteritems():
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
401 if opt in opts and opts[opt]:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
402 if isinstance(repo, str):
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
403 ui.setconfig(section, name, opts.pop(opt))
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
404 else:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
405 repo.ui.setconfig(section, name, opts.pop(opt))
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
406 return orig(ui, repo, *args, **opts)