annotate hgsubversion/wrappers.py @ 915:d6c47c33f6a2

fix breakage introduced by peer classes in hg 2.3
author Bryan O'Sullivan <bryano@fb.com>
date Thu, 19 Jul 2012 16:00:54 -0700
parents c4ee11a5d04c
children 6918f60d0e28
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
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 438
diff changeset
3 from mercurial import cmdutil
876
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
4 try:
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
5 from mercurial import discovery
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
6 discovery.nullid # force demandimport to import the module
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
7 except ImportError:
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
8 discovery = None
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 from mercurial import patch
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 from mercurial import hg
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 from mercurial import util as hgutil
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 from mercurial import node
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
13 from mercurial import i18n
713
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
14 from mercurial import extensions
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
16 import replay
438
e8f13bd20467 pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 435
diff changeset
17 import pushmod
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 import stupid as stupidmod
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 import svnwrap
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
20 import svnrepo
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 import util
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22
804
6beca5b97dc7 wrappers: fix revpair after hg.b33f3e35efb0
Patrick Mezard <pmezard@gmail.com>
parents: 802
diff changeset
23 try:
819
e30ff6d5feff Fix import based feature detection
Patrick Mezard <pmezard@gmail.com>
parents: 816
diff changeset
24 from mercurial import scmutil
e30ff6d5feff Fix import based feature detection
Patrick Mezard <pmezard@gmail.com>
parents: 816
diff changeset
25 revpair = scmutil.revpair
804
6beca5b97dc7 wrappers: fix revpair after hg.b33f3e35efb0
Patrick Mezard <pmezard@gmail.com>
parents: 802
diff changeset
26 except ImportError:
819
e30ff6d5feff Fix import based feature detection
Patrick Mezard <pmezard@gmail.com>
parents: 816
diff changeset
27 revpair = cmdutil.revpair
804
6beca5b97dc7 wrappers: fix revpair after hg.b33f3e35efb0
Patrick Mezard <pmezard@gmail.com>
parents: 802
diff changeset
28
366
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
29 pullfuns = {
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 432
diff changeset
30 True: replay.convert_rev,
366
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
31 False: stupidmod.convert_rev,
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
32 }
25ebdc16b05b Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 356
diff changeset
33
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
34 revmeta = [
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
35 ('revision', 'revnum'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
36 ('user', 'author'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
37 ('date', 'date'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
38 ('message', 'message'),
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
39 ]
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
40
507
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
41
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
42 def version(orig, ui, *args, **opts):
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
43 svn = opts.pop('svn', None)
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
44 orig(ui, *args, **opts)
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
45 if svn:
664
5c94a86ddd73 version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 657
diff changeset
46 svnversion, bindings = svnwrap.version()
5c94a86ddd73 version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 657
diff changeset
47 ui.status('\n')
507
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
48 ui.status('hgsubversion: %s\n' % util.version(ui))
664
5c94a86ddd73 version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 657
diff changeset
49 ui.status('Subversion: %s\n' % svnversion)
5c94a86ddd73 version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 657
diff changeset
50 ui.status('bindings: %s\n' % bindings)
507
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
51
4ce09bf4d382 wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents: 499
diff changeset
52
403
37c96b78b8c0 uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 402
diff changeset
53 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
54 """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
55 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 if not opts.get('svn', False):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 return orig(ui, repo, *args, **opts)
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
58 meta = repo.svnmeta()
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
59 hashes = meta.revmap.hashes()
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 438
diff changeset
60 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
61 if ha.node() == node.nullid:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 raise hgutil.Abort('No parent svn revision!')
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 438
diff changeset
63 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
64 displayer.show(ha)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 return 0
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67
915
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
68 def getpeer(ui, opts, source):
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
69 # Since 2.3 (1ac628cd7113)
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
70 peer = getattr(hg, 'peer', None)
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
71 if peer:
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
72 return peer(ui, opts, source)
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
73 return hg.repository(ui, source)
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
74
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
75
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
76 def getcaps(other):
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
77 return (getattr(other, 'caps', None) or
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
78 getattr(other, 'capabilities', None) or set())
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
79
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
80
771
768639283275 incoming: pass unexpanded source to wrapped function (fixes #178)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 769
diff changeset
81 def incoming(orig, ui, repo, origsource='default', **opts):
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
82 """show incoming revisions from Subversion
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
83 """
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
84
771
768639283275 incoming: pass unexpanded source to wrapped function (fixes #178)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 769
diff changeset
85 source, revs, checkout = util.parseurl(ui.expandpath(origsource))
915
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
86 other = getpeer(ui, opts, source)
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
87 if 'subversion' not in getcaps(other):
771
768639283275 incoming: pass unexpanded source to wrapped function (fixes #178)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 769
diff changeset
88 return orig(ui, repo, origsource, **opts)
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
89
751
5e54e333ec3d wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 749
diff changeset
90 svn = other.svn
5e54e333ec3d wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 749
diff changeset
91 meta = repo.svnmeta(svn.uuid, svn.subdir)
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
92
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
93 ui.status('incoming changes from %s\n' % other.svnurl)
751
5e54e333ec3d wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 749
diff changeset
94 for r in svn.revisions(start=meta.revmap.youngest):
404
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
95 ui.status('\n')
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
96 for label, attr in revmeta:
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
97 l1 = label + ':'
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
98 val = str(getattr(r, attr)).strip()
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
99 if not ui.verbose:
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
100 val = val.split('\n')[0]
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
101 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
102
28e4b47b2179 add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 403
diff changeset
103
805
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
104 def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None):
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
105 assert other.capable('subversion')
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
106 # split off #rev; TODO implement --revision/#rev support
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
107 svn = other.svn
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
108 meta = repo.svnmeta(svn.uuid, svn.subdir)
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
109 parent = repo.parents()[0].node()
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
110 hashes = meta.revmap.hashes()
845
8cf8ff0f52fe outgoing: fix for hg change cd956049fc14
Augie Fackler <durin42@gmail.com>
parents: 841
diff changeset
111 common, heads = util.outgoing_common_and_heads(repo, hashes, parent)
876
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
112 if discovery is not None:
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
113 outobj = getattr(discovery, 'outgoing', None)
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
114 if outobj is not None:
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
115 # Mercurial 2.1 and later
b450448a9033 wrappers: don't break on old hg versions that lack discovery
Augie Fackler <raf@durin42.com>
parents: 845
diff changeset
116 return outobj(repo.changelog, common, heads)
845
8cf8ff0f52fe outgoing: fix for hg change cd956049fc14
Augie Fackler <durin42@gmail.com>
parents: 841
diff changeset
117 # Mercurial 2.0 and earlier
8cf8ff0f52fe outgoing: fix for hg change cd956049fc14
Augie Fackler <durin42@gmail.com>
parents: 841
diff changeset
118 return common, heads
805
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
119
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
120
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 804
diff changeset
121 def findoutgoing(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
122 """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
123 """
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
124 assert dest.capable('subversion')
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 283
diff changeset
125 # split off #rev; TODO implement --revision/#rev support
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 821
diff changeset
126 # svnurl, revs, checkout = util.parseurl(dest.svnurl, heads)
751
5e54e333ec3d wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 749
diff changeset
127 svn = dest.svn
5e54e333ec3d wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 749
diff changeset
128 meta = repo.svnmeta(svn.uuid, svn.subdir)
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
129 parent = repo.parents()[0].node()
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
130 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
131 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
132
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 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
135 """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
136 """
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 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
138 return orig(ui, repo, *args, **opts)
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
139 meta = repo.svnmeta()
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
140 hashes = meta.revmap.hashes()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 if not opts.get('rev', None):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 parent = repo.parents()[0]
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
143 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
144 if o_r:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 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
146 opts['rev'] = ['%s:.' % node.hex(parent.node()), ]
804
6beca5b97dc7 wrappers: fix revpair after hg.b33f3e35efb0
Patrick Mezard <pmezard@gmail.com>
parents: 802
diff changeset
147 node1, node2 = revpair(repo, opts['rev'])
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
148 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
149 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
150 it = patch.diff(repo, node1, node2,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 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
152 'show_function': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 'ignore_all_space': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 'ignore_space_change': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 'ignore_blank_lines': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 'unified': True,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 'text': False,
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 }))
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 438
diff changeset
159 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
160
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
161 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
162 """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
163 """
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
164 assert not revs, 'designated revisions for push remains unimplemented.'
802
d50858a8a17b wrapper: fix bail_if_changed() after hg.d68ddccf276b
Patrick Mezard <pmezard@gmail.com>
parents: 787
diff changeset
165 if hasattr(cmdutil, 'bail_if_changed'):
d50858a8a17b wrapper: fix bail_if_changed() after hg.d68ddccf276b
Patrick Mezard <pmezard@gmail.com>
parents: 787
diff changeset
166 cmdutil.bail_if_changed(repo)
d50858a8a17b wrapper: fix bail_if_changed() after hg.d68ddccf276b
Patrick Mezard <pmezard@gmail.com>
parents: 787
diff changeset
167 else:
d50858a8a17b wrapper: fix bail_if_changed() after hg.d68ddccf276b
Patrick Mezard <pmezard@gmail.com>
parents: 787
diff changeset
168 # Since 1.9 (d68ddccf276b)
d50858a8a17b wrapper: fix bail_if_changed() after hg.d68ddccf276b
Patrick Mezard <pmezard@gmail.com>
parents: 787
diff changeset
169 cmdutil.bailifchanged(repo)
783
7913a82a8cdd Check mercurial/third-parties push conditions before pushing
Patrick Mezard <pmezard@gmail.com>
parents: 779
diff changeset
170 checkpush = getattr(repo, 'checkpush', None)
7913a82a8cdd Check mercurial/third-parties push conditions before pushing
Patrick Mezard <pmezard@gmail.com>
parents: 779
diff changeset
171 if checkpush:
7913a82a8cdd Check mercurial/third-parties push conditions before pushing
Patrick Mezard <pmezard@gmail.com>
parents: 779
diff changeset
172 checkpush(force, revs)
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
173 ui = repo.ui
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 old_encoding = util.swap_out_encoding()
466
9548b406a2d8 pushmod: pass SubversionRepo directly to commit()
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
175 # 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
176 # 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
177 svnurl = repo.ui.expandpath(dest.svnurl)
608
d1de8bb6e11f push: remove superfluous creation of a new `svnremoterepo' instance.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 606
diff changeset
178 svn = dest.svn
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 729
diff changeset
179 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
180
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181 # Strategy:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182 # 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
183 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
184 ui.status('Cowardly refusing to push branch merge\n')
626
8e621dbb82d4 push: return reasonable status codes to the end user
Augie Fackler <durin42@gmail.com>
parents: 620
diff changeset
185 return 0 # results in nonzero exit status, see hg's commands.py
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 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
187 ui.status('searching for changes\n')
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
188 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
189 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
190 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
191 ui.status('no changes found\n')
626
8e621dbb82d4 push: return reasonable status codes to the end user
Augie Fackler <durin42@gmail.com>
parents: 620
diff changeset
192 return 1 # so we get a sane exit status, see hg's commands.push
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193 while outgoing:
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
194
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
195 # 2. Commit oldest revision that needs to be pushed
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196 oldest = outgoing.pop(-1)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 old_ctx = repo[oldest]
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
198 old_pars = old_ctx.parents()
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
199 if len(old_pars) != 1:
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 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
201 'implementation.\n')
626
8e621dbb82d4 push: return reasonable status codes to the end user
Augie Fackler <durin42@gmail.com>
parents: 620
diff changeset
202 return 0 # results in nonzero exit status, see hg's commands.py
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
203 # We will commit to svn against this node's parent rev. Any file-level
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
204 # conflicts here will result in an error reported by svn.
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
205 base_ctx = old_pars[0]
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
206 base_revision = hashes[base_ctx.node()][0]
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
207 svnbranch = base_ctx.branch()
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
208 # Find most recent svn commit we have on this branch.
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
209 # This node will become the nearest known ancestor of the pushed rev.
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
210 oldtipctx = base_ctx
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
211 old_children = oldtipctx.descendants()
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
212 seen = set(c.node() for c in old_children)
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
213 samebranchchildren = [c for c in old_children if c.branch() == svnbranch
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
214 and c.node() in hashes]
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
215 if samebranchchildren:
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
216 # The following relies on descendants being sorted by rev.
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
217 oldtipctx = samebranchchildren[-1]
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
218 # All set, so commit now.
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
219 try:
466
9548b406a2d8 pushmod: pass SubversionRepo directly to commit()
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
220 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
221 except pushmod.NoFilesException:
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222 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
223 old_ctx)
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224 return 1
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
225
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226 # 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
227 # 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
228 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
229 assert not r or r == 0
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
230
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231 # 4. Find the new head of the target branch
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
232 # We expect to get our own new commit back, but we might also get other
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
233 # commits that happened since our last pull, or even right after our own
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
234 # commit (race).
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
235 for c in oldtipctx.descendants():
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
236 if c.node() not in seen and c.branch() == svnbranch:
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
237 newtipctx = c
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
238
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
239 # 5. Rebase all children of the currently-pushing rev to the new head
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
240 heads = repo.heads(old_ctx.node())
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
241 for needs_transplant in heads:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
242 def extrafn(ctx, extra):
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243 if ctx.node() == oldest:
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244 return
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
245 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
246 # 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
247 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
248 svnsourcerev=needs_transplant)
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
249 # Reload the repo after the rebase. Do not reuse contexts across this.
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
250 newtip = newtipctx.node()
915
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
251 repo = getpeer(ui, {}, meta.path)
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
252 repo = getattr(repo, 'local', lambda: repo)()
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
253 newtipctx = repo[newtip]
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 664
diff changeset
254 # Rewrite the node ids in outgoing to their rebased versions.
692
42879fddf727 push: simplify code for remapping rebased node ids
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 691
diff changeset
255 rebasemap = dict()
42879fddf727 push: simplify code for remapping rebased node ids
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 691
diff changeset
256 for child in newtipctx.descendants():
42879fddf727 push: simplify code for remapping rebased node ids
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 691
diff changeset
257 rebasesrc = child.extra().get('rebase_source')
42879fddf727 push: simplify code for remapping rebased node ids
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 691
diff changeset
258 if rebasesrc:
42879fddf727 push: simplify code for remapping rebased node ids
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 691
diff changeset
259 rebasemap[node.bin(rebasesrc)] = child.node()
42879fddf727 push: simplify code for remapping rebased node ids
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 691
diff changeset
260 outgoing = [rebasemap.get(n) or n for n in outgoing]
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
261 # TODO: stop constantly creating the SVNMeta instances.
751
5e54e333ec3d wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 749
diff changeset
262 meta = repo.svnmeta(svn.uuid, svn.subdir)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
263 hashes = meta.revmap.hashes()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
264 util.swap_out_encoding(old_encoding)
626
8e621dbb82d4 push: return reasonable status codes to the end user
Augie Fackler <durin42@gmail.com>
parents: 620
diff changeset
265 return 1 # so we get a sane exit status, see hg's commands.push
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
266
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
267
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
268 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
269 """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
270 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
271 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
272
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
273 # 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
274 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
275 old_encoding = util.swap_out_encoding()
341
cfbd0e563af9 wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
276
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
277 try:
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
278 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
279 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
280 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
281 '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
282
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
283 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
284 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
285 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
286
604
1290ab9def8f pull: fix passing credentials in URL.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 602
diff changeset
287 svn = source.svn
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
288 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
289
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
290 layout = repo.ui.config('hgsubversion', 'layout', 'auto')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
291 if layout == 'auto':
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
292 rootlist = svn.list_dir('', revision=(stopat_rev or None))
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
293 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
294 layout = 'standard'
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
295 else:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
296 layout = 'single'
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
297 repo.ui.setconfig('hgsubversion', 'layout', layout)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
298 repo.ui.note('using %s layout\n' % layout)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
299
701
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
300 branch = repo.ui.config('hgsubversion', 'branch')
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
301 if branch:
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
302 if layout != 'single':
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
303 msg = ('branch cannot be specified for Subversion clones using '
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
304 'standard directory layout')
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
305 raise hgutil.Abort(msg)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
306
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
307 meta.branchmap['default'] = branch
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
308
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
309 ui = repo.ui
651
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
310 start = meta.revmap.youngest
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
311 origrevcount = len(meta.revmap)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
312
651
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
313 if start <= 0:
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
314 # we are initializing a new repository
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
315 start = repo.ui.config('hgsubversion', 'startrev', 0)
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
316 if isinstance(start, str) and start.upper() == 'HEAD':
657
9cf547fc36e8 pull: fix shallow clone when lastest change isn't HEAD.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 651
diff changeset
317 start = svn.last_changed_rev
651
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
318 else:
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
319 start = int(start)
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
320
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
321 if start > 0:
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
322 if layout == 'standard':
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
323 raise hgutil.Abort('non-zero start revisions are only '
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
324 'supported for single-directory clones.')
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
325 ui.note('starting at revision %d; any prior will be ignored\n'
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
326 % start)
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
327 # fetch all revisions *including* the one specified...
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
328 start -= 1
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
329
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
330 # anything less than zero makes no sense
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
331 if start < 0:
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
332 start = 0
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
333
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
334 skiprevs = repo.ui.configlist('hgsubversion', 'unsafeskip', '')
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
335 try:
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
336 skiprevs = set(map(int, skiprevs))
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
337 except ValueError:
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
338 raise hgutil.Abort('unrecognised Subversion revisions %r: '
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
339 'only numbers work.' % checkout)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
340
523
fa7aab230f1d wrappers: calculate and return exact count of changesets added.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 520
diff changeset
341 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
342 if stopat_rev:
66a8bdff9ced pull: report progress to ui.progress so progress bars can appear
Augie Fackler <durin42@gmail.com>
parents: 555
diff changeset
343 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
344 else:
66a8bdff9ced pull: report progress to ui.progress so progress bars can appear
Augie Fackler <durin42@gmail.com>
parents: 555
diff changeset
345 total = svn.HEAD - start
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 819
diff changeset
346 lastpulled = None
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 341
diff changeset
347 try:
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
348 try:
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
349 # start converting revisions
787
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 783
diff changeset
350 firstrun = True
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
351 for r in svn.revisions(start=start, stop=stopat_rev):
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
352 if r.revnum in skiprevs:
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
353 ui.status('[r%d SKIPPED]\n' % r.revnum)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 895
diff changeset
354 continue
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 819
diff changeset
355 lastpulled = r.revnum
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
356 if (r.author is None and
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
357 r.message == 'This is an empty revision for padding.'):
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
358 continue
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
359 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
360 # got a 502? Try more than once!
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
361 tries = 0
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
362 converted = False
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
363 while not converted:
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
364 try:
561
312c8c98eeff pull: handle commits without any commit message
Augie Fackler <durin42@gmail.com>
parents: 560
diff changeset
365 msg = ''
312c8c98eeff pull: handle commits without any commit message
Augie Fackler <durin42@gmail.com>
parents: 560
diff changeset
366 if r.message:
312c8c98eeff pull: handle commits without any commit message
Augie Fackler <durin42@gmail.com>
parents: 560
diff changeset
367 msg = r.message.strip()
431
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
368 if not msg:
769
cc1d4aa3ba41 configurable substitution for empty commit message (fixes #195)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 751
diff changeset
369 msg = util.default_commit_msg(ui)
431
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
370 else:
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
371 msg = [s.strip() for s in msg.splitlines() if s][0]
749
ec52205e5ed1 pull: handle change in termwidth() api from hg change c52c629ce19e
Augie Fackler <durin42@gmail.com>
parents: 748
diff changeset
372 if getattr(ui, 'termwidth', False):
ec52205e5ed1 pull: handle change in termwidth() api from hg change c52c629ce19e
Augie Fackler <durin42@gmail.com>
parents: 748
diff changeset
373 w = ui.termwidth()
ec52205e5ed1 pull: handle change in termwidth() api from hg change c52c629ce19e
Augie Fackler <durin42@gmail.com>
parents: 748
diff changeset
374 else:
ec52205e5ed1 pull: handle change in termwidth() api from hg change c52c629ce19e
Augie Fackler <durin42@gmail.com>
parents: 748
diff changeset
375 w = hgutil.termwidth()
431
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
376 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
377 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
378 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
379
444
8c545dcad7b1 wrappers: save tbdelta in one place for both stupid and replay
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 440
diff changeset
380 meta.save_tbdelta(tbdelta)
787
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 783
diff changeset
381 close = pullfuns[have_replay](ui, meta, svn, r, tbdelta,
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 783
diff changeset
382 firstrun)
520
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 507
diff changeset
383 meta.committags(r, close)
432
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
384 for branch, parent in close.iteritems():
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
385 if parent in (None, node.nullid):
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
386 continue
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
387 meta.delbranch(branch, parent, r)
4bf90f8c9b7b consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
388
418
92beeefeaf93 save metadata from one place
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
389 meta.save()
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
390 converted = True
787
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 783
diff changeset
391 firstrun = False
431
612b8d753549 inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
392
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 821
diff changeset
393 except svnwrap.SubversionRepoCanNotReplay, e: # pragma: no cover
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
394 ui.status('%s\n' % e.message)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
395 stupidmod.print_your_svn_is_old_message(ui)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
396 have_replay = False
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 821
diff changeset
397 except svnwrap.SubversionException, e: # pragma: no cover
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 600
diff changeset
398 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
399 and '502' in str(e)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
400 and tries < 3):
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
401 tries += 1
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
402 ui.status('Got a 502, retrying (%s)\n' % tries)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
403 else:
705
385213d2e2da pull: reveal the handled SubversionException to --traceback.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 701
diff changeset
404 ui.traceback()
390
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
405 raise hgutil.Abort(*e.args)
afe93f14a361 wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents: 367
diff changeset
406 except KeyboardInterrupt:
895
5b9f17e34126 don't suppress KeyboardInterrupt exception tracebacks
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 876
diff changeset
407 ui.traceback()
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 346
diff changeset
408 finally:
602
7c44bc259505 wrappers.pull: fix calculation of progress totals.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
409 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
410 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
411
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 819
diff changeset
412 if lastpulled is not None:
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 819
diff changeset
413 meta.revmap.youngest = lastpulled
523
fa7aab230f1d wrappers: calculate and return exact count of changesets added.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 520
diff changeset
414 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
415
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
416 if revisions == 0:
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
417 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
418 return 0
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
419 else:
341
cfbd0e563af9 wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
420 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
421
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
422 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
423 """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
424
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
425 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
426 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
427 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
428 '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
429
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
430 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
431 """
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
432 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
433 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
434 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
435 """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
436 """
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
437 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
438 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
439 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
440 meta = repo.svnmeta()
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
441 hashes = meta.revmap.hashes()
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
442 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
443 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
444 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
445 return 0
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
446 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
447 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
448 return 0
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 n = c.node()
406
e360558ba65f add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 405
diff changeset
457 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
458 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
459 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
460 break
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
461 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
462 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
463 return 0
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 263
diff changeset
464 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
465 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
466 extrafn=extrafn)
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
467
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
468
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
469 optionmap = {
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
470 'tagpaths': ('hgsubversion', 'tagpaths'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
471 'authors': ('hgsubversion', 'authormap'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
472 'filemap': ('hgsubversion', 'filemap'),
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 561
diff changeset
473 'branchmap': ('hgsubversion', 'branchmap'),
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 713
diff changeset
474 'tagmap': ('hgsubversion', 'tagmap'),
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
475 'stupid': ('hgsubversion', 'stupid'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
476 'defaulthost': ('hgsubversion', 'defaulthost'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
477 'defaultauthors': ('hgsubversion', 'defaultauthors'),
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
478 'usebranchnames': ('hgsubversion', 'usebranchnames'),
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
479 'layout': ('hgsubversion', 'layout'),
651
827547493112 clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 647
diff changeset
480 'startrev': ('hgsubversion', 'startrev'),
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
481 }
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
482
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 466
diff changeset
483 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
484
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
485 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
486 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
487 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
488 %(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
489 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
490 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
491
713
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
492 data = {}
816
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
493 def hgclonewrapper(orig, ui, *args, **opts):
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
494 if getattr(hg, 'peer', None):
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
495 # Since 1.9 (d976542986d2)
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
496 origsource = args[1]
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
497 else:
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
498 origsource = args[0]
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
499
713
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
500 if isinstance(origsource, str):
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
501 source, branch, checkout = util.parseurl(ui.expandpath(origsource),
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
502 opts.get('branch'))
915
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
503 srcrepo = getpeer(ui, opts, source)
713
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
504 else:
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
505 srcrepo = origsource
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
506
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
507 if srcrepo.capable('subversion'):
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
508 branches = opts.pop('branch', None)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
509 if branches:
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
510 data['branches'] = branches
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
511 ui.setconfig('hgsubversion', 'branch', branches[-1])
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
512
816
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 807
diff changeset
513 data['srcrepo'], data['dstrepo'] = orig(ui, *args, **opts)
701
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
514
840
88f3cda47def wrappers: clone must return hg.clone() result (issue300, issue306)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 821
diff changeset
515 return data['srcrepo'], data['dstrepo']
88f3cda47def wrappers: clone must return hg.clone() result (issue300, issue306)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 821
diff changeset
516
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
517 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
518 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
519 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
520
713
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
521 # calling hg.clone directoly to get the repository instances it returns,
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
522 # breaks in subtle ways, so we double-wrap
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
523 orighgclone = extensions.wrapfunction(hg, 'clone', hgclonewrapper)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
524 orig(ui, source, dest, **opts)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
525 hg.clone = orighgclone
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
526
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
527 # do this again; the ui instance isn't shared between the wrappers
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
528 if data.get('branches'):
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
529 ui.setconfig('hgsubversion', 'branch', data['branches'][-1])
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
530
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
531 dstrepo = data.get('dstrepo')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 705
diff changeset
532 srcrepo = data.get('srcrepo')
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
533
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
534 if dstrepo.local() and srcrepo.capable('subversion'):
915
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
535 dst = dstrepo.local()
d6c47c33f6a2 fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents: 908
diff changeset
536 fd = dst.opener("hgrc", "a", text=True)
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
537 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
538 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
539 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
540 config.pop(name, None)
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
541
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
542 if config:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
543 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
544 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
545
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
546
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
547 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
548 """
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
549 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
550 %(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
551 """
701
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
552
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
553 branch = opts.get('branch', None)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
554 if branch:
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
555 ui.setconfig('hgsubversion', 'branch', branch[-1])
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 693
diff changeset
556
402
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
557 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
558 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
559 if isinstance(repo, str):
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
560 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
561 else:
d453cf1aafa3 uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 390
diff changeset
562 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
563 return orig(ui, repo, *args, **opts)