Mercurial > public > mercurial-scm > hg
annotate hgext/fetch.py @ 14076:924c82157d46
url: move URL parsing functions into util to improve startup time
The introduction of the new URL parsing code has created a startup
time regression. This is mainly due to the use of url.hasscheme() in
the ui class. It ends up importing many libraries that the url module
requires.
This fix helps marginally, but if we can get rid of the urllib import
in the URL parser all together, startup time will go back to normal.
perfstartup time before the URL refactoring (8796fb6af67e):
! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
current startup time (139fb11210bb):
! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
after this change:
! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Sat, 30 Apr 2011 09:43:20 -0700 |
parents | b885f28fa4fa |
children | 517e1d88bf7e |
rev | line source |
---|---|
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
1 # fetch.py - pull and merge remote changes |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
2 # |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8188
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
8228
eee2319c5895
add blank line after copyright notices and after header
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
7 |
8894
868670dbc237
extensions: improve the consistency of synopses
C?dric Duval <cedricduval@free.fr>
parents:
8706
diff
changeset
|
8 '''pull, update and merge in one command''' |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
9 |
3891 | 10 from mercurial.i18n import _ |
6211
f89fd07fc51d
Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents:
6207
diff
changeset
|
11 from mercurial.node import nullid, short |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
12711
diff
changeset
|
12 from mercurial import commands, cmdutil, hg, util, error |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
7991
diff
changeset
|
13 from mercurial.lock import release |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
14 |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
15 def fetch(ui, repo, source='default', **opts): |
7598 | 16 '''pull changes from a remote repository, merge new changes if needed. |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
17 |
9258
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
18 This finds all changes from the repository at the specified path |
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
19 or URL and adds them to the local repository. |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
20 |
9258
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
21 If the pulled changes add a new branch head, the head is |
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
22 automatically merged, and the result of the merge is committed. |
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
23 Otherwise, the working directory is updated to include the new |
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
24 changes. |
6206
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
25 |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
26 When a merge occurs, the newly pulled changes are assumed to be |
9258
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
27 "authoritative". The head of the new changes is used as the first |
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
28 parent, with local changes as the second. To switch the merge |
1aeb22492b25
fetch: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents:
9219
diff
changeset
|
29 order, use --switch-parent. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6139
diff
changeset
|
30 |
10973
49a07f441496
Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents:
10580
diff
changeset
|
31 See :hg:`help dates` for a list of formats valid for -d/--date. |
12711
b885f28fa4fa
fetch: fix and document exit codes (issue2356)
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
32 |
b885f28fa4fa
fetch: fix and document exit codes (issue2356)
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
33 Returns 0 on success. |
6163
1f733c2f0165
Document log date ranges and mention 'hg help dates' for all commands (issue998)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6139
diff
changeset
|
34 ''' |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
35 |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
36 date = opts.get('date') |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
37 if date: |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
38 opts['date'] = util.parsedate(date) |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
39 |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
40 parent, p2 = repo.dirstate.parents() |
7049
6489ee64b522
fetch: use dirstate branch instead of first parents
Sune Foldager <cryo@cyanite.org>
parents:
7007
diff
changeset
|
41 branch = repo.dirstate.branch() |
6489ee64b522
fetch: use dirstate branch instead of first parents
Sune Foldager <cryo@cyanite.org>
parents:
7007
diff
changeset
|
42 branchnode = repo.branchtags().get(branch) |
6489ee64b522
fetch: use dirstate branch instead of first parents
Sune Foldager <cryo@cyanite.org>
parents:
7007
diff
changeset
|
43 if parent != branchnode: |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
44 raise util.Abort(_('working dir not at branch tip ' |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
45 '(use "hg update" to check out branch tip)')) |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
46 |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
47 if p2 != nullid: |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
48 raise util.Abort(_('outstanding uncommitted merge')) |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
49 |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
50 wlock = lock = None |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
51 try: |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
52 wlock = repo.wlock() |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
53 lock = repo.lock() |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
54 mod, add, rem, del_ = repo.status()[:4] |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
55 |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
56 if mod or add or rem: |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
57 raise util.Abort(_('outstanding uncommitted changes')) |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
58 if del_: |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
59 raise util.Abort(_('working directory is missing some files')) |
7854
423b4482c5cb
fetch: do not count inactive branches when inferring a merge
Benjamin Pollack <benjamin@bitquabit.com>
parents:
7598
diff
changeset
|
60 bheads = repo.branchheads(branch) |
423b4482c5cb
fetch: do not count inactive branches when inferring a merge
Benjamin Pollack <benjamin@bitquabit.com>
parents:
7598
diff
changeset
|
61 bheads = [head for head in bheads if len(repo[head].children()) == 0] |
423b4482c5cb
fetch: do not count inactive branches when inferring a merge
Benjamin Pollack <benjamin@bitquabit.com>
parents:
7598
diff
changeset
|
62 if len(bheads) > 1: |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
63 raise util.Abort(_('multiple heads in this branch ' |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
64 '(use "hg heads ." and "hg merge" to merge)')) |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
65 |
11273
d1908cb95a82
remoteui: move from cmdutil to hg
Matt Mackall <mpm@selenic.com>
parents:
10973
diff
changeset
|
66 other = hg.repository(hg.remoteui(repo, opts), |
8188 | 67 ui.expandpath(source)) |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
68 ui.status(_('pulling from %s\n') % |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
12711
diff
changeset
|
69 util.hidepassword(ui.expandpath(source))) |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
70 revs = None |
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
71 if opts['rev']: |
8532
b97e2417ae53
fetch: allow -r for remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8407
diff
changeset
|
72 try: |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
73 revs = [other.lookup(rev) for rev in opts['rev']] |
8532
b97e2417ae53
fetch: allow -r for remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8407
diff
changeset
|
74 except error.CapabilityError: |
b97e2417ae53
fetch: allow -r for remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8407
diff
changeset
|
75 err = _("Other repository doesn't support revision lookup, " |
b97e2417ae53
fetch: allow -r for remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8407
diff
changeset
|
76 "so a rev cannot be specified.") |
b97e2417ae53
fetch: allow -r for remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8407
diff
changeset
|
77 raise util.Abort(err) |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
78 |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
79 # Are there any changes at all? |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
80 modheads = repo.pull(other, heads=revs) |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
81 if modheads == 0: |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
82 return 0 |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
83 |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
84 # Is this a simple fast-forward along the current branch? |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
85 newheads = repo.branchheads(branch) |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
86 newchildren = repo.changelog.nodesbetween([parent], newheads)[2] |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
87 if len(newheads) == 1: |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
88 if newchildren[0] != parent: |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
89 return hg.clean(repo, newchildren[0]) |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
90 else: |
12711
b885f28fa4fa
fetch: fix and document exit codes (issue2356)
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
91 return 0 |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
92 |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
93 # Are there more than one additional branch heads? |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
94 newchildren = [n for n in newchildren if n != parent] |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
95 newparent = parent |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
96 if newchildren: |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
97 newparent = newchildren[0] |
4917
126f527b3ba3
Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents:
4915
diff
changeset
|
98 hg.clean(repo, newparent) |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
99 newheads = [n for n in newheads if n != newparent] |
6206
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
100 if len(newheads) > 1: |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
101 ui.status(_('not merging with %d other new branch heads ' |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
102 '(use "hg heads ." and "hg merge" to merge them)\n') % |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
103 (len(newheads) - 1)) |
12711
b885f28fa4fa
fetch: fix and document exit codes (issue2356)
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
104 return 1 |
7007
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
105 |
a6b74fbb5ce0
fetch: added support for named branches
Sune Foldager <cryo@cyanite.org>
parents:
6941
diff
changeset
|
106 # Otherwise, let's merge. |
6206
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
107 err = False |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
108 if newheads: |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
109 # By default, we consider the repository we're pulling |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
110 # *from* as authoritative, so we merge our changes into |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
111 # theirs. |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
112 if opts['switch_parent']: |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
113 firstparent, secondparent = newparent, newheads[0] |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
114 else: |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
115 firstparent, secondparent = newheads[0], newparent |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
116 ui.status(_('updating to %d:%s\n') % |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
117 (repo.changelog.rev(firstparent), |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
118 short(firstparent))) |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
119 hg.clean(repo, firstparent) |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
120 ui.status(_('merging with %d:%s\n') % |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
121 (repo.changelog.rev(secondparent), short(secondparent))) |
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
122 err = hg.merge(repo, secondparent, remind=False) |
6941
b2bc2d984bac
fetch: linearize code by eliminating nested functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6666
diff
changeset
|
123 |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
124 if not err: |
9183
d0225fa2f6c4
do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents:
8894
diff
changeset
|
125 # we don't translate commit messages |
4549
0c61124ad877
dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents:
3891
diff
changeset
|
126 message = (cmdutil.logmessage(opts) or |
9183
d0225fa2f6c4
do not translate commit messages
Martin Geisler <mg@lazybytes.net>
parents:
8894
diff
changeset
|
127 ('Automated merge with %s' % |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
12711
diff
changeset
|
128 util.removeauth(other.url()))) |
8407
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8228
diff
changeset
|
129 editor = cmdutil.commiteditor |
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8228
diff
changeset
|
130 if opts.get('force_editor') or opts.get('edit'): |
223000a687b0
commit: move commit editor to cmdutil, pass as function
Matt Mackall <mpm@selenic.com>
parents:
8228
diff
changeset
|
131 editor = cmdutil.commitforceeditor |
9185
d9a2e6327949
fetch: drop force arg for commit (issue1752)
Matt Mackall <mpm@selenic.com>
parents:
8894
diff
changeset
|
132 n = repo.commit(message, opts['user'], opts['date'], editor=editor) |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
133 ui.status(_('new changeset %d:%s merges remote changes ' |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
134 'with local\n') % (repo.changelog.rev(n), |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
135 short(n))) |
6206
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
136 |
12711
b885f28fa4fa
fetch: fix and document exit codes (issue2356)
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
137 return err |
b885f28fa4fa
fetch: fix and document exit codes (issue2356)
Matt Mackall <mpm@selenic.com>
parents:
11321
diff
changeset
|
138 |
2825
0496cfb05243
fetch: lock repo across pull and commit
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2824
diff
changeset
|
139 finally: |
8112
6ee71f78497c
switch lock releasing in the extensions from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
7991
diff
changeset
|
140 release(lock, wlock) |
2800
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
141 |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
142 cmdtable = { |
135823f37304
new extension: fetch -> combine pull and merge/update
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
143 'fetch': |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
144 (fetch, |
11321
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11273
diff
changeset
|
145 [('r', 'rev', [], |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
11273
diff
changeset
|
146 _('a specific revision you would like to pull'), _('REV')), |
6225
595a69a01129
fetch: rename --force-editor option to --edit, for consistency
Bryan O'Sullivan <bos@serpentine.com>
parents:
6212
diff
changeset
|
147 ('e', 'edit', None, _('edit commit message')), |
595a69a01129
fetch: rename --force-editor option to --edit, for consistency
Bryan O'Sullivan <bos@serpentine.com>
parents:
6212
diff
changeset
|
148 ('', 'force-editor', None, _('edit commit message (DEPRECATED)')), |
6206
0b6f12495276
fetch: switch the default parent used for a merge
Bryan O'Sullivan <bos@serpentine.com>
parents:
6163
diff
changeset
|
149 ('', 'switch-parent', None, _('switch parents when merging')), |
5147
c80af96943aa
refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4917
diff
changeset
|
150 ] + commands.commitopts + commands.commitopts2 + commands.remoteopts, |
4730
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
151 _('hg fetch [SOURCE]')), |
eadfaa9ec487
Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4549
diff
changeset
|
152 } |