##// END OF EJS Templates
absorb: consider rewrite.empty-successor configuration...
Manuel Jacob -
r45684:3ee8e2d5 default
parent child Browse files
Show More
@@ -1,1137 +1,1144 b''
1 # absorb.py
1 # absorb.py
2 #
2 #
3 # Copyright 2016 Facebook, Inc.
3 # Copyright 2016 Facebook, Inc.
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 """apply working directory changes to changesets (EXPERIMENTAL)
8 """apply working directory changes to changesets (EXPERIMENTAL)
9
9
10 The absorb extension provides a command to use annotate information to
10 The absorb extension provides a command to use annotate information to
11 amend modified chunks into the corresponding non-public changesets.
11 amend modified chunks into the corresponding non-public changesets.
12
12
13 ::
13 ::
14
14
15 [absorb]
15 [absorb]
16 # only check 50 recent non-public changesets at most
16 # only check 50 recent non-public changesets at most
17 max-stack-size = 50
17 max-stack-size = 50
18 # whether to add noise to new commits to avoid obsolescence cycle
18 # whether to add noise to new commits to avoid obsolescence cycle
19 add-noise = 1
19 add-noise = 1
20 # make `amend --correlated` a shortcut to the main command
20 # make `amend --correlated` a shortcut to the main command
21 amend-flag = correlated
21 amend-flag = correlated
22
22
23 [color]
23 [color]
24 absorb.description = yellow
24 absorb.description = yellow
25 absorb.node = blue bold
25 absorb.node = blue bold
26 absorb.path = bold
26 absorb.path = bold
27 """
27 """
28
28
29 # TODO:
29 # TODO:
30 # * Rename config items to [commands] namespace
30 # * Rename config items to [commands] namespace
31 # * Converge getdraftstack() with other code in core
31 # * Converge getdraftstack() with other code in core
32 # * move many attributes on fixupstate to be private
32 # * move many attributes on fixupstate to be private
33
33
34 from __future__ import absolute_import
34 from __future__ import absolute_import
35
35
36 import collections
36 import collections
37
37
38 from mercurial.i18n import _
38 from mercurial.i18n import _
39 from mercurial import (
39 from mercurial import (
40 cmdutil,
40 cmdutil,
41 commands,
41 commands,
42 context,
42 context,
43 crecord,
43 crecord,
44 error,
44 error,
45 linelog,
45 linelog,
46 mdiff,
46 mdiff,
47 node,
47 node,
48 obsolete,
48 obsolete,
49 patch,
49 patch,
50 phases,
50 phases,
51 pycompat,
51 pycompat,
52 registrar,
52 registrar,
53 rewriteutil,
53 scmutil,
54 scmutil,
54 util,
55 util,
55 )
56 )
56 from mercurial.utils import stringutil
57 from mercurial.utils import stringutil
57
58
58 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
59 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
59 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
60 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
60 # be specifying the version(s) of Mercurial they are tested with, or
61 # be specifying the version(s) of Mercurial they are tested with, or
61 # leave the attribute unspecified.
62 # leave the attribute unspecified.
62 testedwith = b'ships-with-hg-core'
63 testedwith = b'ships-with-hg-core'
63
64
64 cmdtable = {}
65 cmdtable = {}
65 command = registrar.command(cmdtable)
66 command = registrar.command(cmdtable)
66
67
67 configtable = {}
68 configtable = {}
68 configitem = registrar.configitem(configtable)
69 configitem = registrar.configitem(configtable)
69
70
70 configitem(b'absorb', b'add-noise', default=True)
71 configitem(b'absorb', b'add-noise', default=True)
71 configitem(b'absorb', b'amend-flag', default=None)
72 configitem(b'absorb', b'amend-flag', default=None)
72 configitem(b'absorb', b'max-stack-size', default=50)
73 configitem(b'absorb', b'max-stack-size', default=50)
73
74
74 colortable = {
75 colortable = {
75 b'absorb.description': b'yellow',
76 b'absorb.description': b'yellow',
76 b'absorb.node': b'blue bold',
77 b'absorb.node': b'blue bold',
77 b'absorb.path': b'bold',
78 b'absorb.path': b'bold',
78 }
79 }
79
80
80 defaultdict = collections.defaultdict
81 defaultdict = collections.defaultdict
81
82
82
83
83 class nullui(object):
84 class nullui(object):
84 """blank ui object doing nothing"""
85 """blank ui object doing nothing"""
85
86
86 debugflag = False
87 debugflag = False
87 verbose = False
88 verbose = False
88 quiet = True
89 quiet = True
89
90
90 def __getitem__(name):
91 def __getitem__(name):
91 def nullfunc(*args, **kwds):
92 def nullfunc(*args, **kwds):
92 return
93 return
93
94
94 return nullfunc
95 return nullfunc
95
96
96
97
97 class emptyfilecontext(object):
98 class emptyfilecontext(object):
98 """minimal filecontext representing an empty file"""
99 """minimal filecontext representing an empty file"""
99
100
100 def data(self):
101 def data(self):
101 return b''
102 return b''
102
103
103 def node(self):
104 def node(self):
104 return node.nullid
105 return node.nullid
105
106
106
107
107 def uniq(lst):
108 def uniq(lst):
108 """list -> list. remove duplicated items without changing the order"""
109 """list -> list. remove duplicated items without changing the order"""
109 seen = set()
110 seen = set()
110 result = []
111 result = []
111 for x in lst:
112 for x in lst:
112 if x not in seen:
113 if x not in seen:
113 seen.add(x)
114 seen.add(x)
114 result.append(x)
115 result.append(x)
115 return result
116 return result
116
117
117
118
118 def getdraftstack(headctx, limit=None):
119 def getdraftstack(headctx, limit=None):
119 """(ctx, int?) -> [ctx]. get a linear stack of non-public changesets.
120 """(ctx, int?) -> [ctx]. get a linear stack of non-public changesets.
120
121
121 changesets are sorted in topo order, oldest first.
122 changesets are sorted in topo order, oldest first.
122 return at most limit items, if limit is a positive number.
123 return at most limit items, if limit is a positive number.
123
124
124 merges are considered as non-draft as well. i.e. every commit
125 merges are considered as non-draft as well. i.e. every commit
125 returned has and only has 1 parent.
126 returned has and only has 1 parent.
126 """
127 """
127 ctx = headctx
128 ctx = headctx
128 result = []
129 result = []
129 while ctx.phase() != phases.public:
130 while ctx.phase() != phases.public:
130 if limit and len(result) >= limit:
131 if limit and len(result) >= limit:
131 break
132 break
132 parents = ctx.parents()
133 parents = ctx.parents()
133 if len(parents) != 1:
134 if len(parents) != 1:
134 break
135 break
135 result.append(ctx)
136 result.append(ctx)
136 ctx = parents[0]
137 ctx = parents[0]
137 result.reverse()
138 result.reverse()
138 return result
139 return result
139
140
140
141
141 def getfilestack(stack, path, seenfctxs=None):
142 def getfilestack(stack, path, seenfctxs=None):
142 """([ctx], str, set) -> [fctx], {ctx: fctx}
143 """([ctx], str, set) -> [fctx], {ctx: fctx}
143
144
144 stack is a list of contexts, from old to new. usually they are what
145 stack is a list of contexts, from old to new. usually they are what
145 "getdraftstack" returns.
146 "getdraftstack" returns.
146
147
147 follows renames, but not copies.
148 follows renames, but not copies.
148
149
149 seenfctxs is a set of filecontexts that will be considered "immutable".
150 seenfctxs is a set of filecontexts that will be considered "immutable".
150 they are usually what this function returned in earlier calls, useful
151 they are usually what this function returned in earlier calls, useful
151 to avoid issues that a file was "moved" to multiple places and was then
152 to avoid issues that a file was "moved" to multiple places and was then
152 modified differently, like: "a" was copied to "b", "a" was also copied to
153 modified differently, like: "a" was copied to "b", "a" was also copied to
153 "c" and then "a" was deleted, then both "b" and "c" were "moved" from "a"
154 "c" and then "a" was deleted, then both "b" and "c" were "moved" from "a"
154 and we enforce only one of them to be able to affect "a"'s content.
155 and we enforce only one of them to be able to affect "a"'s content.
155
156
156 return an empty list and an empty dict, if the specified path does not
157 return an empty list and an empty dict, if the specified path does not
157 exist in stack[-1] (the top of the stack).
158 exist in stack[-1] (the top of the stack).
158
159
159 otherwise, return a list of de-duplicated filecontexts, and the map to
160 otherwise, return a list of de-duplicated filecontexts, and the map to
160 convert ctx in the stack to fctx, for possible mutable fctxs. the first item
161 convert ctx in the stack to fctx, for possible mutable fctxs. the first item
161 of the list would be outside the stack and should be considered immutable.
162 of the list would be outside the stack and should be considered immutable.
162 the remaining items are within the stack.
163 the remaining items are within the stack.
163
164
164 for example, given the following changelog and corresponding filelog
165 for example, given the following changelog and corresponding filelog
165 revisions:
166 revisions:
166
167
167 changelog: 3----4----5----6----7
168 changelog: 3----4----5----6----7
168 filelog: x 0----1----1----2 (x: no such file yet)
169 filelog: x 0----1----1----2 (x: no such file yet)
169
170
170 - if stack = [5, 6, 7], returns ([0, 1, 2], {5: 1, 6: 1, 7: 2})
171 - if stack = [5, 6, 7], returns ([0, 1, 2], {5: 1, 6: 1, 7: 2})
171 - if stack = [3, 4, 5], returns ([e, 0, 1], {4: 0, 5: 1}), where "e" is a
172 - if stack = [3, 4, 5], returns ([e, 0, 1], {4: 0, 5: 1}), where "e" is a
172 dummy empty filecontext.
173 dummy empty filecontext.
173 - if stack = [2], returns ([], {})
174 - if stack = [2], returns ([], {})
174 - if stack = [7], returns ([1, 2], {7: 2})
175 - if stack = [7], returns ([1, 2], {7: 2})
175 - if stack = [6, 7], returns ([1, 2], {6: 1, 7: 2}), although {6: 1} can be
176 - if stack = [6, 7], returns ([1, 2], {6: 1, 7: 2}), although {6: 1} can be
176 removed, since 1 is immutable.
177 removed, since 1 is immutable.
177 """
178 """
178 if seenfctxs is None:
179 if seenfctxs is None:
179 seenfctxs = set()
180 seenfctxs = set()
180 assert stack
181 assert stack
181
182
182 if path not in stack[-1]:
183 if path not in stack[-1]:
183 return [], {}
184 return [], {}
184
185
185 fctxs = []
186 fctxs = []
186 fctxmap = {}
187 fctxmap = {}
187
188
188 pctx = stack[0].p1() # the public (immutable) ctx we stop at
189 pctx = stack[0].p1() # the public (immutable) ctx we stop at
189 for ctx in reversed(stack):
190 for ctx in reversed(stack):
190 if path not in ctx: # the file is added in the next commit
191 if path not in ctx: # the file is added in the next commit
191 pctx = ctx
192 pctx = ctx
192 break
193 break
193 fctx = ctx[path]
194 fctx = ctx[path]
194 fctxs.append(fctx)
195 fctxs.append(fctx)
195 if fctx in seenfctxs: # treat fctx as the immutable one
196 if fctx in seenfctxs: # treat fctx as the immutable one
196 pctx = None # do not add another immutable fctx
197 pctx = None # do not add another immutable fctx
197 break
198 break
198 fctxmap[ctx] = fctx # only for mutable fctxs
199 fctxmap[ctx] = fctx # only for mutable fctxs
199 copy = fctx.copysource()
200 copy = fctx.copysource()
200 if copy:
201 if copy:
201 path = copy # follow rename
202 path = copy # follow rename
202 if path in ctx: # but do not follow copy
203 if path in ctx: # but do not follow copy
203 pctx = ctx.p1()
204 pctx = ctx.p1()
204 break
205 break
205
206
206 if pctx is not None: # need an extra immutable fctx
207 if pctx is not None: # need an extra immutable fctx
207 if path in pctx:
208 if path in pctx:
208 fctxs.append(pctx[path])
209 fctxs.append(pctx[path])
209 else:
210 else:
210 fctxs.append(emptyfilecontext())
211 fctxs.append(emptyfilecontext())
211
212
212 fctxs.reverse()
213 fctxs.reverse()
213 # note: we rely on a property of hg: filerev is not reused for linear
214 # note: we rely on a property of hg: filerev is not reused for linear
214 # history. i.e. it's impossible to have:
215 # history. i.e. it's impossible to have:
215 # changelog: 4----5----6 (linear, no merges)
216 # changelog: 4----5----6 (linear, no merges)
216 # filelog: 1----2----1
217 # filelog: 1----2----1
217 # ^ reuse filerev (impossible)
218 # ^ reuse filerev (impossible)
218 # because parents are part of the hash. if that's not true, we need to
219 # because parents are part of the hash. if that's not true, we need to
219 # remove uniq and find a different way to identify fctxs.
220 # remove uniq and find a different way to identify fctxs.
220 return uniq(fctxs), fctxmap
221 return uniq(fctxs), fctxmap
221
222
222
223
223 class overlaystore(patch.filestore):
224 class overlaystore(patch.filestore):
224 """read-only, hybrid store based on a dict and ctx.
225 """read-only, hybrid store based on a dict and ctx.
225 memworkingcopy: {path: content}, overrides file contents.
226 memworkingcopy: {path: content}, overrides file contents.
226 """
227 """
227
228
228 def __init__(self, basectx, memworkingcopy):
229 def __init__(self, basectx, memworkingcopy):
229 self.basectx = basectx
230 self.basectx = basectx
230 self.memworkingcopy = memworkingcopy
231 self.memworkingcopy = memworkingcopy
231
232
232 def getfile(self, path):
233 def getfile(self, path):
233 """comply with mercurial.patch.filestore.getfile"""
234 """comply with mercurial.patch.filestore.getfile"""
234 if path not in self.basectx:
235 if path not in self.basectx:
235 return None, None, None
236 return None, None, None
236 fctx = self.basectx[path]
237 fctx = self.basectx[path]
237 if path in self.memworkingcopy:
238 if path in self.memworkingcopy:
238 content = self.memworkingcopy[path]
239 content = self.memworkingcopy[path]
239 else:
240 else:
240 content = fctx.data()
241 content = fctx.data()
241 mode = (fctx.islink(), fctx.isexec())
242 mode = (fctx.islink(), fctx.isexec())
242 copy = fctx.copysource()
243 copy = fctx.copysource()
243 return content, mode, copy
244 return content, mode, copy
244
245
245
246
246 def overlaycontext(memworkingcopy, ctx, parents=None, extra=None):
247 def overlaycontext(memworkingcopy, ctx, parents=None, extra=None):
247 """({path: content}, ctx, (p1node, p2node)?, {}?) -> memctx
248 """({path: content}, ctx, (p1node, p2node)?, {}?) -> memctx
248 memworkingcopy overrides file contents.
249 memworkingcopy overrides file contents.
249 """
250 """
250 # parents must contain 2 items: (node1, node2)
251 # parents must contain 2 items: (node1, node2)
251 if parents is None:
252 if parents is None:
252 parents = ctx.repo().changelog.parents(ctx.node())
253 parents = ctx.repo().changelog.parents(ctx.node())
253 if extra is None:
254 if extra is None:
254 extra = ctx.extra()
255 extra = ctx.extra()
255 date = ctx.date()
256 date = ctx.date()
256 desc = ctx.description()
257 desc = ctx.description()
257 user = ctx.user()
258 user = ctx.user()
258 files = set(ctx.files()).union(memworkingcopy)
259 files = set(ctx.files()).union(memworkingcopy)
259 store = overlaystore(ctx, memworkingcopy)
260 store = overlaystore(ctx, memworkingcopy)
260 return context.memctx(
261 return context.memctx(
261 repo=ctx.repo(),
262 repo=ctx.repo(),
262 parents=parents,
263 parents=parents,
263 text=desc,
264 text=desc,
264 files=files,
265 files=files,
265 filectxfn=store,
266 filectxfn=store,
266 user=user,
267 user=user,
267 date=date,
268 date=date,
268 branch=None,
269 branch=None,
269 extra=extra,
270 extra=extra,
270 )
271 )
271
272
272
273
273 class filefixupstate(object):
274 class filefixupstate(object):
274 """state needed to apply fixups to a single file
275 """state needed to apply fixups to a single file
275
276
276 internally, it keeps file contents of several revisions and a linelog.
277 internally, it keeps file contents of several revisions and a linelog.
277
278
278 the linelog uses odd revision numbers for original contents (fctxs passed
279 the linelog uses odd revision numbers for original contents (fctxs passed
279 to __init__), and even revision numbers for fixups, like:
280 to __init__), and even revision numbers for fixups, like:
280
281
281 linelog rev 1: self.fctxs[0] (from an immutable "public" changeset)
282 linelog rev 1: self.fctxs[0] (from an immutable "public" changeset)
282 linelog rev 2: fixups made to self.fctxs[0]
283 linelog rev 2: fixups made to self.fctxs[0]
283 linelog rev 3: self.fctxs[1] (a child of fctxs[0])
284 linelog rev 3: self.fctxs[1] (a child of fctxs[0])
284 linelog rev 4: fixups made to self.fctxs[1]
285 linelog rev 4: fixups made to self.fctxs[1]
285 ...
286 ...
286
287
287 a typical use is like:
288 a typical use is like:
288
289
289 1. call diffwith, to calculate self.fixups
290 1. call diffwith, to calculate self.fixups
290 2. (optionally), present self.fixups to the user, or change it
291 2. (optionally), present self.fixups to the user, or change it
291 3. call apply, to apply changes
292 3. call apply, to apply changes
292 4. read results from "finalcontents", or call getfinalcontent
293 4. read results from "finalcontents", or call getfinalcontent
293 """
294 """
294
295
295 def __init__(self, fctxs, path, ui=None, opts=None):
296 def __init__(self, fctxs, path, ui=None, opts=None):
296 """([fctx], ui or None) -> None
297 """([fctx], ui or None) -> None
297
298
298 fctxs should be linear, and sorted by topo order - oldest first.
299 fctxs should be linear, and sorted by topo order - oldest first.
299 fctxs[0] will be considered as "immutable" and will not be changed.
300 fctxs[0] will be considered as "immutable" and will not be changed.
300 """
301 """
301 self.fctxs = fctxs
302 self.fctxs = fctxs
302 self.path = path
303 self.path = path
303 self.ui = ui or nullui()
304 self.ui = ui or nullui()
304 self.opts = opts or {}
305 self.opts = opts or {}
305
306
306 # following fields are built from fctxs. they exist for perf reason
307 # following fields are built from fctxs. they exist for perf reason
307 self.contents = [f.data() for f in fctxs]
308 self.contents = [f.data() for f in fctxs]
308 self.contentlines = pycompat.maplist(mdiff.splitnewlines, self.contents)
309 self.contentlines = pycompat.maplist(mdiff.splitnewlines, self.contents)
309 self.linelog = self._buildlinelog()
310 self.linelog = self._buildlinelog()
310 if self.ui.debugflag:
311 if self.ui.debugflag:
311 assert self._checkoutlinelog() == self.contents
312 assert self._checkoutlinelog() == self.contents
312
313
313 # following fields will be filled later
314 # following fields will be filled later
314 self.chunkstats = [0, 0] # [adopted, total : int]
315 self.chunkstats = [0, 0] # [adopted, total : int]
315 self.targetlines = [] # [str]
316 self.targetlines = [] # [str]
316 self.fixups = [] # [(linelog rev, a1, a2, b1, b2)]
317 self.fixups = [] # [(linelog rev, a1, a2, b1, b2)]
317 self.finalcontents = [] # [str]
318 self.finalcontents = [] # [str]
318 self.ctxaffected = set()
319 self.ctxaffected = set()
319
320
320 def diffwith(self, targetfctx, fm=None):
321 def diffwith(self, targetfctx, fm=None):
321 """calculate fixups needed by examining the differences between
322 """calculate fixups needed by examining the differences between
322 self.fctxs[-1] and targetfctx, chunk by chunk.
323 self.fctxs[-1] and targetfctx, chunk by chunk.
323
324
324 targetfctx is the target state we move towards. we may or may not be
325 targetfctx is the target state we move towards. we may or may not be
325 able to get there because not all modified chunks can be amended into
326 able to get there because not all modified chunks can be amended into
326 a non-public fctx unambiguously.
327 a non-public fctx unambiguously.
327
328
328 call this only once, before apply().
329 call this only once, before apply().
329
330
330 update self.fixups, self.chunkstats, and self.targetlines.
331 update self.fixups, self.chunkstats, and self.targetlines.
331 """
332 """
332 a = self.contents[-1]
333 a = self.contents[-1]
333 alines = self.contentlines[-1]
334 alines = self.contentlines[-1]
334 b = targetfctx.data()
335 b = targetfctx.data()
335 blines = mdiff.splitnewlines(b)
336 blines = mdiff.splitnewlines(b)
336 self.targetlines = blines
337 self.targetlines = blines
337
338
338 self.linelog.annotate(self.linelog.maxrev)
339 self.linelog.annotate(self.linelog.maxrev)
339 annotated = self.linelog.annotateresult # [(linelog rev, linenum)]
340 annotated = self.linelog.annotateresult # [(linelog rev, linenum)]
340 assert len(annotated) == len(alines)
341 assert len(annotated) == len(alines)
341 # add a dummy end line to make insertion at the end easier
342 # add a dummy end line to make insertion at the end easier
342 if annotated:
343 if annotated:
343 dummyendline = (annotated[-1][0], annotated[-1][1] + 1)
344 dummyendline = (annotated[-1][0], annotated[-1][1] + 1)
344 annotated.append(dummyendline)
345 annotated.append(dummyendline)
345
346
346 # analyse diff blocks
347 # analyse diff blocks
347 for chunk in self._alldiffchunks(a, b, alines, blines):
348 for chunk in self._alldiffchunks(a, b, alines, blines):
348 newfixups = self._analysediffchunk(chunk, annotated)
349 newfixups = self._analysediffchunk(chunk, annotated)
349 self.chunkstats[0] += bool(newfixups) # 1 or 0
350 self.chunkstats[0] += bool(newfixups) # 1 or 0
350 self.chunkstats[1] += 1
351 self.chunkstats[1] += 1
351 self.fixups += newfixups
352 self.fixups += newfixups
352 if fm is not None:
353 if fm is not None:
353 self._showchanges(fm, alines, blines, chunk, newfixups)
354 self._showchanges(fm, alines, blines, chunk, newfixups)
354
355
355 def apply(self):
356 def apply(self):
356 """apply self.fixups. update self.linelog, self.finalcontents.
357 """apply self.fixups. update self.linelog, self.finalcontents.
357
358
358 call this only once, before getfinalcontent(), after diffwith().
359 call this only once, before getfinalcontent(), after diffwith().
359 """
360 """
360 # the following is unnecessary, as it's done by "diffwith":
361 # the following is unnecessary, as it's done by "diffwith":
361 # self.linelog.annotate(self.linelog.maxrev)
362 # self.linelog.annotate(self.linelog.maxrev)
362 for rev, a1, a2, b1, b2 in reversed(self.fixups):
363 for rev, a1, a2, b1, b2 in reversed(self.fixups):
363 blines = self.targetlines[b1:b2]
364 blines = self.targetlines[b1:b2]
364 if self.ui.debugflag:
365 if self.ui.debugflag:
365 idx = (max(rev - 1, 0)) // 2
366 idx = (max(rev - 1, 0)) // 2
366 self.ui.write(
367 self.ui.write(
367 _(b'%s: chunk %d:%d -> %d lines\n')
368 _(b'%s: chunk %d:%d -> %d lines\n')
368 % (node.short(self.fctxs[idx].node()), a1, a2, len(blines))
369 % (node.short(self.fctxs[idx].node()), a1, a2, len(blines))
369 )
370 )
370 self.linelog.replacelines(rev, a1, a2, b1, b2)
371 self.linelog.replacelines(rev, a1, a2, b1, b2)
371 if self.opts.get(b'edit_lines', False):
372 if self.opts.get(b'edit_lines', False):
372 self.finalcontents = self._checkoutlinelogwithedits()
373 self.finalcontents = self._checkoutlinelogwithedits()
373 else:
374 else:
374 self.finalcontents = self._checkoutlinelog()
375 self.finalcontents = self._checkoutlinelog()
375
376
376 def getfinalcontent(self, fctx):
377 def getfinalcontent(self, fctx):
377 """(fctx) -> str. get modified file content for a given filecontext"""
378 """(fctx) -> str. get modified file content for a given filecontext"""
378 idx = self.fctxs.index(fctx)
379 idx = self.fctxs.index(fctx)
379 return self.finalcontents[idx]
380 return self.finalcontents[idx]
380
381
381 def _analysediffchunk(self, chunk, annotated):
382 def _analysediffchunk(self, chunk, annotated):
382 """analyse a different chunk and return new fixups found
383 """analyse a different chunk and return new fixups found
383
384
384 return [] if no lines from the chunk can be safely applied.
385 return [] if no lines from the chunk can be safely applied.
385
386
386 the chunk (or lines) cannot be safely applied, if, for example:
387 the chunk (or lines) cannot be safely applied, if, for example:
387 - the modified (deleted) lines belong to a public changeset
388 - the modified (deleted) lines belong to a public changeset
388 (self.fctxs[0])
389 (self.fctxs[0])
389 - the chunk is a pure insertion and the adjacent lines (at most 2
390 - the chunk is a pure insertion and the adjacent lines (at most 2
390 lines) belong to different non-public changesets, or do not belong
391 lines) belong to different non-public changesets, or do not belong
391 to any non-public changesets.
392 to any non-public changesets.
392 - the chunk is modifying lines from different changesets.
393 - the chunk is modifying lines from different changesets.
393 in this case, if the number of lines deleted equals to the number
394 in this case, if the number of lines deleted equals to the number
394 of lines added, assume it's a simple 1:1 map (could be wrong).
395 of lines added, assume it's a simple 1:1 map (could be wrong).
395 otherwise, give up.
396 otherwise, give up.
396 - the chunk is modifying lines from a single non-public changeset,
397 - the chunk is modifying lines from a single non-public changeset,
397 but other revisions touch the area as well. i.e. the lines are
398 but other revisions touch the area as well. i.e. the lines are
398 not continuous as seen from the linelog.
399 not continuous as seen from the linelog.
399 """
400 """
400 a1, a2, b1, b2 = chunk
401 a1, a2, b1, b2 = chunk
401 # find involved indexes from annotate result
402 # find involved indexes from annotate result
402 involved = annotated[a1:a2]
403 involved = annotated[a1:a2]
403 if not involved and annotated: # a1 == a2 and a is not empty
404 if not involved and annotated: # a1 == a2 and a is not empty
404 # pure insertion, check nearby lines. ignore lines belong
405 # pure insertion, check nearby lines. ignore lines belong
405 # to the public (first) changeset (i.e. annotated[i][0] == 1)
406 # to the public (first) changeset (i.e. annotated[i][0] == 1)
406 nearbylinenums = {a2, max(0, a1 - 1)}
407 nearbylinenums = {a2, max(0, a1 - 1)}
407 involved = [
408 involved = [
408 annotated[i] for i in nearbylinenums if annotated[i][0] != 1
409 annotated[i] for i in nearbylinenums if annotated[i][0] != 1
409 ]
410 ]
410 involvedrevs = list({r for r, l in involved})
411 involvedrevs = list({r for r, l in involved})
411 newfixups = []
412 newfixups = []
412 if len(involvedrevs) == 1 and self._iscontinuous(a1, a2 - 1, True):
413 if len(involvedrevs) == 1 and self._iscontinuous(a1, a2 - 1, True):
413 # chunk belongs to a single revision
414 # chunk belongs to a single revision
414 rev = involvedrevs[0]
415 rev = involvedrevs[0]
415 if rev > 1:
416 if rev > 1:
416 fixuprev = rev + 1
417 fixuprev = rev + 1
417 newfixups.append((fixuprev, a1, a2, b1, b2))
418 newfixups.append((fixuprev, a1, a2, b1, b2))
418 elif a2 - a1 == b2 - b1 or b1 == b2:
419 elif a2 - a1 == b2 - b1 or b1 == b2:
419 # 1:1 line mapping, or chunk was deleted
420 # 1:1 line mapping, or chunk was deleted
420 for i in pycompat.xrange(a1, a2):
421 for i in pycompat.xrange(a1, a2):
421 rev, linenum = annotated[i]
422 rev, linenum = annotated[i]
422 if rev > 1:
423 if rev > 1:
423 if b1 == b2: # deletion, simply remove that single line
424 if b1 == b2: # deletion, simply remove that single line
424 nb1 = nb2 = 0
425 nb1 = nb2 = 0
425 else: # 1:1 line mapping, change the corresponding rev
426 else: # 1:1 line mapping, change the corresponding rev
426 nb1 = b1 + i - a1
427 nb1 = b1 + i - a1
427 nb2 = nb1 + 1
428 nb2 = nb1 + 1
428 fixuprev = rev + 1
429 fixuprev = rev + 1
429 newfixups.append((fixuprev, i, i + 1, nb1, nb2))
430 newfixups.append((fixuprev, i, i + 1, nb1, nb2))
430 return self._optimizefixups(newfixups)
431 return self._optimizefixups(newfixups)
431
432
432 @staticmethod
433 @staticmethod
433 def _alldiffchunks(a, b, alines, blines):
434 def _alldiffchunks(a, b, alines, blines):
434 """like mdiff.allblocks, but only care about differences"""
435 """like mdiff.allblocks, but only care about differences"""
435 blocks = mdiff.allblocks(a, b, lines1=alines, lines2=blines)
436 blocks = mdiff.allblocks(a, b, lines1=alines, lines2=blines)
436 for chunk, btype in blocks:
437 for chunk, btype in blocks:
437 if btype != b'!':
438 if btype != b'!':
438 continue
439 continue
439 yield chunk
440 yield chunk
440
441
441 def _buildlinelog(self):
442 def _buildlinelog(self):
442 """calculate the initial linelog based on self.content{,line}s.
443 """calculate the initial linelog based on self.content{,line}s.
443 this is similar to running a partial "annotate".
444 this is similar to running a partial "annotate".
444 """
445 """
445 llog = linelog.linelog()
446 llog = linelog.linelog()
446 a, alines = b'', []
447 a, alines = b'', []
447 for i in pycompat.xrange(len(self.contents)):
448 for i in pycompat.xrange(len(self.contents)):
448 b, blines = self.contents[i], self.contentlines[i]
449 b, blines = self.contents[i], self.contentlines[i]
449 llrev = i * 2 + 1
450 llrev = i * 2 + 1
450 chunks = self._alldiffchunks(a, b, alines, blines)
451 chunks = self._alldiffchunks(a, b, alines, blines)
451 for a1, a2, b1, b2 in reversed(list(chunks)):
452 for a1, a2, b1, b2 in reversed(list(chunks)):
452 llog.replacelines(llrev, a1, a2, b1, b2)
453 llog.replacelines(llrev, a1, a2, b1, b2)
453 a, alines = b, blines
454 a, alines = b, blines
454 return llog
455 return llog
455
456
456 def _checkoutlinelog(self):
457 def _checkoutlinelog(self):
457 """() -> [str]. check out file contents from linelog"""
458 """() -> [str]. check out file contents from linelog"""
458 contents = []
459 contents = []
459 for i in pycompat.xrange(len(self.contents)):
460 for i in pycompat.xrange(len(self.contents)):
460 rev = (i + 1) * 2
461 rev = (i + 1) * 2
461 self.linelog.annotate(rev)
462 self.linelog.annotate(rev)
462 content = b''.join(map(self._getline, self.linelog.annotateresult))
463 content = b''.join(map(self._getline, self.linelog.annotateresult))
463 contents.append(content)
464 contents.append(content)
464 return contents
465 return contents
465
466
466 def _checkoutlinelogwithedits(self):
467 def _checkoutlinelogwithedits(self):
467 """() -> [str]. prompt all lines for edit"""
468 """() -> [str]. prompt all lines for edit"""
468 alllines = self.linelog.getalllines()
469 alllines = self.linelog.getalllines()
469 # header
470 # header
470 editortext = (
471 editortext = (
471 _(
472 _(
472 b'HG: editing %s\nHG: "y" means the line to the right '
473 b'HG: editing %s\nHG: "y" means the line to the right '
473 b'exists in the changeset to the top\nHG:\n'
474 b'exists in the changeset to the top\nHG:\n'
474 )
475 )
475 % self.fctxs[-1].path()
476 % self.fctxs[-1].path()
476 )
477 )
477 # [(idx, fctx)]. hide the dummy emptyfilecontext
478 # [(idx, fctx)]. hide the dummy emptyfilecontext
478 visiblefctxs = [
479 visiblefctxs = [
479 (i, f)
480 (i, f)
480 for i, f in enumerate(self.fctxs)
481 for i, f in enumerate(self.fctxs)
481 if not isinstance(f, emptyfilecontext)
482 if not isinstance(f, emptyfilecontext)
482 ]
483 ]
483 for i, (j, f) in enumerate(visiblefctxs):
484 for i, (j, f) in enumerate(visiblefctxs):
484 editortext += _(b'HG: %s/%s %s %s\n') % (
485 editortext += _(b'HG: %s/%s %s %s\n') % (
485 b'|' * i,
486 b'|' * i,
486 b'-' * (len(visiblefctxs) - i + 1),
487 b'-' * (len(visiblefctxs) - i + 1),
487 node.short(f.node()),
488 node.short(f.node()),
488 f.description().split(b'\n', 1)[0],
489 f.description().split(b'\n', 1)[0],
489 )
490 )
490 editortext += _(b'HG: %s\n') % (b'|' * len(visiblefctxs))
491 editortext += _(b'HG: %s\n') % (b'|' * len(visiblefctxs))
491 # figure out the lifetime of a line, this is relatively inefficient,
492 # figure out the lifetime of a line, this is relatively inefficient,
492 # but probably fine
493 # but probably fine
493 lineset = defaultdict(lambda: set()) # {(llrev, linenum): {llrev}}
494 lineset = defaultdict(lambda: set()) # {(llrev, linenum): {llrev}}
494 for i, f in visiblefctxs:
495 for i, f in visiblefctxs:
495 self.linelog.annotate((i + 1) * 2)
496 self.linelog.annotate((i + 1) * 2)
496 for l in self.linelog.annotateresult:
497 for l in self.linelog.annotateresult:
497 lineset[l].add(i)
498 lineset[l].add(i)
498 # append lines
499 # append lines
499 for l in alllines:
500 for l in alllines:
500 editortext += b' %s : %s' % (
501 editortext += b' %s : %s' % (
501 b''.join(
502 b''.join(
502 [
503 [
503 (b'y' if i in lineset[l] else b' ')
504 (b'y' if i in lineset[l] else b' ')
504 for i, _f in visiblefctxs
505 for i, _f in visiblefctxs
505 ]
506 ]
506 ),
507 ),
507 self._getline(l),
508 self._getline(l),
508 )
509 )
509 # run editor
510 # run editor
510 editedtext = self.ui.edit(editortext, b'', action=b'absorb')
511 editedtext = self.ui.edit(editortext, b'', action=b'absorb')
511 if not editedtext:
512 if not editedtext:
512 raise error.Abort(_(b'empty editor text'))
513 raise error.Abort(_(b'empty editor text'))
513 # parse edited result
514 # parse edited result
514 contents = [b''] * len(self.fctxs)
515 contents = [b''] * len(self.fctxs)
515 leftpadpos = 4
516 leftpadpos = 4
516 colonpos = leftpadpos + len(visiblefctxs) + 1
517 colonpos = leftpadpos + len(visiblefctxs) + 1
517 for l in mdiff.splitnewlines(editedtext):
518 for l in mdiff.splitnewlines(editedtext):
518 if l.startswith(b'HG:'):
519 if l.startswith(b'HG:'):
519 continue
520 continue
520 if l[colonpos - 1 : colonpos + 2] != b' : ':
521 if l[colonpos - 1 : colonpos + 2] != b' : ':
521 raise error.Abort(_(b'malformed line: %s') % l)
522 raise error.Abort(_(b'malformed line: %s') % l)
522 linecontent = l[colonpos + 2 :]
523 linecontent = l[colonpos + 2 :]
523 for i, ch in enumerate(
524 for i, ch in enumerate(
524 pycompat.bytestr(l[leftpadpos : colonpos - 1])
525 pycompat.bytestr(l[leftpadpos : colonpos - 1])
525 ):
526 ):
526 if ch == b'y':
527 if ch == b'y':
527 contents[visiblefctxs[i][0]] += linecontent
528 contents[visiblefctxs[i][0]] += linecontent
528 # chunkstats is hard to calculate if anything changes, therefore
529 # chunkstats is hard to calculate if anything changes, therefore
529 # set them to just a simple value (1, 1).
530 # set them to just a simple value (1, 1).
530 if editedtext != editortext:
531 if editedtext != editortext:
531 self.chunkstats = [1, 1]
532 self.chunkstats = [1, 1]
532 return contents
533 return contents
533
534
534 def _getline(self, lineinfo):
535 def _getline(self, lineinfo):
535 """((rev, linenum)) -> str. convert rev+line number to line content"""
536 """((rev, linenum)) -> str. convert rev+line number to line content"""
536 rev, linenum = lineinfo
537 rev, linenum = lineinfo
537 if rev & 1: # odd: original line taken from fctxs
538 if rev & 1: # odd: original line taken from fctxs
538 return self.contentlines[rev // 2][linenum]
539 return self.contentlines[rev // 2][linenum]
539 else: # even: fixup line from targetfctx
540 else: # even: fixup line from targetfctx
540 return self.targetlines[linenum]
541 return self.targetlines[linenum]
541
542
542 def _iscontinuous(self, a1, a2, closedinterval=False):
543 def _iscontinuous(self, a1, a2, closedinterval=False):
543 """(a1, a2 : int) -> bool
544 """(a1, a2 : int) -> bool
544
545
545 check if these lines are continuous. i.e. no other insertions or
546 check if these lines are continuous. i.e. no other insertions or
546 deletions (from other revisions) among these lines.
547 deletions (from other revisions) among these lines.
547
548
548 closedinterval decides whether a2 should be included or not. i.e. is
549 closedinterval decides whether a2 should be included or not. i.e. is
549 it [a1, a2), or [a1, a2] ?
550 it [a1, a2), or [a1, a2] ?
550 """
551 """
551 if a1 >= a2:
552 if a1 >= a2:
552 return True
553 return True
553 llog = self.linelog
554 llog = self.linelog
554 offset1 = llog.getoffset(a1)
555 offset1 = llog.getoffset(a1)
555 offset2 = llog.getoffset(a2) + int(closedinterval)
556 offset2 = llog.getoffset(a2) + int(closedinterval)
556 linesinbetween = llog.getalllines(offset1, offset2)
557 linesinbetween = llog.getalllines(offset1, offset2)
557 return len(linesinbetween) == a2 - a1 + int(closedinterval)
558 return len(linesinbetween) == a2 - a1 + int(closedinterval)
558
559
559 def _optimizefixups(self, fixups):
560 def _optimizefixups(self, fixups):
560 """[(rev, a1, a2, b1, b2)] -> [(rev, a1, a2, b1, b2)].
561 """[(rev, a1, a2, b1, b2)] -> [(rev, a1, a2, b1, b2)].
561 merge adjacent fixups to make them less fragmented.
562 merge adjacent fixups to make them less fragmented.
562 """
563 """
563 result = []
564 result = []
564 pcurrentchunk = [[-1, -1, -1, -1, -1]]
565 pcurrentchunk = [[-1, -1, -1, -1, -1]]
565
566
566 def pushchunk():
567 def pushchunk():
567 if pcurrentchunk[0][0] != -1:
568 if pcurrentchunk[0][0] != -1:
568 result.append(tuple(pcurrentchunk[0]))
569 result.append(tuple(pcurrentchunk[0]))
569
570
570 for i, chunk in enumerate(fixups):
571 for i, chunk in enumerate(fixups):
571 rev, a1, a2, b1, b2 = chunk
572 rev, a1, a2, b1, b2 = chunk
572 lastrev = pcurrentchunk[0][0]
573 lastrev = pcurrentchunk[0][0]
573 lasta2 = pcurrentchunk[0][2]
574 lasta2 = pcurrentchunk[0][2]
574 lastb2 = pcurrentchunk[0][4]
575 lastb2 = pcurrentchunk[0][4]
575 if (
576 if (
576 a1 == lasta2
577 a1 == lasta2
577 and b1 == lastb2
578 and b1 == lastb2
578 and rev == lastrev
579 and rev == lastrev
579 and self._iscontinuous(max(a1 - 1, 0), a1)
580 and self._iscontinuous(max(a1 - 1, 0), a1)
580 ):
581 ):
581 # merge into currentchunk
582 # merge into currentchunk
582 pcurrentchunk[0][2] = a2
583 pcurrentchunk[0][2] = a2
583 pcurrentchunk[0][4] = b2
584 pcurrentchunk[0][4] = b2
584 else:
585 else:
585 pushchunk()
586 pushchunk()
586 pcurrentchunk[0] = list(chunk)
587 pcurrentchunk[0] = list(chunk)
587 pushchunk()
588 pushchunk()
588 return result
589 return result
589
590
590 def _showchanges(self, fm, alines, blines, chunk, fixups):
591 def _showchanges(self, fm, alines, blines, chunk, fixups):
591 def trim(line):
592 def trim(line):
592 if line.endswith(b'\n'):
593 if line.endswith(b'\n'):
593 line = line[:-1]
594 line = line[:-1]
594 return line
595 return line
595
596
596 # this is not optimized for perf but _showchanges only gets executed
597 # this is not optimized for perf but _showchanges only gets executed
597 # with an extra command-line flag.
598 # with an extra command-line flag.
598 a1, a2, b1, b2 = chunk
599 a1, a2, b1, b2 = chunk
599 aidxs, bidxs = [0] * (a2 - a1), [0] * (b2 - b1)
600 aidxs, bidxs = [0] * (a2 - a1), [0] * (b2 - b1)
600 for idx, fa1, fa2, fb1, fb2 in fixups:
601 for idx, fa1, fa2, fb1, fb2 in fixups:
601 for i in pycompat.xrange(fa1, fa2):
602 for i in pycompat.xrange(fa1, fa2):
602 aidxs[i - a1] = (max(idx, 1) - 1) // 2
603 aidxs[i - a1] = (max(idx, 1) - 1) // 2
603 for i in pycompat.xrange(fb1, fb2):
604 for i in pycompat.xrange(fb1, fb2):
604 bidxs[i - b1] = (max(idx, 1) - 1) // 2
605 bidxs[i - b1] = (max(idx, 1) - 1) // 2
605
606
606 fm.startitem()
607 fm.startitem()
607 fm.write(
608 fm.write(
608 b'hunk',
609 b'hunk',
609 b' %s\n',
610 b' %s\n',
610 b'@@ -%d,%d +%d,%d @@' % (a1, a2 - a1, b1, b2 - b1),
611 b'@@ -%d,%d +%d,%d @@' % (a1, a2 - a1, b1, b2 - b1),
611 label=b'diff.hunk',
612 label=b'diff.hunk',
612 )
613 )
613 fm.data(path=self.path, linetype=b'hunk')
614 fm.data(path=self.path, linetype=b'hunk')
614
615
615 def writeline(idx, diffchar, line, linetype, linelabel):
616 def writeline(idx, diffchar, line, linetype, linelabel):
616 fm.startitem()
617 fm.startitem()
617 node = b''
618 node = b''
618 if idx:
619 if idx:
619 ctx = self.fctxs[idx]
620 ctx = self.fctxs[idx]
620 fm.context(fctx=ctx)
621 fm.context(fctx=ctx)
621 node = ctx.hex()
622 node = ctx.hex()
622 self.ctxaffected.add(ctx.changectx())
623 self.ctxaffected.add(ctx.changectx())
623 fm.write(b'node', b'%-7.7s ', node, label=b'absorb.node')
624 fm.write(b'node', b'%-7.7s ', node, label=b'absorb.node')
624 fm.write(
625 fm.write(
625 b'diffchar ' + linetype,
626 b'diffchar ' + linetype,
626 b'%s%s\n',
627 b'%s%s\n',
627 diffchar,
628 diffchar,
628 line,
629 line,
629 label=linelabel,
630 label=linelabel,
630 )
631 )
631 fm.data(path=self.path, linetype=linetype)
632 fm.data(path=self.path, linetype=linetype)
632
633
633 for i in pycompat.xrange(a1, a2):
634 for i in pycompat.xrange(a1, a2):
634 writeline(
635 writeline(
635 aidxs[i - a1],
636 aidxs[i - a1],
636 b'-',
637 b'-',
637 trim(alines[i]),
638 trim(alines[i]),
638 b'deleted',
639 b'deleted',
639 b'diff.deleted',
640 b'diff.deleted',
640 )
641 )
641 for i in pycompat.xrange(b1, b2):
642 for i in pycompat.xrange(b1, b2):
642 writeline(
643 writeline(
643 bidxs[i - b1],
644 bidxs[i - b1],
644 b'+',
645 b'+',
645 trim(blines[i]),
646 trim(blines[i]),
646 b'inserted',
647 b'inserted',
647 b'diff.inserted',
648 b'diff.inserted',
648 )
649 )
649
650
650
651
651 class fixupstate(object):
652 class fixupstate(object):
652 """state needed to run absorb
653 """state needed to run absorb
653
654
654 internally, it keeps paths and filefixupstates.
655 internally, it keeps paths and filefixupstates.
655
656
656 a typical use is like filefixupstates:
657 a typical use is like filefixupstates:
657
658
658 1. call diffwith, to calculate fixups
659 1. call diffwith, to calculate fixups
659 2. (optionally), present fixups to the user, or edit fixups
660 2. (optionally), present fixups to the user, or edit fixups
660 3. call apply, to apply changes to memory
661 3. call apply, to apply changes to memory
661 4. call commit, to commit changes to hg database
662 4. call commit, to commit changes to hg database
662 """
663 """
663
664
664 def __init__(self, stack, ui=None, opts=None):
665 def __init__(self, stack, ui=None, opts=None):
665 """([ctx], ui or None) -> None
666 """([ctx], ui or None) -> None
666
667
667 stack: should be linear, and sorted by topo order - oldest first.
668 stack: should be linear, and sorted by topo order - oldest first.
668 all commits in stack are considered mutable.
669 all commits in stack are considered mutable.
669 """
670 """
670 assert stack
671 assert stack
671 self.ui = ui or nullui()
672 self.ui = ui or nullui()
672 self.opts = opts or {}
673 self.opts = opts or {}
673 self.stack = stack
674 self.stack = stack
674 self.repo = stack[-1].repo().unfiltered()
675 self.repo = stack[-1].repo().unfiltered()
675
676
676 # following fields will be filled later
677 # following fields will be filled later
677 self.paths = [] # [str]
678 self.paths = [] # [str]
678 self.status = None # ctx.status output
679 self.status = None # ctx.status output
679 self.fctxmap = {} # {path: {ctx: fctx}}
680 self.fctxmap = {} # {path: {ctx: fctx}}
680 self.fixupmap = {} # {path: filefixupstate}
681 self.fixupmap = {} # {path: filefixupstate}
681 self.replacemap = {} # {oldnode: newnode or None}
682 self.replacemap = {} # {oldnode: newnode or None}
682 self.finalnode = None # head after all fixups
683 self.finalnode = None # head after all fixups
683 self.ctxaffected = set() # ctx that will be absorbed into
684 self.ctxaffected = set() # ctx that will be absorbed into
684
685
685 def diffwith(self, targetctx, match=None, fm=None):
686 def diffwith(self, targetctx, match=None, fm=None):
686 """diff and prepare fixups. update self.fixupmap, self.paths"""
687 """diff and prepare fixups. update self.fixupmap, self.paths"""
687 # only care about modified files
688 # only care about modified files
688 self.status = self.stack[-1].status(targetctx, match)
689 self.status = self.stack[-1].status(targetctx, match)
689 self.paths = []
690 self.paths = []
690 # but if --edit-lines is used, the user may want to edit files
691 # but if --edit-lines is used, the user may want to edit files
691 # even if they are not modified
692 # even if they are not modified
692 editopt = self.opts.get(b'edit_lines')
693 editopt = self.opts.get(b'edit_lines')
693 if not self.status.modified and editopt and match:
694 if not self.status.modified and editopt and match:
694 interestingpaths = match.files()
695 interestingpaths = match.files()
695 else:
696 else:
696 interestingpaths = self.status.modified
697 interestingpaths = self.status.modified
697 # prepare the filefixupstate
698 # prepare the filefixupstate
698 seenfctxs = set()
699 seenfctxs = set()
699 # sorting is necessary to eliminate ambiguity for the "double move"
700 # sorting is necessary to eliminate ambiguity for the "double move"
700 # case: "hg cp A B; hg cp A C; hg rm A", then only "B" can affect "A".
701 # case: "hg cp A B; hg cp A C; hg rm A", then only "B" can affect "A".
701 for path in sorted(interestingpaths):
702 for path in sorted(interestingpaths):
702 self.ui.debug(b'calculating fixups for %s\n' % path)
703 self.ui.debug(b'calculating fixups for %s\n' % path)
703 targetfctx = targetctx[path]
704 targetfctx = targetctx[path]
704 fctxs, ctx2fctx = getfilestack(self.stack, path, seenfctxs)
705 fctxs, ctx2fctx = getfilestack(self.stack, path, seenfctxs)
705 # ignore symbolic links or binary, or unchanged files
706 # ignore symbolic links or binary, or unchanged files
706 if any(
707 if any(
707 f.islink() or stringutil.binary(f.data())
708 f.islink() or stringutil.binary(f.data())
708 for f in [targetfctx] + fctxs
709 for f in [targetfctx] + fctxs
709 if not isinstance(f, emptyfilecontext)
710 if not isinstance(f, emptyfilecontext)
710 ):
711 ):
711 continue
712 continue
712 if targetfctx.data() == fctxs[-1].data() and not editopt:
713 if targetfctx.data() == fctxs[-1].data() and not editopt:
713 continue
714 continue
714 seenfctxs.update(fctxs[1:])
715 seenfctxs.update(fctxs[1:])
715 self.fctxmap[path] = ctx2fctx
716 self.fctxmap[path] = ctx2fctx
716 fstate = filefixupstate(fctxs, path, ui=self.ui, opts=self.opts)
717 fstate = filefixupstate(fctxs, path, ui=self.ui, opts=self.opts)
717 if fm is not None:
718 if fm is not None:
718 fm.startitem()
719 fm.startitem()
719 fm.plain(b'showing changes for ')
720 fm.plain(b'showing changes for ')
720 fm.write(b'path', b'%s\n', path, label=b'absorb.path')
721 fm.write(b'path', b'%s\n', path, label=b'absorb.path')
721 fm.data(linetype=b'path')
722 fm.data(linetype=b'path')
722 fstate.diffwith(targetfctx, fm)
723 fstate.diffwith(targetfctx, fm)
723 self.fixupmap[path] = fstate
724 self.fixupmap[path] = fstate
724 self.paths.append(path)
725 self.paths.append(path)
725 self.ctxaffected.update(fstate.ctxaffected)
726 self.ctxaffected.update(fstate.ctxaffected)
726
727
727 def apply(self):
728 def apply(self):
728 """apply fixups to individual filefixupstates"""
729 """apply fixups to individual filefixupstates"""
729 for path, state in pycompat.iteritems(self.fixupmap):
730 for path, state in pycompat.iteritems(self.fixupmap):
730 if self.ui.debugflag:
731 if self.ui.debugflag:
731 self.ui.write(_(b'applying fixups to %s\n') % path)
732 self.ui.write(_(b'applying fixups to %s\n') % path)
732 state.apply()
733 state.apply()
733
734
734 @property
735 @property
735 def chunkstats(self):
736 def chunkstats(self):
736 """-> {path: chunkstats}. collect chunkstats from filefixupstates"""
737 """-> {path: chunkstats}. collect chunkstats from filefixupstates"""
737 return {
738 return {
738 path: state.chunkstats
739 path: state.chunkstats
739 for path, state in pycompat.iteritems(self.fixupmap)
740 for path, state in pycompat.iteritems(self.fixupmap)
740 }
741 }
741
742
742 def commit(self):
743 def commit(self):
743 """commit changes. update self.finalnode, self.replacemap"""
744 """commit changes. update self.finalnode, self.replacemap"""
744 with self.repo.transaction(b'absorb') as tr:
745 with self.repo.transaction(b'absorb') as tr:
745 self._commitstack()
746 self._commitstack()
746 self._movebookmarks(tr)
747 self._movebookmarks(tr)
747 if self.repo[b'.'].node() in self.replacemap:
748 if self.repo[b'.'].node() in self.replacemap:
748 self._moveworkingdirectoryparent()
749 self._moveworkingdirectoryparent()
749 self._cleanupoldcommits()
750 self._cleanupoldcommits()
750 return self.finalnode
751 return self.finalnode
751
752
752 def printchunkstats(self):
753 def printchunkstats(self):
753 """print things like '1 of 2 chunk(s) applied'"""
754 """print things like '1 of 2 chunk(s) applied'"""
754 ui = self.ui
755 ui = self.ui
755 chunkstats = self.chunkstats
756 chunkstats = self.chunkstats
756 if ui.verbose:
757 if ui.verbose:
757 # chunkstats for each file
758 # chunkstats for each file
758 for path, stat in pycompat.iteritems(chunkstats):
759 for path, stat in pycompat.iteritems(chunkstats):
759 if stat[0]:
760 if stat[0]:
760 ui.write(
761 ui.write(
761 _(b'%s: %d of %d chunk(s) applied\n')
762 _(b'%s: %d of %d chunk(s) applied\n')
762 % (path, stat[0], stat[1])
763 % (path, stat[0], stat[1])
763 )
764 )
764 elif not ui.quiet:
765 elif not ui.quiet:
765 # a summary for all files
766 # a summary for all files
766 stats = chunkstats.values()
767 stats = chunkstats.values()
767 applied, total = (sum(s[i] for s in stats) for i in (0, 1))
768 applied, total = (sum(s[i] for s in stats) for i in (0, 1))
768 ui.write(_(b'%d of %d chunk(s) applied\n') % (applied, total))
769 ui.write(_(b'%d of %d chunk(s) applied\n') % (applied, total))
769
770
770 def _commitstack(self):
771 def _commitstack(self):
771 """make new commits. update self.finalnode, self.replacemap.
772 """make new commits. update self.finalnode, self.replacemap.
772 it is splitted from "commit" to avoid too much indentation.
773 it is splitted from "commit" to avoid too much indentation.
773 """
774 """
774 # last node (20-char) committed by us
775 # last node (20-char) committed by us
775 lastcommitted = None
776 lastcommitted = None
776 # p1 which overrides the parent of the next commit, "None" means use
777 # p1 which overrides the parent of the next commit, "None" means use
777 # the original parent unchanged
778 # the original parent unchanged
778 nextp1 = None
779 nextp1 = None
779 for ctx in self.stack:
780 for ctx in self.stack:
780 memworkingcopy = self._getnewfilecontents(ctx)
781 memworkingcopy = self._getnewfilecontents(ctx)
781 if not memworkingcopy and not lastcommitted:
782 if not memworkingcopy and not lastcommitted:
782 # nothing changed, nothing commited
783 # nothing changed, nothing commited
783 nextp1 = ctx
784 nextp1 = ctx
784 continue
785 continue
785 if ctx.files() and self._willbecomenoop(
786 if (
786 memworkingcopy, ctx, nextp1
787 self.skip_empty_successor
788 and ctx.files()
789 and self._willbecomenoop(memworkingcopy, ctx, nextp1)
787 ):
790 ):
788 # changeset is no longer necessary
791 # changeset is no longer necessary
789 self.replacemap[ctx.node()] = None
792 self.replacemap[ctx.node()] = None
790 msg = _(b'became empty and was dropped')
793 msg = _(b'became empty and was dropped')
791 else:
794 else:
792 # changeset needs re-commit
795 # changeset needs re-commit
793 nodestr = self._commitsingle(memworkingcopy, ctx, p1=nextp1)
796 nodestr = self._commitsingle(memworkingcopy, ctx, p1=nextp1)
794 lastcommitted = self.repo[nodestr]
797 lastcommitted = self.repo[nodestr]
795 nextp1 = lastcommitted
798 nextp1 = lastcommitted
796 self.replacemap[ctx.node()] = lastcommitted.node()
799 self.replacemap[ctx.node()] = lastcommitted.node()
797 if memworkingcopy:
800 if memworkingcopy:
798 msg = _(b'%d file(s) changed, became %s') % (
801 msg = _(b'%d file(s) changed, became %s') % (
799 len(memworkingcopy),
802 len(memworkingcopy),
800 self._ctx2str(lastcommitted),
803 self._ctx2str(lastcommitted),
801 )
804 )
802 else:
805 else:
803 msg = _(b'became %s') % self._ctx2str(lastcommitted)
806 msg = _(b'became %s') % self._ctx2str(lastcommitted)
804 if self.ui.verbose and msg:
807 if self.ui.verbose and msg:
805 self.ui.write(_(b'%s: %s\n') % (self._ctx2str(ctx), msg))
808 self.ui.write(_(b'%s: %s\n') % (self._ctx2str(ctx), msg))
806 self.finalnode = lastcommitted and lastcommitted.node()
809 self.finalnode = lastcommitted and lastcommitted.node()
807
810
808 def _ctx2str(self, ctx):
811 def _ctx2str(self, ctx):
809 if self.ui.debugflag:
812 if self.ui.debugflag:
810 return b'%d:%s' % (ctx.rev(), ctx.hex())
813 return b'%d:%s' % (ctx.rev(), ctx.hex())
811 else:
814 else:
812 return b'%d:%s' % (ctx.rev(), node.short(ctx.node()))
815 return b'%d:%s' % (ctx.rev(), node.short(ctx.node()))
813
816
814 def _getnewfilecontents(self, ctx):
817 def _getnewfilecontents(self, ctx):
815 """(ctx) -> {path: str}
818 """(ctx) -> {path: str}
816
819
817 fetch file contents from filefixupstates.
820 fetch file contents from filefixupstates.
818 return the working copy overrides - files different from ctx.
821 return the working copy overrides - files different from ctx.
819 """
822 """
820 result = {}
823 result = {}
821 for path in self.paths:
824 for path in self.paths:
822 ctx2fctx = self.fctxmap[path] # {ctx: fctx}
825 ctx2fctx = self.fctxmap[path] # {ctx: fctx}
823 if ctx not in ctx2fctx:
826 if ctx not in ctx2fctx:
824 continue
827 continue
825 fctx = ctx2fctx[ctx]
828 fctx = ctx2fctx[ctx]
826 content = fctx.data()
829 content = fctx.data()
827 newcontent = self.fixupmap[path].getfinalcontent(fctx)
830 newcontent = self.fixupmap[path].getfinalcontent(fctx)
828 if content != newcontent:
831 if content != newcontent:
829 result[fctx.path()] = newcontent
832 result[fctx.path()] = newcontent
830 return result
833 return result
831
834
832 def _movebookmarks(self, tr):
835 def _movebookmarks(self, tr):
833 repo = self.repo
836 repo = self.repo
834 needupdate = [
837 needupdate = [
835 (name, self.replacemap[hsh])
838 (name, self.replacemap[hsh])
836 for name, hsh in pycompat.iteritems(repo._bookmarks)
839 for name, hsh in pycompat.iteritems(repo._bookmarks)
837 if hsh in self.replacemap
840 if hsh in self.replacemap
838 ]
841 ]
839 changes = []
842 changes = []
840 for name, hsh in needupdate:
843 for name, hsh in needupdate:
841 if hsh:
844 if hsh:
842 changes.append((name, hsh))
845 changes.append((name, hsh))
843 if self.ui.verbose:
846 if self.ui.verbose:
844 self.ui.write(
847 self.ui.write(
845 _(b'moving bookmark %s to %s\n') % (name, node.hex(hsh))
848 _(b'moving bookmark %s to %s\n') % (name, node.hex(hsh))
846 )
849 )
847 else:
850 else:
848 changes.append((name, None))
851 changes.append((name, None))
849 if self.ui.verbose:
852 if self.ui.verbose:
850 self.ui.write(_(b'deleting bookmark %s\n') % name)
853 self.ui.write(_(b'deleting bookmark %s\n') % name)
851 repo._bookmarks.applychanges(repo, tr, changes)
854 repo._bookmarks.applychanges(repo, tr, changes)
852
855
853 def _moveworkingdirectoryparent(self):
856 def _moveworkingdirectoryparent(self):
854 if not self.finalnode:
857 if not self.finalnode:
855 # Find the latest not-{obsoleted,stripped} parent.
858 # Find the latest not-{obsoleted,stripped} parent.
856 revs = self.repo.revs(b'max(::. - %ln)', self.replacemap.keys())
859 revs = self.repo.revs(b'max(::. - %ln)', self.replacemap.keys())
857 ctx = self.repo[revs.first()]
860 ctx = self.repo[revs.first()]
858 self.finalnode = ctx.node()
861 self.finalnode = ctx.node()
859 else:
862 else:
860 ctx = self.repo[self.finalnode]
863 ctx = self.repo[self.finalnode]
861
864
862 dirstate = self.repo.dirstate
865 dirstate = self.repo.dirstate
863 # dirstate.rebuild invalidates fsmonitorstate, causing "hg status" to
866 # dirstate.rebuild invalidates fsmonitorstate, causing "hg status" to
864 # be slow. in absorb's case, no need to invalidate fsmonitorstate.
867 # be slow. in absorb's case, no need to invalidate fsmonitorstate.
865 noop = lambda: 0
868 noop = lambda: 0
866 restore = noop
869 restore = noop
867 if util.safehasattr(dirstate, '_fsmonitorstate'):
870 if util.safehasattr(dirstate, '_fsmonitorstate'):
868 bak = dirstate._fsmonitorstate.invalidate
871 bak = dirstate._fsmonitorstate.invalidate
869
872
870 def restore():
873 def restore():
871 dirstate._fsmonitorstate.invalidate = bak
874 dirstate._fsmonitorstate.invalidate = bak
872
875
873 dirstate._fsmonitorstate.invalidate = noop
876 dirstate._fsmonitorstate.invalidate = noop
874 try:
877 try:
875 with dirstate.parentchange():
878 with dirstate.parentchange():
876 dirstate.rebuild(ctx.node(), ctx.manifest(), self.paths)
879 dirstate.rebuild(ctx.node(), ctx.manifest(), self.paths)
877 finally:
880 finally:
878 restore()
881 restore()
879
882
880 @staticmethod
883 @staticmethod
881 def _willbecomenoop(memworkingcopy, ctx, pctx=None):
884 def _willbecomenoop(memworkingcopy, ctx, pctx=None):
882 """({path: content}, ctx, ctx) -> bool. test if a commit will be noop
885 """({path: content}, ctx, ctx) -> bool. test if a commit will be noop
883
886
884 if it will become an empty commit (does not change anything, after the
887 if it will become an empty commit (does not change anything, after the
885 memworkingcopy overrides), return True. otherwise return False.
888 memworkingcopy overrides), return True. otherwise return False.
886 """
889 """
887 if not pctx:
890 if not pctx:
888 parents = ctx.parents()
891 parents = ctx.parents()
889 if len(parents) != 1:
892 if len(parents) != 1:
890 return False
893 return False
891 pctx = parents[0]
894 pctx = parents[0]
892 if ctx.branch() != pctx.branch():
895 if ctx.branch() != pctx.branch():
893 return False
896 return False
894 if ctx.extra().get(b'close'):
897 if ctx.extra().get(b'close'):
895 return False
898 return False
896 # ctx changes more files (not a subset of memworkingcopy)
899 # ctx changes more files (not a subset of memworkingcopy)
897 if not set(ctx.files()).issubset(set(memworkingcopy)):
900 if not set(ctx.files()).issubset(set(memworkingcopy)):
898 return False
901 return False
899 for path, content in pycompat.iteritems(memworkingcopy):
902 for path, content in pycompat.iteritems(memworkingcopy):
900 if path not in pctx or path not in ctx:
903 if path not in pctx or path not in ctx:
901 return False
904 return False
902 fctx = ctx[path]
905 fctx = ctx[path]
903 pfctx = pctx[path]
906 pfctx = pctx[path]
904 if pfctx.flags() != fctx.flags():
907 if pfctx.flags() != fctx.flags():
905 return False
908 return False
906 if pfctx.data() != content:
909 if pfctx.data() != content:
907 return False
910 return False
908 return True
911 return True
909
912
910 def _commitsingle(self, memworkingcopy, ctx, p1=None):
913 def _commitsingle(self, memworkingcopy, ctx, p1=None):
911 """(ctx, {path: content}, node) -> node. make a single commit
914 """(ctx, {path: content}, node) -> node. make a single commit
912
915
913 the commit is a clone from ctx, with a (optionally) different p1, and
916 the commit is a clone from ctx, with a (optionally) different p1, and
914 different file contents replaced by memworkingcopy.
917 different file contents replaced by memworkingcopy.
915 """
918 """
916 parents = p1 and (p1, node.nullid)
919 parents = p1 and (p1, node.nullid)
917 extra = ctx.extra()
920 extra = ctx.extra()
918 if self._useobsolete and self.ui.configbool(b'absorb', b'add-noise'):
921 if self._useobsolete and self.ui.configbool(b'absorb', b'add-noise'):
919 extra[b'absorb_source'] = ctx.hex()
922 extra[b'absorb_source'] = ctx.hex()
920 mctx = overlaycontext(memworkingcopy, ctx, parents, extra=extra)
923 mctx = overlaycontext(memworkingcopy, ctx, parents, extra=extra)
921 return mctx.commit()
924 return mctx.commit()
922
925
923 @util.propertycache
926 @util.propertycache
924 def _useobsolete(self):
927 def _useobsolete(self):
925 """() -> bool"""
928 """() -> bool"""
926 return obsolete.isenabled(self.repo, obsolete.createmarkersopt)
929 return obsolete.isenabled(self.repo, obsolete.createmarkersopt)
927
930
928 def _cleanupoldcommits(self):
931 def _cleanupoldcommits(self):
929 replacements = {
932 replacements = {
930 k: ([v] if v is not None else [])
933 k: ([v] if v is not None else [])
931 for k, v in pycompat.iteritems(self.replacemap)
934 for k, v in pycompat.iteritems(self.replacemap)
932 }
935 }
933 if replacements:
936 if replacements:
934 scmutil.cleanupnodes(
937 scmutil.cleanupnodes(
935 self.repo, replacements, operation=b'absorb', fixphase=True
938 self.repo, replacements, operation=b'absorb', fixphase=True
936 )
939 )
937
940
941 @util.propertycache
942 def skip_empty_successor(self):
943 return rewriteutil.skip_empty_successor(self.ui, b'absorb')
944
938
945
939 def _parsechunk(hunk):
946 def _parsechunk(hunk):
940 """(crecord.uihunk or patch.recordhunk) -> (path, (a1, a2, [bline]))"""
947 """(crecord.uihunk or patch.recordhunk) -> (path, (a1, a2, [bline]))"""
941 if type(hunk) not in (crecord.uihunk, patch.recordhunk):
948 if type(hunk) not in (crecord.uihunk, patch.recordhunk):
942 return None, None
949 return None, None
943 path = hunk.header.filename()
950 path = hunk.header.filename()
944 a1 = hunk.fromline + len(hunk.before) - 1
951 a1 = hunk.fromline + len(hunk.before) - 1
945 # remove before and after context
952 # remove before and after context
946 hunk.before = hunk.after = []
953 hunk.before = hunk.after = []
947 buf = util.stringio()
954 buf = util.stringio()
948 hunk.write(buf)
955 hunk.write(buf)
949 patchlines = mdiff.splitnewlines(buf.getvalue())
956 patchlines = mdiff.splitnewlines(buf.getvalue())
950 # hunk.prettystr() will update hunk.removed
957 # hunk.prettystr() will update hunk.removed
951 a2 = a1 + hunk.removed
958 a2 = a1 + hunk.removed
952 blines = [l[1:] for l in patchlines[1:] if not l.startswith(b'-')]
959 blines = [l[1:] for l in patchlines[1:] if not l.startswith(b'-')]
953 return path, (a1, a2, blines)
960 return path, (a1, a2, blines)
954
961
955
962
956 def overlaydiffcontext(ctx, chunks):
963 def overlaydiffcontext(ctx, chunks):
957 """(ctx, [crecord.uihunk]) -> memctx
964 """(ctx, [crecord.uihunk]) -> memctx
958
965
959 return a memctx with some [1] patches (chunks) applied to ctx.
966 return a memctx with some [1] patches (chunks) applied to ctx.
960 [1]: modifications are handled. renames, mode changes, etc. are ignored.
967 [1]: modifications are handled. renames, mode changes, etc. are ignored.
961 """
968 """
962 # sadly the applying-patch logic is hardly reusable, and messy:
969 # sadly the applying-patch logic is hardly reusable, and messy:
963 # 1. the core logic "_applydiff" is too heavy - it writes .rej files, it
970 # 1. the core logic "_applydiff" is too heavy - it writes .rej files, it
964 # needs a file stream of a patch and will re-parse it, while we have
971 # needs a file stream of a patch and will re-parse it, while we have
965 # structured hunk objects at hand.
972 # structured hunk objects at hand.
966 # 2. a lot of different implementations about "chunk" (patch.hunk,
973 # 2. a lot of different implementations about "chunk" (patch.hunk,
967 # patch.recordhunk, crecord.uihunk)
974 # patch.recordhunk, crecord.uihunk)
968 # as we only care about applying changes to modified files, no mode
975 # as we only care about applying changes to modified files, no mode
969 # change, no binary diff, and no renames, it's probably okay to
976 # change, no binary diff, and no renames, it's probably okay to
970 # re-invent the logic using much simpler code here.
977 # re-invent the logic using much simpler code here.
971 memworkingcopy = {} # {path: content}
978 memworkingcopy = {} # {path: content}
972 patchmap = defaultdict(lambda: []) # {path: [(a1, a2, [bline])]}
979 patchmap = defaultdict(lambda: []) # {path: [(a1, a2, [bline])]}
973 for path, info in map(_parsechunk, chunks):
980 for path, info in map(_parsechunk, chunks):
974 if not path or not info:
981 if not path or not info:
975 continue
982 continue
976 patchmap[path].append(info)
983 patchmap[path].append(info)
977 for path, patches in pycompat.iteritems(patchmap):
984 for path, patches in pycompat.iteritems(patchmap):
978 if path not in ctx or not patches:
985 if path not in ctx or not patches:
979 continue
986 continue
980 patches.sort(reverse=True)
987 patches.sort(reverse=True)
981 lines = mdiff.splitnewlines(ctx[path].data())
988 lines = mdiff.splitnewlines(ctx[path].data())
982 for a1, a2, blines in patches:
989 for a1, a2, blines in patches:
983 lines[a1:a2] = blines
990 lines[a1:a2] = blines
984 memworkingcopy[path] = b''.join(lines)
991 memworkingcopy[path] = b''.join(lines)
985 return overlaycontext(memworkingcopy, ctx)
992 return overlaycontext(memworkingcopy, ctx)
986
993
987
994
988 def absorb(ui, repo, stack=None, targetctx=None, pats=None, opts=None):
995 def absorb(ui, repo, stack=None, targetctx=None, pats=None, opts=None):
989 """pick fixup chunks from targetctx, apply them to stack.
996 """pick fixup chunks from targetctx, apply them to stack.
990
997
991 if targetctx is None, the working copy context will be used.
998 if targetctx is None, the working copy context will be used.
992 if stack is None, the current draft stack will be used.
999 if stack is None, the current draft stack will be used.
993 return fixupstate.
1000 return fixupstate.
994 """
1001 """
995 if stack is None:
1002 if stack is None:
996 limit = ui.configint(b'absorb', b'max-stack-size')
1003 limit = ui.configint(b'absorb', b'max-stack-size')
997 headctx = repo[b'.']
1004 headctx = repo[b'.']
998 if len(headctx.parents()) > 1:
1005 if len(headctx.parents()) > 1:
999 raise error.Abort(_(b'cannot absorb into a merge'))
1006 raise error.Abort(_(b'cannot absorb into a merge'))
1000 stack = getdraftstack(headctx, limit)
1007 stack = getdraftstack(headctx, limit)
1001 if limit and len(stack) >= limit:
1008 if limit and len(stack) >= limit:
1002 ui.warn(
1009 ui.warn(
1003 _(
1010 _(
1004 b'absorb: only the recent %d changesets will '
1011 b'absorb: only the recent %d changesets will '
1005 b'be analysed\n'
1012 b'be analysed\n'
1006 )
1013 )
1007 % limit
1014 % limit
1008 )
1015 )
1009 if not stack:
1016 if not stack:
1010 raise error.Abort(_(b'no mutable changeset to change'))
1017 raise error.Abort(_(b'no mutable changeset to change'))
1011 if targetctx is None: # default to working copy
1018 if targetctx is None: # default to working copy
1012 targetctx = repo[None]
1019 targetctx = repo[None]
1013 if pats is None:
1020 if pats is None:
1014 pats = ()
1021 pats = ()
1015 if opts is None:
1022 if opts is None:
1016 opts = {}
1023 opts = {}
1017 state = fixupstate(stack, ui=ui, opts=opts)
1024 state = fixupstate(stack, ui=ui, opts=opts)
1018 matcher = scmutil.match(targetctx, pats, opts)
1025 matcher = scmutil.match(targetctx, pats, opts)
1019 if opts.get(b'interactive'):
1026 if opts.get(b'interactive'):
1020 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)
1027 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)
1021 origchunks = patch.parsepatch(diff)
1028 origchunks = patch.parsepatch(diff)
1022 chunks = cmdutil.recordfilter(ui, origchunks, matcher)[0]
1029 chunks = cmdutil.recordfilter(ui, origchunks, matcher)[0]
1023 targetctx = overlaydiffcontext(stack[-1], chunks)
1030 targetctx = overlaydiffcontext(stack[-1], chunks)
1024 fm = None
1031 fm = None
1025 if opts.get(b'print_changes') or not opts.get(b'apply_changes'):
1032 if opts.get(b'print_changes') or not opts.get(b'apply_changes'):
1026 fm = ui.formatter(b'absorb', opts)
1033 fm = ui.formatter(b'absorb', opts)
1027 state.diffwith(targetctx, matcher, fm)
1034 state.diffwith(targetctx, matcher, fm)
1028 if fm is not None:
1035 if fm is not None:
1029 fm.startitem()
1036 fm.startitem()
1030 fm.write(
1037 fm.write(
1031 b"count", b"\n%d changesets affected\n", len(state.ctxaffected)
1038 b"count", b"\n%d changesets affected\n", len(state.ctxaffected)
1032 )
1039 )
1033 fm.data(linetype=b'summary')
1040 fm.data(linetype=b'summary')
1034 for ctx in reversed(stack):
1041 for ctx in reversed(stack):
1035 if ctx not in state.ctxaffected:
1042 if ctx not in state.ctxaffected:
1036 continue
1043 continue
1037 fm.startitem()
1044 fm.startitem()
1038 fm.context(ctx=ctx)
1045 fm.context(ctx=ctx)
1039 fm.data(linetype=b'changeset')
1046 fm.data(linetype=b'changeset')
1040 fm.write(b'node', b'%-7.7s ', ctx.hex(), label=b'absorb.node')
1047 fm.write(b'node', b'%-7.7s ', ctx.hex(), label=b'absorb.node')
1041 descfirstline = ctx.description().splitlines()[0]
1048 descfirstline = ctx.description().splitlines()[0]
1042 fm.write(
1049 fm.write(
1043 b'descfirstline',
1050 b'descfirstline',
1044 b'%s\n',
1051 b'%s\n',
1045 descfirstline,
1052 descfirstline,
1046 label=b'absorb.description',
1053 label=b'absorb.description',
1047 )
1054 )
1048 fm.end()
1055 fm.end()
1049 if not opts.get(b'dry_run'):
1056 if not opts.get(b'dry_run'):
1050 if (
1057 if (
1051 not opts.get(b'apply_changes')
1058 not opts.get(b'apply_changes')
1052 and state.ctxaffected
1059 and state.ctxaffected
1053 and ui.promptchoice(
1060 and ui.promptchoice(
1054 b"apply changes (y/N)? $$ &Yes $$ &No", default=1
1061 b"apply changes (y/N)? $$ &Yes $$ &No", default=1
1055 )
1062 )
1056 ):
1063 ):
1057 raise error.Abort(_(b'absorb cancelled\n'))
1064 raise error.Abort(_(b'absorb cancelled\n'))
1058
1065
1059 state.apply()
1066 state.apply()
1060 if state.commit():
1067 if state.commit():
1061 state.printchunkstats()
1068 state.printchunkstats()
1062 elif not ui.quiet:
1069 elif not ui.quiet:
1063 ui.write(_(b'nothing applied\n'))
1070 ui.write(_(b'nothing applied\n'))
1064 return state
1071 return state
1065
1072
1066
1073
1067 @command(
1074 @command(
1068 b'absorb',
1075 b'absorb',
1069 [
1076 [
1070 (
1077 (
1071 b'a',
1078 b'a',
1072 b'apply-changes',
1079 b'apply-changes',
1073 None,
1080 None,
1074 _(b'apply changes without prompting for confirmation'),
1081 _(b'apply changes without prompting for confirmation'),
1075 ),
1082 ),
1076 (
1083 (
1077 b'p',
1084 b'p',
1078 b'print-changes',
1085 b'print-changes',
1079 None,
1086 None,
1080 _(b'always print which changesets are modified by which changes'),
1087 _(b'always print which changesets are modified by which changes'),
1081 ),
1088 ),
1082 (
1089 (
1083 b'i',
1090 b'i',
1084 b'interactive',
1091 b'interactive',
1085 None,
1092 None,
1086 _(b'interactively select which chunks to apply'),
1093 _(b'interactively select which chunks to apply'),
1087 ),
1094 ),
1088 (
1095 (
1089 b'e',
1096 b'e',
1090 b'edit-lines',
1097 b'edit-lines',
1091 None,
1098 None,
1092 _(
1099 _(
1093 b'edit what lines belong to which changesets before commit '
1100 b'edit what lines belong to which changesets before commit '
1094 b'(EXPERIMENTAL)'
1101 b'(EXPERIMENTAL)'
1095 ),
1102 ),
1096 ),
1103 ),
1097 ]
1104 ]
1098 + commands.dryrunopts
1105 + commands.dryrunopts
1099 + commands.templateopts
1106 + commands.templateopts
1100 + commands.walkopts,
1107 + commands.walkopts,
1101 _(b'hg absorb [OPTION] [FILE]...'),
1108 _(b'hg absorb [OPTION] [FILE]...'),
1102 helpcategory=command.CATEGORY_COMMITTING,
1109 helpcategory=command.CATEGORY_COMMITTING,
1103 helpbasic=True,
1110 helpbasic=True,
1104 )
1111 )
1105 def absorbcmd(ui, repo, *pats, **opts):
1112 def absorbcmd(ui, repo, *pats, **opts):
1106 """incorporate corrections into the stack of draft changesets
1113 """incorporate corrections into the stack of draft changesets
1107
1114
1108 absorb analyzes each change in your working directory and attempts to
1115 absorb analyzes each change in your working directory and attempts to
1109 amend the changed lines into the changesets in your stack that first
1116 amend the changed lines into the changesets in your stack that first
1110 introduced those lines.
1117 introduced those lines.
1111
1118
1112 If absorb cannot find an unambiguous changeset to amend for a change,
1119 If absorb cannot find an unambiguous changeset to amend for a change,
1113 that change will be left in the working directory, untouched. They can be
1120 that change will be left in the working directory, untouched. They can be
1114 observed by :hg:`status` or :hg:`diff` afterwards. In other words,
1121 observed by :hg:`status` or :hg:`diff` afterwards. In other words,
1115 absorb does not write to the working directory.
1122 absorb does not write to the working directory.
1116
1123
1117 Changesets outside the revset `::. and not public() and not merge()` will
1124 Changesets outside the revset `::. and not public() and not merge()` will
1118 not be changed.
1125 not be changed.
1119
1126
1120 Changesets that become empty after applying the changes will be deleted.
1127 Changesets that become empty after applying the changes will be deleted.
1121
1128
1122 By default, absorb will show what it plans to do and prompt for
1129 By default, absorb will show what it plans to do and prompt for
1123 confirmation. If you are confident that the changes will be absorbed
1130 confirmation. If you are confident that the changes will be absorbed
1124 to the correct place, run :hg:`absorb -a` to apply the changes
1131 to the correct place, run :hg:`absorb -a` to apply the changes
1125 immediately.
1132 immediately.
1126
1133
1127 Returns 0 on success, 1 if all chunks were ignored and nothing amended.
1134 Returns 0 on success, 1 if all chunks were ignored and nothing amended.
1128 """
1135 """
1129 opts = pycompat.byteskwargs(opts)
1136 opts = pycompat.byteskwargs(opts)
1130
1137
1131 with repo.wlock(), repo.lock():
1138 with repo.wlock(), repo.lock():
1132 if not opts[b'dry_run']:
1139 if not opts[b'dry_run']:
1133 cmdutil.checkunfinished(repo)
1140 cmdutil.checkunfinished(repo)
1134
1141
1135 state = absorb(ui, repo, pats=pats, opts=opts)
1142 state = absorb(ui, repo, pats=pats, opts=opts)
1136 if sum(s[0] for s in state.chunkstats.values()) == 0:
1143 if sum(s[0] for s in state.chunkstats.values()) == 0:
1137 return 1
1144 return 1
@@ -1,2907 +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, only the rebase command considers this configuration.
1899 Currently, only the rebase and absorb commands consider this configuration.
1900 (EXPERIMENTAL)
1900 (EXPERIMENTAL)
1901
1901
1902 ``storage``
1902 ``storage``
1903 -----------
1903 -----------
1904
1904
1905 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
1906 category impact performance and repository size.
1906 category impact performance and repository size.
1907
1907
1908 ``revlog.optimize-delta-parent-choice``
1908 ``revlog.optimize-delta-parent-choice``
1909 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
1910 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
1911 revlog compression. This option is enabled by default.
1911 revlog compression. This option is enabled by default.
1912
1912
1913 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
1914 repository with many merges.
1914 repository with many merges.
1915
1915
1916 ``revlog.reuse-external-delta-parent``
1916 ``revlog.reuse-external-delta-parent``
1917 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
1918 revisions from an external source.
1918 revisions from an external source.
1919 (typically: apply bundle from `hg pull` or `hg push`).
1919 (typically: apply bundle from `hg pull` or `hg push`).
1920
1920
1921 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
1922 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
1923 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
1924 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,
1925 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
1926 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
1927 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
1928 parents, choice, lack of sparse-revlog, etc).
1928 parents, choice, lack of sparse-revlog, etc).
1929
1929
1930 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
1931 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
1932 the cost of a small increase in CPU consumption.
1932 the cost of a small increase in CPU consumption.
1933
1933
1934 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
1935 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
1936 reused if the same delta parent is selected.
1936 reused if the same delta parent is selected.
1937
1937
1938 ``revlog.reuse-external-delta``
1938 ``revlog.reuse-external-delta``
1939 Control the reuse of delta from external source.
1939 Control the reuse of delta from external source.
1940 (typically: apply bundle from `hg pull` or `hg push`).
1940 (typically: apply bundle from `hg pull` or `hg push`).
1941
1941
1942 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
1943 default, Mercurial will not recompute the same delta again, trusting
1943 default, Mercurial will not recompute the same delta again, trusting
1944 externally provided deltas. There have been rare cases of small adjustment
1944 externally provided deltas. There have been rare cases of small adjustment
1945 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
1946 delta provided by ancient clients can provides better results. Disabling
1946 delta provided by ancient clients can provides better results. Disabling
1947 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
1948 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
1949 down.
1949 down.
1950
1950
1951 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
1952 related ``storage.revlog.reuse-external-delta-parent`` option.
1952 related ``storage.revlog.reuse-external-delta-parent`` option.
1953
1953
1954 ``revlog.zlib.level``
1954 ``revlog.zlib.level``
1955 Zlib compression level used when storing data into the repository. Accepted
1955 Zlib compression level used when storing data into the repository. Accepted
1956 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1956 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
1957 default value is 6.
1957 default value is 6.
1958
1958
1959
1959
1960 ``revlog.zstd.level``
1960 ``revlog.zstd.level``
1961 zstd compression level used when storing data into the repository. Accepted
1961 zstd compression level used when storing data into the repository. Accepted
1962 Value range from 1 (lowest compression) to 22 (highest compression).
1962 Value range from 1 (lowest compression) to 22 (highest compression).
1963 (default 3)
1963 (default 3)
1964
1964
1965 ``server``
1965 ``server``
1966 ----------
1966 ----------
1967
1967
1968 Controls generic server settings.
1968 Controls generic server settings.
1969
1969
1970 ``bookmarks-pushkey-compat``
1970 ``bookmarks-pushkey-compat``
1971 Trigger pushkey hook when being pushed bookmark updates. This config exist
1971 Trigger pushkey hook when being pushed bookmark updates. This config exist
1972 for compatibility purpose (default to True)
1972 for compatibility purpose (default to True)
1973
1973
1974 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1974 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1975 movement we recommend you migrate them to ``txnclose-bookmark`` and
1975 movement we recommend you migrate them to ``txnclose-bookmark`` and
1976 ``pretxnclose-bookmark``.
1976 ``pretxnclose-bookmark``.
1977
1977
1978 ``compressionengines``
1978 ``compressionengines``
1979 List of compression engines and their relative priority to advertise
1979 List of compression engines and their relative priority to advertise
1980 to clients.
1980 to clients.
1981
1981
1982 The order of compression engines determines their priority, the first
1982 The order of compression engines determines their priority, the first
1983 having the highest priority. If a compression engine is not listed
1983 having the highest priority. If a compression engine is not listed
1984 here, it won't be advertised to clients.
1984 here, it won't be advertised to clients.
1985
1985
1986 If not set (the default), built-in defaults are used. Run
1986 If not set (the default), built-in defaults are used. Run
1987 :hg:`debuginstall` to list available compression engines and their
1987 :hg:`debuginstall` to list available compression engines and their
1988 default wire protocol priority.
1988 default wire protocol priority.
1989
1989
1990 Older Mercurial clients only support zlib compression and this setting
1990 Older Mercurial clients only support zlib compression and this setting
1991 has no effect for legacy clients.
1991 has no effect for legacy clients.
1992
1992
1993 ``uncompressed``
1993 ``uncompressed``
1994 Whether to allow clients to clone a repository using the
1994 Whether to allow clients to clone a repository using the
1995 uncompressed streaming protocol. This transfers about 40% more
1995 uncompressed streaming protocol. This transfers about 40% more
1996 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
1997 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
1998 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
1999 regular clone. Over most WAN connections (anything slower than
1999 regular clone. Over most WAN connections (anything slower than
2000 about 6 Mbps), uncompressed streaming is slower, because of the
2000 about 6 Mbps), uncompressed streaming is slower, because of the
2001 extra data transfer overhead. This mode will also temporarily hold
2001 extra data transfer overhead. This mode will also temporarily hold
2002 the write lock while determining what data to transfer.
2002 the write lock while determining what data to transfer.
2003 (default: True)
2003 (default: True)
2004
2004
2005 ``uncompressedallowsecret``
2005 ``uncompressedallowsecret``
2006 Whether to allow stream clones when the repository contains secret
2006 Whether to allow stream clones when the repository contains secret
2007 changesets. (default: False)
2007 changesets. (default: False)
2008
2008
2009 ``preferuncompressed``
2009 ``preferuncompressed``
2010 When set, clients will try to use the uncompressed streaming
2010 When set, clients will try to use the uncompressed streaming
2011 protocol. (default: False)
2011 protocol. (default: False)
2012
2012
2013 ``disablefullbundle``
2013 ``disablefullbundle``
2014 When set, servers will refuse attempts to do pull-based clones.
2014 When set, servers will refuse attempts to do pull-based clones.
2015 If this option is set, ``preferuncompressed`` and/or clone bundles
2015 If this option is set, ``preferuncompressed`` and/or clone bundles
2016 are highly recommended. Partial clones will still be allowed.
2016 are highly recommended. Partial clones will still be allowed.
2017 (default: False)
2017 (default: False)
2018
2018
2019 ``streamunbundle``
2019 ``streamunbundle``
2020 When set, servers will apply data sent from the client directly,
2020 When set, servers will apply data sent from the client directly,
2021 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
2022 effectively prevents concurrent pushes.
2022 effectively prevents concurrent pushes.
2023
2023
2024 ``pullbundle``
2024 ``pullbundle``
2025 When set, the server will check pullbundle.manifest for bundles
2025 When set, the server will check pullbundle.manifest for bundles
2026 covering the requested heads and common nodes. The first matching
2026 covering the requested heads and common nodes. The first matching
2027 entry will be streamed to the client.
2027 entry will be streamed to the client.
2028
2028
2029 For HTTP transport, the stream will still use zlib compression
2029 For HTTP transport, the stream will still use zlib compression
2030 for older clients.
2030 for older clients.
2031
2031
2032 ``concurrent-push-mode``
2032 ``concurrent-push-mode``
2033 Level of allowed race condition between two pushing clients.
2033 Level of allowed race condition between two pushing clients.
2034
2034
2035 - 'strict': push is abort if another client touched the repository
2035 - 'strict': push is abort if another client touched the repository
2036 while the push was preparing.
2036 while the push was preparing.
2037 - '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
2038 affected while the push was preparing. (default since 5.4)
2038 affected while the push was preparing. (default since 5.4)
2039
2039
2040 'check-related' only takes effect for compatible clients (version
2040 'check-related' only takes effect for compatible clients (version
2041 4.3 and later). Older clients will use 'strict'.
2041 4.3 and later). Older clients will use 'strict'.
2042
2042
2043 ``validate``
2043 ``validate``
2044 Whether to validate the completeness of pushed changesets by
2044 Whether to validate the completeness of pushed changesets by
2045 checking that all new file revisions specified in manifests are
2045 checking that all new file revisions specified in manifests are
2046 present. (default: False)
2046 present. (default: False)
2047
2047
2048 ``maxhttpheaderlen``
2048 ``maxhttpheaderlen``
2049 Instruct HTTP clients not to send request headers longer than this
2049 Instruct HTTP clients not to send request headers longer than this
2050 many bytes. (default: 1024)
2050 many bytes. (default: 1024)
2051
2051
2052 ``bundle1``
2052 ``bundle1``
2053 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
2054 exchange format. (default: True)
2054 exchange format. (default: True)
2055
2055
2056 ``bundle1gd``
2056 ``bundle1gd``
2057 Like ``bundle1`` but only used if the repository is using the
2057 Like ``bundle1`` but only used if the repository is using the
2058 *generaldelta* storage format. (default: True)
2058 *generaldelta* storage format. (default: True)
2059
2059
2060 ``bundle1.push``
2060 ``bundle1.push``
2061 Whether to allow clients to push using the legacy bundle1 exchange
2061 Whether to allow clients to push using the legacy bundle1 exchange
2062 format. (default: True)
2062 format. (default: True)
2063
2063
2064 ``bundle1gd.push``
2064 ``bundle1gd.push``
2065 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
2066 *generaldelta* storage format. (default: True)
2066 *generaldelta* storage format. (default: True)
2067
2067
2068 ``bundle1.pull``
2068 ``bundle1.pull``
2069 Whether to allow clients to pull using the legacy bundle1 exchange
2069 Whether to allow clients to pull using the legacy bundle1 exchange
2070 format. (default: True)
2070 format. (default: True)
2071
2071
2072 ``bundle1gd.pull``
2072 ``bundle1gd.pull``
2073 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
2074 *generaldelta* storage format. (default: True)
2074 *generaldelta* storage format. (default: True)
2075
2075
2076 Large repositories using the *generaldelta* storage format should
2076 Large repositories using the *generaldelta* storage format should
2077 consider setting this option because converting *generaldelta*
2077 consider setting this option because converting *generaldelta*
2078 repositories to the exchange format required by the bundle1 data
2078 repositories to the exchange format required by the bundle1 data
2079 format can consume a lot of CPU.
2079 format can consume a lot of CPU.
2080
2080
2081 ``bundle2.stream``
2081 ``bundle2.stream``
2082 Whether to allow clients to pull using the bundle2 streaming protocol.
2082 Whether to allow clients to pull using the bundle2 streaming protocol.
2083 (default: True)
2083 (default: True)
2084
2084
2085 ``zliblevel``
2085 ``zliblevel``
2086 Integer between ``-1`` and ``9`` that controls the zlib compression level
2086 Integer between ``-1`` and ``9`` that controls the zlib compression level
2087 for wire protocol commands that send zlib compressed output (notably the
2087 for wire protocol commands that send zlib compressed output (notably the
2088 commands that send repository history data).
2088 commands that send repository history data).
2089
2089
2090 The default (``-1``) uses the default zlib compression level, which is
2090 The default (``-1``) uses the default zlib compression level, which is
2091 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2091 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2092 maximum compression.
2092 maximum compression.
2093
2093
2094 Setting this option allows server operators to make trade-offs between
2094 Setting this option allows server operators to make trade-offs between
2095 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2095 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2096 but sends more bytes to clients.
2096 but sends more bytes to clients.
2097
2097
2098 This option only impacts the HTTP server.
2098 This option only impacts the HTTP server.
2099
2099
2100 ``zstdlevel``
2100 ``zstdlevel``
2101 Integer between ``1`` and ``22`` that controls the zstd compression level
2101 Integer between ``1`` and ``22`` that controls the zstd compression level
2102 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
2103 ``22`` is the highest amount of compression.
2103 ``22`` is the highest amount of compression.
2104
2104
2105 The default (``3``) should be significantly faster than zlib while likely
2105 The default (``3``) should be significantly faster than zlib while likely
2106 delivering better compression ratios.
2106 delivering better compression ratios.
2107
2107
2108 This option only impacts the HTTP server.
2108 This option only impacts the HTTP server.
2109
2109
2110 See also ``server.zliblevel``.
2110 See also ``server.zliblevel``.
2111
2111
2112 ``view``
2112 ``view``
2113 Repository filter used when exchanging revisions with the peer.
2113 Repository filter used when exchanging revisions with the peer.
2114
2114
2115 The default view (``served``) excludes secret and hidden changesets.
2115 The default view (``served``) excludes secret and hidden changesets.
2116 Another useful value is ``immutable`` (no draft, secret or hidden
2116 Another useful value is ``immutable`` (no draft, secret or hidden
2117 changesets). (EXPERIMENTAL)
2117 changesets). (EXPERIMENTAL)
2118
2118
2119 ``smtp``
2119 ``smtp``
2120 --------
2120 --------
2121
2121
2122 Configuration for extensions that need to send email messages.
2122 Configuration for extensions that need to send email messages.
2123
2123
2124 ``host``
2124 ``host``
2125 Host name of mail server, e.g. "mail.example.com".
2125 Host name of mail server, e.g. "mail.example.com".
2126
2126
2127 ``port``
2127 ``port``
2128 Optional. Port to connect to on mail server. (default: 465 if
2128 Optional. Port to connect to on mail server. (default: 465 if
2129 ``tls`` is smtps; 25 otherwise)
2129 ``tls`` is smtps; 25 otherwise)
2130
2130
2131 ``tls``
2131 ``tls``
2132 Optional. Method to enable TLS when connecting to mail server: starttls,
2132 Optional. Method to enable TLS when connecting to mail server: starttls,
2133 smtps or none. (default: none)
2133 smtps or none. (default: none)
2134
2134
2135 ``username``
2135 ``username``
2136 Optional. User name for authenticating with the SMTP server.
2136 Optional. User name for authenticating with the SMTP server.
2137 (default: None)
2137 (default: None)
2138
2138
2139 ``password``
2139 ``password``
2140 Optional. Password for authenticating with the SMTP server. If not
2140 Optional. Password for authenticating with the SMTP server. If not
2141 specified, interactive sessions will prompt the user for a
2141 specified, interactive sessions will prompt the user for a
2142 password; non-interactive sessions will fail. (default: None)
2142 password; non-interactive sessions will fail. (default: None)
2143
2143
2144 ``local_hostname``
2144 ``local_hostname``
2145 Optional. The hostname that the sender can use to identify
2145 Optional. The hostname that the sender can use to identify
2146 itself to the MTA.
2146 itself to the MTA.
2147
2147
2148
2148
2149 ``subpaths``
2149 ``subpaths``
2150 ------------
2150 ------------
2151
2151
2152 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
2153 or becomes temporarily unavailable. This section lets you define
2153 or becomes temporarily unavailable. This section lets you define
2154 rewrite rules of the form::
2154 rewrite rules of the form::
2155
2155
2156 <pattern> = <replacement>
2156 <pattern> = <replacement>
2157
2157
2158 where ``pattern`` is a regular expression matching a subrepository
2158 where ``pattern`` is a regular expression matching a subrepository
2159 source URL and ``replacement`` is the replacement string used to
2159 source URL and ``replacement`` is the replacement string used to
2160 rewrite it. Groups can be matched in ``pattern`` and referenced in
2160 rewrite it. Groups can be matched in ``pattern`` and referenced in
2161 ``replacements``. For instance::
2161 ``replacements``. For instance::
2162
2162
2163 http://server/(.*)-hg/ = http://hg.server/\1/
2163 http://server/(.*)-hg/ = http://hg.server/\1/
2164
2164
2165 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2165 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2166
2166
2167 Relative subrepository paths are first made absolute, and the
2167 Relative subrepository paths are first made absolute, and the
2168 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``
2169 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
2170 relative path alone. The rules are applied in definition order.
2170 relative path alone. The rules are applied in definition order.
2171
2171
2172 ``subrepos``
2172 ``subrepos``
2173 ------------
2173 ------------
2174
2174
2175 This section contains options that control the behavior of the
2175 This section contains options that control the behavior of the
2176 subrepositories feature. See also :hg:`help subrepos`.
2176 subrepositories feature. See also :hg:`help subrepos`.
2177
2177
2178 Security note: auditing in Mercurial is known to be insufficient to
2178 Security note: auditing in Mercurial is known to be insufficient to
2179 prevent clone-time code execution with carefully constructed Git
2179 prevent clone-time code execution with carefully constructed Git
2180 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
2181 subrepos. Both Git and Subversion subrepos are disabled by default
2181 subrepos. Both Git and Subversion subrepos are disabled by default
2182 out of security concerns. These subrepo types can be enabled using
2182 out of security concerns. These subrepo types can be enabled using
2183 the respective options below.
2183 the respective options below.
2184
2184
2185 ``allowed``
2185 ``allowed``
2186 Whether subrepositories are allowed in the working directory.
2186 Whether subrepositories are allowed in the working directory.
2187
2187
2188 When false, commands involving subrepositories (like :hg:`update`)
2188 When false, commands involving subrepositories (like :hg:`update`)
2189 will fail for all subrepository types.
2189 will fail for all subrepository types.
2190 (default: true)
2190 (default: true)
2191
2191
2192 ``hg:allowed``
2192 ``hg:allowed``
2193 Whether Mercurial subrepositories are allowed in the working
2193 Whether Mercurial subrepositories are allowed in the working
2194 directory. This option only has an effect if ``subrepos.allowed``
2194 directory. This option only has an effect if ``subrepos.allowed``
2195 is true.
2195 is true.
2196 (default: true)
2196 (default: true)
2197
2197
2198 ``git:allowed``
2198 ``git:allowed``
2199 Whether Git subrepositories are allowed in the working directory.
2199 Whether Git subrepositories are allowed in the working directory.
2200 This option only has an effect if ``subrepos.allowed`` is true.
2200 This option only has an effect if ``subrepos.allowed`` is true.
2201
2201
2202 See the security note above before enabling Git subrepos.
2202 See the security note above before enabling Git subrepos.
2203 (default: false)
2203 (default: false)
2204
2204
2205 ``svn:allowed``
2205 ``svn:allowed``
2206 Whether Subversion subrepositories are allowed in the working
2206 Whether Subversion subrepositories are allowed in the working
2207 directory. This option only has an effect if ``subrepos.allowed``
2207 directory. This option only has an effect if ``subrepos.allowed``
2208 is true.
2208 is true.
2209
2209
2210 See the security note above before enabling Subversion subrepos.
2210 See the security note above before enabling Subversion subrepos.
2211 (default: false)
2211 (default: false)
2212
2212
2213 ``templatealias``
2213 ``templatealias``
2214 -----------------
2214 -----------------
2215
2215
2216 Alias definitions for templates. See :hg:`help templates` for details.
2216 Alias definitions for templates. See :hg:`help templates` for details.
2217
2217
2218 ``templates``
2218 ``templates``
2219 -------------
2219 -------------
2220
2220
2221 Use the ``[templates]`` section to define template strings.
2221 Use the ``[templates]`` section to define template strings.
2222 See :hg:`help templates` for details.
2222 See :hg:`help templates` for details.
2223
2223
2224 ``trusted``
2224 ``trusted``
2225 -----------
2225 -----------
2226
2226
2227 Mercurial will not use the settings in the
2227 Mercurial will not use the settings in the
2228 ``.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
2229 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
2230 commands to be run. This issue is often encountered when configuring
2230 commands to be run. This issue is often encountered when configuring
2231 hooks or extensions for shared repositories or servers. However,
2231 hooks or extensions for shared repositories or servers. However,
2232 the web interface will use some safe settings from the ``[web]``
2232 the web interface will use some safe settings from the ``[web]``
2233 section.
2233 section.
2234
2234
2235 This section specifies what users and groups are trusted. The
2235 This section specifies what users and groups are trusted. The
2236 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
2237 group with name ``*``. These settings must be placed in an
2237 group with name ``*``. These settings must be placed in an
2238 *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
2239 user or service running Mercurial.
2239 user or service running Mercurial.
2240
2240
2241 ``users``
2241 ``users``
2242 Comma-separated list of trusted users.
2242 Comma-separated list of trusted users.
2243
2243
2244 ``groups``
2244 ``groups``
2245 Comma-separated list of trusted groups.
2245 Comma-separated list of trusted groups.
2246
2246
2247
2247
2248 ``ui``
2248 ``ui``
2249 ------
2249 ------
2250
2250
2251 User interface controls.
2251 User interface controls.
2252
2252
2253 ``archivemeta``
2253 ``archivemeta``
2254 Whether to include the .hg_archival.txt file containing meta data
2254 Whether to include the .hg_archival.txt file containing meta data
2255 (hashes for the repository base and for tip) in archives created
2255 (hashes for the repository base and for tip) in archives created
2256 by the :hg:`archive` command or downloaded via hgweb.
2256 by the :hg:`archive` command or downloaded via hgweb.
2257 (default: True)
2257 (default: True)
2258
2258
2259 ``askusername``
2259 ``askusername``
2260 Whether to prompt for a username when committing. If True, and
2260 Whether to prompt for a username when committing. If True, and
2261 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2261 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2262 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
2263 default ``USER@HOST`` is used instead.
2263 default ``USER@HOST`` is used instead.
2264 (default: False)
2264 (default: False)
2265
2265
2266 ``clonebundles``
2266 ``clonebundles``
2267 Whether the "clone bundles" feature is enabled.
2267 Whether the "clone bundles" feature is enabled.
2268
2268
2269 When enabled, :hg:`clone` may download and apply a server-advertised
2269 When enabled, :hg:`clone` may download and apply a server-advertised
2270 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.
2271
2271
2272 This can likely result in faster and more reliable clones.
2272 This can likely result in faster and more reliable clones.
2273
2273
2274 (default: True)
2274 (default: True)
2275
2275
2276 ``clonebundlefallback``
2276 ``clonebundlefallback``
2277 Whether failure to apply an advertised "clone bundle" from a server
2277 Whether failure to apply an advertised "clone bundle" from a server
2278 should result in fallback to a regular clone.
2278 should result in fallback to a regular clone.
2279
2279
2280 This is disabled by default because servers advertising "clone
2280 This is disabled by default because servers advertising "clone
2281 bundles" often do so to reduce server load. If advertised bundles
2281 bundles" often do so to reduce server load. If advertised bundles
2282 start mass failing and clients automatically fall back to a regular
2282 start mass failing and clients automatically fall back to a regular
2283 clone, this would add significant and unexpected load to the server
2283 clone, this would add significant and unexpected load to the server
2284 since the server is expecting clone operations to be offloaded to
2284 since the server is expecting clone operations to be offloaded to
2285 pre-generated bundles. Failing fast (the default behavior) ensures
2285 pre-generated bundles. Failing fast (the default behavior) ensures
2286 clients don't overwhelm the server when "clone bundle" application
2286 clients don't overwhelm the server when "clone bundle" application
2287 fails.
2287 fails.
2288
2288
2289 (default: False)
2289 (default: False)
2290
2290
2291 ``clonebundleprefers``
2291 ``clonebundleprefers``
2292 Defines preferences for which "clone bundles" to use.
2292 Defines preferences for which "clone bundles" to use.
2293
2293
2294 Servers advertising "clone bundles" may advertise multiple available
2294 Servers advertising "clone bundles" may advertise multiple available
2295 bundles. Each bundle may have different attributes, such as the bundle
2295 bundles. Each bundle may have different attributes, such as the bundle
2296 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
2297 bundle over another.
2297 bundle over another.
2298
2298
2299 The following keys are defined by Mercurial:
2299 The following keys are defined by Mercurial:
2300
2300
2301 BUNDLESPEC
2301 BUNDLESPEC
2302 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`.
2303 e.g. ``gzip-v2`` or ``bzip2-v1``.
2303 e.g. ``gzip-v2`` or ``bzip2-v1``.
2304
2304
2305 COMPRESSION
2305 COMPRESSION
2306 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2306 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2307
2307
2308 Server operators may define custom keys.
2308 Server operators may define custom keys.
2309
2309
2310 Example values: ``COMPRESSION=bzip2``,
2310 Example values: ``COMPRESSION=bzip2``,
2311 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2311 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2312
2312
2313 By default, the first bundle advertised by the server is used.
2313 By default, the first bundle advertised by the server is used.
2314
2314
2315 ``color``
2315 ``color``
2316 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
2317 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2317 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2318 seems possible. See :hg:`help color` for details.
2318 seems possible. See :hg:`help color` for details.
2319
2319
2320 ``commitsubrepos``
2320 ``commitsubrepos``
2321 Whether to commit modified subrepositories when committing the
2321 Whether to commit modified subrepositories when committing the
2322 parent repository. If False and one subrepository has uncommitted
2322 parent repository. If False and one subrepository has uncommitted
2323 changes, abort the commit.
2323 changes, abort the commit.
2324 (default: False)
2324 (default: False)
2325
2325
2326 ``debug``
2326 ``debug``
2327 Print debugging information. (default: False)
2327 Print debugging information. (default: False)
2328
2328
2329 ``editor``
2329 ``editor``
2330 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2330 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2331
2331
2332 ``fallbackencoding``
2332 ``fallbackencoding``
2333 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
2334 UTF-8. (default: ISO-8859-1)
2334 UTF-8. (default: ISO-8859-1)
2335
2335
2336 ``graphnodetemplate``
2336 ``graphnodetemplate``
2337 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.
2338 (default: ``{graphnode}``)
2338 (default: ``{graphnode}``)
2339
2339
2340 ``ignore``
2340 ``ignore``
2341 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
2342 in the same format as a repository-wide .hgignore file. Filenames
2342 in the same format as a repository-wide .hgignore file. Filenames
2343 are relative to the repository root. This option supports hook syntax,
2343 are relative to the repository root. This option supports hook syntax,
2344 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
2345 setting something like ``ignore.other = ~/.hgignore2``. For details
2345 setting something like ``ignore.other = ~/.hgignore2``. For details
2346 of the ignore file format, see the ``hgignore(5)`` man page.
2346 of the ignore file format, see the ``hgignore(5)`` man page.
2347
2347
2348 ``interactive``
2348 ``interactive``
2349 Allow to prompt the user. (default: True)
2349 Allow to prompt the user. (default: True)
2350
2350
2351 ``interface``
2351 ``interface``
2352 Select the default interface for interactive features (default: text).
2352 Select the default interface for interactive features (default: text).
2353 Possible values are 'text' and 'curses'.
2353 Possible values are 'text' and 'curses'.
2354
2354
2355 ``interface.chunkselector``
2355 ``interface.chunkselector``
2356 Select the interface for change recording (e.g. :hg:`commit -i`).
2356 Select the interface for change recording (e.g. :hg:`commit -i`).
2357 Possible values are 'text' and 'curses'.
2357 Possible values are 'text' and 'curses'.
2358 This config overrides the interface specified by ui.interface.
2358 This config overrides the interface specified by ui.interface.
2359
2359
2360 ``large-file-limit``
2360 ``large-file-limit``
2361 Largest file size that gives no memory use warning.
2361 Largest file size that gives no memory use warning.
2362 Possible values are integers or 0 to disable the check.
2362 Possible values are integers or 0 to disable the check.
2363 (default: 10000000)
2363 (default: 10000000)
2364
2364
2365 ``logtemplate``
2365 ``logtemplate``
2366 Template string for commands that print changesets.
2366 Template string for commands that print changesets.
2367
2367
2368 ``merge``
2368 ``merge``
2369 The conflict resolution program to use during a manual merge.
2369 The conflict resolution program to use during a manual merge.
2370 For more information on merge tools see :hg:`help merge-tools`.
2370 For more information on merge tools see :hg:`help merge-tools`.
2371 For configuring merge tools see the ``[merge-tools]`` section.
2371 For configuring merge tools see the ``[merge-tools]`` section.
2372
2372
2373 ``mergemarkers``
2373 ``mergemarkers``
2374 Sets the merge conflict marker label styling. The ``detailed``
2374 Sets the merge conflict marker label styling. The ``detailed``
2375 style uses the ``mergemarkertemplate`` setting to style the labels.
2375 style uses the ``mergemarkertemplate`` setting to style the labels.
2376 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.
2377 One of ``basic`` or ``detailed``.
2377 One of ``basic`` or ``detailed``.
2378 (default: ``basic``)
2378 (default: ``basic``)
2379
2379
2380 ``mergemarkertemplate``
2380 ``mergemarkertemplate``
2381 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
2382 marker during merge conflicts. See :hg:`help templates` for the template
2382 marker during merge conflicts. See :hg:`help templates` for the template
2383 format.
2383 format.
2384
2384
2385 Defaults to showing the hash, tags, branches, bookmarks, author, and
2385 Defaults to showing the hash, tags, branches, bookmarks, author, and
2386 the first line of the commit description.
2386 the first line of the commit description.
2387
2387
2388 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,
2389 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
2390 managed files. At template expansion, non-ASCII characters use the encoding
2390 managed files. At template expansion, non-ASCII characters use the encoding
2391 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2391 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2392 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
2393 markers is different from the encoding of the merged files,
2393 markers is different from the encoding of the merged files,
2394 serious problems may occur.
2394 serious problems may occur.
2395
2395
2396 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2396 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2397
2397
2398 ``message-output``
2398 ``message-output``
2399 Where to write status and error messages. (default: ``stdio``)
2399 Where to write status and error messages. (default: ``stdio``)
2400
2400
2401 ``channel``
2401 ``channel``
2402 Use separate channel for structured output. (Command-server only)
2402 Use separate channel for structured output. (Command-server only)
2403 ``stderr``
2403 ``stderr``
2404 Everything to stderr.
2404 Everything to stderr.
2405 ``stdio``
2405 ``stdio``
2406 Status to stdout, and error to stderr.
2406 Status to stdout, and error to stderr.
2407
2407
2408 ``origbackuppath``
2408 ``origbackuppath``
2409 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
2410 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
2411 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
2412 suffix.
2412 suffix.
2413
2413
2414 ``paginate``
2414 ``paginate``
2415 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`
2416 for details.
2416 for details.
2417
2417
2418 ``patch``
2418 ``patch``
2419 An optional external tool that ``hg import`` and some extensions
2419 An optional external tool that ``hg import`` and some extensions
2420 will use for applying patches. By default Mercurial uses an
2420 will use for applying patches. By default Mercurial uses an
2421 internal patch utility. The external tool must work as the common
2421 internal patch utility. The external tool must work as the common
2422 Unix ``patch`` program. In particular, it must accept a ``-p``
2422 Unix ``patch`` program. In particular, it must accept a ``-p``
2423 argument to strip patch headers, a ``-d`` argument to specify the
2423 argument to strip patch headers, a ``-d`` argument to specify the
2424 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
2425 from stdin.
2425 from stdin.
2426
2426
2427 It is possible to specify a patch tool together with extra
2427 It is possible to specify a patch tool together with extra
2428 arguments. For example, setting this option to ``patch --merge``
2428 arguments. For example, setting this option to ``patch --merge``
2429 will use the ``patch`` program with its 2-way merge option.
2429 will use the ``patch`` program with its 2-way merge option.
2430
2430
2431 ``portablefilenames``
2431 ``portablefilenames``
2432 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2432 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2433 (default: ``warn``)
2433 (default: ``warn``)
2434
2434
2435 ``warn``
2435 ``warn``
2436 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
2437 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
2438 Windows because it contains reserved parts like ``AUX``, reserved
2438 Windows because it contains reserved parts like ``AUX``, reserved
2439 characters like ``:``, or would cause a case collision with an existing
2439 characters like ``:``, or would cause a case collision with an existing
2440 file).
2440 file).
2441
2441
2442 ``ignore``
2442 ``ignore``
2443 Don't print a warning.
2443 Don't print a warning.
2444
2444
2445 ``abort``
2445 ``abort``
2446 The command is aborted.
2446 The command is aborted.
2447
2447
2448 ``true``
2448 ``true``
2449 Alias for ``warn``.
2449 Alias for ``warn``.
2450
2450
2451 ``false``
2451 ``false``
2452 Alias for ``ignore``.
2452 Alias for ``ignore``.
2453
2453
2454 .. container:: windows
2454 .. container:: windows
2455
2455
2456 On Windows, this configuration option is ignored and the command aborted.
2456 On Windows, this configuration option is ignored and the command aborted.
2457
2457
2458 ``pre-merge-tool-output-template``
2458 ``pre-merge-tool-output-template``
2459 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
2460 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
2461 the conflict resolution, such as the description of the various commits
2461 the conflict resolution, such as the description of the various commits
2462 involved or bookmarks/tags.
2462 involved or bookmarks/tags.
2463
2463
2464 Additional information is available in the ``local`, ``base``, and ``other``
2464 Additional information is available in the ``local`, ``base``, and ``other``
2465 dicts. For example: ``{local.label}``, ``{base.name}``, or
2465 dicts. For example: ``{local.label}``, ``{base.name}``, or
2466 ``{other.islink}``.
2466 ``{other.islink}``.
2467
2467
2468 ``quiet``
2468 ``quiet``
2469 Reduce the amount of output printed.
2469 Reduce the amount of output printed.
2470 (default: False)
2470 (default: False)
2471
2471
2472 ``relative-paths``
2472 ``relative-paths``
2473 Prefer relative paths in the UI.
2473 Prefer relative paths in the UI.
2474
2474
2475 ``remotecmd``
2475 ``remotecmd``
2476 Remote command to use for clone/push/pull operations.
2476 Remote command to use for clone/push/pull operations.
2477 (default: ``hg``)
2477 (default: ``hg``)
2478
2478
2479 ``report_untrusted``
2479 ``report_untrusted``
2480 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
2481 trusted user or group.
2481 trusted user or group.
2482 (default: True)
2482 (default: True)
2483
2483
2484 ``slash``
2484 ``slash``
2485 (Deprecated. Use ``slashpath`` template filter instead.)
2485 (Deprecated. Use ``slashpath`` template filter instead.)
2486
2486
2487 Display paths using a slash (``/``) as the path separator. This
2487 Display paths using a slash (``/``) as the path separator. This
2488 only makes a difference on systems where the default path
2488 only makes a difference on systems where the default path
2489 separator is not the slash character (e.g. Windows uses the
2489 separator is not the slash character (e.g. Windows uses the
2490 backslash character (``\``)).
2490 backslash character (``\``)).
2491 (default: False)
2491 (default: False)
2492
2492
2493 ``statuscopies``
2493 ``statuscopies``
2494 Display copies in the status command.
2494 Display copies in the status command.
2495
2495
2496 ``ssh``
2496 ``ssh``
2497 Command to use for SSH connections. (default: ``ssh``)
2497 Command to use for SSH connections. (default: ``ssh``)
2498
2498
2499 ``ssherrorhint``
2499 ``ssherrorhint``
2500 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.
2501 ``Please see http://company/internalwiki/ssh.html``)
2501 ``Please see http://company/internalwiki/ssh.html``)
2502
2502
2503 ``strict``
2503 ``strict``
2504 Require exact command names, instead of allowing unambiguous
2504 Require exact command names, instead of allowing unambiguous
2505 abbreviations. (default: False)
2505 abbreviations. (default: False)
2506
2506
2507 ``style``
2507 ``style``
2508 Name of style to use for command output.
2508 Name of style to use for command output.
2509
2509
2510 ``supportcontact``
2510 ``supportcontact``
2511 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
2512 large organisation with its own Mercurial deployment process and crash
2512 large organisation with its own Mercurial deployment process and crash
2513 reports should be addressed to your internal support.
2513 reports should be addressed to your internal support.
2514
2514
2515 ``textwidth``
2515 ``textwidth``
2516 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
2517 ``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
2518 width or the terminal width, whichever comes first.
2518 width or the terminal width, whichever comes first.
2519 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
2520 used. (default: 78)
2520 used. (default: 78)
2521
2521
2522 ``timeout``
2522 ``timeout``
2523 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
2524 means no timeout. (default: 600)
2524 means no timeout. (default: 600)
2525
2525
2526 ``timeout.warn``
2526 ``timeout.warn``
2527 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
2528 value means no warning. (default: 0)
2528 value means no warning. (default: 0)
2529
2529
2530 ``traceback``
2530 ``traceback``
2531 Mercurial always prints a traceback when an unknown exception
2531 Mercurial always prints a traceback when an unknown exception
2532 occurs. Setting this to True will make Mercurial print a traceback
2532 occurs. Setting this to True will make Mercurial print a traceback
2533 on all exceptions, even those recognized by Mercurial (such as
2533 on all exceptions, even those recognized by Mercurial (such as
2534 IOError or MemoryError). (default: False)
2534 IOError or MemoryError). (default: False)
2535
2535
2536 ``tweakdefaults``
2536 ``tweakdefaults``
2537
2537
2538 By default Mercurial's behavior changes very little from release
2538 By default Mercurial's behavior changes very little from release
2539 to release, but over time the recommended config settings
2539 to release, but over time the recommended config settings
2540 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
2541 Mercurial's behavior over time. This config setting will have no
2541 Mercurial's behavior over time. This config setting will have no
2542 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2542 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2543 not include ``tweakdefaults``. (default: False)
2543 not include ``tweakdefaults``. (default: False)
2544
2544
2545 It currently means::
2545 It currently means::
2546
2546
2547 .. tweakdefaultsmarker
2547 .. tweakdefaultsmarker
2548
2548
2549 ``username``
2549 ``username``
2550 The committer of a changeset created when running "commit".
2550 The committer of a changeset created when running "commit".
2551 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
2552 <fred@example.com>``. Environment variables in the
2552 <fred@example.com>``. Environment variables in the
2553 username are expanded.
2553 username are expanded.
2554
2554
2555 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2555 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2556 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
2557 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
2558 hgrc file)
2558 hgrc file)
2559
2559
2560 ``verbose``
2560 ``verbose``
2561 Increase the amount of output printed. (default: False)
2561 Increase the amount of output printed. (default: False)
2562
2562
2563
2563
2564 ``web``
2564 ``web``
2565 -------
2565 -------
2566
2566
2567 Web interface configuration. The settings in this section apply to
2567 Web interface configuration. The settings in this section apply to
2568 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
2569 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2569 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2570 and WSGI).
2570 and WSGI).
2571
2571
2572 The Mercurial webserver does no authentication (it does not prompt for
2572 The Mercurial webserver does no authentication (it does not prompt for
2573 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
2574 authorization (it grants or denies access for *authenticated users*
2574 authorization (it grants or denies access for *authenticated users*
2575 based on settings in this section). You must either configure your
2575 based on settings in this section). You must either configure your
2576 webserver to do authentication for you, or disable the authorization
2576 webserver to do authentication for you, or disable the authorization
2577 checks.
2577 checks.
2578
2578
2579 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
2580 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
2581 command line::
2581 command line::
2582
2582
2583 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2583 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2584
2584
2585 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
2586 that this should not be used for public servers.
2586 that this should not be used for public servers.
2587
2587
2588 The full set of options is:
2588 The full set of options is:
2589
2589
2590 ``accesslog``
2590 ``accesslog``
2591 Where to output the access log. (default: stdout)
2591 Where to output the access log. (default: stdout)
2592
2592
2593 ``address``
2593 ``address``
2594 Interface address to bind to. (default: all)
2594 Interface address to bind to. (default: all)
2595
2595
2596 ``allow-archive``
2596 ``allow-archive``
2597 List of archive format (bz2, gz, zip) allowed for downloading.
2597 List of archive format (bz2, gz, zip) allowed for downloading.
2598 (default: empty)
2598 (default: empty)
2599
2599
2600 ``allowbz2``
2600 ``allowbz2``
2601 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2601 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2602 revisions.
2602 revisions.
2603 (default: False)
2603 (default: False)
2604
2604
2605 ``allowgz``
2605 ``allowgz``
2606 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2606 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2607 revisions.
2607 revisions.
2608 (default: False)
2608 (default: False)
2609
2609
2610 ``allow-pull``
2610 ``allow-pull``
2611 Whether to allow pulling from the repository. (default: True)
2611 Whether to allow pulling from the repository. (default: True)
2612
2612
2613 ``allow-push``
2613 ``allow-push``
2614 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,
2615 pushing is not allowed. If the special value ``*``, any remote
2615 pushing is not allowed. If the special value ``*``, any remote
2616 user can push, including unauthenticated users. Otherwise, the
2616 user can push, including unauthenticated users. Otherwise, the
2617 remote user must have been authenticated, and the authenticated
2617 remote user must have been authenticated, and the authenticated
2618 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
2619 allow-push list are examined after the deny_push list.
2619 allow-push list are examined after the deny_push list.
2620
2620
2621 ``allow_read``
2621 ``allow_read``
2622 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
2623 the contents of deny_read, this list determines whether to grant
2623 the contents of deny_read, this list determines whether to grant
2624 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
2625 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
2626 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
2627 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
2628 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
2629 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
2630 examined after the deny_read list.
2630 examined after the deny_read list.
2631
2631
2632 ``allowzip``
2632 ``allowzip``
2633 (DEPRECATED) Whether to allow .zip downloading of repository
2633 (DEPRECATED) Whether to allow .zip downloading of repository
2634 revisions. This feature creates temporary files.
2634 revisions. This feature creates temporary files.
2635 (default: False)
2635 (default: False)
2636
2636
2637 ``archivesubrepos``
2637 ``archivesubrepos``
2638 Whether to recurse into subrepositories when archiving.
2638 Whether to recurse into subrepositories when archiving.
2639 (default: False)
2639 (default: False)
2640
2640
2641 ``baseurl``
2641 ``baseurl``
2642 Base URL to use when publishing URLs in other locations, so
2642 Base URL to use when publishing URLs in other locations, so
2643 third-party tools like email notification hooks can construct
2643 third-party tools like email notification hooks can construct
2644 URLs. Example: ``http://hgserver/repos/``.
2644 URLs. Example: ``http://hgserver/repos/``.
2645
2645
2646 ``cacerts``
2646 ``cacerts``
2647 Path to file containing a list of PEM encoded certificate
2647 Path to file containing a list of PEM encoded certificate
2648 authority certificates. Environment variables and ``~user``
2648 authority certificates. Environment variables and ``~user``
2649 constructs are expanded in the filename. If specified on the
2649 constructs are expanded in the filename. If specified on the
2650 client, then it will verify the identity of remote HTTPS servers
2650 client, then it will verify the identity of remote HTTPS servers
2651 with these certificates.
2651 with these certificates.
2652
2652
2653 To disable SSL verification temporarily, specify ``--insecure`` from
2653 To disable SSL verification temporarily, specify ``--insecure`` from
2654 command line.
2654 command line.
2655
2655
2656 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
2657 one. On most Linux systems this will be
2657 one. On most Linux systems this will be
2658 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2658 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2659 generate this file manually. The form must be as follows::
2659 generate this file manually. The form must be as follows::
2660
2660
2661 -----BEGIN CERTIFICATE-----
2661 -----BEGIN CERTIFICATE-----
2662 ... (certificate in base64 PEM encoding) ...
2662 ... (certificate in base64 PEM encoding) ...
2663 -----END CERTIFICATE-----
2663 -----END CERTIFICATE-----
2664 -----BEGIN CERTIFICATE-----
2664 -----BEGIN CERTIFICATE-----
2665 ... (certificate in base64 PEM encoding) ...
2665 ... (certificate in base64 PEM encoding) ...
2666 -----END CERTIFICATE-----
2666 -----END CERTIFICATE-----
2667
2667
2668 ``cache``
2668 ``cache``
2669 Whether to support caching in hgweb. (default: True)
2669 Whether to support caching in hgweb. (default: True)
2670
2670
2671 ``certificate``
2671 ``certificate``
2672 Certificate to use when running :hg:`serve`.
2672 Certificate to use when running :hg:`serve`.
2673
2673
2674 ``collapse``
2674 ``collapse``
2675 With ``descend`` enabled, repositories in subdirectories are shown at
2675 With ``descend`` enabled, repositories in subdirectories are shown at
2676 a single level alongside repositories in the current path. With
2676 a single level alongside repositories in the current path. With
2677 ``collapse`` also enabled, repositories residing at a deeper level than
2677 ``collapse`` also enabled, repositories residing at a deeper level than
2678 the current path are grouped behind navigable directory entries that
2678 the current path are grouped behind navigable directory entries that
2679 lead to the locations of these repositories. In effect, this setting
2679 lead to the locations of these repositories. In effect, this setting
2680 collapses each collection of repositories found within a subdirectory
2680 collapses each collection of repositories found within a subdirectory
2681 into a single entry for that subdirectory. (default: False)
2681 into a single entry for that subdirectory. (default: False)
2682
2682
2683 ``comparisoncontext``
2683 ``comparisoncontext``
2684 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
2685 negative or the value ``full``, whole files are shown. (default: 5)
2685 negative or the value ``full``, whole files are shown. (default: 5)
2686
2686
2687 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
2688 ``comparison`` command, taking the same values.
2688 ``comparison`` command, taking the same values.
2689
2689
2690 ``contact``
2690 ``contact``
2691 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.
2692 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2692 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2693
2693
2694 ``csp``
2694 ``csp``
2695 Send a ``Content-Security-Policy`` HTTP header with this value.
2695 Send a ``Content-Security-Policy`` HTTP header with this value.
2696
2696
2697 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
2698 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
2699 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2699 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2700 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
2701 ``<script>`` elements containing inline JavaScript.
2701 ``<script>`` elements containing inline JavaScript.
2702
2702
2703 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
2704 data. Please consider the potential for malicious repository data to
2704 data. Please consider the potential for malicious repository data to
2705 "inject" itself into generated HTML content as part of your security
2705 "inject" itself into generated HTML content as part of your security
2706 threat model.
2706 threat model.
2707
2707
2708 ``deny_push``
2708 ``deny_push``
2709 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,
2710 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
2711 denied push. Otherwise, unauthenticated users are all denied, and
2711 denied push. Otherwise, unauthenticated users are all denied, and
2712 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
2713 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.
2714
2714
2715 ``deny_read``
2715 ``deny_read``
2716 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
2717 not empty, unauthenticated users are all denied, and any
2717 not empty, unauthenticated users are all denied, and any
2718 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
2719 the repository. If set to the special value ``*``, all remote users
2719 the repository. If set to the special value ``*``, all remote users
2720 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,
2721 the determination of repository access depends on the presence and
2721 the determination of repository access depends on the presence and
2722 content of the allow_read list (see description). If both
2722 content of the allow_read list (see description). If both
2723 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
2724 permitted to all users by default. If the repository is being
2724 permitted to all users by default. If the repository is being
2725 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
2726 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
2727 priority over (are examined before) the contents of the allow_read
2727 priority over (are examined before) the contents of the allow_read
2728 list.
2728 list.
2729
2729
2730 ``descend``
2730 ``descend``
2731 hgwebdir indexes will not descend into subdirectories. Only repositories
2731 hgwebdir indexes will not descend into subdirectories. Only repositories
2732 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
2733 available from the index corresponding to their containing path).
2733 available from the index corresponding to their containing path).
2734
2734
2735 ``description``
2735 ``description``
2736 Textual description of the repository's purpose or contents.
2736 Textual description of the repository's purpose or contents.
2737 (default: "unknown")
2737 (default: "unknown")
2738
2738
2739 ``encoding``
2739 ``encoding``
2740 Character encoding name. (default: the current locale charset)
2740 Character encoding name. (default: the current locale charset)
2741 Example: "UTF-8".
2741 Example: "UTF-8".
2742
2742
2743 ``errorlog``
2743 ``errorlog``
2744 Where to output the error log. (default: stderr)
2744 Where to output the error log. (default: stderr)
2745
2745
2746 ``guessmime``
2746 ``guessmime``
2747 Control MIME types for raw download of file content.
2747 Control MIME types for raw download of file content.
2748 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
2749 extension. This will serve HTML files as ``text/html`` and might
2749 extension. This will serve HTML files as ``text/html`` and might
2750 allow cross-site scripting attacks when serving untrusted
2750 allow cross-site scripting attacks when serving untrusted
2751 repositories. (default: False)
2751 repositories. (default: False)
2752
2752
2753 ``hidden``
2753 ``hidden``
2754 Whether to hide the repository in the hgwebdir index.
2754 Whether to hide the repository in the hgwebdir index.
2755 (default: False)
2755 (default: False)
2756
2756
2757 ``ipv6``
2757 ``ipv6``
2758 Whether to use IPv6. (default: False)
2758 Whether to use IPv6. (default: False)
2759
2759
2760 ``labels``
2760 ``labels``
2761 List of string *labels* associated with the repository.
2761 List of string *labels* associated with the repository.
2762
2762
2763 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
2764 output. e.g. the ``index`` template can group or filter repositories
2764 output. e.g. the ``index`` template can group or filter repositories
2765 by labels and the ``summary`` template can display additional content
2765 by labels and the ``summary`` template can display additional content
2766 if a specific label is present.
2766 if a specific label is present.
2767
2767
2768 ``logoimg``
2768 ``logoimg``
2769 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.
2770 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
2771 the logo image is "staticurl/logoimg".
2771 the logo image is "staticurl/logoimg".
2772 If unset, ``hglogo.png`` will be used.
2772 If unset, ``hglogo.png`` will be used.
2773
2773
2774 ``logourl``
2774 ``logourl``
2775 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/``
2776 will be used.
2776 will be used.
2777
2777
2778 ``maxchanges``
2778 ``maxchanges``
2779 Maximum number of changes to list on the changelog. (default: 10)
2779 Maximum number of changes to list on the changelog. (default: 10)
2780
2780
2781 ``maxfiles``
2781 ``maxfiles``
2782 Maximum number of files to list per changeset. (default: 10)
2782 Maximum number of files to list per changeset. (default: 10)
2783
2783
2784 ``maxshortchanges``
2784 ``maxshortchanges``
2785 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
2786 pages. (default: 60)
2786 pages. (default: 60)
2787
2787
2788 ``name``
2788 ``name``
2789 Repository name to use in the web interface.
2789 Repository name to use in the web interface.
2790 (default: current working directory)
2790 (default: current working directory)
2791
2791
2792 ``port``
2792 ``port``
2793 Port to listen on. (default: 8000)
2793 Port to listen on. (default: 8000)
2794
2794
2795 ``prefix``
2795 ``prefix``
2796 Prefix path to serve from. (default: '' (server root))
2796 Prefix path to serve from. (default: '' (server root))
2797
2797
2798 ``push_ssl``
2798 ``push_ssl``
2799 Whether to require that inbound pushes be transported over SSL to
2799 Whether to require that inbound pushes be transported over SSL to
2800 prevent password sniffing. (default: True)
2800 prevent password sniffing. (default: True)
2801
2801
2802 ``refreshinterval``
2802 ``refreshinterval``
2803 How frequently directory listings re-scan the filesystem for new
2803 How frequently directory listings re-scan the filesystem for new
2804 repositories, in seconds. This is relevant when wildcards are used
2804 repositories, in seconds. This is relevant when wildcards are used
2805 to define paths. Depending on how much filesystem traversal is
2805 to define paths. Depending on how much filesystem traversal is
2806 required, refreshing may negatively impact performance.
2806 required, refreshing may negatively impact performance.
2807
2807
2808 Values less than or equal to 0 always refresh.
2808 Values less than or equal to 0 always refresh.
2809 (default: 20)
2809 (default: 20)
2810
2810
2811 ``server-header``
2811 ``server-header``
2812 Value for HTTP ``Server`` response header.
2812 Value for HTTP ``Server`` response header.
2813
2813
2814 ``static``
2814 ``static``
2815 Directory where static files are served from.
2815 Directory where static files are served from.
2816
2816
2817 ``staticurl``
2817 ``staticurl``
2818 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
2819 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
2820 this setting to serve them directly with the HTTP server.
2820 this setting to serve them directly with the HTTP server.
2821 Example: ``http://hgserver/static/``.
2821 Example: ``http://hgserver/static/``.
2822
2822
2823 ``stripes``
2823 ``stripes``
2824 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.
2825 Set to 0 to disable. (default: 1)
2825 Set to 0 to disable. (default: 1)
2826
2826
2827 ``style``
2827 ``style``
2828 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
2829 subdirectories in the HTML templates path. (default: ``paper``)
2829 subdirectories in the HTML templates path. (default: ``paper``)
2830 Example: ``monoblue``.
2830 Example: ``monoblue``.
2831
2831
2832 ``templates``
2832 ``templates``
2833 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
2834 can be obtained from ``hg debuginstall``.
2834 can be obtained from ``hg debuginstall``.
2835
2835
2836 ``websub``
2836 ``websub``
2837 ----------
2837 ----------
2838
2838
2839 Web substitution filter definition. You can use this section to
2839 Web substitution filter definition. You can use this section to
2840 define a set of regular expression substitution patterns which
2840 define a set of regular expression substitution patterns which
2841 let you automatically modify the hgweb server output.
2841 let you automatically modify the hgweb server output.
2842
2842
2843 The default hgweb templates only apply these substitution patterns
2843 The default hgweb templates only apply these substitution patterns
2844 on the revision description fields. You can apply them anywhere
2844 on the revision description fields. You can apply them anywhere
2845 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
2846 "websub" filter (usually after calling the "escape" filter).
2846 "websub" filter (usually after calling the "escape" filter).
2847
2847
2848 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
2849 to your issue tracker, or to convert "markdown-like" syntax into
2849 to your issue tracker, or to convert "markdown-like" syntax into
2850 HTML (see the examples below).
2850 HTML (see the examples below).
2851
2851
2852 Each entry in this section names a substitution filter.
2852 Each entry in this section names a substitution filter.
2853 The value of each entry defines the substitution expression itself.
2853 The value of each entry defines the substitution expression itself.
2854 The websub expressions follow the old interhg extension syntax,
2854 The websub expressions follow the old interhg extension syntax,
2855 which in turn imitates the Unix sed replacement syntax::
2855 which in turn imitates the Unix sed replacement syntax::
2856
2856
2857 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2857 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2858
2858
2859 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
2860 and indicates that the search must be case insensitive.
2860 and indicates that the search must be case insensitive.
2861
2861
2862 Examples::
2862 Examples::
2863
2863
2864 [websub]
2864 [websub]
2865 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
2866 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2866 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2867 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2867 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2868
2868
2869 ``worker``
2869 ``worker``
2870 ----------
2870 ----------
2871
2871
2872 Parallel master/worker configuration. We currently perform working
2872 Parallel master/worker configuration. We currently perform working
2873 directory updates in parallel on Unix-like systems, which greatly
2873 directory updates in parallel on Unix-like systems, which greatly
2874 helps performance.
2874 helps performance.
2875
2875
2876 ``enabled``
2876 ``enabled``
2877 Whether to enable workers code to be used.
2877 Whether to enable workers code to be used.
2878 (default: true)
2878 (default: true)
2879
2879
2880 ``numcpus``
2880 ``numcpus``
2881 Number of CPUs to use for parallel operations. A zero or
2881 Number of CPUs to use for parallel operations. A zero or
2882 negative value is treated as ``use the default``.
2882 negative value is treated as ``use the default``.
2883 (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)
2884
2884
2885 ``backgroundclose``
2885 ``backgroundclose``
2886 Whether to enable closing file handles on background threads during certain
2886 Whether to enable closing file handles on background threads during certain
2887 operations. Some platforms aren't very efficient at closing file
2887 operations. Some platforms aren't very efficient at closing file
2888 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
2889 on background threads, file write rate can increase substantially.
2889 on background threads, file write rate can increase substantially.
2890 (default: true on Windows, false elsewhere)
2890 (default: true on Windows, false elsewhere)
2891
2891
2892 ``backgroundcloseminfilecount``
2892 ``backgroundcloseminfilecount``
2893 Minimum number of files required to trigger background file closing.
2893 Minimum number of files required to trigger background file closing.
2894 Operations not writing this many files won't start background close
2894 Operations not writing this many files won't start background close
2895 threads.
2895 threads.
2896 (default: 2048)
2896 (default: 2048)
2897
2897
2898 ``backgroundclosemaxqueue``
2898 ``backgroundclosemaxqueue``
2899 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
2900 background. This option only has an effect if ``backgroundclose`` is
2900 background. This option only has an effect if ``backgroundclose`` is
2901 enabled.
2901 enabled.
2902 (default: 384)
2902 (default: 384)
2903
2903
2904 ``backgroundclosethreadcount``
2904 ``backgroundclosethreadcount``
2905 Number of threads to process background file closes. Only relevant if
2905 Number of threads to process background file closes. Only relevant if
2906 ``backgroundclose`` is enabled.
2906 ``backgroundclose`` is enabled.
2907 (default: 4)
2907 (default: 4)
@@ -1,607 +1,672 b''
1 $ cat >> $HGRCPATH << EOF
1 $ cat >> $HGRCPATH << EOF
2 > [extensions]
2 > [extensions]
3 > absorb=
3 > absorb=
4 > EOF
4 > EOF
5
5
6 $ sedi() { # workaround check-code
6 $ sedi() { # workaround check-code
7 > pattern="$1"
7 > pattern="$1"
8 > shift
8 > shift
9 > for i in "$@"; do
9 > for i in "$@"; do
10 > sed "$pattern" "$i" > "$i".tmp
10 > sed "$pattern" "$i" > "$i".tmp
11 > mv "$i".tmp "$i"
11 > mv "$i".tmp "$i"
12 > done
12 > done
13 > }
13 > }
14
14
15 $ hg init repo1
15 $ hg init repo1
16 $ cd repo1
16 $ cd repo1
17
17
18 Do not crash with empty repo:
18 Do not crash with empty repo:
19
19
20 $ hg absorb
20 $ hg absorb
21 abort: no mutable changeset to change
21 abort: no mutable changeset to change
22 [255]
22 [255]
23
23
24 Make some commits:
24 Make some commits:
25
25
26 $ for i in 1 2 3 4 5; do
26 $ for i in 1 2 3 4 5; do
27 > echo $i >> a
27 > echo $i >> a
28 > hg commit -A a -m "commit $i" -q
28 > hg commit -A a -m "commit $i" -q
29 > done
29 > done
30
30
31 $ hg annotate a
31 $ hg annotate a
32 0: 1
32 0: 1
33 1: 2
33 1: 2
34 2: 3
34 2: 3
35 3: 4
35 3: 4
36 4: 5
36 4: 5
37
37
38 Change a few lines:
38 Change a few lines:
39
39
40 $ cat > a <<EOF
40 $ cat > a <<EOF
41 > 1a
41 > 1a
42 > 2b
42 > 2b
43 > 3
43 > 3
44 > 4d
44 > 4d
45 > 5e
45 > 5e
46 > EOF
46 > EOF
47
47
48 Preview absorb changes:
48 Preview absorb changes:
49
49
50 $ hg absorb --print-changes --dry-run
50 $ hg absorb --print-changes --dry-run
51 showing changes for a
51 showing changes for a
52 @@ -0,2 +0,2 @@
52 @@ -0,2 +0,2 @@
53 4ec16f8 -1
53 4ec16f8 -1
54 5c5f952 -2
54 5c5f952 -2
55 4ec16f8 +1a
55 4ec16f8 +1a
56 5c5f952 +2b
56 5c5f952 +2b
57 @@ -3,2 +3,2 @@
57 @@ -3,2 +3,2 @@
58 ad8b8b7 -4
58 ad8b8b7 -4
59 4f55fa6 -5
59 4f55fa6 -5
60 ad8b8b7 +4d
60 ad8b8b7 +4d
61 4f55fa6 +5e
61 4f55fa6 +5e
62
62
63 4 changesets affected
63 4 changesets affected
64 4f55fa6 commit 5
64 4f55fa6 commit 5
65 ad8b8b7 commit 4
65 ad8b8b7 commit 4
66 5c5f952 commit 2
66 5c5f952 commit 2
67 4ec16f8 commit 1
67 4ec16f8 commit 1
68
68
69 Run absorb:
69 Run absorb:
70
70
71 $ hg absorb --apply-changes
71 $ hg absorb --apply-changes
72 saved backup bundle to * (glob)
72 saved backup bundle to * (glob)
73 2 of 2 chunk(s) applied
73 2 of 2 chunk(s) applied
74 $ hg annotate a
74 $ hg annotate a
75 0: 1a
75 0: 1a
76 1: 2b
76 1: 2b
77 2: 3
77 2: 3
78 3: 4d
78 3: 4d
79 4: 5e
79 4: 5e
80
80
81 Delete a few lines and related commits will be removed if they will be empty:
81 Delete a few lines and related commits will be removed if they will be empty:
82
82
83 $ cat > a <<EOF
83 $ cat > a <<EOF
84 > 2b
84 > 2b
85 > 4d
85 > 4d
86 > EOF
86 > EOF
87 $ echo y | hg absorb --config ui.interactive=1
87 $ echo y | hg absorb --config ui.interactive=1
88 showing changes for a
88 showing changes for a
89 @@ -0,1 +0,0 @@
89 @@ -0,1 +0,0 @@
90 f548282 -1a
90 f548282 -1a
91 @@ -2,1 +1,0 @@
91 @@ -2,1 +1,0 @@
92 ff5d556 -3
92 ff5d556 -3
93 @@ -4,1 +2,0 @@
93 @@ -4,1 +2,0 @@
94 84e5416 -5e
94 84e5416 -5e
95
95
96 3 changesets affected
96 3 changesets affected
97 84e5416 commit 5
97 84e5416 commit 5
98 ff5d556 commit 3
98 ff5d556 commit 3
99 f548282 commit 1
99 f548282 commit 1
100 apply changes (y/N)? y
100 apply changes (y/N)? y
101 saved backup bundle to * (glob)
101 saved backup bundle to * (glob)
102 3 of 3 chunk(s) applied
102 3 of 3 chunk(s) applied
103 $ hg annotate a
103 $ hg annotate a
104 1: 2b
104 1: 2b
105 2: 4d
105 2: 4d
106 $ hg log -T '{rev} {desc}\n' -Gp
106 $ hg log -T '{rev} {desc}\n' -Gp
107 @ 2 commit 4
107 @ 2 commit 4
108 | diff -r 1cae118c7ed8 -r 58a62bade1c6 a
108 | diff -r 1cae118c7ed8 -r 58a62bade1c6 a
109 | --- a/a Thu Jan 01 00:00:00 1970 +0000
109 | --- a/a Thu Jan 01 00:00:00 1970 +0000
110 | +++ b/a Thu Jan 01 00:00:00 1970 +0000
110 | +++ b/a Thu Jan 01 00:00:00 1970 +0000
111 | @@ -1,1 +1,2 @@
111 | @@ -1,1 +1,2 @@
112 | 2b
112 | 2b
113 | +4d
113 | +4d
114 |
114 |
115 o 1 commit 2
115 o 1 commit 2
116 | diff -r 84add69aeac0 -r 1cae118c7ed8 a
116 | diff -r 84add69aeac0 -r 1cae118c7ed8 a
117 | --- a/a Thu Jan 01 00:00:00 1970 +0000
117 | --- a/a Thu Jan 01 00:00:00 1970 +0000
118 | +++ b/a Thu Jan 01 00:00:00 1970 +0000
118 | +++ b/a Thu Jan 01 00:00:00 1970 +0000
119 | @@ -0,0 +1,1 @@
119 | @@ -0,0 +1,1 @@
120 | +2b
120 | +2b
121 |
121 |
122 o 0 commit 1
122 o 0 commit 1
123
123
124
124
125 Non 1:1 map changes will be ignored:
125 Non 1:1 map changes will be ignored:
126
126
127 $ echo 1 > a
127 $ echo 1 > a
128 $ hg absorb --apply-changes
128 $ hg absorb --apply-changes
129 nothing applied
129 nothing applied
130 [1]
130 [1]
131
131
132 The prompt is not given if there are no changes to be applied, even if there
132 The prompt is not given if there are no changes to be applied, even if there
133 are some changes that won't be applied:
133 are some changes that won't be applied:
134
134
135 $ hg absorb
135 $ hg absorb
136 showing changes for a
136 showing changes for a
137 @@ -0,2 +0,1 @@
137 @@ -0,2 +0,1 @@
138 -2b
138 -2b
139 -4d
139 -4d
140 +1
140 +1
141
141
142 0 changesets affected
142 0 changesets affected
143 nothing applied
143 nothing applied
144 [1]
144 [1]
145
145
146 Insertaions:
146 Insertaions:
147
147
148 $ cat > a << EOF
148 $ cat > a << EOF
149 > insert before 2b
149 > insert before 2b
150 > 2b
150 > 2b
151 > 4d
151 > 4d
152 > insert aftert 4d
152 > insert aftert 4d
153 > EOF
153 > EOF
154 $ hg absorb -q --apply-changes
154 $ hg absorb -q --apply-changes
155 $ hg status
155 $ hg status
156 $ hg annotate a
156 $ hg annotate a
157 1: insert before 2b
157 1: insert before 2b
158 1: 2b
158 1: 2b
159 2: 4d
159 2: 4d
160 2: insert aftert 4d
160 2: insert aftert 4d
161
161
162 Bookmarks are moved:
162 Bookmarks are moved:
163
163
164 $ hg bookmark -r 1 b1
164 $ hg bookmark -r 1 b1
165 $ hg bookmark -r 2 b2
165 $ hg bookmark -r 2 b2
166 $ hg bookmark ba
166 $ hg bookmark ba
167 $ hg bookmarks
167 $ hg bookmarks
168 b1 1:b35060a57a50
168 b1 1:b35060a57a50
169 b2 2:946e4bc87915
169 b2 2:946e4bc87915
170 * ba 2:946e4bc87915
170 * ba 2:946e4bc87915
171 $ sedi 's/insert/INSERT/' a
171 $ sedi 's/insert/INSERT/' a
172 $ hg absorb -q --apply-changes
172 $ hg absorb -q --apply-changes
173 $ hg status
173 $ hg status
174 $ hg bookmarks
174 $ hg bookmarks
175 b1 1:a4183e9b3d31
175 b1 1:a4183e9b3d31
176 b2 2:c9b20c925790
176 b2 2:c9b20c925790
177 * ba 2:c9b20c925790
177 * ba 2:c9b20c925790
178
178
179 Non-modified files are ignored:
179 Non-modified files are ignored:
180
180
181 $ touch b
181 $ touch b
182 $ hg commit -A b -m b
182 $ hg commit -A b -m b
183 $ touch c
183 $ touch c
184 $ hg add c
184 $ hg add c
185 $ hg rm b
185 $ hg rm b
186 $ hg absorb --apply-changes
186 $ hg absorb --apply-changes
187 nothing applied
187 nothing applied
188 [1]
188 [1]
189 $ sedi 's/INSERT/Insert/' a
189 $ sedi 's/INSERT/Insert/' a
190 $ hg absorb --apply-changes
190 $ hg absorb --apply-changes
191 saved backup bundle to * (glob)
191 saved backup bundle to * (glob)
192 2 of 2 chunk(s) applied
192 2 of 2 chunk(s) applied
193 $ hg status
193 $ hg status
194 A c
194 A c
195 R b
195 R b
196
196
197 Public commits will not be changed:
197 Public commits will not be changed:
198
198
199 $ hg phase -p 1
199 $ hg phase -p 1
200 $ sedi 's/Insert/insert/' a
200 $ sedi 's/Insert/insert/' a
201 $ hg absorb -pn
201 $ hg absorb -pn
202 showing changes for a
202 showing changes for a
203 @@ -0,1 +0,1 @@
203 @@ -0,1 +0,1 @@
204 -Insert before 2b
204 -Insert before 2b
205 +insert before 2b
205 +insert before 2b
206 @@ -3,1 +3,1 @@
206 @@ -3,1 +3,1 @@
207 85b4e0e -Insert aftert 4d
207 85b4e0e -Insert aftert 4d
208 85b4e0e +insert aftert 4d
208 85b4e0e +insert aftert 4d
209
209
210 1 changesets affected
210 1 changesets affected
211 85b4e0e commit 4
211 85b4e0e commit 4
212 $ hg absorb --apply-changes
212 $ hg absorb --apply-changes
213 saved backup bundle to * (glob)
213 saved backup bundle to * (glob)
214 1 of 2 chunk(s) applied
214 1 of 2 chunk(s) applied
215 $ hg diff -U 0
215 $ hg diff -U 0
216 diff -r 1c8eadede62a a
216 diff -r 1c8eadede62a a
217 --- a/a Thu Jan 01 00:00:00 1970 +0000
217 --- a/a Thu Jan 01 00:00:00 1970 +0000
218 +++ b/a * (glob)
218 +++ b/a * (glob)
219 @@ -1,1 +1,1 @@
219 @@ -1,1 +1,1 @@
220 -Insert before 2b
220 -Insert before 2b
221 +insert before 2b
221 +insert before 2b
222 $ hg annotate a
222 $ hg annotate a
223 1: Insert before 2b
223 1: Insert before 2b
224 1: 2b
224 1: 2b
225 2: 4d
225 2: 4d
226 2: insert aftert 4d
226 2: insert aftert 4d
227
227
228 $ hg co -qC 1
228 $ hg co -qC 1
229 $ sedi 's/Insert/insert/' a
229 $ sedi 's/Insert/insert/' a
230 $ hg absorb --apply-changes
230 $ hg absorb --apply-changes
231 abort: no mutable changeset to change
231 abort: no mutable changeset to change
232 [255]
232 [255]
233
233
234 Make working copy clean:
234 Make working copy clean:
235
235
236 $ hg co -qC ba
236 $ hg co -qC ba
237 $ rm c
237 $ rm c
238 $ hg status
238 $ hg status
239
239
240 Merge commit will not be changed:
240 Merge commit will not be changed:
241
241
242 $ echo 1 > m1
242 $ echo 1 > m1
243 $ hg commit -A m1 -m m1
243 $ hg commit -A m1 -m m1
244 $ hg bookmark -q -i m1
244 $ hg bookmark -q -i m1
245 $ hg update -q '.^'
245 $ hg update -q '.^'
246 $ echo 2 > m2
246 $ echo 2 > m2
247 $ hg commit -q -A m2 -m m2
247 $ hg commit -q -A m2 -m m2
248 $ hg merge -q m1
248 $ hg merge -q m1
249 $ hg commit -m merge
249 $ hg commit -m merge
250 $ hg bookmark -d m1
250 $ hg bookmark -d m1
251 $ hg log -G -T '{rev} {desc} {phase}\n'
251 $ hg log -G -T '{rev} {desc} {phase}\n'
252 @ 6 merge draft
252 @ 6 merge draft
253 |\
253 |\
254 | o 5 m2 draft
254 | o 5 m2 draft
255 | |
255 | |
256 o | 4 m1 draft
256 o | 4 m1 draft
257 |/
257 |/
258 o 3 b draft
258 o 3 b draft
259 |
259 |
260 o 2 commit 4 draft
260 o 2 commit 4 draft
261 |
261 |
262 o 1 commit 2 public
262 o 1 commit 2 public
263 |
263 |
264 o 0 commit 1 public
264 o 0 commit 1 public
265
265
266 $ echo 2 >> m1
266 $ echo 2 >> m1
267 $ echo 2 >> m2
267 $ echo 2 >> m2
268 $ hg absorb --apply-changes
268 $ hg absorb --apply-changes
269 abort: cannot absorb into a merge
269 abort: cannot absorb into a merge
270 [255]
270 [255]
271 $ hg revert -q -C m1 m2
271 $ hg revert -q -C m1 m2
272
272
273 Use a new repo:
273 Use a new repo:
274
274
275 $ cd ..
275 $ cd ..
276 $ hg init repo2
276 $ hg init repo2
277 $ cd repo2
277 $ cd repo2
278
278
279 Make some commits to multiple files:
279 Make some commits to multiple files:
280
280
281 $ for f in a b; do
281 $ for f in a b; do
282 > for i in 1 2; do
282 > for i in 1 2; do
283 > echo $f line $i >> $f
283 > echo $f line $i >> $f
284 > hg commit -A $f -m "commit $f $i" -q
284 > hg commit -A $f -m "commit $f $i" -q
285 > done
285 > done
286 > done
286 > done
287
287
288 Use pattern to select files to be fixed up:
288 Use pattern to select files to be fixed up:
289
289
290 $ sedi 's/line/Line/' a b
290 $ sedi 's/line/Line/' a b
291 $ hg status
291 $ hg status
292 M a
292 M a
293 M b
293 M b
294 $ hg absorb --apply-changes a
294 $ hg absorb --apply-changes a
295 saved backup bundle to * (glob)
295 saved backup bundle to * (glob)
296 1 of 1 chunk(s) applied
296 1 of 1 chunk(s) applied
297 $ hg status
297 $ hg status
298 M b
298 M b
299 $ hg absorb --apply-changes --exclude b
299 $ hg absorb --apply-changes --exclude b
300 nothing applied
300 nothing applied
301 [1]
301 [1]
302 $ hg absorb --apply-changes b
302 $ hg absorb --apply-changes b
303 saved backup bundle to * (glob)
303 saved backup bundle to * (glob)
304 1 of 1 chunk(s) applied
304 1 of 1 chunk(s) applied
305 $ hg status
305 $ hg status
306 $ cat a b
306 $ cat a b
307 a Line 1
307 a Line 1
308 a Line 2
308 a Line 2
309 b Line 1
309 b Line 1
310 b Line 2
310 b Line 2
311
311
312 Test config option absorb.max-stack-size:
312 Test config option absorb.max-stack-size:
313
313
314 $ sedi 's/Line/line/' a b
314 $ sedi 's/Line/line/' a b
315 $ hg log -T '{rev}:{node} {desc}\n'
315 $ hg log -T '{rev}:{node} {desc}\n'
316 3:712d16a8f445834e36145408eabc1d29df05ec09 commit b 2
316 3:712d16a8f445834e36145408eabc1d29df05ec09 commit b 2
317 2:74cfa6294160149d60adbf7582b99ce37a4597ec commit b 1
317 2:74cfa6294160149d60adbf7582b99ce37a4597ec commit b 1
318 1:28f10dcf96158f84985358a2e5d5b3505ca69c22 commit a 2
318 1:28f10dcf96158f84985358a2e5d5b3505ca69c22 commit a 2
319 0:f9a81da8dc53380ed91902e5b82c1b36255a4bd0 commit a 1
319 0:f9a81da8dc53380ed91902e5b82c1b36255a4bd0 commit a 1
320 $ hg --config absorb.max-stack-size=1 absorb -pn
320 $ hg --config absorb.max-stack-size=1 absorb -pn
321 absorb: only the recent 1 changesets will be analysed
321 absorb: only the recent 1 changesets will be analysed
322 showing changes for a
322 showing changes for a
323 @@ -0,2 +0,2 @@
323 @@ -0,2 +0,2 @@
324 -a Line 1
324 -a Line 1
325 -a Line 2
325 -a Line 2
326 +a line 1
326 +a line 1
327 +a line 2
327 +a line 2
328 showing changes for b
328 showing changes for b
329 @@ -0,2 +0,2 @@
329 @@ -0,2 +0,2 @@
330 -b Line 1
330 -b Line 1
331 712d16a -b Line 2
331 712d16a -b Line 2
332 +b line 1
332 +b line 1
333 712d16a +b line 2
333 712d16a +b line 2
334
334
335 1 changesets affected
335 1 changesets affected
336 712d16a commit b 2
336 712d16a commit b 2
337
337
338 Test obsolete markers creation:
338 Test obsolete markers creation:
339
339
340 $ cat >> $HGRCPATH << EOF
340 $ cat >> $HGRCPATH << EOF
341 > [experimental]
341 > [experimental]
342 > evolution=createmarkers
342 > evolution=createmarkers
343 > [absorb]
343 > [absorb]
344 > add-noise=1
344 > add-noise=1
345 > EOF
345 > EOF
346
346
347 $ hg --config absorb.max-stack-size=3 absorb -a
347 $ hg --config absorb.max-stack-size=3 absorb -a
348 absorb: only the recent 3 changesets will be analysed
348 absorb: only the recent 3 changesets will be analysed
349 2 of 2 chunk(s) applied
349 2 of 2 chunk(s) applied
350 $ hg log -T '{rev}:{node|short} {desc} {get(extras, "absorb_source")}\n'
350 $ hg log -T '{rev}:{node|short} {desc} {get(extras, "absorb_source")}\n'
351 6:3dfde4199b46 commit b 2 712d16a8f445834e36145408eabc1d29df05ec09
351 6:3dfde4199b46 commit b 2 712d16a8f445834e36145408eabc1d29df05ec09
352 5:99cfab7da5ff commit b 1 74cfa6294160149d60adbf7582b99ce37a4597ec
352 5:99cfab7da5ff commit b 1 74cfa6294160149d60adbf7582b99ce37a4597ec
353 4:fec2b3bd9e08 commit a 2 28f10dcf96158f84985358a2e5d5b3505ca69c22
353 4:fec2b3bd9e08 commit a 2 28f10dcf96158f84985358a2e5d5b3505ca69c22
354 0:f9a81da8dc53 commit a 1
354 0:f9a81da8dc53 commit a 1
355 $ hg absorb --apply-changes
355 $ hg absorb --apply-changes
356 1 of 1 chunk(s) applied
356 1 of 1 chunk(s) applied
357 $ hg log -T '{rev}:{node|short} {desc} {get(extras, "absorb_source")}\n'
357 $ hg log -T '{rev}:{node|short} {desc} {get(extras, "absorb_source")}\n'
358 10:e1c8c1e030a4 commit b 2 3dfde4199b4610ea6e3c6fa9f5bdad8939d69524
358 10:e1c8c1e030a4 commit b 2 3dfde4199b4610ea6e3c6fa9f5bdad8939d69524
359 9:816c30955758 commit b 1 99cfab7da5ffdaf3b9fc6643b14333e194d87f46
359 9:816c30955758 commit b 1 99cfab7da5ffdaf3b9fc6643b14333e194d87f46
360 8:5867d584106b commit a 2 fec2b3bd9e0834b7cb6a564348a0058171aed811
360 8:5867d584106b commit a 2 fec2b3bd9e0834b7cb6a564348a0058171aed811
361 7:8c76602baf10 commit a 1 f9a81da8dc53380ed91902e5b82c1b36255a4bd0
361 7:8c76602baf10 commit a 1 f9a81da8dc53380ed91902e5b82c1b36255a4bd0
362
362
363 Executable files:
363 Executable files:
364
364
365 $ cat >> $HGRCPATH << EOF
365 $ cat >> $HGRCPATH << EOF
366 > [diff]
366 > [diff]
367 > git=True
367 > git=True
368 > EOF
368 > EOF
369 $ cd ..
369 $ cd ..
370 $ hg init repo3
370 $ hg init repo3
371 $ cd repo3
371 $ cd repo3
372
372
373 #if execbit
373 #if execbit
374 $ echo > foo.py
374 $ echo > foo.py
375 $ chmod +x foo.py
375 $ chmod +x foo.py
376 $ hg add foo.py
376 $ hg add foo.py
377 $ hg commit -mfoo
377 $ hg commit -mfoo
378 #else
378 #else
379 $ hg import -q --bypass - <<EOF
379 $ hg import -q --bypass - <<EOF
380 > # HG changeset patch
380 > # HG changeset patch
381 > foo
381 > foo
382 >
382 >
383 > diff --git a/foo.py b/foo.py
383 > diff --git a/foo.py b/foo.py
384 > new file mode 100755
384 > new file mode 100755
385 > --- /dev/null
385 > --- /dev/null
386 > +++ b/foo.py
386 > +++ b/foo.py
387 > @@ -0,0 +1,1 @@
387 > @@ -0,0 +1,1 @@
388 > +
388 > +
389 > EOF
389 > EOF
390 $ hg up -q
390 $ hg up -q
391 #endif
391 #endif
392
392
393 $ echo bla > foo.py
393 $ echo bla > foo.py
394 $ hg absorb --dry-run --print-changes
394 $ hg absorb --dry-run --print-changes
395 showing changes for foo.py
395 showing changes for foo.py
396 @@ -0,1 +0,1 @@
396 @@ -0,1 +0,1 @@
397 99b4ae7 -
397 99b4ae7 -
398 99b4ae7 +bla
398 99b4ae7 +bla
399
399
400 1 changesets affected
400 1 changesets affected
401 99b4ae7 foo
401 99b4ae7 foo
402 $ hg absorb --dry-run --interactive --print-changes
402 $ hg absorb --dry-run --interactive --print-changes
403 diff -r 99b4ae712f84 foo.py
403 diff -r 99b4ae712f84 foo.py
404 1 hunks, 1 lines changed
404 1 hunks, 1 lines changed
405 examine changes to 'foo.py'?
405 examine changes to 'foo.py'?
406 (enter ? for help) [Ynesfdaq?] y
406 (enter ? for help) [Ynesfdaq?] y
407
407
408 @@ -1,1 +1,1 @@
408 @@ -1,1 +1,1 @@
409 -
409 -
410 +bla
410 +bla
411 record this change to 'foo.py'?
411 record this change to 'foo.py'?
412 (enter ? for help) [Ynesfdaq?] y
412 (enter ? for help) [Ynesfdaq?] y
413
413
414 showing changes for foo.py
414 showing changes for foo.py
415 @@ -0,1 +0,1 @@
415 @@ -0,1 +0,1 @@
416 99b4ae7 -
416 99b4ae7 -
417 99b4ae7 +bla
417 99b4ae7 +bla
418
418
419 1 changesets affected
419 1 changesets affected
420 99b4ae7 foo
420 99b4ae7 foo
421 $ hg absorb --apply-changes
421 $ hg absorb --apply-changes
422 1 of 1 chunk(s) applied
422 1 of 1 chunk(s) applied
423 $ hg diff -c .
423 $ hg diff -c .
424 diff --git a/foo.py b/foo.py
424 diff --git a/foo.py b/foo.py
425 new file mode 100755
425 new file mode 100755
426 --- /dev/null
426 --- /dev/null
427 +++ b/foo.py
427 +++ b/foo.py
428 @@ -0,0 +1,1 @@
428 @@ -0,0 +1,1 @@
429 +bla
429 +bla
430 $ hg diff
430 $ hg diff
431
431
432 Remove lines may delete changesets:
432 Remove lines may delete changesets:
433
433
434 $ cd ..
434 $ cd ..
435 $ hg init repo4
435 $ hg init repo4
436 $ cd repo4
436 $ cd repo4
437 $ cat > a <<EOF
437 $ cat > a <<EOF
438 > 1
438 > 1
439 > 2
439 > 2
440 > EOF
440 > EOF
441 $ hg commit -m a12 -A a
441 $ hg commit -m a12 -A a
442 $ cat > b <<EOF
442 $ cat > b <<EOF
443 > 1
443 > 1
444 > 2
444 > 2
445 > EOF
445 > EOF
446 $ hg commit -m b12 -A b
446 $ hg commit -m b12 -A b
447 $ echo 3 >> b
447 $ echo 3 >> b
448 $ hg commit -m b3
448 $ hg commit -m b3
449 $ echo 4 >> b
449 $ echo 4 >> b
450 $ hg commit -m b4
450 $ hg commit -m b4
451 $ echo 1 > b
451 $ echo 1 > b
452 $ echo 3 >> a
452 $ echo 3 >> a
453 $ hg absorb -pn
453 $ hg absorb -pn
454 showing changes for a
454 showing changes for a
455 @@ -2,0 +2,1 @@
455 @@ -2,0 +2,1 @@
456 bfafb49 +3
456 bfafb49 +3
457 showing changes for b
457 showing changes for b
458 @@ -1,3 +1,0 @@
458 @@ -1,3 +1,0 @@
459 1154859 -2
459 1154859 -2
460 30970db -3
460 30970db -3
461 a393a58 -4
461 a393a58 -4
462
462
463 4 changesets affected
463 4 changesets affected
464 a393a58 b4
464 a393a58 b4
465 30970db b3
465 30970db b3
466 1154859 b12
466 1154859 b12
467 bfafb49 a12
467 bfafb49 a12
468 $ hg absorb -av | grep became
468 $ hg absorb -av | grep became
469 0:bfafb49242db: 1 file(s) changed, became 4:1a2de97fc652
469 0:bfafb49242db: 1 file(s) changed, became 4:1a2de97fc652
470 1:115485984805: 2 file(s) changed, became 5:0c930dfab74c
470 1:115485984805: 2 file(s) changed, became 5:0c930dfab74c
471 2:30970dbf7b40: became empty and was dropped
471 2:30970dbf7b40: became empty and was dropped
472 3:a393a58b9a85: became empty and was dropped
472 3:a393a58b9a85: became empty and was dropped
473 $ hg log -T '{rev} {desc}\n' -Gp
473 $ hg log -T '{rev} {desc}\n' -Gp
474 @ 5 b12
474 @ 5 b12
475 | diff --git a/b b/b
475 | diff --git a/b b/b
476 | new file mode 100644
476 | new file mode 100644
477 | --- /dev/null
477 | --- /dev/null
478 | +++ b/b
478 | +++ b/b
479 | @@ -0,0 +1,1 @@
479 | @@ -0,0 +1,1 @@
480 | +1
480 | +1
481 |
481 |
482 o 4 a12
482 o 4 a12
483 diff --git a/a b/a
483 diff --git a/a b/a
484 new file mode 100644
484 new file mode 100644
485 --- /dev/null
485 --- /dev/null
486 +++ b/a
486 +++ b/a
487 @@ -0,0 +1,3 @@
487 @@ -0,0 +1,3 @@
488 +1
488 +1
489 +2
489 +2
490 +3
490 +3
491
491
492
492
493 Setting config rewrite.empty-successor=keep causes empty changesets to get committed:
494
495 $ cd ..
496 $ hg init repo4a
497 $ cd repo4a
498 $ cat > a <<EOF
499 > 1
500 > 2
501 > EOF
502 $ hg commit -m a12 -A a
503 $ cat > b <<EOF
504 > 1
505 > 2
506 > EOF
507 $ hg commit -m b12 -A b
508 $ echo 3 >> b
509 $ hg commit -m b3
510 $ echo 4 >> b
511 $ hg commit -m b4
512 $ echo 1 > b
513 $ echo 3 >> a
514 $ hg absorb -pn
515 showing changes for a
516 @@ -2,0 +2,1 @@
517 bfafb49 +3
518 showing changes for b
519 @@ -1,3 +1,0 @@
520 1154859 -2
521 30970db -3
522 a393a58 -4
523
524 4 changesets affected
525 a393a58 b4
526 30970db b3
527 1154859 b12
528 bfafb49 a12
529 $ hg absorb -av --config rewrite.empty-successor=keep | grep became
530 0:bfafb49242db: 1 file(s) changed, became 4:1a2de97fc652
531 1:115485984805: 2 file(s) changed, became 5:0c930dfab74c
532 2:30970dbf7b40: 2 file(s) changed, became 6:df6574ae635c
533 3:a393a58b9a85: 2 file(s) changed, became 7:ad4bd3462c9e
534 $ hg log -T '{rev} {desc}\n' -Gp
535 @ 7 b4
536 |
537 o 6 b3
538 |
539 o 5 b12
540 | diff --git a/b b/b
541 | new file mode 100644
542 | --- /dev/null
543 | +++ b/b
544 | @@ -0,0 +1,1 @@
545 | +1
546 |
547 o 4 a12
548 diff --git a/a b/a
549 new file mode 100644
550 --- /dev/null
551 +++ b/a
552 @@ -0,0 +1,3 @@
553 +1
554 +2
555 +3
556
557
493 Use revert to make the current change and its parent disappear.
558 Use revert to make the current change and its parent disappear.
494 This should move us to the non-obsolete ancestor.
559 This should move us to the non-obsolete ancestor.
495
560
496 $ cd ..
561 $ cd ..
497 $ hg init repo5
562 $ hg init repo5
498 $ cd repo5
563 $ cd repo5
499 $ cat > a <<EOF
564 $ cat > a <<EOF
500 > 1
565 > 1
501 > 2
566 > 2
502 > EOF
567 > EOF
503 $ hg commit -m a12 -A a
568 $ hg commit -m a12 -A a
504 $ hg id
569 $ hg id
505 bfafb49242db tip
570 bfafb49242db tip
506 $ echo 3 >> a
571 $ echo 3 >> a
507 $ hg commit -m a123 a
572 $ hg commit -m a123 a
508 $ echo 4 >> a
573 $ echo 4 >> a
509 $ hg commit -m a1234 a
574 $ hg commit -m a1234 a
510 $ hg id
575 $ hg id
511 82dbe7fd19f0 tip
576 82dbe7fd19f0 tip
512 $ hg revert -r 0 a
577 $ hg revert -r 0 a
513 $ hg absorb -pn
578 $ hg absorb -pn
514 showing changes for a
579 showing changes for a
515 @@ -2,2 +2,0 @@
580 @@ -2,2 +2,0 @@
516 f1c23dd -3
581 f1c23dd -3
517 82dbe7f -4
582 82dbe7f -4
518
583
519 2 changesets affected
584 2 changesets affected
520 82dbe7f a1234
585 82dbe7f a1234
521 f1c23dd a123
586 f1c23dd a123
522 $ hg absorb --apply-changes --verbose
587 $ hg absorb --apply-changes --verbose
523 1:f1c23dd5d08d: became empty and was dropped
588 1:f1c23dd5d08d: became empty and was dropped
524 2:82dbe7fd19f0: became empty and was dropped
589 2:82dbe7fd19f0: became empty and was dropped
525 a: 1 of 1 chunk(s) applied
590 a: 1 of 1 chunk(s) applied
526 $ hg id
591 $ hg id
527 bfafb49242db tip
592 bfafb49242db tip
528
593
529 $ cd ..
594 $ cd ..
530 $ hg init repo6
595 $ hg init repo6
531 $ cd repo6
596 $ cd repo6
532 $ echo a1 > a
597 $ echo a1 > a
533 $ touch b
598 $ touch b
534 $ hg commit -m a -A a b
599 $ hg commit -m a -A a b
535 $ hg branch foo -q
600 $ hg branch foo -q
536 $ echo b > b
601 $ echo b > b
537 $ hg commit -m foo # will become empty
602 $ hg commit -m foo # will become empty
538 $ hg branch bar -q
603 $ hg branch bar -q
539 $ hg commit -m bar # is already empty
604 $ hg commit -m bar # is already empty
540 $ echo a2 > a
605 $ echo a2 > a
541 $ printf '' > b
606 $ printf '' > b
542 $ hg absorb --apply-changes --verbose | grep became
607 $ hg absorb --apply-changes --verbose | grep became
543 0:0cde1ae39321: 1 file(s) changed, became 3:fc7fcdd90fdb
608 0:0cde1ae39321: 1 file(s) changed, became 3:fc7fcdd90fdb
544 1:795dfb1adcef: 2 file(s) changed, became 4:a8740537aa53
609 1:795dfb1adcef: 2 file(s) changed, became 4:a8740537aa53
545 2:b02935f68891: 2 file(s) changed, became 5:59533e01c707
610 2:b02935f68891: 2 file(s) changed, became 5:59533e01c707
546 $ hg log -T '{rev} (branch: {branch}) {desc}\n' -G --stat
611 $ hg log -T '{rev} (branch: {branch}) {desc}\n' -G --stat
547 @ 5 (branch: bar) bar
612 @ 5 (branch: bar) bar
548 |
613 |
549 o 4 (branch: foo) foo
614 o 4 (branch: foo) foo
550 |
615 |
551 o 3 (branch: default) a
616 o 3 (branch: default) a
552 a | 1 +
617 a | 1 +
553 b | 0
618 b | 0
554 2 files changed, 1 insertions(+), 0 deletions(-)
619 2 files changed, 1 insertions(+), 0 deletions(-)
555
620
556
621
557 $ cd ..
622 $ cd ..
558 $ hg init repo7
623 $ hg init repo7
559 $ cd repo7
624 $ cd repo7
560 $ echo a1 > a
625 $ echo a1 > a
561 $ touch b
626 $ touch b
562 $ hg commit -m a -A a b
627 $ hg commit -m a -A a b
563 $ echo b > b
628 $ echo b > b
564 $ hg commit -m foo --close-branch # will become empty
629 $ hg commit -m foo --close-branch # will become empty
565 $ echo c > c
630 $ echo c > c
566 $ hg commit -m reopen -A c -q
631 $ hg commit -m reopen -A c -q
567 $ hg commit -m bar --close-branch # is already empty
632 $ hg commit -m bar --close-branch # is already empty
568 $ echo a2 > a
633 $ echo a2 > a
569 $ printf '' > b
634 $ printf '' > b
570 $ hg absorb --apply-changes --verbose | grep became
635 $ hg absorb --apply-changes --verbose | grep became
571 0:0cde1ae39321: 1 file(s) changed, became 4:fc7fcdd90fdb
636 0:0cde1ae39321: 1 file(s) changed, became 4:fc7fcdd90fdb
572 1:651b953d5764: 2 file(s) changed, became 5:0c9de988ecdc
637 1:651b953d5764: 2 file(s) changed, became 5:0c9de988ecdc
573 2:76017bba73f6: 2 file(s) changed, became 6:d53ac896eb25
638 2:76017bba73f6: 2 file(s) changed, became 6:d53ac896eb25
574 3:c7c1d67efc1d: 2 file(s) changed, became 7:66520267fe96
639 3:c7c1d67efc1d: 2 file(s) changed, became 7:66520267fe96
575 $ hg up null -q # to make visible closed heads
640 $ hg up null -q # to make visible closed heads
576 $ hg log -T '{rev} {desc}\n' -G --stat
641 $ hg log -T '{rev} {desc}\n' -G --stat
577 _ 7 bar
642 _ 7 bar
578 |
643 |
579 o 6 reopen
644 o 6 reopen
580 | c | 1 +
645 | c | 1 +
581 | 1 files changed, 1 insertions(+), 0 deletions(-)
646 | 1 files changed, 1 insertions(+), 0 deletions(-)
582 |
647 |
583 _ 5 foo
648 _ 5 foo
584 |
649 |
585 o 4 a
650 o 4 a
586 a | 1 +
651 a | 1 +
587 b | 0
652 b | 0
588 2 files changed, 1 insertions(+), 0 deletions(-)
653 2 files changed, 1 insertions(+), 0 deletions(-)
589
654
590
655
591 $ cd ..
656 $ cd ..
592 $ hg init repo8
657 $ hg init repo8
593 $ cd repo8
658 $ cd repo8
594 $ echo a1 > a
659 $ echo a1 > a
595 $ hg commit -m a -A a
660 $ hg commit -m a -A a
596 $ hg commit -m empty --config ui.allowemptycommit=True
661 $ hg commit -m empty --config ui.allowemptycommit=True
597 $ echo a2 > a
662 $ echo a2 > a
598 $ hg absorb --apply-changes --verbose | grep became
663 $ hg absorb --apply-changes --verbose | grep became
599 0:ecf99a8d6699: 1 file(s) changed, became 2:7e3ccf8e2fa5
664 0:ecf99a8d6699: 1 file(s) changed, became 2:7e3ccf8e2fa5
600 1:97f72456ae0d: 1 file(s) changed, became 3:2df488325d6f
665 1:97f72456ae0d: 1 file(s) changed, became 3:2df488325d6f
601 $ hg log -T '{rev} {desc}\n' -G --stat
666 $ hg log -T '{rev} {desc}\n' -G --stat
602 @ 3 empty
667 @ 3 empty
603 |
668 |
604 o 2 a
669 o 2 a
605 a | 1 +
670 a | 1 +
606 1 files changed, 1 insertions(+), 0 deletions(-)
671 1 files changed, 1 insertions(+), 0 deletions(-)
607
672
General Comments 0
You need to be logged in to leave comments. Login now