Mercurial > hgsubversion
annotate hgsubversion/wrappers.py @ 606:789eec0a339c
wrappers: fix pull output if termwidth() is inexact
This is going to happen soon on Windows.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 26 Apr 2010 22:17:25 +0200 |
parents | 1290ab9def8f |
children | d1de8bb6e11f |
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 |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
3 from mercurial import cmdutil |
257
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 |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
432
diff
changeset
|
10 import replay |
438
e8f13bd20467
pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
435
diff
changeset
|
11 import pushmod |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 import stupid as stupidmod |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 import svnwrap |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
14 import svnrepo |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 import util |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 |
366
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
17 pullfuns = { |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
432
diff
changeset
|
18 True: replay.convert_rev, |
366
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
19 False: stupidmod.convert_rev, |
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
20 } |
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
21 |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
22 revmeta = [ |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
23 ('revision', 'revnum'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
24 ('user', 'author'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
25 ('date', 'date'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
26 ('message', 'message'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
27 ] |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
28 |
507
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
29 |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
30 def version(orig, ui, *args, **opts): |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
31 svn = opts.pop('svn', None) |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
32 orig(ui, *args, **opts) |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
33 if svn: |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
34 ui.status('\nsvn bindings: %s\n' % svnwrap.version()) |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
35 ui.status('hgsubversion: %s\n' % util.version(ui)) |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
36 |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
37 |
403
37c96b78b8c0
uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
402
diff
changeset
|
38 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
|
39 """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
|
40 """ |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 if not opts.get('svn', False): |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 return orig(ui, repo, *args, **opts) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
43 meta = repo.svnmeta() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
44 hashes = meta.revmap.hashes() |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
45 ha = util.parentrev(ui, repo, meta, hashes) |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 if ha.node() == node.nullid: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 raise hgutil.Abort('No parent svn revision!') |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
48 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False) |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 displayer.show(ha) |
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 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
53 def incoming(orig, ui, repo, source='default', **opts): |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
54 """show incoming revisions from Subversion |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
55 """ |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
56 |
555
cbd7065e6ab4
util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents:
523
diff
changeset
|
57 source, revs, checkout = util.parseurl(ui.expandpath(source)) |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
58 other = hg.repository(ui, source) |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
59 if 'subversion' not in other.capabilities: |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
60 return orig(ui, repo, source, **opts) |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
61 |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
62 meta = repo.svnmeta() |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
63 |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
64 ui.status('incoming changes from %s\n' % other.svnurl) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
65 for r in other.svn.revisions(start=meta.revmap.seen): |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
66 ui.status('\n') |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
67 for label, attr in revmeta: |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
68 l1 = label + ':' |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
69 val = str(getattr(r, attr)).strip() |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
70 if not ui.verbose: |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
71 val = val.split('\n')[0] |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
72 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
|
73 |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
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 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
|
76 """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
|
77 """ |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
78 assert dest.capable('subversion') |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
283
diff
changeset
|
80 # split off #rev; TODO implement --revision/#rev support |
555
cbd7065e6ab4
util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents:
523
diff
changeset
|
81 svnurl, revs, checkout = util.parseurl(dest.svnurl, heads) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
82 meta = repo.svnmeta() |
406
e360558ba65f
add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
405
diff
changeset
|
83 parent = repo.parents()[0].node() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
84 hashes = meta.revmap.hashes() |
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
85 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
|
86 |
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 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
|
89 """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
|
90 """ |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 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
|
92 return orig(ui, repo, *args, **opts) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
93 meta = repo.svnmeta() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
94 hashes = meta.revmap.hashes() |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
95 if not opts.get('rev', None): |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 parent = repo.parents()[0] |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
97 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
|
98 if o_r: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
99 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
|
100 opts['rev'] = ['%s:.' % node.hex(parent.node()), ] |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
101 node1, node2 = cmdutil.revpair(repo, opts['rev']) |
406
e360558ba65f
add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
405
diff
changeset
|
102 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
|
103 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
|
104 it = patch.diff(repo, node1, node2, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 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
|
106 'show_function': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 'ignore_all_space': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 'ignore_space_change': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
109 'ignore_blank_lines': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
110 'unified': True, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
111 'text': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
112 })) |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
113 ui.write(util.filterdiff(''.join(it), baserev, newrev)) |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
114 |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
115 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
|
116 """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
|
117 """ |
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
|
118 assert not revs, 'designated revisions for push remains unimplemented.' |
461
db3a53a2cd76
wrappers: make push aborts if uncommitted changes
Patrick Mezard <pmezard@gmail.com>
parents:
444
diff
changeset
|
119 cmdutil.bail_if_changed(repo) |
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 ui = repo.ui |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
121 old_encoding = util.swap_out_encoding() |
466
9548b406a2d8
pushmod: pass SubversionRepo directly to commit()
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
122 # 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
|
123 # TODO: do credentials specified in the URL still work? |
466
9548b406a2d8
pushmod: pass SubversionRepo directly to commit()
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
124 svnurl = repo.ui.expandpath(dest.svnurl) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
125 svn = svnrepo.svnremoterepo(repo.ui, svnurl).svn |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
126 meta = repo.svnmeta(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
|
127 |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
128 # Strategy: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
129 # 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
|
130 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
|
131 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
|
132 return 1 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
133 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
|
134 ui.status('searching for changes\n') |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
135 hashes = meta.revmap.hashes() |
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 return 0 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 while outgoing: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 oldest = outgoing.pop(-1) |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 old_ctx = repo[oldest] |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 if len(old_ctx.parents()) != 1: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 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
|
145 'implementation.\n') |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
146 return 1 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
147 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
|
148 old_children = repo[base_n].children() |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 svnbranch = repo[base_n].branch() |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 oldtip = base_n |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 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
|
152 and c.node() in hashes] |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
153 while samebranchchildren: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 oldtip = samebranchchildren[0].node() |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 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
|
156 and c.node() in hashes] |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 # 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
|
158 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
|
159 try: |
466
9548b406a2d8
pushmod: pass SubversionRepo directly to commit()
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
160 pushmod.commit(ui, repo, old_ctx, meta, base_revision, svn) |
438
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. |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
198 meta = repo.svnmeta(svn.uuid) |
416
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 |
555
cbd7065e6ab4
util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents:
523
diff
changeset
|
210 svn_url, heads, checkout = util.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') |
600
a42e9c9bbb8a
wrappers: remove unused code for compatibility with Subversion 1.4.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
589
diff
changeset
|
222 if not have_replay: |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
223 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
|
224 |
604
1290ab9def8f
pull: fix passing credentials in URL.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
602
diff
changeset
|
225 svn = source.svn |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
226 meta = repo.svnmeta(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
|
227 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
228 layout = repo.ui.config('hgsubversion', 'layout', 'auto') |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
229 if layout == 'auto': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
230 rootlist = svn.list_dir('', revision=(stopat_rev or None)) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
231 if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
232 layout = 'standard' |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
233 else: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
234 layout = 'single' |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
235 repo.ui.setconfig('hgsubversion', 'layout', layout) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
236 repo.ui.note('using %s layout\n' % layout) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
237 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
238 start = max(meta.revmap.seen, skipto_rev) |
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
239 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
|
240 ui = repo.ui |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
241 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
242 if initializing_repo and start > 0: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 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
|
244 'remains unimplemented.') |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
245 |
523
fa7aab230f1d
wrappers: calculate and return exact count of changesets added.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
520
diff
changeset
|
246 oldrevisions = len(meta.revmap) |
559
66a8bdff9ced
pull: report progress to ui.progress so progress bars can appear
Augie Fackler <durin42@gmail.com>
parents:
555
diff
changeset
|
247 if stopat_rev: |
66a8bdff9ced
pull: report progress to ui.progress so progress bars can appear
Augie Fackler <durin42@gmail.com>
parents:
555
diff
changeset
|
248 total = stopat_rev - start |
66a8bdff9ced
pull: report progress to ui.progress so progress bars can appear
Augie Fackler <durin42@gmail.com>
parents:
555
diff
changeset
|
249 else: |
66a8bdff9ced
pull: report progress to ui.progress so progress bars can appear
Augie Fackler <durin42@gmail.com>
parents:
555
diff
changeset
|
250 total = svn.HEAD - start |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
341
diff
changeset
|
251 try: |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
252 try: |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
253 # start converting revisions |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
254 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
|
255 if (r.author is None and |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
256 r.message == 'This is an empty revision for padding.'): |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
257 continue |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
258 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
|
259 # got a 502? Try more than once! |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
260 tries = 0 |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
261 converted = False |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
262 while not converted: |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
263 try: |
561
312c8c98eeff
pull: handle commits without any commit message
Augie Fackler <durin42@gmail.com>
parents:
560
diff
changeset
|
264 msg = '' |
312c8c98eeff
pull: handle commits without any commit message
Augie Fackler <durin42@gmail.com>
parents:
560
diff
changeset
|
265 if r.message: |
312c8c98eeff
pull: handle commits without any commit message
Augie Fackler <durin42@gmail.com>
parents:
560
diff
changeset
|
266 msg = r.message.strip() |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
267 if not msg: |
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
268 msg = util.default_commit_msg |
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
269 else: |
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
270 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
|
271 w = hgutil.termwidth() |
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
272 bits = (r.revnum, r.author, msg) |
606
789eec0a339c
wrappers: fix pull output if termwidth() is inexact
Patrick Mezard <pmezard@gmail.com>
parents:
604
diff
changeset
|
273 ui.status(('[r%d] %s: %s' % bits)[:w] + '\n') |
602
7c44bc259505
wrappers.pull: fix calculation of progress totals.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
274 util.progress(ui, 'pull', r.revnum - start, total=total) |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
275 |
444
8c545dcad7b1
wrappers: save tbdelta in one place for both stupid and replay
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
440
diff
changeset
|
276 meta.save_tbdelta(tbdelta) |
432
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
277 close = pullfuns[have_replay](ui, meta, svn, r, tbdelta) |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
507
diff
changeset
|
278 meta.committags(r, close) |
432
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
279 for branch, parent in close.iteritems(): |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
280 if parent in (None, node.nullid): |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
281 continue |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
282 meta.delbranch(branch, parent, r) |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
283 |
418
92beeefeaf93
save metadata from one place
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
284 meta.save() |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
285 converted = True |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
286 |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
287 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
288 ui.status('%s\n' % e.message) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
289 stupidmod.print_your_svn_is_old_message(ui) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
290 have_replay = False |
601
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
600
diff
changeset
|
291 except svnwrap.SubversionException, e: #pragma: no cover |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
600
diff
changeset
|
292 if (e.args[1] == svnwrap.ERR_RA_DAV_REQUEST_FAILED |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
293 and '502' in str(e) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
294 and tries < 3): |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
295 tries += 1 |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
296 ui.status('Got a 502, retrying (%s)\n' % tries) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
297 else: |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
298 raise hgutil.Abort(*e.args) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
299 except KeyboardInterrupt: |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
300 pass |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
301 finally: |
602
7c44bc259505
wrappers.pull: fix calculation of progress totals.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
302 util.progress(ui, 'pull', None, total=total) |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
303 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
|
304 |
523
fa7aab230f1d
wrappers: calculate and return exact count of changesets added.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
520
diff
changeset
|
305 revisions = len(meta.revmap) - oldrevisions |
fa7aab230f1d
wrappers: calculate and return exact count of changesets added.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
520
diff
changeset
|
306 |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
307 if revisions == 0: |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
308 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
|
309 return 0 |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
310 else: |
341
cfbd0e563af9
wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
311 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
|
312 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
313 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
|
314 """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
|
315 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 '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
|
320 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
321 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
|
322 """ |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
323 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
|
324 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
|
325 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
|
326 """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
|
327 """ |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
328 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
|
329 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
|
330 sourcerev = opts.get('svnsourcerev', repo.parents()[0].node()) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
331 meta = repo.svnmeta() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
332 hashes = meta.revmap.hashes() |
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
333 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
|
334 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
|
335 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
|
336 return 0 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
337 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
|
338 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
|
339 return 0 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
340 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
|
341 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
|
342 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
|
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 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
|
345 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
|
346 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
|
347 n = c.node() |
406
e360558ba65f
add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
405
diff
changeset
|
348 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
|
349 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
|
350 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
|
351 break |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
352 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
|
353 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
|
354 return 0 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
355 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
|
356 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
|
357 extrafn=extrafn) |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
358 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
359 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
360 optionmap = { |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
361 'tagpaths': ('hgsubversion', 'tagpaths'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
362 'authors': ('hgsubversion', 'authormap'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
363 'filemap': ('hgsubversion', 'filemap'), |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
561
diff
changeset
|
364 'branchmap': ('hgsubversion', 'branchmap'), |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
365 'stupid': ('hgsubversion', 'stupid'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
366 'defaulthost': ('hgsubversion', 'defaulthost'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
367 'defaultauthors': ('hgsubversion', 'defaultauthors'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
368 'usebranchnames': ('hgsubversion', 'usebranchnames'), |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
369 'layout': ('hgsubversion', 'layout'), |
402
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 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
372 dontretain = { 'hgsubversion': set(['authormap', 'filemap', 'layout', ]) } |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
373 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
374 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
|
375 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
376 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
|
377 %(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
|
378 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
|
379 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
380 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
381 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
|
382 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
|
383 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
|
384 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
385 # this must be kept in sync with mercurial/commands.py |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
386 srcrepo, dstrepo = hg.clone(cmdutil.remoteui(ui, opts), source, dest, |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
387 pull=opts.get('pull'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
388 stream=opts.get('uncompressed'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
389 rev=opts.get('rev'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
390 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
|
391 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 config.pop(name, None) |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
398 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
399 if config: |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
400 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
|
401 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
|
402 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
403 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
404 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
|
405 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
406 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
|
407 %(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
|
408 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
409 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
|
410 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
|
411 if isinstance(repo, str): |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
412 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
|
413 else: |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
414 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
|
415 return orig(ui, repo, *args, **opts) |