##// END OF EJS Templates
help: remove last occurrences of ".. note::" without two newlines...
Simon Heimberg -
r20532:f1a3ae7c default
parent child Browse files
Show More
@@ -1,558 +1,559 b''
1 1 #!/usr/bin/env python
2 2 #
3 3 # check-code - a style and portability checker for Mercurial
4 4 #
5 5 # Copyright 2010 Matt Mackall <mpm@selenic.com>
6 6 #
7 7 # This software may be used and distributed according to the terms of the
8 8 # GNU General Public License version 2 or any later version.
9 9
10 10 """style and portability checker for Mercurial
11 11
12 12 when a rule triggers wrong, do one of the following (prefer one from top):
13 13 * do the work-around the rule suggests
14 14 * doublecheck that it is a false match
15 15 * improve the rule pattern
16 16 * add an ignore pattern to the rule (3rd arg) which matches your good line
17 17 (you can append a short comment and match this, like: #re-raises, # no-py24)
18 18 * change the pattern to a warning and list the exception in test-check-code-hg
19 19 * ONLY use no--check-code for skipping entire files from external sources
20 20 """
21 21
22 22 import re, glob, os, sys
23 23 import keyword
24 24 import optparse
25 25 try:
26 26 import re2
27 27 except ImportError:
28 28 re2 = None
29 29
30 30 def compilere(pat, multiline=False):
31 31 if multiline:
32 32 pat = '(?m)' + pat
33 33 if re2:
34 34 try:
35 35 return re2.compile(pat)
36 36 except re2.error:
37 37 pass
38 38 return re.compile(pat)
39 39
40 40 def repquote(m):
41 41 fromc = '.:'
42 42 tochr = 'pq'
43 43 def encodechr(i):
44 44 if i > 255:
45 45 return 'u'
46 46 c = chr(i)
47 47 if c in ' \n':
48 48 return c
49 49 if c.isalpha():
50 50 return 'x'
51 51 if c.isdigit():
52 52 return 'n'
53 53 try:
54 54 return tochr[fromc.find(c)]
55 55 except (ValueError, IndexError):
56 56 return 'o'
57 57 t = m.group('text')
58 58 tt = ''.join(encodechr(i) for i in xrange(256))
59 59 t = t.translate(tt)
60 60 return m.group('quote') + t + m.group('quote')
61 61
62 62 def reppython(m):
63 63 comment = m.group('comment')
64 64 if comment:
65 65 l = len(comment.rstrip())
66 66 return "#" * l + comment[l:]
67 67 return repquote(m)
68 68
69 69 def repcomment(m):
70 70 return m.group(1) + "#" * len(m.group(2))
71 71
72 72 def repccomment(m):
73 73 t = re.sub(r"((?<=\n) )|\S", "x", m.group(2))
74 74 return m.group(1) + t + "*/"
75 75
76 76 def repcallspaces(m):
77 77 t = re.sub(r"\n\s+", "\n", m.group(2))
78 78 return m.group(1) + t
79 79
80 80 def repinclude(m):
81 81 return m.group(1) + "<foo>"
82 82
83 83 def rephere(m):
84 84 t = re.sub(r"\S", "x", m.group(2))
85 85 return m.group(1) + t
86 86
87 87
88 88 testpats = [
89 89 [
90 90 (r'pushd|popd', "don't use 'pushd' or 'popd', use 'cd'"),
91 91 (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
92 92 (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
93 93 (r'(?<!hg )grep.*-a', "don't use 'grep -a', use in-line python"),
94 94 (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
95 95 (r'\becho\b.*\\n', "don't use 'echo \\n', use printf"),
96 96 (r'echo -n', "don't use 'echo -n', use printf"),
97 97 (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"),
98 98 (r'head -c', "don't use 'head -c', use 'dd'"),
99 99 (r'tail -n', "don't use the '-n' option to tail, just use '-<num>'"),
100 100 (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
101 101 (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
102 102 (r'printf.*[^\\]\\([1-9]|0\d)', "don't use 'printf \NNN', use Python"),
103 103 (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"),
104 104 (r'\$\(.*\)', "don't use $(expr), use `expr`"),
105 105 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
106 106 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
107 107 "use egrep for extended grep syntax"),
108 108 (r'/bin/', "don't use explicit paths for tools"),
109 109 (r'[^\n]\Z', "no trailing newline"),
110 110 (r'export.*=', "don't export and assign at once"),
111 111 (r'^source\b', "don't use 'source', use '.'"),
112 112 (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
113 113 (r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),
114 114 (r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
115 115 (r'^stop\(\)', "don't use 'stop' as a shell function name"),
116 116 (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
117 117 (r'^alias\b.*=', "don't use alias, use a function"),
118 118 (r'if\s*!', "don't use '!' to negate exit status"),
119 119 (r'/dev/u?random', "don't use entropy, use /dev/zero"),
120 120 (r'do\s*true;\s*done', "don't use true as loop body, use sleep 0"),
121 121 (r'^( *)\t', "don't use tabs to indent"),
122 122 (r'sed (-e )?\'(\d+|/[^/]*/)i(?!\\\n)',
123 123 "put a backslash-escaped newline after sed 'i' command"),
124 124 ],
125 125 # warnings
126 126 [
127 127 (r'^function', "don't use 'function', use old style"),
128 128 (r'^diff.*-\w*N', "don't use 'diff -N'"),
129 129 (r'\$PWD|\${PWD}', "don't use $PWD, use `pwd`"),
130 130 (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\^', "^ must be quoted"),
131 131 (r'kill (`|\$\()', "don't use kill, use killdaemons.py")
132 132 ]
133 133 ]
134 134
135 135 testfilters = [
136 136 (r"( *)(#([^\n]*\S)?)", repcomment),
137 137 (r"<<(\S+)((.|\n)*?\n\1)", rephere),
138 138 ]
139 139
140 140 winglobmsg = "use (glob) to match Windows paths too"
141 141 uprefix = r"^ \$ "
142 142 utestpats = [
143 143 [
144 144 (r'^(\S.*|| [$>] .*)[ \t]\n', "trailing whitespace on non-output"),
145 145 (uprefix + r'.*\|\s*sed[^|>\n]*\n',
146 146 "use regex test output patterns instead of sed"),
147 147 (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
148 148 (uprefix + r'.*(?<!\[)\$\?', "explicit exit code checks unnecessary"),
149 149 (uprefix + r'.*\|\| echo.*(fail|error)',
150 150 "explicit exit code checks unnecessary"),
151 151 (uprefix + r'set -e', "don't use set -e"),
152 152 (uprefix + r'(\s|fi\b|done\b)', "use > for continued lines"),
153 153 (uprefix + r'.*:\.\S*/', "x:.y in a path does not work on msys, rewrite "
154 154 "as x://.y, or see `hg log -k msys` for alternatives", r'-\S+:\.|' #-Rxxx
155 155 'hg pull -q file:../test'), # in test-pull.t which is skipped on windows
156 156 (r'^ saved backup bundle to \$TESTTMP.*\.hg$', winglobmsg),
157 157 (r'^ changeset .* references (corrupted|missing) \$TESTTMP/.*[^)]$',
158 158 winglobmsg),
159 159 (r'^ pulling from \$TESTTMP/.*[^)]$', winglobmsg,
160 160 '\$TESTTMP/unix-repo$'), # in test-issue1802.t which skipped on windows
161 161 (r'^ reverting .*/.*[^)]$', winglobmsg),
162 162 (r'^ cloning subrepo \S+/.*[^)]$', winglobmsg),
163 163 (r'^ pushing to \$TESTTMP/.*[^)]$', winglobmsg),
164 164 (r'^ pushing subrepo \S+/\S+ to.*[^)]$', winglobmsg),
165 165 (r'^ moving \S+/.*[^)]$', winglobmsg),
166 166 (r'^ no changes made to subrepo since.*/.*[^)]$', winglobmsg),
167 167 (r'^ .*: largefile \S+ not available from file:.*/.*[^)]$', winglobmsg),
168 168 (r'^ .*file://\$TESTTMP',
169 169 'write "file:/*/$TESTTMP" + (glob) to match on windows too'),
170 170 ],
171 171 # warnings
172 172 [
173 173 (r'^ [^*?/\n]* \(glob\)$',
174 174 "glob match with no glob character (?*/)"),
175 175 ]
176 176 ]
177 177
178 178 for i in [0, 1]:
179 179 for p, m in testpats[i]:
180 180 if p.startswith(r'^'):
181 181 p = r"^ [$>] (%s)" % p[1:]
182 182 else:
183 183 p = r"^ [$>] .*(%s)" % p
184 184 utestpats[i].append((p, m))
185 185
186 186 utestfilters = [
187 187 (r"<<(\S+)((.|\n)*?\n > \1)", rephere),
188 188 (r"( *)(#([^\n]*\S)?)", repcomment),
189 189 ]
190 190
191 191 pypats = [
192 192 [
193 193 (r'^\s*def\s*\w+\s*\(.*,\s*\(',
194 194 "tuple parameter unpacking not available in Python 3+"),
195 195 (r'lambda\s*\(.*,.*\)',
196 196 "tuple parameter unpacking not available in Python 3+"),
197 197 (r'import (.+,[^.]+\.[^.]+|[^.]+\.[^.]+,)',
198 198 '2to3 can\'t always rewrite "import qux, foo.bar", '
199 199 'use "import foo.bar" on its own line instead.'),
200 200 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
201 201 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
202 202 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
203 203 (r'\s<>\s', '<> operator is not available in Python 3+, use !='),
204 204 (r'^\s*\t', "don't use tabs"),
205 205 (r'\S;\s*\n', "semicolon"),
206 206 (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),
207 207 (r"[^_]_\('[^']+'\s*%", "don't use % inside _()"),
208 208 (r'(\w|\)),\w', "missing whitespace after ,"),
209 209 (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"),
210 210 (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
211 211 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
212 212 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Python 2.4'),
213 213 (r'(?<!def)(\s+|^|\()next\(.+\)',
214 214 'no next(foo) in Python 2.4 and 2.5, use foo.next() instead'),
215 215 (r'(\s+)try:\n((?:\n|\1\s.*\n)*?)\1\s*yield\b.*?'
216 216 r'((?:\n|\1\s.*\n)+?)\1finally:',
217 217 'no yield inside try/finally in Python 2.4'),
218 218 (r'.{81}', "line too long"),
219 219 (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
220 220 (r'[^\n]\Z', "no trailing newline"),
221 221 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
222 222 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
223 223 # "don't use underbars in identifiers"),
224 224 (r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
225 225 "don't use camelcase in identifiers"),
226 226 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
227 227 "linebreak after :"),
228 228 (r'class\s[^( \n]+:', "old-style class, use class foo(object)"),
229 229 (r'class\s[^( \n]+\(\):',
230 230 "class foo() not available in Python 2.4, use class foo(object)"),
231 231 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
232 232 "Python keyword is not a function"),
233 233 (r',]', "unneeded trailing ',' in list"),
234 234 # (r'class\s[A-Z][^\(]*\((?!Exception)',
235 235 # "don't capitalize non-exception classes"),
236 236 # (r'in range\(', "use xrange"),
237 237 # (r'^\s*print\s+', "avoid using print in core and extensions"),
238 238 (r'[\x80-\xff]', "non-ASCII character literal"),
239 239 (r'("\')\.format\(', "str.format() not available in Python 2.4"),
240 240 (r'^\s*with\s+', "with not available in Python 2.4"),
241 241 (r'\.isdisjoint\(', "set.isdisjoint not available in Python 2.4"),
242 242 (r'^\s*except.* as .*:', "except as not available in Python 2.4"),
243 243 (r'^\s*os\.path\.relpath', "relpath not available in Python 2.4"),
244 244 (r'(?<!def)\s+(any|all|format)\(',
245 245 "any/all/format not available in Python 2.4", 'no-py24'),
246 246 (r'(?<!def)\s+(callable)\(',
247 247 "callable not available in Python 3, use getattr(f, '__call__', None)"),
248 248 (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
249 249 (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist),
250 250 "gratuitous whitespace after Python keyword"),
251 251 (r'([\(\[][ \t]\S)|(\S[ \t][\)\]])', "gratuitous whitespace in () or []"),
252 252 # (r'\s\s=', "gratuitous whitespace before ="),
253 253 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=|%=)\S',
254 254 "missing whitespace around operator"),
255 255 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=|%=)\s',
256 256 "missing whitespace around operator"),
257 257 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=|%=)\S',
258 258 "missing whitespace around operator"),
259 259 (r'[^^+=*/!<>&| %-](\s=|=\s)[^= ]',
260 260 "wrong whitespace around ="),
261 261 (r'\([^()]*( =[^=]|[^<>!=]= )',
262 262 "no whitespace around = for named parameters"),
263 263 (r'raise Exception', "don't raise generic exceptions"),
264 264 (r'raise [^,(]+, (\([^\)]+\)|[^,\(\)]+)$',
265 265 "don't use old-style two-argument raise, use Exception(message)"),
266 266 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
267 267 (r' [=!]=\s+(True|False|None)',
268 268 "comparison with singleton, use 'is' or 'is not' instead"),
269 269 (r'^\s*(while|if) [01]:',
270 270 "use True/False for constant Boolean expression"),
271 271 (r'(?:(?<!def)\s+|\()hasattr',
272 272 'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'),
273 273 (r'opener\([^)]*\).read\(',
274 274 "use opener.read() instead"),
275 275 (r'BaseException', 'not in Python 2.4, use Exception'),
276 276 (r'os\.path\.relpath', 'os.path.relpath is not in Python 2.5'),
277 277 (r'opener\([^)]*\).write\(',
278 278 "use opener.write() instead"),
279 279 (r'[\s\(](open|file)\([^)]*\)\.read\(',
280 280 "use util.readfile() instead"),
281 281 (r'[\s\(](open|file)\([^)]*\)\.write\(',
282 282 "use util.writefile() instead"),
283 283 (r'^[\s\(]*(open(er)?|file)\([^)]*\)',
284 284 "always assign an opened file to a variable, and close it afterwards"),
285 285 (r'[\s\(](open|file)\([^)]*\)\.',
286 286 "always assign an opened file to a variable, and close it afterwards"),
287 287 (r'(?i)descendent', "the proper spelling is descendAnt"),
288 288 (r'\.debug\(\_', "don't mark debug messages for translation"),
289 289 (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
290 290 (r'^\s*except\s*:', "naked except clause", r'#.*re-raises'),
291 291 (r':\n( )*( ){1,3}[^ ]', "must indent 4 spaces"),
292 292 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
293 293 "missing _() in ui message (use () to hide false-positives)"),
294 294 (r'release\(.*wlock, .*lock\)', "wrong lock release order"),
295 295 ],
296 296 # warnings
297 297 [
298 298 (r'(^| )pp +xxxxqq[ \n][^\n]', "add two newlines after '.. note::'"),
299 299 ]
300 300 ]
301 301
302 302 pyfilters = [
303 303 (r"""(?msx)(?P<comment>\#.*?$)|
304 304 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
305 305 (?P<text>(([^\\]|\\.)*?))
306 306 (?P=quote))""", reppython),
307 307 ]
308 308
309 309 txtfilters = []
310 310
311 311 txtpats = [
312 312 [
313 313 ('\s$', 'trailing whitespace'),
314 ('.. note::[ \n][^\n]', 'add two newlines after note::')
314 315 ],
315 316 []
316 317 ]
317 318
318 319 cpats = [
319 320 [
320 321 (r'//', "don't use //-style comments"),
321 322 (r'^ ', "don't use spaces to indent"),
322 323 (r'\S\t', "don't use tabs except for indent"),
323 324 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
324 325 (r'.{81}', "line too long"),
325 326 (r'(while|if|do|for)\(', "use space after while/if/do/for"),
326 327 (r'return\(', "return is not a function"),
327 328 (r' ;', "no space before ;"),
328 329 (r'[)][{]', "space between ) and {"),
329 330 (r'\w+\* \w+', "use int *foo, not int* foo"),
330 331 (r'\W\([^\)]+\) \w+', "use (int)foo, not (int) foo"),
331 332 (r'\w+ (\+\+|--)', "use foo++, not foo ++"),
332 333 (r'\w,\w', "missing whitespace after ,"),
333 334 (r'^[^#]\w[+/*]\w', "missing whitespace in expression"),
334 335 (r'^#\s+\w', "use #foo, not # foo"),
335 336 (r'[^\n]\Z', "no trailing newline"),
336 337 (r'^\s*#import\b', "use only #include in standard C code"),
337 338 ],
338 339 # warnings
339 340 []
340 341 ]
341 342
342 343 cfilters = [
343 344 (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment),
344 345 (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote),
345 346 (r'''(#\s*include\s+<)([^>]+)>''', repinclude),
346 347 (r'(\()([^)]+\))', repcallspaces),
347 348 ]
348 349
349 350 inutilpats = [
350 351 [
351 352 (r'\bui\.', "don't use ui in util"),
352 353 ],
353 354 # warnings
354 355 []
355 356 ]
356 357
357 358 inrevlogpats = [
358 359 [
359 360 (r'\brepo\.', "don't use repo in revlog"),
360 361 ],
361 362 # warnings
362 363 []
363 364 ]
364 365
365 366 checks = [
366 367 ('python', r'.*\.(py|cgi)$', pyfilters, pypats),
367 368 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats),
368 369 ('c', r'.*\.[ch]$', cfilters, cpats),
369 370 ('unified test', r'.*\.t$', utestfilters, utestpats),
370 371 ('layering violation repo in revlog', r'mercurial/revlog\.py', pyfilters,
371 372 inrevlogpats),
372 373 ('layering violation ui in util', r'mercurial/util\.py', pyfilters,
373 374 inutilpats),
374 375 ('txt', r'.*\.txt$', txtfilters, txtpats),
375 376 ]
376 377
377 378 def _preparepats():
378 379 for c in checks:
379 380 failandwarn = c[-1]
380 381 for pats in failandwarn:
381 382 for i, pseq in enumerate(pats):
382 383 # fix-up regexes for multi-line searches
383 384 p = pseq[0]
384 385 # \s doesn't match \n
385 386 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
386 387 # [^...] doesn't match newline
387 388 p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
388 389
389 390 pats[i] = (re.compile(p, re.MULTILINE),) + pseq[1:]
390 391 filters = c[2]
391 392 for i, flt in enumerate(filters):
392 393 filters[i] = re.compile(flt[0]), flt[1]
393 394 _preparepats()
394 395
395 396 class norepeatlogger(object):
396 397 def __init__(self):
397 398 self._lastseen = None
398 399
399 400 def log(self, fname, lineno, line, msg, blame):
400 401 """print error related a to given line of a given file.
401 402
402 403 The faulty line will also be printed but only once in the case
403 404 of multiple errors.
404 405
405 406 :fname: filename
406 407 :lineno: line number
407 408 :line: actual content of the line
408 409 :msg: error message
409 410 """
410 411 msgid = fname, lineno, line
411 412 if msgid != self._lastseen:
412 413 if blame:
413 414 print "%s:%d (%s):" % (fname, lineno, blame)
414 415 else:
415 416 print "%s:%d:" % (fname, lineno)
416 417 print " > %s" % line
417 418 self._lastseen = msgid
418 419 print " " + msg
419 420
420 421 _defaultlogger = norepeatlogger()
421 422
422 423 def getblame(f):
423 424 lines = []
424 425 for l in os.popen('hg annotate -un %s' % f):
425 426 start, line = l.split(':', 1)
426 427 user, rev = start.split()
427 428 lines.append((line[1:-1], user, rev))
428 429 return lines
429 430
430 431 def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False,
431 432 blame=False, debug=False, lineno=True):
432 433 """checks style and portability of a given file
433 434
434 435 :f: filepath
435 436 :logfunc: function used to report error
436 437 logfunc(filename, linenumber, linecontent, errormessage)
437 438 :maxerr: number of error to display before aborting.
438 439 Set to false (default) to report all errors
439 440
440 441 return True if no error is found, False otherwise.
441 442 """
442 443 blamecache = None
443 444 result = True
444 445 for name, match, filters, pats in checks:
445 446 if debug:
446 447 print name, f
447 448 fc = 0
448 449 if not re.match(match, f):
449 450 if debug:
450 451 print "Skipping %s for %s it doesn't match %s" % (
451 452 name, match, f)
452 453 continue
453 454 try:
454 455 fp = open(f)
455 456 except IOError, e:
456 457 print "Skipping %s, %s" % (f, str(e).split(':', 1)[0])
457 458 continue
458 459 pre = post = fp.read()
459 460 fp.close()
460 461 if "no-" "check-code" in pre:
461 462 print "Skipping %s it has no-" "check-code" % f
462 463 return "Skip" # skip checking this file
463 464 for p, r in filters:
464 465 post = re.sub(p, r, post)
465 466 nerrs = len(pats[0]) # nerr elements are errors
466 467 if warnings:
467 468 pats = pats[0] + pats[1]
468 469 else:
469 470 pats = pats[0]
470 471 # print post # uncomment to show filtered version
471 472
472 473 if debug:
473 474 print "Checking %s for %s" % (name, f)
474 475
475 476 prelines = None
476 477 errors = []
477 478 for i, pat in enumerate(pats):
478 479 if len(pat) == 3:
479 480 p, msg, ignore = pat
480 481 else:
481 482 p, msg = pat
482 483 ignore = None
483 484 if i >= nerrs:
484 485 msg = "warning: " + msg
485 486
486 487 pos = 0
487 488 n = 0
488 489 for m in p.finditer(post):
489 490 if prelines is None:
490 491 prelines = pre.splitlines()
491 492 postlines = post.splitlines(True)
492 493
493 494 start = m.start()
494 495 while n < len(postlines):
495 496 step = len(postlines[n])
496 497 if pos + step > start:
497 498 break
498 499 pos += step
499 500 n += 1
500 501 l = prelines[n]
501 502
502 503 if ignore and re.search(ignore, l, re.MULTILINE):
503 504 if debug:
504 505 print "Skipping %s for %s:%s (ignore pattern)" % (
505 506 name, f, n)
506 507 continue
507 508 bd = ""
508 509 if blame:
509 510 bd = 'working directory'
510 511 if not blamecache:
511 512 blamecache = getblame(f)
512 513 if n < len(blamecache):
513 514 bl, bu, br = blamecache[n]
514 515 if bl == l:
515 516 bd = '%s@%s' % (bu, br)
516 517
517 518 errors.append((f, lineno and n + 1, l, msg, bd))
518 519 result = False
519 520
520 521 errors.sort()
521 522 for e in errors:
522 523 logfunc(*e)
523 524 fc += 1
524 525 if maxerr and fc >= maxerr:
525 526 print " (too many errors, giving up)"
526 527 break
527 528
528 529 return result
529 530
530 531 if __name__ == "__main__":
531 532 parser = optparse.OptionParser("%prog [options] [files]")
532 533 parser.add_option("-w", "--warnings", action="store_true",
533 534 help="include warning-level checks")
534 535 parser.add_option("-p", "--per-file", type="int",
535 536 help="max warnings per file")
536 537 parser.add_option("-b", "--blame", action="store_true",
537 538 help="use annotate to generate blame info")
538 539 parser.add_option("", "--debug", action="store_true",
539 540 help="show debug information")
540 541 parser.add_option("", "--nolineno", action="store_false",
541 542 dest='lineno', help="don't show line numbers")
542 543
543 544 parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False,
544 545 lineno=True)
545 546 (options, args) = parser.parse_args()
546 547
547 548 if len(args) == 0:
548 549 check = glob.glob("*")
549 550 else:
550 551 check = args
551 552
552 553 ret = 0
553 554 for f in check:
554 555 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
555 556 blame=options.blame, debug=options.debug,
556 557 lineno=options.lineno):
557 558 ret = 1
558 559 sys.exit(ret)
@@ -1,1535 +1,1547 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 The configuration files use a simple ini-file format. A configuration
5 5 file consists of sections, led by a ``[section]`` header and followed
6 6 by ``name = value`` entries::
7 7
8 8 [ui]
9 9 username = Firstname Lastname <firstname.lastname@example.net>
10 10 verbose = True
11 11
12 12 The above entries will be referred to as ``ui.username`` and
13 13 ``ui.verbose``, respectively. See the Syntax section below.
14 14
15 15 Files
16 16 =====
17 17
18 18 Mercurial reads configuration data from several files, if they exist.
19 19 These files do not exist by default and you will have to create the
20 20 appropriate configuration files yourself: global configuration like
21 21 the username setting is typically put into
22 22 ``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local
23 23 configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
24 24
25 25 The names of these files depend on the system on which Mercurial is
26 26 installed. ``*.rc`` files from a single directory are read in
27 27 alphabetical order, later ones overriding earlier ones. Where multiple
28 28 paths are given below, settings from earlier paths override later
29 29 ones.
30 30
31 31 | (All) ``<repo>/.hg/hgrc``
32 32
33 33 Per-repository configuration options that only apply in a
34 34 particular repository. This file is not version-controlled, and
35 35 will not get transferred during a "clone" operation. Options in
36 36 this file override options in all other configuration files. On
37 37 Plan 9 and Unix, most of this file will be ignored if it doesn't
38 38 belong to a trusted user or to a trusted group. See the documentation
39 39 for the ``[trusted]`` section below for more details.
40 40
41 41 | (Plan 9) ``$home/lib/hgrc``
42 42 | (Unix) ``$HOME/.hgrc``
43 43 | (Windows) ``%USERPROFILE%\.hgrc``
44 44 | (Windows) ``%USERPROFILE%\Mercurial.ini``
45 45 | (Windows) ``%HOME%\.hgrc``
46 46 | (Windows) ``%HOME%\Mercurial.ini``
47 47
48 48 Per-user configuration file(s), for the user running Mercurial. On
49 49 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
50 50 files apply to all Mercurial commands executed by this user in any
51 51 directory. Options in these files override per-system and per-installation
52 52 options.
53 53
54 54 | (Plan 9) ``/lib/mercurial/hgrc``
55 55 | (Plan 9) ``/lib/mercurial/hgrc.d/*.rc``
56 56 | (Unix) ``/etc/mercurial/hgrc``
57 57 | (Unix) ``/etc/mercurial/hgrc.d/*.rc``
58 58
59 59 Per-system configuration files, for the system on which Mercurial
60 60 is running. Options in these files apply to all Mercurial commands
61 61 executed by any user in any directory. Options in these files
62 62 override per-installation options.
63 63
64 64 | (Plan 9) ``<install-root>/lib/mercurial/hgrc``
65 65 | (Plan 9) ``<install-root>/lib/mercurial/hgrc.d/*.rc``
66 66 | (Unix) ``<install-root>/etc/mercurial/hgrc``
67 67 | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc``
68 68
69 69 Per-installation configuration files, searched for in the
70 70 directory where Mercurial is installed. ``<install-root>`` is the
71 71 parent directory of the **hg** executable (or symlink) being run. For
72 72 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
73 73 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
74 74 to all Mercurial commands executed by any user in any directory.
75 75
76 76 | (Windows) ``<install-dir>\Mercurial.ini`` **or**
77 77 | (Windows) ``<install-dir>\hgrc.d\*.rc`` **or**
78 78 | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial``
79 79
80 80 Per-installation/system configuration files, for the system on
81 81 which Mercurial is running. Options in these files apply to all
82 82 Mercurial commands executed by any user in any directory. Registry
83 83 keys contain PATH-like strings, every part of which must reference
84 84 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
85 85 be read. Mercurial checks each of these locations in the specified
86 86 order until one or more configuration files are detected.
87 87
88 .. note:: The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
88 .. note::
89
90 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
89 91 is used when running 32-bit Python on 64-bit Windows.
90 92
91 93 Syntax
92 94 ======
93 95
94 96 A configuration file consists of sections, led by a ``[section]`` header
95 97 and followed by ``name = value`` entries (sometimes called
96 98 ``configuration keys``)::
97 99
98 100 [spam]
99 101 eggs=ham
100 102 green=
101 103 eggs
102 104
103 105 Each line contains one entry. If the lines that follow are indented,
104 106 they are treated as continuations of that entry. Leading whitespace is
105 107 removed from values. Empty lines are skipped. Lines beginning with
106 108 ``#`` or ``;`` are ignored and may be used to provide comments.
107 109
108 110 Configuration keys can be set multiple times, in which case Mercurial
109 111 will use the value that was configured last. As an example::
110 112
111 113 [spam]
112 114 eggs=large
113 115 ham=serrano
114 116 eggs=small
115 117
116 118 This would set the configuration key named ``eggs`` to ``small``.
117 119
118 120 It is also possible to define a section multiple times. A section can
119 121 be redefined on the same and/or on different configuration files. For
120 122 example::
121 123
122 124 [foo]
123 125 eggs=large
124 126 ham=serrano
125 127 eggs=small
126 128
127 129 [bar]
128 130 eggs=ham
129 131 green=
130 132 eggs
131 133
132 134 [foo]
133 135 ham=prosciutto
134 136 eggs=medium
135 137 bread=toasted
136 138
137 139 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
138 140 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
139 141 respectively. As you can see there only thing that matters is the last
140 142 value that was set for each of the configuration keys.
141 143
142 144 If a configuration key is set multiple times in different
143 145 configuration files the final value will depend on the order in which
144 146 the different configuration files are read, with settings from earlier
145 147 paths overriding later ones as described on the ``Files`` section
146 148 above.
147 149
148 150 A line of the form ``%include file`` will include ``file`` into the
149 151 current configuration file. The inclusion is recursive, which means
150 152 that included files can include other files. Filenames are relative to
151 153 the configuration file in which the ``%include`` directive is found.
152 154 Environment variables and ``~user`` constructs are expanded in
153 155 ``file``. This lets you do something like::
154 156
155 157 %include ~/.hgrc.d/$HOST.rc
156 158
157 159 to include a different configuration file on each computer you use.
158 160
159 161 A line with ``%unset name`` will remove ``name`` from the current
160 162 section, if it has been set previously.
161 163
162 164 The values are either free-form text strings, lists of text strings,
163 165 or Boolean values. Boolean values can be set to true using any of "1",
164 166 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
165 167 (all case insensitive).
166 168
167 169 List values are separated by whitespace or comma, except when values are
168 170 placed in double quotation marks::
169 171
170 172 allow_read = "John Doe, PhD", brian, betty
171 173
172 174 Quotation marks can be escaped by prefixing them with a backslash. Only
173 175 quotation marks at the beginning of a word is counted as a quotation
174 176 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
175 177
176 178 Sections
177 179 ========
178 180
179 181 This section describes the different sections that may appear in a
180 182 Mercurial configuration file, the purpose of each section, its possible
181 183 keys, and their possible values.
182 184
183 185 ``alias``
184 186 ---------
185 187
186 188 Defines command aliases.
187 189 Aliases allow you to define your own commands in terms of other
188 190 commands (or aliases), optionally including arguments. Positional
189 191 arguments in the form of ``$1``, ``$2``, etc in the alias definition
190 192 are expanded by Mercurial before execution. Positional arguments not
191 193 already used by ``$N`` in the definition are put at the end of the
192 194 command to be executed.
193 195
194 196 Alias definitions consist of lines of the form::
195 197
196 198 <alias> = <command> [<argument>]...
197 199
198 200 For example, this definition::
199 201
200 202 latest = log --limit 5
201 203
202 204 creates a new command ``latest`` that shows only the five most recent
203 205 changesets. You can define subsequent aliases using earlier ones::
204 206
205 207 stable5 = latest -b stable
206 208
207 .. note:: It is possible to create aliases with the same names as
209 .. note::
210
211 It is possible to create aliases with the same names as
208 212 existing commands, which will then override the original
209 213 definitions. This is almost always a bad idea!
210 214
211 215 An alias can start with an exclamation point (``!``) to make it a
212 216 shell alias. A shell alias is executed with the shell and will let you
213 217 run arbitrary commands. As an example, ::
214 218
215 219 echo = !echo $@
216 220
217 221 will let you do ``hg echo foo`` to have ``foo`` printed in your
218 222 terminal. A better example might be::
219 223
220 224 purge = !$HG status --no-status --unknown -0 | xargs -0 rm
221 225
222 226 which will make ``hg purge`` delete all unknown files in the
223 227 repository in the same manner as the purge extension.
224 228
225 229 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
226 230 expand to the command arguments. Unmatched arguments are
227 231 removed. ``$0`` expands to the alias name and ``$@`` expands to all
228 232 arguments separated by a space. These expansions happen before the
229 233 command is passed to the shell.
230 234
231 235 Shell aliases are executed in an environment where ``$HG`` expands to
232 236 the path of the Mercurial that was used to execute the alias. This is
233 237 useful when you want to call further Mercurial commands in a shell
234 238 alias, as was done above for the purge alias. In addition,
235 239 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
236 240 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
237 241
238 .. note:: Some global configuration options such as ``-R`` are
242 .. note::
243
244 Some global configuration options such as ``-R`` are
239 245 processed before shell aliases and will thus not be passed to
240 246 aliases.
241 247
242 248
243 249 ``annotate``
244 250 ------------
245 251
246 252 Settings used when displaying file annotations. All values are
247 253 Booleans and default to False. See ``diff`` section for related
248 254 options for the diff command.
249 255
250 256 ``ignorews``
251 257 Ignore white space when comparing lines.
252 258
253 259 ``ignorewsamount``
254 260 Ignore changes in the amount of white space.
255 261
256 262 ``ignoreblanklines``
257 263 Ignore changes whose lines are all blank.
258 264
259 265
260 266 ``auth``
261 267 --------
262 268
263 269 Authentication credentials for HTTP authentication. This section
264 270 allows you to store usernames and passwords for use when logging
265 271 *into* HTTP servers. See the ``[web]`` configuration section if
266 272 you want to configure *who* can login to your HTTP server.
267 273
268 274 Each line has the following format::
269 275
270 276 <name>.<argument> = <value>
271 277
272 278 where ``<name>`` is used to group arguments into authentication
273 279 entries. Example::
274 280
275 281 foo.prefix = hg.intevation.org/mercurial
276 282 foo.username = foo
277 283 foo.password = bar
278 284 foo.schemes = http https
279 285
280 286 bar.prefix = secure.example.org
281 287 bar.key = path/to/file.key
282 288 bar.cert = path/to/file.cert
283 289 bar.schemes = https
284 290
285 291 Supported arguments:
286 292
287 293 ``prefix``
288 294 Either ``*`` or a URI prefix with or without the scheme part.
289 295 The authentication entry with the longest matching prefix is used
290 296 (where ``*`` matches everything and counts as a match of length
291 297 1). If the prefix doesn't include a scheme, the match is performed
292 298 against the URI with its scheme stripped as well, and the schemes
293 299 argument, q.v., is then subsequently consulted.
294 300
295 301 ``username``
296 302 Optional. Username to authenticate with. If not given, and the
297 303 remote site requires basic or digest authentication, the user will
298 304 be prompted for it. Environment variables are expanded in the
299 305 username letting you do ``foo.username = $USER``. If the URI
300 306 includes a username, only ``[auth]`` entries with a matching
301 307 username or without a username will be considered.
302 308
303 309 ``password``
304 310 Optional. Password to authenticate with. If not given, and the
305 311 remote site requires basic or digest authentication, the user
306 312 will be prompted for it.
307 313
308 314 ``key``
309 315 Optional. PEM encoded client certificate key file. Environment
310 316 variables are expanded in the filename.
311 317
312 318 ``cert``
313 319 Optional. PEM encoded client certificate chain file. Environment
314 320 variables are expanded in the filename.
315 321
316 322 ``schemes``
317 323 Optional. Space separated list of URI schemes to use this
318 324 authentication entry with. Only used if the prefix doesn't include
319 325 a scheme. Supported schemes are http and https. They will match
320 326 static-http and static-https respectively, as well.
321 327 Default: https.
322 328
323 329 If no suitable authentication entry is found, the user is prompted
324 330 for credentials as usual if required by the remote.
325 331
326 332
327 333 ``decode/encode``
328 334 -----------------
329 335
330 336 Filters for transforming files on checkout/checkin. This would
331 337 typically be used for newline processing or other
332 338 localization/canonicalization of files.
333 339
334 340 Filters consist of a filter pattern followed by a filter command.
335 341 Filter patterns are globs by default, rooted at the repository root.
336 342 For example, to match any file ending in ``.txt`` in the root
337 343 directory only, use the pattern ``*.txt``. To match any file ending
338 344 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
339 345 For each file only the first matching filter applies.
340 346
341 347 The filter command can start with a specifier, either ``pipe:`` or
342 348 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
343 349
344 350 A ``pipe:`` command must accept data on stdin and return the transformed
345 351 data on stdout.
346 352
347 353 Pipe example::
348 354
349 355 [encode]
350 356 # uncompress gzip files on checkin to improve delta compression
351 357 # note: not necessarily a good idea, just an example
352 358 *.gz = pipe: gunzip
353 359
354 360 [decode]
355 361 # recompress gzip files when writing them to the working dir (we
356 362 # can safely omit "pipe:", because it's the default)
357 363 *.gz = gzip
358 364
359 365 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
360 366 with the name of a temporary file that contains the data to be
361 367 filtered by the command. The string ``OUTFILE`` is replaced with the name
362 368 of an empty temporary file, where the filtered data must be written by
363 369 the command.
364 370
365 .. note:: The tempfile mechanism is recommended for Windows systems,
371 .. note::
372
373 The tempfile mechanism is recommended for Windows systems,
366 374 where the standard shell I/O redirection operators often have
367 375 strange effects and may corrupt the contents of your files.
368 376
369 377 This filter mechanism is used internally by the ``eol`` extension to
370 378 translate line ending characters between Windows (CRLF) and Unix (LF)
371 379 format. We suggest you use the ``eol`` extension for convenience.
372 380
373 381
374 382 ``defaults``
375 383 ------------
376 384
377 385 (defaults are deprecated. Don't use them. Use aliases instead)
378 386
379 387 Use the ``[defaults]`` section to define command defaults, i.e. the
380 388 default options/arguments to pass to the specified commands.
381 389
382 390 The following example makes :hg:`log` run in verbose mode, and
383 391 :hg:`status` show only the modified files, by default::
384 392
385 393 [defaults]
386 394 log = -v
387 395 status = -m
388 396
389 397 The actual commands, instead of their aliases, must be used when
390 398 defining command defaults. The command defaults will also be applied
391 399 to the aliases of the commands defined.
392 400
393 401
394 402 ``diff``
395 403 --------
396 404
397 405 Settings used when displaying diffs. Everything except for ``unified``
398 406 is a Boolean and defaults to False. See ``annotate`` section for
399 407 related options for the annotate command.
400 408
401 409 ``git``
402 410 Use git extended diff format.
403 411
404 412 ``nodates``
405 413 Don't include dates in diff headers.
406 414
407 415 ``showfunc``
408 416 Show which function each change is in.
409 417
410 418 ``ignorews``
411 419 Ignore white space when comparing lines.
412 420
413 421 ``ignorewsamount``
414 422 Ignore changes in the amount of white space.
415 423
416 424 ``ignoreblanklines``
417 425 Ignore changes whose lines are all blank.
418 426
419 427 ``unified``
420 428 Number of lines of context to show.
421 429
422 430 ``email``
423 431 ---------
424 432
425 433 Settings for extensions that send email messages.
426 434
427 435 ``from``
428 436 Optional. Email address to use in "From" header and SMTP envelope
429 437 of outgoing messages.
430 438
431 439 ``to``
432 440 Optional. Comma-separated list of recipients' email addresses.
433 441
434 442 ``cc``
435 443 Optional. Comma-separated list of carbon copy recipients'
436 444 email addresses.
437 445
438 446 ``bcc``
439 447 Optional. Comma-separated list of blind carbon copy recipients'
440 448 email addresses.
441 449
442 450 ``method``
443 451 Optional. Method to use to send email messages. If value is ``smtp``
444 452 (default), use SMTP (see the ``[smtp]`` section for configuration).
445 453 Otherwise, use as name of program to run that acts like sendmail
446 454 (takes ``-f`` option for sender, list of recipients on command line,
447 455 message on stdin). Normally, setting this to ``sendmail`` or
448 456 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
449 457
450 458 ``charsets``
451 459 Optional. Comma-separated list of character sets considered
452 460 convenient for recipients. Addresses, headers, and parts not
453 461 containing patches of outgoing messages will be encoded in the
454 462 first character set to which conversion from local encoding
455 463 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
456 464 conversion fails, the text in question is sent as is. Defaults to
457 465 empty (explicit) list.
458 466
459 467 Order of outgoing email character sets:
460 468
461 469 1. ``us-ascii``: always first, regardless of settings
462 470 2. ``email.charsets``: in order given by user
463 471 3. ``ui.fallbackencoding``: if not in email.charsets
464 472 4. ``$HGENCODING``: if not in email.charsets
465 473 5. ``utf-8``: always last, regardless of settings
466 474
467 475 Email example::
468 476
469 477 [email]
470 478 from = Joseph User <joe.user@example.com>
471 479 method = /usr/sbin/sendmail
472 480 # charsets for western Europeans
473 481 # us-ascii, utf-8 omitted, as they are tried first and last
474 482 charsets = iso-8859-1, iso-8859-15, windows-1252
475 483
476 484
477 485 ``extensions``
478 486 --------------
479 487
480 488 Mercurial has an extension mechanism for adding new features. To
481 489 enable an extension, create an entry for it in this section.
482 490
483 491 If you know that the extension is already in Python's search path,
484 492 you can give the name of the module, followed by ``=``, with nothing
485 493 after the ``=``.
486 494
487 495 Otherwise, give a name that you choose, followed by ``=``, followed by
488 496 the path to the ``.py`` file (including the file name extension) that
489 497 defines the extension.
490 498
491 499 To explicitly disable an extension that is enabled in an hgrc of
492 500 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
493 501 or ``foo = !`` when path is not supplied.
494 502
495 503 Example for ``~/.hgrc``::
496 504
497 505 [extensions]
498 506 # (the progress extension will get loaded from Mercurial's path)
499 507 progress =
500 508 # (this extension will get loaded from the file specified)
501 509 myfeature = ~/.hgext/myfeature.py
502 510
503 511
504 512 ``format``
505 513 ----------
506 514
507 515 ``usestore``
508 516 Enable or disable the "store" repository format which improves
509 517 compatibility with systems that fold case or otherwise mangle
510 518 filenames. Enabled by default. Disabling this option will allow
511 519 you to store longer filenames in some situations at the expense of
512 520 compatibility and ensures that the on-disk format of newly created
513 521 repositories will be compatible with Mercurial before version 0.9.4.
514 522
515 523 ``usefncache``
516 524 Enable or disable the "fncache" repository format which enhances
517 525 the "store" repository format (which has to be enabled to use
518 526 fncache) to allow longer filenames and avoids using Windows
519 527 reserved names, e.g. "nul". Enabled by default. Disabling this
520 528 option ensures that the on-disk format of newly created
521 529 repositories will be compatible with Mercurial before version 1.1.
522 530
523 531 ``dotencode``
524 532 Enable or disable the "dotencode" repository format which enhances
525 533 the "fncache" repository format (which has to be enabled to use
526 534 dotencode) to avoid issues with filenames starting with ._ on
527 535 Mac OS X and spaces on Windows. Enabled by default. Disabling this
528 536 option ensures that the on-disk format of newly created
529 537 repositories will be compatible with Mercurial before version 1.7.
530 538
531 539 ``graph``
532 540 ---------
533 541
534 542 Web graph view configuration. This section let you change graph
535 543 elements display properties by branches, for instance to make the
536 544 ``default`` branch stand out.
537 545
538 546 Each line has the following format::
539 547
540 548 <branch>.<argument> = <value>
541 549
542 550 where ``<branch>`` is the name of the branch being
543 551 customized. Example::
544 552
545 553 [graph]
546 554 # 2px width
547 555 default.width = 2
548 556 # red color
549 557 default.color = FF0000
550 558
551 559 Supported arguments:
552 560
553 561 ``width``
554 562 Set branch edges width in pixels.
555 563
556 564 ``color``
557 565 Set branch edges color in hexadecimal RGB notation.
558 566
559 567 ``hooks``
560 568 ---------
561 569
562 570 Commands or Python functions that get automatically executed by
563 571 various actions such as starting or finishing a commit. Multiple
564 572 hooks can be run for the same action by appending a suffix to the
565 573 action. Overriding a site-wide hook can be done by changing its
566 574 value or setting it to an empty string. Hooks can be prioritized
567 575 by adding a prefix of ``priority`` to the hook name on a new line
568 576 and setting the priority. The default priority is 0 if
569 577 not specified.
570 578
571 579 Example ``.hg/hgrc``::
572 580
573 581 [hooks]
574 582 # update working directory after adding changesets
575 583 changegroup.update = hg update
576 584 # do not use the site-wide hook
577 585 incoming =
578 586 incoming.email = /my/email/hook
579 587 incoming.autobuild = /my/build/hook
580 588 # force autobuild hook to run before other incoming hooks
581 589 priority.incoming.autobuild = 1
582 590
583 591 Most hooks are run with environment variables set that give useful
584 592 additional information. For each hook below, the environment
585 593 variables it is passed are listed with names of the form ``$HG_foo``.
586 594
587 595 ``changegroup``
588 596 Run after a changegroup has been added via push, pull or unbundle.
589 597 ID of the first new changeset is in ``$HG_NODE``. URL from which
590 598 changes came is in ``$HG_URL``.
591 599
592 600 ``commit``
593 601 Run after a changeset has been created in the local repository. ID
594 602 of the newly created changeset is in ``$HG_NODE``. Parent changeset
595 603 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
596 604
597 605 ``incoming``
598 606 Run after a changeset has been pulled, pushed, or unbundled into
599 607 the local repository. The ID of the newly arrived changeset is in
600 608 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
601 609
602 610 ``outgoing``
603 611 Run after sending changes from local repository to another. ID of
604 612 first changeset sent is in ``$HG_NODE``. Source of operation is in
605 613 ``$HG_SOURCE``; see "preoutgoing" hook for description.
606 614
607 615 ``post-<command>``
608 616 Run after successful invocations of the associated command. The
609 617 contents of the command line are passed as ``$HG_ARGS`` and the result
610 618 code in ``$HG_RESULT``. Parsed command line arguments are passed as
611 619 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
612 620 the python data internally passed to <command>. ``$HG_OPTS`` is a
613 621 dictionary of options (with unspecified options set to their defaults).
614 622 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
615 623
616 624 ``pre-<command>``
617 625 Run before executing the associated command. The contents of the
618 626 command line are passed as ``$HG_ARGS``. Parsed command line arguments
619 627 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
620 628 representations of the data internally passed to <command>. ``$HG_OPTS``
621 629 is a dictionary of options (with unspecified options set to their
622 630 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
623 631 failure, the command doesn't execute and Mercurial returns the failure
624 632 code.
625 633
626 634 ``prechangegroup``
627 635 Run before a changegroup is added via push, pull or unbundle. Exit
628 636 status 0 allows the changegroup to proceed. Non-zero status will
629 637 cause the push, pull or unbundle to fail. URL from which changes
630 638 will come is in ``$HG_URL``.
631 639
632 640 ``precommit``
633 641 Run before starting a local commit. Exit status 0 allows the
634 642 commit to proceed. Non-zero status will cause the commit to fail.
635 643 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
636 644
637 645 ``prelistkeys``
638 646 Run before listing pushkeys (like bookmarks) in the
639 647 repository. Non-zero status will cause failure. The key namespace is
640 648 in ``$HG_NAMESPACE``.
641 649
642 650 ``preoutgoing``
643 651 Run before collecting changes to send from the local repository to
644 652 another. Non-zero status will cause failure. This lets you prevent
645 653 pull over HTTP or SSH. Also prevents against local pull, push
646 654 (outbound) or bundle commands, but not effective, since you can
647 655 just copy files instead then. Source of operation is in
648 656 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
649 657 SSH or HTTP repository. If "push", "pull" or "bundle", operation
650 658 is happening on behalf of repository on same system.
651 659
652 660 ``prepushkey``
653 661 Run before a pushkey (like a bookmark) is added to the
654 662 repository. Non-zero status will cause the key to be rejected. The
655 663 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
656 664 the old value (if any) is in ``$HG_OLD``, and the new value is in
657 665 ``$HG_NEW``.
658 666
659 667 ``pretag``
660 668 Run before creating a tag. Exit status 0 allows the tag to be
661 669 created. Non-zero status will cause the tag to fail. ID of
662 670 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
663 671 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
664 672
665 673 ``pretxnchangegroup``
666 674 Run after a changegroup has been added via push, pull or unbundle,
667 675 but before the transaction has been committed. Changegroup is
668 676 visible to hook program. This lets you validate incoming changes
669 677 before accepting them. Passed the ID of the first new changeset in
670 678 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
671 679 status will cause the transaction to be rolled back and the push,
672 680 pull or unbundle will fail. URL that was source of changes is in
673 681 ``$HG_URL``.
674 682
675 683 ``pretxncommit``
676 684 Run after a changeset has been created but the transaction not yet
677 685 committed. Changeset is visible to hook program. This lets you
678 686 validate commit message and changes. Exit status 0 allows the
679 687 commit to proceed. Non-zero status will cause the transaction to
680 688 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
681 689 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
682 690
683 691 ``preupdate``
684 692 Run before updating the working directory. Exit status 0 allows
685 693 the update to proceed. Non-zero status will prevent the update.
686 694 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
687 695 of second new parent is in ``$HG_PARENT2``.
688 696
689 697 ``listkeys``
690 698 Run after listing pushkeys (like bookmarks) in the repository. The
691 699 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
692 700 dictionary containing the keys and values.
693 701
694 702 ``pushkey``
695 703 Run after a pushkey (like a bookmark) is added to the
696 704 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
697 705 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
698 706 value is in ``$HG_NEW``.
699 707
700 708 ``tag``
701 709 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
702 710 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
703 711 repository if ``$HG_LOCAL=0``.
704 712
705 713 ``update``
706 714 Run after updating the working directory. Changeset ID of first
707 715 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
708 716 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
709 717 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
710 718
711 .. note:: It is generally better to use standard hooks rather than the
719 .. note::
720
721 It is generally better to use standard hooks rather than the
712 722 generic pre- and post- command hooks as they are guaranteed to be
713 723 called in the appropriate contexts for influencing transactions.
714 724 Also, hooks like "commit" will be called in all contexts that
715 725 generate a commit (e.g. tag) and not just the commit command.
716 726
717 .. note:: Environment variables with empty values may not be passed to
727 .. note::
728
729 Environment variables with empty values may not be passed to
718 730 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
719 731 will have an empty value under Unix-like platforms for non-merge
720 732 changesets, while it will not be available at all under Windows.
721 733
722 734 The syntax for Python hooks is as follows::
723 735
724 736 hookname = python:modulename.submodule.callable
725 737 hookname = python:/path/to/python/module.py:callable
726 738
727 739 Python hooks are run within the Mercurial process. Each hook is
728 740 called with at least three keyword arguments: a ui object (keyword
729 741 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
730 742 keyword that tells what kind of hook is used. Arguments listed as
731 743 environment variables above are passed as keyword arguments, with no
732 744 ``HG_`` prefix, and names in lower case.
733 745
734 746 If a Python hook returns a "true" value or raises an exception, this
735 747 is treated as a failure.
736 748
737 749
738 750 ``hostfingerprints``
739 751 --------------------
740 752
741 753 Fingerprints of the certificates of known HTTPS servers.
742 754 A HTTPS connection to a server with a fingerprint configured here will
743 755 only succeed if the servers certificate matches the fingerprint.
744 756 This is very similar to how ssh known hosts works.
745 757 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
746 758 The CA chain and web.cacerts is not used for servers with a fingerprint.
747 759
748 760 For example::
749 761
750 762 [hostfingerprints]
751 763 hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0
752 764
753 765 This feature is only supported when using Python 2.6 or later.
754 766
755 767
756 768 ``http_proxy``
757 769 --------------
758 770
759 771 Used to access web-based Mercurial repositories through a HTTP
760 772 proxy.
761 773
762 774 ``host``
763 775 Host name and (optional) port of the proxy server, for example
764 776 "myproxy:8000".
765 777
766 778 ``no``
767 779 Optional. Comma-separated list of host names that should bypass
768 780 the proxy.
769 781
770 782 ``passwd``
771 783 Optional. Password to authenticate with at the proxy server.
772 784
773 785 ``user``
774 786 Optional. User name to authenticate with at the proxy server.
775 787
776 788 ``always``
777 789 Optional. Always use the proxy, even for localhost and any entries
778 790 in ``http_proxy.no``. True or False. Default: False.
779 791
780 792 ``merge-patterns``
781 793 ------------------
782 794
783 795 This section specifies merge tools to associate with particular file
784 796 patterns. Tools matched here will take precedence over the default
785 797 merge tool. Patterns are globs by default, rooted at the repository
786 798 root.
787 799
788 800 Example::
789 801
790 802 [merge-patterns]
791 803 **.c = kdiff3
792 804 **.jpg = myimgmerge
793 805
794 806 ``merge-tools``
795 807 ---------------
796 808
797 809 This section configures external merge tools to use for file-level
798 810 merges.
799 811
800 812 Example ``~/.hgrc``::
801 813
802 814 [merge-tools]
803 815 # Override stock tool location
804 816 kdiff3.executable = ~/bin/kdiff3
805 817 # Specify command line
806 818 kdiff3.args = $base $local $other -o $output
807 819 # Give higher priority
808 820 kdiff3.priority = 1
809 821
810 822 # Define new tool
811 823 myHtmlTool.args = -m $local $other $base $output
812 824 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
813 825 myHtmlTool.priority = 1
814 826
815 827 Supported arguments:
816 828
817 829 ``priority``
818 830 The priority in which to evaluate this tool.
819 831 Default: 0.
820 832
821 833 ``executable``
822 834 Either just the name of the executable or its pathname. On Windows,
823 835 the path can use environment variables with ${ProgramFiles} syntax.
824 836 Default: the tool name.
825 837
826 838 ``args``
827 839 The arguments to pass to the tool executable. You can refer to the
828 840 files being merged as well as the output file through these
829 841 variables: ``$base``, ``$local``, ``$other``, ``$output``.
830 842 Default: ``$local $base $other``
831 843
832 844 ``premerge``
833 845 Attempt to run internal non-interactive 3-way merge tool before
834 846 launching external tool. Options are ``true``, ``false``, or ``keep``
835 847 to leave markers in the file if the premerge fails.
836 848 Default: True
837 849
838 850 ``binary``
839 851 This tool can merge binary files. Defaults to False, unless tool
840 852 was selected by file pattern match.
841 853
842 854 ``symlink``
843 855 This tool can merge symlinks. Defaults to False, even if tool was
844 856 selected by file pattern match.
845 857
846 858 ``check``
847 859 A list of merge success-checking options:
848 860
849 861 ``changed``
850 862 Ask whether merge was successful when the merged file shows no changes.
851 863 ``conflicts``
852 864 Check whether there are conflicts even though the tool reported success.
853 865 ``prompt``
854 866 Always prompt for merge success, regardless of success reported by tool.
855 867
856 868 ``fixeol``
857 869 Attempt to fix up EOL changes caused by the merge tool.
858 870 Default: False
859 871
860 872 ``gui``
861 873 This tool requires a graphical interface to run. Default: False
862 874
863 875 ``regkey``
864 876 Windows registry key which describes install location of this
865 877 tool. Mercurial will search for this key first under
866 878 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
867 879 Default: None
868 880
869 881 ``regkeyalt``
870 882 An alternate Windows registry key to try if the first key is not
871 883 found. The alternate key uses the same ``regname`` and ``regappend``
872 884 semantics of the primary key. The most common use for this key
873 885 is to search for 32bit applications on 64bit operating systems.
874 886 Default: None
875 887
876 888 ``regname``
877 889 Name of value to read from specified registry key. Defaults to the
878 890 unnamed (default) value.
879 891
880 892 ``regappend``
881 893 String to append to the value read from the registry, typically
882 894 the executable name of the tool.
883 895 Default: None
884 896
885 897
886 898 ``patch``
887 899 ---------
888 900
889 901 Settings used when applying patches, for instance through the 'import'
890 902 command or with Mercurial Queues extension.
891 903
892 904 ``eol``
893 905 When set to 'strict' patch content and patched files end of lines
894 906 are preserved. When set to ``lf`` or ``crlf``, both files end of
895 907 lines are ignored when patching and the result line endings are
896 908 normalized to either LF (Unix) or CRLF (Windows). When set to
897 909 ``auto``, end of lines are again ignored while patching but line
898 910 endings in patched files are normalized to their original setting
899 911 on a per-file basis. If target file does not exist or has no end
900 912 of line, patch line endings are preserved.
901 913 Default: strict.
902 914
903 915
904 916 ``paths``
905 917 ---------
906 918
907 919 Assigns symbolic names to repositories. The left side is the
908 920 symbolic name, and the right gives the directory or URL that is the
909 921 location of the repository. Default paths can be declared by setting
910 922 the following entries.
911 923
912 924 ``default``
913 925 Directory or URL to use when pulling if no source is specified.
914 926 Default is set to repository from which the current repository was
915 927 cloned.
916 928
917 929 ``default-push``
918 930 Optional. Directory or URL to use when pushing if no destination
919 931 is specified.
920 932
921 933 Custom paths can be defined by assigning the path to a name that later can be
922 934 used from the command line. Example::
923 935
924 936 [paths]
925 937 my_path = http://example.com/path
926 938
927 939 To push to the path defined in ``my_path`` run the command::
928 940
929 941 hg push my_path
930 942
931 943
932 944 ``phases``
933 945 ----------
934 946
935 947 Specifies default handling of phases. See :hg:`help phases` for more
936 948 information about working with phases.
937 949
938 950 ``publish``
939 951 Controls draft phase behavior when working as a server. When true,
940 952 pushed changesets are set to public in both client and server and
941 953 pulled or cloned changesets are set to public in the client.
942 954 Default: True
943 955
944 956 ``new-commit``
945 957 Phase of newly-created commits.
946 958 Default: draft
947 959
948 960 ``checksubrepos``
949 961 Check the phase of the current revision of each subrepository. Allowed
950 962 values are "ignore", "follow" and "abort". For settings other than
951 963 "ignore", the phase of the current revision of each subrepository is
952 964 checked before committing the parent repository. If any of those phases is
953 965 greater than the phase of the parent repository (e.g. if a subrepo is in a
954 966 "secret" phase while the parent repo is in "draft" phase), the commit is
955 967 either aborted (if checksubrepos is set to "abort") or the higher phase is
956 968 used for the parent repository commit (if set to "follow").
957 969 Default: "follow"
958 970
959 971
960 972 ``profiling``
961 973 -------------
962 974
963 975 Specifies profiling type, format, and file output. Two profilers are
964 976 supported: an instrumenting profiler (named ``ls``), and a sampling
965 977 profiler (named ``stat``).
966 978
967 979 In this section description, 'profiling data' stands for the raw data
968 980 collected during profiling, while 'profiling report' stands for a
969 981 statistical text report generated from the profiling data. The
970 982 profiling is done using lsprof.
971 983
972 984 ``type``
973 985 The type of profiler to use.
974 986 Default: ls.
975 987
976 988 ``ls``
977 989 Use Python's built-in instrumenting profiler. This profiler
978 990 works on all platforms, but each line number it reports is the
979 991 first line of a function. This restriction makes it difficult to
980 992 identify the expensive parts of a non-trivial function.
981 993 ``stat``
982 994 Use a third-party statistical profiler, statprof. This profiler
983 995 currently runs only on Unix systems, and is most useful for
984 996 profiling commands that run for longer than about 0.1 seconds.
985 997
986 998 ``format``
987 999 Profiling format. Specific to the ``ls`` instrumenting profiler.
988 1000 Default: text.
989 1001
990 1002 ``text``
991 1003 Generate a profiling report. When saving to a file, it should be
992 1004 noted that only the report is saved, and the profiling data is
993 1005 not kept.
994 1006 ``kcachegrind``
995 1007 Format profiling data for kcachegrind use: when saving to a
996 1008 file, the generated file can directly be loaded into
997 1009 kcachegrind.
998 1010
999 1011 ``frequency``
1000 1012 Sampling frequency. Specific to the ``stat`` sampling profiler.
1001 1013 Default: 1000.
1002 1014
1003 1015 ``output``
1004 1016 File path where profiling data or report should be saved. If the
1005 1017 file exists, it is replaced. Default: None, data is printed on
1006 1018 stderr
1007 1019
1008 1020 ``sort``
1009 1021 Sort field. Specific to the ``ls`` instrumenting profiler.
1010 1022 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1011 1023 ``inlinetime``.
1012 1024 Default: inlinetime.
1013 1025
1014 1026 ``limit``
1015 1027 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1016 1028 Default: 30.
1017 1029
1018 1030 ``nested``
1019 1031 Show at most this number of lines of drill-down info after each main entry.
1020 1032 This can help explain the difference between Total and Inline.
1021 1033 Specific to the ``ls`` instrumenting profiler.
1022 1034 Default: 5.
1023 1035
1024 1036 ``revsetalias``
1025 1037 ---------------
1026 1038
1027 1039 Alias definitions for revsets. See :hg:`help revsets` for details.
1028 1040
1029 1041 ``server``
1030 1042 ----------
1031 1043
1032 1044 Controls generic server settings.
1033 1045
1034 1046 ``uncompressed``
1035 1047 Whether to allow clients to clone a repository using the
1036 1048 uncompressed streaming protocol. This transfers about 40% more
1037 1049 data than a regular clone, but uses less memory and CPU on both
1038 1050 server and client. Over a LAN (100 Mbps or better) or a very fast
1039 1051 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1040 1052 regular clone. Over most WAN connections (anything slower than
1041 1053 about 6 Mbps), uncompressed streaming is slower, because of the
1042 1054 extra data transfer overhead. This mode will also temporarily hold
1043 1055 the write lock while determining what data to transfer.
1044 1056 Default is True.
1045 1057
1046 1058 ``preferuncompressed``
1047 1059 When set, clients will try to use the uncompressed streaming
1048 1060 protocol. Default is False.
1049 1061
1050 1062 ``validate``
1051 1063 Whether to validate the completeness of pushed changesets by
1052 1064 checking that all new file revisions specified in manifests are
1053 1065 present. Default is False.
1054 1066
1055 1067 ``smtp``
1056 1068 --------
1057 1069
1058 1070 Configuration for extensions that need to send email messages.
1059 1071
1060 1072 ``host``
1061 1073 Host name of mail server, e.g. "mail.example.com".
1062 1074
1063 1075 ``port``
1064 1076 Optional. Port to connect to on mail server. Default: 465 (if
1065 1077 ``tls`` is smtps) or 25 (otherwise).
1066 1078
1067 1079 ``tls``
1068 1080 Optional. Method to enable TLS when connecting to mail server: starttls,
1069 1081 smtps or none. Default: none.
1070 1082
1071 1083 ``verifycert``
1072 1084 Optional. Verification for the certificate of mail server, when
1073 1085 ``tls`` is starttls or smtps. "strict", "loose" or False. For
1074 1086 "strict" or "loose", the certificate is verified as same as the
1075 1087 verification for HTTPS connections (see ``[hostfingerprints]`` and
1076 1088 ``[web] cacerts`` also). For "strict", sending email is also
1077 1089 aborted, if there is no configuration for mail server in
1078 1090 ``[hostfingerprints]`` and ``[web] cacerts``. --insecure for
1079 1091 :hg:`email` overwrites this as "loose". Default: "strict".
1080 1092
1081 1093 ``username``
1082 1094 Optional. User name for authenticating with the SMTP server.
1083 1095 Default: none.
1084 1096
1085 1097 ``password``
1086 1098 Optional. Password for authenticating with the SMTP server. If not
1087 1099 specified, interactive sessions will prompt the user for a
1088 1100 password; non-interactive sessions will fail. Default: none.
1089 1101
1090 1102 ``local_hostname``
1091 1103 Optional. It's the hostname that the sender can use to identify
1092 1104 itself to the MTA.
1093 1105
1094 1106
1095 1107 ``subpaths``
1096 1108 ------------
1097 1109
1098 1110 Subrepository source URLs can go stale if a remote server changes name
1099 1111 or becomes temporarily unavailable. This section lets you define
1100 1112 rewrite rules of the form::
1101 1113
1102 1114 <pattern> = <replacement>
1103 1115
1104 1116 where ``pattern`` is a regular expression matching a subrepository
1105 1117 source URL and ``replacement`` is the replacement string used to
1106 1118 rewrite it. Groups can be matched in ``pattern`` and referenced in
1107 1119 ``replacements``. For instance::
1108 1120
1109 1121 http://server/(.*)-hg/ = http://hg.server/\1/
1110 1122
1111 1123 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1112 1124
1113 1125 Relative subrepository paths are first made absolute, and the
1114 1126 rewrite rules are then applied on the full (absolute) path. The rules
1115 1127 are applied in definition order.
1116 1128
1117 1129 ``trusted``
1118 1130 -----------
1119 1131
1120 1132 Mercurial will not use the settings in the
1121 1133 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1122 1134 user or to a trusted group, as various hgrc features allow arbitrary
1123 1135 commands to be run. This issue is often encountered when configuring
1124 1136 hooks or extensions for shared repositories or servers. However,
1125 1137 the web interface will use some safe settings from the ``[web]``
1126 1138 section.
1127 1139
1128 1140 This section specifies what users and groups are trusted. The
1129 1141 current user is always trusted. To trust everybody, list a user or a
1130 1142 group with name ``*``. These settings must be placed in an
1131 1143 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1132 1144 user or service running Mercurial.
1133 1145
1134 1146 ``users``
1135 1147 Comma-separated list of trusted users.
1136 1148
1137 1149 ``groups``
1138 1150 Comma-separated list of trusted groups.
1139 1151
1140 1152
1141 1153 ``ui``
1142 1154 ------
1143 1155
1144 1156 User interface controls.
1145 1157
1146 1158 ``archivemeta``
1147 1159 Whether to include the .hg_archival.txt file containing meta data
1148 1160 (hashes for the repository base and for tip) in archives created
1149 1161 by the :hg:`archive` command or downloaded via hgweb.
1150 1162 Default is True.
1151 1163
1152 1164 ``askusername``
1153 1165 Whether to prompt for a username when committing. If True, and
1154 1166 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1155 1167 be prompted to enter a username. If no username is entered, the
1156 1168 default ``USER@HOST`` is used instead.
1157 1169 Default is False.
1158 1170
1159 1171 ``commitsubrepos``
1160 1172 Whether to commit modified subrepositories when committing the
1161 1173 parent repository. If False and one subrepository has uncommitted
1162 1174 changes, abort the commit.
1163 1175 Default is False.
1164 1176
1165 1177 ``debug``
1166 1178 Print debugging information. True or False. Default is False.
1167 1179
1168 1180 ``editor``
1169 1181 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
1170 1182
1171 1183 ``fallbackencoding``
1172 1184 Encoding to try if it's not possible to decode the changelog using
1173 1185 UTF-8. Default is ISO-8859-1.
1174 1186
1175 1187 ``ignore``
1176 1188 A file to read per-user ignore patterns from. This file should be
1177 1189 in the same format as a repository-wide .hgignore file. This
1178 1190 option supports hook syntax, so if you want to specify multiple
1179 1191 ignore files, you can do so by setting something like
1180 1192 ``ignore.other = ~/.hgignore2``. For details of the ignore file
1181 1193 format, see the ``hgignore(5)`` man page.
1182 1194
1183 1195 ``interactive``
1184 1196 Allow to prompt the user. True or False. Default is True.
1185 1197
1186 1198 ``logtemplate``
1187 1199 Template string for commands that print changesets.
1188 1200
1189 1201 ``merge``
1190 1202 The conflict resolution program to use during a manual merge.
1191 1203 For more information on merge tools see :hg:`help merge-tools`.
1192 1204 For configuring merge tools see the ``[merge-tools]`` section.
1193 1205
1194 1206 ``portablefilenames``
1195 1207 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1196 1208 Default is ``warn``.
1197 1209 If set to ``warn`` (or ``true``), a warning message is printed on POSIX
1198 1210 platforms, if a file with a non-portable filename is added (e.g. a file
1199 1211 with a name that can't be created on Windows because it contains reserved
1200 1212 parts like ``AUX``, reserved characters like ``:``, or would cause a case
1201 1213 collision with an existing file).
1202 1214 If set to ``ignore`` (or ``false``), no warning is printed.
1203 1215 If set to ``abort``, the command is aborted.
1204 1216 On Windows, this configuration option is ignored and the command aborted.
1205 1217
1206 1218 ``quiet``
1207 1219 Reduce the amount of output printed. True or False. Default is False.
1208 1220
1209 1221 ``remotecmd``
1210 1222 remote command to use for clone/push/pull operations. Default is ``hg``.
1211 1223
1212 1224 ``reportoldssl``
1213 1225 Warn if an SSL certificate is unable to be due to using Python
1214 1226 2.5 or earlier. True or False. Default is True.
1215 1227
1216 1228 ``report_untrusted``
1217 1229 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1218 1230 trusted user or group. True or False. Default is True.
1219 1231
1220 1232 ``slash``
1221 1233 Display paths using a slash (``/``) as the path separator. This
1222 1234 only makes a difference on systems where the default path
1223 1235 separator is not the slash character (e.g. Windows uses the
1224 1236 backslash character (``\``)).
1225 1237 Default is False.
1226 1238
1227 1239 ``ssh``
1228 1240 command to use for SSH connections. Default is ``ssh``.
1229 1241
1230 1242 ``strict``
1231 1243 Require exact command names, instead of allowing unambiguous
1232 1244 abbreviations. True or False. Default is False.
1233 1245
1234 1246 ``style``
1235 1247 Name of style to use for command output.
1236 1248
1237 1249 ``timeout``
1238 1250 The timeout used when a lock is held (in seconds), a negative value
1239 1251 means no timeout. Default is 600.
1240 1252
1241 1253 ``traceback``
1242 1254 Mercurial always prints a traceback when an unknown exception
1243 1255 occurs. Setting this to True will make Mercurial print a traceback
1244 1256 on all exceptions, even those recognized by Mercurial (such as
1245 1257 IOError or MemoryError). Default is False.
1246 1258
1247 1259 ``username``
1248 1260 The committer of a changeset created when running "commit".
1249 1261 Typically a person's name and email address, e.g. ``Fred Widget
1250 1262 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
1251 1263 the username in hgrc is empty, it has to be specified manually or
1252 1264 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
1253 1265 ``username =`` in the system hgrc). Environment variables in the
1254 1266 username are expanded.
1255 1267
1256 1268 ``verbose``
1257 1269 Increase the amount of output printed. True or False. Default is False.
1258 1270
1259 1271
1260 1272 ``web``
1261 1273 -------
1262 1274
1263 1275 Web interface configuration. The settings in this section apply to
1264 1276 both the builtin webserver (started by :hg:`serve`) and the script you
1265 1277 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1266 1278 and WSGI).
1267 1279
1268 1280 The Mercurial webserver does no authentication (it does not prompt for
1269 1281 usernames and passwords to validate *who* users are), but it does do
1270 1282 authorization (it grants or denies access for *authenticated users*
1271 1283 based on settings in this section). You must either configure your
1272 1284 webserver to do authentication for you, or disable the authorization
1273 1285 checks.
1274 1286
1275 1287 For a quick setup in a trusted environment, e.g., a private LAN, where
1276 1288 you want it to accept pushes from anybody, you can use the following
1277 1289 command line::
1278 1290
1279 1291 $ hg --config web.allow_push=* --config web.push_ssl=False serve
1280 1292
1281 1293 Note that this will allow anybody to push anything to the server and
1282 1294 that this should not be used for public servers.
1283 1295
1284 1296 The full set of options is:
1285 1297
1286 1298 ``accesslog``
1287 1299 Where to output the access log. Default is stdout.
1288 1300
1289 1301 ``address``
1290 1302 Interface address to bind to. Default is all.
1291 1303
1292 1304 ``allow_archive``
1293 1305 List of archive format (bz2, gz, zip) allowed for downloading.
1294 1306 Default is empty.
1295 1307
1296 1308 ``allowbz2``
1297 1309 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
1298 1310 revisions.
1299 1311 Default is False.
1300 1312
1301 1313 ``allowgz``
1302 1314 (DEPRECATED) Whether to allow .tar.gz downloading of repository
1303 1315 revisions.
1304 1316 Default is False.
1305 1317
1306 1318 ``allowpull``
1307 1319 Whether to allow pulling from the repository. Default is True.
1308 1320
1309 1321 ``allow_push``
1310 1322 Whether to allow pushing to the repository. If empty or not set,
1311 1323 push is not allowed. If the special value ``*``, any remote user can
1312 1324 push, including unauthenticated users. Otherwise, the remote user
1313 1325 must have been authenticated, and the authenticated user name must
1314 1326 be present in this list. The contents of the allow_push list are
1315 1327 examined after the deny_push list.
1316 1328
1317 1329 ``allow_read``
1318 1330 If the user has not already been denied repository access due to
1319 1331 the contents of deny_read, this list determines whether to grant
1320 1332 repository access to the user. If this list is not empty, and the
1321 1333 user is unauthenticated or not present in the list, then access is
1322 1334 denied for the user. If the list is empty or not set, then access
1323 1335 is permitted to all users by default. Setting allow_read to the
1324 1336 special value ``*`` is equivalent to it not being set (i.e. access
1325 1337 is permitted to all users). The contents of the allow_read list are
1326 1338 examined after the deny_read list.
1327 1339
1328 1340 ``allowzip``
1329 1341 (DEPRECATED) Whether to allow .zip downloading of repository
1330 1342 revisions. Default is False. This feature creates temporary files.
1331 1343
1332 1344 ``archivesubrepos``
1333 1345 Whether to recurse into subrepositories when archiving. Default is
1334 1346 False.
1335 1347
1336 1348 ``baseurl``
1337 1349 Base URL to use when publishing URLs in other locations, so
1338 1350 third-party tools like email notification hooks can construct
1339 1351 URLs. Example: ``http://hgserver/repos/``.
1340 1352
1341 1353 ``cacerts``
1342 1354 Path to file containing a list of PEM encoded certificate
1343 1355 authority certificates. Environment variables and ``~user``
1344 1356 constructs are expanded in the filename. If specified on the
1345 1357 client, then it will verify the identity of remote HTTPS servers
1346 1358 with these certificates.
1347 1359
1348 1360 This feature is only supported when using Python 2.6 or later. If you wish
1349 1361 to use it with earlier versions of Python, install the backported
1350 1362 version of the ssl library that is available from
1351 1363 ``http://pypi.python.org``.
1352 1364
1353 1365 To disable SSL verification temporarily, specify ``--insecure`` from
1354 1366 command line.
1355 1367
1356 1368 You can use OpenSSL's CA certificate file if your platform has
1357 1369 one. On most Linux systems this will be
1358 1370 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
1359 1371 generate this file manually. The form must be as follows::
1360 1372
1361 1373 -----BEGIN CERTIFICATE-----
1362 1374 ... (certificate in base64 PEM encoding) ...
1363 1375 -----END CERTIFICATE-----
1364 1376 -----BEGIN CERTIFICATE-----
1365 1377 ... (certificate in base64 PEM encoding) ...
1366 1378 -----END CERTIFICATE-----
1367 1379
1368 1380 ``cache``
1369 1381 Whether to support caching in hgweb. Defaults to True.
1370 1382
1371 1383 ``collapse``
1372 1384 With ``descend`` enabled, repositories in subdirectories are shown at
1373 1385 a single level alongside repositories in the current path. With
1374 1386 ``collapse`` also enabled, repositories residing at a deeper level than
1375 1387 the current path are grouped behind navigable directory entries that
1376 1388 lead to the locations of these repositories. In effect, this setting
1377 1389 collapses each collection of repositories found within a subdirectory
1378 1390 into a single entry for that subdirectory. Default is False.
1379 1391
1380 1392 ``comparisoncontext``
1381 1393 Number of lines of context to show in side-by-side file comparison. If
1382 1394 negative or the value ``full``, whole files are shown. Default is 5.
1383 1395 This setting can be overridden by a ``context`` request parameter to the
1384 1396 ``comparison`` command, taking the same values.
1385 1397
1386 1398 ``contact``
1387 1399 Name or email address of the person in charge of the repository.
1388 1400 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
1389 1401
1390 1402 ``deny_push``
1391 1403 Whether to deny pushing to the repository. If empty or not set,
1392 1404 push is not denied. If the special value ``*``, all remote users are
1393 1405 denied push. Otherwise, unauthenticated users are all denied, and
1394 1406 any authenticated user name present in this list is also denied. The
1395 1407 contents of the deny_push list are examined before the allow_push list.
1396 1408
1397 1409 ``deny_read``
1398 1410 Whether to deny reading/viewing of the repository. If this list is
1399 1411 not empty, unauthenticated users are all denied, and any
1400 1412 authenticated user name present in this list is also denied access to
1401 1413 the repository. If set to the special value ``*``, all remote users
1402 1414 are denied access (rarely needed ;). If deny_read is empty or not set,
1403 1415 the determination of repository access depends on the presence and
1404 1416 content of the allow_read list (see description). If both
1405 1417 deny_read and allow_read are empty or not set, then access is
1406 1418 permitted to all users by default. If the repository is being
1407 1419 served via hgwebdir, denied users will not be able to see it in
1408 1420 the list of repositories. The contents of the deny_read list have
1409 1421 priority over (are examined before) the contents of the allow_read
1410 1422 list.
1411 1423
1412 1424 ``descend``
1413 1425 hgwebdir indexes will not descend into subdirectories. Only repositories
1414 1426 directly in the current path will be shown (other repositories are still
1415 1427 available from the index corresponding to their containing path).
1416 1428
1417 1429 ``description``
1418 1430 Textual description of the repository's purpose or contents.
1419 1431 Default is "unknown".
1420 1432
1421 1433 ``encoding``
1422 1434 Character encoding name. Default is the current locale charset.
1423 1435 Example: "UTF-8"
1424 1436
1425 1437 ``errorlog``
1426 1438 Where to output the error log. Default is stderr.
1427 1439
1428 1440 ``guessmime``
1429 1441 Control MIME types for raw download of file content.
1430 1442 Set to True to let hgweb guess the content type from the file
1431 1443 extension. This will serve HTML files as ``text/html`` and might
1432 1444 allow cross-site scripting attacks when serving untrusted
1433 1445 repositories. Default is False.
1434 1446
1435 1447 ``hidden``
1436 1448 Whether to hide the repository in the hgwebdir index.
1437 1449 Default is False.
1438 1450
1439 1451 ``ipv6``
1440 1452 Whether to use IPv6. Default is False.
1441 1453
1442 1454 ``logoimg``
1443 1455 File name of the logo image that some templates display on each page.
1444 1456 The file name is relative to ``staticurl``. That is, the full path to
1445 1457 the logo image is "staticurl/logoimg".
1446 1458 If unset, ``hglogo.png`` will be used.
1447 1459
1448 1460 ``logourl``
1449 1461 Base URL to use for logos. If unset, ``http://mercurial.selenic.com/``
1450 1462 will be used.
1451 1463
1452 1464 ``maxchanges``
1453 1465 Maximum number of changes to list on the changelog. Default is 10.
1454 1466
1455 1467 ``maxfiles``
1456 1468 Maximum number of files to list per changeset. Default is 10.
1457 1469
1458 1470 ``maxshortchanges``
1459 1471 Maximum number of changes to list on the shortlog, graph or filelog
1460 1472 pages. Default is 60.
1461 1473
1462 1474 ``name``
1463 1475 Repository name to use in the web interface. Default is current
1464 1476 working directory.
1465 1477
1466 1478 ``port``
1467 1479 Port to listen on. Default is 8000.
1468 1480
1469 1481 ``prefix``
1470 1482 Prefix path to serve from. Default is '' (server root).
1471 1483
1472 1484 ``push_ssl``
1473 1485 Whether to require that inbound pushes be transported over SSL to
1474 1486 prevent password sniffing. Default is True.
1475 1487
1476 1488 ``staticurl``
1477 1489 Base URL to use for static files. If unset, static files (e.g. the
1478 1490 hgicon.png favicon) will be served by the CGI script itself. Use
1479 1491 this setting to serve them directly with the HTTP server.
1480 1492 Example: ``http://hgserver/static/``.
1481 1493
1482 1494 ``stripes``
1483 1495 How many lines a "zebra stripe" should span in multi-line output.
1484 1496 Default is 1; set to 0 to disable.
1485 1497
1486 1498 ``style``
1487 1499 Which template map style to use.
1488 1500
1489 1501 ``templates``
1490 1502 Where to find the HTML templates. Default is install path.
1491 1503
1492 1504 ``websub``
1493 1505 ----------
1494 1506
1495 1507 Web substitution filter definition. You can use this section to
1496 1508 define a set of regular expression substitution patterns which
1497 1509 let you automatically modify the hgweb server output.
1498 1510
1499 1511 The default hgweb templates only apply these substitution patterns
1500 1512 on the revision description fields. You can apply them anywhere
1501 1513 you want when you create your own templates by adding calls to the
1502 1514 "websub" filter (usually after calling the "escape" filter).
1503 1515
1504 1516 This can be used, for example, to convert issue references to links
1505 1517 to your issue tracker, or to convert "markdown-like" syntax into
1506 1518 HTML (see the examples below).
1507 1519
1508 1520 Each entry in this section names a substitution filter.
1509 1521 The value of each entry defines the substitution expression itself.
1510 1522 The websub expressions follow the old interhg extension syntax,
1511 1523 which in turn imitates the Unix sed replacement syntax::
1512 1524
1513 1525 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
1514 1526
1515 1527 You can use any separator other than "/". The final "i" is optional
1516 1528 and indicates that the search must be case insensitive.
1517 1529
1518 1530 Examples::
1519 1531
1520 1532 [websub]
1521 1533 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
1522 1534 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
1523 1535 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
1524 1536
1525 1537 ``worker``
1526 1538 ----------
1527 1539
1528 1540 Parallel master/worker configuration. We currently perform working
1529 1541 directory updates in parallel on Unix-like systems, which greatly
1530 1542 helps performance.
1531 1543
1532 1544 ``numcpus``
1533 1545 Number of CPUs to use for parallel operations. Default is 4 or the
1534 1546 number of CPUs on the system, whichever is larger. A zero or
1535 1547 negative value is treated as ``use the default``.
@@ -1,89 +1,90 b''
1 1 Synopsis
2 2 ========
3 3
4 4 The Mercurial system uses a file called ``.hgignore`` in the root
5 5 directory of a repository to control its behavior when it searches
6 6 for files that it is not currently tracking.
7 7
8 8 Description
9 9 ===========
10 10
11 11 The working directory of a Mercurial repository will often contain
12 12 files that should not be tracked by Mercurial. These include backup
13 13 files created by editors and build products created by compilers.
14 14 These files can be ignored by listing them in a ``.hgignore`` file in
15 15 the root of the working directory. The ``.hgignore`` file must be
16 16 created manually. It is typically put under version control, so that
17 17 the settings will propagate to other repositories with push and pull.
18 18
19 19 An untracked file is ignored if its path relative to the repository
20 20 root directory, or any prefix path of that path, is matched against
21 21 any pattern in ``.hgignore``.
22 22
23 23 For example, say we have an untracked file, ``file.c``, at
24 24 ``a/b/file.c`` inside our repository. Mercurial will ignore ``file.c``
25 25 if any pattern in ``.hgignore`` matches ``a/b/file.c``, ``a/b`` or ``a``.
26 26
27 27 In addition, a Mercurial configuration file can reference a set of
28 28 per-user or global ignore files. See the ``ignore`` configuration
29 29 key on the ``[ui]`` section of :hg:`help config` for details of how to
30 30 configure these files.
31 31
32 32 To control Mercurial's handling of files that it manages, many
33 33 commands support the ``-I`` and ``-X`` options; see
34 34 :hg:`help <command>` and :hg:`help patterns` for details.
35 35
36 36 Files that are already tracked are not affected by .hgignore, even
37 37 if they appear in .hgignore. An untracked file X can be explicitly
38 38 added with :hg:`add X`, even if X would be excluded by a pattern
39 39 in .hgignore.
40 40
41 41 Syntax
42 42 ======
43 43
44 44 An ignore file is a plain text file consisting of a list of patterns,
45 45 with one pattern per line. Empty lines are skipped. The ``#``
46 46 character is treated as a comment character, and the ``\`` character
47 47 is treated as an escape character.
48 48
49 49 Mercurial supports several pattern syntaxes. The default syntax used
50 50 is Python/Perl-style regular expressions.
51 51
52 52 To change the syntax used, use a line of the following form::
53 53
54 54 syntax: NAME
55 55
56 56 where ``NAME`` is one of the following:
57 57
58 58 ``regexp``
59 59 Regular expression, Python/Perl syntax.
60 60 ``glob``
61 61 Shell-style glob.
62 62
63 63 The chosen syntax stays in effect when parsing all patterns that
64 64 follow, until another syntax is selected.
65 65
66 66 Neither glob nor regexp patterns are rooted. A glob-syntax pattern of
67 67 the form ``*.c`` will match a file ending in ``.c`` in any directory,
68 68 and a regexp pattern of the form ``\.c$`` will do the same. To root a
69 69 regexp pattern, start it with ``^``.
70 70
71 71 .. note::
72
72 73 Patterns specified in other than ``.hgignore`` are always rooted.
73 74 Please see :hg:`help patterns` for details.
74 75
75 76 Example
76 77 =======
77 78
78 79 Here is an example ignore file. ::
79 80
80 81 # use glob syntax.
81 82 syntax: glob
82 83
83 84 *.elc
84 85 *.pyc
85 86 *~
86 87
87 88 # switch to regexp syntax.
88 89 syntax: regexp
89 90 ^\.pc/
@@ -1,84 +1,85 b''
1 1 To merge files Mercurial uses merge tools.
2 2
3 3 A merge tool combines two different versions of a file into a merged
4 4 file. Merge tools are given the two files and the greatest common
5 5 ancestor of the two file versions, so they can determine the changes
6 6 made on both branches.
7 7
8 8 Merge tools are used both for :hg:`resolve`, :hg:`merge`, :hg:`update`,
9 9 :hg:`backout` and in several extensions.
10 10
11 11 Usually, the merge tool tries to automatically reconcile the files by
12 12 combining all non-overlapping changes that occurred separately in
13 13 the two different evolutions of the same initial base file. Furthermore, some
14 14 interactive merge programs make it easier to manually resolve
15 15 conflicting merges, either in a graphical way, or by inserting some
16 16 conflict markers. Mercurial does not include any interactive merge
17 17 programs but relies on external tools for that.
18 18
19 19 Available merge tools
20 20 =====================
21 21
22 22 External merge tools and their properties are configured in the
23 23 merge-tools configuration section - see hgrc(5) - but they can often just
24 24 be named by their executable.
25 25
26 26 A merge tool is generally usable if its executable can be found on the
27 27 system and if it can handle the merge. The executable is found if it
28 28 is an absolute or relative executable path or the name of an
29 29 application in the executable search path. The tool is assumed to be
30 30 able to handle the merge if it can handle symlinks if the file is a
31 31 symlink, if it can handle binary files if the file is binary, and if a
32 32 GUI is available if the tool requires a GUI.
33 33
34 34 There are some internal merge tools which can be used. The internal
35 35 merge tools are:
36 36
37 37 .. internaltoolsmarker
38 38
39 39 Internal tools are always available and do not require a GUI but will by default
40 40 not handle symlinks or binary files.
41 41
42 42 Choosing a merge tool
43 43 =====================
44 44
45 45 Mercurial uses these rules when deciding which merge tool to use:
46 46
47 47 1. If a tool has been specified with the --tool option to merge or resolve, it
48 48 is used. If it is the name of a tool in the merge-tools configuration, its
49 49 configuration is used. Otherwise the specified tool must be executable by
50 50 the shell.
51 51
52 52 2. If the ``HGMERGE`` environment variable is present, its value is used and
53 53 must be executable by the shell.
54 54
55 55 3. If the filename of the file to be merged matches any of the patterns in the
56 56 merge-patterns configuration section, the first usable merge tool
57 57 corresponding to a matching pattern is used. Here, binary capabilities of the
58 58 merge tool are not considered.
59 59
60 60 4. If ui.merge is set it will be considered next. If the value is not the name
61 61 of a configured tool, the specified value is used and must be executable by
62 62 the shell. Otherwise the named tool is used if it is usable.
63 63
64 64 5. If any usable merge tools are present in the merge-tools configuration
65 65 section, the one with the highest priority is used.
66 66
67 67 6. If a program named ``hgmerge`` can be found on the system, it is used - but
68 68 it will by default not be used for symlinks and binary files.
69 69
70 70 7. If the file to be merged is not binary and is not a symlink, then
71 71 ``internal:merge`` is used.
72 72
73 73 8. The merge of the file fails and must be resolved before commit.
74 74
75 75 .. note::
76
76 77 After selecting a merge program, Mercurial will by default attempt
77 78 to merge the files using a simple merge algorithm first. Only if it doesn't
78 79 succeed because of conflicting changes Mercurial will actually execute the
79 80 merge program. Whether to use the simple merge algorithm first can be
80 81 controlled by the premerge setting of the merge tool. Premerge is enabled by
81 82 default unless the file is binary or a symlink.
82 83
83 84 See the merge-tools and ui sections of hgrc(5) for details on the
84 85 configuration of merge tools.
@@ -1,61 +1,62 b''
1 1 Mercurial accepts several notations for identifying one or more files
2 2 at a time.
3 3
4 4 By default, Mercurial treats filenames as shell-style extended glob
5 5 patterns.
6 6
7 7 Alternate pattern notations must be specified explicitly.
8 8
9 9 .. note::
10
10 11 Patterns specified in ``.hgignore`` are not rooted.
11 12 Please see :hg:`help hgignore` for details.
12 13
13 14 To use a plain path name without any pattern matching, start it with
14 15 ``path:``. These path names must completely match starting at the
15 16 current repository root.
16 17
17 18 To use an extended glob, start a name with ``glob:``. Globs are rooted
18 19 at the current directory; a glob such as ``*.c`` will only match files
19 20 in the current directory ending with ``.c``.
20 21
21 22 The supported glob syntax extensions are ``**`` to match any string
22 23 across path separators and ``{a,b}`` to mean "a or b".
23 24
24 25 To use a Perl/Python regular expression, start a name with ``re:``.
25 26 Regexp pattern matching is anchored at the root of the repository.
26 27
27 28 To read name patterns from a file, use ``listfile:`` or ``listfile0:``.
28 29 The latter expects null delimited patterns while the former expects line
29 30 feeds. Each string read from the file is itself treated as a file
30 31 pattern.
31 32
32 33 All patterns, except for ``glob:`` specified in command line (not for
33 34 ``-I`` or ``-X`` options), can match also against directories: files
34 35 under matched directories are treated as matched.
35 36
36 37 Plain examples::
37 38
38 39 path:foo/bar a name bar in a directory named foo in the root
39 40 of the repository
40 41 path:path:name a file or directory named "path:name"
41 42
42 43 Glob examples::
43 44
44 45 glob:*.c any name ending in ".c" in the current directory
45 46 *.c any name ending in ".c" in the current directory
46 47 **.c any name ending in ".c" in any subdirectory of the
47 48 current directory including itself.
48 49 foo/*.c any name ending in ".c" in the directory foo
49 50 foo/**.c any name ending in ".c" in any subdirectory of foo
50 51 including itself.
51 52
52 53 Regexp examples::
53 54
54 55 re:.*\.c$ any name ending in ".c", anywhere in the repository
55 56
56 57 File examples::
57 58
58 59 listfile:list.txt read list from list.txt with one file pattern per line
59 60 listfile0:list.txt read list from list.txt with null byte delimiters
60 61
61 62 See also :hg:`help filesets`.
@@ -1,91 +1,94 b''
1 1 What are phases?
2 2 ================
3 3
4 4 Phases are a system for tracking which changesets have been or should
5 5 be shared. This helps prevent common mistakes when modifying history
6 6 (for instance, with the mq or rebase extensions).
7 7
8 8 Each changeset in a repository is in one of the following phases:
9 9
10 10 - public : changeset is visible on a public server
11 11 - draft : changeset is not yet published
12 12 - secret : changeset should not be pushed, pulled, or cloned
13 13
14 14 These phases are ordered (public < draft < secret) and no changeset
15 15 can be in a lower phase than its ancestors. For instance, if a
16 16 changeset is public, all its ancestors are also public. Lastly,
17 17 changeset phases should only be changed towards the public phase.
18 18
19 19 How are phases managed?
20 20 =======================
21 21
22 22 For the most part, phases should work transparently. By default, a
23 23 changeset is created in the draft phase and is moved into the public
24 24 phase when it is pushed to another repository.
25 25
26 26 Once changesets become public, extensions like mq and rebase will
27 27 refuse to operate on them to prevent creating duplicate changesets.
28 28 Phases can also be manually manipulated with the :hg:`phase` command
29 29 if needed. See :hg:`help -v phase` for examples.
30 30
31 31 Phases and servers
32 32 ==================
33 33
34 34 Normally, all servers are ``publishing`` by default. This means::
35 35
36 36 - all draft changesets that are pulled or cloned appear in phase
37 37 public on the client
38 38
39 39 - all draft changesets that are pushed appear as public on both
40 40 client and server
41 41
42 42 - secret changesets are neither pushed, pulled, or cloned
43 43
44 44 .. note::
45
45 46 Pulling a draft changeset from a publishing server does not mark it
46 47 as public on the server side due to the read-only nature of pull.
47 48
48 49 Sometimes it may be desirable to push and pull changesets in the draft
49 50 phase to share unfinished work. This can be done by setting a
50 51 repository to disable publishing in its configuration file::
51 52
52 53 [phases]
53 54 publish = False
54 55
55 56 See :hg:`help config` for more information on configuration files.
56 57
57 58 .. note::
59
58 60 Servers running older versions of Mercurial are treated as
59 61 publishing.
60 62
61 63 .. note::
64
62 65 Changesets in secret phase are not exchanged with the server. This
63 66 applies to their content: file names, file contents, and changeset
64 67 metadata. For technical reasons, the identifier (e.g. d825e4025e39)
65 68 of the secret changeset may be communicated to the server.
66 69
67 70
68 71 Examples
69 72 ========
70 73
71 74 - list changesets in draft or secret phase::
72 75
73 76 hg log -r "not public()"
74 77
75 78 - change all secret changesets to draft::
76 79
77 80 hg phase --draft "secret()"
78 81
79 82 - forcibly move the current changeset and descendants from public to draft::
80 83
81 84 hg phase --force --draft .
82 85
83 86 - show a list of changeset revision and phase::
84 87
85 88 hg log --template "{rev} {phase}\n"
86 89
87 90 - resynchronize draft changesets relative to a remote repository::
88 91
89 92 hg phase -fd "outgoing(URL)"
90 93
91 94 See :hg:`help phase` for more information on manually manipulating phases.
@@ -1,142 +1,143 b''
1 1 Subrepositories let you nest external repositories or projects into a
2 2 parent Mercurial repository, and make commands operate on them as a
3 3 group.
4 4
5 5 Mercurial currently supports Mercurial, Git, and Subversion
6 6 subrepositories.
7 7
8 8 Subrepositories are made of three components:
9 9
10 10 1. Nested repository checkouts. They can appear anywhere in the
11 11 parent working directory.
12 12
13 13 2. Nested repository references. They are defined in ``.hgsub``, which
14 14 should be placed in the root of working directory, and
15 15 tell where the subrepository checkouts come from. Mercurial
16 16 subrepositories are referenced like::
17 17
18 18 path/to/nested = https://example.com/nested/repo/path
19 19
20 20 Git and Subversion subrepos are also supported::
21 21
22 22 path/to/nested = [git]git://example.com/nested/repo/path
23 23 path/to/nested = [svn]https://example.com/nested/trunk/path
24 24
25 25 where ``path/to/nested`` is the checkout location relatively to the
26 26 parent Mercurial root, and ``https://example.com/nested/repo/path``
27 27 is the source repository path. The source can also reference a
28 28 filesystem path.
29 29
30 30 Note that ``.hgsub`` does not exist by default in Mercurial
31 31 repositories, you have to create and add it to the parent
32 32 repository before using subrepositories.
33 33
34 34 3. Nested repository states. They are defined in ``.hgsubstate``, which
35 35 is placed in the root of working directory, and
36 36 capture whatever information is required to restore the
37 37 subrepositories to the state they were committed in a parent
38 38 repository changeset. Mercurial automatically record the nested
39 39 repositories states when committing in the parent repository.
40 40
41 41 .. note::
42
42 43 The ``.hgsubstate`` file should not be edited manually.
43 44
44 45
45 46 Adding a Subrepository
46 47 ======================
47 48
48 49 If ``.hgsub`` does not exist, create it and add it to the parent
49 50 repository. Clone or checkout the external projects where you want it
50 51 to live in the parent repository. Edit ``.hgsub`` and add the
51 52 subrepository entry as described above. At this point, the
52 53 subrepository is tracked and the next commit will record its state in
53 54 ``.hgsubstate`` and bind it to the committed changeset.
54 55
55 56 Synchronizing a Subrepository
56 57 =============================
57 58
58 59 Subrepos do not automatically track the latest changeset of their
59 60 sources. Instead, they are updated to the changeset that corresponds
60 61 with the changeset checked out in the top-level changeset. This is so
61 62 developers always get a consistent set of compatible code and
62 63 libraries when they update.
63 64
64 65 Thus, updating subrepos is a manual process. Simply check out target
65 66 subrepo at the desired revision, test in the top-level repo, then
66 67 commit in the parent repository to record the new combination.
67 68
68 69 Deleting a Subrepository
69 70 ========================
70 71
71 72 To remove a subrepository from the parent repository, delete its
72 73 reference from ``.hgsub``, then remove its files.
73 74
74 75 Interaction with Mercurial Commands
75 76 ===================================
76 77
77 78 :add: add does not recurse in subrepos unless -S/--subrepos is
78 79 specified. However, if you specify the full path of a file in a
79 80 subrepo, it will be added even without -S/--subrepos specified.
80 81 Git and Subversion subrepositories are currently silently
81 82 ignored.
82 83
83 84 :archive: archive does not recurse in subrepositories unless
84 85 -S/--subrepos is specified.
85 86
86 87 :commit: commit creates a consistent snapshot of the state of the
87 88 entire project and its subrepositories. If any subrepositories
88 89 have been modified, Mercurial will abort. Mercurial can be made
89 90 to instead commit all modified subrepositories by specifying
90 91 -S/--subrepos, or setting "ui.commitsubrepos=True" in a
91 92 configuration file (see :hg:`help config`). After there are no
92 93 longer any modified subrepositories, it records their state and
93 94 finally commits it in the parent repository.
94 95
95 96 :diff: diff does not recurse in subrepos unless -S/--subrepos is
96 97 specified. Changes are displayed as usual, on the subrepositories
97 98 elements. Git and Subversion subrepositories are currently
98 99 silently ignored.
99 100
100 101 :forget: forget currently only handles exact file matches in subrepos.
101 102 Git and Subversion subrepositories are currently silently ignored.
102 103
103 104 :incoming: incoming does not recurse in subrepos unless -S/--subrepos
104 105 is specified. Git and Subversion subrepositories are currently
105 106 silently ignored.
106 107
107 108 :outgoing: outgoing does not recurse in subrepos unless -S/--subrepos
108 109 is specified. Git and Subversion subrepositories are currently
109 110 silently ignored.
110 111
111 112 :pull: pull is not recursive since it is not clear what to pull prior
112 113 to running :hg:`update`. Listing and retrieving all
113 114 subrepositories changes referenced by the parent repository pulled
114 115 changesets is expensive at best, impossible in the Subversion
115 116 case.
116 117
117 118 :push: Mercurial will automatically push all subrepositories first
118 119 when the parent repository is being pushed. This ensures new
119 120 subrepository changes are available when referenced by top-level
120 121 repositories. Push is a no-op for Subversion subrepositories.
121 122
122 123 :status: status does not recurse into subrepositories unless
123 124 -S/--subrepos is specified. Subrepository changes are displayed as
124 125 regular Mercurial changes on the subrepository
125 126 elements. Subversion subrepositories are currently silently
126 127 ignored.
127 128
128 129 :update: update restores the subrepos in the state they were
129 130 originally committed in target changeset. If the recorded
130 131 changeset is not available in the current subrepository, Mercurial
131 132 will pull it in first before updating. This means that updating
132 133 can require network access when using subrepositories.
133 134
134 135 Remapping Subrepositories Sources
135 136 =================================
136 137
137 138 A subrepository source location may change during a project life,
138 139 invalidating references stored in the parent repository history. To
139 140 fix this, rewriting rules can be defined in parent repository ``hgrc``
140 141 file or in Mercurial configuration. See the ``[subpaths]`` section in
141 142 hgrc(5) for more details.
142 143
General Comments 0
You need to be logged in to leave comments. Login now