Mercurial > hgsubversion
annotate hgsubversion/wrappers.py @ 1557:dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 24 Mar 2018 16:57:49 -0400 |
parents | cff81f35b31e |
children | ae572c9be4e6 |
rev | line source |
---|---|
1494
051a517b473b
findcommonoutgoing: adapt to change to take a repo rather than changelog
Augie Fackler <raf@durin42.com>
parents:
1376
diff
changeset
|
1 import inspect |
051a517b473b
findcommonoutgoing: adapt to change to take a repo rather than changelog
Augie Fackler <raf@durin42.com>
parents:
1376
diff
changeset
|
2 import os |
051a517b473b
findcommonoutgoing: adapt to change to take a repo rather than changelog
Augie Fackler <raf@durin42.com>
parents:
1376
diff
changeset
|
3 |
264
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
4 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
|
5 |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
6 from mercurial import cmdutil |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
7 from mercurial import discovery |
1246
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
8 try: |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
9 from mercurial import exchange |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
10 exchange.push # existed in first iteration of this file |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
11 except ImportError: |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
12 # We only *use* the exchange module in hg 3.2+, so this is safe |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
13 pass |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1551
diff
changeset
|
14 from mercurial import error as hgerror |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 from mercurial import patch |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 from mercurial import hg |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 from mercurial import util as hgutil |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 from mercurial import node |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
19 from mercurial import i18n |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
20 from mercurial import extensions |
1557
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
21 try: |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
22 # hg 4.6 and later |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
23 from mercurial import logcmdutil |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
24 logcmdutil.changesetdisplayer |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
25 except ImportError: |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
26 # hg 4.5 and earlier |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
27 logcmdutil = None |
933
a9f315eae67c
push: use native rebase instead of our rebase wrapper
David Schleimer <dschleimer@fb.com>
parents:
930
diff
changeset
|
28 from mercurial import repair |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
29 from mercurial import revset |
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
30 from mercurial import scmutil |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 |
1492 | 32 import inspect |
1004
b2d89ba6b871
layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
999
diff
changeset
|
33 import layouts |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
432
diff
changeset
|
34 import replay |
438
e8f13bd20467
pushmod: split push functions out into separate module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
435
diff
changeset
|
35 import pushmod |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 import stupid as stupidmod |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 import svnwrap |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
38 import svnrepo |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 import util |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
41 try: |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
42 from mercurial import obsolete |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
43 except ImportError: |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
44 obsolete = None |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
45 |
366
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
46 pullfuns = { |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
432
diff
changeset
|
47 True: replay.convert_rev, |
366
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
48 False: stupidmod.convert_rev, |
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
49 } |
25ebdc16b05b
Simplify pulling revs a bit, unify stupid/replay interfaces.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
356
diff
changeset
|
50 |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
51 revmeta = [ |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
52 ('revision', 'revnum'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
53 ('user', 'author'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
54 ('date', 'date'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
55 ('message', 'message'), |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
56 ] |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
57 |
507
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
58 |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
59 def version(orig, ui, *args, **opts): |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
60 svn = opts.pop('svn', None) |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
61 orig(ui, *args, **opts) |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
62 if svn: |
664
5c94a86ddd73
version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
657
diff
changeset
|
63 svnversion, bindings = svnwrap.version() |
5c94a86ddd73
version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
657
diff
changeset
|
64 ui.status('\n') |
507
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
65 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
|
66 ui.status('Subversion: %s\n' % svnversion) |
5c94a86ddd73
version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
657
diff
changeset
|
67 ui.status('bindings: %s\n' % bindings) |
507
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
68 |
4ce09bf4d382
wrappers: wrap version with a --svn flag
Augie Fackler <durin42@gmail.com>
parents:
499
diff
changeset
|
69 |
403
37c96b78b8c0
uisetup: use a single loop/abstraction for wrapping all the commands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
402
diff
changeset
|
70 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
|
71 """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
|
72 """ |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 if not opts.get('svn', False): |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 return orig(ui, repo, *args, **opts) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
75 meta = repo.svnmeta() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
76 hashes = meta.revmap.hashes() |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
77 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
|
78 if ha.node() == node.nullid: |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1551
diff
changeset
|
79 raise hgerror.Abort('No parent svn revision!') |
1557
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
80 if logcmdutil is not None: |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
81 displayer = logcmdutil.changesetdisplayer( |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
82 ui, repo, opts, buffered=False) |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
83 else: |
dd409375c261
wrappers: adapt to introduction of logcmdutil package in hg
Augie Fackler <raf@durin42.com>
parents:
1555
diff
changeset
|
84 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
|
85 displayer.show(ha) |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 return 0 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
87 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
88 |
915
d6c47c33f6a2
fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
908
diff
changeset
|
89 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
|
90 # 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
|
91 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
|
92 if peer: |
d6c47c33f6a2
fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
908
diff
changeset
|
93 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
|
94 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
|
95 |
930
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
928
diff
changeset
|
96 def getlocalpeer(ui, opts, source): |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
928
diff
changeset
|
97 peer = getpeer(ui, opts, source) |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
928
diff
changeset
|
98 repo = getattr(peer, 'local', lambda: peer)() |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
928
diff
changeset
|
99 if isinstance(repo, bool): |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
928
diff
changeset
|
100 repo = peer |
5bacb9c63e3e
Fix more peer breakage with old hg versions
Patrick Mezard <patrick@mezard.eu>
parents:
928
diff
changeset
|
101 return repo |
915
d6c47c33f6a2
fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
908
diff
changeset
|
102 |
d6c47c33f6a2
fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
908
diff
changeset
|
103 def getcaps(other): |
1519
aec176db232c
svnrepo: update with the latest upstream change
Jun Wu <quark@fb.com>
parents:
1516
diff
changeset
|
104 caps = (getattr(other, 'caps', None) or |
915
d6c47c33f6a2
fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
908
diff
changeset
|
105 getattr(other, 'capabilities', None) or set()) |
1519
aec176db232c
svnrepo: update with the latest upstream change
Jun Wu <quark@fb.com>
parents:
1516
diff
changeset
|
106 # 'capabilities' might be an instance method |
aec176db232c
svnrepo: update with the latest upstream change
Jun Wu <quark@fb.com>
parents:
1516
diff
changeset
|
107 if hgutil.safehasattr(caps, '__call__'): |
aec176db232c
svnrepo: update with the latest upstream change
Jun Wu <quark@fb.com>
parents:
1516
diff
changeset
|
108 caps = caps() |
aec176db232c
svnrepo: update with the latest upstream change
Jun Wu <quark@fb.com>
parents:
1516
diff
changeset
|
109 return caps |
915
d6c47c33f6a2
fix breakage introduced by peer classes in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
908
diff
changeset
|
110 |
771
768639283275
incoming: pass unexpanded source to wrapped function (fixes #178)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
769
diff
changeset
|
111 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
|
112 """show incoming revisions from Subversion |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
113 """ |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
114 |
771
768639283275
incoming: pass unexpanded source to wrapped function (fixes #178)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
769
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 return orig(ui, repo, origsource, **opts) |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
119 |
751
5e54e333ec3d
wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
749
diff
changeset
|
120 svn = other.svn |
5e54e333ec3d
wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
749
diff
changeset
|
121 meta = repo.svnmeta(svn.uuid, svn.subdir) |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
122 |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
123 ui.status('incoming changes from %s\n' % other.svnurl) |
1434
0a6b3da6d34c
RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents:
1426
diff
changeset
|
124 svnrevisions = list(svn.revisions(start=meta.revmap.lastpulled)) |
984
6315bdd1546e
wrappers: Implement --newest-first option in incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
983
diff
changeset
|
125 if opts.get('newest_first'): |
6315bdd1546e
wrappers: Implement --newest-first option in incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
983
diff
changeset
|
126 svnrevisions.reverse() |
985
b303b60be11e
wrappers: Return the same value as the original incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
984
diff
changeset
|
127 # Returns 0 if there are incoming changes, 1 otherwise. |
b303b60be11e
wrappers: Return the same value as the original incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
984
diff
changeset
|
128 if len(svnrevisions) > 0: |
b303b60be11e
wrappers: Return the same value as the original incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
984
diff
changeset
|
129 ret = 0 |
b303b60be11e
wrappers: Return the same value as the original incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
984
diff
changeset
|
130 else: |
b303b60be11e
wrappers: Return the same value as the original incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
984
diff
changeset
|
131 ret = 1 |
984
6315bdd1546e
wrappers: Implement --newest-first option in incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
983
diff
changeset
|
132 for r in svnrevisions: |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
133 ui.status('\n') |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
134 for label, attr in revmeta: |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
135 l1 = label + ':' |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
136 val = str(getattr(r, attr)).strip() |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
137 if not ui.verbose: |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
138 val = val.split('\n')[0] |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
139 ui.status('%s%s\n' % (l1.ljust(13), val)) |
985
b303b60be11e
wrappers: Return the same value as the original incoming command
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
984
diff
changeset
|
140 return ret |
404
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
141 |
28e4b47b2179
add a working incoming wrapper command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
403
diff
changeset
|
142 |
999
3f45bd7b60cf
bundle: add 'portable' parameter to prevent error (issue383)
Michael Connor <mconnor@fb.com>
parents:
992
diff
changeset
|
143 def findcommonoutgoing(repo, other, onlyheads=None, force=False, |
3f45bd7b60cf
bundle: add 'portable' parameter to prevent error (issue383)
Michael Connor <mconnor@fb.com>
parents:
992
diff
changeset
|
144 commoninc=None, portable=False): |
805
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
145 assert other.capable('subversion') |
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
146 # 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
|
147 svn = other.svn |
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
148 meta = repo.svnmeta(svn.uuid, svn.subdir) |
1376
717bf096197e
compat: fix some more use of repo.parents()
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
1368
diff
changeset
|
149 parent = repo[None].parents()[0].node() |
805
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
150 hashes = meta.revmap.hashes() |
845
8cf8ff0f52fe
outgoing: fix for hg change cd956049fc14
Augie Fackler <durin42@gmail.com>
parents:
841
diff
changeset
|
151 common, heads = util.outgoing_common_and_heads(repo, hashes, parent) |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
152 outobj = getattr(discovery, 'outgoing', None) |
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
153 if outobj is not None: |
1492 | 154 argspec = inspect.getargspec(outobj.__init__) |
155 if 'repo' in argspec[0]: | |
156 # Starting from Mercurial 3.9.1 outgoing.__init__ accepts | |
157 # `repo` object instead of a `changelog` | |
158 return outobj(repo, common, heads) | |
1498 | 159 # Mercurial 2.1 through 3.9 |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
160 return outobj(repo.changelog, common, heads) |
845
8cf8ff0f52fe
outgoing: fix for hg change cd956049fc14
Augie Fackler <durin42@gmail.com>
parents:
841
diff
changeset
|
161 # Mercurial 2.0 and earlier |
8cf8ff0f52fe
outgoing: fix for hg change cd956049fc14
Augie Fackler <durin42@gmail.com>
parents:
841
diff
changeset
|
162 return common, heads |
805
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
163 |
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
164 |
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
804
diff
changeset
|
165 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
|
166 """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
|
167 """ |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
168 assert dest.capable('subversion') |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
283
diff
changeset
|
169 # 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
|
170 # 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
|
171 svn = dest.svn |
5e54e333ec3d
wrappers: pass on subdir when creating obtaining svnmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
749
diff
changeset
|
172 meta = repo.svnmeta(svn.uuid, svn.subdir) |
1376
717bf096197e
compat: fix some more use of repo.parents()
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
1368
diff
changeset
|
173 parent = repo[None].parents()[0].node() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
174 hashes = meta.revmap.hashes() |
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
175 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
|
176 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
178 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
|
179 """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
|
180 """ |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
181 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
|
182 return orig(ui, repo, *args, **opts) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
183 meta = repo.svnmeta() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
184 hashes = meta.revmap.hashes() |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 if not opts.get('rev', None): |
1376
717bf096197e
compat: fix some more use of repo.parents()
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
1368
diff
changeset
|
186 parent = repo[None].parents()[0] |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
187 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
|
188 if o_r: |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 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
|
190 opts['rev'] = ['%s:.' % node.hex(parent.node()), ] |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
191 node1, node2 = scmutil.revpair(repo, opts['rev']) |
406
e360558ba65f
add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
405
diff
changeset
|
192 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
|
193 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
|
194 it = patch.diff(repo, node1, node2, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
195 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
|
196 'show_function': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
197 'ignore_all_space': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
198 'ignore_space_change': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
199 'ignore_blank_lines': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 'unified': True, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 'text': False, |
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
202 })) |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
438
diff
changeset
|
203 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
|
204 |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
205 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
|
206 """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
|
207 """ |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
329
diff
changeset
|
208 assert not revs, 'designated revisions for push remains unimplemented.' |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
209 cmdutil.bailifchanged(repo) |
783
7913a82a8cdd
Check mercurial/third-parties push conditions before pushing
Patrick Mezard <pmezard@gmail.com>
parents:
779
diff
changeset
|
210 checkpush = getattr(repo, 'checkpush', None) |
7913a82a8cdd
Check mercurial/third-parties push conditions before pushing
Patrick Mezard <pmezard@gmail.com>
parents:
779
diff
changeset
|
211 if checkpush: |
1175
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
212 try: |
1173
b04758acf410
wrappers: note which version of hg e10000369b47 is from
Augie Fackler <raf@durin42.com>
parents:
1172
diff
changeset
|
213 # The checkpush function changed as of e10000369b47 (first |
b04758acf410
wrappers: note which version of hg e10000369b47 is from
Augie Fackler <raf@durin42.com>
parents:
1172
diff
changeset
|
214 # in 3.0) in mercurial |
1175
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
215 from mercurial.exchange import pushoperation |
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
216 pushop = pushoperation(repo, dest, force, revs, False) |
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
217 checkpush(pushop) |
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
218 except (ImportError, TypeError): |
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
219 checkpush(force, revs) |
d6296f901fc7
push: update push logic to match mercurial upstream
Durham Goode <durham@fb.com>
parents:
1094
diff
changeset
|
220 |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
329
diff
changeset
|
221 ui = repo.ui |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
222 old_encoding = util.swap_out_encoding() |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
223 |
1176
97a064e2075d
push: fix obsolete feature detection
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1175
diff
changeset
|
224 try: |
1513
07c38eee3954
obsolete: support obsolete.isenabled
Durham Goode <durham@fb.com>
parents:
1504
diff
changeset
|
225 hasobsolete = (obsolete._enabled or |
07c38eee3954
obsolete: support obsolete.isenabled
Durham Goode <durham@fb.com>
parents:
1504
diff
changeset
|
226 obsolete.isenabled(repo, obsolete.createmarkersopt)) |
1176
97a064e2075d
push: fix obsolete feature detection
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1175
diff
changeset
|
227 except: |
97a064e2075d
push: fix obsolete feature detection
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1175
diff
changeset
|
228 hasobsolete = False |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
229 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
230 temporary_commits = [] |
1340
db9d85618d3d
wrapper: delay marker creation in push
Laurent Charignon <lcharignon@fb.com>
parents:
1338
diff
changeset
|
231 obsmarkers = [] |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
232 try: |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
233 # TODO: implement --rev/#rev support |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
234 # TODO: do credentials specified in the URL still work? |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
235 svn = dest.svn |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
236 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
|
237 |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
238 # Strategy: |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
239 # 1. Find all outgoing commits from this head |
1376
717bf096197e
compat: fix some more use of repo.parents()
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
1368
diff
changeset
|
240 if len(repo[None].parents()) != 1: |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
241 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
|
242 return 0 # results in nonzero exit status, see hg's commands.py |
1368
4f8b1f202c90
compat: fix use of repo.parents() to repo[None].parents()
Laurent Charignon <lcharignon@fb.com>
parents:
1361
diff
changeset
|
243 workingrev = repo[None].parents()[0] |
1236
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
244 workingbranch = workingrev.branch() |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
245 ui.status('searching for changes\n') |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
246 hashes = meta.revmap.hashes() |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
247 outgoing = util.outgoing_revisions(repo, hashes, workingrev.node()) |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
248 if not (outgoing and len(outgoing)): |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
249 ui.status('no changes found\n') |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
250 return 1 # so we get a sane exit status, see hg's commands.push |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
251 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
252 tip_ctx = repo[outgoing[-1]].p1() |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
253 svnbranch = tip_ctx.branch() |
991
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
254 modified_files = {} |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
255 for i in range(len(outgoing) - 1, -1, -1): |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
256 # 2. Pick the oldest changeset that needs to be pushed |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
257 current_ctx = repo[outgoing[i]] |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
258 original_ctx = current_ctx |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
259 |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
260 if len(current_ctx.parents()) != 1: |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
261 ui.status('Found a branch merge, this needs discussion and ' |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
262 'implementation.\n') |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
263 # results in nonzero exit status, see hg's commands.py |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
264 return 0 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
265 |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
266 # 3. Move the changeset to the tip of the branch if necessary |
991
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
267 conflicts = False |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
268 for file in current_ctx.files(): |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
269 if file in modified_files: |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
270 conflicts = True |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
271 break |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
272 |
991
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
273 if conflicts or current_ctx.branch() != svnbranch: |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
274 util.swap_out_encoding(old_encoding) |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
275 try: |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
276 def extrafn(ctx, extra): |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
277 extra['branch'] = ctx.branch() |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
278 |
1050
fb0715c9347d
decrease verbosity somewhat
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
279 ui.note('rebasing %s onto %s \n' % (current_ctx, tip_ctx)) |
991
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
280 hgrebase.rebase(ui, repo, |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
281 dest=node.hex(tip_ctx.node()), |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
282 rev=[node.hex(current_ctx.node())], |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
283 extrafn=extrafn, keep=True) |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
284 finally: |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
285 util.swap_out_encoding() |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
286 |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
287 # Don't trust the pre-rebase repo and context. |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
288 repo = getlocalpeer(ui, {}, meta.path) |
1293
9e85feb93984
wrappers: improve push performance by reusing the existing metadata
Mateusz Kwapich <mitrandir@fb.com>
parents:
1286
diff
changeset
|
289 meta = repo.svnmeta(svn.uuid, svn.subdir) |
9e85feb93984
wrappers: improve push performance by reusing the existing metadata
Mateusz Kwapich <mitrandir@fb.com>
parents:
1286
diff
changeset
|
290 hashes = meta.revmap.hashes() |
991
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
291 tip_ctx = repo[tip_ctx.node()] |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
292 for c in tip_ctx.descendants(): |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
293 rebasesrc = c.extra().get('rebase_source') |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
294 if rebasesrc and node.bin(rebasesrc) == current_ctx.node(): |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
295 current_ctx = c |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
296 temporary_commits.append(c.node()) |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
297 break |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
298 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
299 # 4. Push the changeset to subversion |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
300 tip_hash = hashes[tip_ctx.node()][0] |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
301 try: |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
302 ui.status('committing %s\n' % current_ctx) |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
303 pushedrev = pushmod.commit(ui, repo, current_ctx, meta, |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
304 tip_hash, svn) |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
305 except pushmod.NoFilesException: |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
306 ui.warn("Could not push revision %s because it had no changes " |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
307 "in svn.\n" % current_ctx) |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
308 return |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
309 |
1236
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
310 # This hook is here purely for testing. It allows us to |
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
311 # onsistently trigger hit the race condition between |
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
312 # pushing and pulling here. In particular, we use it to |
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
313 # trigger another revision landing between the time we |
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
314 # push a revision and pull it back. |
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
315 repo.hook('debug-hgsubversion-between-push-and-pull-for-tests') |
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
316 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
317 # 5. Pull the latest changesets from subversion, which will |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
318 # include the one we just committed (and possibly others). |
1293
9e85feb93984
wrappers: improve push performance by reusing the existing metadata
Mateusz Kwapich <mitrandir@fb.com>
parents:
1286
diff
changeset
|
319 r = pull(repo, dest, force=force, meta=meta) |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
320 assert not r or r == 0 |
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
321 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
322 # 6. Move our tip to the latest pulled tip |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
323 for c in tip_ctx.descendants(): |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
324 if c.node() in hashes and c.branch() == svnbranch: |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
325 if meta.get_source_rev(ctx=c)[0] == pushedrev.revnum: |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
326 # This is corresponds to the changeset we just pushed |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
327 if hasobsolete: |
1340
db9d85618d3d
wrapper: delay marker creation in push
Laurent Charignon <lcharignon@fb.com>
parents:
1338
diff
changeset
|
328 obsmarkers.append([(original_ctx, [c])]) |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
329 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
330 tip_ctx = c |
933
a9f315eae67c
push: use native rebase instead of our rebase wrapper
David Schleimer <dschleimer@fb.com>
parents:
930
diff
changeset
|
331 |
991
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
332 # Remember what files have been modified since the |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
333 # whole push started. |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
334 for file in c.files(): |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
335 modified_files[file] = True |
26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
Durham Goode <durham@fb.com>
parents:
990
diff
changeset
|
336 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
337 # 7. Rebase any children of the commit we just pushed |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
338 # that are not in the outgoing set |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
339 for c in original_ctx.children(): |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
340 if not c.node() in hashes and not c.node() in outgoing: |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
341 util.swap_out_encoding(old_encoding) |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
342 try: |
992
110794582448
push: avoid failure when push is being called from a newly created subdirectory
Kapil Bajaj <kapilbajaj@fb.com>
parents:
991
diff
changeset
|
343 # Path changed as subdirectories were getting |
110794582448
push: avoid failure when push is being called from a newly created subdirectory
Kapil Bajaj <kapilbajaj@fb.com>
parents:
991
diff
changeset
|
344 # deleted during push. |
110794582448
push: avoid failure when push is being called from a newly created subdirectory
Kapil Bajaj <kapilbajaj@fb.com>
parents:
991
diff
changeset
|
345 saved_path = os.getcwd() |
110794582448
push: avoid failure when push is being called from a newly created subdirectory
Kapil Bajaj <kapilbajaj@fb.com>
parents:
991
diff
changeset
|
346 os.chdir(repo.root) |
110794582448
push: avoid failure when push is being called from a newly created subdirectory
Kapil Bajaj <kapilbajaj@fb.com>
parents:
991
diff
changeset
|
347 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
348 def extrafn(ctx, extra): |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
349 extra['branch'] = ctx.branch() |
933
a9f315eae67c
push: use native rebase instead of our rebase wrapper
David Schleimer <dschleimer@fb.com>
parents:
930
diff
changeset
|
350 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
351 ui.status('rebasing non-outgoing %s onto %s\n' % (c, tip_ctx)) |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
352 needs_rebase_set = "%s::" % node.hex(c.node()) |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
353 hgrebase.rebase(ui, repo, |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
354 dest=node.hex(tip_ctx.node()), |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
355 rev=[needs_rebase_set], |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
356 extrafn=extrafn, |
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
357 keep=not hasobsolete) |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
358 finally: |
992
110794582448
push: avoid failure when push is being called from a newly created subdirectory
Kapil Bajaj <kapilbajaj@fb.com>
parents:
991
diff
changeset
|
359 os.chdir(saved_path) |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
360 util.swap_out_encoding() |
933
a9f315eae67c
push: use native rebase instead of our rebase wrapper
David Schleimer <dschleimer@fb.com>
parents:
930
diff
changeset
|
361 |
a9f315eae67c
push: use native rebase instead of our rebase wrapper
David Schleimer <dschleimer@fb.com>
parents:
930
diff
changeset
|
362 |
946
289f2c7752a8
push: reset encoding before the final update
Patrick Mezard <patrick@mezard.eu>
parents:
933
diff
changeset
|
363 util.swap_out_encoding(old_encoding) |
289f2c7752a8
push: reset encoding before the final update
Patrick Mezard <patrick@mezard.eu>
parents:
933
diff
changeset
|
364 try: |
1236
f367a4462191
push: update to branch tip instead of tip
David Schleimer <dschleimer@fb.com>
parents:
1184
diff
changeset
|
365 hg.update(repo, repo.branchtip(workingbranch)) |
946
289f2c7752a8
push: reset encoding before the final update
Patrick Mezard <patrick@mezard.eu>
parents:
933
diff
changeset
|
366 finally: |
289f2c7752a8
push: reset encoding before the final update
Patrick Mezard <patrick@mezard.eu>
parents:
933
diff
changeset
|
367 util.swap_out_encoding() |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
368 |
1533
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
369 with repo.wlock(): |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
370 with repo.lock(): |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
371 if hasobsolete: |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
372 for marker in obsmarkers: |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
373 obsolete.createmarkers(repo, marker) |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
374 beforepush = marker[0][0] |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
375 afterpush = marker[0][1][0] |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
376 ui.note('marking %s as obsoleted by %s\n' % |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
377 (beforepush.hex(), afterpush.hex())) |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
378 else: |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
379 # strip the original changesets since the push was |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
380 # successful and changeset obsolescence is unavailable |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
381 util.strip(ui, repo, outgoing, "all") |
926
c4001eecfdb1
wrappers: properly reset encoding when leaving push()
Patrick Mezard <patrick@mezard.eu>
parents:
925
diff
changeset
|
382 finally: |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
383 try: |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
384 # It's always safe to delete the temporary commits. |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
385 # The originals are not deleted unless the push |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
386 # completely succeeded. |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
387 if temporary_commits: |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
388 # If the repo is on a temporary commit, get off before |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
389 # the strip. |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
390 parent = repo[None].p1() |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
391 if parent.node() in temporary_commits: |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
392 hg.update(repo, parent.p1().node()) |
1533
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
393 with repo.wlock(): |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
394 with repo.lock(): |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
395 if hasobsolete: |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
396 relations = ( |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
397 (repo[n], ()) for n in temporary_commits) |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
398 obsolete.createmarkers(repo, relations) |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
399 else: |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
400 util.strip( |
0212c3a84ccd
wrappers: add some missing lock/wlock grabbing
Augie Fackler <raf@durin42.com>
parents:
1519
diff
changeset
|
401 ui, repo, temporary_commits, backup=None) |
1055
2d7398fffd0d
push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1050
diff
changeset
|
402 |
990
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
403 finally: |
def2144c0a8c
push: rebase one at a time before push
Durham Goode <durham@fb.com>
parents:
986
diff
changeset
|
404 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
|
405 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
|
406 |
1246
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
407 def exchangepush(orig, repo, remote, force=False, revs=None, newbranch=False, |
1361
d227cf8d0860
exchangepush: accept kwargs and just forward them
Sean Farley <sean@farley.io>
parents:
1360
diff
changeset
|
408 bookmarks=(), **kwargs): |
1246
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
409 capable = getattr(remote, 'capable', lambda x: False) |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
410 if capable('subversion'): |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
411 pushop = exchange.pushoperation(repo, remote, force, revs, newbranch, |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
412 bookmarks=bookmarks) |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
413 pushop.cgresult = push(repo, remote, force, revs) |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
414 return pushop |
2179747e7fea
push: wrap exchange.push when localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1236
diff
changeset
|
415 else: |
1361
d227cf8d0860
exchangepush: accept kwargs and just forward them
Sean Farley <sean@farley.io>
parents:
1360
diff
changeset
|
416 return orig(repo, remote, force, revs, newbranch, bookmarks=bookmarks, |
d227cf8d0860
exchangepush: accept kwargs and just forward them
Sean Farley <sean@farley.io>
parents:
1360
diff
changeset
|
417 **kwargs) |
257
ffccf0080e54
Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 |
1293
9e85feb93984
wrappers: improve push performance by reusing the existing metadata
Mateusz Kwapich <mitrandir@fb.com>
parents:
1286
diff
changeset
|
419 def pull(repo, source, heads=[], force=False, meta=None): |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
346
diff
changeset
|
420 """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
|
421 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
|
422 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
|
423 |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
341
diff
changeset
|
424 # 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
|
425 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
|
426 old_encoding = util.swap_out_encoding() |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
427 total = 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
|
428 try: |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
429 have_replay = not repo.ui.configbool('hgsubversion', 'stupid') |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
430 if not have_replay: |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
431 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
|
432 |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
433 svn = source.svn |
1293
9e85feb93984
wrappers: improve push performance by reusing the existing metadata
Mateusz Kwapich <mitrandir@fb.com>
parents:
1286
diff
changeset
|
434 if meta is None: |
9e85feb93984
wrappers: improve push performance by reusing the existing metadata
Mateusz Kwapich <mitrandir@fb.com>
parents:
1286
diff
changeset
|
435 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
|
436 |
974
336f4bce479a
consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
437 stopat_rev = util.parse_revnum(svn, checkout) |
336f4bce479a
consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
438 |
1302
0326686199f5
wrappers: use meta.layout instead of accessing config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1300
diff
changeset
|
439 if meta.layout == 'auto': |
0326686199f5
wrappers: use meta.layout instead of accessing config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1300
diff
changeset
|
440 meta.layout = meta.layout_from_subversion(svn, (stopat_rev or None)) |
0326686199f5
wrappers: use meta.layout instead of accessing config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1300
diff
changeset
|
441 repo.ui.note('using %s layout\n' % meta.layout) |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
442 |
1297
fc48e1065926
wrappers: use meta.branch instead of ui.config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1293
diff
changeset
|
443 if meta.branch: |
1302
0326686199f5
wrappers: use meta.layout instead of accessing config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1300
diff
changeset
|
444 if meta.layout != 'single': |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
445 msg = ('branch cannot be specified for Subversion clones using ' |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
446 'standard directory layout') |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1551
diff
changeset
|
447 raise hgerror.Abort(msg) |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
448 |
1297
fc48e1065926
wrappers: use meta.branch instead of ui.config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1293
diff
changeset
|
449 meta.branchmap['default'] = meta.branch |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
450 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
451 ui = repo.ui |
1434
0a6b3da6d34c
RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents:
1426
diff
changeset
|
452 start = meta.revmap.lastpulled |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
453 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
454 if start <= 0: |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
455 # we are initializing a new repository |
974
336f4bce479a
consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
456 start = util.parse_revnum(svn, repo.ui.config('hgsubversion', |
336f4bce479a
consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
457 'startrev', 0)) |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
458 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
459 if start > 0: |
1302
0326686199f5
wrappers: use meta.layout instead of accessing config directly
Sean Farley <sean.michael.farley@gmail.com>
parents:
1300
diff
changeset
|
460 if meta.layout == 'standard': |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1551
diff
changeset
|
461 raise hgerror.Abort('non-zero start revisions are only ' |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
462 'supported for single-directory clones.') |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
463 ui.note('starting at revision %d; any prior will be ignored\n' |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
464 % start) |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
465 # fetch all revisions *including* the one specified... |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
466 start -= 1 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
467 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
468 # anything less than zero makes no sense |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
469 if start < 0: |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
470 start = 0 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
471 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
472 skiprevs = repo.ui.configlist('hgsubversion', 'unsafeskip', '') |
974
336f4bce479a
consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
473 skiprevs = set(util.parse_revnum(svn, r) for r in skiprevs) |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
474 |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
475 oldrevisions = len(meta.revmap) |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
476 if stopat_rev: |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
477 total = stopat_rev - start |
651
827547493112
clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
647
diff
changeset
|
478 else: |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
479 total = svn.HEAD - start |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
480 lastpulled = None |
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
481 |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
482 try: |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
483 # start converting revisions |
787
4bbc6bf947f5
replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents:
783
diff
changeset
|
484 firstrun = True |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
485 for r in svn.revisions(start=start, stop=stopat_rev): |
980
641d0c41d1ea
pull: use a single if-statement for the two ways to skip revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
486 if (r.revnum in skiprevs or |
641d0c41d1ea
pull: use a single if-statement for the two ways to skip revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
487 (r.author is None and |
641d0c41d1ea
pull: use a single if-statement for the two ways to skip revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
946
diff
changeset
|
488 r.message == 'This is an empty revision for padding.')): |
981
82bbb3428684
pull: save the last pulled revision *after* converting revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
980
diff
changeset
|
489 lastpulled = r.revnum |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
490 continue |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
491 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
|
492 # got a 502? Try more than once! |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
493 tries = 0 |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
494 converted = False |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
495 while not converted: |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
496 try: |
1286
8cec74df235a
wrappers: call meta.getmessage instead of util
Sean Farley <sean.michael.farley@gmail.com>
parents:
1280
diff
changeset
|
497 msg = meta.getmessage(r).strip() |
1045
67e11b650e94
handle invalid UTF-8 in commit messages consistently
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1040
diff
changeset
|
498 if msg: |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
499 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
|
500 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
|
501 w = ui.termwidth() |
ec52205e5ed1
pull: handle change in termwidth() api from hg change c52c629ce19e
Augie Fackler <durin42@gmail.com>
parents:
748
diff
changeset
|
502 else: |
ec52205e5ed1
pull: handle change in termwidth() api from hg change c52c629ce19e
Augie Fackler <durin42@gmail.com>
parents:
748
diff
changeset
|
503 w = hgutil.termwidth() |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
504 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
|
505 ui.status(('[r%d] %s: %s' % bits)[:w] + '\n') |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
506 ui.progress('pull', r.revnum - start, total=total) |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
507 |
444
8c545dcad7b1
wrappers: save tbdelta in one place for both stupid and replay
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
440
diff
changeset
|
508 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
|
509 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
|
510 firstrun) |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
507
diff
changeset
|
511 meta.committags(r, close) |
432
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
512 for branch, parent in close.iteritems(): |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
513 if parent in (None, node.nullid): |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
514 continue |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
515 meta.delbranch(branch, parent, r) |
4bf90f8c9b7b
consolidate metadata calls from stupid and replay code
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
516 |
418
92beeefeaf93
save metadata from one place
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
517 meta.save() |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
518 converted = True |
787
4bbc6bf947f5
replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents:
783
diff
changeset
|
519 firstrun = False |
431
612b8d753549
inline describe_revision(), use custom termwidth
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
419
diff
changeset
|
520 |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
821
diff
changeset
|
521 except svnwrap.SubversionRepoCanNotReplay, e: # pragma: no cover |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
522 ui.status('%s\n' % e.message) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
523 stupidmod.print_your_svn_is_old_message(ui) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
524 have_replay = False |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
821
diff
changeset
|
525 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
|
526 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
|
527 and '502' in str(e) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
528 and tries < 3): |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
529 tries += 1 |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
530 ui.status('Got a 502, retrying (%s)\n' % tries) |
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
531 else: |
705
385213d2e2da
pull: reveal the handled SubversionException to --traceback.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
701
diff
changeset
|
532 ui.traceback() |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1551
diff
changeset
|
533 raise hgerror.Abort(*e.args) |
981
82bbb3428684
pull: save the last pulled revision *after* converting revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
980
diff
changeset
|
534 |
82bbb3428684
pull: save the last pulled revision *after* converting revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
980
diff
changeset
|
535 lastpulled = r.revnum |
82bbb3428684
pull: save the last pulled revision *after* converting revisions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
980
diff
changeset
|
536 |
390
afe93f14a361
wrappers: Python 2.4 compat.
Augie Fackler <durin42@gmail.com>
parents:
367
diff
changeset
|
537 except KeyboardInterrupt: |
895
5b9f17e34126
don't suppress KeyboardInterrupt exception tracebacks
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
876
diff
changeset
|
538 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
|
539 finally: |
927
3271fa883f34
wrappers: ensure all pull() code path reset the encoding
Patrick Mezard <patrick@mezard.eu>
parents:
926
diff
changeset
|
540 if total is not None: |
1039
3df6ed4e7561
drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1005
diff
changeset
|
541 ui.progress('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
|
542 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
|
543 |
821
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
819
diff
changeset
|
544 if lastpulled is not None: |
1434
0a6b3da6d34c
RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents:
1426
diff
changeset
|
545 meta.revmap.lastpulled = lastpulled |
523
fa7aab230f1d
wrappers: calculate and return exact count of changesets added.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
520
diff
changeset
|
546 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
|
547 |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
548 if revisions == 0: |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
549 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
|
550 return 0 |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
551 else: |
341
cfbd0e563af9
wrappers: remove unused clone() function.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
552 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
|
553 |
1336
f97b8c333c9e
wrappers: accept-and-forward oparg pull argument
Augie Fackler <raf@durin42.com>
parents:
1319
diff
changeset
|
554 def exchangepull(orig, repo, remote, heads=None, force=False, bookmarks=(), |
1360
129f4ad088c2
wrappers: accept-and-forward kwargs including opargs
Sean Farley <sean@farley.io>
parents:
1336
diff
changeset
|
555 **kwargs): |
1247
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
556 capable = getattr(remote, 'capable', lambda x: False) |
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
557 if capable('subversion'): |
1279
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
558 # transaction manager is present in Mercurial >= 3.3 |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
559 try: |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
560 trmanager = getattr(exchange, 'transactionmanager') |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
561 except AttributeError: |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
562 trmanager = None |
1247
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
563 pullop = exchange.pulloperation(repo, remote, heads, force, |
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
564 bookmarks=bookmarks) |
1279
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
565 if trmanager: |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
566 pullop.trmanager = trmanager(repo, 'pull', remote.url()) |
1247
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
567 try: |
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
568 pullop.cgresult = pull(repo, remote, heads, force) |
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
569 return pullop |
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
570 finally: |
1279
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
571 if trmanager: |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
572 pullop.trmanager.release() |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
573 else: |
b5520673f6f2
pull: adapt from upstream changes to transactions
Sean Farley <sean.michael.farley@gmail.com>
parents:
1248
diff
changeset
|
574 pullop.releasetransaction() |
1247
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
575 else: |
1360
129f4ad088c2
wrappers: accept-and-forward kwargs including opargs
Sean Farley <sean@farley.io>
parents:
1336
diff
changeset
|
576 return orig(repo, remote, heads, force, bookmarks=bookmarks, **kwargs) |
1247
3a4d74823187
pull: wrap exchange.pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
1246
diff
changeset
|
577 |
264
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
578 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
|
579 """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
|
580 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
581 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
|
582 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
|
583 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
|
584 '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
|
585 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
586 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
|
587 """ |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
588 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
|
589 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
|
590 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
|
591 """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
|
592 """ |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
593 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
|
594 extrafn = opts.get('svnextrafn', extrafn2) |
1376
717bf096197e
compat: fix some more use of repo.parents()
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents:
1368
diff
changeset
|
595 sourcerev = opts.get('svnsourcerev', repo[None].parents()[0].node()) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
463
diff
changeset
|
596 meta = repo.svnmeta() |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
597 hashes = meta.revmap.hashes() |
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
415
diff
changeset
|
598 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
|
599 if not o_r: |
1050
fb0715c9347d
decrease verbosity somewhat
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
600 ui.note('nothing to rebase\n') |
264
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
601 return 0 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
602 if len(repo[sourcerev].children()): |
1050
fb0715c9347d
decrease verbosity somewhat
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
603 ui.status('refusing to rebase non-head commit like a coward\n') |
264
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
604 return 0 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
605 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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 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
|
611 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
|
612 n = c.node() |
406
e360558ba65f
add a function to generate svn_commit_hashes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
405
diff
changeset
|
613 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
|
614 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
|
615 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
|
616 break |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
617 if parent_rev == target_rev: |
1050
fb0715c9347d
decrease verbosity somewhat
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1045
diff
changeset
|
618 ui.status('already up to date!\n') |
264
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
619 return 0 |
112d57bb736e
rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents:
263
diff
changeset
|
620 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
|
621 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
|
622 extrafn=extrafn) |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
623 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
624 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
625 optionmap = { |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
626 'tagpaths': ('hgsubversion', 'tagpaths'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
627 'authors': ('hgsubversion', 'authormap'), |
1374
a17d8874a099
Added dynamic author mapping.
Jerome M. BERGER <jeberger@free.fr>
parents:
1372
diff
changeset
|
628 'mapauthorscmd': ('hgsubversion', 'mapauthorscmd'), |
1093
791382a21cc4
layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents:
1092
diff
changeset
|
629 'branchdir': ('hgsubversion', 'branchdir'), |
1319
43a365f5d13c
Allow changing the path to the trunk
Francois Dinel <fdinel@gmail.com>
parents:
1302
diff
changeset
|
630 'trunkdir': ('hgsubversion', 'trunkdir'), |
1094
9a7e3dbd0f6e
layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents:
1093
diff
changeset
|
631 'infix': ('hgsubversion', 'infix'), |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
632 'filemap': ('hgsubversion', 'filemap'), |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
561
diff
changeset
|
633 'branchmap': ('hgsubversion', 'branchmap'), |
729 | 634 'tagmap': ('hgsubversion', 'tagmap'), |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
635 'stupid': ('hgsubversion', 'stupid'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
636 'defaulthost': ('hgsubversion', 'defaulthost'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
637 'defaultauthors': ('hgsubversion', 'defaultauthors'), |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
638 'usebranchnames': ('hgsubversion', 'usebranchnames'), |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
466
diff
changeset
|
639 'layout': ('hgsubversion', 'layout'), |
651
827547493112
clone: allow specifying a start revision.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
647
diff
changeset
|
640 'startrev': ('hgsubversion', 'startrev'), |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
641 } |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
642 |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
643 extrasections = set(['hgsubversionbranch']) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
644 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
645 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
646 dontretain = { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
647 'hgsubversion': set(['authormap', 'filemap', 'layout', ]), |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
648 'hgsubversionbranch': set(), |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
649 } |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
650 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
651 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
|
652 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
653 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
|
654 %(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
|
655 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
|
656 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
657 |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
658 data = {} |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
807
diff
changeset
|
659 def hgclonewrapper(orig, ui, *args, **opts): |
1121
7a4d8525737a
wrappers: remove pre-1.9 code from hgclonewrapper
Sean Farley <sean.michael.farley@gmail.com>
parents:
1120
diff
changeset
|
660 origsource = args[1] |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
807
diff
changeset
|
661 |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
662 if isinstance(origsource, str): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
663 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
|
664 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
|
665 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
|
666 else: |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
667 srcrepo = origsource |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
668 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
669 if srcrepo.capable('subversion'): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
670 branches = opts.pop('branch', None) |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
671 if branches: |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
672 data['branches'] = branches |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
673 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
|
674 |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
807
diff
changeset
|
675 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
|
676 |
840
88f3cda47def
wrappers: clone must return hg.clone() result (issue300, issue306)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
821
diff
changeset
|
677 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
|
678 |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
679 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
|
680 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
|
681 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
|
682 |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
683 # 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
|
684 # breaks in subtle ways, so we double-wrap |
1504
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
685 orighgclone = None |
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
686 try: |
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
687 orighgclone = extensions.wrapfunction(hg, 'clone', hgclonewrapper) |
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
688 orig(ui, source, dest, **opts) |
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
689 finally: |
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
690 if orighgclone: |
e65d6f6897f4
clone: add try/finally to unwrap
Durham Goode <durham@fb.com>
parents:
1503
diff
changeset
|
691 hg.clone = orighgclone |
713
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
692 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
693 # 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
|
694 if data.get('branches'): |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
695 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
|
696 |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
697 dstrepo = data.get('dstrepo') |
69c0e7c4faf9
clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
705
diff
changeset
|
698 srcrepo = data.get('srcrepo') |
1120
8a734c3e9b8d
wrappers: remove pre-1.9 code from clone
Sean Farley <sean.michael.farley@gmail.com>
parents:
1094
diff
changeset
|
699 dst = dstrepo.local() |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
700 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
701 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
|
702 dst = dstrepo.local() |
1551
22137e94411f
wrappers: cope with removal of text= kwarg on vfs
Augie Fackler <raf@durin42.com>
parents:
1533
diff
changeset
|
703 try: |
22137e94411f
wrappers: cope with removal of text= kwarg on vfs
Augie Fackler <raf@durin42.com>
parents:
1533
diff
changeset
|
704 # hg before 4.5 requires text=True here |
22137e94411f
wrappers: cope with removal of text= kwarg on vfs
Augie Fackler <raf@durin42.com>
parents:
1533
diff
changeset
|
705 fd = dst.vfs("hgrc", "a", text=True) |
22137e94411f
wrappers: cope with removal of text= kwarg on vfs
Augie Fackler <raf@durin42.com>
parents:
1533
diff
changeset
|
706 except TypeError: |
22137e94411f
wrappers: cope with removal of text= kwarg on vfs
Augie Fackler <raf@durin42.com>
parents:
1533
diff
changeset
|
707 fd = dst.vfs("hgrc", "a") |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
708 preservesections = set(s for s, v in optionmap.itervalues()) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
709 preservesections |= extrasections |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1055
diff
changeset
|
710 for section in preservesections: |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
711 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
|
712 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
|
713 config.pop(name, None) |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
714 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
715 if config: |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
716 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
|
717 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
|
718 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
719 |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
720 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
|
721 """ |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
722 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
|
723 %(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
|
724 """ |
701
3b8088de027d
clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
693
diff
changeset
|
725 |
3b8088de027d
clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
693
diff
changeset
|
726 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
|
727 if branch: |
3b8088de027d
clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
693
diff
changeset
|
728 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
|
729 |
402
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
730 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
|
731 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
|
732 if isinstance(repo, str): |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
733 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
|
734 else: |
d453cf1aafa3
uisetup: move clone and push/pull wrappers to wrappers module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
390
diff
changeset
|
735 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
|
736 return orig(ui, repo, *args, **opts) |