##// END OF EJS Templates
rebase: consider rewrite.empty-successor configuration...
Manuel Jacob -
r45683:1efbfa9b default
parent child Browse files
Show More
@@ -0,0 +1,44 b''
1 $ cat << EOF >> $HGRCPATH
2 > [extensions]
3 > rebase=
4 > [alias]
5 > tglog = log -G -T "{rev} '{desc}'\n"
6 > EOF
7
8 $ hg init
9
10 $ echo a > a; hg add a; hg ci -m a
11 $ echo b > b; hg add b; hg ci -m b1
12 $ hg up 0 -q
13 $ echo b > b; hg add b; hg ci -m b2 -q
14
15 $ hg tglog
16 @ 2 'b2'
17 |
18 | o 1 'b1'
19 |/
20 o 0 'a'
21
22
23 With rewrite.empty-successor=skip, b2 is skipped because it would become empty.
24
25 $ hg rebase -s 2 -d 1 --config rewrite.empty-successor=skip --dry-run
26 starting dry-run rebase; repository will not be changed
27 rebasing 2:6e2aad5e0f3c "b2" (tip)
28 note: not rebasing 2:6e2aad5e0f3c "b2" (tip), its destination already has all its changes
29 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
30
31 With rewrite.empty-successor=keep, b2 will be recreated although it became empty.
32
33 $ hg rebase -s 2 -d 1 --config rewrite.empty-successor=keep
34 rebasing 2:6e2aad5e0f3c "b2" (tip)
35 note: created empty successor for 2:6e2aad5e0f3c "b2" (tip), its destination already has all its changes
36 saved backup bundle to $TESTTMP/.hg/strip-backup/6e2aad5e0f3c-7d7c8801-rebase.hg
37
38 $ hg tglog
39 @ 2 'b2'
40 |
41 o 1 'b1'
42 |
43 o 0 'a'
44
@@ -1,2248 +1,2262 b''
1 # rebase.py - rebasing feature for mercurial
1 # rebase.py - rebasing feature for mercurial
2 #
2 #
3 # Copyright 2008 Stefano Tortarolo <stefano.tortarolo at gmail dot com>
3 # Copyright 2008 Stefano Tortarolo <stefano.tortarolo at gmail dot com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''command to move sets of revisions to a different ancestor
8 '''command to move sets of revisions to a different ancestor
9
9
10 This extension lets you rebase changesets in an existing Mercurial
10 This extension lets you rebase changesets in an existing Mercurial
11 repository.
11 repository.
12
12
13 For more information:
13 For more information:
14 https://mercurial-scm.org/wiki/RebaseExtension
14 https://mercurial-scm.org/wiki/RebaseExtension
15 '''
15 '''
16
16
17 from __future__ import absolute_import
17 from __future__ import absolute_import
18
18
19 import errno
19 import errno
20 import os
20 import os
21
21
22 from mercurial.i18n import _
22 from mercurial.i18n import _
23 from mercurial.node import (
23 from mercurial.node import (
24 nullrev,
24 nullrev,
25 short,
25 short,
26 )
26 )
27 from mercurial.pycompat import open
27 from mercurial.pycompat import open
28 from mercurial import (
28 from mercurial import (
29 bookmarks,
29 bookmarks,
30 cmdutil,
30 cmdutil,
31 commands,
31 commands,
32 copies,
32 copies,
33 destutil,
33 destutil,
34 dirstateguard,
34 dirstateguard,
35 error,
35 error,
36 extensions,
36 extensions,
37 hg,
37 hg,
38 merge as mergemod,
38 merge as mergemod,
39 mergestate as mergestatemod,
39 mergestate as mergestatemod,
40 mergeutil,
40 mergeutil,
41 node as nodemod,
41 node as nodemod,
42 obsolete,
42 obsolete,
43 obsutil,
43 obsutil,
44 patch,
44 patch,
45 phases,
45 phases,
46 pycompat,
46 pycompat,
47 registrar,
47 registrar,
48 repair,
48 repair,
49 revset,
49 revset,
50 revsetlang,
50 revsetlang,
51 rewriteutil,
51 rewriteutil,
52 scmutil,
52 scmutil,
53 smartset,
53 smartset,
54 state as statemod,
54 state as statemod,
55 util,
55 util,
56 )
56 )
57
57
58 # The following constants are used throughout the rebase module. The ordering of
58 # The following constants are used throughout the rebase module. The ordering of
59 # their values must be maintained.
59 # their values must be maintained.
60
60
61 # Indicates that a revision needs to be rebased
61 # Indicates that a revision needs to be rebased
62 revtodo = -1
62 revtodo = -1
63 revtodostr = b'-1'
63 revtodostr = b'-1'
64
64
65 # legacy revstates no longer needed in current code
65 # legacy revstates no longer needed in current code
66 # -2: nullmerge, -3: revignored, -4: revprecursor, -5: revpruned
66 # -2: nullmerge, -3: revignored, -4: revprecursor, -5: revpruned
67 legacystates = {b'-2', b'-3', b'-4', b'-5'}
67 legacystates = {b'-2', b'-3', b'-4', b'-5'}
68
68
69 cmdtable = {}
69 cmdtable = {}
70 command = registrar.command(cmdtable)
70 command = registrar.command(cmdtable)
71 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
71 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
72 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
72 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
73 # be specifying the version(s) of Mercurial they are tested with, or
73 # be specifying the version(s) of Mercurial they are tested with, or
74 # leave the attribute unspecified.
74 # leave the attribute unspecified.
75 testedwith = b'ships-with-hg-core'
75 testedwith = b'ships-with-hg-core'
76
76
77
77
78 def _nothingtorebase():
78 def _nothingtorebase():
79 return 1
79 return 1
80
80
81
81
82 def _savegraft(ctx, extra):
82 def _savegraft(ctx, extra):
83 s = ctx.extra().get(b'source', None)
83 s = ctx.extra().get(b'source', None)
84 if s is not None:
84 if s is not None:
85 extra[b'source'] = s
85 extra[b'source'] = s
86 s = ctx.extra().get(b'intermediate-source', None)
86 s = ctx.extra().get(b'intermediate-source', None)
87 if s is not None:
87 if s is not None:
88 extra[b'intermediate-source'] = s
88 extra[b'intermediate-source'] = s
89
89
90
90
91 def _savebranch(ctx, extra):
91 def _savebranch(ctx, extra):
92 extra[b'branch'] = ctx.branch()
92 extra[b'branch'] = ctx.branch()
93
93
94
94
95 def _destrebase(repo, sourceset, destspace=None):
95 def _destrebase(repo, sourceset, destspace=None):
96 """small wrapper around destmerge to pass the right extra args
96 """small wrapper around destmerge to pass the right extra args
97
97
98 Please wrap destutil.destmerge instead."""
98 Please wrap destutil.destmerge instead."""
99 return destutil.destmerge(
99 return destutil.destmerge(
100 repo,
100 repo,
101 action=b'rebase',
101 action=b'rebase',
102 sourceset=sourceset,
102 sourceset=sourceset,
103 onheadcheck=False,
103 onheadcheck=False,
104 destspace=destspace,
104 destspace=destspace,
105 )
105 )
106
106
107
107
108 revsetpredicate = registrar.revsetpredicate()
108 revsetpredicate = registrar.revsetpredicate()
109
109
110
110
111 @revsetpredicate(b'_destrebase')
111 @revsetpredicate(b'_destrebase')
112 def _revsetdestrebase(repo, subset, x):
112 def _revsetdestrebase(repo, subset, x):
113 # ``_rebasedefaultdest()``
113 # ``_rebasedefaultdest()``
114
114
115 # default destination for rebase.
115 # default destination for rebase.
116 # # XXX: Currently private because I expect the signature to change.
116 # # XXX: Currently private because I expect the signature to change.
117 # # XXX: - bailing out in case of ambiguity vs returning all data.
117 # # XXX: - bailing out in case of ambiguity vs returning all data.
118 # i18n: "_rebasedefaultdest" is a keyword
118 # i18n: "_rebasedefaultdest" is a keyword
119 sourceset = None
119 sourceset = None
120 if x is not None:
120 if x is not None:
121 sourceset = revset.getset(repo, smartset.fullreposet(repo), x)
121 sourceset = revset.getset(repo, smartset.fullreposet(repo), x)
122 return subset & smartset.baseset([_destrebase(repo, sourceset)])
122 return subset & smartset.baseset([_destrebase(repo, sourceset)])
123
123
124
124
125 @revsetpredicate(b'_destautoorphanrebase')
125 @revsetpredicate(b'_destautoorphanrebase')
126 def _revsetdestautoorphanrebase(repo, subset, x):
126 def _revsetdestautoorphanrebase(repo, subset, x):
127 # ``_destautoorphanrebase()``
127 # ``_destautoorphanrebase()``
128
128
129 # automatic rebase destination for a single orphan revision.
129 # automatic rebase destination for a single orphan revision.
130 unfi = repo.unfiltered()
130 unfi = repo.unfiltered()
131 obsoleted = unfi.revs(b'obsolete()')
131 obsoleted = unfi.revs(b'obsolete()')
132
132
133 src = revset.getset(repo, subset, x).first()
133 src = revset.getset(repo, subset, x).first()
134
134
135 # Empty src or already obsoleted - Do not return a destination
135 # Empty src or already obsoleted - Do not return a destination
136 if not src or src in obsoleted:
136 if not src or src in obsoleted:
137 return smartset.baseset()
137 return smartset.baseset()
138 dests = destutil.orphanpossibledestination(repo, src)
138 dests = destutil.orphanpossibledestination(repo, src)
139 if len(dests) > 1:
139 if len(dests) > 1:
140 raise error.Abort(
140 raise error.Abort(
141 _(b"ambiguous automatic rebase: %r could end up on any of %r")
141 _(b"ambiguous automatic rebase: %r could end up on any of %r")
142 % (src, dests)
142 % (src, dests)
143 )
143 )
144 # We have zero or one destination, so we can just return here.
144 # We have zero or one destination, so we can just return here.
145 return smartset.baseset(dests)
145 return smartset.baseset(dests)
146
146
147
147
148 def _ctxdesc(ctx):
148 def _ctxdesc(ctx):
149 """short description for a context"""
149 """short description for a context"""
150 desc = b'%d:%s "%s"' % (
150 desc = b'%d:%s "%s"' % (
151 ctx.rev(),
151 ctx.rev(),
152 ctx,
152 ctx,
153 ctx.description().split(b'\n', 1)[0],
153 ctx.description().split(b'\n', 1)[0],
154 )
154 )
155 repo = ctx.repo()
155 repo = ctx.repo()
156 names = []
156 names = []
157 for nsname, ns in pycompat.iteritems(repo.names):
157 for nsname, ns in pycompat.iteritems(repo.names):
158 if nsname == b'branches':
158 if nsname == b'branches':
159 continue
159 continue
160 names.extend(ns.names(repo, ctx.node()))
160 names.extend(ns.names(repo, ctx.node()))
161 if names:
161 if names:
162 desc += b' (%s)' % b' '.join(names)
162 desc += b' (%s)' % b' '.join(names)
163 return desc
163 return desc
164
164
165
165
166 class rebaseruntime(object):
166 class rebaseruntime(object):
167 """This class is a container for rebase runtime state"""
167 """This class is a container for rebase runtime state"""
168
168
169 def __init__(self, repo, ui, inmemory=False, opts=None):
169 def __init__(self, repo, ui, inmemory=False, opts=None):
170 if opts is None:
170 if opts is None:
171 opts = {}
171 opts = {}
172
172
173 # prepared: whether we have rebasestate prepared or not. Currently it
173 # prepared: whether we have rebasestate prepared or not. Currently it
174 # decides whether "self.repo" is unfiltered or not.
174 # decides whether "self.repo" is unfiltered or not.
175 # The rebasestate has explicit hash to hash instructions not depending
175 # The rebasestate has explicit hash to hash instructions not depending
176 # on visibility. If rebasestate exists (in-memory or on-disk), use
176 # on visibility. If rebasestate exists (in-memory or on-disk), use
177 # unfiltered repo to avoid visibility issues.
177 # unfiltered repo to avoid visibility issues.
178 # Before knowing rebasestate (i.e. when starting a new rebase (not
178 # Before knowing rebasestate (i.e. when starting a new rebase (not
179 # --continue or --abort)), the original repo should be used so
179 # --continue or --abort)), the original repo should be used so
180 # visibility-dependent revsets are correct.
180 # visibility-dependent revsets are correct.
181 self.prepared = False
181 self.prepared = False
182 self.resume = False
182 self.resume = False
183 self._repo = repo
183 self._repo = repo
184
184
185 self.ui = ui
185 self.ui = ui
186 self.opts = opts
186 self.opts = opts
187 self.originalwd = None
187 self.originalwd = None
188 self.external = nullrev
188 self.external = nullrev
189 # Mapping between the old revision id and either what is the new rebased
189 # Mapping between the old revision id and either what is the new rebased
190 # revision or what needs to be done with the old revision. The state
190 # revision or what needs to be done with the old revision. The state
191 # dict will be what contains most of the rebase progress state.
191 # dict will be what contains most of the rebase progress state.
192 self.state = {}
192 self.state = {}
193 self.activebookmark = None
193 self.activebookmark = None
194 self.destmap = {}
194 self.destmap = {}
195 self.skipped = set()
195 self.skipped = set()
196
196
197 self.collapsef = opts.get(b'collapse', False)
197 self.collapsef = opts.get(b'collapse', False)
198 self.collapsemsg = cmdutil.logmessage(ui, opts)
198 self.collapsemsg = cmdutil.logmessage(ui, opts)
199 self.date = opts.get(b'date', None)
199 self.date = opts.get(b'date', None)
200
200
201 e = opts.get(b'extrafn') # internal, used by e.g. hgsubversion
201 e = opts.get(b'extrafn') # internal, used by e.g. hgsubversion
202 self.extrafns = [_savegraft]
202 self.extrafns = [_savegraft]
203 if e:
203 if e:
204 self.extrafns = [e]
204 self.extrafns = [e]
205
205
206 self.backupf = ui.configbool(b'rewrite', b'backup-bundle')
206 self.backupf = ui.configbool(b'rewrite', b'backup-bundle')
207 self.keepf = opts.get(b'keep', False)
207 self.keepf = opts.get(b'keep', False)
208 self.keepbranchesf = opts.get(b'keepbranches', False)
208 self.keepbranchesf = opts.get(b'keepbranches', False)
209 self.skipemptysuccessorf = rewriteutil.skip_empty_successor(
210 repo.ui, b'rebase'
211 )
209 self.obsoletenotrebased = {}
212 self.obsoletenotrebased = {}
210 self.obsoletewithoutsuccessorindestination = set()
213 self.obsoletewithoutsuccessorindestination = set()
211 self.inmemory = inmemory
214 self.inmemory = inmemory
212 self.stateobj = statemod.cmdstate(repo, b'rebasestate')
215 self.stateobj = statemod.cmdstate(repo, b'rebasestate')
213
216
214 @property
217 @property
215 def repo(self):
218 def repo(self):
216 if self.prepared:
219 if self.prepared:
217 return self._repo.unfiltered()
220 return self._repo.unfiltered()
218 else:
221 else:
219 return self._repo
222 return self._repo
220
223
221 def storestatus(self, tr=None):
224 def storestatus(self, tr=None):
222 """Store the current status to allow recovery"""
225 """Store the current status to allow recovery"""
223 if tr:
226 if tr:
224 tr.addfilegenerator(
227 tr.addfilegenerator(
225 b'rebasestate',
228 b'rebasestate',
226 (b'rebasestate',),
229 (b'rebasestate',),
227 self._writestatus,
230 self._writestatus,
228 location=b'plain',
231 location=b'plain',
229 )
232 )
230 else:
233 else:
231 with self.repo.vfs(b"rebasestate", b"w") as f:
234 with self.repo.vfs(b"rebasestate", b"w") as f:
232 self._writestatus(f)
235 self._writestatus(f)
233
236
234 def _writestatus(self, f):
237 def _writestatus(self, f):
235 repo = self.repo
238 repo = self.repo
236 assert repo.filtername is None
239 assert repo.filtername is None
237 f.write(repo[self.originalwd].hex() + b'\n')
240 f.write(repo[self.originalwd].hex() + b'\n')
238 # was "dest". we now write dest per src root below.
241 # was "dest". we now write dest per src root below.
239 f.write(b'\n')
242 f.write(b'\n')
240 f.write(repo[self.external].hex() + b'\n')
243 f.write(repo[self.external].hex() + b'\n')
241 f.write(b'%d\n' % int(self.collapsef))
244 f.write(b'%d\n' % int(self.collapsef))
242 f.write(b'%d\n' % int(self.keepf))
245 f.write(b'%d\n' % int(self.keepf))
243 f.write(b'%d\n' % int(self.keepbranchesf))
246 f.write(b'%d\n' % int(self.keepbranchesf))
244 f.write(b'%s\n' % (self.activebookmark or b''))
247 f.write(b'%s\n' % (self.activebookmark or b''))
245 destmap = self.destmap
248 destmap = self.destmap
246 for d, v in pycompat.iteritems(self.state):
249 for d, v in pycompat.iteritems(self.state):
247 oldrev = repo[d].hex()
250 oldrev = repo[d].hex()
248 if v >= 0:
251 if v >= 0:
249 newrev = repo[v].hex()
252 newrev = repo[v].hex()
250 else:
253 else:
251 newrev = b"%d" % v
254 newrev = b"%d" % v
252 destnode = repo[destmap[d]].hex()
255 destnode = repo[destmap[d]].hex()
253 f.write(b"%s:%s:%s\n" % (oldrev, newrev, destnode))
256 f.write(b"%s:%s:%s\n" % (oldrev, newrev, destnode))
254 repo.ui.debug(b'rebase status stored\n')
257 repo.ui.debug(b'rebase status stored\n')
255
258
256 def restorestatus(self):
259 def restorestatus(self):
257 """Restore a previously stored status"""
260 """Restore a previously stored status"""
258 if not self.stateobj.exists():
261 if not self.stateobj.exists():
259 cmdutil.wrongtooltocontinue(self.repo, _(b'rebase'))
262 cmdutil.wrongtooltocontinue(self.repo, _(b'rebase'))
260
263
261 data = self._read()
264 data = self._read()
262 self.repo.ui.debug(b'rebase status resumed\n')
265 self.repo.ui.debug(b'rebase status resumed\n')
263
266
264 self.originalwd = data[b'originalwd']
267 self.originalwd = data[b'originalwd']
265 self.destmap = data[b'destmap']
268 self.destmap = data[b'destmap']
266 self.state = data[b'state']
269 self.state = data[b'state']
267 self.skipped = data[b'skipped']
270 self.skipped = data[b'skipped']
268 self.collapsef = data[b'collapse']
271 self.collapsef = data[b'collapse']
269 self.keepf = data[b'keep']
272 self.keepf = data[b'keep']
270 self.keepbranchesf = data[b'keepbranches']
273 self.keepbranchesf = data[b'keepbranches']
271 self.external = data[b'external']
274 self.external = data[b'external']
272 self.activebookmark = data[b'activebookmark']
275 self.activebookmark = data[b'activebookmark']
273
276
274 def _read(self):
277 def _read(self):
275 self.prepared = True
278 self.prepared = True
276 repo = self.repo
279 repo = self.repo
277 assert repo.filtername is None
280 assert repo.filtername is None
278 data = {
281 data = {
279 b'keepbranches': None,
282 b'keepbranches': None,
280 b'collapse': None,
283 b'collapse': None,
281 b'activebookmark': None,
284 b'activebookmark': None,
282 b'external': nullrev,
285 b'external': nullrev,
283 b'keep': None,
286 b'keep': None,
284 b'originalwd': None,
287 b'originalwd': None,
285 }
288 }
286 legacydest = None
289 legacydest = None
287 state = {}
290 state = {}
288 destmap = {}
291 destmap = {}
289
292
290 if True:
293 if True:
291 f = repo.vfs(b"rebasestate")
294 f = repo.vfs(b"rebasestate")
292 for i, l in enumerate(f.read().splitlines()):
295 for i, l in enumerate(f.read().splitlines()):
293 if i == 0:
296 if i == 0:
294 data[b'originalwd'] = repo[l].rev()
297 data[b'originalwd'] = repo[l].rev()
295 elif i == 1:
298 elif i == 1:
296 # this line should be empty in newer version. but legacy
299 # this line should be empty in newer version. but legacy
297 # clients may still use it
300 # clients may still use it
298 if l:
301 if l:
299 legacydest = repo[l].rev()
302 legacydest = repo[l].rev()
300 elif i == 2:
303 elif i == 2:
301 data[b'external'] = repo[l].rev()
304 data[b'external'] = repo[l].rev()
302 elif i == 3:
305 elif i == 3:
303 data[b'collapse'] = bool(int(l))
306 data[b'collapse'] = bool(int(l))
304 elif i == 4:
307 elif i == 4:
305 data[b'keep'] = bool(int(l))
308 data[b'keep'] = bool(int(l))
306 elif i == 5:
309 elif i == 5:
307 data[b'keepbranches'] = bool(int(l))
310 data[b'keepbranches'] = bool(int(l))
308 elif i == 6 and not (len(l) == 81 and b':' in l):
311 elif i == 6 and not (len(l) == 81 and b':' in l):
309 # line 6 is a recent addition, so for backwards
312 # line 6 is a recent addition, so for backwards
310 # compatibility check that the line doesn't look like the
313 # compatibility check that the line doesn't look like the
311 # oldrev:newrev lines
314 # oldrev:newrev lines
312 data[b'activebookmark'] = l
315 data[b'activebookmark'] = l
313 else:
316 else:
314 args = l.split(b':')
317 args = l.split(b':')
315 oldrev = repo[args[0]].rev()
318 oldrev = repo[args[0]].rev()
316 newrev = args[1]
319 newrev = args[1]
317 if newrev in legacystates:
320 if newrev in legacystates:
318 continue
321 continue
319 if len(args) > 2:
322 if len(args) > 2:
320 destrev = repo[args[2]].rev()
323 destrev = repo[args[2]].rev()
321 else:
324 else:
322 destrev = legacydest
325 destrev = legacydest
323 destmap[oldrev] = destrev
326 destmap[oldrev] = destrev
324 if newrev == revtodostr:
327 if newrev == revtodostr:
325 state[oldrev] = revtodo
328 state[oldrev] = revtodo
326 # Legacy compat special case
329 # Legacy compat special case
327 else:
330 else:
328 state[oldrev] = repo[newrev].rev()
331 state[oldrev] = repo[newrev].rev()
329
332
330 if data[b'keepbranches'] is None:
333 if data[b'keepbranches'] is None:
331 raise error.Abort(_(b'.hg/rebasestate is incomplete'))
334 raise error.Abort(_(b'.hg/rebasestate is incomplete'))
332
335
333 data[b'destmap'] = destmap
336 data[b'destmap'] = destmap
334 data[b'state'] = state
337 data[b'state'] = state
335 skipped = set()
338 skipped = set()
336 # recompute the set of skipped revs
339 # recompute the set of skipped revs
337 if not data[b'collapse']:
340 if not data[b'collapse']:
338 seen = set(destmap.values())
341 seen = set(destmap.values())
339 for old, new in sorted(state.items()):
342 for old, new in sorted(state.items()):
340 if new != revtodo and new in seen:
343 if new != revtodo and new in seen:
341 skipped.add(old)
344 skipped.add(old)
342 seen.add(new)
345 seen.add(new)
343 data[b'skipped'] = skipped
346 data[b'skipped'] = skipped
344 repo.ui.debug(
347 repo.ui.debug(
345 b'computed skipped revs: %s\n'
348 b'computed skipped revs: %s\n'
346 % (b' '.join(b'%d' % r for r in sorted(skipped)) or b'')
349 % (b' '.join(b'%d' % r for r in sorted(skipped)) or b'')
347 )
350 )
348
351
349 return data
352 return data
350
353
351 def _handleskippingobsolete(self, obsoleterevs, destmap):
354 def _handleskippingobsolete(self, obsoleterevs, destmap):
352 """Compute structures necessary for skipping obsolete revisions
355 """Compute structures necessary for skipping obsolete revisions
353
356
354 obsoleterevs: iterable of all obsolete revisions in rebaseset
357 obsoleterevs: iterable of all obsolete revisions in rebaseset
355 destmap: {srcrev: destrev} destination revisions
358 destmap: {srcrev: destrev} destination revisions
356 """
359 """
357 self.obsoletenotrebased = {}
360 self.obsoletenotrebased = {}
358 if not self.ui.configbool(b'experimental', b'rebaseskipobsolete'):
361 if not self.ui.configbool(b'experimental', b'rebaseskipobsolete'):
359 return
362 return
360 obsoleteset = set(obsoleterevs)
363 obsoleteset = set(obsoleterevs)
361 (
364 (
362 self.obsoletenotrebased,
365 self.obsoletenotrebased,
363 self.obsoletewithoutsuccessorindestination,
366 self.obsoletewithoutsuccessorindestination,
364 obsoleteextinctsuccessors,
367 obsoleteextinctsuccessors,
365 ) = _computeobsoletenotrebased(self.repo, obsoleteset, destmap)
368 ) = _computeobsoletenotrebased(self.repo, obsoleteset, destmap)
366 skippedset = set(self.obsoletenotrebased)
369 skippedset = set(self.obsoletenotrebased)
367 skippedset.update(self.obsoletewithoutsuccessorindestination)
370 skippedset.update(self.obsoletewithoutsuccessorindestination)
368 skippedset.update(obsoleteextinctsuccessors)
371 skippedset.update(obsoleteextinctsuccessors)
369 _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
372 _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
370
373
371 def _prepareabortorcontinue(
374 def _prepareabortorcontinue(
372 self, isabort, backup=True, suppwarns=False, dryrun=False, confirm=False
375 self, isabort, backup=True, suppwarns=False, dryrun=False, confirm=False
373 ):
376 ):
374 self.resume = True
377 self.resume = True
375 try:
378 try:
376 self.restorestatus()
379 self.restorestatus()
377 self.collapsemsg = restorecollapsemsg(self.repo, isabort)
380 self.collapsemsg = restorecollapsemsg(self.repo, isabort)
378 except error.RepoLookupError:
381 except error.RepoLookupError:
379 if isabort:
382 if isabort:
380 clearstatus(self.repo)
383 clearstatus(self.repo)
381 clearcollapsemsg(self.repo)
384 clearcollapsemsg(self.repo)
382 self.repo.ui.warn(
385 self.repo.ui.warn(
383 _(
386 _(
384 b'rebase aborted (no revision is removed,'
387 b'rebase aborted (no revision is removed,'
385 b' only broken state is cleared)\n'
388 b' only broken state is cleared)\n'
386 )
389 )
387 )
390 )
388 return 0
391 return 0
389 else:
392 else:
390 msg = _(b'cannot continue inconsistent rebase')
393 msg = _(b'cannot continue inconsistent rebase')
391 hint = _(b'use "hg rebase --abort" to clear broken state')
394 hint = _(b'use "hg rebase --abort" to clear broken state')
392 raise error.Abort(msg, hint=hint)
395 raise error.Abort(msg, hint=hint)
393
396
394 if isabort:
397 if isabort:
395 backup = backup and self.backupf
398 backup = backup and self.backupf
396 return self._abort(
399 return self._abort(
397 backup=backup,
400 backup=backup,
398 suppwarns=suppwarns,
401 suppwarns=suppwarns,
399 dryrun=dryrun,
402 dryrun=dryrun,
400 confirm=confirm,
403 confirm=confirm,
401 )
404 )
402
405
403 def _preparenewrebase(self, destmap):
406 def _preparenewrebase(self, destmap):
404 if not destmap:
407 if not destmap:
405 return _nothingtorebase()
408 return _nothingtorebase()
406
409
407 rebaseset = destmap.keys()
410 rebaseset = destmap.keys()
408 if not self.keepf:
411 if not self.keepf:
409 try:
412 try:
410 rewriteutil.precheck(self.repo, rebaseset, action=b'rebase')
413 rewriteutil.precheck(self.repo, rebaseset, action=b'rebase')
411 except error.Abort as e:
414 except error.Abort as e:
412 if e.hint is None:
415 if e.hint is None:
413 e.hint = _(b'use --keep to keep original changesets')
416 e.hint = _(b'use --keep to keep original changesets')
414 raise e
417 raise e
415
418
416 result = buildstate(self.repo, destmap, self.collapsef)
419 result = buildstate(self.repo, destmap, self.collapsef)
417
420
418 if not result:
421 if not result:
419 # Empty state built, nothing to rebase
422 # Empty state built, nothing to rebase
420 self.ui.status(_(b'nothing to rebase\n'))
423 self.ui.status(_(b'nothing to rebase\n'))
421 return _nothingtorebase()
424 return _nothingtorebase()
422
425
423 (self.originalwd, self.destmap, self.state) = result
426 (self.originalwd, self.destmap, self.state) = result
424 if self.collapsef:
427 if self.collapsef:
425 dests = set(self.destmap.values())
428 dests = set(self.destmap.values())
426 if len(dests) != 1:
429 if len(dests) != 1:
427 raise error.Abort(
430 raise error.Abort(
428 _(b'--collapse does not work with multiple destinations')
431 _(b'--collapse does not work with multiple destinations')
429 )
432 )
430 destrev = next(iter(dests))
433 destrev = next(iter(dests))
431 destancestors = self.repo.changelog.ancestors(
434 destancestors = self.repo.changelog.ancestors(
432 [destrev], inclusive=True
435 [destrev], inclusive=True
433 )
436 )
434 self.external = externalparent(self.repo, self.state, destancestors)
437 self.external = externalparent(self.repo, self.state, destancestors)
435
438
436 for destrev in sorted(set(destmap.values())):
439 for destrev in sorted(set(destmap.values())):
437 dest = self.repo[destrev]
440 dest = self.repo[destrev]
438 if dest.closesbranch() and not self.keepbranchesf:
441 if dest.closesbranch() and not self.keepbranchesf:
439 self.ui.status(_(b'reopening closed branch head %s\n') % dest)
442 self.ui.status(_(b'reopening closed branch head %s\n') % dest)
440
443
441 self.prepared = True
444 self.prepared = True
442
445
443 def _assignworkingcopy(self):
446 def _assignworkingcopy(self):
444 if self.inmemory:
447 if self.inmemory:
445 from mercurial.context import overlayworkingctx
448 from mercurial.context import overlayworkingctx
446
449
447 self.wctx = overlayworkingctx(self.repo)
450 self.wctx = overlayworkingctx(self.repo)
448 self.repo.ui.debug(b"rebasing in-memory\n")
451 self.repo.ui.debug(b"rebasing in-memory\n")
449 else:
452 else:
450 self.wctx = self.repo[None]
453 self.wctx = self.repo[None]
451 self.repo.ui.debug(b"rebasing on disk\n")
454 self.repo.ui.debug(b"rebasing on disk\n")
452 self.repo.ui.log(
455 self.repo.ui.log(
453 b"rebase",
456 b"rebase",
454 b"using in-memory rebase: %r\n",
457 b"using in-memory rebase: %r\n",
455 self.inmemory,
458 self.inmemory,
456 rebase_imm_used=self.inmemory,
459 rebase_imm_used=self.inmemory,
457 )
460 )
458
461
459 def _performrebase(self, tr):
462 def _performrebase(self, tr):
460 self._assignworkingcopy()
463 self._assignworkingcopy()
461 repo, ui = self.repo, self.ui
464 repo, ui = self.repo, self.ui
462 if self.keepbranchesf:
465 if self.keepbranchesf:
463 # insert _savebranch at the start of extrafns so if
466 # insert _savebranch at the start of extrafns so if
464 # there's a user-provided extrafn it can clobber branch if
467 # there's a user-provided extrafn it can clobber branch if
465 # desired
468 # desired
466 self.extrafns.insert(0, _savebranch)
469 self.extrafns.insert(0, _savebranch)
467 if self.collapsef:
470 if self.collapsef:
468 branches = set()
471 branches = set()
469 for rev in self.state:
472 for rev in self.state:
470 branches.add(repo[rev].branch())
473 branches.add(repo[rev].branch())
471 if len(branches) > 1:
474 if len(branches) > 1:
472 raise error.Abort(
475 raise error.Abort(
473 _(b'cannot collapse multiple named branches')
476 _(b'cannot collapse multiple named branches')
474 )
477 )
475
478
476 # Calculate self.obsoletenotrebased
479 # Calculate self.obsoletenotrebased
477 obsrevs = _filterobsoleterevs(self.repo, self.state)
480 obsrevs = _filterobsoleterevs(self.repo, self.state)
478 self._handleskippingobsolete(obsrevs, self.destmap)
481 self._handleskippingobsolete(obsrevs, self.destmap)
479
482
480 # Keep track of the active bookmarks in order to reset them later
483 # Keep track of the active bookmarks in order to reset them later
481 self.activebookmark = self.activebookmark or repo._activebookmark
484 self.activebookmark = self.activebookmark or repo._activebookmark
482 if self.activebookmark:
485 if self.activebookmark:
483 bookmarks.deactivate(repo)
486 bookmarks.deactivate(repo)
484
487
485 # Store the state before we begin so users can run 'hg rebase --abort'
488 # Store the state before we begin so users can run 'hg rebase --abort'
486 # if we fail before the transaction closes.
489 # if we fail before the transaction closes.
487 self.storestatus()
490 self.storestatus()
488 if tr:
491 if tr:
489 # When using single transaction, store state when transaction
492 # When using single transaction, store state when transaction
490 # commits.
493 # commits.
491 self.storestatus(tr)
494 self.storestatus(tr)
492
495
493 cands = [k for k, v in pycompat.iteritems(self.state) if v == revtodo]
496 cands = [k for k, v in pycompat.iteritems(self.state) if v == revtodo]
494 p = repo.ui.makeprogress(
497 p = repo.ui.makeprogress(
495 _(b"rebasing"), unit=_(b'changesets'), total=len(cands)
498 _(b"rebasing"), unit=_(b'changesets'), total=len(cands)
496 )
499 )
497
500
498 def progress(ctx):
501 def progress(ctx):
499 p.increment(item=(b"%d:%s" % (ctx.rev(), ctx)))
502 p.increment(item=(b"%d:%s" % (ctx.rev(), ctx)))
500
503
501 allowdivergence = self.ui.configbool(
504 allowdivergence = self.ui.configbool(
502 b'experimental', b'evolution.allowdivergence'
505 b'experimental', b'evolution.allowdivergence'
503 )
506 )
504 for subset in sortsource(self.destmap):
507 for subset in sortsource(self.destmap):
505 sortedrevs = self.repo.revs(b'sort(%ld, -topo)', subset)
508 sortedrevs = self.repo.revs(b'sort(%ld, -topo)', subset)
506 if not allowdivergence:
509 if not allowdivergence:
507 sortedrevs -= self.repo.revs(
510 sortedrevs -= self.repo.revs(
508 b'descendants(%ld) and not %ld',
511 b'descendants(%ld) and not %ld',
509 self.obsoletewithoutsuccessorindestination,
512 self.obsoletewithoutsuccessorindestination,
510 self.obsoletewithoutsuccessorindestination,
513 self.obsoletewithoutsuccessorindestination,
511 )
514 )
512 for rev in sortedrevs:
515 for rev in sortedrevs:
513 self._rebasenode(tr, rev, allowdivergence, progress)
516 self._rebasenode(tr, rev, allowdivergence, progress)
514 p.complete()
517 p.complete()
515 ui.note(_(b'rebase merging completed\n'))
518 ui.note(_(b'rebase merging completed\n'))
516
519
517 def _concludenode(self, rev, p1, editor, commitmsg=None):
520 def _concludenode(self, rev, p1, editor, commitmsg=None):
518 '''Commit the wd changes with parents p1 and p2.
521 '''Commit the wd changes with parents p1 and p2.
519
522
520 Reuse commit info from rev but also store useful information in extra.
523 Reuse commit info from rev but also store useful information in extra.
521 Return node of committed revision.'''
524 Return node of committed revision.'''
522 repo = self.repo
525 repo = self.repo
523 ctx = repo[rev]
526 ctx = repo[rev]
524 if commitmsg is None:
527 if commitmsg is None:
525 commitmsg = ctx.description()
528 commitmsg = ctx.description()
526 date = self.date
529 date = self.date
527 if date is None:
530 if date is None:
528 date = ctx.date()
531 date = ctx.date()
529 extra = {b'rebase_source': ctx.hex()}
532 extra = {b'rebase_source': ctx.hex()}
530 for c in self.extrafns:
533 for c in self.extrafns:
531 c(ctx, extra)
534 c(ctx, extra)
532 destphase = max(ctx.phase(), phases.draft)
535 destphase = max(ctx.phase(), phases.draft)
533 overrides = {(b'phases', b'new-commit'): destphase}
536 overrides = {
537 (b'phases', b'new-commit'): destphase,
538 (b'ui', b'allowemptycommit'): not self.skipemptysuccessorf,
539 }
534 with repo.ui.configoverride(overrides, b'rebase'):
540 with repo.ui.configoverride(overrides, b'rebase'):
535 if self.inmemory:
541 if self.inmemory:
536 newnode = commitmemorynode(
542 newnode = commitmemorynode(
537 repo,
543 repo,
538 wctx=self.wctx,
544 wctx=self.wctx,
539 extra=extra,
545 extra=extra,
540 commitmsg=commitmsg,
546 commitmsg=commitmsg,
541 editor=editor,
547 editor=editor,
542 user=ctx.user(),
548 user=ctx.user(),
543 date=date,
549 date=date,
544 )
550 )
545 mergestatemod.mergestate.clean(repo)
551 mergestatemod.mergestate.clean(repo)
546 else:
552 else:
547 newnode = commitnode(
553 newnode = commitnode(
548 repo,
554 repo,
549 extra=extra,
555 extra=extra,
550 commitmsg=commitmsg,
556 commitmsg=commitmsg,
551 editor=editor,
557 editor=editor,
552 user=ctx.user(),
558 user=ctx.user(),
553 date=date,
559 date=date,
554 )
560 )
555
561
556 return newnode
562 return newnode
557
563
558 def _rebasenode(self, tr, rev, allowdivergence, progressfn):
564 def _rebasenode(self, tr, rev, allowdivergence, progressfn):
559 repo, ui, opts = self.repo, self.ui, self.opts
565 repo, ui, opts = self.repo, self.ui, self.opts
560 dest = self.destmap[rev]
566 dest = self.destmap[rev]
561 ctx = repo[rev]
567 ctx = repo[rev]
562 desc = _ctxdesc(ctx)
568 desc = _ctxdesc(ctx)
563 if self.state[rev] == rev:
569 if self.state[rev] == rev:
564 ui.status(_(b'already rebased %s\n') % desc)
570 ui.status(_(b'already rebased %s\n') % desc)
565 elif (
571 elif (
566 not allowdivergence
572 not allowdivergence
567 and rev in self.obsoletewithoutsuccessorindestination
573 and rev in self.obsoletewithoutsuccessorindestination
568 ):
574 ):
569 msg = (
575 msg = (
570 _(
576 _(
571 b'note: not rebasing %s and its descendants as '
577 b'note: not rebasing %s and its descendants as '
572 b'this would cause divergence\n'
578 b'this would cause divergence\n'
573 )
579 )
574 % desc
580 % desc
575 )
581 )
576 repo.ui.status(msg)
582 repo.ui.status(msg)
577 self.skipped.add(rev)
583 self.skipped.add(rev)
578 elif rev in self.obsoletenotrebased:
584 elif rev in self.obsoletenotrebased:
579 succ = self.obsoletenotrebased[rev]
585 succ = self.obsoletenotrebased[rev]
580 if succ is None:
586 if succ is None:
581 msg = _(b'note: not rebasing %s, it has no successor\n') % desc
587 msg = _(b'note: not rebasing %s, it has no successor\n') % desc
582 else:
588 else:
583 succdesc = _ctxdesc(repo[succ])
589 succdesc = _ctxdesc(repo[succ])
584 msg = _(
590 msg = _(
585 b'note: not rebasing %s, already in destination as %s\n'
591 b'note: not rebasing %s, already in destination as %s\n'
586 ) % (desc, succdesc)
592 ) % (desc, succdesc)
587 repo.ui.status(msg)
593 repo.ui.status(msg)
588 # Make clearrebased aware state[rev] is not a true successor
594 # Make clearrebased aware state[rev] is not a true successor
589 self.skipped.add(rev)
595 self.skipped.add(rev)
590 # Record rev as moved to its desired destination in self.state.
596 # Record rev as moved to its desired destination in self.state.
591 # This helps bookmark and working parent movement.
597 # This helps bookmark and working parent movement.
592 dest = max(
598 dest = max(
593 adjustdest(repo, rev, self.destmap, self.state, self.skipped)
599 adjustdest(repo, rev, self.destmap, self.state, self.skipped)
594 )
600 )
595 self.state[rev] = dest
601 self.state[rev] = dest
596 elif self.state[rev] == revtodo:
602 elif self.state[rev] == revtodo:
597 ui.status(_(b'rebasing %s\n') % desc)
603 ui.status(_(b'rebasing %s\n') % desc)
598 progressfn(ctx)
604 progressfn(ctx)
599 p1, p2, base = defineparents(
605 p1, p2, base = defineparents(
600 repo,
606 repo,
601 rev,
607 rev,
602 self.destmap,
608 self.destmap,
603 self.state,
609 self.state,
604 self.skipped,
610 self.skipped,
605 self.obsoletenotrebased,
611 self.obsoletenotrebased,
606 )
612 )
607 if self.resume and self.wctx.p1().rev() == p1:
613 if self.resume and self.wctx.p1().rev() == p1:
608 repo.ui.debug(b'resuming interrupted rebase\n')
614 repo.ui.debug(b'resuming interrupted rebase\n')
609 self.resume = False
615 self.resume = False
610 else:
616 else:
611 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
617 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
612 with ui.configoverride(overrides, b'rebase'):
618 with ui.configoverride(overrides, b'rebase'):
613 stats = rebasenode(
619 stats = rebasenode(
614 repo,
620 repo,
615 rev,
621 rev,
616 p1,
622 p1,
617 p2,
623 p2,
618 base,
624 base,
619 self.collapsef,
625 self.collapsef,
620 dest,
626 dest,
621 wctx=self.wctx,
627 wctx=self.wctx,
622 )
628 )
623 if stats.unresolvedcount > 0:
629 if stats.unresolvedcount > 0:
624 if self.inmemory:
630 if self.inmemory:
625 raise error.InMemoryMergeConflictsError()
631 raise error.InMemoryMergeConflictsError()
626 else:
632 else:
627 raise error.InterventionRequired(
633 raise error.InterventionRequired(
628 _(
634 _(
629 b'unresolved conflicts (see hg '
635 b'unresolved conflicts (see hg '
630 b'resolve, then hg rebase --continue)'
636 b'resolve, then hg rebase --continue)'
631 )
637 )
632 )
638 )
633 if not self.collapsef:
639 if not self.collapsef:
634 merging = p2 != nullrev
640 merging = p2 != nullrev
635 editform = cmdutil.mergeeditform(merging, b'rebase')
641 editform = cmdutil.mergeeditform(merging, b'rebase')
636 editor = cmdutil.getcommiteditor(
642 editor = cmdutil.getcommiteditor(
637 editform=editform, **pycompat.strkwargs(opts)
643 editform=editform, **pycompat.strkwargs(opts)
638 )
644 )
639 # We need to set parents again here just in case we're continuing
645 # We need to set parents again here just in case we're continuing
640 # a rebase started with an old hg version (before 9c9cfecd4600),
646 # a rebase started with an old hg version (before 9c9cfecd4600),
641 # because those old versions would have left us with two dirstate
647 # because those old versions would have left us with two dirstate
642 # parents, and we don't want to create a merge commit here (unless
648 # parents, and we don't want to create a merge commit here (unless
643 # we're rebasing a merge commit).
649 # we're rebasing a merge commit).
644 self.wctx.setparents(repo[p1].node(), repo[p2].node())
650 self.wctx.setparents(repo[p1].node(), repo[p2].node())
645 newnode = self._concludenode(rev, p1, editor)
651 newnode = self._concludenode(rev, p1, editor)
646 else:
652 else:
647 # Skip commit if we are collapsing
653 # Skip commit if we are collapsing
648 newnode = None
654 newnode = None
649 # Update the state
655 # Update the state
650 if newnode is not None:
656 if newnode is not None:
651 self.state[rev] = repo[newnode].rev()
657 self.state[rev] = repo[newnode].rev()
652 ui.debug(b'rebased as %s\n' % short(newnode))
658 ui.debug(b'rebased as %s\n' % short(newnode))
659 if repo[newnode].isempty():
660 ui.warn(
661 _(
662 b'note: created empty successor for %s, its '
663 b'destination already has all its changes\n'
664 )
665 % desc
666 )
653 else:
667 else:
654 if not self.collapsef:
668 if not self.collapsef:
655 ui.warn(
669 ui.warn(
656 _(
670 _(
657 b'note: not rebasing %s, its destination already '
671 b'note: not rebasing %s, its destination already '
658 b'has all its changes\n'
672 b'has all its changes\n'
659 )
673 )
660 % desc
674 % desc
661 )
675 )
662 self.skipped.add(rev)
676 self.skipped.add(rev)
663 self.state[rev] = p1
677 self.state[rev] = p1
664 ui.debug(b'next revision set to %d\n' % p1)
678 ui.debug(b'next revision set to %d\n' % p1)
665 else:
679 else:
666 ui.status(
680 ui.status(
667 _(b'already rebased %s as %s\n') % (desc, repo[self.state[rev]])
681 _(b'already rebased %s as %s\n') % (desc, repo[self.state[rev]])
668 )
682 )
669 if not tr:
683 if not tr:
670 # When not using single transaction, store state after each
684 # When not using single transaction, store state after each
671 # commit is completely done. On InterventionRequired, we thus
685 # commit is completely done. On InterventionRequired, we thus
672 # won't store the status. Instead, we'll hit the "len(parents) == 2"
686 # won't store the status. Instead, we'll hit the "len(parents) == 2"
673 # case and realize that the commit was in progress.
687 # case and realize that the commit was in progress.
674 self.storestatus()
688 self.storestatus()
675
689
676 def _finishrebase(self):
690 def _finishrebase(self):
677 repo, ui, opts = self.repo, self.ui, self.opts
691 repo, ui, opts = self.repo, self.ui, self.opts
678 fm = ui.formatter(b'rebase', opts)
692 fm = ui.formatter(b'rebase', opts)
679 fm.startitem()
693 fm.startitem()
680 if self.collapsef:
694 if self.collapsef:
681 p1, p2, _base = defineparents(
695 p1, p2, _base = defineparents(
682 repo,
696 repo,
683 min(self.state),
697 min(self.state),
684 self.destmap,
698 self.destmap,
685 self.state,
699 self.state,
686 self.skipped,
700 self.skipped,
687 self.obsoletenotrebased,
701 self.obsoletenotrebased,
688 )
702 )
689 editopt = opts.get(b'edit')
703 editopt = opts.get(b'edit')
690 editform = b'rebase.collapse'
704 editform = b'rebase.collapse'
691 if self.collapsemsg:
705 if self.collapsemsg:
692 commitmsg = self.collapsemsg
706 commitmsg = self.collapsemsg
693 else:
707 else:
694 commitmsg = b'Collapsed revision'
708 commitmsg = b'Collapsed revision'
695 for rebased in sorted(self.state):
709 for rebased in sorted(self.state):
696 if rebased not in self.skipped:
710 if rebased not in self.skipped:
697 commitmsg += b'\n* %s' % repo[rebased].description()
711 commitmsg += b'\n* %s' % repo[rebased].description()
698 editopt = True
712 editopt = True
699 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
713 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
700 revtoreuse = max(self.state)
714 revtoreuse = max(self.state)
701
715
702 self.wctx.setparents(repo[p1].node(), repo[self.external].node())
716 self.wctx.setparents(repo[p1].node(), repo[self.external].node())
703 newnode = self._concludenode(
717 newnode = self._concludenode(
704 revtoreuse, p1, editor, commitmsg=commitmsg
718 revtoreuse, p1, editor, commitmsg=commitmsg
705 )
719 )
706
720
707 if newnode is not None:
721 if newnode is not None:
708 newrev = repo[newnode].rev()
722 newrev = repo[newnode].rev()
709 for oldrev in self.state:
723 for oldrev in self.state:
710 self.state[oldrev] = newrev
724 self.state[oldrev] = newrev
711
725
712 if b'qtip' in repo.tags():
726 if b'qtip' in repo.tags():
713 updatemq(repo, self.state, self.skipped, **pycompat.strkwargs(opts))
727 updatemq(repo, self.state, self.skipped, **pycompat.strkwargs(opts))
714
728
715 # restore original working directory
729 # restore original working directory
716 # (we do this before stripping)
730 # (we do this before stripping)
717 newwd = self.state.get(self.originalwd, self.originalwd)
731 newwd = self.state.get(self.originalwd, self.originalwd)
718 if newwd < 0:
732 if newwd < 0:
719 # original directory is a parent of rebase set root or ignored
733 # original directory is a parent of rebase set root or ignored
720 newwd = self.originalwd
734 newwd = self.originalwd
721 if newwd not in [c.rev() for c in repo[None].parents()]:
735 if newwd not in [c.rev() for c in repo[None].parents()]:
722 ui.note(_(b"update back to initial working directory parent\n"))
736 ui.note(_(b"update back to initial working directory parent\n"))
723 hg.updaterepo(repo, newwd, overwrite=False)
737 hg.updaterepo(repo, newwd, overwrite=False)
724
738
725 collapsedas = None
739 collapsedas = None
726 if self.collapsef and not self.keepf:
740 if self.collapsef and not self.keepf:
727 collapsedas = newnode
741 collapsedas = newnode
728 clearrebased(
742 clearrebased(
729 ui,
743 ui,
730 repo,
744 repo,
731 self.destmap,
745 self.destmap,
732 self.state,
746 self.state,
733 self.skipped,
747 self.skipped,
734 collapsedas,
748 collapsedas,
735 self.keepf,
749 self.keepf,
736 fm=fm,
750 fm=fm,
737 backup=self.backupf,
751 backup=self.backupf,
738 )
752 )
739
753
740 clearstatus(repo)
754 clearstatus(repo)
741 clearcollapsemsg(repo)
755 clearcollapsemsg(repo)
742
756
743 ui.note(_(b"rebase completed\n"))
757 ui.note(_(b"rebase completed\n"))
744 util.unlinkpath(repo.sjoin(b'undo'), ignoremissing=True)
758 util.unlinkpath(repo.sjoin(b'undo'), ignoremissing=True)
745 if self.skipped:
759 if self.skipped:
746 skippedlen = len(self.skipped)
760 skippedlen = len(self.skipped)
747 ui.note(_(b"%d revisions have been skipped\n") % skippedlen)
761 ui.note(_(b"%d revisions have been skipped\n") % skippedlen)
748 fm.end()
762 fm.end()
749
763
750 if (
764 if (
751 self.activebookmark
765 self.activebookmark
752 and self.activebookmark in repo._bookmarks
766 and self.activebookmark in repo._bookmarks
753 and repo[b'.'].node() == repo._bookmarks[self.activebookmark]
767 and repo[b'.'].node() == repo._bookmarks[self.activebookmark]
754 ):
768 ):
755 bookmarks.activate(repo, self.activebookmark)
769 bookmarks.activate(repo, self.activebookmark)
756
770
757 def _abort(self, backup=True, suppwarns=False, dryrun=False, confirm=False):
771 def _abort(self, backup=True, suppwarns=False, dryrun=False, confirm=False):
758 '''Restore the repository to its original state.'''
772 '''Restore the repository to its original state.'''
759
773
760 repo = self.repo
774 repo = self.repo
761 try:
775 try:
762 # If the first commits in the rebased set get skipped during the
776 # If the first commits in the rebased set get skipped during the
763 # rebase, their values within the state mapping will be the dest
777 # rebase, their values within the state mapping will be the dest
764 # rev id. The rebased list must must not contain the dest rev
778 # rev id. The rebased list must must not contain the dest rev
765 # (issue4896)
779 # (issue4896)
766 rebased = [
780 rebased = [
767 s
781 s
768 for r, s in self.state.items()
782 for r, s in self.state.items()
769 if s >= 0 and s != r and s != self.destmap[r]
783 if s >= 0 and s != r and s != self.destmap[r]
770 ]
784 ]
771 immutable = [d for d in rebased if not repo[d].mutable()]
785 immutable = [d for d in rebased if not repo[d].mutable()]
772 cleanup = True
786 cleanup = True
773 if immutable:
787 if immutable:
774 repo.ui.warn(
788 repo.ui.warn(
775 _(b"warning: can't clean up public changesets %s\n")
789 _(b"warning: can't clean up public changesets %s\n")
776 % b', '.join(bytes(repo[r]) for r in immutable),
790 % b', '.join(bytes(repo[r]) for r in immutable),
777 hint=_(b"see 'hg help phases' for details"),
791 hint=_(b"see 'hg help phases' for details"),
778 )
792 )
779 cleanup = False
793 cleanup = False
780
794
781 descendants = set()
795 descendants = set()
782 if rebased:
796 if rebased:
783 descendants = set(repo.changelog.descendants(rebased))
797 descendants = set(repo.changelog.descendants(rebased))
784 if descendants - set(rebased):
798 if descendants - set(rebased):
785 repo.ui.warn(
799 repo.ui.warn(
786 _(
800 _(
787 b"warning: new changesets detected on "
801 b"warning: new changesets detected on "
788 b"destination branch, can't strip\n"
802 b"destination branch, can't strip\n"
789 )
803 )
790 )
804 )
791 cleanup = False
805 cleanup = False
792
806
793 if cleanup:
807 if cleanup:
794 if rebased:
808 if rebased:
795 strippoints = [
809 strippoints = [
796 c.node() for c in repo.set(b'roots(%ld)', rebased)
810 c.node() for c in repo.set(b'roots(%ld)', rebased)
797 ]
811 ]
798
812
799 updateifonnodes = set(rebased)
813 updateifonnodes = set(rebased)
800 updateifonnodes.update(self.destmap.values())
814 updateifonnodes.update(self.destmap.values())
801
815
802 if not dryrun and not confirm:
816 if not dryrun and not confirm:
803 updateifonnodes.add(self.originalwd)
817 updateifonnodes.add(self.originalwd)
804
818
805 shouldupdate = repo[b'.'].rev() in updateifonnodes
819 shouldupdate = repo[b'.'].rev() in updateifonnodes
806
820
807 # Update away from the rebase if necessary
821 # Update away from the rebase if necessary
808 if shouldupdate:
822 if shouldupdate:
809 mergemod.clean_update(repo[self.originalwd])
823 mergemod.clean_update(repo[self.originalwd])
810
824
811 # Strip from the first rebased revision
825 # Strip from the first rebased revision
812 if rebased:
826 if rebased:
813 repair.strip(repo.ui, repo, strippoints, backup=backup)
827 repair.strip(repo.ui, repo, strippoints, backup=backup)
814
828
815 if self.activebookmark and self.activebookmark in repo._bookmarks:
829 if self.activebookmark and self.activebookmark in repo._bookmarks:
816 bookmarks.activate(repo, self.activebookmark)
830 bookmarks.activate(repo, self.activebookmark)
817
831
818 finally:
832 finally:
819 clearstatus(repo)
833 clearstatus(repo)
820 clearcollapsemsg(repo)
834 clearcollapsemsg(repo)
821 if not suppwarns:
835 if not suppwarns:
822 repo.ui.warn(_(b'rebase aborted\n'))
836 repo.ui.warn(_(b'rebase aborted\n'))
823 return 0
837 return 0
824
838
825
839
826 @command(
840 @command(
827 b'rebase',
841 b'rebase',
828 [
842 [
829 (
843 (
830 b's',
844 b's',
831 b'source',
845 b'source',
832 [],
846 [],
833 _(b'rebase the specified changesets and their descendants'),
847 _(b'rebase the specified changesets and their descendants'),
834 _(b'REV'),
848 _(b'REV'),
835 ),
849 ),
836 (
850 (
837 b'b',
851 b'b',
838 b'base',
852 b'base',
839 [],
853 [],
840 _(b'rebase everything from branching point of specified changeset'),
854 _(b'rebase everything from branching point of specified changeset'),
841 _(b'REV'),
855 _(b'REV'),
842 ),
856 ),
843 (b'r', b'rev', [], _(b'rebase these revisions'), _(b'REV')),
857 (b'r', b'rev', [], _(b'rebase these revisions'), _(b'REV')),
844 (
858 (
845 b'd',
859 b'd',
846 b'dest',
860 b'dest',
847 b'',
861 b'',
848 _(b'rebase onto the specified changeset'),
862 _(b'rebase onto the specified changeset'),
849 _(b'REV'),
863 _(b'REV'),
850 ),
864 ),
851 (b'', b'collapse', False, _(b'collapse the rebased changesets')),
865 (b'', b'collapse', False, _(b'collapse the rebased changesets')),
852 (
866 (
853 b'm',
867 b'm',
854 b'message',
868 b'message',
855 b'',
869 b'',
856 _(b'use text as collapse commit message'),
870 _(b'use text as collapse commit message'),
857 _(b'TEXT'),
871 _(b'TEXT'),
858 ),
872 ),
859 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
873 (b'e', b'edit', False, _(b'invoke editor on commit messages')),
860 (
874 (
861 b'l',
875 b'l',
862 b'logfile',
876 b'logfile',
863 b'',
877 b'',
864 _(b'read collapse commit message from file'),
878 _(b'read collapse commit message from file'),
865 _(b'FILE'),
879 _(b'FILE'),
866 ),
880 ),
867 (b'k', b'keep', False, _(b'keep original changesets')),
881 (b'k', b'keep', False, _(b'keep original changesets')),
868 (b'', b'keepbranches', False, _(b'keep original branch names')),
882 (b'', b'keepbranches', False, _(b'keep original branch names')),
869 (b'D', b'detach', False, _(b'(DEPRECATED)')),
883 (b'D', b'detach', False, _(b'(DEPRECATED)')),
870 (b'i', b'interactive', False, _(b'(DEPRECATED)')),
884 (b'i', b'interactive', False, _(b'(DEPRECATED)')),
871 (b't', b'tool', b'', _(b'specify merge tool')),
885 (b't', b'tool', b'', _(b'specify merge tool')),
872 (b'', b'stop', False, _(b'stop interrupted rebase')),
886 (b'', b'stop', False, _(b'stop interrupted rebase')),
873 (b'c', b'continue', False, _(b'continue an interrupted rebase')),
887 (b'c', b'continue', False, _(b'continue an interrupted rebase')),
874 (b'a', b'abort', False, _(b'abort an interrupted rebase')),
888 (b'a', b'abort', False, _(b'abort an interrupted rebase')),
875 (
889 (
876 b'',
890 b'',
877 b'auto-orphans',
891 b'auto-orphans',
878 b'',
892 b'',
879 _(
893 _(
880 b'automatically rebase orphan revisions '
894 b'automatically rebase orphan revisions '
881 b'in the specified revset (EXPERIMENTAL)'
895 b'in the specified revset (EXPERIMENTAL)'
882 ),
896 ),
883 ),
897 ),
884 ]
898 ]
885 + cmdutil.dryrunopts
899 + cmdutil.dryrunopts
886 + cmdutil.formatteropts
900 + cmdutil.formatteropts
887 + cmdutil.confirmopts,
901 + cmdutil.confirmopts,
888 _(b'[[-s REV]... | [-b REV]... | [-r REV]...] [-d REV] [OPTION]...'),
902 _(b'[[-s REV]... | [-b REV]... | [-r REV]...] [-d REV] [OPTION]...'),
889 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
903 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
890 )
904 )
891 def rebase(ui, repo, **opts):
905 def rebase(ui, repo, **opts):
892 """move changeset (and descendants) to a different branch
906 """move changeset (and descendants) to a different branch
893
907
894 Rebase uses repeated merging to graft changesets from one part of
908 Rebase uses repeated merging to graft changesets from one part of
895 history (the source) onto another (the destination). This can be
909 history (the source) onto another (the destination). This can be
896 useful for linearizing *local* changes relative to a master
910 useful for linearizing *local* changes relative to a master
897 development tree.
911 development tree.
898
912
899 Published commits cannot be rebased (see :hg:`help phases`).
913 Published commits cannot be rebased (see :hg:`help phases`).
900 To copy commits, see :hg:`help graft`.
914 To copy commits, see :hg:`help graft`.
901
915
902 If you don't specify a destination changeset (``-d/--dest``), rebase
916 If you don't specify a destination changeset (``-d/--dest``), rebase
903 will use the same logic as :hg:`merge` to pick a destination. if
917 will use the same logic as :hg:`merge` to pick a destination. if
904 the current branch contains exactly one other head, the other head
918 the current branch contains exactly one other head, the other head
905 is merged with by default. Otherwise, an explicit revision with
919 is merged with by default. Otherwise, an explicit revision with
906 which to merge with must be provided. (destination changeset is not
920 which to merge with must be provided. (destination changeset is not
907 modified by rebasing, but new changesets are added as its
921 modified by rebasing, but new changesets are added as its
908 descendants.)
922 descendants.)
909
923
910 Here are the ways to select changesets:
924 Here are the ways to select changesets:
911
925
912 1. Explicitly select them using ``--rev``.
926 1. Explicitly select them using ``--rev``.
913
927
914 2. Use ``--source`` to select a root changeset and include all of its
928 2. Use ``--source`` to select a root changeset and include all of its
915 descendants.
929 descendants.
916
930
917 3. Use ``--base`` to select a changeset; rebase will find ancestors
931 3. Use ``--base`` to select a changeset; rebase will find ancestors
918 and their descendants which are not also ancestors of the destination.
932 and their descendants which are not also ancestors of the destination.
919
933
920 4. If you do not specify any of ``--rev``, ``--source``, or ``--base``,
934 4. If you do not specify any of ``--rev``, ``--source``, or ``--base``,
921 rebase will use ``--base .`` as above.
935 rebase will use ``--base .`` as above.
922
936
923 If ``--source`` or ``--rev`` is used, special names ``SRC`` and ``ALLSRC``
937 If ``--source`` or ``--rev`` is used, special names ``SRC`` and ``ALLSRC``
924 can be used in ``--dest``. Destination would be calculated per source
938 can be used in ``--dest``. Destination would be calculated per source
925 revision with ``SRC`` substituted by that single source revision and
939 revision with ``SRC`` substituted by that single source revision and
926 ``ALLSRC`` substituted by all source revisions.
940 ``ALLSRC`` substituted by all source revisions.
927
941
928 Rebase will destroy original changesets unless you use ``--keep``.
942 Rebase will destroy original changesets unless you use ``--keep``.
929 It will also move your bookmarks (even if you do).
943 It will also move your bookmarks (even if you do).
930
944
931 Some changesets may be dropped if they do not contribute changes
945 Some changesets may be dropped if they do not contribute changes
932 (e.g. merges from the destination branch).
946 (e.g. merges from the destination branch).
933
947
934 Unlike ``merge``, rebase will do nothing if you are at the branch tip of
948 Unlike ``merge``, rebase will do nothing if you are at the branch tip of
935 a named branch with two heads. You will need to explicitly specify source
949 a named branch with two heads. You will need to explicitly specify source
936 and/or destination.
950 and/or destination.
937
951
938 If you need to use a tool to automate merge/conflict decisions, you
952 If you need to use a tool to automate merge/conflict decisions, you
939 can specify one with ``--tool``, see :hg:`help merge-tools`.
953 can specify one with ``--tool``, see :hg:`help merge-tools`.
940 As a caveat: the tool will not be used to mediate when a file was
954 As a caveat: the tool will not be used to mediate when a file was
941 deleted, there is no hook presently available for this.
955 deleted, there is no hook presently available for this.
942
956
943 If a rebase is interrupted to manually resolve a conflict, it can be
957 If a rebase is interrupted to manually resolve a conflict, it can be
944 continued with --continue/-c, aborted with --abort/-a, or stopped with
958 continued with --continue/-c, aborted with --abort/-a, or stopped with
945 --stop.
959 --stop.
946
960
947 .. container:: verbose
961 .. container:: verbose
948
962
949 Examples:
963 Examples:
950
964
951 - move "local changes" (current commit back to branching point)
965 - move "local changes" (current commit back to branching point)
952 to the current branch tip after a pull::
966 to the current branch tip after a pull::
953
967
954 hg rebase
968 hg rebase
955
969
956 - move a single changeset to the stable branch::
970 - move a single changeset to the stable branch::
957
971
958 hg rebase -r 5f493448 -d stable
972 hg rebase -r 5f493448 -d stable
959
973
960 - splice a commit and all its descendants onto another part of history::
974 - splice a commit and all its descendants onto another part of history::
961
975
962 hg rebase --source c0c3 --dest 4cf9
976 hg rebase --source c0c3 --dest 4cf9
963
977
964 - rebase everything on a branch marked by a bookmark onto the
978 - rebase everything on a branch marked by a bookmark onto the
965 default branch::
979 default branch::
966
980
967 hg rebase --base myfeature --dest default
981 hg rebase --base myfeature --dest default
968
982
969 - collapse a sequence of changes into a single commit::
983 - collapse a sequence of changes into a single commit::
970
984
971 hg rebase --collapse -r 1520:1525 -d .
985 hg rebase --collapse -r 1520:1525 -d .
972
986
973 - move a named branch while preserving its name::
987 - move a named branch while preserving its name::
974
988
975 hg rebase -r "branch(featureX)" -d 1.3 --keepbranches
989 hg rebase -r "branch(featureX)" -d 1.3 --keepbranches
976
990
977 - stabilize orphaned changesets so history looks linear::
991 - stabilize orphaned changesets so history looks linear::
978
992
979 hg rebase -r 'orphan()-obsolete()'\
993 hg rebase -r 'orphan()-obsolete()'\
980 -d 'first(max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::) +\
994 -d 'first(max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::) +\
981 max(::((roots(ALLSRC) & ::SRC)^)-obsolete()))'
995 max(::((roots(ALLSRC) & ::SRC)^)-obsolete()))'
982
996
983 Configuration Options:
997 Configuration Options:
984
998
985 You can make rebase require a destination if you set the following config
999 You can make rebase require a destination if you set the following config
986 option::
1000 option::
987
1001
988 [commands]
1002 [commands]
989 rebase.requiredest = True
1003 rebase.requiredest = True
990
1004
991 By default, rebase will close the transaction after each commit. For
1005 By default, rebase will close the transaction after each commit. For
992 performance purposes, you can configure rebase to use a single transaction
1006 performance purposes, you can configure rebase to use a single transaction
993 across the entire rebase. WARNING: This setting introduces a significant
1007 across the entire rebase. WARNING: This setting introduces a significant
994 risk of losing the work you've done in a rebase if the rebase aborts
1008 risk of losing the work you've done in a rebase if the rebase aborts
995 unexpectedly::
1009 unexpectedly::
996
1010
997 [rebase]
1011 [rebase]
998 singletransaction = True
1012 singletransaction = True
999
1013
1000 By default, rebase writes to the working copy, but you can configure it to
1014 By default, rebase writes to the working copy, but you can configure it to
1001 run in-memory for better performance. When the rebase is not moving the
1015 run in-memory for better performance. When the rebase is not moving the
1002 parent(s) of the working copy (AKA the "currently checked out changesets"),
1016 parent(s) of the working copy (AKA the "currently checked out changesets"),
1003 this may also allow it to run even if the working copy is dirty::
1017 this may also allow it to run even if the working copy is dirty::
1004
1018
1005 [rebase]
1019 [rebase]
1006 experimental.inmemory = True
1020 experimental.inmemory = True
1007
1021
1008 Return Values:
1022 Return Values:
1009
1023
1010 Returns 0 on success, 1 if nothing to rebase or there are
1024 Returns 0 on success, 1 if nothing to rebase or there are
1011 unresolved conflicts.
1025 unresolved conflicts.
1012
1026
1013 """
1027 """
1014 opts = pycompat.byteskwargs(opts)
1028 opts = pycompat.byteskwargs(opts)
1015 inmemory = ui.configbool(b'rebase', b'experimental.inmemory')
1029 inmemory = ui.configbool(b'rebase', b'experimental.inmemory')
1016 action = cmdutil.check_at_most_one_arg(opts, b'abort', b'stop', b'continue')
1030 action = cmdutil.check_at_most_one_arg(opts, b'abort', b'stop', b'continue')
1017 if action:
1031 if action:
1018 cmdutil.check_incompatible_arguments(
1032 cmdutil.check_incompatible_arguments(
1019 opts, action, [b'confirm', b'dry_run']
1033 opts, action, [b'confirm', b'dry_run']
1020 )
1034 )
1021 cmdutil.check_incompatible_arguments(
1035 cmdutil.check_incompatible_arguments(
1022 opts, action, [b'rev', b'source', b'base', b'dest']
1036 opts, action, [b'rev', b'source', b'base', b'dest']
1023 )
1037 )
1024 cmdutil.check_at_most_one_arg(opts, b'confirm', b'dry_run')
1038 cmdutil.check_at_most_one_arg(opts, b'confirm', b'dry_run')
1025 cmdutil.check_at_most_one_arg(opts, b'rev', b'source', b'base')
1039 cmdutil.check_at_most_one_arg(opts, b'rev', b'source', b'base')
1026
1040
1027 if action or repo.currenttransaction() is not None:
1041 if action or repo.currenttransaction() is not None:
1028 # in-memory rebase is not compatible with resuming rebases.
1042 # in-memory rebase is not compatible with resuming rebases.
1029 # (Or if it is run within a transaction, since the restart logic can
1043 # (Or if it is run within a transaction, since the restart logic can
1030 # fail the entire transaction.)
1044 # fail the entire transaction.)
1031 inmemory = False
1045 inmemory = False
1032
1046
1033 if opts.get(b'auto_orphans'):
1047 if opts.get(b'auto_orphans'):
1034 disallowed_opts = set(opts) - {b'auto_orphans'}
1048 disallowed_opts = set(opts) - {b'auto_orphans'}
1035 cmdutil.check_incompatible_arguments(
1049 cmdutil.check_incompatible_arguments(
1036 opts, b'auto_orphans', disallowed_opts
1050 opts, b'auto_orphans', disallowed_opts
1037 )
1051 )
1038
1052
1039 userrevs = list(repo.revs(opts.get(b'auto_orphans')))
1053 userrevs = list(repo.revs(opts.get(b'auto_orphans')))
1040 opts[b'rev'] = [revsetlang.formatspec(b'%ld and orphan()', userrevs)]
1054 opts[b'rev'] = [revsetlang.formatspec(b'%ld and orphan()', userrevs)]
1041 opts[b'dest'] = b'_destautoorphanrebase(SRC)'
1055 opts[b'dest'] = b'_destautoorphanrebase(SRC)'
1042
1056
1043 if opts.get(b'dry_run') or opts.get(b'confirm'):
1057 if opts.get(b'dry_run') or opts.get(b'confirm'):
1044 return _dryrunrebase(ui, repo, action, opts)
1058 return _dryrunrebase(ui, repo, action, opts)
1045 elif action == b'stop':
1059 elif action == b'stop':
1046 rbsrt = rebaseruntime(repo, ui)
1060 rbsrt = rebaseruntime(repo, ui)
1047 with repo.wlock(), repo.lock():
1061 with repo.wlock(), repo.lock():
1048 rbsrt.restorestatus()
1062 rbsrt.restorestatus()
1049 if rbsrt.collapsef:
1063 if rbsrt.collapsef:
1050 raise error.Abort(_(b"cannot stop in --collapse session"))
1064 raise error.Abort(_(b"cannot stop in --collapse session"))
1051 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1065 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1052 if not (rbsrt.keepf or allowunstable):
1066 if not (rbsrt.keepf or allowunstable):
1053 raise error.Abort(
1067 raise error.Abort(
1054 _(
1068 _(
1055 b"cannot remove original changesets with"
1069 b"cannot remove original changesets with"
1056 b" unrebased descendants"
1070 b" unrebased descendants"
1057 ),
1071 ),
1058 hint=_(
1072 hint=_(
1059 b'either enable obsmarkers to allow unstable '
1073 b'either enable obsmarkers to allow unstable '
1060 b'revisions or use --keep to keep original '
1074 b'revisions or use --keep to keep original '
1061 b'changesets'
1075 b'changesets'
1062 ),
1076 ),
1063 )
1077 )
1064 # update to the current working revision
1078 # update to the current working revision
1065 # to clear interrupted merge
1079 # to clear interrupted merge
1066 hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
1080 hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
1067 rbsrt._finishrebase()
1081 rbsrt._finishrebase()
1068 return 0
1082 return 0
1069 elif inmemory:
1083 elif inmemory:
1070 try:
1084 try:
1071 # in-memory merge doesn't support conflicts, so if we hit any, abort
1085 # in-memory merge doesn't support conflicts, so if we hit any, abort
1072 # and re-run as an on-disk merge.
1086 # and re-run as an on-disk merge.
1073 overrides = {(b'rebase', b'singletransaction'): True}
1087 overrides = {(b'rebase', b'singletransaction'): True}
1074 with ui.configoverride(overrides, b'rebase'):
1088 with ui.configoverride(overrides, b'rebase'):
1075 return _dorebase(ui, repo, action, opts, inmemory=inmemory)
1089 return _dorebase(ui, repo, action, opts, inmemory=inmemory)
1076 except error.InMemoryMergeConflictsError:
1090 except error.InMemoryMergeConflictsError:
1077 ui.warn(
1091 ui.warn(
1078 _(
1092 _(
1079 b'hit merge conflicts; re-running rebase without in-memory'
1093 b'hit merge conflicts; re-running rebase without in-memory'
1080 b' merge\n'
1094 b' merge\n'
1081 )
1095 )
1082 )
1096 )
1083 # TODO: Make in-memory merge not use the on-disk merge state, so
1097 # TODO: Make in-memory merge not use the on-disk merge state, so
1084 # we don't have to clean it here
1098 # we don't have to clean it here
1085 mergestatemod.mergestate.clean(repo)
1099 mergestatemod.mergestate.clean(repo)
1086 clearstatus(repo)
1100 clearstatus(repo)
1087 clearcollapsemsg(repo)
1101 clearcollapsemsg(repo)
1088 return _dorebase(ui, repo, action, opts, inmemory=False)
1102 return _dorebase(ui, repo, action, opts, inmemory=False)
1089 else:
1103 else:
1090 return _dorebase(ui, repo, action, opts)
1104 return _dorebase(ui, repo, action, opts)
1091
1105
1092
1106
1093 def _dryrunrebase(ui, repo, action, opts):
1107 def _dryrunrebase(ui, repo, action, opts):
1094 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts)
1108 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts)
1095 confirm = opts.get(b'confirm')
1109 confirm = opts.get(b'confirm')
1096 if confirm:
1110 if confirm:
1097 ui.status(_(b'starting in-memory rebase\n'))
1111 ui.status(_(b'starting in-memory rebase\n'))
1098 else:
1112 else:
1099 ui.status(
1113 ui.status(
1100 _(b'starting dry-run rebase; repository will not be changed\n')
1114 _(b'starting dry-run rebase; repository will not be changed\n')
1101 )
1115 )
1102 with repo.wlock(), repo.lock():
1116 with repo.wlock(), repo.lock():
1103 needsabort = True
1117 needsabort = True
1104 try:
1118 try:
1105 overrides = {(b'rebase', b'singletransaction'): True}
1119 overrides = {(b'rebase', b'singletransaction'): True}
1106 with ui.configoverride(overrides, b'rebase'):
1120 with ui.configoverride(overrides, b'rebase'):
1107 _origrebase(
1121 _origrebase(
1108 ui,
1122 ui,
1109 repo,
1123 repo,
1110 action,
1124 action,
1111 opts,
1125 opts,
1112 rbsrt,
1126 rbsrt,
1113 inmemory=True,
1127 inmemory=True,
1114 leaveunfinished=True,
1128 leaveunfinished=True,
1115 )
1129 )
1116 except error.InMemoryMergeConflictsError:
1130 except error.InMemoryMergeConflictsError:
1117 ui.status(_(b'hit a merge conflict\n'))
1131 ui.status(_(b'hit a merge conflict\n'))
1118 return 1
1132 return 1
1119 except error.Abort:
1133 except error.Abort:
1120 needsabort = False
1134 needsabort = False
1121 raise
1135 raise
1122 else:
1136 else:
1123 if confirm:
1137 if confirm:
1124 ui.status(_(b'rebase completed successfully\n'))
1138 ui.status(_(b'rebase completed successfully\n'))
1125 if not ui.promptchoice(_(b'apply changes (yn)?$$ &Yes $$ &No')):
1139 if not ui.promptchoice(_(b'apply changes (yn)?$$ &Yes $$ &No')):
1126 # finish unfinished rebase
1140 # finish unfinished rebase
1127 rbsrt._finishrebase()
1141 rbsrt._finishrebase()
1128 else:
1142 else:
1129 rbsrt._prepareabortorcontinue(
1143 rbsrt._prepareabortorcontinue(
1130 isabort=True,
1144 isabort=True,
1131 backup=False,
1145 backup=False,
1132 suppwarns=True,
1146 suppwarns=True,
1133 confirm=confirm,
1147 confirm=confirm,
1134 )
1148 )
1135 needsabort = False
1149 needsabort = False
1136 else:
1150 else:
1137 ui.status(
1151 ui.status(
1138 _(
1152 _(
1139 b'dry-run rebase completed successfully; run without'
1153 b'dry-run rebase completed successfully; run without'
1140 b' -n/--dry-run to perform this rebase\n'
1154 b' -n/--dry-run to perform this rebase\n'
1141 )
1155 )
1142 )
1156 )
1143 return 0
1157 return 0
1144 finally:
1158 finally:
1145 if needsabort:
1159 if needsabort:
1146 # no need to store backup in case of dryrun
1160 # no need to store backup in case of dryrun
1147 rbsrt._prepareabortorcontinue(
1161 rbsrt._prepareabortorcontinue(
1148 isabort=True,
1162 isabort=True,
1149 backup=False,
1163 backup=False,
1150 suppwarns=True,
1164 suppwarns=True,
1151 dryrun=opts.get(b'dry_run'),
1165 dryrun=opts.get(b'dry_run'),
1152 )
1166 )
1153
1167
1154
1168
1155 def _dorebase(ui, repo, action, opts, inmemory=False):
1169 def _dorebase(ui, repo, action, opts, inmemory=False):
1156 rbsrt = rebaseruntime(repo, ui, inmemory, opts)
1170 rbsrt = rebaseruntime(repo, ui, inmemory, opts)
1157 return _origrebase(ui, repo, action, opts, rbsrt, inmemory=inmemory)
1171 return _origrebase(ui, repo, action, opts, rbsrt, inmemory=inmemory)
1158
1172
1159
1173
1160 def _origrebase(
1174 def _origrebase(
1161 ui, repo, action, opts, rbsrt, inmemory=False, leaveunfinished=False
1175 ui, repo, action, opts, rbsrt, inmemory=False, leaveunfinished=False
1162 ):
1176 ):
1163 assert action != b'stop'
1177 assert action != b'stop'
1164 with repo.wlock(), repo.lock():
1178 with repo.wlock(), repo.lock():
1165 if opts.get(b'interactive'):
1179 if opts.get(b'interactive'):
1166 try:
1180 try:
1167 if extensions.find(b'histedit'):
1181 if extensions.find(b'histedit'):
1168 enablehistedit = b''
1182 enablehistedit = b''
1169 except KeyError:
1183 except KeyError:
1170 enablehistedit = b" --config extensions.histedit="
1184 enablehistedit = b" --config extensions.histedit="
1171 help = b"hg%s help -e histedit" % enablehistedit
1185 help = b"hg%s help -e histedit" % enablehistedit
1172 msg = (
1186 msg = (
1173 _(
1187 _(
1174 b"interactive history editing is supported by the "
1188 b"interactive history editing is supported by the "
1175 b"'histedit' extension (see \"%s\")"
1189 b"'histedit' extension (see \"%s\")"
1176 )
1190 )
1177 % help
1191 % help
1178 )
1192 )
1179 raise error.Abort(msg)
1193 raise error.Abort(msg)
1180
1194
1181 if rbsrt.collapsemsg and not rbsrt.collapsef:
1195 if rbsrt.collapsemsg and not rbsrt.collapsef:
1182 raise error.Abort(_(b'message can only be specified with collapse'))
1196 raise error.Abort(_(b'message can only be specified with collapse'))
1183
1197
1184 if action:
1198 if action:
1185 if rbsrt.collapsef:
1199 if rbsrt.collapsef:
1186 raise error.Abort(
1200 raise error.Abort(
1187 _(b'cannot use collapse with continue or abort')
1201 _(b'cannot use collapse with continue or abort')
1188 )
1202 )
1189 if action == b'abort' and opts.get(b'tool', False):
1203 if action == b'abort' and opts.get(b'tool', False):
1190 ui.warn(_(b'tool option will be ignored\n'))
1204 ui.warn(_(b'tool option will be ignored\n'))
1191 if action == b'continue':
1205 if action == b'continue':
1192 ms = mergestatemod.mergestate.read(repo)
1206 ms = mergestatemod.mergestate.read(repo)
1193 mergeutil.checkunresolved(ms)
1207 mergeutil.checkunresolved(ms)
1194
1208
1195 retcode = rbsrt._prepareabortorcontinue(
1209 retcode = rbsrt._prepareabortorcontinue(
1196 isabort=(action == b'abort')
1210 isabort=(action == b'abort')
1197 )
1211 )
1198 if retcode is not None:
1212 if retcode is not None:
1199 return retcode
1213 return retcode
1200 else:
1214 else:
1201 # search default destination in this space
1215 # search default destination in this space
1202 # used in the 'hg pull --rebase' case, see issue 5214.
1216 # used in the 'hg pull --rebase' case, see issue 5214.
1203 destspace = opts.get(b'_destspace')
1217 destspace = opts.get(b'_destspace')
1204 destmap = _definedestmap(
1218 destmap = _definedestmap(
1205 ui,
1219 ui,
1206 repo,
1220 repo,
1207 inmemory,
1221 inmemory,
1208 opts.get(b'dest', None),
1222 opts.get(b'dest', None),
1209 opts.get(b'source', []),
1223 opts.get(b'source', []),
1210 opts.get(b'base', []),
1224 opts.get(b'base', []),
1211 opts.get(b'rev', []),
1225 opts.get(b'rev', []),
1212 destspace=destspace,
1226 destspace=destspace,
1213 )
1227 )
1214 retcode = rbsrt._preparenewrebase(destmap)
1228 retcode = rbsrt._preparenewrebase(destmap)
1215 if retcode is not None:
1229 if retcode is not None:
1216 return retcode
1230 return retcode
1217 storecollapsemsg(repo, rbsrt.collapsemsg)
1231 storecollapsemsg(repo, rbsrt.collapsemsg)
1218
1232
1219 tr = None
1233 tr = None
1220
1234
1221 singletr = ui.configbool(b'rebase', b'singletransaction')
1235 singletr = ui.configbool(b'rebase', b'singletransaction')
1222 if singletr:
1236 if singletr:
1223 tr = repo.transaction(b'rebase')
1237 tr = repo.transaction(b'rebase')
1224
1238
1225 # If `rebase.singletransaction` is enabled, wrap the entire operation in
1239 # If `rebase.singletransaction` is enabled, wrap the entire operation in
1226 # one transaction here. Otherwise, transactions are obtained when
1240 # one transaction here. Otherwise, transactions are obtained when
1227 # committing each node, which is slower but allows partial success.
1241 # committing each node, which is slower but allows partial success.
1228 with util.acceptintervention(tr):
1242 with util.acceptintervention(tr):
1229 # Same logic for the dirstate guard, except we don't create one when
1243 # Same logic for the dirstate guard, except we don't create one when
1230 # rebasing in-memory (it's not needed).
1244 # rebasing in-memory (it's not needed).
1231 dsguard = None
1245 dsguard = None
1232 if singletr and not inmemory:
1246 if singletr and not inmemory:
1233 dsguard = dirstateguard.dirstateguard(repo, b'rebase')
1247 dsguard = dirstateguard.dirstateguard(repo, b'rebase')
1234 with util.acceptintervention(dsguard):
1248 with util.acceptintervention(dsguard):
1235 rbsrt._performrebase(tr)
1249 rbsrt._performrebase(tr)
1236 if not leaveunfinished:
1250 if not leaveunfinished:
1237 rbsrt._finishrebase()
1251 rbsrt._finishrebase()
1238
1252
1239
1253
1240 def _definedestmap(ui, repo, inmemory, destf, srcf, basef, revf, destspace):
1254 def _definedestmap(ui, repo, inmemory, destf, srcf, basef, revf, destspace):
1241 """use revisions argument to define destmap {srcrev: destrev}"""
1255 """use revisions argument to define destmap {srcrev: destrev}"""
1242 if revf is None:
1256 if revf is None:
1243 revf = []
1257 revf = []
1244
1258
1245 # destspace is here to work around issues with `hg pull --rebase` see
1259 # destspace is here to work around issues with `hg pull --rebase` see
1246 # issue5214 for details
1260 # issue5214 for details
1247
1261
1248 cmdutil.checkunfinished(repo)
1262 cmdutil.checkunfinished(repo)
1249 if not inmemory:
1263 if not inmemory:
1250 cmdutil.bailifchanged(repo)
1264 cmdutil.bailifchanged(repo)
1251
1265
1252 if ui.configbool(b'commands', b'rebase.requiredest') and not destf:
1266 if ui.configbool(b'commands', b'rebase.requiredest') and not destf:
1253 raise error.Abort(
1267 raise error.Abort(
1254 _(b'you must specify a destination'),
1268 _(b'you must specify a destination'),
1255 hint=_(b'use: hg rebase -d REV'),
1269 hint=_(b'use: hg rebase -d REV'),
1256 )
1270 )
1257
1271
1258 dest = None
1272 dest = None
1259
1273
1260 if revf:
1274 if revf:
1261 rebaseset = scmutil.revrange(repo, revf)
1275 rebaseset = scmutil.revrange(repo, revf)
1262 if not rebaseset:
1276 if not rebaseset:
1263 ui.status(_(b'empty "rev" revision set - nothing to rebase\n'))
1277 ui.status(_(b'empty "rev" revision set - nothing to rebase\n'))
1264 return None
1278 return None
1265 elif srcf:
1279 elif srcf:
1266 src = scmutil.revrange(repo, srcf)
1280 src = scmutil.revrange(repo, srcf)
1267 if not src:
1281 if not src:
1268 ui.status(_(b'empty "source" revision set - nothing to rebase\n'))
1282 ui.status(_(b'empty "source" revision set - nothing to rebase\n'))
1269 return None
1283 return None
1270 # `+ (%ld)` to work around `wdir()::` being empty
1284 # `+ (%ld)` to work around `wdir()::` being empty
1271 rebaseset = repo.revs(b'(%ld):: + (%ld)', src, src)
1285 rebaseset = repo.revs(b'(%ld):: + (%ld)', src, src)
1272 else:
1286 else:
1273 base = scmutil.revrange(repo, basef or [b'.'])
1287 base = scmutil.revrange(repo, basef or [b'.'])
1274 if not base:
1288 if not base:
1275 ui.status(
1289 ui.status(
1276 _(b'empty "base" revision set - ' b"can't compute rebase set\n")
1290 _(b'empty "base" revision set - ' b"can't compute rebase set\n")
1277 )
1291 )
1278 return None
1292 return None
1279 if destf:
1293 if destf:
1280 # --base does not support multiple destinations
1294 # --base does not support multiple destinations
1281 dest = scmutil.revsingle(repo, destf)
1295 dest = scmutil.revsingle(repo, destf)
1282 else:
1296 else:
1283 dest = repo[_destrebase(repo, base, destspace=destspace)]
1297 dest = repo[_destrebase(repo, base, destspace=destspace)]
1284 destf = bytes(dest)
1298 destf = bytes(dest)
1285
1299
1286 roots = [] # selected children of branching points
1300 roots = [] # selected children of branching points
1287 bpbase = {} # {branchingpoint: [origbase]}
1301 bpbase = {} # {branchingpoint: [origbase]}
1288 for b in base: # group bases by branching points
1302 for b in base: # group bases by branching points
1289 bp = repo.revs(b'ancestor(%d, %d)', b, dest.rev()).first()
1303 bp = repo.revs(b'ancestor(%d, %d)', b, dest.rev()).first()
1290 bpbase[bp] = bpbase.get(bp, []) + [b]
1304 bpbase[bp] = bpbase.get(bp, []) + [b]
1291 if None in bpbase:
1305 if None in bpbase:
1292 # emulate the old behavior, showing "nothing to rebase" (a better
1306 # emulate the old behavior, showing "nothing to rebase" (a better
1293 # behavior may be abort with "cannot find branching point" error)
1307 # behavior may be abort with "cannot find branching point" error)
1294 bpbase.clear()
1308 bpbase.clear()
1295 for bp, bs in pycompat.iteritems(bpbase): # calculate roots
1309 for bp, bs in pycompat.iteritems(bpbase): # calculate roots
1296 roots += list(repo.revs(b'children(%d) & ancestors(%ld)', bp, bs))
1310 roots += list(repo.revs(b'children(%d) & ancestors(%ld)', bp, bs))
1297
1311
1298 rebaseset = repo.revs(b'%ld::', roots)
1312 rebaseset = repo.revs(b'%ld::', roots)
1299
1313
1300 if not rebaseset:
1314 if not rebaseset:
1301 # transform to list because smartsets are not comparable to
1315 # transform to list because smartsets are not comparable to
1302 # lists. This should be improved to honor laziness of
1316 # lists. This should be improved to honor laziness of
1303 # smartset.
1317 # smartset.
1304 if list(base) == [dest.rev()]:
1318 if list(base) == [dest.rev()]:
1305 if basef:
1319 if basef:
1306 ui.status(
1320 ui.status(
1307 _(
1321 _(
1308 b'nothing to rebase - %s is both "base"'
1322 b'nothing to rebase - %s is both "base"'
1309 b' and destination\n'
1323 b' and destination\n'
1310 )
1324 )
1311 % dest
1325 % dest
1312 )
1326 )
1313 else:
1327 else:
1314 ui.status(
1328 ui.status(
1315 _(
1329 _(
1316 b'nothing to rebase - working directory '
1330 b'nothing to rebase - working directory '
1317 b'parent is also destination\n'
1331 b'parent is also destination\n'
1318 )
1332 )
1319 )
1333 )
1320 elif not repo.revs(b'%ld - ::%d', base, dest.rev()):
1334 elif not repo.revs(b'%ld - ::%d', base, dest.rev()):
1321 if basef:
1335 if basef:
1322 ui.status(
1336 ui.status(
1323 _(
1337 _(
1324 b'nothing to rebase - "base" %s is '
1338 b'nothing to rebase - "base" %s is '
1325 b'already an ancestor of destination '
1339 b'already an ancestor of destination '
1326 b'%s\n'
1340 b'%s\n'
1327 )
1341 )
1328 % (b'+'.join(bytes(repo[r]) for r in base), dest)
1342 % (b'+'.join(bytes(repo[r]) for r in base), dest)
1329 )
1343 )
1330 else:
1344 else:
1331 ui.status(
1345 ui.status(
1332 _(
1346 _(
1333 b'nothing to rebase - working '
1347 b'nothing to rebase - working '
1334 b'directory parent is already an '
1348 b'directory parent is already an '
1335 b'ancestor of destination %s\n'
1349 b'ancestor of destination %s\n'
1336 )
1350 )
1337 % dest
1351 % dest
1338 )
1352 )
1339 else: # can it happen?
1353 else: # can it happen?
1340 ui.status(
1354 ui.status(
1341 _(b'nothing to rebase from %s to %s\n')
1355 _(b'nothing to rebase from %s to %s\n')
1342 % (b'+'.join(bytes(repo[r]) for r in base), dest)
1356 % (b'+'.join(bytes(repo[r]) for r in base), dest)
1343 )
1357 )
1344 return None
1358 return None
1345
1359
1346 if nodemod.wdirrev in rebaseset:
1360 if nodemod.wdirrev in rebaseset:
1347 raise error.Abort(_(b'cannot rebase the working copy'))
1361 raise error.Abort(_(b'cannot rebase the working copy'))
1348 rebasingwcp = repo[b'.'].rev() in rebaseset
1362 rebasingwcp = repo[b'.'].rev() in rebaseset
1349 ui.log(
1363 ui.log(
1350 b"rebase",
1364 b"rebase",
1351 b"rebasing working copy parent: %r\n",
1365 b"rebasing working copy parent: %r\n",
1352 rebasingwcp,
1366 rebasingwcp,
1353 rebase_rebasing_wcp=rebasingwcp,
1367 rebase_rebasing_wcp=rebasingwcp,
1354 )
1368 )
1355 if inmemory and rebasingwcp:
1369 if inmemory and rebasingwcp:
1356 # Check these since we did not before.
1370 # Check these since we did not before.
1357 cmdutil.checkunfinished(repo)
1371 cmdutil.checkunfinished(repo)
1358 cmdutil.bailifchanged(repo)
1372 cmdutil.bailifchanged(repo)
1359
1373
1360 if not destf:
1374 if not destf:
1361 dest = repo[_destrebase(repo, rebaseset, destspace=destspace)]
1375 dest = repo[_destrebase(repo, rebaseset, destspace=destspace)]
1362 destf = bytes(dest)
1376 destf = bytes(dest)
1363
1377
1364 allsrc = revsetlang.formatspec(b'%ld', rebaseset)
1378 allsrc = revsetlang.formatspec(b'%ld', rebaseset)
1365 alias = {b'ALLSRC': allsrc}
1379 alias = {b'ALLSRC': allsrc}
1366
1380
1367 if dest is None:
1381 if dest is None:
1368 try:
1382 try:
1369 # fast path: try to resolve dest without SRC alias
1383 # fast path: try to resolve dest without SRC alias
1370 dest = scmutil.revsingle(repo, destf, localalias=alias)
1384 dest = scmutil.revsingle(repo, destf, localalias=alias)
1371 except error.RepoLookupError:
1385 except error.RepoLookupError:
1372 # multi-dest path: resolve dest for each SRC separately
1386 # multi-dest path: resolve dest for each SRC separately
1373 destmap = {}
1387 destmap = {}
1374 for r in rebaseset:
1388 for r in rebaseset:
1375 alias[b'SRC'] = revsetlang.formatspec(b'%d', r)
1389 alias[b'SRC'] = revsetlang.formatspec(b'%d', r)
1376 # use repo.anyrevs instead of scmutil.revsingle because we
1390 # use repo.anyrevs instead of scmutil.revsingle because we
1377 # don't want to abort if destset is empty.
1391 # don't want to abort if destset is empty.
1378 destset = repo.anyrevs([destf], user=True, localalias=alias)
1392 destset = repo.anyrevs([destf], user=True, localalias=alias)
1379 size = len(destset)
1393 size = len(destset)
1380 if size == 1:
1394 if size == 1:
1381 destmap[r] = destset.first()
1395 destmap[r] = destset.first()
1382 elif size == 0:
1396 elif size == 0:
1383 ui.note(_(b'skipping %s - empty destination\n') % repo[r])
1397 ui.note(_(b'skipping %s - empty destination\n') % repo[r])
1384 else:
1398 else:
1385 raise error.Abort(
1399 raise error.Abort(
1386 _(b'rebase destination for %s is not unique') % repo[r]
1400 _(b'rebase destination for %s is not unique') % repo[r]
1387 )
1401 )
1388
1402
1389 if dest is not None:
1403 if dest is not None:
1390 # single-dest case: assign dest to each rev in rebaseset
1404 # single-dest case: assign dest to each rev in rebaseset
1391 destrev = dest.rev()
1405 destrev = dest.rev()
1392 destmap = {r: destrev for r in rebaseset} # {srcrev: destrev}
1406 destmap = {r: destrev for r in rebaseset} # {srcrev: destrev}
1393
1407
1394 if not destmap:
1408 if not destmap:
1395 ui.status(_(b'nothing to rebase - empty destination\n'))
1409 ui.status(_(b'nothing to rebase - empty destination\n'))
1396 return None
1410 return None
1397
1411
1398 return destmap
1412 return destmap
1399
1413
1400
1414
1401 def externalparent(repo, state, destancestors):
1415 def externalparent(repo, state, destancestors):
1402 """Return the revision that should be used as the second parent
1416 """Return the revision that should be used as the second parent
1403 when the revisions in state is collapsed on top of destancestors.
1417 when the revisions in state is collapsed on top of destancestors.
1404 Abort if there is more than one parent.
1418 Abort if there is more than one parent.
1405 """
1419 """
1406 parents = set()
1420 parents = set()
1407 source = min(state)
1421 source = min(state)
1408 for rev in state:
1422 for rev in state:
1409 if rev == source:
1423 if rev == source:
1410 continue
1424 continue
1411 for p in repo[rev].parents():
1425 for p in repo[rev].parents():
1412 if p.rev() not in state and p.rev() not in destancestors:
1426 if p.rev() not in state and p.rev() not in destancestors:
1413 parents.add(p.rev())
1427 parents.add(p.rev())
1414 if not parents:
1428 if not parents:
1415 return nullrev
1429 return nullrev
1416 if len(parents) == 1:
1430 if len(parents) == 1:
1417 return parents.pop()
1431 return parents.pop()
1418 raise error.Abort(
1432 raise error.Abort(
1419 _(
1433 _(
1420 b'unable to collapse on top of %d, there is more '
1434 b'unable to collapse on top of %d, there is more '
1421 b'than one external parent: %s'
1435 b'than one external parent: %s'
1422 )
1436 )
1423 % (max(destancestors), b', '.join(b"%d" % p for p in sorted(parents)))
1437 % (max(destancestors), b', '.join(b"%d" % p for p in sorted(parents)))
1424 )
1438 )
1425
1439
1426
1440
1427 def commitmemorynode(repo, wctx, editor, extra, user, date, commitmsg):
1441 def commitmemorynode(repo, wctx, editor, extra, user, date, commitmsg):
1428 '''Commit the memory changes with parents p1 and p2.
1442 '''Commit the memory changes with parents p1 and p2.
1429 Return node of committed revision.'''
1443 Return node of committed revision.'''
1430 # By convention, ``extra['branch']`` (set by extrafn) clobbers
1444 # By convention, ``extra['branch']`` (set by extrafn) clobbers
1431 # ``branch`` (used when passing ``--keepbranches``).
1445 # ``branch`` (used when passing ``--keepbranches``).
1432 branch = None
1446 branch = None
1433 if b'branch' in extra:
1447 if b'branch' in extra:
1434 branch = extra[b'branch']
1448 branch = extra[b'branch']
1435
1449
1436 memctx = wctx.tomemctx(
1450 memctx = wctx.tomemctx(
1437 commitmsg,
1451 commitmsg,
1438 date=date,
1452 date=date,
1439 extra=extra,
1453 extra=extra,
1440 user=user,
1454 user=user,
1441 branch=branch,
1455 branch=branch,
1442 editor=editor,
1456 editor=editor,
1443 )
1457 )
1444 if memctx.isempty() and not repo.ui.configbool(b'ui', b'allowemptycommit'):
1458 if memctx.isempty() and not repo.ui.configbool(b'ui', b'allowemptycommit'):
1445 return None
1459 return None
1446 commitres = repo.commitctx(memctx)
1460 commitres = repo.commitctx(memctx)
1447 wctx.clean() # Might be reused
1461 wctx.clean() # Might be reused
1448 return commitres
1462 return commitres
1449
1463
1450
1464
1451 def commitnode(repo, editor, extra, user, date, commitmsg):
1465 def commitnode(repo, editor, extra, user, date, commitmsg):
1452 '''Commit the wd changes with parents p1 and p2.
1466 '''Commit the wd changes with parents p1 and p2.
1453 Return node of committed revision.'''
1467 Return node of committed revision.'''
1454 dsguard = util.nullcontextmanager()
1468 dsguard = util.nullcontextmanager()
1455 if not repo.ui.configbool(b'rebase', b'singletransaction'):
1469 if not repo.ui.configbool(b'rebase', b'singletransaction'):
1456 dsguard = dirstateguard.dirstateguard(repo, b'rebase')
1470 dsguard = dirstateguard.dirstateguard(repo, b'rebase')
1457 with dsguard:
1471 with dsguard:
1458 # Commit might fail if unresolved files exist
1472 # Commit might fail if unresolved files exist
1459 newnode = repo.commit(
1473 newnode = repo.commit(
1460 text=commitmsg, user=user, date=date, extra=extra, editor=editor
1474 text=commitmsg, user=user, date=date, extra=extra, editor=editor
1461 )
1475 )
1462
1476
1463 repo.dirstate.setbranch(repo[newnode].branch())
1477 repo.dirstate.setbranch(repo[newnode].branch())
1464 return newnode
1478 return newnode
1465
1479
1466
1480
1467 def rebasenode(repo, rev, p1, p2, base, collapse, dest, wctx):
1481 def rebasenode(repo, rev, p1, p2, base, collapse, dest, wctx):
1468 """Rebase a single revision rev on top of p1 using base as merge ancestor"""
1482 """Rebase a single revision rev on top of p1 using base as merge ancestor"""
1469 # Merge phase
1483 # Merge phase
1470 # Update to destination and merge it with local
1484 # Update to destination and merge it with local
1471 p1ctx = repo[p1]
1485 p1ctx = repo[p1]
1472 if wctx.isinmemory():
1486 if wctx.isinmemory():
1473 wctx.setbase(p1ctx)
1487 wctx.setbase(p1ctx)
1474 else:
1488 else:
1475 if repo[b'.'].rev() != p1:
1489 if repo[b'.'].rev() != p1:
1476 repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx))
1490 repo.ui.debug(b" update to %d:%s\n" % (p1, p1ctx))
1477 mergemod.clean_update(p1ctx)
1491 mergemod.clean_update(p1ctx)
1478 else:
1492 else:
1479 repo.ui.debug(b" already in destination\n")
1493 repo.ui.debug(b" already in destination\n")
1480 # This is, alas, necessary to invalidate workingctx's manifest cache,
1494 # This is, alas, necessary to invalidate workingctx's manifest cache,
1481 # as well as other data we litter on it in other places.
1495 # as well as other data we litter on it in other places.
1482 wctx = repo[None]
1496 wctx = repo[None]
1483 repo.dirstate.write(repo.currenttransaction())
1497 repo.dirstate.write(repo.currenttransaction())
1484 ctx = repo[rev]
1498 ctx = repo[rev]
1485 repo.ui.debug(b" merge against %d:%s\n" % (rev, ctx))
1499 repo.ui.debug(b" merge against %d:%s\n" % (rev, ctx))
1486 if base is not None:
1500 if base is not None:
1487 repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base]))
1501 repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base]))
1488
1502
1489 # See explanation in merge.graft()
1503 # See explanation in merge.graft()
1490 mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node())
1504 mergeancestor = repo.changelog.isancestor(p1ctx.node(), ctx.node())
1491 stats = mergemod.update(
1505 stats = mergemod.update(
1492 repo,
1506 repo,
1493 rev,
1507 rev,
1494 branchmerge=True,
1508 branchmerge=True,
1495 force=True,
1509 force=True,
1496 ancestor=base,
1510 ancestor=base,
1497 mergeancestor=mergeancestor,
1511 mergeancestor=mergeancestor,
1498 labels=[b'dest', b'source'],
1512 labels=[b'dest', b'source'],
1499 wc=wctx,
1513 wc=wctx,
1500 )
1514 )
1501 wctx.setparents(p1ctx.node(), repo[p2].node())
1515 wctx.setparents(p1ctx.node(), repo[p2].node())
1502 if collapse:
1516 if collapse:
1503 copies.graftcopies(wctx, ctx, repo[dest])
1517 copies.graftcopies(wctx, ctx, repo[dest])
1504 else:
1518 else:
1505 # If we're not using --collapse, we need to
1519 # If we're not using --collapse, we need to
1506 # duplicate copies between the revision we're
1520 # duplicate copies between the revision we're
1507 # rebasing and its first parent.
1521 # rebasing and its first parent.
1508 copies.graftcopies(wctx, ctx, ctx.p1())
1522 copies.graftcopies(wctx, ctx, ctx.p1())
1509 return stats
1523 return stats
1510
1524
1511
1525
1512 def adjustdest(repo, rev, destmap, state, skipped):
1526 def adjustdest(repo, rev, destmap, state, skipped):
1513 r"""adjust rebase destination given the current rebase state
1527 r"""adjust rebase destination given the current rebase state
1514
1528
1515 rev is what is being rebased. Return a list of two revs, which are the
1529 rev is what is being rebased. Return a list of two revs, which are the
1516 adjusted destinations for rev's p1 and p2, respectively. If a parent is
1530 adjusted destinations for rev's p1 and p2, respectively. If a parent is
1517 nullrev, return dest without adjustment for it.
1531 nullrev, return dest without adjustment for it.
1518
1532
1519 For example, when doing rebasing B+E to F, C to G, rebase will first move B
1533 For example, when doing rebasing B+E to F, C to G, rebase will first move B
1520 to B1, and E's destination will be adjusted from F to B1.
1534 to B1, and E's destination will be adjusted from F to B1.
1521
1535
1522 B1 <- written during rebasing B
1536 B1 <- written during rebasing B
1523 |
1537 |
1524 F <- original destination of B, E
1538 F <- original destination of B, E
1525 |
1539 |
1526 | E <- rev, which is being rebased
1540 | E <- rev, which is being rebased
1527 | |
1541 | |
1528 | D <- prev, one parent of rev being checked
1542 | D <- prev, one parent of rev being checked
1529 | |
1543 | |
1530 | x <- skipped, ex. no successor or successor in (::dest)
1544 | x <- skipped, ex. no successor or successor in (::dest)
1531 | |
1545 | |
1532 | C <- rebased as C', different destination
1546 | C <- rebased as C', different destination
1533 | |
1547 | |
1534 | B <- rebased as B1 C'
1548 | B <- rebased as B1 C'
1535 |/ |
1549 |/ |
1536 A G <- destination of C, different
1550 A G <- destination of C, different
1537
1551
1538 Another example about merge changeset, rebase -r C+G+H -d K, rebase will
1552 Another example about merge changeset, rebase -r C+G+H -d K, rebase will
1539 first move C to C1, G to G1, and when it's checking H, the adjusted
1553 first move C to C1, G to G1, and when it's checking H, the adjusted
1540 destinations will be [C1, G1].
1554 destinations will be [C1, G1].
1541
1555
1542 H C1 G1
1556 H C1 G1
1543 /| | /
1557 /| | /
1544 F G |/
1558 F G |/
1545 K | | -> K
1559 K | | -> K
1546 | C D |
1560 | C D |
1547 | |/ |
1561 | |/ |
1548 | B | ...
1562 | B | ...
1549 |/ |/
1563 |/ |/
1550 A A
1564 A A
1551
1565
1552 Besides, adjust dest according to existing rebase information. For example,
1566 Besides, adjust dest according to existing rebase information. For example,
1553
1567
1554 B C D B needs to be rebased on top of C, C needs to be rebased on top
1568 B C D B needs to be rebased on top of C, C needs to be rebased on top
1555 \|/ of D. We will rebase C first.
1569 \|/ of D. We will rebase C first.
1556 A
1570 A
1557
1571
1558 C' After rebasing C, when considering B's destination, use C'
1572 C' After rebasing C, when considering B's destination, use C'
1559 | instead of the original C.
1573 | instead of the original C.
1560 B D
1574 B D
1561 \ /
1575 \ /
1562 A
1576 A
1563 """
1577 """
1564 # pick already rebased revs with same dest from state as interesting source
1578 # pick already rebased revs with same dest from state as interesting source
1565 dest = destmap[rev]
1579 dest = destmap[rev]
1566 source = [
1580 source = [
1567 s
1581 s
1568 for s, d in state.items()
1582 for s, d in state.items()
1569 if d > 0 and destmap[s] == dest and s not in skipped
1583 if d > 0 and destmap[s] == dest and s not in skipped
1570 ]
1584 ]
1571
1585
1572 result = []
1586 result = []
1573 for prev in repo.changelog.parentrevs(rev):
1587 for prev in repo.changelog.parentrevs(rev):
1574 adjusted = dest
1588 adjusted = dest
1575 if prev != nullrev:
1589 if prev != nullrev:
1576 candidate = repo.revs(b'max(%ld and (::%d))', source, prev).first()
1590 candidate = repo.revs(b'max(%ld and (::%d))', source, prev).first()
1577 if candidate is not None:
1591 if candidate is not None:
1578 adjusted = state[candidate]
1592 adjusted = state[candidate]
1579 if adjusted == dest and dest in state:
1593 if adjusted == dest and dest in state:
1580 adjusted = state[dest]
1594 adjusted = state[dest]
1581 if adjusted == revtodo:
1595 if adjusted == revtodo:
1582 # sortsource should produce an order that makes this impossible
1596 # sortsource should produce an order that makes this impossible
1583 raise error.ProgrammingError(
1597 raise error.ProgrammingError(
1584 b'rev %d should be rebased already at this time' % dest
1598 b'rev %d should be rebased already at this time' % dest
1585 )
1599 )
1586 result.append(adjusted)
1600 result.append(adjusted)
1587 return result
1601 return result
1588
1602
1589
1603
1590 def _checkobsrebase(repo, ui, rebaseobsrevs, rebaseobsskipped):
1604 def _checkobsrebase(repo, ui, rebaseobsrevs, rebaseobsskipped):
1591 """
1605 """
1592 Abort if rebase will create divergence or rebase is noop because of markers
1606 Abort if rebase will create divergence or rebase is noop because of markers
1593
1607
1594 `rebaseobsrevs`: set of obsolete revision in source
1608 `rebaseobsrevs`: set of obsolete revision in source
1595 `rebaseobsskipped`: set of revisions from source skipped because they have
1609 `rebaseobsskipped`: set of revisions from source skipped because they have
1596 successors in destination or no non-obsolete successor.
1610 successors in destination or no non-obsolete successor.
1597 """
1611 """
1598 # Obsolete node with successors not in dest leads to divergence
1612 # Obsolete node with successors not in dest leads to divergence
1599 divergenceok = ui.configbool(b'experimental', b'evolution.allowdivergence')
1613 divergenceok = ui.configbool(b'experimental', b'evolution.allowdivergence')
1600 divergencebasecandidates = rebaseobsrevs - rebaseobsskipped
1614 divergencebasecandidates = rebaseobsrevs - rebaseobsskipped
1601
1615
1602 if divergencebasecandidates and not divergenceok:
1616 if divergencebasecandidates and not divergenceok:
1603 divhashes = (bytes(repo[r]) for r in divergencebasecandidates)
1617 divhashes = (bytes(repo[r]) for r in divergencebasecandidates)
1604 msg = _(b"this rebase will cause divergences from: %s")
1618 msg = _(b"this rebase will cause divergences from: %s")
1605 h = _(
1619 h = _(
1606 b"to force the rebase please set "
1620 b"to force the rebase please set "
1607 b"experimental.evolution.allowdivergence=True"
1621 b"experimental.evolution.allowdivergence=True"
1608 )
1622 )
1609 raise error.Abort(msg % (b",".join(divhashes),), hint=h)
1623 raise error.Abort(msg % (b",".join(divhashes),), hint=h)
1610
1624
1611
1625
1612 def successorrevs(unfi, rev):
1626 def successorrevs(unfi, rev):
1613 """yield revision numbers for successors of rev"""
1627 """yield revision numbers for successors of rev"""
1614 assert unfi.filtername is None
1628 assert unfi.filtername is None
1615 get_rev = unfi.changelog.index.get_rev
1629 get_rev = unfi.changelog.index.get_rev
1616 for s in obsutil.allsuccessors(unfi.obsstore, [unfi[rev].node()]):
1630 for s in obsutil.allsuccessors(unfi.obsstore, [unfi[rev].node()]):
1617 r = get_rev(s)
1631 r = get_rev(s)
1618 if r is not None:
1632 if r is not None:
1619 yield r
1633 yield r
1620
1634
1621
1635
1622 def defineparents(repo, rev, destmap, state, skipped, obsskipped):
1636 def defineparents(repo, rev, destmap, state, skipped, obsskipped):
1623 """Return new parents and optionally a merge base for rev being rebased
1637 """Return new parents and optionally a merge base for rev being rebased
1624
1638
1625 The destination specified by "dest" cannot always be used directly because
1639 The destination specified by "dest" cannot always be used directly because
1626 previously rebase result could affect destination. For example,
1640 previously rebase result could affect destination. For example,
1627
1641
1628 D E rebase -r C+D+E -d B
1642 D E rebase -r C+D+E -d B
1629 |/ C will be rebased to C'
1643 |/ C will be rebased to C'
1630 B C D's new destination will be C' instead of B
1644 B C D's new destination will be C' instead of B
1631 |/ E's new destination will be C' instead of B
1645 |/ E's new destination will be C' instead of B
1632 A
1646 A
1633
1647
1634 The new parents of a merge is slightly more complicated. See the comment
1648 The new parents of a merge is slightly more complicated. See the comment
1635 block below.
1649 block below.
1636 """
1650 """
1637 # use unfiltered changelog since successorrevs may return filtered nodes
1651 # use unfiltered changelog since successorrevs may return filtered nodes
1638 assert repo.filtername is None
1652 assert repo.filtername is None
1639 cl = repo.changelog
1653 cl = repo.changelog
1640 isancestor = cl.isancestorrev
1654 isancestor = cl.isancestorrev
1641
1655
1642 dest = destmap[rev]
1656 dest = destmap[rev]
1643 oldps = repo.changelog.parentrevs(rev) # old parents
1657 oldps = repo.changelog.parentrevs(rev) # old parents
1644 newps = [nullrev, nullrev] # new parents
1658 newps = [nullrev, nullrev] # new parents
1645 dests = adjustdest(repo, rev, destmap, state, skipped)
1659 dests = adjustdest(repo, rev, destmap, state, skipped)
1646 bases = list(oldps) # merge base candidates, initially just old parents
1660 bases = list(oldps) # merge base candidates, initially just old parents
1647
1661
1648 if all(r == nullrev for r in oldps[1:]):
1662 if all(r == nullrev for r in oldps[1:]):
1649 # For non-merge changeset, just move p to adjusted dest as requested.
1663 # For non-merge changeset, just move p to adjusted dest as requested.
1650 newps[0] = dests[0]
1664 newps[0] = dests[0]
1651 else:
1665 else:
1652 # For merge changeset, if we move p to dests[i] unconditionally, both
1666 # For merge changeset, if we move p to dests[i] unconditionally, both
1653 # parents may change and the end result looks like "the merge loses a
1667 # parents may change and the end result looks like "the merge loses a
1654 # parent", which is a surprise. This is a limit because "--dest" only
1668 # parent", which is a surprise. This is a limit because "--dest" only
1655 # accepts one dest per src.
1669 # accepts one dest per src.
1656 #
1670 #
1657 # Therefore, only move p with reasonable conditions (in this order):
1671 # Therefore, only move p with reasonable conditions (in this order):
1658 # 1. use dest, if dest is a descendent of (p or one of p's successors)
1672 # 1. use dest, if dest is a descendent of (p or one of p's successors)
1659 # 2. use p's rebased result, if p is rebased (state[p] > 0)
1673 # 2. use p's rebased result, if p is rebased (state[p] > 0)
1660 #
1674 #
1661 # Comparing with adjustdest, the logic here does some additional work:
1675 # Comparing with adjustdest, the logic here does some additional work:
1662 # 1. decide which parents will not be moved towards dest
1676 # 1. decide which parents will not be moved towards dest
1663 # 2. if the above decision is "no", should a parent still be moved
1677 # 2. if the above decision is "no", should a parent still be moved
1664 # because it was rebased?
1678 # because it was rebased?
1665 #
1679 #
1666 # For example:
1680 # For example:
1667 #
1681 #
1668 # C # "rebase -r C -d D" is an error since none of the parents
1682 # C # "rebase -r C -d D" is an error since none of the parents
1669 # /| # can be moved. "rebase -r B+C -d D" will move C's parent
1683 # /| # can be moved. "rebase -r B+C -d D" will move C's parent
1670 # A B D # B (using rule "2."), since B will be rebased.
1684 # A B D # B (using rule "2."), since B will be rebased.
1671 #
1685 #
1672 # The loop tries to be not rely on the fact that a Mercurial node has
1686 # The loop tries to be not rely on the fact that a Mercurial node has
1673 # at most 2 parents.
1687 # at most 2 parents.
1674 for i, p in enumerate(oldps):
1688 for i, p in enumerate(oldps):
1675 np = p # new parent
1689 np = p # new parent
1676 if any(isancestor(x, dests[i]) for x in successorrevs(repo, p)):
1690 if any(isancestor(x, dests[i]) for x in successorrevs(repo, p)):
1677 np = dests[i]
1691 np = dests[i]
1678 elif p in state and state[p] > 0:
1692 elif p in state and state[p] > 0:
1679 np = state[p]
1693 np = state[p]
1680
1694
1681 # If one parent becomes an ancestor of the other, drop the ancestor
1695 # If one parent becomes an ancestor of the other, drop the ancestor
1682 for j, x in enumerate(newps[:i]):
1696 for j, x in enumerate(newps[:i]):
1683 if x == nullrev:
1697 if x == nullrev:
1684 continue
1698 continue
1685 if isancestor(np, x): # CASE-1
1699 if isancestor(np, x): # CASE-1
1686 np = nullrev
1700 np = nullrev
1687 elif isancestor(x, np): # CASE-2
1701 elif isancestor(x, np): # CASE-2
1688 newps[j] = np
1702 newps[j] = np
1689 np = nullrev
1703 np = nullrev
1690 # New parents forming an ancestor relationship does not
1704 # New parents forming an ancestor relationship does not
1691 # mean the old parents have a similar relationship. Do not
1705 # mean the old parents have a similar relationship. Do not
1692 # set bases[x] to nullrev.
1706 # set bases[x] to nullrev.
1693 bases[j], bases[i] = bases[i], bases[j]
1707 bases[j], bases[i] = bases[i], bases[j]
1694
1708
1695 newps[i] = np
1709 newps[i] = np
1696
1710
1697 # "rebasenode" updates to new p1, and the old p1 will be used as merge
1711 # "rebasenode" updates to new p1, and the old p1 will be used as merge
1698 # base. If only p2 changes, merging using unchanged p1 as merge base is
1712 # base. If only p2 changes, merging using unchanged p1 as merge base is
1699 # suboptimal. Therefore swap parents to make the merge sane.
1713 # suboptimal. Therefore swap parents to make the merge sane.
1700 if newps[1] != nullrev and oldps[0] == newps[0]:
1714 if newps[1] != nullrev and oldps[0] == newps[0]:
1701 assert len(newps) == 2 and len(oldps) == 2
1715 assert len(newps) == 2 and len(oldps) == 2
1702 newps.reverse()
1716 newps.reverse()
1703 bases.reverse()
1717 bases.reverse()
1704
1718
1705 # No parent change might be an error because we fail to make rev a
1719 # No parent change might be an error because we fail to make rev a
1706 # descendent of requested dest. This can happen, for example:
1720 # descendent of requested dest. This can happen, for example:
1707 #
1721 #
1708 # C # rebase -r C -d D
1722 # C # rebase -r C -d D
1709 # /| # None of A and B will be changed to D and rebase fails.
1723 # /| # None of A and B will be changed to D and rebase fails.
1710 # A B D
1724 # A B D
1711 if set(newps) == set(oldps) and dest not in newps:
1725 if set(newps) == set(oldps) and dest not in newps:
1712 raise error.Abort(
1726 raise error.Abort(
1713 _(
1727 _(
1714 b'cannot rebase %d:%s without '
1728 b'cannot rebase %d:%s without '
1715 b'moving at least one of its parents'
1729 b'moving at least one of its parents'
1716 )
1730 )
1717 % (rev, repo[rev])
1731 % (rev, repo[rev])
1718 )
1732 )
1719
1733
1720 # Source should not be ancestor of dest. The check here guarantees it's
1734 # Source should not be ancestor of dest. The check here guarantees it's
1721 # impossible. With multi-dest, the initial check does not cover complex
1735 # impossible. With multi-dest, the initial check does not cover complex
1722 # cases since we don't have abstractions to dry-run rebase cheaply.
1736 # cases since we don't have abstractions to dry-run rebase cheaply.
1723 if any(p != nullrev and isancestor(rev, p) for p in newps):
1737 if any(p != nullrev and isancestor(rev, p) for p in newps):
1724 raise error.Abort(_(b'source is ancestor of destination'))
1738 raise error.Abort(_(b'source is ancestor of destination'))
1725
1739
1726 # Check if the merge will contain unwanted changes. That may happen if
1740 # Check if the merge will contain unwanted changes. That may happen if
1727 # there are multiple special (non-changelog ancestor) merge bases, which
1741 # there are multiple special (non-changelog ancestor) merge bases, which
1728 # cannot be handled well by the 3-way merge algorithm. For example:
1742 # cannot be handled well by the 3-way merge algorithm. For example:
1729 #
1743 #
1730 # F
1744 # F
1731 # /|
1745 # /|
1732 # D E # "rebase -r D+E+F -d Z", when rebasing F, if "D" was chosen
1746 # D E # "rebase -r D+E+F -d Z", when rebasing F, if "D" was chosen
1733 # | | # as merge base, the difference between D and F will include
1747 # | | # as merge base, the difference between D and F will include
1734 # B C # C, so the rebased F will contain C surprisingly. If "E" was
1748 # B C # C, so the rebased F will contain C surprisingly. If "E" was
1735 # |/ # chosen, the rebased F will contain B.
1749 # |/ # chosen, the rebased F will contain B.
1736 # A Z
1750 # A Z
1737 #
1751 #
1738 # But our merge base candidates (D and E in above case) could still be
1752 # But our merge base candidates (D and E in above case) could still be
1739 # better than the default (ancestor(F, Z) == null). Therefore still
1753 # better than the default (ancestor(F, Z) == null). Therefore still
1740 # pick one (so choose p1 above).
1754 # pick one (so choose p1 above).
1741 if sum(1 for b in set(bases) if b != nullrev and b not in newps) > 1:
1755 if sum(1 for b in set(bases) if b != nullrev and b not in newps) > 1:
1742 unwanted = [None, None] # unwanted[i]: unwanted revs if choose bases[i]
1756 unwanted = [None, None] # unwanted[i]: unwanted revs if choose bases[i]
1743 for i, base in enumerate(bases):
1757 for i, base in enumerate(bases):
1744 if base == nullrev or base in newps:
1758 if base == nullrev or base in newps:
1745 continue
1759 continue
1746 # Revisions in the side (not chosen as merge base) branch that
1760 # Revisions in the side (not chosen as merge base) branch that
1747 # might contain "surprising" contents
1761 # might contain "surprising" contents
1748 other_bases = set(bases) - {base}
1762 other_bases = set(bases) - {base}
1749 siderevs = list(
1763 siderevs = list(
1750 repo.revs(b'(%ld %% (%d+%d))', other_bases, base, dest)
1764 repo.revs(b'(%ld %% (%d+%d))', other_bases, base, dest)
1751 )
1765 )
1752
1766
1753 # If those revisions are covered by rebaseset, the result is good.
1767 # If those revisions are covered by rebaseset, the result is good.
1754 # A merge in rebaseset would be considered to cover its ancestors.
1768 # A merge in rebaseset would be considered to cover its ancestors.
1755 if siderevs:
1769 if siderevs:
1756 rebaseset = [
1770 rebaseset = [
1757 r for r, d in state.items() if d > 0 and r not in obsskipped
1771 r for r, d in state.items() if d > 0 and r not in obsskipped
1758 ]
1772 ]
1759 merges = [
1773 merges = [
1760 r for r in rebaseset if cl.parentrevs(r)[1] != nullrev
1774 r for r in rebaseset if cl.parentrevs(r)[1] != nullrev
1761 ]
1775 ]
1762 unwanted[i] = list(
1776 unwanted[i] = list(
1763 repo.revs(
1777 repo.revs(
1764 b'%ld - (::%ld) - %ld', siderevs, merges, rebaseset
1778 b'%ld - (::%ld) - %ld', siderevs, merges, rebaseset
1765 )
1779 )
1766 )
1780 )
1767
1781
1768 if any(revs is not None for revs in unwanted):
1782 if any(revs is not None for revs in unwanted):
1769 # Choose a merge base that has a minimal number of unwanted revs.
1783 # Choose a merge base that has a minimal number of unwanted revs.
1770 l, i = min(
1784 l, i = min(
1771 (len(revs), i)
1785 (len(revs), i)
1772 for i, revs in enumerate(unwanted)
1786 for i, revs in enumerate(unwanted)
1773 if revs is not None
1787 if revs is not None
1774 )
1788 )
1775
1789
1776 # The merge will include unwanted revisions. Abort now. Revisit this if
1790 # The merge will include unwanted revisions. Abort now. Revisit this if
1777 # we have a more advanced merge algorithm that handles multiple bases.
1791 # we have a more advanced merge algorithm that handles multiple bases.
1778 if l > 0:
1792 if l > 0:
1779 unwanteddesc = _(b' or ').join(
1793 unwanteddesc = _(b' or ').join(
1780 (
1794 (
1781 b', '.join(b'%d:%s' % (r, repo[r]) for r in revs)
1795 b', '.join(b'%d:%s' % (r, repo[r]) for r in revs)
1782 for revs in unwanted
1796 for revs in unwanted
1783 if revs is not None
1797 if revs is not None
1784 )
1798 )
1785 )
1799 )
1786 raise error.Abort(
1800 raise error.Abort(
1787 _(b'rebasing %d:%s will include unwanted changes from %s')
1801 _(b'rebasing %d:%s will include unwanted changes from %s')
1788 % (rev, repo[rev], unwanteddesc)
1802 % (rev, repo[rev], unwanteddesc)
1789 )
1803 )
1790
1804
1791 # newps[0] should match merge base if possible. Currently, if newps[i]
1805 # newps[0] should match merge base if possible. Currently, if newps[i]
1792 # is nullrev, the only case is newps[i] and newps[j] (j < i), one is
1806 # is nullrev, the only case is newps[i] and newps[j] (j < i), one is
1793 # the other's ancestor. In that case, it's fine to not swap newps here.
1807 # the other's ancestor. In that case, it's fine to not swap newps here.
1794 # (see CASE-1 and CASE-2 above)
1808 # (see CASE-1 and CASE-2 above)
1795 if i != 0:
1809 if i != 0:
1796 if newps[i] != nullrev:
1810 if newps[i] != nullrev:
1797 newps[0], newps[i] = newps[i], newps[0]
1811 newps[0], newps[i] = newps[i], newps[0]
1798 bases[0], bases[i] = bases[i], bases[0]
1812 bases[0], bases[i] = bases[i], bases[0]
1799
1813
1800 # "rebasenode" updates to new p1, use the corresponding merge base.
1814 # "rebasenode" updates to new p1, use the corresponding merge base.
1801 base = bases[0]
1815 base = bases[0]
1802
1816
1803 repo.ui.debug(b" future parents are %d and %d\n" % tuple(newps))
1817 repo.ui.debug(b" future parents are %d and %d\n" % tuple(newps))
1804
1818
1805 return newps[0], newps[1], base
1819 return newps[0], newps[1], base
1806
1820
1807
1821
1808 def isagitpatch(repo, patchname):
1822 def isagitpatch(repo, patchname):
1809 """Return true if the given patch is in git format"""
1823 """Return true if the given patch is in git format"""
1810 mqpatch = os.path.join(repo.mq.path, patchname)
1824 mqpatch = os.path.join(repo.mq.path, patchname)
1811 for line in patch.linereader(open(mqpatch, b'rb')):
1825 for line in patch.linereader(open(mqpatch, b'rb')):
1812 if line.startswith(b'diff --git'):
1826 if line.startswith(b'diff --git'):
1813 return True
1827 return True
1814 return False
1828 return False
1815
1829
1816
1830
1817 def updatemq(repo, state, skipped, **opts):
1831 def updatemq(repo, state, skipped, **opts):
1818 """Update rebased mq patches - finalize and then import them"""
1832 """Update rebased mq patches - finalize and then import them"""
1819 mqrebase = {}
1833 mqrebase = {}
1820 mq = repo.mq
1834 mq = repo.mq
1821 original_series = mq.fullseries[:]
1835 original_series = mq.fullseries[:]
1822 skippedpatches = set()
1836 skippedpatches = set()
1823
1837
1824 for p in mq.applied:
1838 for p in mq.applied:
1825 rev = repo[p.node].rev()
1839 rev = repo[p.node].rev()
1826 if rev in state:
1840 if rev in state:
1827 repo.ui.debug(
1841 repo.ui.debug(
1828 b'revision %d is an mq patch (%s), finalize it.\n'
1842 b'revision %d is an mq patch (%s), finalize it.\n'
1829 % (rev, p.name)
1843 % (rev, p.name)
1830 )
1844 )
1831 mqrebase[rev] = (p.name, isagitpatch(repo, p.name))
1845 mqrebase[rev] = (p.name, isagitpatch(repo, p.name))
1832 else:
1846 else:
1833 # Applied but not rebased, not sure this should happen
1847 # Applied but not rebased, not sure this should happen
1834 skippedpatches.add(p.name)
1848 skippedpatches.add(p.name)
1835
1849
1836 if mqrebase:
1850 if mqrebase:
1837 mq.finish(repo, mqrebase.keys())
1851 mq.finish(repo, mqrebase.keys())
1838
1852
1839 # We must start import from the newest revision
1853 # We must start import from the newest revision
1840 for rev in sorted(mqrebase, reverse=True):
1854 for rev in sorted(mqrebase, reverse=True):
1841 if rev not in skipped:
1855 if rev not in skipped:
1842 name, isgit = mqrebase[rev]
1856 name, isgit = mqrebase[rev]
1843 repo.ui.note(
1857 repo.ui.note(
1844 _(b'updating mq patch %s to %d:%s\n')
1858 _(b'updating mq patch %s to %d:%s\n')
1845 % (name, state[rev], repo[state[rev]])
1859 % (name, state[rev], repo[state[rev]])
1846 )
1860 )
1847 mq.qimport(
1861 mq.qimport(
1848 repo,
1862 repo,
1849 (),
1863 (),
1850 patchname=name,
1864 patchname=name,
1851 git=isgit,
1865 git=isgit,
1852 rev=[b"%d" % state[rev]],
1866 rev=[b"%d" % state[rev]],
1853 )
1867 )
1854 else:
1868 else:
1855 # Rebased and skipped
1869 # Rebased and skipped
1856 skippedpatches.add(mqrebase[rev][0])
1870 skippedpatches.add(mqrebase[rev][0])
1857
1871
1858 # Patches were either applied and rebased and imported in
1872 # Patches were either applied and rebased and imported in
1859 # order, applied and removed or unapplied. Discard the removed
1873 # order, applied and removed or unapplied. Discard the removed
1860 # ones while preserving the original series order and guards.
1874 # ones while preserving the original series order and guards.
1861 newseries = [
1875 newseries = [
1862 s
1876 s
1863 for s in original_series
1877 for s in original_series
1864 if mq.guard_re.split(s, 1)[0] not in skippedpatches
1878 if mq.guard_re.split(s, 1)[0] not in skippedpatches
1865 ]
1879 ]
1866 mq.fullseries[:] = newseries
1880 mq.fullseries[:] = newseries
1867 mq.seriesdirty = True
1881 mq.seriesdirty = True
1868 mq.savedirty()
1882 mq.savedirty()
1869
1883
1870
1884
1871 def storecollapsemsg(repo, collapsemsg):
1885 def storecollapsemsg(repo, collapsemsg):
1872 """Store the collapse message to allow recovery"""
1886 """Store the collapse message to allow recovery"""
1873 collapsemsg = collapsemsg or b''
1887 collapsemsg = collapsemsg or b''
1874 f = repo.vfs(b"last-message.txt", b"w")
1888 f = repo.vfs(b"last-message.txt", b"w")
1875 f.write(b"%s\n" % collapsemsg)
1889 f.write(b"%s\n" % collapsemsg)
1876 f.close()
1890 f.close()
1877
1891
1878
1892
1879 def clearcollapsemsg(repo):
1893 def clearcollapsemsg(repo):
1880 """Remove collapse message file"""
1894 """Remove collapse message file"""
1881 repo.vfs.unlinkpath(b"last-message.txt", ignoremissing=True)
1895 repo.vfs.unlinkpath(b"last-message.txt", ignoremissing=True)
1882
1896
1883
1897
1884 def restorecollapsemsg(repo, isabort):
1898 def restorecollapsemsg(repo, isabort):
1885 """Restore previously stored collapse message"""
1899 """Restore previously stored collapse message"""
1886 try:
1900 try:
1887 f = repo.vfs(b"last-message.txt")
1901 f = repo.vfs(b"last-message.txt")
1888 collapsemsg = f.readline().strip()
1902 collapsemsg = f.readline().strip()
1889 f.close()
1903 f.close()
1890 except IOError as err:
1904 except IOError as err:
1891 if err.errno != errno.ENOENT:
1905 if err.errno != errno.ENOENT:
1892 raise
1906 raise
1893 if isabort:
1907 if isabort:
1894 # Oh well, just abort like normal
1908 # Oh well, just abort like normal
1895 collapsemsg = b''
1909 collapsemsg = b''
1896 else:
1910 else:
1897 raise error.Abort(_(b'missing .hg/last-message.txt for rebase'))
1911 raise error.Abort(_(b'missing .hg/last-message.txt for rebase'))
1898 return collapsemsg
1912 return collapsemsg
1899
1913
1900
1914
1901 def clearstatus(repo):
1915 def clearstatus(repo):
1902 """Remove the status files"""
1916 """Remove the status files"""
1903 # Make sure the active transaction won't write the state file
1917 # Make sure the active transaction won't write the state file
1904 tr = repo.currenttransaction()
1918 tr = repo.currenttransaction()
1905 if tr:
1919 if tr:
1906 tr.removefilegenerator(b'rebasestate')
1920 tr.removefilegenerator(b'rebasestate')
1907 repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
1921 repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
1908
1922
1909
1923
1910 def sortsource(destmap):
1924 def sortsource(destmap):
1911 """yield source revisions in an order that we only rebase things once
1925 """yield source revisions in an order that we only rebase things once
1912
1926
1913 If source and destination overlaps, we should filter out revisions
1927 If source and destination overlaps, we should filter out revisions
1914 depending on other revisions which hasn't been rebased yet.
1928 depending on other revisions which hasn't been rebased yet.
1915
1929
1916 Yield a sorted list of revisions each time.
1930 Yield a sorted list of revisions each time.
1917
1931
1918 For example, when rebasing A to B, B to C. This function yields [B], then
1932 For example, when rebasing A to B, B to C. This function yields [B], then
1919 [A], indicating B needs to be rebased first.
1933 [A], indicating B needs to be rebased first.
1920
1934
1921 Raise if there is a cycle so the rebase is impossible.
1935 Raise if there is a cycle so the rebase is impossible.
1922 """
1936 """
1923 srcset = set(destmap)
1937 srcset = set(destmap)
1924 while srcset:
1938 while srcset:
1925 srclist = sorted(srcset)
1939 srclist = sorted(srcset)
1926 result = []
1940 result = []
1927 for r in srclist:
1941 for r in srclist:
1928 if destmap[r] not in srcset:
1942 if destmap[r] not in srcset:
1929 result.append(r)
1943 result.append(r)
1930 if not result:
1944 if not result:
1931 raise error.Abort(_(b'source and destination form a cycle'))
1945 raise error.Abort(_(b'source and destination form a cycle'))
1932 srcset -= set(result)
1946 srcset -= set(result)
1933 yield result
1947 yield result
1934
1948
1935
1949
1936 def buildstate(repo, destmap, collapse):
1950 def buildstate(repo, destmap, collapse):
1937 '''Define which revisions are going to be rebased and where
1951 '''Define which revisions are going to be rebased and where
1938
1952
1939 repo: repo
1953 repo: repo
1940 destmap: {srcrev: destrev}
1954 destmap: {srcrev: destrev}
1941 '''
1955 '''
1942 rebaseset = destmap.keys()
1956 rebaseset = destmap.keys()
1943 originalwd = repo[b'.'].rev()
1957 originalwd = repo[b'.'].rev()
1944
1958
1945 # This check isn't strictly necessary, since mq detects commits over an
1959 # This check isn't strictly necessary, since mq detects commits over an
1946 # applied patch. But it prevents messing up the working directory when
1960 # applied patch. But it prevents messing up the working directory when
1947 # a partially completed rebase is blocked by mq.
1961 # a partially completed rebase is blocked by mq.
1948 if b'qtip' in repo.tags():
1962 if b'qtip' in repo.tags():
1949 mqapplied = {repo[s.node].rev() for s in repo.mq.applied}
1963 mqapplied = {repo[s.node].rev() for s in repo.mq.applied}
1950 if set(destmap.values()) & mqapplied:
1964 if set(destmap.values()) & mqapplied:
1951 raise error.Abort(_(b'cannot rebase onto an applied mq patch'))
1965 raise error.Abort(_(b'cannot rebase onto an applied mq patch'))
1952
1966
1953 # Get "cycle" error early by exhausting the generator.
1967 # Get "cycle" error early by exhausting the generator.
1954 sortedsrc = list(sortsource(destmap)) # a list of sorted revs
1968 sortedsrc = list(sortsource(destmap)) # a list of sorted revs
1955 if not sortedsrc:
1969 if not sortedsrc:
1956 raise error.Abort(_(b'no matching revisions'))
1970 raise error.Abort(_(b'no matching revisions'))
1957
1971
1958 # Only check the first batch of revisions to rebase not depending on other
1972 # Only check the first batch of revisions to rebase not depending on other
1959 # rebaseset. This means "source is ancestor of destination" for the second
1973 # rebaseset. This means "source is ancestor of destination" for the second
1960 # (and following) batches of revisions are not checked here. We rely on
1974 # (and following) batches of revisions are not checked here. We rely on
1961 # "defineparents" to do that check.
1975 # "defineparents" to do that check.
1962 roots = list(repo.set(b'roots(%ld)', sortedsrc[0]))
1976 roots = list(repo.set(b'roots(%ld)', sortedsrc[0]))
1963 if not roots:
1977 if not roots:
1964 raise error.Abort(_(b'no matching revisions'))
1978 raise error.Abort(_(b'no matching revisions'))
1965
1979
1966 def revof(r):
1980 def revof(r):
1967 return r.rev()
1981 return r.rev()
1968
1982
1969 roots = sorted(roots, key=revof)
1983 roots = sorted(roots, key=revof)
1970 state = dict.fromkeys(rebaseset, revtodo)
1984 state = dict.fromkeys(rebaseset, revtodo)
1971 emptyrebase = len(sortedsrc) == 1
1985 emptyrebase = len(sortedsrc) == 1
1972 for root in roots:
1986 for root in roots:
1973 dest = repo[destmap[root.rev()]]
1987 dest = repo[destmap[root.rev()]]
1974 commonbase = root.ancestor(dest)
1988 commonbase = root.ancestor(dest)
1975 if commonbase == root:
1989 if commonbase == root:
1976 raise error.Abort(_(b'source is ancestor of destination'))
1990 raise error.Abort(_(b'source is ancestor of destination'))
1977 if commonbase == dest:
1991 if commonbase == dest:
1978 wctx = repo[None]
1992 wctx = repo[None]
1979 if dest == wctx.p1():
1993 if dest == wctx.p1():
1980 # when rebasing to '.', it will use the current wd branch name
1994 # when rebasing to '.', it will use the current wd branch name
1981 samebranch = root.branch() == wctx.branch()
1995 samebranch = root.branch() == wctx.branch()
1982 else:
1996 else:
1983 samebranch = root.branch() == dest.branch()
1997 samebranch = root.branch() == dest.branch()
1984 if not collapse and samebranch and dest in root.parents():
1998 if not collapse and samebranch and dest in root.parents():
1985 # mark the revision as done by setting its new revision
1999 # mark the revision as done by setting its new revision
1986 # equal to its old (current) revisions
2000 # equal to its old (current) revisions
1987 state[root.rev()] = root.rev()
2001 state[root.rev()] = root.rev()
1988 repo.ui.debug(b'source is a child of destination\n')
2002 repo.ui.debug(b'source is a child of destination\n')
1989 continue
2003 continue
1990
2004
1991 emptyrebase = False
2005 emptyrebase = False
1992 repo.ui.debug(b'rebase onto %s starting from %s\n' % (dest, root))
2006 repo.ui.debug(b'rebase onto %s starting from %s\n' % (dest, root))
1993 if emptyrebase:
2007 if emptyrebase:
1994 return None
2008 return None
1995 for rev in sorted(state):
2009 for rev in sorted(state):
1996 parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev]
2010 parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev]
1997 # if all parents of this revision are done, then so is this revision
2011 # if all parents of this revision are done, then so is this revision
1998 if parents and all((state.get(p) == p for p in parents)):
2012 if parents and all((state.get(p) == p for p in parents)):
1999 state[rev] = rev
2013 state[rev] = rev
2000 return originalwd, destmap, state
2014 return originalwd, destmap, state
2001
2015
2002
2016
2003 def clearrebased(
2017 def clearrebased(
2004 ui,
2018 ui,
2005 repo,
2019 repo,
2006 destmap,
2020 destmap,
2007 state,
2021 state,
2008 skipped,
2022 skipped,
2009 collapsedas=None,
2023 collapsedas=None,
2010 keepf=False,
2024 keepf=False,
2011 fm=None,
2025 fm=None,
2012 backup=True,
2026 backup=True,
2013 ):
2027 ):
2014 """dispose of rebased revision at the end of the rebase
2028 """dispose of rebased revision at the end of the rebase
2015
2029
2016 If `collapsedas` is not None, the rebase was a collapse whose result if the
2030 If `collapsedas` is not None, the rebase was a collapse whose result if the
2017 `collapsedas` node.
2031 `collapsedas` node.
2018
2032
2019 If `keepf` is not True, the rebase has --keep set and no nodes should be
2033 If `keepf` is not True, the rebase has --keep set and no nodes should be
2020 removed (but bookmarks still need to be moved).
2034 removed (but bookmarks still need to be moved).
2021
2035
2022 If `backup` is False, no backup will be stored when stripping rebased
2036 If `backup` is False, no backup will be stored when stripping rebased
2023 revisions.
2037 revisions.
2024 """
2038 """
2025 tonode = repo.changelog.node
2039 tonode = repo.changelog.node
2026 replacements = {}
2040 replacements = {}
2027 moves = {}
2041 moves = {}
2028 stripcleanup = not obsolete.isenabled(repo, obsolete.createmarkersopt)
2042 stripcleanup = not obsolete.isenabled(repo, obsolete.createmarkersopt)
2029
2043
2030 collapsednodes = []
2044 collapsednodes = []
2031 for rev, newrev in sorted(state.items()):
2045 for rev, newrev in sorted(state.items()):
2032 if newrev >= 0 and newrev != rev:
2046 if newrev >= 0 and newrev != rev:
2033 oldnode = tonode(rev)
2047 oldnode = tonode(rev)
2034 newnode = collapsedas or tonode(newrev)
2048 newnode = collapsedas or tonode(newrev)
2035 moves[oldnode] = newnode
2049 moves[oldnode] = newnode
2036 succs = None
2050 succs = None
2037 if rev in skipped:
2051 if rev in skipped:
2038 if stripcleanup or not repo[rev].obsolete():
2052 if stripcleanup or not repo[rev].obsolete():
2039 succs = ()
2053 succs = ()
2040 elif collapsedas:
2054 elif collapsedas:
2041 collapsednodes.append(oldnode)
2055 collapsednodes.append(oldnode)
2042 else:
2056 else:
2043 succs = (newnode,)
2057 succs = (newnode,)
2044 if succs is not None:
2058 if succs is not None:
2045 replacements[(oldnode,)] = succs
2059 replacements[(oldnode,)] = succs
2046 if collapsednodes:
2060 if collapsednodes:
2047 replacements[tuple(collapsednodes)] = (collapsedas,)
2061 replacements[tuple(collapsednodes)] = (collapsedas,)
2048 if fm:
2062 if fm:
2049 hf = fm.hexfunc
2063 hf = fm.hexfunc
2050 fl = fm.formatlist
2064 fl = fm.formatlist
2051 fd = fm.formatdict
2065 fd = fm.formatdict
2052 changes = {}
2066 changes = {}
2053 for oldns, newn in pycompat.iteritems(replacements):
2067 for oldns, newn in pycompat.iteritems(replacements):
2054 for oldn in oldns:
2068 for oldn in oldns:
2055 changes[hf(oldn)] = fl([hf(n) for n in newn], name=b'node')
2069 changes[hf(oldn)] = fl([hf(n) for n in newn], name=b'node')
2056 nodechanges = fd(changes, key=b"oldnode", value=b"newnodes")
2070 nodechanges = fd(changes, key=b"oldnode", value=b"newnodes")
2057 fm.data(nodechanges=nodechanges)
2071 fm.data(nodechanges=nodechanges)
2058 if keepf:
2072 if keepf:
2059 replacements = {}
2073 replacements = {}
2060 scmutil.cleanupnodes(repo, replacements, b'rebase', moves, backup=backup)
2074 scmutil.cleanupnodes(repo, replacements, b'rebase', moves, backup=backup)
2061
2075
2062
2076
2063 def pullrebase(orig, ui, repo, *args, **opts):
2077 def pullrebase(orig, ui, repo, *args, **opts):
2064 """Call rebase after pull if the latter has been invoked with --rebase"""
2078 """Call rebase after pull if the latter has been invoked with --rebase"""
2065 if opts.get('rebase'):
2079 if opts.get('rebase'):
2066 if ui.configbool(b'commands', b'rebase.requiredest'):
2080 if ui.configbool(b'commands', b'rebase.requiredest'):
2067 msg = _(b'rebase destination required by configuration')
2081 msg = _(b'rebase destination required by configuration')
2068 hint = _(b'use hg pull followed by hg rebase -d DEST')
2082 hint = _(b'use hg pull followed by hg rebase -d DEST')
2069 raise error.Abort(msg, hint=hint)
2083 raise error.Abort(msg, hint=hint)
2070
2084
2071 with repo.wlock(), repo.lock():
2085 with repo.wlock(), repo.lock():
2072 if opts.get('update'):
2086 if opts.get('update'):
2073 del opts['update']
2087 del opts['update']
2074 ui.debug(
2088 ui.debug(
2075 b'--update and --rebase are not compatible, ignoring '
2089 b'--update and --rebase are not compatible, ignoring '
2076 b'the update flag\n'
2090 b'the update flag\n'
2077 )
2091 )
2078
2092
2079 cmdutil.checkunfinished(repo, skipmerge=True)
2093 cmdutil.checkunfinished(repo, skipmerge=True)
2080 cmdutil.bailifchanged(
2094 cmdutil.bailifchanged(
2081 repo,
2095 repo,
2082 hint=_(
2096 hint=_(
2083 b'cannot pull with rebase: '
2097 b'cannot pull with rebase: '
2084 b'please commit or shelve your changes first'
2098 b'please commit or shelve your changes first'
2085 ),
2099 ),
2086 )
2100 )
2087
2101
2088 revsprepull = len(repo)
2102 revsprepull = len(repo)
2089 origpostincoming = commands.postincoming
2103 origpostincoming = commands.postincoming
2090
2104
2091 def _dummy(*args, **kwargs):
2105 def _dummy(*args, **kwargs):
2092 pass
2106 pass
2093
2107
2094 commands.postincoming = _dummy
2108 commands.postincoming = _dummy
2095 try:
2109 try:
2096 ret = orig(ui, repo, *args, **opts)
2110 ret = orig(ui, repo, *args, **opts)
2097 finally:
2111 finally:
2098 commands.postincoming = origpostincoming
2112 commands.postincoming = origpostincoming
2099 revspostpull = len(repo)
2113 revspostpull = len(repo)
2100 if revspostpull > revsprepull:
2114 if revspostpull > revsprepull:
2101 # --rev option from pull conflict with rebase own --rev
2115 # --rev option from pull conflict with rebase own --rev
2102 # dropping it
2116 # dropping it
2103 if 'rev' in opts:
2117 if 'rev' in opts:
2104 del opts['rev']
2118 del opts['rev']
2105 # positional argument from pull conflicts with rebase's own
2119 # positional argument from pull conflicts with rebase's own
2106 # --source.
2120 # --source.
2107 if 'source' in opts:
2121 if 'source' in opts:
2108 del opts['source']
2122 del opts['source']
2109 # revsprepull is the len of the repo, not revnum of tip.
2123 # revsprepull is the len of the repo, not revnum of tip.
2110 destspace = list(repo.changelog.revs(start=revsprepull))
2124 destspace = list(repo.changelog.revs(start=revsprepull))
2111 opts['_destspace'] = destspace
2125 opts['_destspace'] = destspace
2112 try:
2126 try:
2113 rebase(ui, repo, **opts)
2127 rebase(ui, repo, **opts)
2114 except error.NoMergeDestAbort:
2128 except error.NoMergeDestAbort:
2115 # we can maybe update instead
2129 # we can maybe update instead
2116 rev, _a, _b = destutil.destupdate(repo)
2130 rev, _a, _b = destutil.destupdate(repo)
2117 if rev == repo[b'.'].rev():
2131 if rev == repo[b'.'].rev():
2118 ui.status(_(b'nothing to rebase\n'))
2132 ui.status(_(b'nothing to rebase\n'))
2119 else:
2133 else:
2120 ui.status(_(b'nothing to rebase - updating instead\n'))
2134 ui.status(_(b'nothing to rebase - updating instead\n'))
2121 # not passing argument to get the bare update behavior
2135 # not passing argument to get the bare update behavior
2122 # with warning and trumpets
2136 # with warning and trumpets
2123 commands.update(ui, repo)
2137 commands.update(ui, repo)
2124 else:
2138 else:
2125 if opts.get('tool'):
2139 if opts.get('tool'):
2126 raise error.Abort(_(b'--tool can only be used with --rebase'))
2140 raise error.Abort(_(b'--tool can only be used with --rebase'))
2127 ret = orig(ui, repo, *args, **opts)
2141 ret = orig(ui, repo, *args, **opts)
2128
2142
2129 return ret
2143 return ret
2130
2144
2131
2145
2132 def _filterobsoleterevs(repo, revs):
2146 def _filterobsoleterevs(repo, revs):
2133 """returns a set of the obsolete revisions in revs"""
2147 """returns a set of the obsolete revisions in revs"""
2134 return {r for r in revs if repo[r].obsolete()}
2148 return {r for r in revs if repo[r].obsolete()}
2135
2149
2136
2150
2137 def _computeobsoletenotrebased(repo, rebaseobsrevs, destmap):
2151 def _computeobsoletenotrebased(repo, rebaseobsrevs, destmap):
2138 """Return (obsoletenotrebased, obsoletewithoutsuccessorindestination).
2152 """Return (obsoletenotrebased, obsoletewithoutsuccessorindestination).
2139
2153
2140 `obsoletenotrebased` is a mapping mapping obsolete => successor for all
2154 `obsoletenotrebased` is a mapping mapping obsolete => successor for all
2141 obsolete nodes to be rebased given in `rebaseobsrevs`.
2155 obsolete nodes to be rebased given in `rebaseobsrevs`.
2142
2156
2143 `obsoletewithoutsuccessorindestination` is a set with obsolete revisions
2157 `obsoletewithoutsuccessorindestination` is a set with obsolete revisions
2144 without a successor in destination.
2158 without a successor in destination.
2145
2159
2146 `obsoleteextinctsuccessors` is a set of obsolete revisions with only
2160 `obsoleteextinctsuccessors` is a set of obsolete revisions with only
2147 obsolete successors.
2161 obsolete successors.
2148 """
2162 """
2149 obsoletenotrebased = {}
2163 obsoletenotrebased = {}
2150 obsoletewithoutsuccessorindestination = set()
2164 obsoletewithoutsuccessorindestination = set()
2151 obsoleteextinctsuccessors = set()
2165 obsoleteextinctsuccessors = set()
2152
2166
2153 assert repo.filtername is None
2167 assert repo.filtername is None
2154 cl = repo.changelog
2168 cl = repo.changelog
2155 get_rev = cl.index.get_rev
2169 get_rev = cl.index.get_rev
2156 extinctrevs = set(repo.revs(b'extinct()'))
2170 extinctrevs = set(repo.revs(b'extinct()'))
2157 for srcrev in rebaseobsrevs:
2171 for srcrev in rebaseobsrevs:
2158 srcnode = cl.node(srcrev)
2172 srcnode = cl.node(srcrev)
2159 # XXX: more advanced APIs are required to handle split correctly
2173 # XXX: more advanced APIs are required to handle split correctly
2160 successors = set(obsutil.allsuccessors(repo.obsstore, [srcnode]))
2174 successors = set(obsutil.allsuccessors(repo.obsstore, [srcnode]))
2161 # obsutil.allsuccessors includes node itself
2175 # obsutil.allsuccessors includes node itself
2162 successors.remove(srcnode)
2176 successors.remove(srcnode)
2163 succrevs = {get_rev(s) for s in successors}
2177 succrevs = {get_rev(s) for s in successors}
2164 succrevs.discard(None)
2178 succrevs.discard(None)
2165 if succrevs.issubset(extinctrevs):
2179 if succrevs.issubset(extinctrevs):
2166 # all successors are extinct
2180 # all successors are extinct
2167 obsoleteextinctsuccessors.add(srcrev)
2181 obsoleteextinctsuccessors.add(srcrev)
2168 if not successors:
2182 if not successors:
2169 # no successor
2183 # no successor
2170 obsoletenotrebased[srcrev] = None
2184 obsoletenotrebased[srcrev] = None
2171 else:
2185 else:
2172 dstrev = destmap[srcrev]
2186 dstrev = destmap[srcrev]
2173 for succrev in succrevs:
2187 for succrev in succrevs:
2174 if cl.isancestorrev(succrev, dstrev):
2188 if cl.isancestorrev(succrev, dstrev):
2175 obsoletenotrebased[srcrev] = succrev
2189 obsoletenotrebased[srcrev] = succrev
2176 break
2190 break
2177 else:
2191 else:
2178 # If 'srcrev' has a successor in rebase set but none in
2192 # If 'srcrev' has a successor in rebase set but none in
2179 # destination (which would be catched above), we shall skip it
2193 # destination (which would be catched above), we shall skip it
2180 # and its descendants to avoid divergence.
2194 # and its descendants to avoid divergence.
2181 if srcrev in extinctrevs or any(s in destmap for s in succrevs):
2195 if srcrev in extinctrevs or any(s in destmap for s in succrevs):
2182 obsoletewithoutsuccessorindestination.add(srcrev)
2196 obsoletewithoutsuccessorindestination.add(srcrev)
2183
2197
2184 return (
2198 return (
2185 obsoletenotrebased,
2199 obsoletenotrebased,
2186 obsoletewithoutsuccessorindestination,
2200 obsoletewithoutsuccessorindestination,
2187 obsoleteextinctsuccessors,
2201 obsoleteextinctsuccessors,
2188 )
2202 )
2189
2203
2190
2204
2191 def abortrebase(ui, repo):
2205 def abortrebase(ui, repo):
2192 with repo.wlock(), repo.lock():
2206 with repo.wlock(), repo.lock():
2193 rbsrt = rebaseruntime(repo, ui)
2207 rbsrt = rebaseruntime(repo, ui)
2194 rbsrt._prepareabortorcontinue(isabort=True)
2208 rbsrt._prepareabortorcontinue(isabort=True)
2195
2209
2196
2210
2197 def continuerebase(ui, repo):
2211 def continuerebase(ui, repo):
2198 with repo.wlock(), repo.lock():
2212 with repo.wlock(), repo.lock():
2199 rbsrt = rebaseruntime(repo, ui)
2213 rbsrt = rebaseruntime(repo, ui)
2200 ms = mergestatemod.mergestate.read(repo)
2214 ms = mergestatemod.mergestate.read(repo)
2201 mergeutil.checkunresolved(ms)
2215 mergeutil.checkunresolved(ms)
2202 retcode = rbsrt._prepareabortorcontinue(isabort=False)
2216 retcode = rbsrt._prepareabortorcontinue(isabort=False)
2203 if retcode is not None:
2217 if retcode is not None:
2204 return retcode
2218 return retcode
2205 rbsrt._performrebase(None)
2219 rbsrt._performrebase(None)
2206 rbsrt._finishrebase()
2220 rbsrt._finishrebase()
2207
2221
2208
2222
2209 def summaryhook(ui, repo):
2223 def summaryhook(ui, repo):
2210 if not repo.vfs.exists(b'rebasestate'):
2224 if not repo.vfs.exists(b'rebasestate'):
2211 return
2225 return
2212 try:
2226 try:
2213 rbsrt = rebaseruntime(repo, ui, {})
2227 rbsrt = rebaseruntime(repo, ui, {})
2214 rbsrt.restorestatus()
2228 rbsrt.restorestatus()
2215 state = rbsrt.state
2229 state = rbsrt.state
2216 except error.RepoLookupError:
2230 except error.RepoLookupError:
2217 # i18n: column positioning for "hg summary"
2231 # i18n: column positioning for "hg summary"
2218 msg = _(b'rebase: (use "hg rebase --abort" to clear broken state)\n')
2232 msg = _(b'rebase: (use "hg rebase --abort" to clear broken state)\n')
2219 ui.write(msg)
2233 ui.write(msg)
2220 return
2234 return
2221 numrebased = len([i for i in pycompat.itervalues(state) if i >= 0])
2235 numrebased = len([i for i in pycompat.itervalues(state) if i >= 0])
2222 # i18n: column positioning for "hg summary"
2236 # i18n: column positioning for "hg summary"
2223 ui.write(
2237 ui.write(
2224 _(b'rebase: %s, %s (rebase --continue)\n')
2238 _(b'rebase: %s, %s (rebase --continue)\n')
2225 % (
2239 % (
2226 ui.label(_(b'%d rebased'), b'rebase.rebased') % numrebased,
2240 ui.label(_(b'%d rebased'), b'rebase.rebased') % numrebased,
2227 ui.label(_(b'%d remaining'), b'rebase.remaining')
2241 ui.label(_(b'%d remaining'), b'rebase.remaining')
2228 % (len(state) - numrebased),
2242 % (len(state) - numrebased),
2229 )
2243 )
2230 )
2244 )
2231
2245
2232
2246
2233 def uisetup(ui):
2247 def uisetup(ui):
2234 # Replace pull with a decorator to provide --rebase option
2248 # Replace pull with a decorator to provide --rebase option
2235 entry = extensions.wrapcommand(commands.table, b'pull', pullrebase)
2249 entry = extensions.wrapcommand(commands.table, b'pull', pullrebase)
2236 entry[1].append(
2250 entry[1].append(
2237 (b'', b'rebase', None, _(b"rebase working directory to branch head"))
2251 (b'', b'rebase', None, _(b"rebase working directory to branch head"))
2238 )
2252 )
2239 entry[1].append((b't', b'tool', b'', _(b"specify merge tool for rebase")))
2253 entry[1].append((b't', b'tool', b'', _(b"specify merge tool for rebase")))
2240 cmdutil.summaryhooks.add(b'rebase', summaryhook)
2254 cmdutil.summaryhooks.add(b'rebase', summaryhook)
2241 statemod.addunfinished(
2255 statemod.addunfinished(
2242 b'rebase',
2256 b'rebase',
2243 fname=b'rebasestate',
2257 fname=b'rebasestate',
2244 stopflag=True,
2258 stopflag=True,
2245 continueflag=True,
2259 continueflag=True,
2246 abortfunc=abortrebase,
2260 abortfunc=abortrebase,
2247 continuefunc=continuerebase,
2261 continuefunc=continuerebase,
2248 )
2262 )
@@ -1,2906 +1,2907 b''
1 The Mercurial system uses a set of configuration files to control
1 The Mercurial system uses a set of configuration files to control
2 aspects of its behavior.
2 aspects of its behavior.
3
3
4 Troubleshooting
4 Troubleshooting
5 ===============
5 ===============
6
6
7 If you're having problems with your configuration,
7 If you're having problems with your configuration,
8 :hg:`config --debug` can help you understand what is introducing
8 :hg:`config --debug` can help you understand what is introducing
9 a setting into your environment.
9 a setting into your environment.
10
10
11 See :hg:`help config.syntax` and :hg:`help config.files`
11 See :hg:`help config.syntax` and :hg:`help config.files`
12 for information about how and where to override things.
12 for information about how and where to override things.
13
13
14 Structure
14 Structure
15 =========
15 =========
16
16
17 The configuration files use a simple ini-file format. A configuration
17 The configuration files use a simple ini-file format. A configuration
18 file consists of sections, led by a ``[section]`` header and followed
18 file consists of sections, led by a ``[section]`` header and followed
19 by ``name = value`` entries::
19 by ``name = value`` entries::
20
20
21 [ui]
21 [ui]
22 username = Firstname Lastname <firstname.lastname@example.net>
22 username = Firstname Lastname <firstname.lastname@example.net>
23 verbose = True
23 verbose = True
24
24
25 The above entries will be referred to as ``ui.username`` and
25 The above entries will be referred to as ``ui.username`` and
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27
27
28 Files
28 Files
29 =====
29 =====
30
30
31 Mercurial reads configuration data from several files, if they exist.
31 Mercurial reads configuration data from several files, if they exist.
32 These files do not exist by default and you will have to create the
32 These files do not exist by default and you will have to create the
33 appropriate configuration files yourself:
33 appropriate configuration files yourself:
34
34
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36
36
37 Global configuration like the username setting is typically put into:
37 Global configuration like the username setting is typically put into:
38
38
39 .. container:: windows
39 .. container:: windows
40
40
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42
42
43 .. container:: unix.plan9
43 .. container:: unix.plan9
44
44
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46
46
47 The names of these files depend on the system on which Mercurial is
47 The names of these files depend on the system on which Mercurial is
48 installed. ``*.rc`` files from a single directory are read in
48 installed. ``*.rc`` files from a single directory are read in
49 alphabetical order, later ones overriding earlier ones. Where multiple
49 alphabetical order, later ones overriding earlier ones. Where multiple
50 paths are given below, settings from earlier paths override later
50 paths are given below, settings from earlier paths override later
51 ones.
51 ones.
52
52
53 .. container:: verbose.unix
53 .. container:: verbose.unix
54
54
55 On Unix, the following files are consulted:
55 On Unix, the following files are consulted:
56
56
57 - ``<repo>/.hg/hgrc`` (per-repository)
57 - ``<repo>/.hg/hgrc`` (per-repository)
58 - ``$HOME/.hgrc`` (per-user)
58 - ``$HOME/.hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 - ``/etc/mercurial/hgrc`` (per-system)
62 - ``/etc/mercurial/hgrc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 - ``<internal>/*.rc`` (defaults)
64 - ``<internal>/*.rc`` (defaults)
65
65
66 .. container:: verbose.windows
66 .. container:: verbose.windows
67
67
68 On Windows, the following files are consulted:
68 On Windows, the following files are consulted:
69
69
70 - ``<repo>/.hg/hgrc`` (per-repository)
70 - ``<repo>/.hg/hgrc`` (per-repository)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
78 - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
79 - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
79 - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
80 - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
80 - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
81 - ``<internal>/*.rc`` (defaults)
81 - ``<internal>/*.rc`` (defaults)
82
82
83 .. note::
83 .. note::
84
84
85 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
85 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
86 is used when running 32-bit Python on 64-bit Windows.
86 is used when running 32-bit Python on 64-bit Windows.
87
87
88 .. container:: verbose.plan9
88 .. container:: verbose.plan9
89
89
90 On Plan9, the following files are consulted:
90 On Plan9, the following files are consulted:
91
91
92 - ``<repo>/.hg/hgrc`` (per-repository)
92 - ``<repo>/.hg/hgrc`` (per-repository)
93 - ``$home/lib/hgrc`` (per-user)
93 - ``$home/lib/hgrc`` (per-user)
94 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
94 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
95 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
95 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
96 - ``/lib/mercurial/hgrc`` (per-system)
96 - ``/lib/mercurial/hgrc`` (per-system)
97 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
97 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
98 - ``<internal>/*.rc`` (defaults)
98 - ``<internal>/*.rc`` (defaults)
99
99
100 Per-repository configuration options only apply in a
100 Per-repository configuration options only apply in a
101 particular repository. This file is not version-controlled, and
101 particular repository. This file is not version-controlled, and
102 will not get transferred during a "clone" operation. Options in
102 will not get transferred during a "clone" operation. Options in
103 this file override options in all other configuration files.
103 this file override options in all other configuration files.
104
104
105 .. container:: unix.plan9
105 .. container:: unix.plan9
106
106
107 On Plan 9 and Unix, most of this file will be ignored if it doesn't
107 On Plan 9 and Unix, most of this file will be ignored if it doesn't
108 belong to a trusted user or to a trusted group. See
108 belong to a trusted user or to a trusted group. See
109 :hg:`help config.trusted` for more details.
109 :hg:`help config.trusted` for more details.
110
110
111 Per-user configuration file(s) are for the user running Mercurial. Options
111 Per-user configuration file(s) are for the user running Mercurial. Options
112 in these files apply to all Mercurial commands executed by this user in any
112 in these files apply to all Mercurial commands executed by this user in any
113 directory. Options in these files override per-system and per-installation
113 directory. Options in these files override per-system and per-installation
114 options.
114 options.
115
115
116 Per-installation configuration files are searched for in the
116 Per-installation configuration files are searched for in the
117 directory where Mercurial is installed. ``<install-root>`` is the
117 directory where Mercurial is installed. ``<install-root>`` is the
118 parent directory of the **hg** executable (or symlink) being run.
118 parent directory of the **hg** executable (or symlink) being run.
119
119
120 .. container:: unix.plan9
120 .. container:: unix.plan9
121
121
122 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
122 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
123 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
123 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
124 files apply to all Mercurial commands executed by any user in any
124 files apply to all Mercurial commands executed by any user in any
125 directory.
125 directory.
126
126
127 Per-installation configuration files are for the system on
127 Per-installation configuration files are for the system on
128 which Mercurial is running. Options in these files apply to all
128 which Mercurial is running. Options in these files apply to all
129 Mercurial commands executed by any user in any directory. Registry
129 Mercurial commands executed by any user in any directory. Registry
130 keys contain PATH-like strings, every part of which must reference
130 keys contain PATH-like strings, every part of which must reference
131 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
131 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
132 be read. Mercurial checks each of these locations in the specified
132 be read. Mercurial checks each of these locations in the specified
133 order until one or more configuration files are detected.
133 order until one or more configuration files are detected.
134
134
135 Per-system configuration files are for the system on which Mercurial
135 Per-system configuration files are for the system on which Mercurial
136 is running. Options in these files apply to all Mercurial commands
136 is running. Options in these files apply to all Mercurial commands
137 executed by any user in any directory. Options in these files
137 executed by any user in any directory. Options in these files
138 override per-installation options.
138 override per-installation options.
139
139
140 Mercurial comes with some default configuration. The default configuration
140 Mercurial comes with some default configuration. The default configuration
141 files are installed with Mercurial and will be overwritten on upgrades. Default
141 files are installed with Mercurial and will be overwritten on upgrades. Default
142 configuration files should never be edited by users or administrators but can
142 configuration files should never be edited by users or administrators but can
143 be overridden in other configuration files. So far the directory only contains
143 be overridden in other configuration files. So far the directory only contains
144 merge tool configuration but packagers can also put other default configuration
144 merge tool configuration but packagers can also put other default configuration
145 there.
145 there.
146
146
147 Syntax
147 Syntax
148 ======
148 ======
149
149
150 A configuration file consists of sections, led by a ``[section]`` header
150 A configuration file consists of sections, led by a ``[section]`` header
151 and followed by ``name = value`` entries (sometimes called
151 and followed by ``name = value`` entries (sometimes called
152 ``configuration keys``)::
152 ``configuration keys``)::
153
153
154 [spam]
154 [spam]
155 eggs=ham
155 eggs=ham
156 green=
156 green=
157 eggs
157 eggs
158
158
159 Each line contains one entry. If the lines that follow are indented,
159 Each line contains one entry. If the lines that follow are indented,
160 they are treated as continuations of that entry. Leading whitespace is
160 they are treated as continuations of that entry. Leading whitespace is
161 removed from values. Empty lines are skipped. Lines beginning with
161 removed from values. Empty lines are skipped. Lines beginning with
162 ``#`` or ``;`` are ignored and may be used to provide comments.
162 ``#`` or ``;`` are ignored and may be used to provide comments.
163
163
164 Configuration keys can be set multiple times, in which case Mercurial
164 Configuration keys can be set multiple times, in which case Mercurial
165 will use the value that was configured last. As an example::
165 will use the value that was configured last. As an example::
166
166
167 [spam]
167 [spam]
168 eggs=large
168 eggs=large
169 ham=serrano
169 ham=serrano
170 eggs=small
170 eggs=small
171
171
172 This would set the configuration key named ``eggs`` to ``small``.
172 This would set the configuration key named ``eggs`` to ``small``.
173
173
174 It is also possible to define a section multiple times. A section can
174 It is also possible to define a section multiple times. A section can
175 be redefined on the same and/or on different configuration files. For
175 be redefined on the same and/or on different configuration files. For
176 example::
176 example::
177
177
178 [foo]
178 [foo]
179 eggs=large
179 eggs=large
180 ham=serrano
180 ham=serrano
181 eggs=small
181 eggs=small
182
182
183 [bar]
183 [bar]
184 eggs=ham
184 eggs=ham
185 green=
185 green=
186 eggs
186 eggs
187
187
188 [foo]
188 [foo]
189 ham=prosciutto
189 ham=prosciutto
190 eggs=medium
190 eggs=medium
191 bread=toasted
191 bread=toasted
192
192
193 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
193 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
194 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
194 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
195 respectively. As you can see there only thing that matters is the last
195 respectively. As you can see there only thing that matters is the last
196 value that was set for each of the configuration keys.
196 value that was set for each of the configuration keys.
197
197
198 If a configuration key is set multiple times in different
198 If a configuration key is set multiple times in different
199 configuration files the final value will depend on the order in which
199 configuration files the final value will depend on the order in which
200 the different configuration files are read, with settings from earlier
200 the different configuration files are read, with settings from earlier
201 paths overriding later ones as described on the ``Files`` section
201 paths overriding later ones as described on the ``Files`` section
202 above.
202 above.
203
203
204 A line of the form ``%include file`` will include ``file`` into the
204 A line of the form ``%include file`` will include ``file`` into the
205 current configuration file. The inclusion is recursive, which means
205 current configuration file. The inclusion is recursive, which means
206 that included files can include other files. Filenames are relative to
206 that included files can include other files. Filenames are relative to
207 the configuration file in which the ``%include`` directive is found.
207 the configuration file in which the ``%include`` directive is found.
208 Environment variables and ``~user`` constructs are expanded in
208 Environment variables and ``~user`` constructs are expanded in
209 ``file``. This lets you do something like::
209 ``file``. This lets you do something like::
210
210
211 %include ~/.hgrc.d/$HOST.rc
211 %include ~/.hgrc.d/$HOST.rc
212
212
213 to include a different configuration file on each computer you use.
213 to include a different configuration file on each computer you use.
214
214
215 A line with ``%unset name`` will remove ``name`` from the current
215 A line with ``%unset name`` will remove ``name`` from the current
216 section, if it has been set previously.
216 section, if it has been set previously.
217
217
218 The values are either free-form text strings, lists of text strings,
218 The values are either free-form text strings, lists of text strings,
219 or Boolean values. Boolean values can be set to true using any of "1",
219 or Boolean values. Boolean values can be set to true using any of "1",
220 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
220 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
221 (all case insensitive).
221 (all case insensitive).
222
222
223 List values are separated by whitespace or comma, except when values are
223 List values are separated by whitespace or comma, except when values are
224 placed in double quotation marks::
224 placed in double quotation marks::
225
225
226 allow_read = "John Doe, PhD", brian, betty
226 allow_read = "John Doe, PhD", brian, betty
227
227
228 Quotation marks can be escaped by prefixing them with a backslash. Only
228 Quotation marks can be escaped by prefixing them with a backslash. Only
229 quotation marks at the beginning of a word is counted as a quotation
229 quotation marks at the beginning of a word is counted as a quotation
230 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
230 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
231
231
232 Sections
232 Sections
233 ========
233 ========
234
234
235 This section describes the different sections that may appear in a
235 This section describes the different sections that may appear in a
236 Mercurial configuration file, the purpose of each section, its possible
236 Mercurial configuration file, the purpose of each section, its possible
237 keys, and their possible values.
237 keys, and their possible values.
238
238
239 ``alias``
239 ``alias``
240 ---------
240 ---------
241
241
242 Defines command aliases.
242 Defines command aliases.
243
243
244 Aliases allow you to define your own commands in terms of other
244 Aliases allow you to define your own commands in terms of other
245 commands (or aliases), optionally including arguments. Positional
245 commands (or aliases), optionally including arguments. Positional
246 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
246 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
247 are expanded by Mercurial before execution. Positional arguments not
247 are expanded by Mercurial before execution. Positional arguments not
248 already used by ``$N`` in the definition are put at the end of the
248 already used by ``$N`` in the definition are put at the end of the
249 command to be executed.
249 command to be executed.
250
250
251 Alias definitions consist of lines of the form::
251 Alias definitions consist of lines of the form::
252
252
253 <alias> = <command> [<argument>]...
253 <alias> = <command> [<argument>]...
254
254
255 For example, this definition::
255 For example, this definition::
256
256
257 latest = log --limit 5
257 latest = log --limit 5
258
258
259 creates a new command ``latest`` that shows only the five most recent
259 creates a new command ``latest`` that shows only the five most recent
260 changesets. You can define subsequent aliases using earlier ones::
260 changesets. You can define subsequent aliases using earlier ones::
261
261
262 stable5 = latest -b stable
262 stable5 = latest -b stable
263
263
264 .. note::
264 .. note::
265
265
266 It is possible to create aliases with the same names as
266 It is possible to create aliases with the same names as
267 existing commands, which will then override the original
267 existing commands, which will then override the original
268 definitions. This is almost always a bad idea!
268 definitions. This is almost always a bad idea!
269
269
270 An alias can start with an exclamation point (``!``) to make it a
270 An alias can start with an exclamation point (``!``) to make it a
271 shell alias. A shell alias is executed with the shell and will let you
271 shell alias. A shell alias is executed with the shell and will let you
272 run arbitrary commands. As an example, ::
272 run arbitrary commands. As an example, ::
273
273
274 echo = !echo $@
274 echo = !echo $@
275
275
276 will let you do ``hg echo foo`` to have ``foo`` printed in your
276 will let you do ``hg echo foo`` to have ``foo`` printed in your
277 terminal. A better example might be::
277 terminal. A better example might be::
278
278
279 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
279 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
280
280
281 which will make ``hg purge`` delete all unknown files in the
281 which will make ``hg purge`` delete all unknown files in the
282 repository in the same manner as the purge extension.
282 repository in the same manner as the purge extension.
283
283
284 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
284 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
285 expand to the command arguments. Unmatched arguments are
285 expand to the command arguments. Unmatched arguments are
286 removed. ``$0`` expands to the alias name and ``$@`` expands to all
286 removed. ``$0`` expands to the alias name and ``$@`` expands to all
287 arguments separated by a space. ``"$@"`` (with quotes) expands to all
287 arguments separated by a space. ``"$@"`` (with quotes) expands to all
288 arguments quoted individually and separated by a space. These expansions
288 arguments quoted individually and separated by a space. These expansions
289 happen before the command is passed to the shell.
289 happen before the command is passed to the shell.
290
290
291 Shell aliases are executed in an environment where ``$HG`` expands to
291 Shell aliases are executed in an environment where ``$HG`` expands to
292 the path of the Mercurial that was used to execute the alias. This is
292 the path of the Mercurial that was used to execute the alias. This is
293 useful when you want to call further Mercurial commands in a shell
293 useful when you want to call further Mercurial commands in a shell
294 alias, as was done above for the purge alias. In addition,
294 alias, as was done above for the purge alias. In addition,
295 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
295 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
296 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
296 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
297
297
298 .. note::
298 .. note::
299
299
300 Some global configuration options such as ``-R`` are
300 Some global configuration options such as ``-R`` are
301 processed before shell aliases and will thus not be passed to
301 processed before shell aliases and will thus not be passed to
302 aliases.
302 aliases.
303
303
304
304
305 ``annotate``
305 ``annotate``
306 ------------
306 ------------
307
307
308 Settings used when displaying file annotations. All values are
308 Settings used when displaying file annotations. All values are
309 Booleans and default to False. See :hg:`help config.diff` for
309 Booleans and default to False. See :hg:`help config.diff` for
310 related options for the diff command.
310 related options for the diff command.
311
311
312 ``ignorews``
312 ``ignorews``
313 Ignore white space when comparing lines.
313 Ignore white space when comparing lines.
314
314
315 ``ignorewseol``
315 ``ignorewseol``
316 Ignore white space at the end of a line when comparing lines.
316 Ignore white space at the end of a line when comparing lines.
317
317
318 ``ignorewsamount``
318 ``ignorewsamount``
319 Ignore changes in the amount of white space.
319 Ignore changes in the amount of white space.
320
320
321 ``ignoreblanklines``
321 ``ignoreblanklines``
322 Ignore changes whose lines are all blank.
322 Ignore changes whose lines are all blank.
323
323
324
324
325 ``auth``
325 ``auth``
326 --------
326 --------
327
327
328 Authentication credentials and other authentication-like configuration
328 Authentication credentials and other authentication-like configuration
329 for HTTP connections. This section allows you to store usernames and
329 for HTTP connections. This section allows you to store usernames and
330 passwords for use when logging *into* HTTP servers. See
330 passwords for use when logging *into* HTTP servers. See
331 :hg:`help config.web` if you want to configure *who* can login to
331 :hg:`help config.web` if you want to configure *who* can login to
332 your HTTP server.
332 your HTTP server.
333
333
334 The following options apply to all hosts.
334 The following options apply to all hosts.
335
335
336 ``cookiefile``
336 ``cookiefile``
337 Path to a file containing HTTP cookie lines. Cookies matching a
337 Path to a file containing HTTP cookie lines. Cookies matching a
338 host will be sent automatically.
338 host will be sent automatically.
339
339
340 The file format uses the Mozilla cookies.txt format, which defines cookies
340 The file format uses the Mozilla cookies.txt format, which defines cookies
341 on their own lines. Each line contains 7 fields delimited by the tab
341 on their own lines. Each line contains 7 fields delimited by the tab
342 character (domain, is_domain_cookie, path, is_secure, expires, name,
342 character (domain, is_domain_cookie, path, is_secure, expires, name,
343 value). For more info, do an Internet search for "Netscape cookies.txt
343 value). For more info, do an Internet search for "Netscape cookies.txt
344 format."
344 format."
345
345
346 Note: the cookies parser does not handle port numbers on domains. You
346 Note: the cookies parser does not handle port numbers on domains. You
347 will need to remove ports from the domain for the cookie to be recognized.
347 will need to remove ports from the domain for the cookie to be recognized.
348 This could result in a cookie being disclosed to an unwanted server.
348 This could result in a cookie being disclosed to an unwanted server.
349
349
350 The cookies file is read-only.
350 The cookies file is read-only.
351
351
352 Other options in this section are grouped by name and have the following
352 Other options in this section are grouped by name and have the following
353 format::
353 format::
354
354
355 <name>.<argument> = <value>
355 <name>.<argument> = <value>
356
356
357 where ``<name>`` is used to group arguments into authentication
357 where ``<name>`` is used to group arguments into authentication
358 entries. Example::
358 entries. Example::
359
359
360 foo.prefix = hg.intevation.de/mercurial
360 foo.prefix = hg.intevation.de/mercurial
361 foo.username = foo
361 foo.username = foo
362 foo.password = bar
362 foo.password = bar
363 foo.schemes = http https
363 foo.schemes = http https
364
364
365 bar.prefix = secure.example.org
365 bar.prefix = secure.example.org
366 bar.key = path/to/file.key
366 bar.key = path/to/file.key
367 bar.cert = path/to/file.cert
367 bar.cert = path/to/file.cert
368 bar.schemes = https
368 bar.schemes = https
369
369
370 Supported arguments:
370 Supported arguments:
371
371
372 ``prefix``
372 ``prefix``
373 Either ``*`` or a URI prefix with or without the scheme part.
373 Either ``*`` or a URI prefix with or without the scheme part.
374 The authentication entry with the longest matching prefix is used
374 The authentication entry with the longest matching prefix is used
375 (where ``*`` matches everything and counts as a match of length
375 (where ``*`` matches everything and counts as a match of length
376 1). If the prefix doesn't include a scheme, the match is performed
376 1). If the prefix doesn't include a scheme, the match is performed
377 against the URI with its scheme stripped as well, and the schemes
377 against the URI with its scheme stripped as well, and the schemes
378 argument, q.v., is then subsequently consulted.
378 argument, q.v., is then subsequently consulted.
379
379
380 ``username``
380 ``username``
381 Optional. Username to authenticate with. If not given, and the
381 Optional. Username to authenticate with. If not given, and the
382 remote site requires basic or digest authentication, the user will
382 remote site requires basic or digest authentication, the user will
383 be prompted for it. Environment variables are expanded in the
383 be prompted for it. Environment variables are expanded in the
384 username letting you do ``foo.username = $USER``. If the URI
384 username letting you do ``foo.username = $USER``. If the URI
385 includes a username, only ``[auth]`` entries with a matching
385 includes a username, only ``[auth]`` entries with a matching
386 username or without a username will be considered.
386 username or without a username will be considered.
387
387
388 ``password``
388 ``password``
389 Optional. Password to authenticate with. If not given, and the
389 Optional. Password to authenticate with. If not given, and the
390 remote site requires basic or digest authentication, the user
390 remote site requires basic or digest authentication, the user
391 will be prompted for it.
391 will be prompted for it.
392
392
393 ``key``
393 ``key``
394 Optional. PEM encoded client certificate key file. Environment
394 Optional. PEM encoded client certificate key file. Environment
395 variables are expanded in the filename.
395 variables are expanded in the filename.
396
396
397 ``cert``
397 ``cert``
398 Optional. PEM encoded client certificate chain file. Environment
398 Optional. PEM encoded client certificate chain file. Environment
399 variables are expanded in the filename.
399 variables are expanded in the filename.
400
400
401 ``schemes``
401 ``schemes``
402 Optional. Space separated list of URI schemes to use this
402 Optional. Space separated list of URI schemes to use this
403 authentication entry with. Only used if the prefix doesn't include
403 authentication entry with. Only used if the prefix doesn't include
404 a scheme. Supported schemes are http and https. They will match
404 a scheme. Supported schemes are http and https. They will match
405 static-http and static-https respectively, as well.
405 static-http and static-https respectively, as well.
406 (default: https)
406 (default: https)
407
407
408 If no suitable authentication entry is found, the user is prompted
408 If no suitable authentication entry is found, the user is prompted
409 for credentials as usual if required by the remote.
409 for credentials as usual if required by the remote.
410
410
411 ``cmdserver``
411 ``cmdserver``
412 -------------
412 -------------
413
413
414 Controls command server settings. (ADVANCED)
414 Controls command server settings. (ADVANCED)
415
415
416 ``message-encodings``
416 ``message-encodings``
417 List of encodings for the ``m`` (message) channel. The first encoding
417 List of encodings for the ``m`` (message) channel. The first encoding
418 supported by the server will be selected and advertised in the hello
418 supported by the server will be selected and advertised in the hello
419 message. This is useful only when ``ui.message-output`` is set to
419 message. This is useful only when ``ui.message-output`` is set to
420 ``channel``. Supported encodings are ``cbor``.
420 ``channel``. Supported encodings are ``cbor``.
421
421
422 ``shutdown-on-interrupt``
422 ``shutdown-on-interrupt``
423 If set to false, the server's main loop will continue running after
423 If set to false, the server's main loop will continue running after
424 SIGINT received. ``runcommand`` requests can still be interrupted by
424 SIGINT received. ``runcommand`` requests can still be interrupted by
425 SIGINT. Close the write end of the pipe to shut down the server
425 SIGINT. Close the write end of the pipe to shut down the server
426 process gracefully.
426 process gracefully.
427 (default: True)
427 (default: True)
428
428
429 ``color``
429 ``color``
430 ---------
430 ---------
431
431
432 Configure the Mercurial color mode. For details about how to define your custom
432 Configure the Mercurial color mode. For details about how to define your custom
433 effect and style see :hg:`help color`.
433 effect and style see :hg:`help color`.
434
434
435 ``mode``
435 ``mode``
436 String: control the method used to output color. One of ``auto``, ``ansi``,
436 String: control the method used to output color. One of ``auto``, ``ansi``,
437 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
437 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
438 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
438 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
439 terminal. Any invalid value will disable color.
439 terminal. Any invalid value will disable color.
440
440
441 ``pagermode``
441 ``pagermode``
442 String: optional override of ``color.mode`` used with pager.
442 String: optional override of ``color.mode`` used with pager.
443
443
444 On some systems, terminfo mode may cause problems when using
444 On some systems, terminfo mode may cause problems when using
445 color with ``less -R`` as a pager program. less with the -R option
445 color with ``less -R`` as a pager program. less with the -R option
446 will only display ECMA-48 color codes, and terminfo mode may sometimes
446 will only display ECMA-48 color codes, and terminfo mode may sometimes
447 emit codes that less doesn't understand. You can work around this by
447 emit codes that less doesn't understand. You can work around this by
448 either using ansi mode (or auto mode), or by using less -r (which will
448 either using ansi mode (or auto mode), or by using less -r (which will
449 pass through all terminal control codes, not just color control
449 pass through all terminal control codes, not just color control
450 codes).
450 codes).
451
451
452 On some systems (such as MSYS in Windows), the terminal may support
452 On some systems (such as MSYS in Windows), the terminal may support
453 a different color mode than the pager program.
453 a different color mode than the pager program.
454
454
455 ``commands``
455 ``commands``
456 ------------
456 ------------
457
457
458 ``commit.post-status``
458 ``commit.post-status``
459 Show status of files in the working directory after successful commit.
459 Show status of files in the working directory after successful commit.
460 (default: False)
460 (default: False)
461
461
462 ``merge.require-rev``
462 ``merge.require-rev``
463 Require that the revision to merge the current commit with be specified on
463 Require that the revision to merge the current commit with be specified on
464 the command line. If this is enabled and a revision is not specified, the
464 the command line. If this is enabled and a revision is not specified, the
465 command aborts.
465 command aborts.
466 (default: False)
466 (default: False)
467
467
468 ``push.require-revs``
468 ``push.require-revs``
469 Require revisions to push be specified using one or more mechanisms such as
469 Require revisions to push be specified using one or more mechanisms such as
470 specifying them positionally on the command line, using ``-r``, ``-b``,
470 specifying them positionally on the command line, using ``-r``, ``-b``,
471 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
471 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
472 configuration. If this is enabled and revisions are not specified, the
472 configuration. If this is enabled and revisions are not specified, the
473 command aborts.
473 command aborts.
474 (default: False)
474 (default: False)
475
475
476 ``resolve.confirm``
476 ``resolve.confirm``
477 Confirm before performing action if no filename is passed.
477 Confirm before performing action if no filename is passed.
478 (default: False)
478 (default: False)
479
479
480 ``resolve.explicit-re-merge``
480 ``resolve.explicit-re-merge``
481 Require uses of ``hg resolve`` to specify which action it should perform,
481 Require uses of ``hg resolve`` to specify which action it should perform,
482 instead of re-merging files by default.
482 instead of re-merging files by default.
483 (default: False)
483 (default: False)
484
484
485 ``resolve.mark-check``
485 ``resolve.mark-check``
486 Determines what level of checking :hg:`resolve --mark` will perform before
486 Determines what level of checking :hg:`resolve --mark` will perform before
487 marking files as resolved. Valid values are ``none`, ``warn``, and
487 marking files as resolved. Valid values are ``none`, ``warn``, and
488 ``abort``. ``warn`` will output a warning listing the file(s) that still
488 ``abort``. ``warn`` will output a warning listing the file(s) that still
489 have conflict markers in them, but will still mark everything resolved.
489 have conflict markers in them, but will still mark everything resolved.
490 ``abort`` will output the same warning but will not mark things as resolved.
490 ``abort`` will output the same warning but will not mark things as resolved.
491 If --all is passed and this is set to ``abort``, only a warning will be
491 If --all is passed and this is set to ``abort``, only a warning will be
492 shown (an error will not be raised).
492 shown (an error will not be raised).
493 (default: ``none``)
493 (default: ``none``)
494
494
495 ``status.relative``
495 ``status.relative``
496 Make paths in :hg:`status` output relative to the current directory.
496 Make paths in :hg:`status` output relative to the current directory.
497 (default: False)
497 (default: False)
498
498
499 ``status.terse``
499 ``status.terse``
500 Default value for the --terse flag, which condenses status output.
500 Default value for the --terse flag, which condenses status output.
501 (default: empty)
501 (default: empty)
502
502
503 ``update.check``
503 ``update.check``
504 Determines what level of checking :hg:`update` will perform before moving
504 Determines what level of checking :hg:`update` will perform before moving
505 to a destination revision. Valid values are ``abort``, ``none``,
505 to a destination revision. Valid values are ``abort``, ``none``,
506 ``linear``, and ``noconflict``. ``abort`` always fails if the working
506 ``linear``, and ``noconflict``. ``abort`` always fails if the working
507 directory has uncommitted changes. ``none`` performs no checking, and may
507 directory has uncommitted changes. ``none`` performs no checking, and may
508 result in a merge with uncommitted changes. ``linear`` allows any update
508 result in a merge with uncommitted changes. ``linear`` allows any update
509 as long as it follows a straight line in the revision history, and may
509 as long as it follows a straight line in the revision history, and may
510 trigger a merge with uncommitted changes. ``noconflict`` will allow any
510 trigger a merge with uncommitted changes. ``noconflict`` will allow any
511 update which would not trigger a merge with uncommitted changes, if any
511 update which would not trigger a merge with uncommitted changes, if any
512 are present.
512 are present.
513 (default: ``linear``)
513 (default: ``linear``)
514
514
515 ``update.requiredest``
515 ``update.requiredest``
516 Require that the user pass a destination when running :hg:`update`.
516 Require that the user pass a destination when running :hg:`update`.
517 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
517 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
518 will be disallowed.
518 will be disallowed.
519 (default: False)
519 (default: False)
520
520
521 ``committemplate``
521 ``committemplate``
522 ------------------
522 ------------------
523
523
524 ``changeset``
524 ``changeset``
525 String: configuration in this section is used as the template to
525 String: configuration in this section is used as the template to
526 customize the text shown in the editor when committing.
526 customize the text shown in the editor when committing.
527
527
528 In addition to pre-defined template keywords, commit log specific one
528 In addition to pre-defined template keywords, commit log specific one
529 below can be used for customization:
529 below can be used for customization:
530
530
531 ``extramsg``
531 ``extramsg``
532 String: Extra message (typically 'Leave message empty to abort
532 String: Extra message (typically 'Leave message empty to abort
533 commit.'). This may be changed by some commands or extensions.
533 commit.'). This may be changed by some commands or extensions.
534
534
535 For example, the template configuration below shows as same text as
535 For example, the template configuration below shows as same text as
536 one shown by default::
536 one shown by default::
537
537
538 [committemplate]
538 [committemplate]
539 changeset = {desc}\n\n
539 changeset = {desc}\n\n
540 HG: Enter commit message. Lines beginning with 'HG:' are removed.
540 HG: Enter commit message. Lines beginning with 'HG:' are removed.
541 HG: {extramsg}
541 HG: {extramsg}
542 HG: --
542 HG: --
543 HG: user: {author}\n{ifeq(p2rev, "-1", "",
543 HG: user: {author}\n{ifeq(p2rev, "-1", "",
544 "HG: branch merge\n")
544 "HG: branch merge\n")
545 }HG: branch '{branch}'\n{if(activebookmark,
545 }HG: branch '{branch}'\n{if(activebookmark,
546 "HG: bookmark '{activebookmark}'\n") }{subrepos %
546 "HG: bookmark '{activebookmark}'\n") }{subrepos %
547 "HG: subrepo {subrepo}\n" }{file_adds %
547 "HG: subrepo {subrepo}\n" }{file_adds %
548 "HG: added {file}\n" }{file_mods %
548 "HG: added {file}\n" }{file_mods %
549 "HG: changed {file}\n" }{file_dels %
549 "HG: changed {file}\n" }{file_dels %
550 "HG: removed {file}\n" }{if(files, "",
550 "HG: removed {file}\n" }{if(files, "",
551 "HG: no files changed\n")}
551 "HG: no files changed\n")}
552
552
553 ``diff()``
553 ``diff()``
554 String: show the diff (see :hg:`help templates` for detail)
554 String: show the diff (see :hg:`help templates` for detail)
555
555
556 Sometimes it is helpful to show the diff of the changeset in the editor without
556 Sometimes it is helpful to show the diff of the changeset in the editor without
557 having to prefix 'HG: ' to each line so that highlighting works correctly. For
557 having to prefix 'HG: ' to each line so that highlighting works correctly. For
558 this, Mercurial provides a special string which will ignore everything below
558 this, Mercurial provides a special string which will ignore everything below
559 it::
559 it::
560
560
561 HG: ------------------------ >8 ------------------------
561 HG: ------------------------ >8 ------------------------
562
562
563 For example, the template configuration below will show the diff below the
563 For example, the template configuration below will show the diff below the
564 extra message::
564 extra message::
565
565
566 [committemplate]
566 [committemplate]
567 changeset = {desc}\n\n
567 changeset = {desc}\n\n
568 HG: Enter commit message. Lines beginning with 'HG:' are removed.
568 HG: Enter commit message. Lines beginning with 'HG:' are removed.
569 HG: {extramsg}
569 HG: {extramsg}
570 HG: ------------------------ >8 ------------------------
570 HG: ------------------------ >8 ------------------------
571 HG: Do not touch the line above.
571 HG: Do not touch the line above.
572 HG: Everything below will be removed.
572 HG: Everything below will be removed.
573 {diff()}
573 {diff()}
574
574
575 .. note::
575 .. note::
576
576
577 For some problematic encodings (see :hg:`help win32mbcs` for
577 For some problematic encodings (see :hg:`help win32mbcs` for
578 detail), this customization should be configured carefully, to
578 detail), this customization should be configured carefully, to
579 avoid showing broken characters.
579 avoid showing broken characters.
580
580
581 For example, if a multibyte character ending with backslash (0x5c) is
581 For example, if a multibyte character ending with backslash (0x5c) is
582 followed by the ASCII character 'n' in the customized template,
582 followed by the ASCII character 'n' in the customized template,
583 the sequence of backslash and 'n' is treated as line-feed unexpectedly
583 the sequence of backslash and 'n' is treated as line-feed unexpectedly
584 (and the multibyte character is broken, too).
584 (and the multibyte character is broken, too).
585
585
586 Customized template is used for commands below (``--edit`` may be
586 Customized template is used for commands below (``--edit`` may be
587 required):
587 required):
588
588
589 - :hg:`backout`
589 - :hg:`backout`
590 - :hg:`commit`
590 - :hg:`commit`
591 - :hg:`fetch` (for merge commit only)
591 - :hg:`fetch` (for merge commit only)
592 - :hg:`graft`
592 - :hg:`graft`
593 - :hg:`histedit`
593 - :hg:`histedit`
594 - :hg:`import`
594 - :hg:`import`
595 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
595 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
596 - :hg:`rebase`
596 - :hg:`rebase`
597 - :hg:`shelve`
597 - :hg:`shelve`
598 - :hg:`sign`
598 - :hg:`sign`
599 - :hg:`tag`
599 - :hg:`tag`
600 - :hg:`transplant`
600 - :hg:`transplant`
601
601
602 Configuring items below instead of ``changeset`` allows showing
602 Configuring items below instead of ``changeset`` allows showing
603 customized message only for specific actions, or showing different
603 customized message only for specific actions, or showing different
604 messages for each action.
604 messages for each action.
605
605
606 - ``changeset.backout`` for :hg:`backout`
606 - ``changeset.backout`` for :hg:`backout`
607 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
607 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
608 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
608 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
609 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
609 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
610 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
610 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
611 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
611 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
612 - ``changeset.gpg.sign`` for :hg:`sign`
612 - ``changeset.gpg.sign`` for :hg:`sign`
613 - ``changeset.graft`` for :hg:`graft`
613 - ``changeset.graft`` for :hg:`graft`
614 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
614 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
615 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
615 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
616 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
616 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
617 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
617 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
618 - ``changeset.import.bypass`` for :hg:`import --bypass`
618 - ``changeset.import.bypass`` for :hg:`import --bypass`
619 - ``changeset.import.normal.merge`` for :hg:`import` on merges
619 - ``changeset.import.normal.merge`` for :hg:`import` on merges
620 - ``changeset.import.normal.normal`` for :hg:`import` on other
620 - ``changeset.import.normal.normal`` for :hg:`import` on other
621 - ``changeset.mq.qnew`` for :hg:`qnew`
621 - ``changeset.mq.qnew`` for :hg:`qnew`
622 - ``changeset.mq.qfold`` for :hg:`qfold`
622 - ``changeset.mq.qfold`` for :hg:`qfold`
623 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
623 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
624 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
624 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
625 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
625 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
626 - ``changeset.rebase.normal`` for :hg:`rebase` on other
626 - ``changeset.rebase.normal`` for :hg:`rebase` on other
627 - ``changeset.shelve.shelve`` for :hg:`shelve`
627 - ``changeset.shelve.shelve`` for :hg:`shelve`
628 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
628 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
629 - ``changeset.tag.remove`` for :hg:`tag --remove`
629 - ``changeset.tag.remove`` for :hg:`tag --remove`
630 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
630 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
631 - ``changeset.transplant.normal`` for :hg:`transplant` on other
631 - ``changeset.transplant.normal`` for :hg:`transplant` on other
632
632
633 These dot-separated lists of names are treated as hierarchical ones.
633 These dot-separated lists of names are treated as hierarchical ones.
634 For example, ``changeset.tag.remove`` customizes the commit message
634 For example, ``changeset.tag.remove`` customizes the commit message
635 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
635 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
636 commit message for :hg:`tag` regardless of ``--remove`` option.
636 commit message for :hg:`tag` regardless of ``--remove`` option.
637
637
638 When the external editor is invoked for a commit, the corresponding
638 When the external editor is invoked for a commit, the corresponding
639 dot-separated list of names without the ``changeset.`` prefix
639 dot-separated list of names without the ``changeset.`` prefix
640 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
640 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
641 variable.
641 variable.
642
642
643 In this section, items other than ``changeset`` can be referred from
643 In this section, items other than ``changeset`` can be referred from
644 others. For example, the configuration to list committed files up
644 others. For example, the configuration to list committed files up
645 below can be referred as ``{listupfiles}``::
645 below can be referred as ``{listupfiles}``::
646
646
647 [committemplate]
647 [committemplate]
648 listupfiles = {file_adds %
648 listupfiles = {file_adds %
649 "HG: added {file}\n" }{file_mods %
649 "HG: added {file}\n" }{file_mods %
650 "HG: changed {file}\n" }{file_dels %
650 "HG: changed {file}\n" }{file_dels %
651 "HG: removed {file}\n" }{if(files, "",
651 "HG: removed {file}\n" }{if(files, "",
652 "HG: no files changed\n")}
652 "HG: no files changed\n")}
653
653
654 ``decode/encode``
654 ``decode/encode``
655 -----------------
655 -----------------
656
656
657 Filters for transforming files on checkout/checkin. This would
657 Filters for transforming files on checkout/checkin. This would
658 typically be used for newline processing or other
658 typically be used for newline processing or other
659 localization/canonicalization of files.
659 localization/canonicalization of files.
660
660
661 Filters consist of a filter pattern followed by a filter command.
661 Filters consist of a filter pattern followed by a filter command.
662 Filter patterns are globs by default, rooted at the repository root.
662 Filter patterns are globs by default, rooted at the repository root.
663 For example, to match any file ending in ``.txt`` in the root
663 For example, to match any file ending in ``.txt`` in the root
664 directory only, use the pattern ``*.txt``. To match any file ending
664 directory only, use the pattern ``*.txt``. To match any file ending
665 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
665 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
666 For each file only the first matching filter applies.
666 For each file only the first matching filter applies.
667
667
668 The filter command can start with a specifier, either ``pipe:`` or
668 The filter command can start with a specifier, either ``pipe:`` or
669 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
669 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
670
670
671 A ``pipe:`` command must accept data on stdin and return the transformed
671 A ``pipe:`` command must accept data on stdin and return the transformed
672 data on stdout.
672 data on stdout.
673
673
674 Pipe example::
674 Pipe example::
675
675
676 [encode]
676 [encode]
677 # uncompress gzip files on checkin to improve delta compression
677 # uncompress gzip files on checkin to improve delta compression
678 # note: not necessarily a good idea, just an example
678 # note: not necessarily a good idea, just an example
679 *.gz = pipe: gunzip
679 *.gz = pipe: gunzip
680
680
681 [decode]
681 [decode]
682 # recompress gzip files when writing them to the working dir (we
682 # recompress gzip files when writing them to the working dir (we
683 # can safely omit "pipe:", because it's the default)
683 # can safely omit "pipe:", because it's the default)
684 *.gz = gzip
684 *.gz = gzip
685
685
686 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
686 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
687 with the name of a temporary file that contains the data to be
687 with the name of a temporary file that contains the data to be
688 filtered by the command. The string ``OUTFILE`` is replaced with the name
688 filtered by the command. The string ``OUTFILE`` is replaced with the name
689 of an empty temporary file, where the filtered data must be written by
689 of an empty temporary file, where the filtered data must be written by
690 the command.
690 the command.
691
691
692 .. container:: windows
692 .. container:: windows
693
693
694 .. note::
694 .. note::
695
695
696 The tempfile mechanism is recommended for Windows systems,
696 The tempfile mechanism is recommended for Windows systems,
697 where the standard shell I/O redirection operators often have
697 where the standard shell I/O redirection operators often have
698 strange effects and may corrupt the contents of your files.
698 strange effects and may corrupt the contents of your files.
699
699
700 This filter mechanism is used internally by the ``eol`` extension to
700 This filter mechanism is used internally by the ``eol`` extension to
701 translate line ending characters between Windows (CRLF) and Unix (LF)
701 translate line ending characters between Windows (CRLF) and Unix (LF)
702 format. We suggest you use the ``eol`` extension for convenience.
702 format. We suggest you use the ``eol`` extension for convenience.
703
703
704
704
705 ``defaults``
705 ``defaults``
706 ------------
706 ------------
707
707
708 (defaults are deprecated. Don't use them. Use aliases instead.)
708 (defaults are deprecated. Don't use them. Use aliases instead.)
709
709
710 Use the ``[defaults]`` section to define command defaults, i.e. the
710 Use the ``[defaults]`` section to define command defaults, i.e. the
711 default options/arguments to pass to the specified commands.
711 default options/arguments to pass to the specified commands.
712
712
713 The following example makes :hg:`log` run in verbose mode, and
713 The following example makes :hg:`log` run in verbose mode, and
714 :hg:`status` show only the modified files, by default::
714 :hg:`status` show only the modified files, by default::
715
715
716 [defaults]
716 [defaults]
717 log = -v
717 log = -v
718 status = -m
718 status = -m
719
719
720 The actual commands, instead of their aliases, must be used when
720 The actual commands, instead of their aliases, must be used when
721 defining command defaults. The command defaults will also be applied
721 defining command defaults. The command defaults will also be applied
722 to the aliases of the commands defined.
722 to the aliases of the commands defined.
723
723
724
724
725 ``diff``
725 ``diff``
726 --------
726 --------
727
727
728 Settings used when displaying diffs. Everything except for ``unified``
728 Settings used when displaying diffs. Everything except for ``unified``
729 is a Boolean and defaults to False. See :hg:`help config.annotate`
729 is a Boolean and defaults to False. See :hg:`help config.annotate`
730 for related options for the annotate command.
730 for related options for the annotate command.
731
731
732 ``git``
732 ``git``
733 Use git extended diff format.
733 Use git extended diff format.
734
734
735 ``nobinary``
735 ``nobinary``
736 Omit git binary patches.
736 Omit git binary patches.
737
737
738 ``nodates``
738 ``nodates``
739 Don't include dates in diff headers.
739 Don't include dates in diff headers.
740
740
741 ``noprefix``
741 ``noprefix``
742 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
742 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
743
743
744 ``showfunc``
744 ``showfunc``
745 Show which function each change is in.
745 Show which function each change is in.
746
746
747 ``ignorews``
747 ``ignorews``
748 Ignore white space when comparing lines.
748 Ignore white space when comparing lines.
749
749
750 ``ignorewsamount``
750 ``ignorewsamount``
751 Ignore changes in the amount of white space.
751 Ignore changes in the amount of white space.
752
752
753 ``ignoreblanklines``
753 ``ignoreblanklines``
754 Ignore changes whose lines are all blank.
754 Ignore changes whose lines are all blank.
755
755
756 ``unified``
756 ``unified``
757 Number of lines of context to show.
757 Number of lines of context to show.
758
758
759 ``word-diff``
759 ``word-diff``
760 Highlight changed words.
760 Highlight changed words.
761
761
762 ``email``
762 ``email``
763 ---------
763 ---------
764
764
765 Settings for extensions that send email messages.
765 Settings for extensions that send email messages.
766
766
767 ``from``
767 ``from``
768 Optional. Email address to use in "From" header and SMTP envelope
768 Optional. Email address to use in "From" header and SMTP envelope
769 of outgoing messages.
769 of outgoing messages.
770
770
771 ``to``
771 ``to``
772 Optional. Comma-separated list of recipients' email addresses.
772 Optional. Comma-separated list of recipients' email addresses.
773
773
774 ``cc``
774 ``cc``
775 Optional. Comma-separated list of carbon copy recipients'
775 Optional. Comma-separated list of carbon copy recipients'
776 email addresses.
776 email addresses.
777
777
778 ``bcc``
778 ``bcc``
779 Optional. Comma-separated list of blind carbon copy recipients'
779 Optional. Comma-separated list of blind carbon copy recipients'
780 email addresses.
780 email addresses.
781
781
782 ``method``
782 ``method``
783 Optional. Method to use to send email messages. If value is ``smtp``
783 Optional. Method to use to send email messages. If value is ``smtp``
784 (default), use SMTP (see the ``[smtp]`` section for configuration).
784 (default), use SMTP (see the ``[smtp]`` section for configuration).
785 Otherwise, use as name of program to run that acts like sendmail
785 Otherwise, use as name of program to run that acts like sendmail
786 (takes ``-f`` option for sender, list of recipients on command line,
786 (takes ``-f`` option for sender, list of recipients on command line,
787 message on stdin). Normally, setting this to ``sendmail`` or
787 message on stdin). Normally, setting this to ``sendmail`` or
788 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
788 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
789
789
790 ``charsets``
790 ``charsets``
791 Optional. Comma-separated list of character sets considered
791 Optional. Comma-separated list of character sets considered
792 convenient for recipients. Addresses, headers, and parts not
792 convenient for recipients. Addresses, headers, and parts not
793 containing patches of outgoing messages will be encoded in the
793 containing patches of outgoing messages will be encoded in the
794 first character set to which conversion from local encoding
794 first character set to which conversion from local encoding
795 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
795 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
796 conversion fails, the text in question is sent as is.
796 conversion fails, the text in question is sent as is.
797 (default: '')
797 (default: '')
798
798
799 Order of outgoing email character sets:
799 Order of outgoing email character sets:
800
800
801 1. ``us-ascii``: always first, regardless of settings
801 1. ``us-ascii``: always first, regardless of settings
802 2. ``email.charsets``: in order given by user
802 2. ``email.charsets``: in order given by user
803 3. ``ui.fallbackencoding``: if not in email.charsets
803 3. ``ui.fallbackencoding``: if not in email.charsets
804 4. ``$HGENCODING``: if not in email.charsets
804 4. ``$HGENCODING``: if not in email.charsets
805 5. ``utf-8``: always last, regardless of settings
805 5. ``utf-8``: always last, regardless of settings
806
806
807 Email example::
807 Email example::
808
808
809 [email]
809 [email]
810 from = Joseph User <joe.user@example.com>
810 from = Joseph User <joe.user@example.com>
811 method = /usr/sbin/sendmail
811 method = /usr/sbin/sendmail
812 # charsets for western Europeans
812 # charsets for western Europeans
813 # us-ascii, utf-8 omitted, as they are tried first and last
813 # us-ascii, utf-8 omitted, as they are tried first and last
814 charsets = iso-8859-1, iso-8859-15, windows-1252
814 charsets = iso-8859-1, iso-8859-15, windows-1252
815
815
816
816
817 ``extensions``
817 ``extensions``
818 --------------
818 --------------
819
819
820 Mercurial has an extension mechanism for adding new features. To
820 Mercurial has an extension mechanism for adding new features. To
821 enable an extension, create an entry for it in this section.
821 enable an extension, create an entry for it in this section.
822
822
823 If you know that the extension is already in Python's search path,
823 If you know that the extension is already in Python's search path,
824 you can give the name of the module, followed by ``=``, with nothing
824 you can give the name of the module, followed by ``=``, with nothing
825 after the ``=``.
825 after the ``=``.
826
826
827 Otherwise, give a name that you choose, followed by ``=``, followed by
827 Otherwise, give a name that you choose, followed by ``=``, followed by
828 the path to the ``.py`` file (including the file name extension) that
828 the path to the ``.py`` file (including the file name extension) that
829 defines the extension.
829 defines the extension.
830
830
831 To explicitly disable an extension that is enabled in an hgrc of
831 To explicitly disable an extension that is enabled in an hgrc of
832 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
832 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
833 or ``foo = !`` when path is not supplied.
833 or ``foo = !`` when path is not supplied.
834
834
835 Example for ``~/.hgrc``::
835 Example for ``~/.hgrc``::
836
836
837 [extensions]
837 [extensions]
838 # (the churn extension will get loaded from Mercurial's path)
838 # (the churn extension will get loaded from Mercurial's path)
839 churn =
839 churn =
840 # (this extension will get loaded from the file specified)
840 # (this extension will get loaded from the file specified)
841 myfeature = ~/.hgext/myfeature.py
841 myfeature = ~/.hgext/myfeature.py
842
842
843
843
844 ``format``
844 ``format``
845 ----------
845 ----------
846
846
847 Configuration that controls the repository format. Newer format options are more
847 Configuration that controls the repository format. Newer format options are more
848 powerful, but incompatible with some older versions of Mercurial. Format options
848 powerful, but incompatible with some older versions of Mercurial. Format options
849 are considered at repository initialization only. You need to make a new clone
849 are considered at repository initialization only. You need to make a new clone
850 for config changes to be taken into account.
850 for config changes to be taken into account.
851
851
852 For more details about repository format and version compatibility, see
852 For more details about repository format and version compatibility, see
853 https://www.mercurial-scm.org/wiki/MissingRequirement
853 https://www.mercurial-scm.org/wiki/MissingRequirement
854
854
855 ``usegeneraldelta``
855 ``usegeneraldelta``
856 Enable or disable the "generaldelta" repository format which improves
856 Enable or disable the "generaldelta" repository format which improves
857 repository compression by allowing "revlog" to store deltas against
857 repository compression by allowing "revlog" to store deltas against
858 arbitrary revisions instead of the previously stored one. This provides
858 arbitrary revisions instead of the previously stored one. This provides
859 significant improvement for repositories with branches.
859 significant improvement for repositories with branches.
860
860
861 Repositories with this on-disk format require Mercurial version 1.9.
861 Repositories with this on-disk format require Mercurial version 1.9.
862
862
863 Enabled by default.
863 Enabled by default.
864
864
865 ``dotencode``
865 ``dotencode``
866 Enable or disable the "dotencode" repository format which enhances
866 Enable or disable the "dotencode" repository format which enhances
867 the "fncache" repository format (which has to be enabled to use
867 the "fncache" repository format (which has to be enabled to use
868 dotencode) to avoid issues with filenames starting with "._" on
868 dotencode) to avoid issues with filenames starting with "._" on
869 Mac OS X and spaces on Windows.
869 Mac OS X and spaces on Windows.
870
870
871 Repositories with this on-disk format require Mercurial version 1.7.
871 Repositories with this on-disk format require Mercurial version 1.7.
872
872
873 Enabled by default.
873 Enabled by default.
874
874
875 ``usefncache``
875 ``usefncache``
876 Enable or disable the "fncache" repository format which enhances
876 Enable or disable the "fncache" repository format which enhances
877 the "store" repository format (which has to be enabled to use
877 the "store" repository format (which has to be enabled to use
878 fncache) to allow longer filenames and avoids using Windows
878 fncache) to allow longer filenames and avoids using Windows
879 reserved names, e.g. "nul".
879 reserved names, e.g. "nul".
880
880
881 Repositories with this on-disk format require Mercurial version 1.1.
881 Repositories with this on-disk format require Mercurial version 1.1.
882
882
883 Enabled by default.
883 Enabled by default.
884
884
885 ``usestore``
885 ``usestore``
886 Enable or disable the "store" repository format which improves
886 Enable or disable the "store" repository format which improves
887 compatibility with systems that fold case or otherwise mangle
887 compatibility with systems that fold case or otherwise mangle
888 filenames. Disabling this option will allow you to store longer filenames
888 filenames. Disabling this option will allow you to store longer filenames
889 in some situations at the expense of compatibility.
889 in some situations at the expense of compatibility.
890
890
891 Repositories with this on-disk format require Mercurial version 0.9.4.
891 Repositories with this on-disk format require Mercurial version 0.9.4.
892
892
893 Enabled by default.
893 Enabled by default.
894
894
895 ``sparse-revlog``
895 ``sparse-revlog``
896 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
896 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
897 delta re-use inside revlog. For very branchy repositories, it results in a
897 delta re-use inside revlog. For very branchy repositories, it results in a
898 smaller store. For repositories with many revisions, it also helps
898 smaller store. For repositories with many revisions, it also helps
899 performance (by using shortened delta chains.)
899 performance (by using shortened delta chains.)
900
900
901 Repositories with this on-disk format require Mercurial version 4.7
901 Repositories with this on-disk format require Mercurial version 4.7
902
902
903 Enabled by default.
903 Enabled by default.
904
904
905 ``revlog-compression``
905 ``revlog-compression``
906 Compression algorithm used by revlog. Supported values are `zlib` and
906 Compression algorithm used by revlog. Supported values are `zlib` and
907 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
907 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
908 a newer format that is usually a net win over `zlib`, operating faster at
908 a newer format that is usually a net win over `zlib`, operating faster at
909 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
909 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
910 can be specified, the first available one will be used.
910 can be specified, the first available one will be used.
911
911
912 On some systems, the Mercurial installation may lack `zstd` support.
912 On some systems, the Mercurial installation may lack `zstd` support.
913
913
914 Default is `zlib`.
914 Default is `zlib`.
915
915
916 ``bookmarks-in-store``
916 ``bookmarks-in-store``
917 Store bookmarks in .hg/store/. This means that bookmarks are shared when
917 Store bookmarks in .hg/store/. This means that bookmarks are shared when
918 using `hg share` regardless of the `-B` option.
918 using `hg share` regardless of the `-B` option.
919
919
920 Repositories with this on-disk format require Mercurial version 5.1.
920 Repositories with this on-disk format require Mercurial version 5.1.
921
921
922 Disabled by default.
922 Disabled by default.
923
923
924
924
925 ``graph``
925 ``graph``
926 ---------
926 ---------
927
927
928 Web graph view configuration. This section let you change graph
928 Web graph view configuration. This section let you change graph
929 elements display properties by branches, for instance to make the
929 elements display properties by branches, for instance to make the
930 ``default`` branch stand out.
930 ``default`` branch stand out.
931
931
932 Each line has the following format::
932 Each line has the following format::
933
933
934 <branch>.<argument> = <value>
934 <branch>.<argument> = <value>
935
935
936 where ``<branch>`` is the name of the branch being
936 where ``<branch>`` is the name of the branch being
937 customized. Example::
937 customized. Example::
938
938
939 [graph]
939 [graph]
940 # 2px width
940 # 2px width
941 default.width = 2
941 default.width = 2
942 # red color
942 # red color
943 default.color = FF0000
943 default.color = FF0000
944
944
945 Supported arguments:
945 Supported arguments:
946
946
947 ``width``
947 ``width``
948 Set branch edges width in pixels.
948 Set branch edges width in pixels.
949
949
950 ``color``
950 ``color``
951 Set branch edges color in hexadecimal RGB notation.
951 Set branch edges color in hexadecimal RGB notation.
952
952
953 ``hooks``
953 ``hooks``
954 ---------
954 ---------
955
955
956 Commands or Python functions that get automatically executed by
956 Commands or Python functions that get automatically executed by
957 various actions such as starting or finishing a commit. Multiple
957 various actions such as starting or finishing a commit. Multiple
958 hooks can be run for the same action by appending a suffix to the
958 hooks can be run for the same action by appending a suffix to the
959 action. Overriding a site-wide hook can be done by changing its
959 action. Overriding a site-wide hook can be done by changing its
960 value or setting it to an empty string. Hooks can be prioritized
960 value or setting it to an empty string. Hooks can be prioritized
961 by adding a prefix of ``priority.`` to the hook name on a new line
961 by adding a prefix of ``priority.`` to the hook name on a new line
962 and setting the priority. The default priority is 0.
962 and setting the priority. The default priority is 0.
963
963
964 Example ``.hg/hgrc``::
964 Example ``.hg/hgrc``::
965
965
966 [hooks]
966 [hooks]
967 # update working directory after adding changesets
967 # update working directory after adding changesets
968 changegroup.update = hg update
968 changegroup.update = hg update
969 # do not use the site-wide hook
969 # do not use the site-wide hook
970 incoming =
970 incoming =
971 incoming.email = /my/email/hook
971 incoming.email = /my/email/hook
972 incoming.autobuild = /my/build/hook
972 incoming.autobuild = /my/build/hook
973 # force autobuild hook to run before other incoming hooks
973 # force autobuild hook to run before other incoming hooks
974 priority.incoming.autobuild = 1
974 priority.incoming.autobuild = 1
975
975
976 Most hooks are run with environment variables set that give useful
976 Most hooks are run with environment variables set that give useful
977 additional information. For each hook below, the environment variables
977 additional information. For each hook below, the environment variables
978 it is passed are listed with names in the form ``$HG_foo``. The
978 it is passed are listed with names in the form ``$HG_foo``. The
979 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
979 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
980 They contain the type of hook which triggered the run and the full name
980 They contain the type of hook which triggered the run and the full name
981 of the hook in the config, respectively. In the example above, this will
981 of the hook in the config, respectively. In the example above, this will
982 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
982 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
983
983
984 .. container:: windows
984 .. container:: windows
985
985
986 Some basic Unix syntax can be enabled for portability, including ``$VAR``
986 Some basic Unix syntax can be enabled for portability, including ``$VAR``
987 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
987 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
988 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
988 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
989 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
989 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
990 slash or inside of a strong quote. Strong quotes will be replaced by
990 slash or inside of a strong quote. Strong quotes will be replaced by
991 double quotes after processing.
991 double quotes after processing.
992
992
993 This feature is enabled by adding a prefix of ``tonative.`` to the hook
993 This feature is enabled by adding a prefix of ``tonative.`` to the hook
994 name on a new line, and setting it to ``True``. For example::
994 name on a new line, and setting it to ``True``. For example::
995
995
996 [hooks]
996 [hooks]
997 incoming.autobuild = /my/build/hook
997 incoming.autobuild = /my/build/hook
998 # enable translation to cmd.exe syntax for autobuild hook
998 # enable translation to cmd.exe syntax for autobuild hook
999 tonative.incoming.autobuild = True
999 tonative.incoming.autobuild = True
1000
1000
1001 ``changegroup``
1001 ``changegroup``
1002 Run after a changegroup has been added via push, pull or unbundle. The ID of
1002 Run after a changegroup has been added via push, pull or unbundle. The ID of
1003 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1003 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1004 The URL from which changes came is in ``$HG_URL``.
1004 The URL from which changes came is in ``$HG_URL``.
1005
1005
1006 ``commit``
1006 ``commit``
1007 Run after a changeset has been created in the local repository. The ID
1007 Run after a changeset has been created in the local repository. The ID
1008 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1008 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1009 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1009 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1010
1010
1011 ``incoming``
1011 ``incoming``
1012 Run after a changeset has been pulled, pushed, or unbundled into
1012 Run after a changeset has been pulled, pushed, or unbundled into
1013 the local repository. The ID of the newly arrived changeset is in
1013 the local repository. The ID of the newly arrived changeset is in
1014 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1014 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1015
1015
1016 ``outgoing``
1016 ``outgoing``
1017 Run after sending changes from the local repository to another. The ID of
1017 Run after sending changes from the local repository to another. The ID of
1018 first changeset sent is in ``$HG_NODE``. The source of operation is in
1018 first changeset sent is in ``$HG_NODE``. The source of operation is in
1019 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1019 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1020
1020
1021 ``post-<command>``
1021 ``post-<command>``
1022 Run after successful invocations of the associated command. The
1022 Run after successful invocations of the associated command. The
1023 contents of the command line are passed as ``$HG_ARGS`` and the result
1023 contents of the command line are passed as ``$HG_ARGS`` and the result
1024 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1024 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1025 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1025 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1026 the python data internally passed to <command>. ``$HG_OPTS`` is a
1026 the python data internally passed to <command>. ``$HG_OPTS`` is a
1027 dictionary of options (with unspecified options set to their defaults).
1027 dictionary of options (with unspecified options set to their defaults).
1028 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1028 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1029
1029
1030 ``fail-<command>``
1030 ``fail-<command>``
1031 Run after a failed invocation of an associated command. The contents
1031 Run after a failed invocation of an associated command. The contents
1032 of the command line are passed as ``$HG_ARGS``. Parsed command line
1032 of the command line are passed as ``$HG_ARGS``. Parsed command line
1033 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1033 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1034 string representations of the python data internally passed to
1034 string representations of the python data internally passed to
1035 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1035 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1036 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1036 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1037 Hook failure is ignored.
1037 Hook failure is ignored.
1038
1038
1039 ``pre-<command>``
1039 ``pre-<command>``
1040 Run before executing the associated command. The contents of the
1040 Run before executing the associated command. The contents of the
1041 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1041 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1042 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1042 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1043 representations of the data internally passed to <command>. ``$HG_OPTS``
1043 representations of the data internally passed to <command>. ``$HG_OPTS``
1044 is a dictionary of options (with unspecified options set to their
1044 is a dictionary of options (with unspecified options set to their
1045 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1045 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1046 failure, the command doesn't execute and Mercurial returns the failure
1046 failure, the command doesn't execute and Mercurial returns the failure
1047 code.
1047 code.
1048
1048
1049 ``prechangegroup``
1049 ``prechangegroup``
1050 Run before a changegroup is added via push, pull or unbundle. Exit
1050 Run before a changegroup is added via push, pull or unbundle. Exit
1051 status 0 allows the changegroup to proceed. A non-zero status will
1051 status 0 allows the changegroup to proceed. A non-zero status will
1052 cause the push, pull or unbundle to fail. The URL from which changes
1052 cause the push, pull or unbundle to fail. The URL from which changes
1053 will come is in ``$HG_URL``.
1053 will come is in ``$HG_URL``.
1054
1054
1055 ``precommit``
1055 ``precommit``
1056 Run before starting a local commit. Exit status 0 allows the
1056 Run before starting a local commit. Exit status 0 allows the
1057 commit to proceed. A non-zero status will cause the commit to fail.
1057 commit to proceed. A non-zero status will cause the commit to fail.
1058 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1058 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1059
1059
1060 ``prelistkeys``
1060 ``prelistkeys``
1061 Run before listing pushkeys (like bookmarks) in the
1061 Run before listing pushkeys (like bookmarks) in the
1062 repository. A non-zero status will cause failure. The key namespace is
1062 repository. A non-zero status will cause failure. The key namespace is
1063 in ``$HG_NAMESPACE``.
1063 in ``$HG_NAMESPACE``.
1064
1064
1065 ``preoutgoing``
1065 ``preoutgoing``
1066 Run before collecting changes to send from the local repository to
1066 Run before collecting changes to send from the local repository to
1067 another. A non-zero status will cause failure. This lets you prevent
1067 another. A non-zero status will cause failure. This lets you prevent
1068 pull over HTTP or SSH. It can also prevent propagating commits (via
1068 pull over HTTP or SSH. It can also prevent propagating commits (via
1069 local pull, push (outbound) or bundle commands), but not completely,
1069 local pull, push (outbound) or bundle commands), but not completely,
1070 since you can just copy files instead. The source of operation is in
1070 since you can just copy files instead. The source of operation is in
1071 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1071 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1072 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1072 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1073 is happening on behalf of a repository on same system.
1073 is happening on behalf of a repository on same system.
1074
1074
1075 ``prepushkey``
1075 ``prepushkey``
1076 Run before a pushkey (like a bookmark) is added to the
1076 Run before a pushkey (like a bookmark) is added to the
1077 repository. A non-zero status will cause the key to be rejected. The
1077 repository. A non-zero status will cause the key to be rejected. The
1078 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1078 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1079 the old value (if any) is in ``$HG_OLD``, and the new value is in
1079 the old value (if any) is in ``$HG_OLD``, and the new value is in
1080 ``$HG_NEW``.
1080 ``$HG_NEW``.
1081
1081
1082 ``pretag``
1082 ``pretag``
1083 Run before creating a tag. Exit status 0 allows the tag to be
1083 Run before creating a tag. Exit status 0 allows the tag to be
1084 created. A non-zero status will cause the tag to fail. The ID of the
1084 created. A non-zero status will cause the tag to fail. The ID of the
1085 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1085 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1086 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1086 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1087
1087
1088 ``pretxnopen``
1088 ``pretxnopen``
1089 Run before any new repository transaction is open. The reason for the
1089 Run before any new repository transaction is open. The reason for the
1090 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1090 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1091 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1091 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1092 transaction from being opened.
1092 transaction from being opened.
1093
1093
1094 ``pretxnclose``
1094 ``pretxnclose``
1095 Run right before the transaction is actually finalized. Any repository change
1095 Run right before the transaction is actually finalized. Any repository change
1096 will be visible to the hook program. This lets you validate the transaction
1096 will be visible to the hook program. This lets you validate the transaction
1097 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1097 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1098 status will cause the transaction to be rolled back. The reason for the
1098 status will cause the transaction to be rolled back. The reason for the
1099 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1099 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1100 the transaction will be in ``HG_TXNID``. The rest of the available data will
1100 the transaction will be in ``HG_TXNID``. The rest of the available data will
1101 vary according the transaction type. New changesets will add ``$HG_NODE``
1101 vary according the transaction type. New changesets will add ``$HG_NODE``
1102 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1102 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1103 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1103 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1104 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1104 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1105 respectively, etc.
1105 respectively, etc.
1106
1106
1107 ``pretxnclose-bookmark``
1107 ``pretxnclose-bookmark``
1108 Run right before a bookmark change is actually finalized. Any repository
1108 Run right before a bookmark change is actually finalized. Any repository
1109 change will be visible to the hook program. This lets you validate the
1109 change will be visible to the hook program. This lets you validate the
1110 transaction content or change it. Exit status 0 allows the commit to
1110 transaction content or change it. Exit status 0 allows the commit to
1111 proceed. A non-zero status will cause the transaction to be rolled back.
1111 proceed. A non-zero status will cause the transaction to be rolled back.
1112 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1112 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1113 bookmark location will be available in ``$HG_NODE`` while the previous
1113 bookmark location will be available in ``$HG_NODE`` while the previous
1114 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1114 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1115 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1115 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1116 will be empty.
1116 will be empty.
1117 In addition, the reason for the transaction opening will be in
1117 In addition, the reason for the transaction opening will be in
1118 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1118 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1119 ``HG_TXNID``.
1119 ``HG_TXNID``.
1120
1120
1121 ``pretxnclose-phase``
1121 ``pretxnclose-phase``
1122 Run right before a phase change is actually finalized. Any repository change
1122 Run right before a phase change is actually finalized. Any repository change
1123 will be visible to the hook program. This lets you validate the transaction
1123 will be visible to the hook program. This lets you validate the transaction
1124 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1124 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1125 status will cause the transaction to be rolled back. The hook is called
1125 status will cause the transaction to be rolled back. The hook is called
1126 multiple times, once for each revision affected by a phase change.
1126 multiple times, once for each revision affected by a phase change.
1127 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1127 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1128 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1128 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1129 will be empty. In addition, the reason for the transaction opening will be in
1129 will be empty. In addition, the reason for the transaction opening will be in
1130 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1130 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1131 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1131 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1132 the ``$HG_OLDPHASE`` entry will be empty.
1132 the ``$HG_OLDPHASE`` entry will be empty.
1133
1133
1134 ``txnclose``
1134 ``txnclose``
1135 Run after any repository transaction has been committed. At this
1135 Run after any repository transaction has been committed. At this
1136 point, the transaction can no longer be rolled back. The hook will run
1136 point, the transaction can no longer be rolled back. The hook will run
1137 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1137 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1138 details about available variables.
1138 details about available variables.
1139
1139
1140 ``txnclose-bookmark``
1140 ``txnclose-bookmark``
1141 Run after any bookmark change has been committed. At this point, the
1141 Run after any bookmark change has been committed. At this point, the
1142 transaction can no longer be rolled back. The hook will run after the lock
1142 transaction can no longer be rolled back. The hook will run after the lock
1143 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1143 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1144 about available variables.
1144 about available variables.
1145
1145
1146 ``txnclose-phase``
1146 ``txnclose-phase``
1147 Run after any phase change has been committed. At this point, the
1147 Run after any phase change has been committed. At this point, the
1148 transaction can no longer be rolled back. The hook will run after the lock
1148 transaction can no longer be rolled back. The hook will run after the lock
1149 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1149 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1150 available variables.
1150 available variables.
1151
1151
1152 ``txnabort``
1152 ``txnabort``
1153 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1153 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1154 for details about available variables.
1154 for details about available variables.
1155
1155
1156 ``pretxnchangegroup``
1156 ``pretxnchangegroup``
1157 Run after a changegroup has been added via push, pull or unbundle, but before
1157 Run after a changegroup has been added via push, pull or unbundle, but before
1158 the transaction has been committed. The changegroup is visible to the hook
1158 the transaction has been committed. The changegroup is visible to the hook
1159 program. This allows validation of incoming changes before accepting them.
1159 program. This allows validation of incoming changes before accepting them.
1160 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1160 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1161 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1161 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1162 status will cause the transaction to be rolled back, and the push, pull or
1162 status will cause the transaction to be rolled back, and the push, pull or
1163 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1163 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1164
1164
1165 ``pretxncommit``
1165 ``pretxncommit``
1166 Run after a changeset has been created, but before the transaction is
1166 Run after a changeset has been created, but before the transaction is
1167 committed. The changeset is visible to the hook program. This allows
1167 committed. The changeset is visible to the hook program. This allows
1168 validation of the commit message and changes. Exit status 0 allows the
1168 validation of the commit message and changes. Exit status 0 allows the
1169 commit to proceed. A non-zero status will cause the transaction to
1169 commit to proceed. A non-zero status will cause the transaction to
1170 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1170 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1171 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1171 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1172
1172
1173 ``preupdate``
1173 ``preupdate``
1174 Run before updating the working directory. Exit status 0 allows
1174 Run before updating the working directory. Exit status 0 allows
1175 the update to proceed. A non-zero status will prevent the update.
1175 the update to proceed. A non-zero status will prevent the update.
1176 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1176 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1177 merge, the ID of second new parent is in ``$HG_PARENT2``.
1177 merge, the ID of second new parent is in ``$HG_PARENT2``.
1178
1178
1179 ``listkeys``
1179 ``listkeys``
1180 Run after listing pushkeys (like bookmarks) in the repository. The
1180 Run after listing pushkeys (like bookmarks) in the repository. The
1181 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1181 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1182 dictionary containing the keys and values.
1182 dictionary containing the keys and values.
1183
1183
1184 ``pushkey``
1184 ``pushkey``
1185 Run after a pushkey (like a bookmark) is added to the
1185 Run after a pushkey (like a bookmark) is added to the
1186 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1186 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1187 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1187 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1188 value is in ``$HG_NEW``.
1188 value is in ``$HG_NEW``.
1189
1189
1190 ``tag``
1190 ``tag``
1191 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1191 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1192 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1192 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1193 the repository if ``$HG_LOCAL=0``.
1193 the repository if ``$HG_LOCAL=0``.
1194
1194
1195 ``update``
1195 ``update``
1196 Run after updating the working directory. The changeset ID of first
1196 Run after updating the working directory. The changeset ID of first
1197 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1197 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1198 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1198 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1199 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1199 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1200
1200
1201 .. note::
1201 .. note::
1202
1202
1203 It is generally better to use standard hooks rather than the
1203 It is generally better to use standard hooks rather than the
1204 generic pre- and post- command hooks, as they are guaranteed to be
1204 generic pre- and post- command hooks, as they are guaranteed to be
1205 called in the appropriate contexts for influencing transactions.
1205 called in the appropriate contexts for influencing transactions.
1206 Also, hooks like "commit" will be called in all contexts that
1206 Also, hooks like "commit" will be called in all contexts that
1207 generate a commit (e.g. tag) and not just the commit command.
1207 generate a commit (e.g. tag) and not just the commit command.
1208
1208
1209 .. note::
1209 .. note::
1210
1210
1211 Environment variables with empty values may not be passed to
1211 Environment variables with empty values may not be passed to
1212 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1212 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1213 will have an empty value under Unix-like platforms for non-merge
1213 will have an empty value under Unix-like platforms for non-merge
1214 changesets, while it will not be available at all under Windows.
1214 changesets, while it will not be available at all under Windows.
1215
1215
1216 The syntax for Python hooks is as follows::
1216 The syntax for Python hooks is as follows::
1217
1217
1218 hookname = python:modulename.submodule.callable
1218 hookname = python:modulename.submodule.callable
1219 hookname = python:/path/to/python/module.py:callable
1219 hookname = python:/path/to/python/module.py:callable
1220
1220
1221 Python hooks are run within the Mercurial process. Each hook is
1221 Python hooks are run within the Mercurial process. Each hook is
1222 called with at least three keyword arguments: a ui object (keyword
1222 called with at least three keyword arguments: a ui object (keyword
1223 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1223 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1224 keyword that tells what kind of hook is used. Arguments listed as
1224 keyword that tells what kind of hook is used. Arguments listed as
1225 environment variables above are passed as keyword arguments, with no
1225 environment variables above are passed as keyword arguments, with no
1226 ``HG_`` prefix, and names in lower case.
1226 ``HG_`` prefix, and names in lower case.
1227
1227
1228 If a Python hook returns a "true" value or raises an exception, this
1228 If a Python hook returns a "true" value or raises an exception, this
1229 is treated as a failure.
1229 is treated as a failure.
1230
1230
1231
1231
1232 ``hostfingerprints``
1232 ``hostfingerprints``
1233 --------------------
1233 --------------------
1234
1234
1235 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1235 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1236
1236
1237 Fingerprints of the certificates of known HTTPS servers.
1237 Fingerprints of the certificates of known HTTPS servers.
1238
1238
1239 A HTTPS connection to a server with a fingerprint configured here will
1239 A HTTPS connection to a server with a fingerprint configured here will
1240 only succeed if the servers certificate matches the fingerprint.
1240 only succeed if the servers certificate matches the fingerprint.
1241 This is very similar to how ssh known hosts works.
1241 This is very similar to how ssh known hosts works.
1242
1242
1243 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1243 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1244 Multiple values can be specified (separated by spaces or commas). This can
1244 Multiple values can be specified (separated by spaces or commas). This can
1245 be used to define both old and new fingerprints while a host transitions
1245 be used to define both old and new fingerprints while a host transitions
1246 to a new certificate.
1246 to a new certificate.
1247
1247
1248 The CA chain and web.cacerts is not used for servers with a fingerprint.
1248 The CA chain and web.cacerts is not used for servers with a fingerprint.
1249
1249
1250 For example::
1250 For example::
1251
1251
1252 [hostfingerprints]
1252 [hostfingerprints]
1253 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1253 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1254 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1254 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1255
1255
1256 ``hostsecurity``
1256 ``hostsecurity``
1257 ----------------
1257 ----------------
1258
1258
1259 Used to specify global and per-host security settings for connecting to
1259 Used to specify global and per-host security settings for connecting to
1260 other machines.
1260 other machines.
1261
1261
1262 The following options control default behavior for all hosts.
1262 The following options control default behavior for all hosts.
1263
1263
1264 ``ciphers``
1264 ``ciphers``
1265 Defines the cryptographic ciphers to use for connections.
1265 Defines the cryptographic ciphers to use for connections.
1266
1266
1267 Value must be a valid OpenSSL Cipher List Format as documented at
1267 Value must be a valid OpenSSL Cipher List Format as documented at
1268 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1268 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1269
1269
1270 This setting is for advanced users only. Setting to incorrect values
1270 This setting is for advanced users only. Setting to incorrect values
1271 can significantly lower connection security or decrease performance.
1271 can significantly lower connection security or decrease performance.
1272 You have been warned.
1272 You have been warned.
1273
1273
1274 This option requires Python 2.7.
1274 This option requires Python 2.7.
1275
1275
1276 ``minimumprotocol``
1276 ``minimumprotocol``
1277 Defines the minimum channel encryption protocol to use.
1277 Defines the minimum channel encryption protocol to use.
1278
1278
1279 By default, the highest version of TLS supported by both client and server
1279 By default, the highest version of TLS supported by both client and server
1280 is used.
1280 is used.
1281
1281
1282 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1282 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1283
1283
1284 When running on an old Python version, only ``tls1.0`` is allowed since
1284 When running on an old Python version, only ``tls1.0`` is allowed since
1285 old versions of Python only support up to TLS 1.0.
1285 old versions of Python only support up to TLS 1.0.
1286
1286
1287 When running a Python that supports modern TLS versions, the default is
1287 When running a Python that supports modern TLS versions, the default is
1288 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1288 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1289 weakens security and should only be used as a feature of last resort if
1289 weakens security and should only be used as a feature of last resort if
1290 a server does not support TLS 1.1+.
1290 a server does not support TLS 1.1+.
1291
1291
1292 Options in the ``[hostsecurity]`` section can have the form
1292 Options in the ``[hostsecurity]`` section can have the form
1293 ``hostname``:``setting``. This allows multiple settings to be defined on a
1293 ``hostname``:``setting``. This allows multiple settings to be defined on a
1294 per-host basis.
1294 per-host basis.
1295
1295
1296 The following per-host settings can be defined.
1296 The following per-host settings can be defined.
1297
1297
1298 ``ciphers``
1298 ``ciphers``
1299 This behaves like ``ciphers`` as described above except it only applies
1299 This behaves like ``ciphers`` as described above except it only applies
1300 to the host on which it is defined.
1300 to the host on which it is defined.
1301
1301
1302 ``fingerprints``
1302 ``fingerprints``
1303 A list of hashes of the DER encoded peer/remote certificate. Values have
1303 A list of hashes of the DER encoded peer/remote certificate. Values have
1304 the form ``algorithm``:``fingerprint``. e.g.
1304 the form ``algorithm``:``fingerprint``. e.g.
1305 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1305 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1306 In addition, colons (``:``) can appear in the fingerprint part.
1306 In addition, colons (``:``) can appear in the fingerprint part.
1307
1307
1308 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1308 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1309 ``sha512``.
1309 ``sha512``.
1310
1310
1311 Use of ``sha256`` or ``sha512`` is preferred.
1311 Use of ``sha256`` or ``sha512`` is preferred.
1312
1312
1313 If a fingerprint is specified, the CA chain is not validated for this
1313 If a fingerprint is specified, the CA chain is not validated for this
1314 host and Mercurial will require the remote certificate to match one
1314 host and Mercurial will require the remote certificate to match one
1315 of the fingerprints specified. This means if the server updates its
1315 of the fingerprints specified. This means if the server updates its
1316 certificate, Mercurial will abort until a new fingerprint is defined.
1316 certificate, Mercurial will abort until a new fingerprint is defined.
1317 This can provide stronger security than traditional CA-based validation
1317 This can provide stronger security than traditional CA-based validation
1318 at the expense of convenience.
1318 at the expense of convenience.
1319
1319
1320 This option takes precedence over ``verifycertsfile``.
1320 This option takes precedence over ``verifycertsfile``.
1321
1321
1322 ``minimumprotocol``
1322 ``minimumprotocol``
1323 This behaves like ``minimumprotocol`` as described above except it
1323 This behaves like ``minimumprotocol`` as described above except it
1324 only applies to the host on which it is defined.
1324 only applies to the host on which it is defined.
1325
1325
1326 ``verifycertsfile``
1326 ``verifycertsfile``
1327 Path to file a containing a list of PEM encoded certificates used to
1327 Path to file a containing a list of PEM encoded certificates used to
1328 verify the server certificate. Environment variables and ``~user``
1328 verify the server certificate. Environment variables and ``~user``
1329 constructs are expanded in the filename.
1329 constructs are expanded in the filename.
1330
1330
1331 The server certificate or the certificate's certificate authority (CA)
1331 The server certificate or the certificate's certificate authority (CA)
1332 must match a certificate from this file or certificate verification
1332 must match a certificate from this file or certificate verification
1333 will fail and connections to the server will be refused.
1333 will fail and connections to the server will be refused.
1334
1334
1335 If defined, only certificates provided by this file will be used:
1335 If defined, only certificates provided by this file will be used:
1336 ``web.cacerts`` and any system/default certificates will not be
1336 ``web.cacerts`` and any system/default certificates will not be
1337 used.
1337 used.
1338
1338
1339 This option has no effect if the per-host ``fingerprints`` option
1339 This option has no effect if the per-host ``fingerprints`` option
1340 is set.
1340 is set.
1341
1341
1342 The format of the file is as follows::
1342 The format of the file is as follows::
1343
1343
1344 -----BEGIN CERTIFICATE-----
1344 -----BEGIN CERTIFICATE-----
1345 ... (certificate in base64 PEM encoding) ...
1345 ... (certificate in base64 PEM encoding) ...
1346 -----END CERTIFICATE-----
1346 -----END CERTIFICATE-----
1347 -----BEGIN CERTIFICATE-----
1347 -----BEGIN CERTIFICATE-----
1348 ... (certificate in base64 PEM encoding) ...
1348 ... (certificate in base64 PEM encoding) ...
1349 -----END CERTIFICATE-----
1349 -----END CERTIFICATE-----
1350
1350
1351 For example::
1351 For example::
1352
1352
1353 [hostsecurity]
1353 [hostsecurity]
1354 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1354 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1355 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1355 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1356 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1356 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1357 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1357 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1358
1358
1359 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1359 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1360 when connecting to ``hg.example.com``::
1360 when connecting to ``hg.example.com``::
1361
1361
1362 [hostsecurity]
1362 [hostsecurity]
1363 minimumprotocol = tls1.2
1363 minimumprotocol = tls1.2
1364 hg.example.com:minimumprotocol = tls1.1
1364 hg.example.com:minimumprotocol = tls1.1
1365
1365
1366 ``http_proxy``
1366 ``http_proxy``
1367 --------------
1367 --------------
1368
1368
1369 Used to access web-based Mercurial repositories through a HTTP
1369 Used to access web-based Mercurial repositories through a HTTP
1370 proxy.
1370 proxy.
1371
1371
1372 ``host``
1372 ``host``
1373 Host name and (optional) port of the proxy server, for example
1373 Host name and (optional) port of the proxy server, for example
1374 "myproxy:8000".
1374 "myproxy:8000".
1375
1375
1376 ``no``
1376 ``no``
1377 Optional. Comma-separated list of host names that should bypass
1377 Optional. Comma-separated list of host names that should bypass
1378 the proxy.
1378 the proxy.
1379
1379
1380 ``passwd``
1380 ``passwd``
1381 Optional. Password to authenticate with at the proxy server.
1381 Optional. Password to authenticate with at the proxy server.
1382
1382
1383 ``user``
1383 ``user``
1384 Optional. User name to authenticate with at the proxy server.
1384 Optional. User name to authenticate with at the proxy server.
1385
1385
1386 ``always``
1386 ``always``
1387 Optional. Always use the proxy, even for localhost and any entries
1387 Optional. Always use the proxy, even for localhost and any entries
1388 in ``http_proxy.no``. (default: False)
1388 in ``http_proxy.no``. (default: False)
1389
1389
1390 ``http``
1390 ``http``
1391 ----------
1391 ----------
1392
1392
1393 Used to configure access to Mercurial repositories via HTTP.
1393 Used to configure access to Mercurial repositories via HTTP.
1394
1394
1395 ``timeout``
1395 ``timeout``
1396 If set, blocking operations will timeout after that many seconds.
1396 If set, blocking operations will timeout after that many seconds.
1397 (default: None)
1397 (default: None)
1398
1398
1399 ``merge``
1399 ``merge``
1400 ---------
1400 ---------
1401
1401
1402 This section specifies behavior during merges and updates.
1402 This section specifies behavior during merges and updates.
1403
1403
1404 ``checkignored``
1404 ``checkignored``
1405 Controls behavior when an ignored file on disk has the same name as a tracked
1405 Controls behavior when an ignored file on disk has the same name as a tracked
1406 file in the changeset being merged or updated to, and has different
1406 file in the changeset being merged or updated to, and has different
1407 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1407 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1408 abort on such files. With ``warn``, warn on such files and back them up as
1408 abort on such files. With ``warn``, warn on such files and back them up as
1409 ``.orig``. With ``ignore``, don't print a warning and back them up as
1409 ``.orig``. With ``ignore``, don't print a warning and back them up as
1410 ``.orig``. (default: ``abort``)
1410 ``.orig``. (default: ``abort``)
1411
1411
1412 ``checkunknown``
1412 ``checkunknown``
1413 Controls behavior when an unknown file that isn't ignored has the same name
1413 Controls behavior when an unknown file that isn't ignored has the same name
1414 as a tracked file in the changeset being merged or updated to, and has
1414 as a tracked file in the changeset being merged or updated to, and has
1415 different contents. Similar to ``merge.checkignored``, except for files that
1415 different contents. Similar to ``merge.checkignored``, except for files that
1416 are not ignored. (default: ``abort``)
1416 are not ignored. (default: ``abort``)
1417
1417
1418 ``on-failure``
1418 ``on-failure``
1419 When set to ``continue`` (the default), the merge process attempts to
1419 When set to ``continue`` (the default), the merge process attempts to
1420 merge all unresolved files using the merge chosen tool, regardless of
1420 merge all unresolved files using the merge chosen tool, regardless of
1421 whether previous file merge attempts during the process succeeded or not.
1421 whether previous file merge attempts during the process succeeded or not.
1422 Setting this to ``prompt`` will prompt after any merge failure continue
1422 Setting this to ``prompt`` will prompt after any merge failure continue
1423 or halt the merge process. Setting this to ``halt`` will automatically
1423 or halt the merge process. Setting this to ``halt`` will automatically
1424 halt the merge process on any merge tool failure. The merge process
1424 halt the merge process on any merge tool failure. The merge process
1425 can be restarted by using the ``resolve`` command. When a merge is
1425 can be restarted by using the ``resolve`` command. When a merge is
1426 halted, the repository is left in a normal ``unresolved`` merge state.
1426 halted, the repository is left in a normal ``unresolved`` merge state.
1427 (default: ``continue``)
1427 (default: ``continue``)
1428
1428
1429 ``strict-capability-check``
1429 ``strict-capability-check``
1430 Whether capabilities of internal merge tools are checked strictly
1430 Whether capabilities of internal merge tools are checked strictly
1431 or not, while examining rules to decide merge tool to be used.
1431 or not, while examining rules to decide merge tool to be used.
1432 (default: False)
1432 (default: False)
1433
1433
1434 ``merge-patterns``
1434 ``merge-patterns``
1435 ------------------
1435 ------------------
1436
1436
1437 This section specifies merge tools to associate with particular file
1437 This section specifies merge tools to associate with particular file
1438 patterns. Tools matched here will take precedence over the default
1438 patterns. Tools matched here will take precedence over the default
1439 merge tool. Patterns are globs by default, rooted at the repository
1439 merge tool. Patterns are globs by default, rooted at the repository
1440 root.
1440 root.
1441
1441
1442 Example::
1442 Example::
1443
1443
1444 [merge-patterns]
1444 [merge-patterns]
1445 **.c = kdiff3
1445 **.c = kdiff3
1446 **.jpg = myimgmerge
1446 **.jpg = myimgmerge
1447
1447
1448 ``merge-tools``
1448 ``merge-tools``
1449 ---------------
1449 ---------------
1450
1450
1451 This section configures external merge tools to use for file-level
1451 This section configures external merge tools to use for file-level
1452 merges. This section has likely been preconfigured at install time.
1452 merges. This section has likely been preconfigured at install time.
1453 Use :hg:`config merge-tools` to check the existing configuration.
1453 Use :hg:`config merge-tools` to check the existing configuration.
1454 Also see :hg:`help merge-tools` for more details.
1454 Also see :hg:`help merge-tools` for more details.
1455
1455
1456 Example ``~/.hgrc``::
1456 Example ``~/.hgrc``::
1457
1457
1458 [merge-tools]
1458 [merge-tools]
1459 # Override stock tool location
1459 # Override stock tool location
1460 kdiff3.executable = ~/bin/kdiff3
1460 kdiff3.executable = ~/bin/kdiff3
1461 # Specify command line
1461 # Specify command line
1462 kdiff3.args = $base $local $other -o $output
1462 kdiff3.args = $base $local $other -o $output
1463 # Give higher priority
1463 # Give higher priority
1464 kdiff3.priority = 1
1464 kdiff3.priority = 1
1465
1465
1466 # Changing the priority of preconfigured tool
1466 # Changing the priority of preconfigured tool
1467 meld.priority = 0
1467 meld.priority = 0
1468
1468
1469 # Disable a preconfigured tool
1469 # Disable a preconfigured tool
1470 vimdiff.disabled = yes
1470 vimdiff.disabled = yes
1471
1471
1472 # Define new tool
1472 # Define new tool
1473 myHtmlTool.args = -m $local $other $base $output
1473 myHtmlTool.args = -m $local $other $base $output
1474 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1474 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1475 myHtmlTool.priority = 1
1475 myHtmlTool.priority = 1
1476
1476
1477 Supported arguments:
1477 Supported arguments:
1478
1478
1479 ``priority``
1479 ``priority``
1480 The priority in which to evaluate this tool.
1480 The priority in which to evaluate this tool.
1481 (default: 0)
1481 (default: 0)
1482
1482
1483 ``executable``
1483 ``executable``
1484 Either just the name of the executable or its pathname.
1484 Either just the name of the executable or its pathname.
1485
1485
1486 .. container:: windows
1486 .. container:: windows
1487
1487
1488 On Windows, the path can use environment variables with ${ProgramFiles}
1488 On Windows, the path can use environment variables with ${ProgramFiles}
1489 syntax.
1489 syntax.
1490
1490
1491 (default: the tool name)
1491 (default: the tool name)
1492
1492
1493 ``args``
1493 ``args``
1494 The arguments to pass to the tool executable. You can refer to the
1494 The arguments to pass to the tool executable. You can refer to the
1495 files being merged as well as the output file through these
1495 files being merged as well as the output file through these
1496 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1496 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1497
1497
1498 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1498 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1499 being performed. During an update or merge, ``$local`` represents the original
1499 being performed. During an update or merge, ``$local`` represents the original
1500 state of the file, while ``$other`` represents the commit you are updating to or
1500 state of the file, while ``$other`` represents the commit you are updating to or
1501 the commit you are merging with. During a rebase, ``$local`` represents the
1501 the commit you are merging with. During a rebase, ``$local`` represents the
1502 destination of the rebase, and ``$other`` represents the commit being rebased.
1502 destination of the rebase, and ``$other`` represents the commit being rebased.
1503
1503
1504 Some operations define custom labels to assist with identifying the revisions,
1504 Some operations define custom labels to assist with identifying the revisions,
1505 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1505 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1506 labels are not available, these will be ``local``, ``other``, and ``base``,
1506 labels are not available, these will be ``local``, ``other``, and ``base``,
1507 respectively.
1507 respectively.
1508 (default: ``$local $base $other``)
1508 (default: ``$local $base $other``)
1509
1509
1510 ``premerge``
1510 ``premerge``
1511 Attempt to run internal non-interactive 3-way merge tool before
1511 Attempt to run internal non-interactive 3-way merge tool before
1512 launching external tool. Options are ``true``, ``false``, ``keep`` or
1512 launching external tool. Options are ``true``, ``false``, ``keep`` or
1513 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1513 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1514 premerge fails. The ``keep-merge3`` will do the same but include information
1514 premerge fails. The ``keep-merge3`` will do the same but include information
1515 about the base of the merge in the marker (see internal :merge3 in
1515 about the base of the merge in the marker (see internal :merge3 in
1516 :hg:`help merge-tools`).
1516 :hg:`help merge-tools`).
1517 (default: True)
1517 (default: True)
1518
1518
1519 ``binary``
1519 ``binary``
1520 This tool can merge binary files. (default: False, unless tool
1520 This tool can merge binary files. (default: False, unless tool
1521 was selected by file pattern match)
1521 was selected by file pattern match)
1522
1522
1523 ``symlink``
1523 ``symlink``
1524 This tool can merge symlinks. (default: False)
1524 This tool can merge symlinks. (default: False)
1525
1525
1526 ``check``
1526 ``check``
1527 A list of merge success-checking options:
1527 A list of merge success-checking options:
1528
1528
1529 ``changed``
1529 ``changed``
1530 Ask whether merge was successful when the merged file shows no changes.
1530 Ask whether merge was successful when the merged file shows no changes.
1531 ``conflicts``
1531 ``conflicts``
1532 Check whether there are conflicts even though the tool reported success.
1532 Check whether there are conflicts even though the tool reported success.
1533 ``prompt``
1533 ``prompt``
1534 Always prompt for merge success, regardless of success reported by tool.
1534 Always prompt for merge success, regardless of success reported by tool.
1535
1535
1536 ``fixeol``
1536 ``fixeol``
1537 Attempt to fix up EOL changes caused by the merge tool.
1537 Attempt to fix up EOL changes caused by the merge tool.
1538 (default: False)
1538 (default: False)
1539
1539
1540 ``gui``
1540 ``gui``
1541 This tool requires a graphical interface to run. (default: False)
1541 This tool requires a graphical interface to run. (default: False)
1542
1542
1543 ``mergemarkers``
1543 ``mergemarkers``
1544 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1544 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1545 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1545 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1546 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1546 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1547 markers generated during premerge will be ``detailed`` if either this option or
1547 markers generated during premerge will be ``detailed`` if either this option or
1548 the corresponding option in the ``[ui]`` section is ``detailed``.
1548 the corresponding option in the ``[ui]`` section is ``detailed``.
1549 (default: ``basic``)
1549 (default: ``basic``)
1550
1550
1551 ``mergemarkertemplate``
1551 ``mergemarkertemplate``
1552 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1552 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1553 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1553 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1554 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1554 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1555 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1555 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1556 information.
1556 information.
1557
1557
1558 .. container:: windows
1558 .. container:: windows
1559
1559
1560 ``regkey``
1560 ``regkey``
1561 Windows registry key which describes install location of this
1561 Windows registry key which describes install location of this
1562 tool. Mercurial will search for this key first under
1562 tool. Mercurial will search for this key first under
1563 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1563 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1564 (default: None)
1564 (default: None)
1565
1565
1566 ``regkeyalt``
1566 ``regkeyalt``
1567 An alternate Windows registry key to try if the first key is not
1567 An alternate Windows registry key to try if the first key is not
1568 found. The alternate key uses the same ``regname`` and ``regappend``
1568 found. The alternate key uses the same ``regname`` and ``regappend``
1569 semantics of the primary key. The most common use for this key
1569 semantics of the primary key. The most common use for this key
1570 is to search for 32bit applications on 64bit operating systems.
1570 is to search for 32bit applications on 64bit operating systems.
1571 (default: None)
1571 (default: None)
1572
1572
1573 ``regname``
1573 ``regname``
1574 Name of value to read from specified registry key.
1574 Name of value to read from specified registry key.
1575 (default: the unnamed (default) value)
1575 (default: the unnamed (default) value)
1576
1576
1577 ``regappend``
1577 ``regappend``
1578 String to append to the value read from the registry, typically
1578 String to append to the value read from the registry, typically
1579 the executable name of the tool.
1579 the executable name of the tool.
1580 (default: None)
1580 (default: None)
1581
1581
1582 ``pager``
1582 ``pager``
1583 ---------
1583 ---------
1584
1584
1585 Setting used to control when to paginate and with what external tool. See
1585 Setting used to control when to paginate and with what external tool. See
1586 :hg:`help pager` for details.
1586 :hg:`help pager` for details.
1587
1587
1588 ``pager``
1588 ``pager``
1589 Define the external tool used as pager.
1589 Define the external tool used as pager.
1590
1590
1591 If no pager is set, Mercurial uses the environment variable $PAGER.
1591 If no pager is set, Mercurial uses the environment variable $PAGER.
1592 If neither pager.pager, nor $PAGER is set, a default pager will be
1592 If neither pager.pager, nor $PAGER is set, a default pager will be
1593 used, typically `less` on Unix and `more` on Windows. Example::
1593 used, typically `less` on Unix and `more` on Windows. Example::
1594
1594
1595 [pager]
1595 [pager]
1596 pager = less -FRX
1596 pager = less -FRX
1597
1597
1598 ``ignore``
1598 ``ignore``
1599 List of commands to disable the pager for. Example::
1599 List of commands to disable the pager for. Example::
1600
1600
1601 [pager]
1601 [pager]
1602 ignore = version, help, update
1602 ignore = version, help, update
1603
1603
1604 ``patch``
1604 ``patch``
1605 ---------
1605 ---------
1606
1606
1607 Settings used when applying patches, for instance through the 'import'
1607 Settings used when applying patches, for instance through the 'import'
1608 command or with Mercurial Queues extension.
1608 command or with Mercurial Queues extension.
1609
1609
1610 ``eol``
1610 ``eol``
1611 When set to 'strict' patch content and patched files end of lines
1611 When set to 'strict' patch content and patched files end of lines
1612 are preserved. When set to ``lf`` or ``crlf``, both files end of
1612 are preserved. When set to ``lf`` or ``crlf``, both files end of
1613 lines are ignored when patching and the result line endings are
1613 lines are ignored when patching and the result line endings are
1614 normalized to either LF (Unix) or CRLF (Windows). When set to
1614 normalized to either LF (Unix) or CRLF (Windows). When set to
1615 ``auto``, end of lines are again ignored while patching but line
1615 ``auto``, end of lines are again ignored while patching but line
1616 endings in patched files are normalized to their original setting
1616 endings in patched files are normalized to their original setting
1617 on a per-file basis. If target file does not exist or has no end
1617 on a per-file basis. If target file does not exist or has no end
1618 of line, patch line endings are preserved.
1618 of line, patch line endings are preserved.
1619 (default: strict)
1619 (default: strict)
1620
1620
1621 ``fuzz``
1621 ``fuzz``
1622 The number of lines of 'fuzz' to allow when applying patches. This
1622 The number of lines of 'fuzz' to allow when applying patches. This
1623 controls how much context the patcher is allowed to ignore when
1623 controls how much context the patcher is allowed to ignore when
1624 trying to apply a patch.
1624 trying to apply a patch.
1625 (default: 2)
1625 (default: 2)
1626
1626
1627 ``paths``
1627 ``paths``
1628 ---------
1628 ---------
1629
1629
1630 Assigns symbolic names and behavior to repositories.
1630 Assigns symbolic names and behavior to repositories.
1631
1631
1632 Options are symbolic names defining the URL or directory that is the
1632 Options are symbolic names defining the URL or directory that is the
1633 location of the repository. Example::
1633 location of the repository. Example::
1634
1634
1635 [paths]
1635 [paths]
1636 my_server = https://example.com/my_repo
1636 my_server = https://example.com/my_repo
1637 local_path = /home/me/repo
1637 local_path = /home/me/repo
1638
1638
1639 These symbolic names can be used from the command line. To pull
1639 These symbolic names can be used from the command line. To pull
1640 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1640 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1641 :hg:`push local_path`.
1641 :hg:`push local_path`.
1642
1642
1643 Options containing colons (``:``) denote sub-options that can influence
1643 Options containing colons (``:``) denote sub-options that can influence
1644 behavior for that specific path. Example::
1644 behavior for that specific path. Example::
1645
1645
1646 [paths]
1646 [paths]
1647 my_server = https://example.com/my_path
1647 my_server = https://example.com/my_path
1648 my_server:pushurl = ssh://example.com/my_path
1648 my_server:pushurl = ssh://example.com/my_path
1649
1649
1650 The following sub-options can be defined:
1650 The following sub-options can be defined:
1651
1651
1652 ``pushurl``
1652 ``pushurl``
1653 The URL to use for push operations. If not defined, the location
1653 The URL to use for push operations. If not defined, the location
1654 defined by the path's main entry is used.
1654 defined by the path's main entry is used.
1655
1655
1656 ``pushrev``
1656 ``pushrev``
1657 A revset defining which revisions to push by default.
1657 A revset defining which revisions to push by default.
1658
1658
1659 When :hg:`push` is executed without a ``-r`` argument, the revset
1659 When :hg:`push` is executed without a ``-r`` argument, the revset
1660 defined by this sub-option is evaluated to determine what to push.
1660 defined by this sub-option is evaluated to determine what to push.
1661
1661
1662 For example, a value of ``.`` will push the working directory's
1662 For example, a value of ``.`` will push the working directory's
1663 revision by default.
1663 revision by default.
1664
1664
1665 Revsets specifying bookmarks will not result in the bookmark being
1665 Revsets specifying bookmarks will not result in the bookmark being
1666 pushed.
1666 pushed.
1667
1667
1668 The following special named paths exist:
1668 The following special named paths exist:
1669
1669
1670 ``default``
1670 ``default``
1671 The URL or directory to use when no source or remote is specified.
1671 The URL or directory to use when no source or remote is specified.
1672
1672
1673 :hg:`clone` will automatically define this path to the location the
1673 :hg:`clone` will automatically define this path to the location the
1674 repository was cloned from.
1674 repository was cloned from.
1675
1675
1676 ``default-push``
1676 ``default-push``
1677 (deprecated) The URL or directory for the default :hg:`push` location.
1677 (deprecated) The URL or directory for the default :hg:`push` location.
1678 ``default:pushurl`` should be used instead.
1678 ``default:pushurl`` should be used instead.
1679
1679
1680 ``phases``
1680 ``phases``
1681 ----------
1681 ----------
1682
1682
1683 Specifies default handling of phases. See :hg:`help phases` for more
1683 Specifies default handling of phases. See :hg:`help phases` for more
1684 information about working with phases.
1684 information about working with phases.
1685
1685
1686 ``publish``
1686 ``publish``
1687 Controls draft phase behavior when working as a server. When true,
1687 Controls draft phase behavior when working as a server. When true,
1688 pushed changesets are set to public in both client and server and
1688 pushed changesets are set to public in both client and server and
1689 pulled or cloned changesets are set to public in the client.
1689 pulled or cloned changesets are set to public in the client.
1690 (default: True)
1690 (default: True)
1691
1691
1692 ``new-commit``
1692 ``new-commit``
1693 Phase of newly-created commits.
1693 Phase of newly-created commits.
1694 (default: draft)
1694 (default: draft)
1695
1695
1696 ``checksubrepos``
1696 ``checksubrepos``
1697 Check the phase of the current revision of each subrepository. Allowed
1697 Check the phase of the current revision of each subrepository. Allowed
1698 values are "ignore", "follow" and "abort". For settings other than
1698 values are "ignore", "follow" and "abort". For settings other than
1699 "ignore", the phase of the current revision of each subrepository is
1699 "ignore", the phase of the current revision of each subrepository is
1700 checked before committing the parent repository. If any of those phases is
1700 checked before committing the parent repository. If any of those phases is
1701 greater than the phase of the parent repository (e.g. if a subrepo is in a
1701 greater than the phase of the parent repository (e.g. if a subrepo is in a
1702 "secret" phase while the parent repo is in "draft" phase), the commit is
1702 "secret" phase while the parent repo is in "draft" phase), the commit is
1703 either aborted (if checksubrepos is set to "abort") or the higher phase is
1703 either aborted (if checksubrepos is set to "abort") or the higher phase is
1704 used for the parent repository commit (if set to "follow").
1704 used for the parent repository commit (if set to "follow").
1705 (default: follow)
1705 (default: follow)
1706
1706
1707
1707
1708 ``profiling``
1708 ``profiling``
1709 -------------
1709 -------------
1710
1710
1711 Specifies profiling type, format, and file output. Two profilers are
1711 Specifies profiling type, format, and file output. Two profilers are
1712 supported: an instrumenting profiler (named ``ls``), and a sampling
1712 supported: an instrumenting profiler (named ``ls``), and a sampling
1713 profiler (named ``stat``).
1713 profiler (named ``stat``).
1714
1714
1715 In this section description, 'profiling data' stands for the raw data
1715 In this section description, 'profiling data' stands for the raw data
1716 collected during profiling, while 'profiling report' stands for a
1716 collected during profiling, while 'profiling report' stands for a
1717 statistical text report generated from the profiling data.
1717 statistical text report generated from the profiling data.
1718
1718
1719 ``enabled``
1719 ``enabled``
1720 Enable the profiler.
1720 Enable the profiler.
1721 (default: false)
1721 (default: false)
1722
1722
1723 This is equivalent to passing ``--profile`` on the command line.
1723 This is equivalent to passing ``--profile`` on the command line.
1724
1724
1725 ``type``
1725 ``type``
1726 The type of profiler to use.
1726 The type of profiler to use.
1727 (default: stat)
1727 (default: stat)
1728
1728
1729 ``ls``
1729 ``ls``
1730 Use Python's built-in instrumenting profiler. This profiler
1730 Use Python's built-in instrumenting profiler. This profiler
1731 works on all platforms, but each line number it reports is the
1731 works on all platforms, but each line number it reports is the
1732 first line of a function. This restriction makes it difficult to
1732 first line of a function. This restriction makes it difficult to
1733 identify the expensive parts of a non-trivial function.
1733 identify the expensive parts of a non-trivial function.
1734 ``stat``
1734 ``stat``
1735 Use a statistical profiler, statprof. This profiler is most
1735 Use a statistical profiler, statprof. This profiler is most
1736 useful for profiling commands that run for longer than about 0.1
1736 useful for profiling commands that run for longer than about 0.1
1737 seconds.
1737 seconds.
1738
1738
1739 ``format``
1739 ``format``
1740 Profiling format. Specific to the ``ls`` instrumenting profiler.
1740 Profiling format. Specific to the ``ls`` instrumenting profiler.
1741 (default: text)
1741 (default: text)
1742
1742
1743 ``text``
1743 ``text``
1744 Generate a profiling report. When saving to a file, it should be
1744 Generate a profiling report. When saving to a file, it should be
1745 noted that only the report is saved, and the profiling data is
1745 noted that only the report is saved, and the profiling data is
1746 not kept.
1746 not kept.
1747 ``kcachegrind``
1747 ``kcachegrind``
1748 Format profiling data for kcachegrind use: when saving to a
1748 Format profiling data for kcachegrind use: when saving to a
1749 file, the generated file can directly be loaded into
1749 file, the generated file can directly be loaded into
1750 kcachegrind.
1750 kcachegrind.
1751
1751
1752 ``statformat``
1752 ``statformat``
1753 Profiling format for the ``stat`` profiler.
1753 Profiling format for the ``stat`` profiler.
1754 (default: hotpath)
1754 (default: hotpath)
1755
1755
1756 ``hotpath``
1756 ``hotpath``
1757 Show a tree-based display containing the hot path of execution (where
1757 Show a tree-based display containing the hot path of execution (where
1758 most time was spent).
1758 most time was spent).
1759 ``bymethod``
1759 ``bymethod``
1760 Show a table of methods ordered by how frequently they are active.
1760 Show a table of methods ordered by how frequently they are active.
1761 ``byline``
1761 ``byline``
1762 Show a table of lines in files ordered by how frequently they are active.
1762 Show a table of lines in files ordered by how frequently they are active.
1763 ``json``
1763 ``json``
1764 Render profiling data as JSON.
1764 Render profiling data as JSON.
1765
1765
1766 ``frequency``
1766 ``frequency``
1767 Sampling frequency. Specific to the ``stat`` sampling profiler.
1767 Sampling frequency. Specific to the ``stat`` sampling profiler.
1768 (default: 1000)
1768 (default: 1000)
1769
1769
1770 ``output``
1770 ``output``
1771 File path where profiling data or report should be saved. If the
1771 File path where profiling data or report should be saved. If the
1772 file exists, it is replaced. (default: None, data is printed on
1772 file exists, it is replaced. (default: None, data is printed on
1773 stderr)
1773 stderr)
1774
1774
1775 ``sort``
1775 ``sort``
1776 Sort field. Specific to the ``ls`` instrumenting profiler.
1776 Sort field. Specific to the ``ls`` instrumenting profiler.
1777 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1777 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1778 ``inlinetime``.
1778 ``inlinetime``.
1779 (default: inlinetime)
1779 (default: inlinetime)
1780
1780
1781 ``time-track``
1781 ``time-track``
1782 Control if the stat profiler track ``cpu`` or ``real`` time.
1782 Control if the stat profiler track ``cpu`` or ``real`` time.
1783 (default: ``cpu`` on Windows, otherwise ``real``)
1783 (default: ``cpu`` on Windows, otherwise ``real``)
1784
1784
1785 ``limit``
1785 ``limit``
1786 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1786 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1787 (default: 30)
1787 (default: 30)
1788
1788
1789 ``nested``
1789 ``nested``
1790 Show at most this number of lines of drill-down info after each main entry.
1790 Show at most this number of lines of drill-down info after each main entry.
1791 This can help explain the difference between Total and Inline.
1791 This can help explain the difference between Total and Inline.
1792 Specific to the ``ls`` instrumenting profiler.
1792 Specific to the ``ls`` instrumenting profiler.
1793 (default: 0)
1793 (default: 0)
1794
1794
1795 ``showmin``
1795 ``showmin``
1796 Minimum fraction of samples an entry must have for it to be displayed.
1796 Minimum fraction of samples an entry must have for it to be displayed.
1797 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1797 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1798 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1798 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1799
1799
1800 Only used by the ``stat`` profiler.
1800 Only used by the ``stat`` profiler.
1801
1801
1802 For the ``hotpath`` format, default is ``0.05``.
1802 For the ``hotpath`` format, default is ``0.05``.
1803 For the ``chrome`` format, default is ``0.005``.
1803 For the ``chrome`` format, default is ``0.005``.
1804
1804
1805 The option is unused on other formats.
1805 The option is unused on other formats.
1806
1806
1807 ``showmax``
1807 ``showmax``
1808 Maximum fraction of samples an entry can have before it is ignored in
1808 Maximum fraction of samples an entry can have before it is ignored in
1809 display. Values format is the same as ``showmin``.
1809 display. Values format is the same as ``showmin``.
1810
1810
1811 Only used by the ``stat`` profiler.
1811 Only used by the ``stat`` profiler.
1812
1812
1813 For the ``chrome`` format, default is ``0.999``.
1813 For the ``chrome`` format, default is ``0.999``.
1814
1814
1815 The option is unused on other formats.
1815 The option is unused on other formats.
1816
1816
1817 ``showtime``
1817 ``showtime``
1818 Show time taken as absolute durations, in addition to percentages.
1818 Show time taken as absolute durations, in addition to percentages.
1819 Only used by the ``hotpath`` format.
1819 Only used by the ``hotpath`` format.
1820 (default: true)
1820 (default: true)
1821
1821
1822 ``progress``
1822 ``progress``
1823 ------------
1823 ------------
1824
1824
1825 Mercurial commands can draw progress bars that are as informative as
1825 Mercurial commands can draw progress bars that are as informative as
1826 possible. Some progress bars only offer indeterminate information, while others
1826 possible. Some progress bars only offer indeterminate information, while others
1827 have a definite end point.
1827 have a definite end point.
1828
1828
1829 ``debug``
1829 ``debug``
1830 Whether to print debug info when updating the progress bar. (default: False)
1830 Whether to print debug info when updating the progress bar. (default: False)
1831
1831
1832 ``delay``
1832 ``delay``
1833 Number of seconds (float) before showing the progress bar. (default: 3)
1833 Number of seconds (float) before showing the progress bar. (default: 3)
1834
1834
1835 ``changedelay``
1835 ``changedelay``
1836 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1836 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1837 that value will be used instead. (default: 1)
1837 that value will be used instead. (default: 1)
1838
1838
1839 ``estimateinterval``
1839 ``estimateinterval``
1840 Maximum sampling interval in seconds for speed and estimated time
1840 Maximum sampling interval in seconds for speed and estimated time
1841 calculation. (default: 60)
1841 calculation. (default: 60)
1842
1842
1843 ``refresh``
1843 ``refresh``
1844 Time in seconds between refreshes of the progress bar. (default: 0.1)
1844 Time in seconds between refreshes of the progress bar. (default: 0.1)
1845
1845
1846 ``format``
1846 ``format``
1847 Format of the progress bar.
1847 Format of the progress bar.
1848
1848
1849 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1849 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1850 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1850 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1851 last 20 characters of the item, but this can be changed by adding either
1851 last 20 characters of the item, but this can be changed by adding either
1852 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1852 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1853 first num characters.
1853 first num characters.
1854
1854
1855 (default: topic bar number estimate)
1855 (default: topic bar number estimate)
1856
1856
1857 ``width``
1857 ``width``
1858 If set, the maximum width of the progress information (that is, min(width,
1858 If set, the maximum width of the progress information (that is, min(width,
1859 term width) will be used).
1859 term width) will be used).
1860
1860
1861 ``clear-complete``
1861 ``clear-complete``
1862 Clear the progress bar after it's done. (default: True)
1862 Clear the progress bar after it's done. (default: True)
1863
1863
1864 ``disable``
1864 ``disable``
1865 If true, don't show a progress bar.
1865 If true, don't show a progress bar.
1866
1866
1867 ``assume-tty``
1867 ``assume-tty``
1868 If true, ALWAYS show a progress bar, unless disable is given.
1868 If true, ALWAYS show a progress bar, unless disable is given.
1869
1869
1870 ``rebase``
1870 ``rebase``
1871 ----------
1871 ----------
1872
1872
1873 ``evolution.allowdivergence``
1873 ``evolution.allowdivergence``
1874 Default to False, when True allow creating divergence when performing
1874 Default to False, when True allow creating divergence when performing
1875 rebase of obsolete changesets.
1875 rebase of obsolete changesets.
1876
1876
1877 ``revsetalias``
1877 ``revsetalias``
1878 ---------------
1878 ---------------
1879
1879
1880 Alias definitions for revsets. See :hg:`help revsets` for details.
1880 Alias definitions for revsets. See :hg:`help revsets` for details.
1881
1881
1882 ``rewrite``
1882 ``rewrite``
1883 -----------
1883 -----------
1884
1884
1885 ``backup-bundle``
1885 ``backup-bundle``
1886 Whether to save stripped changesets to a bundle file. (default: True)
1886 Whether to save stripped changesets to a bundle file. (default: True)
1887
1887
1888 ``update-timestamp``
1888 ``update-timestamp``
1889 If true, updates the date and time of the changeset to current. It is only
1889 If true, updates the date and time of the changeset to current. It is only
1890 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1890 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1891 current version.
1891 current version.
1892
1892
1893 ``empty-successor``
1893 ``empty-successor``
1894
1894
1895 Control what happens with empty successors that are the result of rewrite
1895 Control what happens with empty successors that are the result of rewrite
1896 operations. If set to ``skip``, the successor is not created. If set to
1896 operations. If set to ``skip``, the successor is not created. If set to
1897 ``keep``, the empty successor is created and kept.
1897 ``keep``, the empty successor is created and kept.
1898
1898
1899 Currently, no command considers this configuration. (EXPERIMENTAL)
1899 Currently, only the rebase command considers this configuration.
1900 (EXPERIMENTAL)
1900
1901
1901 ``storage``
1902 ``storage``
1902 -----------
1903 -----------
1903
1904
1904 Control the strategy Mercurial uses internally to store history. Options in this
1905 Control the strategy Mercurial uses internally to store history. Options in this
1905 category impact performance and repository size.
1906 category impact performance and repository size.
1906
1907
1907 ``revlog.optimize-delta-parent-choice``
1908 ``revlog.optimize-delta-parent-choice``
1908 When storing a merge revision, both parents will be equally considered as
1909 When storing a merge revision, both parents will be equally considered as
1909 a possible delta base. This results in better delta selection and improved
1910 a possible delta base. This results in better delta selection and improved
1910 revlog compression. This option is enabled by default.
1911 revlog compression. This option is enabled by default.
1911
1912
1912 Turning this option off can result in large increase of repository size for
1913 Turning this option off can result in large increase of repository size for
1913 repository with many merges.
1914 repository with many merges.
1914
1915
1915 ``revlog.reuse-external-delta-parent``
1916 ``revlog.reuse-external-delta-parent``
1916 Control the order in which delta parents are considered when adding new
1917 Control the order in which delta parents are considered when adding new
1917 revisions from an external source.
1918 revisions from an external source.
1918 (typically: apply bundle from `hg pull` or `hg push`).
1919 (typically: apply bundle from `hg pull` or `hg push`).
1919
1920
1920 New revisions are usually provided as a delta against other revisions. By
1921 New revisions are usually provided as a delta against other revisions. By
1921 default, Mercurial will try to reuse this delta first, therefore using the
1922 default, Mercurial will try to reuse this delta first, therefore using the
1922 same "delta parent" as the source. Directly using delta's from the source
1923 same "delta parent" as the source. Directly using delta's from the source
1923 reduces CPU usage and usually speeds up operation. However, in some case,
1924 reduces CPU usage and usually speeds up operation. However, in some case,
1924 the source might have sub-optimal delta bases and forcing their reevaluation
1925 the source might have sub-optimal delta bases and forcing their reevaluation
1925 is useful. For example, pushes from an old client could have sub-optimal
1926 is useful. For example, pushes from an old client could have sub-optimal
1926 delta's parent that the server want to optimize. (lack of general delta, bad
1927 delta's parent that the server want to optimize. (lack of general delta, bad
1927 parents, choice, lack of sparse-revlog, etc).
1928 parents, choice, lack of sparse-revlog, etc).
1928
1929
1929 This option is enabled by default. Turning it off will ensure bad delta
1930 This option is enabled by default. Turning it off will ensure bad delta
1930 parent choices from older client do not propagate to this repository, at
1931 parent choices from older client do not propagate to this repository, at
1931 the cost of a small increase in CPU consumption.
1932 the cost of a small increase in CPU consumption.
1932
1933
1933 Note: this option only control the order in which delta parents are
1934 Note: this option only control the order in which delta parents are
1934 considered. Even when disabled, the existing delta from the source will be
1935 considered. Even when disabled, the existing delta from the source will be
1935 reused if the same delta parent is selected.
1936 reused if the same delta parent is selected.
1936
1937
1937 ``revlog.reuse-external-delta``
1938 ``revlog.reuse-external-delta``
1938 Control the reuse of delta from external source.
1939 Control the reuse of delta from external source.
1939 (typically: apply bundle from `hg pull` or `hg push`).
1940 (typically: apply bundle from `hg pull` or `hg push`).
1940
1941
1941 New revisions are usually provided as a delta against another revision. By
1942 New revisions are usually provided as a delta against another revision. By
1942 default, Mercurial will not recompute the same delta again, trusting
1943 default, Mercurial will not recompute the same delta again, trusting
1943 externally provided deltas. There have been rare cases of small adjustment
1944 externally provided deltas. There have been rare cases of small adjustment
1944 to the diffing algorithm in the past. So in some rare case, recomputing
1945 to the diffing algorithm in the past. So in some rare case, recomputing
1945 delta provided by ancient clients can provides better results. Disabling
1946 delta provided by ancient clients can provides better results. Disabling
1946 this option means going through a full delta recomputation for all incoming
1947 this option means going through a full delta recomputation for all incoming
1947 revisions. It means a large increase in CPU usage and will slow operations
1948 revisions. It means a large increase in CPU usage and will slow operations
1948 down.
1949 down.
1949
1950
1950 This option is enabled by default. When disabled, it also disables the
1951 This option is enabled by default. When disabled, it also disables the
1951 related ``storage.revlog.reuse-external-delta-parent`` option.
1952 related ``storage.revlog.reuse-external-delta-parent`` option.
1952
1953
1953 ``revlog.zlib.level``
1954 ``revlog.zlib.level``
1954 Zlib compression level used when storing data into the repository. Accepted
1955 Zlib compression level used when storing data into the repository. Accepted
1955 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1956 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1956 default value is 6.
1957 default value is 6.
1957
1958
1958
1959
1959 ``revlog.zstd.level``
1960 ``revlog.zstd.level``
1960 zstd compression level used when storing data into the repository. Accepted
1961 zstd compression level used when storing data into the repository. Accepted
1961 Value range from 1 (lowest compression) to 22 (highest compression).
1962 Value range from 1 (lowest compression) to 22 (highest compression).
1962 (default 3)
1963 (default 3)
1963
1964
1964 ``server``
1965 ``server``
1965 ----------
1966 ----------
1966
1967
1967 Controls generic server settings.
1968 Controls generic server settings.
1968
1969
1969 ``bookmarks-pushkey-compat``
1970 ``bookmarks-pushkey-compat``
1970 Trigger pushkey hook when being pushed bookmark updates. This config exist
1971 Trigger pushkey hook when being pushed bookmark updates. This config exist
1971 for compatibility purpose (default to True)
1972 for compatibility purpose (default to True)
1972
1973
1973 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1974 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1974 movement we recommend you migrate them to ``txnclose-bookmark`` and
1975 movement we recommend you migrate them to ``txnclose-bookmark`` and
1975 ``pretxnclose-bookmark``.
1976 ``pretxnclose-bookmark``.
1976
1977
1977 ``compressionengines``
1978 ``compressionengines``
1978 List of compression engines and their relative priority to advertise
1979 List of compression engines and their relative priority to advertise
1979 to clients.
1980 to clients.
1980
1981
1981 The order of compression engines determines their priority, the first
1982 The order of compression engines determines their priority, the first
1982 having the highest priority. If a compression engine is not listed
1983 having the highest priority. If a compression engine is not listed
1983 here, it won't be advertised to clients.
1984 here, it won't be advertised to clients.
1984
1985
1985 If not set (the default), built-in defaults are used. Run
1986 If not set (the default), built-in defaults are used. Run
1986 :hg:`debuginstall` to list available compression engines and their
1987 :hg:`debuginstall` to list available compression engines and their
1987 default wire protocol priority.
1988 default wire protocol priority.
1988
1989
1989 Older Mercurial clients only support zlib compression and this setting
1990 Older Mercurial clients only support zlib compression and this setting
1990 has no effect for legacy clients.
1991 has no effect for legacy clients.
1991
1992
1992 ``uncompressed``
1993 ``uncompressed``
1993 Whether to allow clients to clone a repository using the
1994 Whether to allow clients to clone a repository using the
1994 uncompressed streaming protocol. This transfers about 40% more
1995 uncompressed streaming protocol. This transfers about 40% more
1995 data than a regular clone, but uses less memory and CPU on both
1996 data than a regular clone, but uses less memory and CPU on both
1996 server and client. Over a LAN (100 Mbps or better) or a very fast
1997 server and client. Over a LAN (100 Mbps or better) or a very fast
1997 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1998 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1998 regular clone. Over most WAN connections (anything slower than
1999 regular clone. Over most WAN connections (anything slower than
1999 about 6 Mbps), uncompressed streaming is slower, because of the
2000 about 6 Mbps), uncompressed streaming is slower, because of the
2000 extra data transfer overhead. This mode will also temporarily hold
2001 extra data transfer overhead. This mode will also temporarily hold
2001 the write lock while determining what data to transfer.
2002 the write lock while determining what data to transfer.
2002 (default: True)
2003 (default: True)
2003
2004
2004 ``uncompressedallowsecret``
2005 ``uncompressedallowsecret``
2005 Whether to allow stream clones when the repository contains secret
2006 Whether to allow stream clones when the repository contains secret
2006 changesets. (default: False)
2007 changesets. (default: False)
2007
2008
2008 ``preferuncompressed``
2009 ``preferuncompressed``
2009 When set, clients will try to use the uncompressed streaming
2010 When set, clients will try to use the uncompressed streaming
2010 protocol. (default: False)
2011 protocol. (default: False)
2011
2012
2012 ``disablefullbundle``
2013 ``disablefullbundle``
2013 When set, servers will refuse attempts to do pull-based clones.
2014 When set, servers will refuse attempts to do pull-based clones.
2014 If this option is set, ``preferuncompressed`` and/or clone bundles
2015 If this option is set, ``preferuncompressed`` and/or clone bundles
2015 are highly recommended. Partial clones will still be allowed.
2016 are highly recommended. Partial clones will still be allowed.
2016 (default: False)
2017 (default: False)
2017
2018
2018 ``streamunbundle``
2019 ``streamunbundle``
2019 When set, servers will apply data sent from the client directly,
2020 When set, servers will apply data sent from the client directly,
2020 otherwise it will be written to a temporary file first. This option
2021 otherwise it will be written to a temporary file first. This option
2021 effectively prevents concurrent pushes.
2022 effectively prevents concurrent pushes.
2022
2023
2023 ``pullbundle``
2024 ``pullbundle``
2024 When set, the server will check pullbundle.manifest for bundles
2025 When set, the server will check pullbundle.manifest for bundles
2025 covering the requested heads and common nodes. The first matching
2026 covering the requested heads and common nodes. The first matching
2026 entry will be streamed to the client.
2027 entry will be streamed to the client.
2027
2028
2028 For HTTP transport, the stream will still use zlib compression
2029 For HTTP transport, the stream will still use zlib compression
2029 for older clients.
2030 for older clients.
2030
2031
2031 ``concurrent-push-mode``
2032 ``concurrent-push-mode``
2032 Level of allowed race condition between two pushing clients.
2033 Level of allowed race condition between two pushing clients.
2033
2034
2034 - 'strict': push is abort if another client touched the repository
2035 - 'strict': push is abort if another client touched the repository
2035 while the push was preparing.
2036 while the push was preparing.
2036 - 'check-related': push is only aborted if it affects head that got also
2037 - 'check-related': push is only aborted if it affects head that got also
2037 affected while the push was preparing. (default since 5.4)
2038 affected while the push was preparing. (default since 5.4)
2038
2039
2039 'check-related' only takes effect for compatible clients (version
2040 'check-related' only takes effect for compatible clients (version
2040 4.3 and later). Older clients will use 'strict'.
2041 4.3 and later). Older clients will use 'strict'.
2041
2042
2042 ``validate``
2043 ``validate``
2043 Whether to validate the completeness of pushed changesets by
2044 Whether to validate the completeness of pushed changesets by
2044 checking that all new file revisions specified in manifests are
2045 checking that all new file revisions specified in manifests are
2045 present. (default: False)
2046 present. (default: False)
2046
2047
2047 ``maxhttpheaderlen``
2048 ``maxhttpheaderlen``
2048 Instruct HTTP clients not to send request headers longer than this
2049 Instruct HTTP clients not to send request headers longer than this
2049 many bytes. (default: 1024)
2050 many bytes. (default: 1024)
2050
2051
2051 ``bundle1``
2052 ``bundle1``
2052 Whether to allow clients to push and pull using the legacy bundle1
2053 Whether to allow clients to push and pull using the legacy bundle1
2053 exchange format. (default: True)
2054 exchange format. (default: True)
2054
2055
2055 ``bundle1gd``
2056 ``bundle1gd``
2056 Like ``bundle1`` but only used if the repository is using the
2057 Like ``bundle1`` but only used if the repository is using the
2057 *generaldelta* storage format. (default: True)
2058 *generaldelta* storage format. (default: True)
2058
2059
2059 ``bundle1.push``
2060 ``bundle1.push``
2060 Whether to allow clients to push using the legacy bundle1 exchange
2061 Whether to allow clients to push using the legacy bundle1 exchange
2061 format. (default: True)
2062 format. (default: True)
2062
2063
2063 ``bundle1gd.push``
2064 ``bundle1gd.push``
2064 Like ``bundle1.push`` but only used if the repository is using the
2065 Like ``bundle1.push`` but only used if the repository is using the
2065 *generaldelta* storage format. (default: True)
2066 *generaldelta* storage format. (default: True)
2066
2067
2067 ``bundle1.pull``
2068 ``bundle1.pull``
2068 Whether to allow clients to pull using the legacy bundle1 exchange
2069 Whether to allow clients to pull using the legacy bundle1 exchange
2069 format. (default: True)
2070 format. (default: True)
2070
2071
2071 ``bundle1gd.pull``
2072 ``bundle1gd.pull``
2072 Like ``bundle1.pull`` but only used if the repository is using the
2073 Like ``bundle1.pull`` but only used if the repository is using the
2073 *generaldelta* storage format. (default: True)
2074 *generaldelta* storage format. (default: True)
2074
2075
2075 Large repositories using the *generaldelta* storage format should
2076 Large repositories using the *generaldelta* storage format should
2076 consider setting this option because converting *generaldelta*
2077 consider setting this option because converting *generaldelta*
2077 repositories to the exchange format required by the bundle1 data
2078 repositories to the exchange format required by the bundle1 data
2078 format can consume a lot of CPU.
2079 format can consume a lot of CPU.
2079
2080
2080 ``bundle2.stream``
2081 ``bundle2.stream``
2081 Whether to allow clients to pull using the bundle2 streaming protocol.
2082 Whether to allow clients to pull using the bundle2 streaming protocol.
2082 (default: True)
2083 (default: True)
2083
2084
2084 ``zliblevel``
2085 ``zliblevel``
2085 Integer between ``-1`` and ``9`` that controls the zlib compression level
2086 Integer between ``-1`` and ``9`` that controls the zlib compression level
2086 for wire protocol commands that send zlib compressed output (notably the
2087 for wire protocol commands that send zlib compressed output (notably the
2087 commands that send repository history data).
2088 commands that send repository history data).
2088
2089
2089 The default (``-1``) uses the default zlib compression level, which is
2090 The default (``-1``) uses the default zlib compression level, which is
2090 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2091 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2091 maximum compression.
2092 maximum compression.
2092
2093
2093 Setting this option allows server operators to make trade-offs between
2094 Setting this option allows server operators to make trade-offs between
2094 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2095 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2095 but sends more bytes to clients.
2096 but sends more bytes to clients.
2096
2097
2097 This option only impacts the HTTP server.
2098 This option only impacts the HTTP server.
2098
2099
2099 ``zstdlevel``
2100 ``zstdlevel``
2100 Integer between ``1`` and ``22`` that controls the zstd compression level
2101 Integer between ``1`` and ``22`` that controls the zstd compression level
2101 for wire protocol commands. ``1`` is the minimal amount of compression and
2102 for wire protocol commands. ``1`` is the minimal amount of compression and
2102 ``22`` is the highest amount of compression.
2103 ``22`` is the highest amount of compression.
2103
2104
2104 The default (``3``) should be significantly faster than zlib while likely
2105 The default (``3``) should be significantly faster than zlib while likely
2105 delivering better compression ratios.
2106 delivering better compression ratios.
2106
2107
2107 This option only impacts the HTTP server.
2108 This option only impacts the HTTP server.
2108
2109
2109 See also ``server.zliblevel``.
2110 See also ``server.zliblevel``.
2110
2111
2111 ``view``
2112 ``view``
2112 Repository filter used when exchanging revisions with the peer.
2113 Repository filter used when exchanging revisions with the peer.
2113
2114
2114 The default view (``served``) excludes secret and hidden changesets.
2115 The default view (``served``) excludes secret and hidden changesets.
2115 Another useful value is ``immutable`` (no draft, secret or hidden
2116 Another useful value is ``immutable`` (no draft, secret or hidden
2116 changesets). (EXPERIMENTAL)
2117 changesets). (EXPERIMENTAL)
2117
2118
2118 ``smtp``
2119 ``smtp``
2119 --------
2120 --------
2120
2121
2121 Configuration for extensions that need to send email messages.
2122 Configuration for extensions that need to send email messages.
2122
2123
2123 ``host``
2124 ``host``
2124 Host name of mail server, e.g. "mail.example.com".
2125 Host name of mail server, e.g. "mail.example.com".
2125
2126
2126 ``port``
2127 ``port``
2127 Optional. Port to connect to on mail server. (default: 465 if
2128 Optional. Port to connect to on mail server. (default: 465 if
2128 ``tls`` is smtps; 25 otherwise)
2129 ``tls`` is smtps; 25 otherwise)
2129
2130
2130 ``tls``
2131 ``tls``
2131 Optional. Method to enable TLS when connecting to mail server: starttls,
2132 Optional. Method to enable TLS when connecting to mail server: starttls,
2132 smtps or none. (default: none)
2133 smtps or none. (default: none)
2133
2134
2134 ``username``
2135 ``username``
2135 Optional. User name for authenticating with the SMTP server.
2136 Optional. User name for authenticating with the SMTP server.
2136 (default: None)
2137 (default: None)
2137
2138
2138 ``password``
2139 ``password``
2139 Optional. Password for authenticating with the SMTP server. If not
2140 Optional. Password for authenticating with the SMTP server. If not
2140 specified, interactive sessions will prompt the user for a
2141 specified, interactive sessions will prompt the user for a
2141 password; non-interactive sessions will fail. (default: None)
2142 password; non-interactive sessions will fail. (default: None)
2142
2143
2143 ``local_hostname``
2144 ``local_hostname``
2144 Optional. The hostname that the sender can use to identify
2145 Optional. The hostname that the sender can use to identify
2145 itself to the MTA.
2146 itself to the MTA.
2146
2147
2147
2148
2148 ``subpaths``
2149 ``subpaths``
2149 ------------
2150 ------------
2150
2151
2151 Subrepository source URLs can go stale if a remote server changes name
2152 Subrepository source URLs can go stale if a remote server changes name
2152 or becomes temporarily unavailable. This section lets you define
2153 or becomes temporarily unavailable. This section lets you define
2153 rewrite rules of the form::
2154 rewrite rules of the form::
2154
2155
2155 <pattern> = <replacement>
2156 <pattern> = <replacement>
2156
2157
2157 where ``pattern`` is a regular expression matching a subrepository
2158 where ``pattern`` is a regular expression matching a subrepository
2158 source URL and ``replacement`` is the replacement string used to
2159 source URL and ``replacement`` is the replacement string used to
2159 rewrite it. Groups can be matched in ``pattern`` and referenced in
2160 rewrite it. Groups can be matched in ``pattern`` and referenced in
2160 ``replacements``. For instance::
2161 ``replacements``. For instance::
2161
2162
2162 http://server/(.*)-hg/ = http://hg.server/\1/
2163 http://server/(.*)-hg/ = http://hg.server/\1/
2163
2164
2164 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2165 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2165
2166
2166 Relative subrepository paths are first made absolute, and the
2167 Relative subrepository paths are first made absolute, and the
2167 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2168 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2168 doesn't match the full path, an attempt is made to apply it on the
2169 doesn't match the full path, an attempt is made to apply it on the
2169 relative path alone. The rules are applied in definition order.
2170 relative path alone. The rules are applied in definition order.
2170
2171
2171 ``subrepos``
2172 ``subrepos``
2172 ------------
2173 ------------
2173
2174
2174 This section contains options that control the behavior of the
2175 This section contains options that control the behavior of the
2175 subrepositories feature. See also :hg:`help subrepos`.
2176 subrepositories feature. See also :hg:`help subrepos`.
2176
2177
2177 Security note: auditing in Mercurial is known to be insufficient to
2178 Security note: auditing in Mercurial is known to be insufficient to
2178 prevent clone-time code execution with carefully constructed Git
2179 prevent clone-time code execution with carefully constructed Git
2179 subrepos. It is unknown if a similar detect is present in Subversion
2180 subrepos. It is unknown if a similar detect is present in Subversion
2180 subrepos. Both Git and Subversion subrepos are disabled by default
2181 subrepos. Both Git and Subversion subrepos are disabled by default
2181 out of security concerns. These subrepo types can be enabled using
2182 out of security concerns. These subrepo types can be enabled using
2182 the respective options below.
2183 the respective options below.
2183
2184
2184 ``allowed``
2185 ``allowed``
2185 Whether subrepositories are allowed in the working directory.
2186 Whether subrepositories are allowed in the working directory.
2186
2187
2187 When false, commands involving subrepositories (like :hg:`update`)
2188 When false, commands involving subrepositories (like :hg:`update`)
2188 will fail for all subrepository types.
2189 will fail for all subrepository types.
2189 (default: true)
2190 (default: true)
2190
2191
2191 ``hg:allowed``
2192 ``hg:allowed``
2192 Whether Mercurial subrepositories are allowed in the working
2193 Whether Mercurial subrepositories are allowed in the working
2193 directory. This option only has an effect if ``subrepos.allowed``
2194 directory. This option only has an effect if ``subrepos.allowed``
2194 is true.
2195 is true.
2195 (default: true)
2196 (default: true)
2196
2197
2197 ``git:allowed``
2198 ``git:allowed``
2198 Whether Git subrepositories are allowed in the working directory.
2199 Whether Git subrepositories are allowed in the working directory.
2199 This option only has an effect if ``subrepos.allowed`` is true.
2200 This option only has an effect if ``subrepos.allowed`` is true.
2200
2201
2201 See the security note above before enabling Git subrepos.
2202 See the security note above before enabling Git subrepos.
2202 (default: false)
2203 (default: false)
2203
2204
2204 ``svn:allowed``
2205 ``svn:allowed``
2205 Whether Subversion subrepositories are allowed in the working
2206 Whether Subversion subrepositories are allowed in the working
2206 directory. This option only has an effect if ``subrepos.allowed``
2207 directory. This option only has an effect if ``subrepos.allowed``
2207 is true.
2208 is true.
2208
2209
2209 See the security note above before enabling Subversion subrepos.
2210 See the security note above before enabling Subversion subrepos.
2210 (default: false)
2211 (default: false)
2211
2212
2212 ``templatealias``
2213 ``templatealias``
2213 -----------------
2214 -----------------
2214
2215
2215 Alias definitions for templates. See :hg:`help templates` for details.
2216 Alias definitions for templates. See :hg:`help templates` for details.
2216
2217
2217 ``templates``
2218 ``templates``
2218 -------------
2219 -------------
2219
2220
2220 Use the ``[templates]`` section to define template strings.
2221 Use the ``[templates]`` section to define template strings.
2221 See :hg:`help templates` for details.
2222 See :hg:`help templates` for details.
2222
2223
2223 ``trusted``
2224 ``trusted``
2224 -----------
2225 -----------
2225
2226
2226 Mercurial will not use the settings in the
2227 Mercurial will not use the settings in the
2227 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2228 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2228 user or to a trusted group, as various hgrc features allow arbitrary
2229 user or to a trusted group, as various hgrc features allow arbitrary
2229 commands to be run. This issue is often encountered when configuring
2230 commands to be run. This issue is often encountered when configuring
2230 hooks or extensions for shared repositories or servers. However,
2231 hooks or extensions for shared repositories or servers. However,
2231 the web interface will use some safe settings from the ``[web]``
2232 the web interface will use some safe settings from the ``[web]``
2232 section.
2233 section.
2233
2234
2234 This section specifies what users and groups are trusted. The
2235 This section specifies what users and groups are trusted. The
2235 current user is always trusted. To trust everybody, list a user or a
2236 current user is always trusted. To trust everybody, list a user or a
2236 group with name ``*``. These settings must be placed in an
2237 group with name ``*``. These settings must be placed in an
2237 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2238 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2238 user or service running Mercurial.
2239 user or service running Mercurial.
2239
2240
2240 ``users``
2241 ``users``
2241 Comma-separated list of trusted users.
2242 Comma-separated list of trusted users.
2242
2243
2243 ``groups``
2244 ``groups``
2244 Comma-separated list of trusted groups.
2245 Comma-separated list of trusted groups.
2245
2246
2246
2247
2247 ``ui``
2248 ``ui``
2248 ------
2249 ------
2249
2250
2250 User interface controls.
2251 User interface controls.
2251
2252
2252 ``archivemeta``
2253 ``archivemeta``
2253 Whether to include the .hg_archival.txt file containing meta data
2254 Whether to include the .hg_archival.txt file containing meta data
2254 (hashes for the repository base and for tip) in archives created
2255 (hashes for the repository base and for tip) in archives created
2255 by the :hg:`archive` command or downloaded via hgweb.
2256 by the :hg:`archive` command or downloaded via hgweb.
2256 (default: True)
2257 (default: True)
2257
2258
2258 ``askusername``
2259 ``askusername``
2259 Whether to prompt for a username when committing. If True, and
2260 Whether to prompt for a username when committing. If True, and
2260 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2261 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2261 be prompted to enter a username. If no username is entered, the
2262 be prompted to enter a username. If no username is entered, the
2262 default ``USER@HOST`` is used instead.
2263 default ``USER@HOST`` is used instead.
2263 (default: False)
2264 (default: False)
2264
2265
2265 ``clonebundles``
2266 ``clonebundles``
2266 Whether the "clone bundles" feature is enabled.
2267 Whether the "clone bundles" feature is enabled.
2267
2268
2268 When enabled, :hg:`clone` may download and apply a server-advertised
2269 When enabled, :hg:`clone` may download and apply a server-advertised
2269 bundle file from a URL instead of using the normal exchange mechanism.
2270 bundle file from a URL instead of using the normal exchange mechanism.
2270
2271
2271 This can likely result in faster and more reliable clones.
2272 This can likely result in faster and more reliable clones.
2272
2273
2273 (default: True)
2274 (default: True)
2274
2275
2275 ``clonebundlefallback``
2276 ``clonebundlefallback``
2276 Whether failure to apply an advertised "clone bundle" from a server
2277 Whether failure to apply an advertised "clone bundle" from a server
2277 should result in fallback to a regular clone.
2278 should result in fallback to a regular clone.
2278
2279
2279 This is disabled by default because servers advertising "clone
2280 This is disabled by default because servers advertising "clone
2280 bundles" often do so to reduce server load. If advertised bundles
2281 bundles" often do so to reduce server load. If advertised bundles
2281 start mass failing and clients automatically fall back to a regular
2282 start mass failing and clients automatically fall back to a regular
2282 clone, this would add significant and unexpected load to the server
2283 clone, this would add significant and unexpected load to the server
2283 since the server is expecting clone operations to be offloaded to
2284 since the server is expecting clone operations to be offloaded to
2284 pre-generated bundles. Failing fast (the default behavior) ensures
2285 pre-generated bundles. Failing fast (the default behavior) ensures
2285 clients don't overwhelm the server when "clone bundle" application
2286 clients don't overwhelm the server when "clone bundle" application
2286 fails.
2287 fails.
2287
2288
2288 (default: False)
2289 (default: False)
2289
2290
2290 ``clonebundleprefers``
2291 ``clonebundleprefers``
2291 Defines preferences for which "clone bundles" to use.
2292 Defines preferences for which "clone bundles" to use.
2292
2293
2293 Servers advertising "clone bundles" may advertise multiple available
2294 Servers advertising "clone bundles" may advertise multiple available
2294 bundles. Each bundle may have different attributes, such as the bundle
2295 bundles. Each bundle may have different attributes, such as the bundle
2295 type and compression format. This option is used to prefer a particular
2296 type and compression format. This option is used to prefer a particular
2296 bundle over another.
2297 bundle over another.
2297
2298
2298 The following keys are defined by Mercurial:
2299 The following keys are defined by Mercurial:
2299
2300
2300 BUNDLESPEC
2301 BUNDLESPEC
2301 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2302 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2302 e.g. ``gzip-v2`` or ``bzip2-v1``.
2303 e.g. ``gzip-v2`` or ``bzip2-v1``.
2303
2304
2304 COMPRESSION
2305 COMPRESSION
2305 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2306 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2306
2307
2307 Server operators may define custom keys.
2308 Server operators may define custom keys.
2308
2309
2309 Example values: ``COMPRESSION=bzip2``,
2310 Example values: ``COMPRESSION=bzip2``,
2310 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2311 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2311
2312
2312 By default, the first bundle advertised by the server is used.
2313 By default, the first bundle advertised by the server is used.
2313
2314
2314 ``color``
2315 ``color``
2315 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2316 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2316 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2317 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2317 seems possible. See :hg:`help color` for details.
2318 seems possible. See :hg:`help color` for details.
2318
2319
2319 ``commitsubrepos``
2320 ``commitsubrepos``
2320 Whether to commit modified subrepositories when committing the
2321 Whether to commit modified subrepositories when committing the
2321 parent repository. If False and one subrepository has uncommitted
2322 parent repository. If False and one subrepository has uncommitted
2322 changes, abort the commit.
2323 changes, abort the commit.
2323 (default: False)
2324 (default: False)
2324
2325
2325 ``debug``
2326 ``debug``
2326 Print debugging information. (default: False)
2327 Print debugging information. (default: False)
2327
2328
2328 ``editor``
2329 ``editor``
2329 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2330 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2330
2331
2331 ``fallbackencoding``
2332 ``fallbackencoding``
2332 Encoding to try if it's not possible to decode the changelog using
2333 Encoding to try if it's not possible to decode the changelog using
2333 UTF-8. (default: ISO-8859-1)
2334 UTF-8. (default: ISO-8859-1)
2334
2335
2335 ``graphnodetemplate``
2336 ``graphnodetemplate``
2336 The template used to print changeset nodes in an ASCII revision graph.
2337 The template used to print changeset nodes in an ASCII revision graph.
2337 (default: ``{graphnode}``)
2338 (default: ``{graphnode}``)
2338
2339
2339 ``ignore``
2340 ``ignore``
2340 A file to read per-user ignore patterns from. This file should be
2341 A file to read per-user ignore patterns from. This file should be
2341 in the same format as a repository-wide .hgignore file. Filenames
2342 in the same format as a repository-wide .hgignore file. Filenames
2342 are relative to the repository root. This option supports hook syntax,
2343 are relative to the repository root. This option supports hook syntax,
2343 so if you want to specify multiple ignore files, you can do so by
2344 so if you want to specify multiple ignore files, you can do so by
2344 setting something like ``ignore.other = ~/.hgignore2``. For details
2345 setting something like ``ignore.other = ~/.hgignore2``. For details
2345 of the ignore file format, see the ``hgignore(5)`` man page.
2346 of the ignore file format, see the ``hgignore(5)`` man page.
2346
2347
2347 ``interactive``
2348 ``interactive``
2348 Allow to prompt the user. (default: True)
2349 Allow to prompt the user. (default: True)
2349
2350
2350 ``interface``
2351 ``interface``
2351 Select the default interface for interactive features (default: text).
2352 Select the default interface for interactive features (default: text).
2352 Possible values are 'text' and 'curses'.
2353 Possible values are 'text' and 'curses'.
2353
2354
2354 ``interface.chunkselector``
2355 ``interface.chunkselector``
2355 Select the interface for change recording (e.g. :hg:`commit -i`).
2356 Select the interface for change recording (e.g. :hg:`commit -i`).
2356 Possible values are 'text' and 'curses'.
2357 Possible values are 'text' and 'curses'.
2357 This config overrides the interface specified by ui.interface.
2358 This config overrides the interface specified by ui.interface.
2358
2359
2359 ``large-file-limit``
2360 ``large-file-limit``
2360 Largest file size that gives no memory use warning.
2361 Largest file size that gives no memory use warning.
2361 Possible values are integers or 0 to disable the check.
2362 Possible values are integers or 0 to disable the check.
2362 (default: 10000000)
2363 (default: 10000000)
2363
2364
2364 ``logtemplate``
2365 ``logtemplate``
2365 Template string for commands that print changesets.
2366 Template string for commands that print changesets.
2366
2367
2367 ``merge``
2368 ``merge``
2368 The conflict resolution program to use during a manual merge.
2369 The conflict resolution program to use during a manual merge.
2369 For more information on merge tools see :hg:`help merge-tools`.
2370 For more information on merge tools see :hg:`help merge-tools`.
2370 For configuring merge tools see the ``[merge-tools]`` section.
2371 For configuring merge tools see the ``[merge-tools]`` section.
2371
2372
2372 ``mergemarkers``
2373 ``mergemarkers``
2373 Sets the merge conflict marker label styling. The ``detailed``
2374 Sets the merge conflict marker label styling. The ``detailed``
2374 style uses the ``mergemarkertemplate`` setting to style the labels.
2375 style uses the ``mergemarkertemplate`` setting to style the labels.
2375 The ``basic`` style just uses 'local' and 'other' as the marker label.
2376 The ``basic`` style just uses 'local' and 'other' as the marker label.
2376 One of ``basic`` or ``detailed``.
2377 One of ``basic`` or ``detailed``.
2377 (default: ``basic``)
2378 (default: ``basic``)
2378
2379
2379 ``mergemarkertemplate``
2380 ``mergemarkertemplate``
2380 The template used to print the commit description next to each conflict
2381 The template used to print the commit description next to each conflict
2381 marker during merge conflicts. See :hg:`help templates` for the template
2382 marker during merge conflicts. See :hg:`help templates` for the template
2382 format.
2383 format.
2383
2384
2384 Defaults to showing the hash, tags, branches, bookmarks, author, and
2385 Defaults to showing the hash, tags, branches, bookmarks, author, and
2385 the first line of the commit description.
2386 the first line of the commit description.
2386
2387
2387 If you use non-ASCII characters in names for tags, branches, bookmarks,
2388 If you use non-ASCII characters in names for tags, branches, bookmarks,
2388 authors, and/or commit descriptions, you must pay attention to encodings of
2389 authors, and/or commit descriptions, you must pay attention to encodings of
2389 managed files. At template expansion, non-ASCII characters use the encoding
2390 managed files. At template expansion, non-ASCII characters use the encoding
2390 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2391 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2391 environment variables that govern your locale. If the encoding of the merge
2392 environment variables that govern your locale. If the encoding of the merge
2392 markers is different from the encoding of the merged files,
2393 markers is different from the encoding of the merged files,
2393 serious problems may occur.
2394 serious problems may occur.
2394
2395
2395 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2396 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2396
2397
2397 ``message-output``
2398 ``message-output``
2398 Where to write status and error messages. (default: ``stdio``)
2399 Where to write status and error messages. (default: ``stdio``)
2399
2400
2400 ``channel``
2401 ``channel``
2401 Use separate channel for structured output. (Command-server only)
2402 Use separate channel for structured output. (Command-server only)
2402 ``stderr``
2403 ``stderr``
2403 Everything to stderr.
2404 Everything to stderr.
2404 ``stdio``
2405 ``stdio``
2405 Status to stdout, and error to stderr.
2406 Status to stdout, and error to stderr.
2406
2407
2407 ``origbackuppath``
2408 ``origbackuppath``
2408 The path to a directory used to store generated .orig files. If the path is
2409 The path to a directory used to store generated .orig files. If the path is
2409 not a directory, one will be created. If set, files stored in this
2410 not a directory, one will be created. If set, files stored in this
2410 directory have the same name as the original file and do not have a .orig
2411 directory have the same name as the original file and do not have a .orig
2411 suffix.
2412 suffix.
2412
2413
2413 ``paginate``
2414 ``paginate``
2414 Control the pagination of command output (default: True). See :hg:`help pager`
2415 Control the pagination of command output (default: True). See :hg:`help pager`
2415 for details.
2416 for details.
2416
2417
2417 ``patch``
2418 ``patch``
2418 An optional external tool that ``hg import`` and some extensions
2419 An optional external tool that ``hg import`` and some extensions
2419 will use for applying patches. By default Mercurial uses an
2420 will use for applying patches. By default Mercurial uses an
2420 internal patch utility. The external tool must work as the common
2421 internal patch utility. The external tool must work as the common
2421 Unix ``patch`` program. In particular, it must accept a ``-p``
2422 Unix ``patch`` program. In particular, it must accept a ``-p``
2422 argument to strip patch headers, a ``-d`` argument to specify the
2423 argument to strip patch headers, a ``-d`` argument to specify the
2423 current directory, a file name to patch, and a patch file to take
2424 current directory, a file name to patch, and a patch file to take
2424 from stdin.
2425 from stdin.
2425
2426
2426 It is possible to specify a patch tool together with extra
2427 It is possible to specify a patch tool together with extra
2427 arguments. For example, setting this option to ``patch --merge``
2428 arguments. For example, setting this option to ``patch --merge``
2428 will use the ``patch`` program with its 2-way merge option.
2429 will use the ``patch`` program with its 2-way merge option.
2429
2430
2430 ``portablefilenames``
2431 ``portablefilenames``
2431 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2432 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2432 (default: ``warn``)
2433 (default: ``warn``)
2433
2434
2434 ``warn``
2435 ``warn``
2435 Print a warning message on POSIX platforms, if a file with a non-portable
2436 Print a warning message on POSIX platforms, if a file with a non-portable
2436 filename is added (e.g. a file with a name that can't be created on
2437 filename is added (e.g. a file with a name that can't be created on
2437 Windows because it contains reserved parts like ``AUX``, reserved
2438 Windows because it contains reserved parts like ``AUX``, reserved
2438 characters like ``:``, or would cause a case collision with an existing
2439 characters like ``:``, or would cause a case collision with an existing
2439 file).
2440 file).
2440
2441
2441 ``ignore``
2442 ``ignore``
2442 Don't print a warning.
2443 Don't print a warning.
2443
2444
2444 ``abort``
2445 ``abort``
2445 The command is aborted.
2446 The command is aborted.
2446
2447
2447 ``true``
2448 ``true``
2448 Alias for ``warn``.
2449 Alias for ``warn``.
2449
2450
2450 ``false``
2451 ``false``
2451 Alias for ``ignore``.
2452 Alias for ``ignore``.
2452
2453
2453 .. container:: windows
2454 .. container:: windows
2454
2455
2455 On Windows, this configuration option is ignored and the command aborted.
2456 On Windows, this configuration option is ignored and the command aborted.
2456
2457
2457 ``pre-merge-tool-output-template``
2458 ``pre-merge-tool-output-template``
2458 A template that is printed before executing an external merge tool. This can
2459 A template that is printed before executing an external merge tool. This can
2459 be used to print out additional context that might be useful to have during
2460 be used to print out additional context that might be useful to have during
2460 the conflict resolution, such as the description of the various commits
2461 the conflict resolution, such as the description of the various commits
2461 involved or bookmarks/tags.
2462 involved or bookmarks/tags.
2462
2463
2463 Additional information is available in the ``local`, ``base``, and ``other``
2464 Additional information is available in the ``local`, ``base``, and ``other``
2464 dicts. For example: ``{local.label}``, ``{base.name}``, or
2465 dicts. For example: ``{local.label}``, ``{base.name}``, or
2465 ``{other.islink}``.
2466 ``{other.islink}``.
2466
2467
2467 ``quiet``
2468 ``quiet``
2468 Reduce the amount of output printed.
2469 Reduce the amount of output printed.
2469 (default: False)
2470 (default: False)
2470
2471
2471 ``relative-paths``
2472 ``relative-paths``
2472 Prefer relative paths in the UI.
2473 Prefer relative paths in the UI.
2473
2474
2474 ``remotecmd``
2475 ``remotecmd``
2475 Remote command to use for clone/push/pull operations.
2476 Remote command to use for clone/push/pull operations.
2476 (default: ``hg``)
2477 (default: ``hg``)
2477
2478
2478 ``report_untrusted``
2479 ``report_untrusted``
2479 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2480 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2480 trusted user or group.
2481 trusted user or group.
2481 (default: True)
2482 (default: True)
2482
2483
2483 ``slash``
2484 ``slash``
2484 (Deprecated. Use ``slashpath`` template filter instead.)
2485 (Deprecated. Use ``slashpath`` template filter instead.)
2485
2486
2486 Display paths using a slash (``/``) as the path separator. This
2487 Display paths using a slash (``/``) as the path separator. This
2487 only makes a difference on systems where the default path
2488 only makes a difference on systems where the default path
2488 separator is not the slash character (e.g. Windows uses the
2489 separator is not the slash character (e.g. Windows uses the
2489 backslash character (``\``)).
2490 backslash character (``\``)).
2490 (default: False)
2491 (default: False)
2491
2492
2492 ``statuscopies``
2493 ``statuscopies``
2493 Display copies in the status command.
2494 Display copies in the status command.
2494
2495
2495 ``ssh``
2496 ``ssh``
2496 Command to use for SSH connections. (default: ``ssh``)
2497 Command to use for SSH connections. (default: ``ssh``)
2497
2498
2498 ``ssherrorhint``
2499 ``ssherrorhint``
2499 A hint shown to the user in the case of SSH error (e.g.
2500 A hint shown to the user in the case of SSH error (e.g.
2500 ``Please see http://company/internalwiki/ssh.html``)
2501 ``Please see http://company/internalwiki/ssh.html``)
2501
2502
2502 ``strict``
2503 ``strict``
2503 Require exact command names, instead of allowing unambiguous
2504 Require exact command names, instead of allowing unambiguous
2504 abbreviations. (default: False)
2505 abbreviations. (default: False)
2505
2506
2506 ``style``
2507 ``style``
2507 Name of style to use for command output.
2508 Name of style to use for command output.
2508
2509
2509 ``supportcontact``
2510 ``supportcontact``
2510 A URL where users should report a Mercurial traceback. Use this if you are a
2511 A URL where users should report a Mercurial traceback. Use this if you are a
2511 large organisation with its own Mercurial deployment process and crash
2512 large organisation with its own Mercurial deployment process and crash
2512 reports should be addressed to your internal support.
2513 reports should be addressed to your internal support.
2513
2514
2514 ``textwidth``
2515 ``textwidth``
2515 Maximum width of help text. A longer line generated by ``hg help`` or
2516 Maximum width of help text. A longer line generated by ``hg help`` or
2516 ``hg subcommand --help`` will be broken after white space to get this
2517 ``hg subcommand --help`` will be broken after white space to get this
2517 width or the terminal width, whichever comes first.
2518 width or the terminal width, whichever comes first.
2518 A non-positive value will disable this and the terminal width will be
2519 A non-positive value will disable this and the terminal width will be
2519 used. (default: 78)
2520 used. (default: 78)
2520
2521
2521 ``timeout``
2522 ``timeout``
2522 The timeout used when a lock is held (in seconds), a negative value
2523 The timeout used when a lock is held (in seconds), a negative value
2523 means no timeout. (default: 600)
2524 means no timeout. (default: 600)
2524
2525
2525 ``timeout.warn``
2526 ``timeout.warn``
2526 Time (in seconds) before a warning is printed about held lock. A negative
2527 Time (in seconds) before a warning is printed about held lock. A negative
2527 value means no warning. (default: 0)
2528 value means no warning. (default: 0)
2528
2529
2529 ``traceback``
2530 ``traceback``
2530 Mercurial always prints a traceback when an unknown exception
2531 Mercurial always prints a traceback when an unknown exception
2531 occurs. Setting this to True will make Mercurial print a traceback
2532 occurs. Setting this to True will make Mercurial print a traceback
2532 on all exceptions, even those recognized by Mercurial (such as
2533 on all exceptions, even those recognized by Mercurial (such as
2533 IOError or MemoryError). (default: False)
2534 IOError or MemoryError). (default: False)
2534
2535
2535 ``tweakdefaults``
2536 ``tweakdefaults``
2536
2537
2537 By default Mercurial's behavior changes very little from release
2538 By default Mercurial's behavior changes very little from release
2538 to release, but over time the recommended config settings
2539 to release, but over time the recommended config settings
2539 shift. Enable this config to opt in to get automatic tweaks to
2540 shift. Enable this config to opt in to get automatic tweaks to
2540 Mercurial's behavior over time. This config setting will have no
2541 Mercurial's behavior over time. This config setting will have no
2541 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2542 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2542 not include ``tweakdefaults``. (default: False)
2543 not include ``tweakdefaults``. (default: False)
2543
2544
2544 It currently means::
2545 It currently means::
2545
2546
2546 .. tweakdefaultsmarker
2547 .. tweakdefaultsmarker
2547
2548
2548 ``username``
2549 ``username``
2549 The committer of a changeset created when running "commit".
2550 The committer of a changeset created when running "commit".
2550 Typically a person's name and email address, e.g. ``Fred Widget
2551 Typically a person's name and email address, e.g. ``Fred Widget
2551 <fred@example.com>``. Environment variables in the
2552 <fred@example.com>``. Environment variables in the
2552 username are expanded.
2553 username are expanded.
2553
2554
2554 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2555 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2555 hgrc is empty, e.g. if the system admin set ``username =`` in the
2556 hgrc is empty, e.g. if the system admin set ``username =`` in the
2556 system hgrc, it has to be specified manually or in a different
2557 system hgrc, it has to be specified manually or in a different
2557 hgrc file)
2558 hgrc file)
2558
2559
2559 ``verbose``
2560 ``verbose``
2560 Increase the amount of output printed. (default: False)
2561 Increase the amount of output printed. (default: False)
2561
2562
2562
2563
2563 ``web``
2564 ``web``
2564 -------
2565 -------
2565
2566
2566 Web interface configuration. The settings in this section apply to
2567 Web interface configuration. The settings in this section apply to
2567 both the builtin webserver (started by :hg:`serve`) and the script you
2568 both the builtin webserver (started by :hg:`serve`) and the script you
2568 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2569 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2569 and WSGI).
2570 and WSGI).
2570
2571
2571 The Mercurial webserver does no authentication (it does not prompt for
2572 The Mercurial webserver does no authentication (it does not prompt for
2572 usernames and passwords to validate *who* users are), but it does do
2573 usernames and passwords to validate *who* users are), but it does do
2573 authorization (it grants or denies access for *authenticated users*
2574 authorization (it grants or denies access for *authenticated users*
2574 based on settings in this section). You must either configure your
2575 based on settings in this section). You must either configure your
2575 webserver to do authentication for you, or disable the authorization
2576 webserver to do authentication for you, or disable the authorization
2576 checks.
2577 checks.
2577
2578
2578 For a quick setup in a trusted environment, e.g., a private LAN, where
2579 For a quick setup in a trusted environment, e.g., a private LAN, where
2579 you want it to accept pushes from anybody, you can use the following
2580 you want it to accept pushes from anybody, you can use the following
2580 command line::
2581 command line::
2581
2582
2582 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2583 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2583
2584
2584 Note that this will allow anybody to push anything to the server and
2585 Note that this will allow anybody to push anything to the server and
2585 that this should not be used for public servers.
2586 that this should not be used for public servers.
2586
2587
2587 The full set of options is:
2588 The full set of options is:
2588
2589
2589 ``accesslog``
2590 ``accesslog``
2590 Where to output the access log. (default: stdout)
2591 Where to output the access log. (default: stdout)
2591
2592
2592 ``address``
2593 ``address``
2593 Interface address to bind to. (default: all)
2594 Interface address to bind to. (default: all)
2594
2595
2595 ``allow-archive``
2596 ``allow-archive``
2596 List of archive format (bz2, gz, zip) allowed for downloading.
2597 List of archive format (bz2, gz, zip) allowed for downloading.
2597 (default: empty)
2598 (default: empty)
2598
2599
2599 ``allowbz2``
2600 ``allowbz2``
2600 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2601 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2601 revisions.
2602 revisions.
2602 (default: False)
2603 (default: False)
2603
2604
2604 ``allowgz``
2605 ``allowgz``
2605 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2606 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2606 revisions.
2607 revisions.
2607 (default: False)
2608 (default: False)
2608
2609
2609 ``allow-pull``
2610 ``allow-pull``
2610 Whether to allow pulling from the repository. (default: True)
2611 Whether to allow pulling from the repository. (default: True)
2611
2612
2612 ``allow-push``
2613 ``allow-push``
2613 Whether to allow pushing to the repository. If empty or not set,
2614 Whether to allow pushing to the repository. If empty or not set,
2614 pushing is not allowed. If the special value ``*``, any remote
2615 pushing is not allowed. If the special value ``*``, any remote
2615 user can push, including unauthenticated users. Otherwise, the
2616 user can push, including unauthenticated users. Otherwise, the
2616 remote user must have been authenticated, and the authenticated
2617 remote user must have been authenticated, and the authenticated
2617 user name must be present in this list. The contents of the
2618 user name must be present in this list. The contents of the
2618 allow-push list are examined after the deny_push list.
2619 allow-push list are examined after the deny_push list.
2619
2620
2620 ``allow_read``
2621 ``allow_read``
2621 If the user has not already been denied repository access due to
2622 If the user has not already been denied repository access due to
2622 the contents of deny_read, this list determines whether to grant
2623 the contents of deny_read, this list determines whether to grant
2623 repository access to the user. If this list is not empty, and the
2624 repository access to the user. If this list is not empty, and the
2624 user is unauthenticated or not present in the list, then access is
2625 user is unauthenticated or not present in the list, then access is
2625 denied for the user. If the list is empty or not set, then access
2626 denied for the user. If the list is empty or not set, then access
2626 is permitted to all users by default. Setting allow_read to the
2627 is permitted to all users by default. Setting allow_read to the
2627 special value ``*`` is equivalent to it not being set (i.e. access
2628 special value ``*`` is equivalent to it not being set (i.e. access
2628 is permitted to all users). The contents of the allow_read list are
2629 is permitted to all users). The contents of the allow_read list are
2629 examined after the deny_read list.
2630 examined after the deny_read list.
2630
2631
2631 ``allowzip``
2632 ``allowzip``
2632 (DEPRECATED) Whether to allow .zip downloading of repository
2633 (DEPRECATED) Whether to allow .zip downloading of repository
2633 revisions. This feature creates temporary files.
2634 revisions. This feature creates temporary files.
2634 (default: False)
2635 (default: False)
2635
2636
2636 ``archivesubrepos``
2637 ``archivesubrepos``
2637 Whether to recurse into subrepositories when archiving.
2638 Whether to recurse into subrepositories when archiving.
2638 (default: False)
2639 (default: False)
2639
2640
2640 ``baseurl``
2641 ``baseurl``
2641 Base URL to use when publishing URLs in other locations, so
2642 Base URL to use when publishing URLs in other locations, so
2642 third-party tools like email notification hooks can construct
2643 third-party tools like email notification hooks can construct
2643 URLs. Example: ``http://hgserver/repos/``.
2644 URLs. Example: ``http://hgserver/repos/``.
2644
2645
2645 ``cacerts``
2646 ``cacerts``
2646 Path to file containing a list of PEM encoded certificate
2647 Path to file containing a list of PEM encoded certificate
2647 authority certificates. Environment variables and ``~user``
2648 authority certificates. Environment variables and ``~user``
2648 constructs are expanded in the filename. If specified on the
2649 constructs are expanded in the filename. If specified on the
2649 client, then it will verify the identity of remote HTTPS servers
2650 client, then it will verify the identity of remote HTTPS servers
2650 with these certificates.
2651 with these certificates.
2651
2652
2652 To disable SSL verification temporarily, specify ``--insecure`` from
2653 To disable SSL verification temporarily, specify ``--insecure`` from
2653 command line.
2654 command line.
2654
2655
2655 You can use OpenSSL's CA certificate file if your platform has
2656 You can use OpenSSL's CA certificate file if your platform has
2656 one. On most Linux systems this will be
2657 one. On most Linux systems this will be
2657 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2658 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2658 generate this file manually. The form must be as follows::
2659 generate this file manually. The form must be as follows::
2659
2660
2660 -----BEGIN CERTIFICATE-----
2661 -----BEGIN CERTIFICATE-----
2661 ... (certificate in base64 PEM encoding) ...
2662 ... (certificate in base64 PEM encoding) ...
2662 -----END CERTIFICATE-----
2663 -----END CERTIFICATE-----
2663 -----BEGIN CERTIFICATE-----
2664 -----BEGIN CERTIFICATE-----
2664 ... (certificate in base64 PEM encoding) ...
2665 ... (certificate in base64 PEM encoding) ...
2665 -----END CERTIFICATE-----
2666 -----END CERTIFICATE-----
2666
2667
2667 ``cache``
2668 ``cache``
2668 Whether to support caching in hgweb. (default: True)
2669 Whether to support caching in hgweb. (default: True)
2669
2670
2670 ``certificate``
2671 ``certificate``
2671 Certificate to use when running :hg:`serve`.
2672 Certificate to use when running :hg:`serve`.
2672
2673
2673 ``collapse``
2674 ``collapse``
2674 With ``descend`` enabled, repositories in subdirectories are shown at
2675 With ``descend`` enabled, repositories in subdirectories are shown at
2675 a single level alongside repositories in the current path. With
2676 a single level alongside repositories in the current path. With
2676 ``collapse`` also enabled, repositories residing at a deeper level than
2677 ``collapse`` also enabled, repositories residing at a deeper level than
2677 the current path are grouped behind navigable directory entries that
2678 the current path are grouped behind navigable directory entries that
2678 lead to the locations of these repositories. In effect, this setting
2679 lead to the locations of these repositories. In effect, this setting
2679 collapses each collection of repositories found within a subdirectory
2680 collapses each collection of repositories found within a subdirectory
2680 into a single entry for that subdirectory. (default: False)
2681 into a single entry for that subdirectory. (default: False)
2681
2682
2682 ``comparisoncontext``
2683 ``comparisoncontext``
2683 Number of lines of context to show in side-by-side file comparison. If
2684 Number of lines of context to show in side-by-side file comparison. If
2684 negative or the value ``full``, whole files are shown. (default: 5)
2685 negative or the value ``full``, whole files are shown. (default: 5)
2685
2686
2686 This setting can be overridden by a ``context`` request parameter to the
2687 This setting can be overridden by a ``context`` request parameter to the
2687 ``comparison`` command, taking the same values.
2688 ``comparison`` command, taking the same values.
2688
2689
2689 ``contact``
2690 ``contact``
2690 Name or email address of the person in charge of the repository.
2691 Name or email address of the person in charge of the repository.
2691 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2692 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2692
2693
2693 ``csp``
2694 ``csp``
2694 Send a ``Content-Security-Policy`` HTTP header with this value.
2695 Send a ``Content-Security-Policy`` HTTP header with this value.
2695
2696
2696 The value may contain a special string ``%nonce%``, which will be replaced
2697 The value may contain a special string ``%nonce%``, which will be replaced
2697 by a randomly-generated one-time use value. If the value contains
2698 by a randomly-generated one-time use value. If the value contains
2698 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2699 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2699 one-time property of the nonce. This nonce will also be inserted into
2700 one-time property of the nonce. This nonce will also be inserted into
2700 ``<script>`` elements containing inline JavaScript.
2701 ``<script>`` elements containing inline JavaScript.
2701
2702
2702 Note: lots of HTML content sent by the server is derived from repository
2703 Note: lots of HTML content sent by the server is derived from repository
2703 data. Please consider the potential for malicious repository data to
2704 data. Please consider the potential for malicious repository data to
2704 "inject" itself into generated HTML content as part of your security
2705 "inject" itself into generated HTML content as part of your security
2705 threat model.
2706 threat model.
2706
2707
2707 ``deny_push``
2708 ``deny_push``
2708 Whether to deny pushing to the repository. If empty or not set,
2709 Whether to deny pushing to the repository. If empty or not set,
2709 push is not denied. If the special value ``*``, all remote users are
2710 push is not denied. If the special value ``*``, all remote users are
2710 denied push. Otherwise, unauthenticated users are all denied, and
2711 denied push. Otherwise, unauthenticated users are all denied, and
2711 any authenticated user name present in this list is also denied. The
2712 any authenticated user name present in this list is also denied. The
2712 contents of the deny_push list are examined before the allow-push list.
2713 contents of the deny_push list are examined before the allow-push list.
2713
2714
2714 ``deny_read``
2715 ``deny_read``
2715 Whether to deny reading/viewing of the repository. If this list is
2716 Whether to deny reading/viewing of the repository. If this list is
2716 not empty, unauthenticated users are all denied, and any
2717 not empty, unauthenticated users are all denied, and any
2717 authenticated user name present in this list is also denied access to
2718 authenticated user name present in this list is also denied access to
2718 the repository. If set to the special value ``*``, all remote users
2719 the repository. If set to the special value ``*``, all remote users
2719 are denied access (rarely needed ;). If deny_read is empty or not set,
2720 are denied access (rarely needed ;). If deny_read is empty or not set,
2720 the determination of repository access depends on the presence and
2721 the determination of repository access depends on the presence and
2721 content of the allow_read list (see description). If both
2722 content of the allow_read list (see description). If both
2722 deny_read and allow_read are empty or not set, then access is
2723 deny_read and allow_read are empty or not set, then access is
2723 permitted to all users by default. If the repository is being
2724 permitted to all users by default. If the repository is being
2724 served via hgwebdir, denied users will not be able to see it in
2725 served via hgwebdir, denied users will not be able to see it in
2725 the list of repositories. The contents of the deny_read list have
2726 the list of repositories. The contents of the deny_read list have
2726 priority over (are examined before) the contents of the allow_read
2727 priority over (are examined before) the contents of the allow_read
2727 list.
2728 list.
2728
2729
2729 ``descend``
2730 ``descend``
2730 hgwebdir indexes will not descend into subdirectories. Only repositories
2731 hgwebdir indexes will not descend into subdirectories. Only repositories
2731 directly in the current path will be shown (other repositories are still
2732 directly in the current path will be shown (other repositories are still
2732 available from the index corresponding to their containing path).
2733 available from the index corresponding to their containing path).
2733
2734
2734 ``description``
2735 ``description``
2735 Textual description of the repository's purpose or contents.
2736 Textual description of the repository's purpose or contents.
2736 (default: "unknown")
2737 (default: "unknown")
2737
2738
2738 ``encoding``
2739 ``encoding``
2739 Character encoding name. (default: the current locale charset)
2740 Character encoding name. (default: the current locale charset)
2740 Example: "UTF-8".
2741 Example: "UTF-8".
2741
2742
2742 ``errorlog``
2743 ``errorlog``
2743 Where to output the error log. (default: stderr)
2744 Where to output the error log. (default: stderr)
2744
2745
2745 ``guessmime``
2746 ``guessmime``
2746 Control MIME types for raw download of file content.
2747 Control MIME types for raw download of file content.
2747 Set to True to let hgweb guess the content type from the file
2748 Set to True to let hgweb guess the content type from the file
2748 extension. This will serve HTML files as ``text/html`` and might
2749 extension. This will serve HTML files as ``text/html`` and might
2749 allow cross-site scripting attacks when serving untrusted
2750 allow cross-site scripting attacks when serving untrusted
2750 repositories. (default: False)
2751 repositories. (default: False)
2751
2752
2752 ``hidden``
2753 ``hidden``
2753 Whether to hide the repository in the hgwebdir index.
2754 Whether to hide the repository in the hgwebdir index.
2754 (default: False)
2755 (default: False)
2755
2756
2756 ``ipv6``
2757 ``ipv6``
2757 Whether to use IPv6. (default: False)
2758 Whether to use IPv6. (default: False)
2758
2759
2759 ``labels``
2760 ``labels``
2760 List of string *labels* associated with the repository.
2761 List of string *labels* associated with the repository.
2761
2762
2762 Labels are exposed as a template keyword and can be used to customize
2763 Labels are exposed as a template keyword and can be used to customize
2763 output. e.g. the ``index`` template can group or filter repositories
2764 output. e.g. the ``index`` template can group or filter repositories
2764 by labels and the ``summary`` template can display additional content
2765 by labels and the ``summary`` template can display additional content
2765 if a specific label is present.
2766 if a specific label is present.
2766
2767
2767 ``logoimg``
2768 ``logoimg``
2768 File name of the logo image that some templates display on each page.
2769 File name of the logo image that some templates display on each page.
2769 The file name is relative to ``staticurl``. That is, the full path to
2770 The file name is relative to ``staticurl``. That is, the full path to
2770 the logo image is "staticurl/logoimg".
2771 the logo image is "staticurl/logoimg".
2771 If unset, ``hglogo.png`` will be used.
2772 If unset, ``hglogo.png`` will be used.
2772
2773
2773 ``logourl``
2774 ``logourl``
2774 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2775 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2775 will be used.
2776 will be used.
2776
2777
2777 ``maxchanges``
2778 ``maxchanges``
2778 Maximum number of changes to list on the changelog. (default: 10)
2779 Maximum number of changes to list on the changelog. (default: 10)
2779
2780
2780 ``maxfiles``
2781 ``maxfiles``
2781 Maximum number of files to list per changeset. (default: 10)
2782 Maximum number of files to list per changeset. (default: 10)
2782
2783
2783 ``maxshortchanges``
2784 ``maxshortchanges``
2784 Maximum number of changes to list on the shortlog, graph or filelog
2785 Maximum number of changes to list on the shortlog, graph or filelog
2785 pages. (default: 60)
2786 pages. (default: 60)
2786
2787
2787 ``name``
2788 ``name``
2788 Repository name to use in the web interface.
2789 Repository name to use in the web interface.
2789 (default: current working directory)
2790 (default: current working directory)
2790
2791
2791 ``port``
2792 ``port``
2792 Port to listen on. (default: 8000)
2793 Port to listen on. (default: 8000)
2793
2794
2794 ``prefix``
2795 ``prefix``
2795 Prefix path to serve from. (default: '' (server root))
2796 Prefix path to serve from. (default: '' (server root))
2796
2797
2797 ``push_ssl``
2798 ``push_ssl``
2798 Whether to require that inbound pushes be transported over SSL to
2799 Whether to require that inbound pushes be transported over SSL to
2799 prevent password sniffing. (default: True)
2800 prevent password sniffing. (default: True)
2800
2801
2801 ``refreshinterval``
2802 ``refreshinterval``
2802 How frequently directory listings re-scan the filesystem for new
2803 How frequently directory listings re-scan the filesystem for new
2803 repositories, in seconds. This is relevant when wildcards are used
2804 repositories, in seconds. This is relevant when wildcards are used
2804 to define paths. Depending on how much filesystem traversal is
2805 to define paths. Depending on how much filesystem traversal is
2805 required, refreshing may negatively impact performance.
2806 required, refreshing may negatively impact performance.
2806
2807
2807 Values less than or equal to 0 always refresh.
2808 Values less than or equal to 0 always refresh.
2808 (default: 20)
2809 (default: 20)
2809
2810
2810 ``server-header``
2811 ``server-header``
2811 Value for HTTP ``Server`` response header.
2812 Value for HTTP ``Server`` response header.
2812
2813
2813 ``static``
2814 ``static``
2814 Directory where static files are served from.
2815 Directory where static files are served from.
2815
2816
2816 ``staticurl``
2817 ``staticurl``
2817 Base URL to use for static files. If unset, static files (e.g. the
2818 Base URL to use for static files. If unset, static files (e.g. the
2818 hgicon.png favicon) will be served by the CGI script itself. Use
2819 hgicon.png favicon) will be served by the CGI script itself. Use
2819 this setting to serve them directly with the HTTP server.
2820 this setting to serve them directly with the HTTP server.
2820 Example: ``http://hgserver/static/``.
2821 Example: ``http://hgserver/static/``.
2821
2822
2822 ``stripes``
2823 ``stripes``
2823 How many lines a "zebra stripe" should span in multi-line output.
2824 How many lines a "zebra stripe" should span in multi-line output.
2824 Set to 0 to disable. (default: 1)
2825 Set to 0 to disable. (default: 1)
2825
2826
2826 ``style``
2827 ``style``
2827 Which template map style to use. The available options are the names of
2828 Which template map style to use. The available options are the names of
2828 subdirectories in the HTML templates path. (default: ``paper``)
2829 subdirectories in the HTML templates path. (default: ``paper``)
2829 Example: ``monoblue``.
2830 Example: ``monoblue``.
2830
2831
2831 ``templates``
2832 ``templates``
2832 Where to find the HTML templates. The default path to the HTML templates
2833 Where to find the HTML templates. The default path to the HTML templates
2833 can be obtained from ``hg debuginstall``.
2834 can be obtained from ``hg debuginstall``.
2834
2835
2835 ``websub``
2836 ``websub``
2836 ----------
2837 ----------
2837
2838
2838 Web substitution filter definition. You can use this section to
2839 Web substitution filter definition. You can use this section to
2839 define a set of regular expression substitution patterns which
2840 define a set of regular expression substitution patterns which
2840 let you automatically modify the hgweb server output.
2841 let you automatically modify the hgweb server output.
2841
2842
2842 The default hgweb templates only apply these substitution patterns
2843 The default hgweb templates only apply these substitution patterns
2843 on the revision description fields. You can apply them anywhere
2844 on the revision description fields. You can apply them anywhere
2844 you want when you create your own templates by adding calls to the
2845 you want when you create your own templates by adding calls to the
2845 "websub" filter (usually after calling the "escape" filter).
2846 "websub" filter (usually after calling the "escape" filter).
2846
2847
2847 This can be used, for example, to convert issue references to links
2848 This can be used, for example, to convert issue references to links
2848 to your issue tracker, or to convert "markdown-like" syntax into
2849 to your issue tracker, or to convert "markdown-like" syntax into
2849 HTML (see the examples below).
2850 HTML (see the examples below).
2850
2851
2851 Each entry in this section names a substitution filter.
2852 Each entry in this section names a substitution filter.
2852 The value of each entry defines the substitution expression itself.
2853 The value of each entry defines the substitution expression itself.
2853 The websub expressions follow the old interhg extension syntax,
2854 The websub expressions follow the old interhg extension syntax,
2854 which in turn imitates the Unix sed replacement syntax::
2855 which in turn imitates the Unix sed replacement syntax::
2855
2856
2856 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2857 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2857
2858
2858 You can use any separator other than "/". The final "i" is optional
2859 You can use any separator other than "/". The final "i" is optional
2859 and indicates that the search must be case insensitive.
2860 and indicates that the search must be case insensitive.
2860
2861
2861 Examples::
2862 Examples::
2862
2863
2863 [websub]
2864 [websub]
2864 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2865 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2865 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2866 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2866 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2867 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2867
2868
2868 ``worker``
2869 ``worker``
2869 ----------
2870 ----------
2870
2871
2871 Parallel master/worker configuration. We currently perform working
2872 Parallel master/worker configuration. We currently perform working
2872 directory updates in parallel on Unix-like systems, which greatly
2873 directory updates in parallel on Unix-like systems, which greatly
2873 helps performance.
2874 helps performance.
2874
2875
2875 ``enabled``
2876 ``enabled``
2876 Whether to enable workers code to be used.
2877 Whether to enable workers code to be used.
2877 (default: true)
2878 (default: true)
2878
2879
2879 ``numcpus``
2880 ``numcpus``
2880 Number of CPUs to use for parallel operations. A zero or
2881 Number of CPUs to use for parallel operations. A zero or
2881 negative value is treated as ``use the default``.
2882 negative value is treated as ``use the default``.
2882 (default: 4 or the number of CPUs on the system, whichever is larger)
2883 (default: 4 or the number of CPUs on the system, whichever is larger)
2883
2884
2884 ``backgroundclose``
2885 ``backgroundclose``
2885 Whether to enable closing file handles on background threads during certain
2886 Whether to enable closing file handles on background threads during certain
2886 operations. Some platforms aren't very efficient at closing file
2887 operations. Some platforms aren't very efficient at closing file
2887 handles that have been written or appended to. By performing file closing
2888 handles that have been written or appended to. By performing file closing
2888 on background threads, file write rate can increase substantially.
2889 on background threads, file write rate can increase substantially.
2889 (default: true on Windows, false elsewhere)
2890 (default: true on Windows, false elsewhere)
2890
2891
2891 ``backgroundcloseminfilecount``
2892 ``backgroundcloseminfilecount``
2892 Minimum number of files required to trigger background file closing.
2893 Minimum number of files required to trigger background file closing.
2893 Operations not writing this many files won't start background close
2894 Operations not writing this many files won't start background close
2894 threads.
2895 threads.
2895 (default: 2048)
2896 (default: 2048)
2896
2897
2897 ``backgroundclosemaxqueue``
2898 ``backgroundclosemaxqueue``
2898 The maximum number of opened file handles waiting to be closed in the
2899 The maximum number of opened file handles waiting to be closed in the
2899 background. This option only has an effect if ``backgroundclose`` is
2900 background. This option only has an effect if ``backgroundclose`` is
2900 enabled.
2901 enabled.
2901 (default: 384)
2902 (default: 384)
2902
2903
2903 ``backgroundclosethreadcount``
2904 ``backgroundclosethreadcount``
2904 Number of threads to process background file closes. Only relevant if
2905 Number of threads to process background file closes. Only relevant if
2905 ``backgroundclose`` is enabled.
2906 ``backgroundclose`` is enabled.
2906 (default: 4)
2907 (default: 4)
General Comments 0
You need to be logged in to leave comments. Login now