##// END OF EJS Templates
help: show "default: off" for boolean flags that default to off...
Martin von Zweigbergk -
r40990:8604f130 default
parent child Browse files
Show More
@@ -1,864 +1,864 b''
1 1 # help.py - help data for mercurial
2 2 #
3 3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import itertools
11 11 import os
12 12 import re
13 13 import textwrap
14 14
15 15 from .i18n import (
16 16 _,
17 17 gettext,
18 18 )
19 19 from . import (
20 20 cmdutil,
21 21 encoding,
22 22 error,
23 23 extensions,
24 24 fancyopts,
25 25 filemerge,
26 26 fileset,
27 27 minirst,
28 28 pycompat,
29 29 registrar,
30 30 revset,
31 31 templatefilters,
32 32 templatefuncs,
33 33 templatekw,
34 34 ui as uimod,
35 35 util,
36 36 )
37 37 from .hgweb import (
38 38 webcommands,
39 39 )
40 40
41 41 _exclkeywords = {
42 42 "(ADVANCED)",
43 43 "(DEPRECATED)",
44 44 "(EXPERIMENTAL)",
45 45 # i18n: "(ADVANCED)" is a keyword, must be translated consistently
46 46 _("(ADVANCED)"),
47 47 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
48 48 _("(DEPRECATED)"),
49 49 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
50 50 _("(EXPERIMENTAL)"),
51 51 }
52 52
53 53 # The order in which command categories will be displayed.
54 54 # Extensions with custom categories should insert them into this list
55 55 # after/before the appropriate item, rather than replacing the list or
56 56 # assuming absolute positions.
57 57 CATEGORY_ORDER = [
58 58 registrar.command.CATEGORY_REPO_CREATION,
59 59 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT,
60 60 registrar.command.CATEGORY_COMMITTING,
61 61 registrar.command.CATEGORY_CHANGE_MANAGEMENT,
62 62 registrar.command.CATEGORY_CHANGE_ORGANIZATION,
63 63 registrar.command.CATEGORY_FILE_CONTENTS,
64 64 registrar.command.CATEGORY_CHANGE_NAVIGATION ,
65 65 registrar.command.CATEGORY_WORKING_DIRECTORY,
66 66 registrar.command.CATEGORY_IMPORT_EXPORT,
67 67 registrar.command.CATEGORY_MAINTENANCE,
68 68 registrar.command.CATEGORY_HELP,
69 69 registrar.command.CATEGORY_MISC,
70 70 registrar.command.CATEGORY_NONE,
71 71 ]
72 72
73 73 # Human-readable category names. These are translated.
74 74 # Extensions with custom categories should add their names here.
75 75 CATEGORY_NAMES = {
76 76 registrar.command.CATEGORY_REPO_CREATION: 'Repository creation',
77 77 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT:
78 78 'Remote repository management',
79 79 registrar.command.CATEGORY_COMMITTING: 'Change creation',
80 80 registrar.command.CATEGORY_CHANGE_NAVIGATION: 'Change navigation',
81 81 registrar.command.CATEGORY_CHANGE_MANAGEMENT: 'Change manipulation',
82 82 registrar.command.CATEGORY_CHANGE_ORGANIZATION: 'Change organization',
83 83 registrar.command.CATEGORY_WORKING_DIRECTORY:
84 84 'Working directory management',
85 85 registrar.command.CATEGORY_FILE_CONTENTS: 'File content management',
86 86 registrar.command.CATEGORY_IMPORT_EXPORT: 'Change import/export',
87 87 registrar.command.CATEGORY_MAINTENANCE: 'Repository maintenance',
88 88 registrar.command.CATEGORY_HELP: 'Help',
89 89 registrar.command.CATEGORY_MISC: 'Miscellaneous commands',
90 90 registrar.command.CATEGORY_NONE: 'Uncategorized commands',
91 91 }
92 92
93 93 # Topic categories.
94 94 TOPIC_CATEGORY_IDS = 'ids'
95 95 TOPIC_CATEGORY_OUTPUT = 'output'
96 96 TOPIC_CATEGORY_CONFIG = 'config'
97 97 TOPIC_CATEGORY_CONCEPTS = 'concepts'
98 98 TOPIC_CATEGORY_MISC = 'misc'
99 99 TOPIC_CATEGORY_NONE = 'none'
100 100
101 101 # The order in which topic categories will be displayed.
102 102 # Extensions with custom categories should insert them into this list
103 103 # after/before the appropriate item, rather than replacing the list or
104 104 # assuming absolute positions.
105 105 TOPIC_CATEGORY_ORDER = [
106 106 TOPIC_CATEGORY_IDS,
107 107 TOPIC_CATEGORY_OUTPUT,
108 108 TOPIC_CATEGORY_CONFIG,
109 109 TOPIC_CATEGORY_CONCEPTS,
110 110 TOPIC_CATEGORY_MISC,
111 111 TOPIC_CATEGORY_NONE,
112 112 ]
113 113
114 114 # Human-readable topic category names. These are translated.
115 115 TOPIC_CATEGORY_NAMES = {
116 116 TOPIC_CATEGORY_IDS: 'Mercurial identifiers',
117 117 TOPIC_CATEGORY_OUTPUT: 'Mercurial output',
118 118 TOPIC_CATEGORY_CONFIG: 'Mercurial configuration',
119 119 TOPIC_CATEGORY_CONCEPTS: 'Concepts',
120 120 TOPIC_CATEGORY_MISC: 'Miscellaneous',
121 121 TOPIC_CATEGORY_NONE: 'Uncategorized topics',
122 122 TOPIC_CATEGORY_NONE: 'Uncategorized topics',
123 123 }
124 124
125 125 def listexts(header, exts, indent=1, showdeprecated=False):
126 126 '''return a text listing of the given extensions'''
127 127 rst = []
128 128 if exts:
129 129 for name, desc in sorted(exts.iteritems()):
130 130 if not showdeprecated and any(w in desc for w in _exclkeywords):
131 131 continue
132 132 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
133 133 if rst:
134 134 rst.insert(0, '\n%s\n\n' % header)
135 135 return rst
136 136
137 137 def extshelp(ui):
138 138 rst = loaddoc('extensions')(ui).splitlines(True)
139 139 rst.extend(listexts(
140 140 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
141 141 rst.extend(listexts(_('disabled extensions:'), extensions.disabled(),
142 142 showdeprecated=ui.verbose))
143 143 doc = ''.join(rst)
144 144 return doc
145 145
146 146 def optrst(header, options, verbose):
147 147 data = []
148 148 multioccur = False
149 149 for option in options:
150 150 if len(option) == 5:
151 151 shortopt, longopt, default, desc, optlabel = option
152 152 else:
153 153 shortopt, longopt, default, desc = option
154 154 optlabel = _("VALUE") # default label
155 155
156 156 if not verbose and any(w in desc for w in _exclkeywords):
157 157 continue
158 158
159 159 so = ''
160 160 if shortopt:
161 161 so = '-' + shortopt
162 162 lo = '--' + longopt
163 163
164 164 if isinstance(default, fancyopts.customopt):
165 165 default = default.getdefaultvalue()
166 if default and not callable(default):
166 if (default and not callable(default)) or default is False:
167 167 # default is of unknown type, and in Python 2 we abused
168 168 # the %s-shows-repr property to handle integers etc. To
169 169 # match that behavior on Python 3, we do str(default) and
170 170 # then convert it to bytes.
171 171 defaultstr = pycompat.bytestr(default)
172 if default is True:
173 defaultstr = _("on")
172 if isinstance(default, bool):
173 defaultstr = _("on") if default else _("off")
174 174 desc += _(" (default: %s)") % defaultstr
175 175
176 176 if isinstance(default, list):
177 177 lo += " %s [+]" % optlabel
178 178 multioccur = True
179 179 elif (default is not None) and not isinstance(default, bool):
180 180 lo += " %s" % optlabel
181 181
182 182 data.append((so, lo, desc))
183 183
184 184 if multioccur:
185 185 header += (_(" ([+] can be repeated)"))
186 186
187 187 rst = ['\n%s:\n\n' % header]
188 188 rst.extend(minirst.maketable(data, 1))
189 189
190 190 return ''.join(rst)
191 191
192 192 def indicateomitted(rst, omitted, notomitted=None):
193 193 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
194 194 if notomitted:
195 195 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
196 196
197 197 def filtercmd(ui, cmd, func, kw, doc):
198 198 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
199 199 # Debug command, and user is not looking for those.
200 200 return True
201 201 if not ui.verbose:
202 202 if not kw and not doc:
203 203 # Command had no documentation, no point in showing it by default.
204 204 return True
205 205 if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False):
206 206 # Alias didn't have its own documentation.
207 207 return True
208 208 if doc and any(w in doc for w in _exclkeywords):
209 209 # Documentation has excluded keywords.
210 210 return True
211 211 if kw == "shortlist" and not getattr(func, 'helpbasic', False):
212 212 # We're presenting the short list but the command is not basic.
213 213 return True
214 214 if ui.configbool('help', 'hidden-command.%s' % cmd):
215 215 # Configuration explicitly hides the command.
216 216 return True
217 217 return False
218 218
219 219 def filtertopic(ui, topic):
220 220 return ui.configbool('help', 'hidden-topic.%s' % topic, False)
221 221
222 222 def topicmatch(ui, commands, kw):
223 223 """Return help topics matching kw.
224 224
225 225 Returns {'section': [(name, summary), ...], ...} where section is
226 226 one of topics, commands, extensions, or extensioncommands.
227 227 """
228 228 kw = encoding.lower(kw)
229 229 def lowercontains(container):
230 230 return kw in encoding.lower(container) # translated in helptable
231 231 results = {'topics': [],
232 232 'commands': [],
233 233 'extensions': [],
234 234 'extensioncommands': [],
235 235 }
236 236 for topic in helptable:
237 237 names, header, doc = topic[0:3]
238 238 # Old extensions may use a str as doc.
239 239 if (sum(map(lowercontains, names))
240 240 or lowercontains(header)
241 241 or (callable(doc) and lowercontains(doc(ui)))):
242 242 name = names[0]
243 243 if not filtertopic(ui, name):
244 244 results['topics'].append((names[0], header))
245 245 for cmd, entry in commands.table.iteritems():
246 246 if len(entry) == 3:
247 247 summary = entry[2]
248 248 else:
249 249 summary = ''
250 250 # translate docs *before* searching there
251 251 func = entry[0]
252 252 docs = _(pycompat.getdoc(func)) or ''
253 253 if kw in cmd or lowercontains(summary) or lowercontains(docs):
254 254 doclines = docs.splitlines()
255 255 if doclines:
256 256 summary = doclines[0]
257 257 cmdname = cmdutil.parsealiases(cmd)[0]
258 258 if filtercmd(ui, cmdname, func, kw, docs):
259 259 continue
260 260 results['commands'].append((cmdname, summary))
261 261 for name, docs in itertools.chain(
262 262 extensions.enabled(False).iteritems(),
263 263 extensions.disabled().iteritems()):
264 264 if not docs:
265 265 continue
266 266 name = name.rpartition('.')[-1]
267 267 if lowercontains(name) or lowercontains(docs):
268 268 # extension docs are already translated
269 269 results['extensions'].append((name, docs.splitlines()[0]))
270 270 try:
271 271 mod = extensions.load(ui, name, '')
272 272 except ImportError:
273 273 # debug message would be printed in extensions.load()
274 274 continue
275 275 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
276 276 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
277 277 cmdname = cmdutil.parsealiases(cmd)[0]
278 278 func = entry[0]
279 279 cmddoc = pycompat.getdoc(func)
280 280 if cmddoc:
281 281 cmddoc = gettext(cmddoc).splitlines()[0]
282 282 else:
283 283 cmddoc = _('(no help text available)')
284 284 if filtercmd(ui, cmdname, func, kw, cmddoc):
285 285 continue
286 286 results['extensioncommands'].append((cmdname, cmddoc))
287 287 return results
288 288
289 289 def loaddoc(topic, subdir=None):
290 290 """Return a delayed loader for help/topic.txt."""
291 291
292 292 def loader(ui):
293 293 docdir = os.path.join(util.datapath, 'help')
294 294 if subdir:
295 295 docdir = os.path.join(docdir, subdir)
296 296 path = os.path.join(docdir, topic + ".txt")
297 297 doc = gettext(util.readfile(path))
298 298 for rewriter in helphooks.get(topic, []):
299 299 doc = rewriter(ui, topic, doc)
300 300 return doc
301 301
302 302 return loader
303 303
304 304 internalstable = sorted([
305 305 (['bundle2'], _('Bundle2'),
306 306 loaddoc('bundle2', subdir='internals')),
307 307 (['bundles'], _('Bundles'),
308 308 loaddoc('bundles', subdir='internals')),
309 309 (['cbor'], _('CBOR'),
310 310 loaddoc('cbor', subdir='internals')),
311 311 (['censor'], _('Censor'),
312 312 loaddoc('censor', subdir='internals')),
313 313 (['changegroups'], _('Changegroups'),
314 314 loaddoc('changegroups', subdir='internals')),
315 315 (['config'], _('Config Registrar'),
316 316 loaddoc('config', subdir='internals')),
317 317 (['extensions', 'extension'], _('Extension API'),
318 318 loaddoc('extensions', subdir='internals')),
319 319 (['requirements'], _('Repository Requirements'),
320 320 loaddoc('requirements', subdir='internals')),
321 321 (['revlogs'], _('Revision Logs'),
322 322 loaddoc('revlogs', subdir='internals')),
323 323 (['wireprotocol'], _('Wire Protocol'),
324 324 loaddoc('wireprotocol', subdir='internals')),
325 325 (['wireprotocolrpc'], _('Wire Protocol RPC'),
326 326 loaddoc('wireprotocolrpc', subdir='internals')),
327 327 (['wireprotocolv2'], _('Wire Protocol Version 2'),
328 328 loaddoc('wireprotocolv2', subdir='internals')),
329 329 ])
330 330
331 331 def internalshelp(ui):
332 332 """Generate the index for the "internals" topic."""
333 333 lines = ['To access a subtopic, use "hg help internals.{subtopic-name}"\n',
334 334 '\n']
335 335 for names, header, doc in internalstable:
336 336 lines.append(' :%s: %s\n' % (names[0], header))
337 337
338 338 return ''.join(lines)
339 339
340 340 helptable = sorted([
341 341 (['bundlespec'], _("Bundle File Formats"), loaddoc('bundlespec'),
342 342 TOPIC_CATEGORY_CONCEPTS),
343 343 (['color'], _("Colorizing Outputs"), loaddoc('color'),
344 344 TOPIC_CATEGORY_OUTPUT),
345 345 (["config", "hgrc"], _("Configuration Files"), loaddoc('config'),
346 346 TOPIC_CATEGORY_CONFIG),
347 347 (['deprecated'], _("Deprecated Features"), loaddoc('deprecated'),
348 348 TOPIC_CATEGORY_MISC),
349 349 (["dates"], _("Date Formats"), loaddoc('dates'), TOPIC_CATEGORY_OUTPUT),
350 350 (["flags"], _("Command-line flags"), loaddoc('flags'),
351 351 TOPIC_CATEGORY_CONFIG),
352 352 (["patterns"], _("File Name Patterns"), loaddoc('patterns'),
353 353 TOPIC_CATEGORY_IDS),
354 354 (['environment', 'env'], _('Environment Variables'),
355 355 loaddoc('environment'), TOPIC_CATEGORY_CONFIG),
356 356 (['revisions', 'revs', 'revsets', 'revset', 'multirevs', 'mrevs'],
357 357 _('Specifying Revisions'), loaddoc('revisions'), TOPIC_CATEGORY_IDS),
358 358 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets'),
359 359 TOPIC_CATEGORY_IDS),
360 360 (['diffs'], _('Diff Formats'), loaddoc('diffs'), TOPIC_CATEGORY_OUTPUT),
361 361 (['merge-tools', 'mergetools', 'mergetool'], _('Merge Tools'),
362 362 loaddoc('merge-tools'), TOPIC_CATEGORY_CONFIG),
363 363 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
364 364 loaddoc('templates'), TOPIC_CATEGORY_OUTPUT),
365 365 (['urls'], _('URL Paths'), loaddoc('urls'), TOPIC_CATEGORY_IDS),
366 366 (["extensions"], _("Using Additional Features"), extshelp,
367 367 TOPIC_CATEGORY_CONFIG),
368 368 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos'),
369 369 TOPIC_CATEGORY_CONCEPTS),
370 370 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb'),
371 371 TOPIC_CATEGORY_CONFIG),
372 372 (["glossary"], _("Glossary"), loaddoc('glossary'), TOPIC_CATEGORY_CONCEPTS),
373 373 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
374 374 loaddoc('hgignore'), TOPIC_CATEGORY_IDS),
375 375 (["phases"], _("Working with Phases"), loaddoc('phases'),
376 376 TOPIC_CATEGORY_CONCEPTS),
377 377 (['scripting'], _('Using Mercurial from scripts and automation'),
378 378 loaddoc('scripting'), TOPIC_CATEGORY_MISC),
379 379 (['internals'], _("Technical implementation topics"), internalshelp,
380 380 TOPIC_CATEGORY_MISC),
381 381 (['pager'], _("Pager Support"), loaddoc('pager'), TOPIC_CATEGORY_CONFIG),
382 382 ])
383 383
384 384 # Maps topics with sub-topics to a list of their sub-topics.
385 385 subtopics = {
386 386 'internals': internalstable,
387 387 }
388 388
389 389 # Map topics to lists of callable taking the current topic help and
390 390 # returning the updated version
391 391 helphooks = {}
392 392
393 393 def addtopichook(topic, rewriter):
394 394 helphooks.setdefault(topic, []).append(rewriter)
395 395
396 396 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
397 397 """Extract docstring from the items key to function mapping, build a
398 398 single documentation block and use it to overwrite the marker in doc.
399 399 """
400 400 entries = []
401 401 for name in sorted(items):
402 402 text = (pycompat.getdoc(items[name]) or '').rstrip()
403 403 if (not text
404 404 or not ui.verbose and any(w in text for w in _exclkeywords)):
405 405 continue
406 406 text = gettext(text)
407 407 if dedent:
408 408 # Abuse latin1 to use textwrap.dedent() on bytes.
409 409 text = textwrap.dedent(text.decode('latin1')).encode('latin1')
410 410 lines = text.splitlines()
411 411 doclines = [(lines[0])]
412 412 for l in lines[1:]:
413 413 # Stop once we find some Python doctest
414 414 if l.strip().startswith('>>>'):
415 415 break
416 416 if dedent:
417 417 doclines.append(l.rstrip())
418 418 else:
419 419 doclines.append(' ' + l.strip())
420 420 entries.append('\n'.join(doclines))
421 421 entries = '\n\n'.join(entries)
422 422 return doc.replace(marker, entries)
423 423
424 424 def addtopicsymbols(topic, marker, symbols, dedent=False):
425 425 def add(ui, topic, doc):
426 426 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
427 427 addtopichook(topic, add)
428 428
429 429 addtopicsymbols('bundlespec', '.. bundlecompressionmarker',
430 430 util.bundlecompressiontopics())
431 431 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
432 432 addtopicsymbols('merge-tools', '.. internaltoolsmarker',
433 433 filemerge.internalsdoc)
434 434 addtopicsymbols('revisions', '.. predicatesmarker', revset.symbols)
435 435 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
436 436 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
437 437 addtopicsymbols('templates', '.. functionsmarker', templatefuncs.funcs)
438 438 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
439 439 dedent=True)
440 440
441 441 def inserttweakrc(ui, topic, doc):
442 442 marker = '.. tweakdefaultsmarker'
443 443 repl = uimod.tweakrc
444 444 def sub(m):
445 445 lines = [m.group(1) + s for s in repl.splitlines()]
446 446 return '\n'.join(lines)
447 447 return re.sub(br'( *)%s' % re.escape(marker), sub, doc)
448 448
449 449 addtopichook('config', inserttweakrc)
450 450
451 451 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None,
452 452 **opts):
453 453 '''
454 454 Generate the help for 'name' as unformatted restructured text. If
455 455 'name' is None, describe the commands available.
456 456 '''
457 457
458 458 opts = pycompat.byteskwargs(opts)
459 459
460 460 def helpcmd(name, subtopic=None):
461 461 try:
462 462 aliases, entry = cmdutil.findcmd(name, commands.table,
463 463 strict=unknowncmd)
464 464 except error.AmbiguousCommand as inst:
465 465 # py3 fix: except vars can't be used outside the scope of the
466 466 # except block, nor can be used inside a lambda. python issue4617
467 467 prefix = inst.args[0]
468 468 select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix)
469 469 rst = helplist(select)
470 470 return rst
471 471
472 472 rst = []
473 473
474 474 # check if it's an invalid alias and display its error if it is
475 475 if getattr(entry[0], 'badalias', None):
476 476 rst.append(entry[0].badalias + '\n')
477 477 if entry[0].unknowncmd:
478 478 try:
479 479 rst.extend(helpextcmd(entry[0].cmdname))
480 480 except error.UnknownCommand:
481 481 pass
482 482 return rst
483 483
484 484 # synopsis
485 485 if len(entry) > 2:
486 486 if entry[2].startswith('hg'):
487 487 rst.append("%s\n" % entry[2])
488 488 else:
489 489 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
490 490 else:
491 491 rst.append('hg %s\n' % aliases[0])
492 492 # aliases
493 493 if full and not ui.quiet and len(aliases) > 1:
494 494 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
495 495 rst.append('\n')
496 496
497 497 # description
498 498 doc = gettext(pycompat.getdoc(entry[0]))
499 499 if not doc:
500 500 doc = _("(no help text available)")
501 501 if util.safehasattr(entry[0], 'definition'): # aliased command
502 502 source = entry[0].source
503 503 if entry[0].definition.startswith('!'): # shell alias
504 504 doc = (_('shell alias for: %s\n\n%s\n\ndefined by: %s\n') %
505 505 (entry[0].definition[1:], doc, source))
506 506 else:
507 507 doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') %
508 508 (entry[0].definition, doc, source))
509 509 doc = doc.splitlines(True)
510 510 if ui.quiet or not full:
511 511 rst.append(doc[0])
512 512 else:
513 513 rst.extend(doc)
514 514 rst.append('\n')
515 515
516 516 # check if this command shadows a non-trivial (multi-line)
517 517 # extension help text
518 518 try:
519 519 mod = extensions.find(name)
520 520 doc = gettext(pycompat.getdoc(mod)) or ''
521 521 if '\n' in doc.strip():
522 522 msg = _("(use 'hg help -e %s' to show help for "
523 523 "the %s extension)") % (name, name)
524 524 rst.append('\n%s\n' % msg)
525 525 except KeyError:
526 526 pass
527 527
528 528 # options
529 529 if not ui.quiet and entry[1]:
530 530 rst.append(optrst(_("options"), entry[1], ui.verbose))
531 531
532 532 if ui.verbose:
533 533 rst.append(optrst(_("global options"),
534 534 commands.globalopts, ui.verbose))
535 535
536 536 if not ui.verbose:
537 537 if not full:
538 538 rst.append(_("\n(use 'hg %s -h' to show more help)\n")
539 539 % name)
540 540 elif not ui.quiet:
541 541 rst.append(_('\n(some details hidden, use --verbose '
542 542 'to show complete help)'))
543 543
544 544 return rst
545 545
546 546 def helplist(select=None, **opts):
547 547 # Category -> list of commands
548 548 cats = {}
549 549 # Command -> short description
550 550 h = {}
551 551 # Command -> string showing synonyms
552 552 syns = {}
553 553 for c, e in commands.table.iteritems():
554 554 fs = cmdutil.parsealiases(c)
555 555 f = fs[0]
556 556 syns[f] = ', '.join(fs)
557 557 func = e[0]
558 558 if select and not select(f):
559 559 continue
560 560 doc = pycompat.getdoc(func)
561 561 if filtercmd(ui, f, func, name, doc):
562 562 continue
563 563 doc = gettext(doc)
564 564 if not doc:
565 565 doc = _("(no help text available)")
566 566 h[f] = doc.splitlines()[0].rstrip()
567 567
568 568 cat = getattr(func, 'helpcategory', None) or (
569 569 registrar.command.CATEGORY_NONE)
570 570 cats.setdefault(cat, []).append(f)
571 571
572 572 rst = []
573 573 if not h:
574 574 if not ui.quiet:
575 575 rst.append(_('no commands defined\n'))
576 576 return rst
577 577
578 578 # Output top header.
579 579 if not ui.quiet:
580 580 if name == "shortlist":
581 581 rst.append(_('basic commands:\n\n'))
582 582 elif name == "debug":
583 583 rst.append(_('debug commands (internal and unsupported):\n\n'))
584 584 else:
585 585 rst.append(_('list of commands:\n'))
586 586
587 587 def appendcmds(cmds):
588 588 cmds = sorted(cmds)
589 589 for c in cmds:
590 590 if ui.verbose:
591 591 rst.append(" :%s: %s\n" % (syns[c], h[c]))
592 592 else:
593 593 rst.append(' :%s: %s\n' % (c, h[c]))
594 594
595 595 if name in ('shortlist', 'debug'):
596 596 # List without categories.
597 597 appendcmds(h)
598 598 else:
599 599 # Check that all categories have an order.
600 600 missing_order = set(cats.keys()) - set(CATEGORY_ORDER)
601 601 if missing_order:
602 602 ui.develwarn('help categories missing from CATEGORY_ORDER: %s' %
603 603 missing_order)
604 604
605 605 # List per category.
606 606 for cat in CATEGORY_ORDER:
607 607 catfns = cats.get(cat, [])
608 608 if catfns:
609 609 if len(cats) > 1:
610 610 catname = gettext(CATEGORY_NAMES[cat])
611 611 rst.append("\n%s:\n" % catname)
612 612 rst.append("\n")
613 613 appendcmds(catfns)
614 614
615 615 ex = opts.get
616 616 anyopts = (ex(r'keyword') or not (ex(r'command') or ex(r'extension')))
617 617 if not name and anyopts:
618 618 exts = listexts(_('enabled extensions:'), extensions.enabled())
619 619 if exts:
620 620 rst.append('\n')
621 621 rst.extend(exts)
622 622
623 623 rst.append(_("\nadditional help topics:\n"))
624 624 # Group commands by category.
625 625 topiccats = {}
626 626 for topic in helptable:
627 627 names, header, doc = topic[0:3]
628 628 if len(topic) > 3 and topic[3]:
629 629 category = topic[3]
630 630 else:
631 631 category = TOPIC_CATEGORY_NONE
632 632
633 633 topicname = names[0]
634 634 if not filtertopic(ui, topicname):
635 635 topiccats.setdefault(category, []).append(
636 636 (topicname, header))
637 637
638 638 # Check that all categories have an order.
639 639 missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
640 640 if missing_order:
641 641 ui.develwarn(
642 642 'help categories missing from TOPIC_CATEGORY_ORDER: %s' %
643 643 missing_order)
644 644
645 645 # Output topics per category.
646 646 for cat in TOPIC_CATEGORY_ORDER:
647 647 topics = topiccats.get(cat, [])
648 648 if topics:
649 649 if len(topiccats) > 1:
650 650 catname = gettext(TOPIC_CATEGORY_NAMES[cat])
651 651 rst.append("\n%s:\n" % catname)
652 652 rst.append("\n")
653 653 for t, desc in topics:
654 654 rst.append(" :%s: %s\n" % (t, desc))
655 655
656 656 if ui.quiet:
657 657 pass
658 658 elif ui.verbose:
659 659 rst.append('\n%s\n' % optrst(_("global options"),
660 660 commands.globalopts, ui.verbose))
661 661 if name == 'shortlist':
662 662 rst.append(_("\n(use 'hg help' for the full list "
663 663 "of commands)\n"))
664 664 else:
665 665 if name == 'shortlist':
666 666 rst.append(_("\n(use 'hg help' for the full list of commands "
667 667 "or 'hg -v' for details)\n"))
668 668 elif name and not full:
669 669 rst.append(_("\n(use 'hg help %s' to show the full help "
670 670 "text)\n") % name)
671 671 elif name and syns and name in syns.keys():
672 672 rst.append(_("\n(use 'hg help -v -e %s' to show built-in "
673 673 "aliases and global options)\n") % name)
674 674 else:
675 675 rst.append(_("\n(use 'hg help -v%s' to show built-in aliases "
676 676 "and global options)\n")
677 677 % (name and " " + name or ""))
678 678 return rst
679 679
680 680 def helptopic(name, subtopic=None):
681 681 # Look for sub-topic entry first.
682 682 header, doc = None, None
683 683 if subtopic and name in subtopics:
684 684 for names, header, doc in subtopics[name]:
685 685 if subtopic in names:
686 686 break
687 687
688 688 if not header:
689 689 for topic in helptable:
690 690 names, header, doc = topic[0:3]
691 691 if name in names:
692 692 break
693 693 else:
694 694 raise error.UnknownCommand(name)
695 695
696 696 rst = [minirst.section(header)]
697 697
698 698 # description
699 699 if not doc:
700 700 rst.append(" %s\n" % _("(no help text available)"))
701 701 if callable(doc):
702 702 rst += [" %s\n" % l for l in doc(ui).splitlines()]
703 703
704 704 if not ui.verbose:
705 705 omitted = _('(some details hidden, use --verbose'
706 706 ' to show complete help)')
707 707 indicateomitted(rst, omitted)
708 708
709 709 try:
710 710 cmdutil.findcmd(name, commands.table)
711 711 rst.append(_("\nuse 'hg help -c %s' to see help for "
712 712 "the %s command\n") % (name, name))
713 713 except error.UnknownCommand:
714 714 pass
715 715 return rst
716 716
717 717 def helpext(name, subtopic=None):
718 718 try:
719 719 mod = extensions.find(name)
720 720 doc = gettext(pycompat.getdoc(mod)) or _('no help text available')
721 721 except KeyError:
722 722 mod = None
723 723 doc = extensions.disabledext(name)
724 724 if not doc:
725 725 raise error.UnknownCommand(name)
726 726
727 727 if '\n' not in doc:
728 728 head, tail = doc, ""
729 729 else:
730 730 head, tail = doc.split('\n', 1)
731 731 rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)]
732 732 if tail:
733 733 rst.extend(tail.splitlines(True))
734 734 rst.append('\n')
735 735
736 736 if not ui.verbose:
737 737 omitted = _('(some details hidden, use --verbose'
738 738 ' to show complete help)')
739 739 indicateomitted(rst, omitted)
740 740
741 741 if mod:
742 742 try:
743 743 ct = mod.cmdtable
744 744 except AttributeError:
745 745 ct = {}
746 746 modcmds = set([c.partition('|')[0] for c in ct])
747 747 rst.extend(helplist(modcmds.__contains__))
748 748 else:
749 749 rst.append(_("(use 'hg help extensions' for information on enabling"
750 750 " extensions)\n"))
751 751 return rst
752 752
753 753 def helpextcmd(name, subtopic=None):
754 754 cmd, ext, doc = extensions.disabledcmd(ui, name,
755 755 ui.configbool('ui', 'strict'))
756 756 doc = doc.splitlines()[0]
757 757
758 758 rst = listexts(_("'%s' is provided by the following "
759 759 "extension:") % cmd, {ext: doc}, indent=4,
760 760 showdeprecated=True)
761 761 rst.append('\n')
762 762 rst.append(_("(use 'hg help extensions' for information on enabling "
763 763 "extensions)\n"))
764 764 return rst
765 765
766 766
767 767 rst = []
768 768 kw = opts.get('keyword')
769 769 if kw or name is None and any(opts[o] for o in opts):
770 770 matches = topicmatch(ui, commands, name or '')
771 771 helpareas = []
772 772 if opts.get('extension'):
773 773 helpareas += [('extensions', _('Extensions'))]
774 774 if opts.get('command'):
775 775 helpareas += [('commands', _('Commands'))]
776 776 if not helpareas:
777 777 helpareas = [('topics', _('Topics')),
778 778 ('commands', _('Commands')),
779 779 ('extensions', _('Extensions')),
780 780 ('extensioncommands', _('Extension Commands'))]
781 781 for t, title in helpareas:
782 782 if matches[t]:
783 783 rst.append('%s:\n\n' % title)
784 784 rst.extend(minirst.maketable(sorted(matches[t]), 1))
785 785 rst.append('\n')
786 786 if not rst:
787 787 msg = _('no matches')
788 788 hint = _("try 'hg help' for a list of topics")
789 789 raise error.Abort(msg, hint=hint)
790 790 elif name and name != 'shortlist':
791 791 queries = []
792 792 if unknowncmd:
793 793 queries += [helpextcmd]
794 794 if opts.get('extension'):
795 795 queries += [helpext]
796 796 if opts.get('command'):
797 797 queries += [helpcmd]
798 798 if not queries:
799 799 queries = (helptopic, helpcmd, helpext, helpextcmd)
800 800 for f in queries:
801 801 try:
802 802 rst = f(name, subtopic)
803 803 break
804 804 except error.UnknownCommand:
805 805 pass
806 806 else:
807 807 if unknowncmd:
808 808 raise error.UnknownCommand(name)
809 809 else:
810 810 msg = _('no such help topic: %s') % name
811 811 hint = _("try 'hg help --keyword %s'") % name
812 812 raise error.Abort(msg, hint=hint)
813 813 else:
814 814 # program name
815 815 if not ui.quiet:
816 816 rst = [_("Mercurial Distributed SCM\n"), '\n']
817 817 rst.extend(helplist(None, **pycompat.strkwargs(opts)))
818 818
819 819 return ''.join(rst)
820 820
821 821 def formattedhelp(ui, commands, fullname, keep=None, unknowncmd=False,
822 822 full=True, **opts):
823 823 """get help for a given topic (as a dotted name) as rendered rst
824 824
825 825 Either returns the rendered help text or raises an exception.
826 826 """
827 827 if keep is None:
828 828 keep = []
829 829 else:
830 830 keep = list(keep) # make a copy so we can mutate this later
831 831
832 832 # <fullname> := <name>[.<subtopic][.<section>]
833 833 name = subtopic = section = None
834 834 if fullname is not None:
835 835 nameparts = fullname.split('.')
836 836 name = nameparts.pop(0)
837 837 if nameparts and name in subtopics:
838 838 subtopic = nameparts.pop(0)
839 839 if nameparts:
840 840 section = encoding.lower('.'.join(nameparts))
841 841
842 842 textwidth = ui.configint('ui', 'textwidth')
843 843 termwidth = ui.termwidth() - 2
844 844 if textwidth <= 0 or termwidth < textwidth:
845 845 textwidth = termwidth
846 846 text = help_(ui, commands, name,
847 847 subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
848 848
849 849 blocks, pruned = minirst.parse(text, keep=keep)
850 850 if 'verbose' in pruned:
851 851 keep.append('omitted')
852 852 else:
853 853 keep.append('notomitted')
854 854 blocks, pruned = minirst.parse(text, keep=keep)
855 855 if section:
856 856 blocks = minirst.filtersections(blocks, section)
857 857
858 858 # We could have been given a weird ".foo" section without a name
859 859 # to look for, or we could have simply failed to found "foo.bar"
860 860 # because bar isn't a section of foo
861 861 if section and not (blocks and name):
862 862 raise error.Abort(_("help section not found: %s") % fullname)
863 863
864 864 return minirst.formatplain(blocks, textwidth)
@@ -1,1838 +1,1838 b''
1 1 Test basic extension support
2 2 $ cat > unflush.py <<EOF
3 3 > import sys
4 4 > from mercurial import pycompat
5 5 > if pycompat.ispy3:
6 6 > # no changes required
7 7 > sys.exit(0)
8 8 > with open(sys.argv[1], 'rb') as f:
9 9 > data = f.read()
10 10 > with open(sys.argv[1], 'wb') as f:
11 11 > f.write(data.replace(b', flush=True', b''))
12 12 > EOF
13 13
14 14 $ cat > foobar.py <<EOF
15 15 > import os
16 16 > from mercurial import commands, registrar
17 17 > cmdtable = {}
18 18 > command = registrar.command(cmdtable)
19 19 > configtable = {}
20 20 > configitem = registrar.configitem(configtable)
21 21 > configitem(b'tests', b'foo', default=b"Foo")
22 22 > def uisetup(ui):
23 23 > ui.debug(b"uisetup called [debug]\\n")
24 24 > ui.write(b"uisetup called\\n")
25 25 > ui.status(b"uisetup called [status]\\n")
26 26 > ui.flush()
27 27 > def uipopulate(ui):
28 28 > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1
29 29 > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt)
30 30 > def reposetup(ui, repo):
31 31 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
32 32 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
33 33 > ui.flush()
34 34 > @command(b'foo', [], b'hg foo')
35 35 > def foo(ui, *args, **kwargs):
36 36 > foo = ui.config(b'tests', b'foo')
37 37 > ui.write(foo)
38 38 > ui.write(b"\\n")
39 39 > @command(b'bar', [], b'hg bar', norepo=True)
40 40 > def bar(ui, *args, **kwargs):
41 41 > ui.write(b"Bar\\n")
42 42 > EOF
43 43 $ abspath=`pwd`/foobar.py
44 44
45 45 $ mkdir barfoo
46 46 $ cp foobar.py barfoo/__init__.py
47 47 $ barfoopath=`pwd`/barfoo
48 48
49 49 $ hg init a
50 50 $ cd a
51 51 $ echo foo > file
52 52 $ hg add file
53 53 $ hg commit -m 'add file'
54 54
55 55 $ echo '[extensions]' >> $HGRCPATH
56 56 $ echo "foobar = $abspath" >> $HGRCPATH
57 57 $ hg foo
58 58 uisetup called
59 59 uisetup called [status]
60 60 uipopulate called (1 times)
61 61 uipopulate called (1 times)
62 62 uipopulate called (1 times)
63 63 reposetup called for a
64 64 ui == repo.ui
65 65 uipopulate called (1 times) (chg !)
66 66 uipopulate called (1 times) (chg !)
67 67 uipopulate called (1 times) (chg !)
68 68 uipopulate called (1 times) (chg !)
69 69 uipopulate called (1 times) (chg !)
70 70 reposetup called for a (chg !)
71 71 ui == repo.ui (chg !)
72 72 Foo
73 73 $ hg foo --quiet
74 74 uisetup called (no-chg !)
75 75 uipopulate called (1 times)
76 76 uipopulate called (1 times)
77 77 uipopulate called (1 times) (chg !)
78 78 uipopulate called (1 times) (chg !)
79 79 uipopulate called (1 times) (chg !)
80 80 reposetup called for a (chg !)
81 81 ui == repo.ui
82 82 Foo
83 83 $ hg foo --debug
84 84 uisetup called [debug] (no-chg !)
85 85 uisetup called (no-chg !)
86 86 uisetup called [status] (no-chg !)
87 87 uipopulate called (1 times)
88 88 uipopulate called (1 times)
89 89 uipopulate called (1 times) (chg !)
90 90 uipopulate called (1 times) (chg !)
91 91 uipopulate called (1 times) (chg !)
92 92 reposetup called for a (chg !)
93 93 ui == repo.ui
94 94 Foo
95 95
96 96 $ cd ..
97 97 $ hg clone a b
98 98 uisetup called (no-chg !)
99 99 uisetup called [status] (no-chg !)
100 100 uipopulate called (1 times)
101 101 uipopulate called (1 times) (chg !)
102 102 uipopulate called (1 times) (chg !)
103 103 reposetup called for a
104 104 ui == repo.ui
105 105 uipopulate called (1 times)
106 106 reposetup called for b
107 107 ui == repo.ui
108 108 updating to branch default
109 109 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 110
111 111 $ hg bar
112 112 uisetup called (no-chg !)
113 113 uisetup called [status] (no-chg !)
114 114 uipopulate called (1 times)
115 115 uipopulate called (1 times) (chg !)
116 116 Bar
117 117 $ echo 'foobar = !' >> $HGRCPATH
118 118
119 119 module/__init__.py-style
120 120
121 121 $ echo "barfoo = $barfoopath" >> $HGRCPATH
122 122 $ cd a
123 123 $ hg foo
124 124 uisetup called
125 125 uisetup called [status]
126 126 uipopulate called (1 times)
127 127 uipopulate called (1 times)
128 128 uipopulate called (1 times)
129 129 reposetup called for a
130 130 ui == repo.ui
131 131 uipopulate called (1 times) (chg !)
132 132 uipopulate called (1 times) (chg !)
133 133 uipopulate called (1 times) (chg !)
134 134 uipopulate called (1 times) (chg !)
135 135 uipopulate called (1 times) (chg !)
136 136 reposetup called for a (chg !)
137 137 ui == repo.ui (chg !)
138 138 Foo
139 139 $ echo 'barfoo = !' >> $HGRCPATH
140 140
141 141 Check that extensions are loaded in phases:
142 142
143 143 $ cat > foo.py <<EOF
144 144 > from __future__ import print_function
145 145 > import os
146 146 > name = os.path.basename(__file__).rsplit('.', 1)[0]
147 147 > print("1) %s imported" % name, flush=True)
148 148 > def uisetup(ui):
149 149 > print("2) %s uisetup" % name, flush=True)
150 150 > def extsetup():
151 151 > print("3) %s extsetup" % name, flush=True)
152 152 > def uipopulate(ui):
153 153 > print("4) %s uipopulate" % name, flush=True)
154 154 > def reposetup(ui, repo):
155 155 > print("5) %s reposetup" % name, flush=True)
156 156 >
157 157 > bytesname = name.encode('utf-8')
158 158 > # custom predicate to check registration of functions at loading
159 159 > from mercurial import (
160 160 > registrar,
161 161 > smartset,
162 162 > )
163 163 > revsetpredicate = registrar.revsetpredicate()
164 164 > @revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb
165 165 > def custompredicate(repo, subset, x):
166 166 > return smartset.baseset([r for r in subset if r in {0}])
167 167 > EOF
168 168 $ "$PYTHON" $TESTTMP/unflush.py foo.py
169 169
170 170 $ cp foo.py bar.py
171 171 $ echo 'foo = foo.py' >> $HGRCPATH
172 172 $ echo 'bar = bar.py' >> $HGRCPATH
173 173
174 174 Check normal command's load order of extensions and registration of functions
175 175
176 176 $ hg log -r "foo() and bar()" -q
177 177 1) foo imported
178 178 1) bar imported
179 179 2) foo uisetup
180 180 2) bar uisetup
181 181 3) foo extsetup
182 182 3) bar extsetup
183 183 4) foo uipopulate
184 184 4) bar uipopulate
185 185 4) foo uipopulate
186 186 4) bar uipopulate
187 187 4) foo uipopulate
188 188 4) bar uipopulate
189 189 5) foo reposetup
190 190 5) bar reposetup
191 191 0:c24b9ac61126
192 192
193 193 Check hgweb's load order of extensions and registration of functions
194 194
195 195 $ cat > hgweb.cgi <<EOF
196 196 > #!$PYTHON
197 197 > from mercurial import demandimport; demandimport.enable()
198 198 > from mercurial.hgweb import hgweb
199 199 > from mercurial.hgweb import wsgicgi
200 200 > application = hgweb(b'.', b'test repo')
201 201 > wsgicgi.launch(application)
202 202 > EOF
203 203 $ . "$TESTDIR/cgienv"
204 204
205 205 $ PATH_INFO='/' SCRIPT_NAME='' "$PYTHON" hgweb.cgi \
206 206 > | grep '^[0-9]) ' # ignores HTML output
207 207 1) foo imported
208 208 1) bar imported
209 209 2) foo uisetup
210 210 2) bar uisetup
211 211 3) foo extsetup
212 212 3) bar extsetup
213 213 4) foo uipopulate
214 214 4) bar uipopulate
215 215 4) foo uipopulate
216 216 4) bar uipopulate
217 217 5) foo reposetup
218 218 5) bar reposetup
219 219
220 220 (check that revset predicate foo() and bar() are available)
221 221
222 222 #if msys
223 223 $ PATH_INFO='//shortlog'
224 224 #else
225 225 $ PATH_INFO='/shortlog'
226 226 #endif
227 227 $ export PATH_INFO
228 228 $ SCRIPT_NAME='' QUERY_STRING='rev=foo() and bar()' "$PYTHON" hgweb.cgi \
229 229 > | grep '<a href="/rev/[0-9a-z]*">'
230 230 <a href="/rev/c24b9ac61126">add file</a>
231 231
232 232 $ echo 'foo = !' >> $HGRCPATH
233 233 $ echo 'bar = !' >> $HGRCPATH
234 234
235 235 Check "from __future__ import absolute_import" support for external libraries
236 236
237 237 (import-checker.py reports issues for some of heredoc python code
238 238 fragments below, because import-checker.py does not know test specific
239 239 package hierarchy. NO_CHECK_* should be used as a limit mark of
240 240 heredoc, in order to make import-checker.py ignore them. For
241 241 simplicity, all python code fragments below are generated with such
242 242 limit mark, regardless of importing module or not.)
243 243
244 244 #if windows
245 245 $ PATHSEP=";"
246 246 #else
247 247 $ PATHSEP=":"
248 248 #endif
249 249 $ export PATHSEP
250 250
251 251 $ mkdir $TESTTMP/libroot
252 252 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
253 253 $ mkdir $TESTTMP/libroot/mod
254 254 $ touch $TESTTMP/libroot/mod/__init__.py
255 255 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
256 256
257 257 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF
258 258 > from __future__ import absolute_import, print_function
259 259 > import ambig # should load "libroot/ambig.py"
260 260 > s = ambig.s
261 261 > NO_CHECK_EOF
262 262 $ cat > loadabs.py <<NO_CHECK_EOF
263 263 > import mod.ambigabs as ambigabs
264 264 > def extsetup():
265 265 > print('ambigabs.s=%s' % ambigabs.s, flush=True)
266 266 > NO_CHECK_EOF
267 267 $ "$PYTHON" $TESTTMP/unflush.py loadabs.py
268 268 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
269 269 ambigabs.s=libroot/ambig.py
270 270 $TESTTMP/a
271 271
272 272 #if no-py3
273 273 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF
274 274 > from __future__ import print_function
275 275 > import ambig # should load "libroot/mod/ambig.py"
276 276 > s = ambig.s
277 277 > NO_CHECK_EOF
278 278 $ cat > loadrel.py <<NO_CHECK_EOF
279 279 > import mod.ambigrel as ambigrel
280 280 > def extsetup():
281 281 > print('ambigrel.s=%s' % ambigrel.s, flush=True)
282 282 > NO_CHECK_EOF
283 283 $ "$PYTHON" $TESTTMP/unflush.py loadrel.py
284 284 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
285 285 ambigrel.s=libroot/mod/ambig.py
286 286 $TESTTMP/a
287 287 #endif
288 288
289 289 Check absolute/relative import of extension specific modules
290 290
291 291 $ mkdir $TESTTMP/extroot
292 292 $ cat > $TESTTMP/extroot/bar.py <<NO_CHECK_EOF
293 293 > s = b'this is extroot.bar'
294 294 > NO_CHECK_EOF
295 295 $ mkdir $TESTTMP/extroot/sub1
296 296 $ cat > $TESTTMP/extroot/sub1/__init__.py <<NO_CHECK_EOF
297 297 > s = b'this is extroot.sub1.__init__'
298 298 > NO_CHECK_EOF
299 299 $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF
300 300 > s = b'this is extroot.sub1.baz'
301 301 > NO_CHECK_EOF
302 302 $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF
303 303 > from __future__ import absolute_import
304 304 > s = b'this is extroot.__init__'
305 305 > from . import foo
306 306 > def extsetup(ui):
307 307 > ui.write(b'(extroot) ', foo.func(), b'\n')
308 308 > ui.flush()
309 309 > NO_CHECK_EOF
310 310
311 311 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
312 312 > # test absolute import
313 313 > buf = []
314 314 > def func():
315 315 > # "not locals" case
316 316 > import extroot.bar
317 317 > buf.append(b'import extroot.bar in func(): %s' % extroot.bar.s)
318 318 > return b'\n(extroot) '.join(buf)
319 319 > # b"fromlist == ('*',)" case
320 320 > from extroot.bar import *
321 321 > buf.append(b'from extroot.bar import *: %s' % s)
322 322 > # "not fromlist" and "if '.' in name" case
323 323 > import extroot.sub1.baz
324 324 > buf.append(b'import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
325 325 > # "not fromlist" and NOT "if '.' in name" case
326 326 > import extroot
327 327 > buf.append(b'import extroot: %s' % extroot.s)
328 328 > # NOT "not fromlist" and NOT "level != -1" case
329 329 > from extroot.bar import s
330 330 > buf.append(b'from extroot.bar import s: %s' % s)
331 331 > NO_CHECK_EOF
332 332 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
333 333 (extroot) from extroot.bar import *: this is extroot.bar
334 334 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
335 335 (extroot) import extroot: this is extroot.__init__
336 336 (extroot) from extroot.bar import s: this is extroot.bar
337 337 (extroot) import extroot.bar in func(): this is extroot.bar
338 338 $TESTTMP/a
339 339
340 340 #if no-py3
341 341 $ rm "$TESTTMP"/extroot/foo.*
342 342 $ rm -Rf "$TESTTMP/extroot/__pycache__"
343 343 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
344 344 > # test relative import
345 345 > buf = []
346 346 > def func():
347 347 > # "not locals" case
348 348 > import bar
349 349 > buf.append('import bar in func(): %s' % bar.s)
350 350 > return '\n(extroot) '.join(buf)
351 351 > # "fromlist == ('*',)" case
352 352 > from bar import *
353 353 > buf.append('from bar import *: %s' % s)
354 354 > # "not fromlist" and "if '.' in name" case
355 355 > import sub1.baz
356 356 > buf.append('import sub1.baz: %s' % sub1.baz.s)
357 357 > # "not fromlist" and NOT "if '.' in name" case
358 358 > import sub1
359 359 > buf.append('import sub1: %s' % sub1.s)
360 360 > # NOT "not fromlist" and NOT "level != -1" case
361 361 > from bar import s
362 362 > buf.append('from bar import s: %s' % s)
363 363 > NO_CHECK_EOF
364 364 $ hg --config extensions.extroot=$TESTTMP/extroot root
365 365 (extroot) from bar import *: this is extroot.bar
366 366 (extroot) import sub1.baz: this is extroot.sub1.baz
367 367 (extroot) import sub1: this is extroot.sub1.__init__
368 368 (extroot) from bar import s: this is extroot.bar
369 369 (extroot) import bar in func(): this is extroot.bar
370 370 $TESTTMP/a
371 371 #endif
372 372
373 373 #if demandimport
374 374
375 375 Examine whether module loading is delayed until actual referring, even
376 376 though module is imported with "absolute_import" feature.
377 377
378 378 Files below in each packages are used for described purpose:
379 379
380 380 - "called": examine whether "from MODULE import ATTR" works correctly
381 381 - "unused": examine whether loading is delayed correctly
382 382 - "used": examine whether "from PACKAGE import MODULE" works correctly
383 383
384 384 Package hierarchy is needed to examine whether demand importing works
385 385 as expected for "from SUB.PACK.AGE import MODULE".
386 386
387 387 Setup "external library" to be imported with "absolute_import"
388 388 feature.
389 389
390 390 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
391 391 $ touch $TESTTMP/extlibroot/__init__.py
392 392 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
393 393 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
394 394
395 395 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<NO_CHECK_EOF
396 396 > def func():
397 397 > return b"this is extlibroot.lsub1.lsub2.called.func()"
398 398 > NO_CHECK_EOF
399 399 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<NO_CHECK_EOF
400 400 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
401 401 > NO_CHECK_EOF
402 402 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<NO_CHECK_EOF
403 403 > detail = b"this is extlibroot.lsub1.lsub2.used"
404 404 > NO_CHECK_EOF
405 405
406 406 Setup sub-package of "external library", which causes instantiation of
407 407 demandmod in "recurse down the module chain" code path. Relative
408 408 importing with "absolute_import" feature isn't tested, because "level
409 409 >=1 " doesn't cause instantiation of demandmod.
410 410
411 411 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
412 412 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF
413 413 > detail = b"this is extlibroot.recursedown.abs.used"
414 414 > NO_CHECK_EOF
415 415 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF
416 416 > from __future__ import absolute_import
417 417 > from extlibroot.recursedown.abs.used import detail
418 418 > NO_CHECK_EOF
419 419
420 420 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
421 421 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF
422 422 > detail = b"this is extlibroot.recursedown.legacy.used"
423 423 > NO_CHECK_EOF
424 424 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<NO_CHECK_EOF
425 425 > # legacy style (level == -1) import
426 426 > from extlibroot.recursedown.legacy.used import detail
427 427 > NO_CHECK_EOF
428 428
429 429 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF
430 430 > from __future__ import absolute_import
431 431 > from extlibroot.recursedown.abs import detail as absdetail
432 432 > from .legacy import detail as legacydetail
433 433 > NO_CHECK_EOF
434 434
435 435 Setup package that re-exports an attribute of its submodule as the same
436 436 name. This leaves 'shadowing.used' pointing to 'used.detail', but still
437 437 the submodule 'used' should be somehow accessible. (issue5617)
438 438
439 439 $ mkdir -p $TESTTMP/extlibroot/shadowing
440 440 $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF
441 441 > detail = b"this is extlibroot.shadowing.used"
442 442 > NO_CHECK_EOF
443 443 $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF
444 444 > from __future__ import absolute_import
445 445 > from extlibroot.shadowing.used import detail
446 446 > NO_CHECK_EOF
447 447 $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF
448 448 > from __future__ import absolute_import
449 449 > from .used import detail as used
450 450 > NO_CHECK_EOF
451 451
452 452 Setup extension local modules to be imported with "absolute_import"
453 453 feature.
454 454
455 455 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
456 456 $ touch $TESTTMP/absextroot/xsub1/__init__.py
457 457 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
458 458
459 459 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<NO_CHECK_EOF
460 460 > def func():
461 461 > return b"this is absextroot.xsub1.xsub2.called.func()"
462 462 > NO_CHECK_EOF
463 463 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<NO_CHECK_EOF
464 464 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
465 465 > NO_CHECK_EOF
466 466 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<NO_CHECK_EOF
467 467 > detail = b"this is absextroot.xsub1.xsub2.used"
468 468 > NO_CHECK_EOF
469 469
470 470 Setup extension local modules to examine whether demand importing
471 471 works as expected in "level > 1" case.
472 472
473 473 $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF
474 474 > detail = b"this is absextroot.relimportee"
475 475 > NO_CHECK_EOF
476 476 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF
477 477 > from __future__ import absolute_import
478 478 > from mercurial import pycompat
479 479 > from ... import relimportee
480 480 > detail = b"this relimporter imports %r" % (
481 481 > pycompat.bytestr(relimportee.detail))
482 482 > NO_CHECK_EOF
483 483
484 484 Setup modules, which actually import extension local modules at
485 485 runtime.
486 486
487 487 $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF
488 488 > from __future__ import absolute_import
489 489 >
490 490 > # import extension local modules absolutely (level = 0)
491 491 > from absextroot.xsub1.xsub2 import used, unused
492 492 > from absextroot.xsub1.xsub2.called import func
493 493 >
494 494 > def getresult():
495 495 > result = []
496 496 > result.append(used.detail)
497 497 > result.append(func())
498 498 > return result
499 499 > NO_CHECK_EOF
500 500
501 501 $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF
502 502 > from __future__ import absolute_import
503 503 >
504 504 > # import extension local modules relatively (level == 1)
505 505 > from .xsub1.xsub2 import used, unused
506 506 > from .xsub1.xsub2.called import func
507 507 >
508 508 > # import a module, which implies "importing with level > 1"
509 509 > from .xsub1.xsub2 import relimporter
510 510 >
511 511 > def getresult():
512 512 > result = []
513 513 > result.append(used.detail)
514 514 > result.append(func())
515 515 > result.append(relimporter.detail)
516 516 > return result
517 517 > NO_CHECK_EOF
518 518
519 519 Setup main procedure of extension.
520 520
521 521 $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF
522 522 > from __future__ import absolute_import
523 523 > from mercurial import registrar
524 524 > cmdtable = {}
525 525 > command = registrar.command(cmdtable)
526 526 >
527 527 > # "absolute" and "relative" shouldn't be imported before actual
528 528 > # command execution, because (1) they import same modules, and (2)
529 529 > # preceding import (= instantiate "demandmod" object instead of
530 530 > # real "module" object) might hide problem of succeeding import.
531 531 >
532 532 > @command(b'showabsolute', [], norepo=True)
533 533 > def showabsolute(ui, *args, **opts):
534 534 > from absextroot import absolute
535 535 > ui.write(b'ABS: %s\n' % b'\nABS: '.join(absolute.getresult()))
536 536 >
537 537 > @command(b'showrelative', [], norepo=True)
538 538 > def showrelative(ui, *args, **opts):
539 539 > from . import relative
540 540 > ui.write(b'REL: %s\n' % b'\nREL: '.join(relative.getresult()))
541 541 >
542 542 > # import modules from external library
543 543 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
544 544 > from extlibroot.lsub1.lsub2.called import func as lfunc
545 545 > from extlibroot.recursedown import absdetail, legacydetail
546 546 > from extlibroot.shadowing import proxied
547 547 >
548 548 > def uisetup(ui):
549 549 > result = []
550 550 > result.append(lused.detail)
551 551 > result.append(lfunc())
552 552 > result.append(absdetail)
553 553 > result.append(legacydetail)
554 554 > result.append(proxied.detail)
555 555 > ui.write(b'LIB: %s\n' % b'\nLIB: '.join(result))
556 556 > NO_CHECK_EOF
557 557
558 558 Examine module importing.
559 559
560 560 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
561 561 LIB: this is extlibroot.lsub1.lsub2.used
562 562 LIB: this is extlibroot.lsub1.lsub2.called.func()
563 563 LIB: this is extlibroot.recursedown.abs.used
564 564 LIB: this is extlibroot.recursedown.legacy.used
565 565 LIB: this is extlibroot.shadowing.used
566 566 ABS: this is absextroot.xsub1.xsub2.used
567 567 ABS: this is absextroot.xsub1.xsub2.called.func()
568 568
569 569 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
570 570 LIB: this is extlibroot.lsub1.lsub2.used
571 571 LIB: this is extlibroot.lsub1.lsub2.called.func()
572 572 LIB: this is extlibroot.recursedown.abs.used
573 573 LIB: this is extlibroot.recursedown.legacy.used
574 574 LIB: this is extlibroot.shadowing.used
575 575 REL: this is absextroot.xsub1.xsub2.used
576 576 REL: this is absextroot.xsub1.xsub2.called.func()
577 577 REL: this relimporter imports 'this is absextroot.relimportee'
578 578
579 579 Examine whether sub-module is imported relatively as expected.
580 580
581 581 See also issue5208 for detail about example case on Python 3.x.
582 582
583 583 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
584 584 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
585 585
586 586 $ cat > $TESTTMP/notexist.py <<NO_CHECK_EOF
587 587 > text = 'notexist.py at root is loaded unintentionally\n'
588 588 > NO_CHECK_EOF
589 589
590 590 $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF
591 591 > from mercurial import registrar
592 592 > cmdtable = {}
593 593 > command = registrar.command(cmdtable)
594 594 >
595 595 > # demand import avoids failure of importing notexist here
596 596 > import extlibroot.lsub1.lsub2.notexist
597 597 >
598 598 > @command(b'checkrelativity', [], norepo=True)
599 599 > def checkrelativity(ui, *args, **opts):
600 600 > try:
601 601 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
602 602 > return 1 # unintentional success
603 603 > except ImportError:
604 604 > pass # intentional failure
605 605 > NO_CHECK_EOF
606 606
607 607 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
608 608
609 609 #endif
610 610
611 611 (Here, module importing tests are finished. Therefore, use other than
612 612 NO_CHECK_* limit mark for heredoc python files, in order to apply
613 613 import-checker.py or so on their contents)
614 614
615 615 Make sure a broken uisetup doesn't globally break hg:
616 616 $ cat > $TESTTMP/baduisetup.py <<EOF
617 617 > def uisetup(ui):
618 618 > 1/0
619 619 > EOF
620 620
621 621 Even though the extension fails during uisetup, hg is still basically usable:
622 622 $ hg --config extensions.baduisetup=$TESTTMP/baduisetup.py version
623 623 Traceback (most recent call last):
624 624 File "*/mercurial/extensions.py", line *, in _runuisetup (glob)
625 625 uisetup(ui)
626 626 File "$TESTTMP/baduisetup.py", line 2, in uisetup
627 627 1/0
628 628 ZeroDivisionError: * by zero (glob)
629 629 *** failed to set up extension baduisetup: * by zero (glob)
630 630 Mercurial Distributed SCM (version *) (glob)
631 631 (see https://mercurial-scm.org for more information)
632 632
633 633 Copyright (C) 2005-* Matt Mackall and others (glob)
634 634 This is free software; see the source for copying conditions. There is NO
635 635 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
636 636
637 637 $ cd ..
638 638
639 639 hide outer repo
640 640 $ hg init
641 641
642 642 $ cat > empty.py <<EOF
643 643 > '''empty cmdtable
644 644 > '''
645 645 > cmdtable = {}
646 646 > EOF
647 647 $ emptypath=`pwd`/empty.py
648 648 $ echo "empty = $emptypath" >> $HGRCPATH
649 649 $ hg help empty
650 650 empty extension - empty cmdtable
651 651
652 652 no commands defined
653 653
654 654
655 655 $ echo 'empty = !' >> $HGRCPATH
656 656
657 657 $ cat > debugextension.py <<EOF
658 658 > '''only debugcommands
659 659 > '''
660 660 > from mercurial import registrar
661 661 > cmdtable = {}
662 662 > command = registrar.command(cmdtable)
663 663 > @command(b'debugfoobar', [], b'hg debugfoobar')
664 664 > def debugfoobar(ui, repo, *args, **opts):
665 665 > "yet another debug command"
666 666 > pass
667 667 > @command(b'foo', [], b'hg foo')
668 668 > def foo(ui, repo, *args, **opts):
669 669 > """yet another foo command
670 670 > This command has been DEPRECATED since forever.
671 671 > """
672 672 > pass
673 673 > EOF
674 674 $ debugpath=`pwd`/debugextension.py
675 675 $ echo "debugextension = $debugpath" >> $HGRCPATH
676 676
677 677 $ hg help debugextension
678 678 hg debugextensions
679 679
680 680 show information about active extensions
681 681
682 682 options:
683 683
684 684 -T --template TEMPLATE display with template
685 685
686 686 (some details hidden, use --verbose to show complete help)
687 687
688 688
689 689 $ hg --verbose help debugextension
690 690 hg debugextensions
691 691
692 692 show information about active extensions
693 693
694 694 options:
695 695
696 696 -T --template TEMPLATE display with template
697 697
698 698 global options ([+] can be repeated):
699 699
700 700 -R --repository REPO repository root directory or name of overlay bundle
701 701 file
702 702 --cwd DIR change working directory
703 703 -y --noninteractive do not prompt, automatically pick the first choice for
704 704 all prompts
705 705 -q --quiet suppress output
706 706 -v --verbose enable additional output
707 707 --color TYPE when to colorize (boolean, always, auto, never, or
708 708 debug)
709 709 --config CONFIG [+] set/override config option (use 'section.name=value')
710 710 --debug enable debugging output
711 711 --debugger start debugger
712 712 --encoding ENCODE set the charset encoding (default: ascii)
713 713 --encodingmode MODE set the charset encoding mode (default: strict)
714 714 --traceback always print a traceback on exception
715 715 --time time how long the command takes
716 716 --profile print command execution profile
717 717 --version output version information and exit
718 718 -h --help display help and exit
719 --hidden consider hidden changesets
719 --hidden consider hidden changesets (default: off)
720 720 --pager TYPE when to paginate (boolean, always, auto, or never)
721 721 (default: auto)
722 722
723 723
724 724
725 725
726 726
727 727
728 728 $ hg --debug help debugextension
729 729 hg debugextensions
730 730
731 731 show information about active extensions
732 732
733 733 options:
734 734
735 735 -T --template TEMPLATE display with template
736 736
737 737 global options ([+] can be repeated):
738 738
739 739 -R --repository REPO repository root directory or name of overlay bundle
740 740 file
741 741 --cwd DIR change working directory
742 742 -y --noninteractive do not prompt, automatically pick the first choice for
743 743 all prompts
744 744 -q --quiet suppress output
745 745 -v --verbose enable additional output
746 746 --color TYPE when to colorize (boolean, always, auto, never, or
747 747 debug)
748 748 --config CONFIG [+] set/override config option (use 'section.name=value')
749 749 --debug enable debugging output
750 750 --debugger start debugger
751 751 --encoding ENCODE set the charset encoding (default: ascii)
752 752 --encodingmode MODE set the charset encoding mode (default: strict)
753 753 --traceback always print a traceback on exception
754 754 --time time how long the command takes
755 755 --profile print command execution profile
756 756 --version output version information and exit
757 757 -h --help display help and exit
758 --hidden consider hidden changesets
758 --hidden consider hidden changesets (default: off)
759 759 --pager TYPE when to paginate (boolean, always, auto, or never)
760 760 (default: auto)
761 761
762 762
763 763
764 764
765 765
766 766 $ echo 'debugextension = !' >> $HGRCPATH
767 767
768 768 Asking for help about a deprecated extension should do something useful:
769 769
770 770 $ hg help glog
771 771 'glog' is provided by the following extension:
772 772
773 773 graphlog command to view revision graphs from a shell (DEPRECATED)
774 774
775 775 (use 'hg help extensions' for information on enabling extensions)
776 776
777 777 Extension module help vs command help:
778 778
779 779 $ echo 'extdiff =' >> $HGRCPATH
780 780 $ hg help extdiff
781 781 hg extdiff [OPT]... [FILE]...
782 782
783 783 use external program to diff repository (or selected files)
784 784
785 785 Show differences between revisions for the specified files, using an
786 786 external program. The default program used is diff, with default options
787 787 "-Npru".
788 788
789 789 To select a different program, use the -p/--program option. The program
790 790 will be passed the names of two directories to compare. To pass additional
791 791 options to the program, use -o/--option. These will be passed before the
792 792 names of the directories to compare.
793 793
794 794 When two revision arguments are given, then changes are shown between
795 795 those revisions. If only one revision is specified then that revision is
796 796 compared to the working directory, and, when no revisions are specified,
797 797 the working directory files are compared to its parent.
798 798
799 799 (use 'hg help -e extdiff' to show help for the extdiff extension)
800 800
801 801 options ([+] can be repeated):
802 802
803 803 -p --program CMD comparison program to run
804 804 -o --option OPT [+] pass option to comparison program
805 805 -r --rev REV [+] revision
806 806 -c --change REV change made by revision
807 807 --patch compare patches for two revisions
808 808 -I --include PATTERN [+] include names matching the given patterns
809 809 -X --exclude PATTERN [+] exclude names matching the given patterns
810 810 -S --subrepos recurse into subrepositories
811 811
812 812 (some details hidden, use --verbose to show complete help)
813 813
814 814
815 815
816 816
817 817
818 818
819 819
820 820
821 821
822 822
823 823 $ hg help --extension extdiff
824 824 extdiff extension - command to allow external programs to compare revisions
825 825
826 826 The extdiff Mercurial extension allows you to use external programs to compare
827 827 revisions, or revision with working directory. The external diff programs are
828 828 called with a configurable set of options and two non-option arguments: paths
829 829 to directories containing snapshots of files to compare.
830 830
831 831 If there is more than one file being compared and the "child" revision is the
832 832 working directory, any modifications made in the external diff program will be
833 833 copied back to the working directory from the temporary directory.
834 834
835 835 The extdiff extension also allows you to configure new diff commands, so you
836 836 do not need to type 'hg extdiff -p kdiff3' always.
837 837
838 838 [extdiff]
839 839 # add new command that runs GNU diff(1) in 'context diff' mode
840 840 cdiff = gdiff -Nprc5
841 841 ## or the old way:
842 842 #cmd.cdiff = gdiff
843 843 #opts.cdiff = -Nprc5
844 844
845 845 # add new command called meld, runs meld (no need to name twice). If
846 846 # the meld executable is not available, the meld tool in [merge-tools]
847 847 # will be used, if available
848 848 meld =
849 849
850 850 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
851 851 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
852 852 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
853 853 # your .vimrc
854 854 vimdiff = gvim -f "+next" \
855 855 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
856 856
857 857 Tool arguments can include variables that are expanded at runtime:
858 858
859 859 $parent1, $plabel1 - filename, descriptive label of first parent
860 860 $child, $clabel - filename, descriptive label of child revision
861 861 $parent2, $plabel2 - filename, descriptive label of second parent
862 862 $root - repository root
863 863 $parent is an alias for $parent1.
864 864
865 865 The extdiff extension will look in your [diff-tools] and [merge-tools]
866 866 sections for diff tool arguments, when none are specified in [extdiff].
867 867
868 868 [extdiff]
869 869 kdiff3 =
870 870
871 871 [diff-tools]
872 872 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
873 873
874 874 You can use -I/-X and list of file or directory names like normal 'hg diff'
875 875 command. The extdiff extension makes snapshots of only needed files, so
876 876 running the external diff program will actually be pretty fast (at least
877 877 faster than having to compare the entire tree).
878 878
879 879 list of commands:
880 880
881 881 extdiff use external program to diff repository (or selected files)
882 882
883 883 (use 'hg help -v -e extdiff' to show built-in aliases and global options)
884 884
885 885
886 886
887 887
888 888
889 889
890 890
891 891
892 892
893 893
894 894
895 895
896 896
897 897
898 898
899 899
900 900 $ echo 'extdiff = !' >> $HGRCPATH
901 901
902 902 Test help topic with same name as extension
903 903
904 904 $ cat > multirevs.py <<EOF
905 905 > from mercurial import commands, registrar
906 906 > cmdtable = {}
907 907 > command = registrar.command(cmdtable)
908 908 > """multirevs extension
909 909 > Big multi-line module docstring."""
910 910 > @command(b'multirevs', [], b'ARG', norepo=True)
911 911 > def multirevs(ui, repo, arg, *args, **opts):
912 912 > """multirevs command"""
913 913 > pass
914 914 > EOF
915 915 $ echo "multirevs = multirevs.py" >> $HGRCPATH
916 916
917 917 $ hg help multirevs | tail
918 918 used):
919 919
920 920 hg update :@
921 921
922 922 - Show diff between tags 1.3 and 1.5 (this works because the first and the
923 923 last revisions of the revset are used):
924 924
925 925 hg diff -r 1.3::1.5
926 926
927 927 use 'hg help -c multirevs' to see help for the multirevs command
928 928
929 929
930 930
931 931
932 932
933 933
934 934 $ hg help -c multirevs
935 935 hg multirevs ARG
936 936
937 937 multirevs command
938 938
939 939 (some details hidden, use --verbose to show complete help)
940 940
941 941
942 942
943 943 $ hg multirevs
944 944 hg multirevs: invalid arguments
945 945 hg multirevs ARG
946 946
947 947 multirevs command
948 948
949 949 (use 'hg multirevs -h' to show more help)
950 950 [255]
951 951
952 952
953 953
954 954 $ echo "multirevs = !" >> $HGRCPATH
955 955
956 956 Issue811: Problem loading extensions twice (by site and by user)
957 957
958 958 $ cat <<EOF >> $HGRCPATH
959 959 > mq =
960 960 > strip =
961 961 > hgext.mq =
962 962 > hgext/mq =
963 963 > EOF
964 964
965 965 Show extensions:
966 966 (note that mq force load strip, also checking it's not loaded twice)
967 967
968 968 #if no-extraextensions
969 969 $ hg debugextensions
970 970 mq
971 971 strip
972 972 #endif
973 973
974 974 For extensions, which name matches one of its commands, help
975 975 message should ask '-v -e' to get list of built-in aliases
976 976 along with extension help itself
977 977
978 978 $ mkdir $TESTTMP/d
979 979 $ cat > $TESTTMP/d/dodo.py <<EOF
980 980 > """
981 981 > This is an awesome 'dodo' extension. It does nothing and
982 982 > writes 'Foo foo'
983 983 > """
984 984 > from mercurial import commands, registrar
985 985 > cmdtable = {}
986 986 > command = registrar.command(cmdtable)
987 987 > @command(b'dodo', [], b'hg dodo')
988 988 > def dodo(ui, *args, **kwargs):
989 989 > """Does nothing"""
990 990 > ui.write(b"I do nothing. Yay\\n")
991 991 > @command(b'foofoo', [], b'hg foofoo')
992 992 > def foofoo(ui, *args, **kwargs):
993 993 > """Writes 'Foo foo'"""
994 994 > ui.write(b"Foo foo\\n")
995 995 > EOF
996 996 $ dodopath=$TESTTMP/d/dodo.py
997 997
998 998 $ echo "dodo = $dodopath" >> $HGRCPATH
999 999
1000 1000 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
1001 1001 $ hg help -e dodo
1002 1002 dodo extension -
1003 1003
1004 1004 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1005 1005
1006 1006 list of commands:
1007 1007
1008 1008 dodo Does nothing
1009 1009 foofoo Writes 'Foo foo'
1010 1010
1011 1011 (use 'hg help -v -e dodo' to show built-in aliases and global options)
1012 1012
1013 1013 Make sure that '-v -e' prints list of built-in aliases along with
1014 1014 extension help itself
1015 1015 $ hg help -v -e dodo
1016 1016 dodo extension -
1017 1017
1018 1018 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1019 1019
1020 1020 list of commands:
1021 1021
1022 1022 dodo Does nothing
1023 1023 foofoo Writes 'Foo foo'
1024 1024
1025 1025 global options ([+] can be repeated):
1026 1026
1027 1027 -R --repository REPO repository root directory or name of overlay bundle
1028 1028 file
1029 1029 --cwd DIR change working directory
1030 1030 -y --noninteractive do not prompt, automatically pick the first choice for
1031 1031 all prompts
1032 1032 -q --quiet suppress output
1033 1033 -v --verbose enable additional output
1034 1034 --color TYPE when to colorize (boolean, always, auto, never, or
1035 1035 debug)
1036 1036 --config CONFIG [+] set/override config option (use 'section.name=value')
1037 1037 --debug enable debugging output
1038 1038 --debugger start debugger
1039 1039 --encoding ENCODE set the charset encoding (default: ascii)
1040 1040 --encodingmode MODE set the charset encoding mode (default: strict)
1041 1041 --traceback always print a traceback on exception
1042 1042 --time time how long the command takes
1043 1043 --profile print command execution profile
1044 1044 --version output version information and exit
1045 1045 -h --help display help and exit
1046 --hidden consider hidden changesets
1046 --hidden consider hidden changesets (default: off)
1047 1047 --pager TYPE when to paginate (boolean, always, auto, or never)
1048 1048 (default: auto)
1049 1049
1050 1050 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
1051 1051 $ hg help -v dodo
1052 1052 hg dodo
1053 1053
1054 1054 Does nothing
1055 1055
1056 1056 (use 'hg help -e dodo' to show help for the dodo extension)
1057 1057
1058 1058 options:
1059 1059
1060 1060 --mq operate on patch repository
1061 1061
1062 1062 global options ([+] can be repeated):
1063 1063
1064 1064 -R --repository REPO repository root directory or name of overlay bundle
1065 1065 file
1066 1066 --cwd DIR change working directory
1067 1067 -y --noninteractive do not prompt, automatically pick the first choice for
1068 1068 all prompts
1069 1069 -q --quiet suppress output
1070 1070 -v --verbose enable additional output
1071 1071 --color TYPE when to colorize (boolean, always, auto, never, or
1072 1072 debug)
1073 1073 --config CONFIG [+] set/override config option (use 'section.name=value')
1074 1074 --debug enable debugging output
1075 1075 --debugger start debugger
1076 1076 --encoding ENCODE set the charset encoding (default: ascii)
1077 1077 --encodingmode MODE set the charset encoding mode (default: strict)
1078 1078 --traceback always print a traceback on exception
1079 1079 --time time how long the command takes
1080 1080 --profile print command execution profile
1081 1081 --version output version information and exit
1082 1082 -h --help display help and exit
1083 --hidden consider hidden changesets
1083 --hidden consider hidden changesets (default: off)
1084 1084 --pager TYPE when to paginate (boolean, always, auto, or never)
1085 1085 (default: auto)
1086 1086
1087 1087 In case when extension name doesn't match any of its commands,
1088 1088 help message should ask for '-v' to get list of built-in aliases
1089 1089 along with extension help
1090 1090 $ cat > $TESTTMP/d/dudu.py <<EOF
1091 1091 > """
1092 1092 > This is an awesome 'dudu' extension. It does something and
1093 1093 > also writes 'Beep beep'
1094 1094 > """
1095 1095 > from mercurial import commands, registrar
1096 1096 > cmdtable = {}
1097 1097 > command = registrar.command(cmdtable)
1098 1098 > @command(b'something', [], b'hg something')
1099 1099 > def something(ui, *args, **kwargs):
1100 1100 > """Does something"""
1101 1101 > ui.write(b"I do something. Yaaay\\n")
1102 1102 > @command(b'beep', [], b'hg beep')
1103 1103 > def beep(ui, *args, **kwargs):
1104 1104 > """Writes 'Beep beep'"""
1105 1105 > ui.write(b"Beep beep\\n")
1106 1106 > EOF
1107 1107 $ dudupath=$TESTTMP/d/dudu.py
1108 1108
1109 1109 $ echo "dudu = $dudupath" >> $HGRCPATH
1110 1110
1111 1111 $ hg help -e dudu
1112 1112 dudu extension -
1113 1113
1114 1114 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1115 1115 beep'
1116 1116
1117 1117 list of commands:
1118 1118
1119 1119 beep Writes 'Beep beep'
1120 1120 something Does something
1121 1121
1122 1122 (use 'hg help -v dudu' to show built-in aliases and global options)
1123 1123
1124 1124 In case when extension name doesn't match any of its commands,
1125 1125 help options '-v' and '-v -e' should be equivalent
1126 1126 $ hg help -v dudu
1127 1127 dudu extension -
1128 1128
1129 1129 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1130 1130 beep'
1131 1131
1132 1132 list of commands:
1133 1133
1134 1134 beep Writes 'Beep beep'
1135 1135 something Does something
1136 1136
1137 1137 global options ([+] can be repeated):
1138 1138
1139 1139 -R --repository REPO repository root directory or name of overlay bundle
1140 1140 file
1141 1141 --cwd DIR change working directory
1142 1142 -y --noninteractive do not prompt, automatically pick the first choice for
1143 1143 all prompts
1144 1144 -q --quiet suppress output
1145 1145 -v --verbose enable additional output
1146 1146 --color TYPE when to colorize (boolean, always, auto, never, or
1147 1147 debug)
1148 1148 --config CONFIG [+] set/override config option (use 'section.name=value')
1149 1149 --debug enable debugging output
1150 1150 --debugger start debugger
1151 1151 --encoding ENCODE set the charset encoding (default: ascii)
1152 1152 --encodingmode MODE set the charset encoding mode (default: strict)
1153 1153 --traceback always print a traceback on exception
1154 1154 --time time how long the command takes
1155 1155 --profile print command execution profile
1156 1156 --version output version information and exit
1157 1157 -h --help display help and exit
1158 --hidden consider hidden changesets
1158 --hidden consider hidden changesets (default: off)
1159 1159 --pager TYPE when to paginate (boolean, always, auto, or never)
1160 1160 (default: auto)
1161 1161
1162 1162 $ hg help -v -e dudu
1163 1163 dudu extension -
1164 1164
1165 1165 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1166 1166 beep'
1167 1167
1168 1168 list of commands:
1169 1169
1170 1170 beep Writes 'Beep beep'
1171 1171 something Does something
1172 1172
1173 1173 global options ([+] can be repeated):
1174 1174
1175 1175 -R --repository REPO repository root directory or name of overlay bundle
1176 1176 file
1177 1177 --cwd DIR change working directory
1178 1178 -y --noninteractive do not prompt, automatically pick the first choice for
1179 1179 all prompts
1180 1180 -q --quiet suppress output
1181 1181 -v --verbose enable additional output
1182 1182 --color TYPE when to colorize (boolean, always, auto, never, or
1183 1183 debug)
1184 1184 --config CONFIG [+] set/override config option (use 'section.name=value')
1185 1185 --debug enable debugging output
1186 1186 --debugger start debugger
1187 1187 --encoding ENCODE set the charset encoding (default: ascii)
1188 1188 --encodingmode MODE set the charset encoding mode (default: strict)
1189 1189 --traceback always print a traceback on exception
1190 1190 --time time how long the command takes
1191 1191 --profile print command execution profile
1192 1192 --version output version information and exit
1193 1193 -h --help display help and exit
1194 --hidden consider hidden changesets
1194 --hidden consider hidden changesets (default: off)
1195 1195 --pager TYPE when to paginate (boolean, always, auto, or never)
1196 1196 (default: auto)
1197 1197
1198 1198 Disabled extension commands:
1199 1199
1200 1200 $ ORGHGRCPATH=$HGRCPATH
1201 1201 $ HGRCPATH=
1202 1202 $ export HGRCPATH
1203 1203 $ hg help email
1204 1204 'email' is provided by the following extension:
1205 1205
1206 1206 patchbomb command to send changesets as (a series of) patch emails
1207 1207
1208 1208 (use 'hg help extensions' for information on enabling extensions)
1209 1209
1210 1210
1211 1211 $ hg qdel
1212 1212 hg: unknown command 'qdel'
1213 1213 'qdelete' is provided by the following extension:
1214 1214
1215 1215 mq manage a stack of patches
1216 1216
1217 1217 (use 'hg help extensions' for information on enabling extensions)
1218 1218 [255]
1219 1219
1220 1220
1221 1221 $ hg churn
1222 1222 hg: unknown command 'churn'
1223 1223 'churn' is provided by the following extension:
1224 1224
1225 1225 churn command to display statistics about repository history
1226 1226
1227 1227 (use 'hg help extensions' for information on enabling extensions)
1228 1228 [255]
1229 1229
1230 1230
1231 1231
1232 1232 Disabled extensions:
1233 1233
1234 1234 $ hg help churn
1235 1235 churn extension - command to display statistics about repository history
1236 1236
1237 1237 (use 'hg help extensions' for information on enabling extensions)
1238 1238
1239 1239 $ hg help patchbomb
1240 1240 patchbomb extension - command to send changesets as (a series of) patch emails
1241 1241
1242 1242 The series is started off with a "[PATCH 0 of N]" introduction, which
1243 1243 describes the series as a whole.
1244 1244
1245 1245 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1246 1246 line of the changeset description as the subject text. The message contains
1247 1247 two or three body parts:
1248 1248
1249 1249 - The changeset description.
1250 1250 - [Optional] The result of running diffstat on the patch.
1251 1251 - The patch itself, as generated by 'hg export'.
1252 1252
1253 1253 Each message refers to the first in the series using the In-Reply-To and
1254 1254 References headers, so they will show up as a sequence in threaded mail and
1255 1255 news readers, and in mail archives.
1256 1256
1257 1257 To configure other defaults, add a section like this to your configuration
1258 1258 file:
1259 1259
1260 1260 [email]
1261 1261 from = My Name <my@email>
1262 1262 to = recipient1, recipient2, ...
1263 1263 cc = cc1, cc2, ...
1264 1264 bcc = bcc1, bcc2, ...
1265 1265 reply-to = address1, address2, ...
1266 1266
1267 1267 Use "[patchbomb]" as configuration section name if you need to override global
1268 1268 "[email]" address settings.
1269 1269
1270 1270 Then you can use the 'hg email' command to mail a series of changesets as a
1271 1271 patchbomb.
1272 1272
1273 1273 You can also either configure the method option in the email section to be a
1274 1274 sendmail compatible mailer or fill out the [smtp] section so that the
1275 1275 patchbomb extension can automatically send patchbombs directly from the
1276 1276 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1277 1277
1278 1278 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1279 1279 supply one via configuration or the command line. You can override this to
1280 1280 never prompt by configuring an empty value:
1281 1281
1282 1282 [email]
1283 1283 cc =
1284 1284
1285 1285 You can control the default inclusion of an introduction message with the
1286 1286 "patchbomb.intro" configuration option. The configuration is always
1287 1287 overwritten by command line flags like --intro and --desc:
1288 1288
1289 1289 [patchbomb]
1290 1290 intro=auto # include introduction message if more than 1 patch (default)
1291 1291 intro=never # never include an introduction message
1292 1292 intro=always # always include an introduction message
1293 1293
1294 1294 You can specify a template for flags to be added in subject prefixes. Flags
1295 1295 specified by --flag option are exported as "{flags}" keyword:
1296 1296
1297 1297 [patchbomb]
1298 1298 flagtemplate = "{separate(' ',
1299 1299 ifeq(branch, 'default', '', branch|upper),
1300 1300 flags)}"
1301 1301
1302 1302 You can set patchbomb to always ask for confirmation by setting
1303 1303 "patchbomb.confirm" to true.
1304 1304
1305 1305 (use 'hg help extensions' for information on enabling extensions)
1306 1306
1307 1307
1308 1308 Broken disabled extension and command:
1309 1309
1310 1310 $ mkdir hgext
1311 1311 $ echo > hgext/__init__.py
1312 1312 $ cat > hgext/broken.py <<NO_CHECK_EOF
1313 1313 > "broken extension'
1314 1314 > NO_CHECK_EOF
1315 1315 $ cat > path.py <<EOF
1316 1316 > import os
1317 1317 > import sys
1318 1318 > sys.path.insert(0, os.environ['HGEXTPATH'])
1319 1319 > EOF
1320 1320 $ HGEXTPATH=`pwd`
1321 1321 $ export HGEXTPATH
1322 1322
1323 1323 $ hg --config extensions.path=./path.py help broken
1324 1324 broken extension - (no help text available)
1325 1325
1326 1326 (use 'hg help extensions' for information on enabling extensions)
1327 1327
1328 1328
1329 1329 $ cat > hgext/forest.py <<EOF
1330 1330 > cmdtable = None
1331 1331 > @command()
1332 1332 > def f():
1333 1333 > pass
1334 1334 > @command(123)
1335 1335 > def g():
1336 1336 > pass
1337 1337 > EOF
1338 1338 $ hg --config extensions.path=./path.py help foo
1339 1339 abort: no such help topic: foo
1340 1340 (try 'hg help --keyword foo')
1341 1341 [255]
1342 1342
1343 1343 $ cat > throw.py <<EOF
1344 1344 > from mercurial import commands, registrar, util
1345 1345 > cmdtable = {}
1346 1346 > command = registrar.command(cmdtable)
1347 1347 > class Bogon(Exception): pass
1348 1348 > @command(b'throw', [], b'hg throw', norepo=True)
1349 1349 > def throw(ui, **opts):
1350 1350 > """throws an exception"""
1351 1351 > raise Bogon()
1352 1352 > EOF
1353 1353
1354 1354 No declared supported version, extension complains:
1355 1355 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1356 1356 ** Unknown exception encountered with possibly-broken third-party extension throw
1357 1357 ** which supports versions unknown of Mercurial.
1358 1358 ** Please disable throw and try your action again.
1359 1359 ** If that fixes the bug please report it to the extension author.
1360 1360 ** Python * (glob)
1361 1361 ** Mercurial Distributed SCM * (glob)
1362 1362 ** Extensions loaded: throw
1363 1363
1364 1364 empty declaration of supported version, extension complains:
1365 1365 $ echo "testedwith = ''" >> throw.py
1366 1366 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1367 1367 ** Unknown exception encountered with possibly-broken third-party extension throw
1368 1368 ** which supports versions unknown of Mercurial.
1369 1369 ** Please disable throw and try your action again.
1370 1370 ** If that fixes the bug please report it to the extension author.
1371 1371 ** Python * (glob)
1372 1372 ** Mercurial Distributed SCM (*) (glob)
1373 1373 ** Extensions loaded: throw
1374 1374
1375 1375 If the extension specifies a buglink, show that:
1376 1376 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1377 1377 $ rm -f throw.pyc throw.pyo
1378 1378 $ rm -Rf __pycache__
1379 1379 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1380 1380 ** Unknown exception encountered with possibly-broken third-party extension throw
1381 1381 ** which supports versions unknown of Mercurial.
1382 1382 ** Please disable throw and try your action again.
1383 1383 ** If that fixes the bug please report it to http://example.com/bts
1384 1384 ** Python * (glob)
1385 1385 ** Mercurial Distributed SCM (*) (glob)
1386 1386 ** Extensions loaded: throw
1387 1387
1388 1388 If the extensions declare outdated versions, accuse the older extension first:
1389 1389 $ echo "from mercurial import util" >> older.py
1390 1390 $ echo "util.version = lambda:b'2.2'" >> older.py
1391 1391 $ echo "testedwith = b'1.9.3'" >> older.py
1392 1392 $ echo "testedwith = b'2.1.1'" >> throw.py
1393 1393 $ rm -f throw.pyc throw.pyo
1394 1394 $ rm -Rf __pycache__
1395 1395 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1396 1396 > throw 2>&1 | egrep '^\*\*'
1397 1397 ** Unknown exception encountered with possibly-broken third-party extension older
1398 1398 ** which supports versions 1.9 of Mercurial.
1399 1399 ** Please disable older and try your action again.
1400 1400 ** If that fixes the bug please report it to the extension author.
1401 1401 ** Python * (glob)
1402 1402 ** Mercurial Distributed SCM (version 2.2)
1403 1403 ** Extensions loaded: throw, older
1404 1404
1405 1405 One extension only tested with older, one only with newer versions:
1406 1406 $ echo "util.version = lambda:b'2.1'" >> older.py
1407 1407 $ rm -f older.pyc older.pyo
1408 1408 $ rm -Rf __pycache__
1409 1409 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1410 1410 > throw 2>&1 | egrep '^\*\*'
1411 1411 ** Unknown exception encountered with possibly-broken third-party extension older
1412 1412 ** which supports versions 1.9 of Mercurial.
1413 1413 ** Please disable older and try your action again.
1414 1414 ** If that fixes the bug please report it to the extension author.
1415 1415 ** Python * (glob)
1416 1416 ** Mercurial Distributed SCM (version 2.1)
1417 1417 ** Extensions loaded: throw, older
1418 1418
1419 1419 Older extension is tested with current version, the other only with newer:
1420 1420 $ echo "util.version = lambda:b'1.9.3'" >> older.py
1421 1421 $ rm -f older.pyc older.pyo
1422 1422 $ rm -Rf __pycache__
1423 1423 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1424 1424 > throw 2>&1 | egrep '^\*\*'
1425 1425 ** Unknown exception encountered with possibly-broken third-party extension throw
1426 1426 ** which supports versions 2.1 of Mercurial.
1427 1427 ** Please disable throw and try your action again.
1428 1428 ** If that fixes the bug please report it to http://example.com/bts
1429 1429 ** Python * (glob)
1430 1430 ** Mercurial Distributed SCM (version 1.9.3)
1431 1431 ** Extensions loaded: throw, older
1432 1432
1433 1433 Ability to point to a different point
1434 1434 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1435 1435 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1436 1436 ** unknown exception encountered, please report by visiting
1437 1437 ** Your Local Goat Lenders
1438 1438 ** Python * (glob)
1439 1439 ** Mercurial Distributed SCM (*) (glob)
1440 1440 ** Extensions loaded: throw, older
1441 1441
1442 1442 Declare the version as supporting this hg version, show regular bts link:
1443 1443 $ hgver=`hg debuginstall -T '{hgver}'`
1444 1444 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1445 1445 $ if [ -z "$hgver" ]; then
1446 1446 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1447 1447 > fi
1448 1448 $ rm -f throw.pyc throw.pyo
1449 1449 $ rm -Rf __pycache__
1450 1450 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1451 1451 ** unknown exception encountered, please report by visiting
1452 1452 ** https://mercurial-scm.org/wiki/BugTracker
1453 1453 ** Python * (glob)
1454 1454 ** Mercurial Distributed SCM (*) (glob)
1455 1455 ** Extensions loaded: throw
1456 1456
1457 1457 Patch version is ignored during compatibility check
1458 1458 $ echo "testedwith = b'3.2'" >> throw.py
1459 1459 $ echo "util.version = lambda:b'3.2.2'" >> throw.py
1460 1460 $ rm -f throw.pyc throw.pyo
1461 1461 $ rm -Rf __pycache__
1462 1462 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1463 1463 ** unknown exception encountered, please report by visiting
1464 1464 ** https://mercurial-scm.org/wiki/BugTracker
1465 1465 ** Python * (glob)
1466 1466 ** Mercurial Distributed SCM (*) (glob)
1467 1467 ** Extensions loaded: throw
1468 1468
1469 1469 Test version number support in 'hg version':
1470 1470 $ echo '__version__ = (1, 2, 3)' >> throw.py
1471 1471 $ rm -f throw.pyc throw.pyo
1472 1472 $ rm -Rf __pycache__
1473 1473 $ hg version -v
1474 1474 Mercurial Distributed SCM (version *) (glob)
1475 1475 (see https://mercurial-scm.org for more information)
1476 1476
1477 1477 Copyright (C) 2005-* Matt Mackall and others (glob)
1478 1478 This is free software; see the source for copying conditions. There is NO
1479 1479 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1480 1480
1481 1481 Enabled extensions:
1482 1482
1483 1483
1484 1484 $ hg version -v --config extensions.throw=throw.py
1485 1485 Mercurial Distributed SCM (version *) (glob)
1486 1486 (see https://mercurial-scm.org for more information)
1487 1487
1488 1488 Copyright (C) 2005-* Matt Mackall and others (glob)
1489 1489 This is free software; see the source for copying conditions. There is NO
1490 1490 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1491 1491
1492 1492 Enabled extensions:
1493 1493
1494 1494 throw external 1.2.3
1495 1495 $ echo 'getversion = lambda: b"1.twentythree"' >> throw.py
1496 1496 $ rm -f throw.pyc throw.pyo
1497 1497 $ rm -Rf __pycache__
1498 1498 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1499 1499 Mercurial Distributed SCM (version *) (glob)
1500 1500 (see https://mercurial-scm.org for more information)
1501 1501
1502 1502 Copyright (C) 2005-* Matt Mackall and others (glob)
1503 1503 This is free software; see the source for copying conditions. There is NO
1504 1504 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1505 1505
1506 1506 Enabled extensions:
1507 1507
1508 1508 throw external 1.twentythree
1509 1509 strip internal
1510 1510
1511 1511 $ hg version -q --config extensions.throw=throw.py
1512 1512 Mercurial Distributed SCM (version *) (glob)
1513 1513
1514 1514 Test template output:
1515 1515
1516 1516 $ hg version --config extensions.strip= -T'{extensions}'
1517 1517 strip
1518 1518
1519 1519 Test JSON output of version:
1520 1520
1521 1521 $ hg version -Tjson
1522 1522 [
1523 1523 {
1524 1524 "extensions": [],
1525 1525 "ver": "*" (glob)
1526 1526 }
1527 1527 ]
1528 1528
1529 1529 $ hg version --config extensions.throw=throw.py -Tjson
1530 1530 [
1531 1531 {
1532 1532 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1533 1533 "ver": "3.2.2"
1534 1534 }
1535 1535 ]
1536 1536
1537 1537 $ hg version --config extensions.strip= -Tjson
1538 1538 [
1539 1539 {
1540 1540 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1541 1541 "ver": "*" (glob)
1542 1542 }
1543 1543 ]
1544 1544
1545 1545 Test template output of version:
1546 1546
1547 1547 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1548 1548 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1549 1549 throw 1.twentythree (external)
1550 1550 strip (internal)
1551 1551
1552 1552 Refuse to load extensions with minimum version requirements
1553 1553
1554 1554 $ cat > minversion1.py << EOF
1555 1555 > from mercurial import util
1556 1556 > util.version = lambda: b'3.5.2'
1557 1557 > minimumhgversion = b'3.6'
1558 1558 > EOF
1559 1559 $ hg --config extensions.minversion=minversion1.py version
1560 1560 (third party extension minversion requires version 3.6 or newer of Mercurial (current: 3.5.2); disabling)
1561 1561 Mercurial Distributed SCM (version 3.5.2)
1562 1562 (see https://mercurial-scm.org for more information)
1563 1563
1564 1564 Copyright (C) 2005-* Matt Mackall and others (glob)
1565 1565 This is free software; see the source for copying conditions. There is NO
1566 1566 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1567 1567
1568 1568 $ cat > minversion2.py << EOF
1569 1569 > from mercurial import util
1570 1570 > util.version = lambda: b'3.6'
1571 1571 > minimumhgversion = b'3.7'
1572 1572 > EOF
1573 1573 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1574 1574 (third party extension minversion requires version 3.7 or newer of Mercurial (current: 3.6); disabling)
1575 1575
1576 1576 Can load version that is only off by point release
1577 1577
1578 1578 $ cat > minversion2.py << EOF
1579 1579 > from mercurial import util
1580 1580 > util.version = lambda: b'3.6.1'
1581 1581 > minimumhgversion = b'3.6'
1582 1582 > EOF
1583 1583 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1584 1584 [1]
1585 1585
1586 1586 Can load minimum version identical to current
1587 1587
1588 1588 $ cat > minversion3.py << EOF
1589 1589 > from mercurial import util
1590 1590 > util.version = lambda: b'3.5'
1591 1591 > minimumhgversion = b'3.5'
1592 1592 > EOF
1593 1593 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1594 1594 [1]
1595 1595
1596 1596 Restore HGRCPATH
1597 1597
1598 1598 $ HGRCPATH=$ORGHGRCPATH
1599 1599 $ export HGRCPATH
1600 1600
1601 1601 Commands handling multiple repositories at a time should invoke only
1602 1602 "reposetup()" of extensions enabling in the target repository.
1603 1603
1604 1604 $ mkdir reposetup-test
1605 1605 $ cd reposetup-test
1606 1606
1607 1607 $ cat > $TESTTMP/reposetuptest.py <<EOF
1608 1608 > from mercurial import extensions
1609 1609 > def reposetup(ui, repo):
1610 1610 > ui.write(b'reposetup() for %s\n' % (repo.root))
1611 1611 > ui.flush()
1612 1612 > EOF
1613 1613 $ hg init src
1614 1614 $ echo a > src/a
1615 1615 $ hg -R src commit -Am '#0 at src/a'
1616 1616 adding a
1617 1617 $ echo '[extensions]' >> src/.hg/hgrc
1618 1618 $ echo '# enable extension locally' >> src/.hg/hgrc
1619 1619 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1620 1620 $ hg -R src status
1621 1621 reposetup() for $TESTTMP/reposetup-test/src
1622 1622 reposetup() for $TESTTMP/reposetup-test/src (chg !)
1623 1623
1624 1624 #if no-extraextensions
1625 1625 $ hg --cwd src debugextensions
1626 1626 reposetup() for $TESTTMP/reposetup-test/src
1627 1627 dodo (untested!)
1628 1628 dudu (untested!)
1629 1629 mq
1630 1630 reposetuptest (untested!)
1631 1631 strip
1632 1632 #endif
1633 1633
1634 1634 $ hg clone -U src clone-dst1
1635 1635 reposetup() for $TESTTMP/reposetup-test/src
1636 1636 $ hg init push-dst1
1637 1637 $ hg -q -R src push push-dst1
1638 1638 reposetup() for $TESTTMP/reposetup-test/src
1639 1639 $ hg init pull-src1
1640 1640 $ hg -q -R pull-src1 pull src
1641 1641 reposetup() for $TESTTMP/reposetup-test/src
1642 1642
1643 1643 $ cat <<EOF >> $HGRCPATH
1644 1644 > [extensions]
1645 1645 > # disable extension globally and explicitly
1646 1646 > reposetuptest = !
1647 1647 > EOF
1648 1648 $ hg clone -U src clone-dst2
1649 1649 reposetup() for $TESTTMP/reposetup-test/src
1650 1650 $ hg init push-dst2
1651 1651 $ hg -q -R src push push-dst2
1652 1652 reposetup() for $TESTTMP/reposetup-test/src
1653 1653 $ hg init pull-src2
1654 1654 $ hg -q -R pull-src2 pull src
1655 1655 reposetup() for $TESTTMP/reposetup-test/src
1656 1656
1657 1657 $ cat <<EOF >> $HGRCPATH
1658 1658 > [extensions]
1659 1659 > # enable extension globally
1660 1660 > reposetuptest = $TESTTMP/reposetuptest.py
1661 1661 > EOF
1662 1662 $ hg clone -U src clone-dst3
1663 1663 reposetup() for $TESTTMP/reposetup-test/src
1664 1664 reposetup() for $TESTTMP/reposetup-test/clone-dst3
1665 1665 $ hg init push-dst3
1666 1666 reposetup() for $TESTTMP/reposetup-test/push-dst3
1667 1667 $ hg -q -R src push push-dst3
1668 1668 reposetup() for $TESTTMP/reposetup-test/src
1669 1669 reposetup() for $TESTTMP/reposetup-test/push-dst3
1670 1670 $ hg init pull-src3
1671 1671 reposetup() for $TESTTMP/reposetup-test/pull-src3
1672 1672 $ hg -q -R pull-src3 pull src
1673 1673 reposetup() for $TESTTMP/reposetup-test/pull-src3
1674 1674 reposetup() for $TESTTMP/reposetup-test/src
1675 1675
1676 1676 $ echo '[extensions]' >> src/.hg/hgrc
1677 1677 $ echo '# disable extension locally' >> src/.hg/hgrc
1678 1678 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1679 1679 $ hg clone -U src clone-dst4
1680 1680 reposetup() for $TESTTMP/reposetup-test/clone-dst4
1681 1681 $ hg init push-dst4
1682 1682 reposetup() for $TESTTMP/reposetup-test/push-dst4
1683 1683 $ hg -q -R src push push-dst4
1684 1684 reposetup() for $TESTTMP/reposetup-test/push-dst4
1685 1685 $ hg init pull-src4
1686 1686 reposetup() for $TESTTMP/reposetup-test/pull-src4
1687 1687 $ hg -q -R pull-src4 pull src
1688 1688 reposetup() for $TESTTMP/reposetup-test/pull-src4
1689 1689
1690 1690 disabling in command line overlays with all configuration
1691 1691 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1692 1692 $ hg --config extensions.reposetuptest=! init push-dst5
1693 1693 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1694 1694 $ hg --config extensions.reposetuptest=! init pull-src5
1695 1695 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1696 1696
1697 1697 $ cat <<EOF >> $HGRCPATH
1698 1698 > [extensions]
1699 1699 > # disable extension globally and explicitly
1700 1700 > reposetuptest = !
1701 1701 > EOF
1702 1702 $ hg init parent
1703 1703 $ hg init parent/sub1
1704 1704 $ echo 1 > parent/sub1/1
1705 1705 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1706 1706 adding 1
1707 1707 $ hg init parent/sub2
1708 1708 $ hg init parent/sub2/sub21
1709 1709 $ echo 21 > parent/sub2/sub21/21
1710 1710 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1711 1711 adding 21
1712 1712 $ cat > parent/sub2/.hgsub <<EOF
1713 1713 > sub21 = sub21
1714 1714 > EOF
1715 1715 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1716 1716 adding .hgsub
1717 1717 $ hg init parent/sub3
1718 1718 $ echo 3 > parent/sub3/3
1719 1719 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1720 1720 adding 3
1721 1721 $ cat > parent/.hgsub <<EOF
1722 1722 > sub1 = sub1
1723 1723 > sub2 = sub2
1724 1724 > sub3 = sub3
1725 1725 > EOF
1726 1726 $ hg -R parent commit -Am '#0 at parent'
1727 1727 adding .hgsub
1728 1728 $ echo '[extensions]' >> parent/.hg/hgrc
1729 1729 $ echo '# enable extension locally' >> parent/.hg/hgrc
1730 1730 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1731 1731 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1732 1732 $ hg -R parent status -S -A
1733 1733 reposetup() for $TESTTMP/reposetup-test/parent
1734 1734 reposetup() for $TESTTMP/reposetup-test/parent/sub2
1735 1735 C .hgsub
1736 1736 C .hgsubstate
1737 1737 C sub1/1
1738 1738 C sub2/.hgsub
1739 1739 C sub2/.hgsubstate
1740 1740 C sub2/sub21/21
1741 1741 C sub3/3
1742 1742
1743 1743 $ cd ..
1744 1744
1745 1745 Prohibit registration of commands that don't use @command (issue5137)
1746 1746
1747 1747 $ hg init deprecated
1748 1748 $ cd deprecated
1749 1749
1750 1750 $ cat <<EOF > deprecatedcmd.py
1751 1751 > def deprecatedcmd(repo, ui):
1752 1752 > pass
1753 1753 > cmdtable = {
1754 1754 > b'deprecatedcmd': (deprecatedcmd, [], b''),
1755 1755 > }
1756 1756 > EOF
1757 1757 $ cat <<EOF > .hg/hgrc
1758 1758 > [extensions]
1759 1759 > deprecatedcmd = `pwd`/deprecatedcmd.py
1760 1760 > mq = !
1761 1761 > hgext.mq = !
1762 1762 > hgext/mq = !
1763 1763 > EOF
1764 1764
1765 1765 $ hg deprecatedcmd > /dev/null
1766 1766 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1767 1767 *** (use @command decorator to register 'deprecatedcmd')
1768 1768 hg: unknown command 'deprecatedcmd'
1769 1769 (use 'hg help' for a list of commands)
1770 1770 [255]
1771 1771
1772 1772 the extension shouldn't be loaded at all so the mq works:
1773 1773
1774 1774 $ hg qseries --config extensions.mq= > /dev/null
1775 1775 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1776 1776 *** (use @command decorator to register 'deprecatedcmd')
1777 1777
1778 1778 $ cd ..
1779 1779
1780 1780 Test synopsis and docstring extending
1781 1781
1782 1782 $ hg init exthelp
1783 1783 $ cat > exthelp.py <<EOF
1784 1784 > from mercurial import commands, extensions
1785 1785 > def exbookmarks(orig, *args, **opts):
1786 1786 > return orig(*args, **opts)
1787 1787 > def uisetup(ui):
1788 1788 > synopsis = b' GREPME [--foo] [-x]'
1789 1789 > docstring = '''
1790 1790 > GREPME make sure that this is in the help!
1791 1791 > '''
1792 1792 > extensions.wrapcommand(commands.table, b'bookmarks', exbookmarks,
1793 1793 > synopsis, docstring)
1794 1794 > EOF
1795 1795 $ abspath=`pwd`/exthelp.py
1796 1796 $ echo '[extensions]' >> $HGRCPATH
1797 1797 $ echo "exthelp = $abspath" >> $HGRCPATH
1798 1798 $ cd exthelp
1799 1799 $ hg help bookmarks | grep GREPME
1800 1800 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1801 1801 GREPME make sure that this is in the help!
1802 1802 $ cd ..
1803 1803
1804 1804 Show deprecation warning for the use of cmdutil.command
1805 1805
1806 1806 $ cat > nonregistrar.py <<EOF
1807 1807 > from mercurial import cmdutil
1808 1808 > cmdtable = {}
1809 1809 > command = cmdutil.command(cmdtable)
1810 1810 > @command(b'foo', [], norepo=True)
1811 1811 > def foo(ui):
1812 1812 > pass
1813 1813 > EOF
1814 1814
1815 1815 Prohibit the use of unicode strings as the default value of options
1816 1816
1817 1817 $ hg init $TESTTMP/opt-unicode-default
1818 1818
1819 1819 $ cat > $TESTTMP/test_unicode_default_value.py << EOF
1820 1820 > from __future__ import print_function
1821 1821 > from mercurial import registrar
1822 1822 > cmdtable = {}
1823 1823 > command = registrar.command(cmdtable)
1824 1824 > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]')
1825 1825 > def ext(*args, **opts):
1826 1826 > print(opts[b'opt'], flush=True)
1827 1827 > EOF
1828 1828 $ "$PYTHON" $TESTTMP/unflush.py $TESTTMP/test_unicode_default_value.py
1829 1829 $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF
1830 1830 > [extensions]
1831 1831 > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py
1832 1832 > EOF
1833 1833 $ hg -R $TESTTMP/opt-unicode-default dummy
1834 1834 *** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: unicode *'value' found in cmdtable.dummy (glob)
1835 1835 *** (use b'' to make it byte string)
1836 1836 hg: unknown command 'dummy'
1837 1837 (did you mean summary?)
1838 1838 [255]
@@ -1,1231 +1,1231 b''
1 1 A script that implements uppercasing of specific lines in a file. This
2 2 approximates the behavior of code formatters well enough for our tests.
3 3
4 4 $ UPPERCASEPY="$TESTTMP/uppercase.py"
5 5 $ cat > $UPPERCASEPY <<EOF
6 6 > import sys
7 7 > from mercurial.utils.procutil import setbinary
8 8 > setbinary(sys.stdin)
9 9 > setbinary(sys.stdout)
10 10 > lines = set()
11 11 > for arg in sys.argv[1:]:
12 12 > if arg == 'all':
13 13 > sys.stdout.write(sys.stdin.read().upper())
14 14 > sys.exit(0)
15 15 > else:
16 16 > first, last = arg.split('-')
17 17 > lines.update(range(int(first), int(last) + 1))
18 18 > for i, line in enumerate(sys.stdin.readlines()):
19 19 > if i + 1 in lines:
20 20 > sys.stdout.write(line.upper())
21 21 > else:
22 22 > sys.stdout.write(line)
23 23 > EOF
24 24 $ TESTLINES="foo\nbar\nbaz\nqux\n"
25 25 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
26 26 foo
27 27 bar
28 28 baz
29 29 qux
30 30 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY all
31 31 FOO
32 32 BAR
33 33 BAZ
34 34 QUX
35 35 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 1-1
36 36 FOO
37 37 bar
38 38 baz
39 39 qux
40 40 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 1-2
41 41 FOO
42 42 BAR
43 43 baz
44 44 qux
45 45 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 2-3
46 46 foo
47 47 BAR
48 48 BAZ
49 49 qux
50 50 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY 2-2 4-4
51 51 foo
52 52 BAR
53 53 baz
54 54 QUX
55 55
56 56 Set up the config with two simple fixers: one that fixes specific line ranges,
57 57 and one that always fixes the whole file. They both "fix" files by converting
58 58 letters to uppercase. They use different file extensions, so each test case can
59 59 choose which behavior to use by naming files.
60 60
61 61 $ cat >> $HGRCPATH <<EOF
62 62 > [extensions]
63 63 > fix =
64 64 > [experimental]
65 65 > evolution.createmarkers=True
66 66 > evolution.allowunstable=True
67 67 > [fix]
68 68 > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY all
69 69 > uppercase-whole-file:pattern=set:**.whole
70 70 > uppercase-changed-lines:command="$PYTHON" $UPPERCASEPY
71 71 > uppercase-changed-lines:linerange={first}-{last}
72 72 > uppercase-changed-lines:pattern=set:**.changed
73 73 > EOF
74 74
75 75 Help text for fix.
76 76
77 77 $ hg help fix
78 78 hg fix [OPTION]... [FILE]...
79 79
80 80 rewrite file content in changesets or working directory
81 81
82 82 Runs any configured tools to fix the content of files. Only affects files
83 83 with changes, unless file arguments are provided. Only affects changed
84 84 lines of files, unless the --whole flag is used. Some tools may always
85 85 affect the whole file regardless of --whole.
86 86
87 87 If revisions are specified with --rev, those revisions will be checked,
88 88 and they may be replaced with new revisions that have fixed file content.
89 89 It is desirable to specify all descendants of each specified revision, so
90 90 that the fixes propagate to the descendants. If all descendants are fixed
91 91 at the same time, no merging, rebasing, or evolution will be required.
92 92
93 93 If --working-dir is used, files with uncommitted changes in the working
94 94 copy will be fixed. If the checked-out revision is also fixed, the working
95 95 directory will update to the replacement revision.
96 96
97 97 When determining what lines of each file to fix at each revision, the
98 98 whole set of revisions being fixed is considered, so that fixes to earlier
99 99 revisions are not forgotten in later ones. The --base flag can be used to
100 100 override this default behavior, though it is not usually desirable to do
101 101 so.
102 102
103 103 (use 'hg help -e fix' to show help for the fix extension)
104 104
105 105 options ([+] can be repeated):
106 106
107 --all fix all non-public non-obsolete revisions
107 --all fix all non-public non-obsolete revisions (default: off)
108 108 --base REV [+] revisions to diff against (overrides automatic selection,
109 109 and applies to every revision being fixed)
110 110 -r --rev REV [+] revisions to fix
111 -w --working-dir fix the working directory
112 --whole always fix every line of a file
111 -w --working-dir fix the working directory (default: off)
112 --whole always fix every line of a file (default: off)
113 113
114 114 (some details hidden, use --verbose to show complete help)
115 115
116 116 $ hg help -e fix
117 117 fix extension - rewrite file content in changesets or working copy
118 118 (EXPERIMENTAL)
119 119
120 120 Provides a command that runs configured tools on the contents of modified
121 121 files, writing back any fixes to the working copy or replacing changesets.
122 122
123 123 Here is an example configuration that causes 'hg fix' to apply automatic
124 124 formatting fixes to modified lines in C++ code:
125 125
126 126 [fix]
127 127 clang-format:command=clang-format --assume-filename={rootpath}
128 128 clang-format:linerange=--lines={first}:{last}
129 129 clang-format:pattern=set:**.cpp or **.hpp
130 130
131 131 The :command suboption forms the first part of the shell command that will be
132 132 used to fix a file. The content of the file is passed on standard input, and
133 133 the fixed file content is expected on standard output. Any output on standard
134 134 error will be displayed as a warning. If the exit status is not zero, the file
135 135 will not be affected. A placeholder warning is displayed if there is a non-
136 136 zero exit status but no standard error output. Some values may be substituted
137 137 into the command:
138 138
139 139 {rootpath} The path of the file being fixed, relative to the repo root
140 140 {basename} The name of the file being fixed, without the directory path
141 141
142 142 If the :linerange suboption is set, the tool will only be run if there are
143 143 changed lines in a file. The value of this suboption is appended to the shell
144 144 command once for every range of changed lines in the file. Some values may be
145 145 substituted into the command:
146 146
147 147 {first} The 1-based line number of the first line in the modified range
148 148 {last} The 1-based line number of the last line in the modified range
149 149
150 150 The :pattern suboption determines which files will be passed through each
151 151 configured tool. See 'hg help patterns' for possible values. If there are file
152 152 arguments to 'hg fix', the intersection of these patterns is used.
153 153
154 154 There is also a configurable limit for the maximum size of file that will be
155 155 processed by 'hg fix':
156 156
157 157 [fix]
158 158 maxfilesize = 2MB
159 159
160 160 Normally, execution of configured tools will continue after a failure
161 161 (indicated by a non-zero exit status). It can also be configured to abort
162 162 after the first such failure, so that no files will be affected if any tool
163 163 fails. This abort will also cause 'hg fix' to exit with a non-zero status:
164 164
165 165 [fix]
166 166 failure = abort
167 167
168 168 When multiple tools are configured to affect a file, they execute in an order
169 169 defined by the :priority suboption. The priority suboption has a default value
170 170 of zero for each tool. Tools are executed in order of descending priority. The
171 171 execution order of tools with equal priority is unspecified. For example, you
172 172 could use the 'sort' and 'head' utilities to keep only the 10 smallest numbers
173 173 in a text file by ensuring that 'sort' runs before 'head':
174 174
175 175 [fix]
176 176 sort:command = sort --numeric-sort
177 177 head:command = head --lines=10
178 178 sort:pattern = numbers.txt
179 179 head:pattern = numbers.txt
180 180 sort:priority = 2
181 181 head:priority = 1
182 182
183 183 To account for changes made by each tool, the line numbers used for
184 184 incremental formatting are recomputed before executing the next tool. So, each
185 185 tool may see different values for the arguments added by the :linerange
186 186 suboption.
187 187
188 188 list of commands:
189 189
190 190 fix rewrite file content in changesets or working directory
191 191
192 192 (use 'hg help -v -e fix' to show built-in aliases and global options)
193 193
194 194 There is no default behavior in the absence of --rev and --working-dir.
195 195
196 196 $ hg init badusage
197 197 $ cd badusage
198 198
199 199 $ hg fix
200 200 abort: no changesets specified
201 201 (use --rev or --working-dir)
202 202 [255]
203 203 $ hg fix --whole
204 204 abort: no changesets specified
205 205 (use --rev or --working-dir)
206 206 [255]
207 207 $ hg fix --base 0
208 208 abort: no changesets specified
209 209 (use --rev or --working-dir)
210 210 [255]
211 211
212 212 Fixing a public revision isn't allowed. It should abort early enough that
213 213 nothing happens, even to the working directory.
214 214
215 215 $ printf "hello\n" > hello.whole
216 216 $ hg commit -Aqm "hello"
217 217 $ hg phase -r 0 --public
218 218 $ hg fix -r 0
219 219 abort: can't fix immutable changeset 0:6470986d2e7b
220 220 [255]
221 221 $ hg fix -r 0 --working-dir
222 222 abort: can't fix immutable changeset 0:6470986d2e7b
223 223 [255]
224 224 $ hg cat -r tip hello.whole
225 225 hello
226 226 $ cat hello.whole
227 227 hello
228 228
229 229 $ cd ..
230 230
231 231 Fixing a clean working directory should do nothing. Even the --whole flag
232 232 shouldn't cause any clean files to be fixed. Specifying a clean file explicitly
233 233 should only fix it if the fixer always fixes the whole file. The combination of
234 234 an explicit filename and --whole should format the entire file regardless.
235 235
236 236 $ hg init fixcleanwdir
237 237 $ cd fixcleanwdir
238 238
239 239 $ printf "hello\n" > hello.changed
240 240 $ printf "world\n" > hello.whole
241 241 $ hg commit -Aqm "foo"
242 242 $ hg fix --working-dir
243 243 $ hg diff
244 244 $ hg fix --working-dir --whole
245 245 $ hg diff
246 246 $ hg fix --working-dir *
247 247 $ cat *
248 248 hello
249 249 WORLD
250 250 $ hg revert --all --no-backup
251 251 reverting hello.whole
252 252 $ hg fix --working-dir * --whole
253 253 $ cat *
254 254 HELLO
255 255 WORLD
256 256
257 257 The same ideas apply to fixing a revision, so we create a revision that doesn't
258 258 modify either of the files in question and try fixing it. This also tests that
259 259 we ignore a file that doesn't match any configured fixer.
260 260
261 261 $ hg revert --all --no-backup
262 262 reverting hello.changed
263 263 reverting hello.whole
264 264 $ printf "unimportant\n" > some.file
265 265 $ hg commit -Aqm "some other file"
266 266
267 267 $ hg fix -r .
268 268 $ hg cat -r tip *
269 269 hello
270 270 world
271 271 unimportant
272 272 $ hg fix -r . --whole
273 273 $ hg cat -r tip *
274 274 hello
275 275 world
276 276 unimportant
277 277 $ hg fix -r . *
278 278 $ hg cat -r tip *
279 279 hello
280 280 WORLD
281 281 unimportant
282 282 $ hg fix -r . * --whole --config experimental.evolution.allowdivergence=true
283 283 2 new content-divergent changesets
284 284 $ hg cat -r tip *
285 285 HELLO
286 286 WORLD
287 287 unimportant
288 288
289 289 $ cd ..
290 290
291 291 Fixing the working directory should still work if there are no revisions.
292 292
293 293 $ hg init norevisions
294 294 $ cd norevisions
295 295
296 296 $ printf "something\n" > something.whole
297 297 $ hg add
298 298 adding something.whole
299 299 $ hg fix --working-dir
300 300 $ cat something.whole
301 301 SOMETHING
302 302
303 303 $ cd ..
304 304
305 305 Test the effect of fixing the working directory for each possible status, with
306 306 and without providing explicit file arguments.
307 307
308 308 $ hg init implicitlyfixstatus
309 309 $ cd implicitlyfixstatus
310 310
311 311 $ printf "modified\n" > modified.whole
312 312 $ printf "removed\n" > removed.whole
313 313 $ printf "deleted\n" > deleted.whole
314 314 $ printf "clean\n" > clean.whole
315 315 $ printf "ignored.whole" > .hgignore
316 316 $ hg commit -Aqm "stuff"
317 317
318 318 $ printf "modified!!!\n" > modified.whole
319 319 $ printf "unknown\n" > unknown.whole
320 320 $ printf "ignored\n" > ignored.whole
321 321 $ printf "added\n" > added.whole
322 322 $ hg add added.whole
323 323 $ hg remove removed.whole
324 324 $ rm deleted.whole
325 325
326 326 $ hg status --all
327 327 M modified.whole
328 328 A added.whole
329 329 R removed.whole
330 330 ! deleted.whole
331 331 ? unknown.whole
332 332 I ignored.whole
333 333 C .hgignore
334 334 C clean.whole
335 335
336 336 $ hg fix --working-dir
337 337
338 338 $ hg status --all
339 339 M modified.whole
340 340 A added.whole
341 341 R removed.whole
342 342 ! deleted.whole
343 343 ? unknown.whole
344 344 I ignored.whole
345 345 C .hgignore
346 346 C clean.whole
347 347
348 348 $ cat *.whole
349 349 ADDED
350 350 clean
351 351 ignored
352 352 MODIFIED!!!
353 353 unknown
354 354
355 355 $ printf "modified!!!\n" > modified.whole
356 356 $ printf "added\n" > added.whole
357 357 $ hg fix --working-dir *.whole
358 358
359 359 $ hg status --all
360 360 M clean.whole
361 361 M modified.whole
362 362 A added.whole
363 363 R removed.whole
364 364 ! deleted.whole
365 365 ? unknown.whole
366 366 I ignored.whole
367 367 C .hgignore
368 368
369 369 It would be better if this also fixed the unknown file.
370 370 $ cat *.whole
371 371 ADDED
372 372 CLEAN
373 373 ignored
374 374 MODIFIED!!!
375 375 unknown
376 376
377 377 $ cd ..
378 378
379 379 Test that incremental fixing works on files with additions, deletions, and
380 380 changes in multiple line ranges. Note that deletions do not generally cause
381 381 neighboring lines to be fixed, so we don't return a line range for purely
382 382 deleted sections. In the future we should support a :deletion config that
383 383 allows fixers to know where deletions are located.
384 384
385 385 $ hg init incrementalfixedlines
386 386 $ cd incrementalfixedlines
387 387
388 388 $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.txt
389 389 $ hg commit -Aqm "foo"
390 390 $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.txt
391 391
392 392 $ hg --config "fix.fail:command=echo" \
393 393 > --config "fix.fail:linerange={first}:{last}" \
394 394 > --config "fix.fail:pattern=foo.txt" \
395 395 > fix --working-dir
396 396 $ cat foo.txt
397 397 1:1 4:6 8:8
398 398
399 399 $ cd ..
400 400
401 401 Test that --whole fixes all lines regardless of the diffs present.
402 402
403 403 $ hg init wholeignoresdiffs
404 404 $ cd wholeignoresdiffs
405 405
406 406 $ printf "a\nb\nc\nd\ne\nf\ng\n" > foo.changed
407 407 $ hg commit -Aqm "foo"
408 408 $ printf "zz\na\nc\ndd\nee\nff\nf\ngg\n" > foo.changed
409 409 $ hg fix --working-dir --whole
410 410 $ cat foo.changed
411 411 ZZ
412 412 A
413 413 C
414 414 DD
415 415 EE
416 416 FF
417 417 F
418 418 GG
419 419
420 420 $ cd ..
421 421
422 422 We should do nothing with symlinks, and their targets should be unaffected. Any
423 423 other behavior would be more complicated to implement and harder to document.
424 424
425 425 #if symlink
426 426 $ hg init dontmesswithsymlinks
427 427 $ cd dontmesswithsymlinks
428 428
429 429 $ printf "hello\n" > hello.whole
430 430 $ ln -s hello.whole hellolink
431 431 $ hg add
432 432 adding hello.whole
433 433 adding hellolink
434 434 $ hg fix --working-dir hellolink
435 435 $ hg status
436 436 A hello.whole
437 437 A hellolink
438 438
439 439 $ cd ..
440 440 #endif
441 441
442 442 We should allow fixers to run on binary files, even though this doesn't sound
443 443 like a common use case. There's not much benefit to disallowing it, and users
444 444 can add "and not binary()" to their filesets if needed. The Mercurial
445 445 philosophy is generally to not handle binary files specially anyway.
446 446
447 447 $ hg init cantouchbinaryfiles
448 448 $ cd cantouchbinaryfiles
449 449
450 450 $ printf "hello\0\n" > hello.whole
451 451 $ hg add
452 452 adding hello.whole
453 453 $ hg fix --working-dir 'set:binary()'
454 454 $ cat hello.whole
455 455 HELLO\x00 (esc)
456 456
457 457 $ cd ..
458 458
459 459 We have a config for the maximum size of file we will attempt to fix. This can
460 460 be helpful to avoid running unsuspecting fixer tools on huge inputs, which
461 461 could happen by accident without a well considered configuration. A more
462 462 precise configuration could use the size() fileset function if one global limit
463 463 is undesired.
464 464
465 465 $ hg init maxfilesize
466 466 $ cd maxfilesize
467 467
468 468 $ printf "this file is huge\n" > hello.whole
469 469 $ hg add
470 470 adding hello.whole
471 471 $ hg --config fix.maxfilesize=10 fix --working-dir
472 472 ignoring file larger than 10 bytes: hello.whole
473 473 $ cat hello.whole
474 474 this file is huge
475 475
476 476 $ cd ..
477 477
478 478 If we specify a file to fix, other files should be left alone, even if they
479 479 have changes.
480 480
481 481 $ hg init fixonlywhatitellyouto
482 482 $ cd fixonlywhatitellyouto
483 483
484 484 $ printf "fix me!\n" > fixme.whole
485 485 $ printf "not me.\n" > notme.whole
486 486 $ hg add
487 487 adding fixme.whole
488 488 adding notme.whole
489 489 $ hg fix --working-dir fixme.whole
490 490 $ cat *.whole
491 491 FIX ME!
492 492 not me.
493 493
494 494 $ cd ..
495 495
496 496 Specifying a directory name should fix all its files and subdirectories.
497 497
498 498 $ hg init fixdirectory
499 499 $ cd fixdirectory
500 500
501 501 $ mkdir -p dir1/dir2
502 502 $ printf "foo\n" > foo.whole
503 503 $ printf "bar\n" > dir1/bar.whole
504 504 $ printf "baz\n" > dir1/dir2/baz.whole
505 505 $ hg add
506 506 adding dir1/bar.whole
507 507 adding dir1/dir2/baz.whole
508 508 adding foo.whole
509 509 $ hg fix --working-dir dir1
510 510 $ cat foo.whole dir1/bar.whole dir1/dir2/baz.whole
511 511 foo
512 512 BAR
513 513 BAZ
514 514
515 515 $ cd ..
516 516
517 517 Fixing a file in the working directory that needs no fixes should not actually
518 518 write back to the file, so for example the mtime shouldn't change.
519 519
520 520 $ hg init donttouchunfixedfiles
521 521 $ cd donttouchunfixedfiles
522 522
523 523 $ printf "NO FIX NEEDED\n" > foo.whole
524 524 $ hg add
525 525 adding foo.whole
526 526 $ cp -p foo.whole foo.whole.orig
527 527 $ cp -p foo.whole.orig foo.whole
528 528 $ sleep 2 # mtime has a resolution of one or two seconds.
529 529 $ hg fix --working-dir
530 530 $ f foo.whole.orig --newer foo.whole
531 531 foo.whole.orig: newer than foo.whole
532 532
533 533 $ cd ..
534 534
535 535 When a fixer prints to stderr, we don't assume that it has failed. We show the
536 536 error messages to the user, and we still let the fixer affect the file it was
537 537 fixing if its exit code is zero. Some code formatters might emit error messages
538 538 on stderr and nothing on stdout, which would cause us the clear the file,
539 539 except that they also exit with a non-zero code. We show the user which fixer
540 540 emitted the stderr, and which revision, but we assume that the fixer will print
541 541 the filename if it is relevant (since the issue may be non-specific). There is
542 542 also a config to abort (without affecting any files whatsoever) if we see any
543 543 tool with a non-zero exit status.
544 544
545 545 $ hg init showstderr
546 546 $ cd showstderr
547 547
548 548 $ printf "hello\n" > hello.txt
549 549 $ hg add
550 550 adding hello.txt
551 551 $ cat > $TESTTMP/work.sh <<'EOF'
552 552 > printf 'HELLO\n'
553 553 > printf "$@: some\nerror that didn't stop the tool" >&2
554 554 > exit 0 # success despite the stderr output
555 555 > EOF
556 556 $ hg --config "fix.work:command=sh $TESTTMP/work.sh {rootpath}" \
557 557 > --config "fix.work:pattern=hello.txt" \
558 558 > fix --working-dir
559 559 [wdir] work: hello.txt: some
560 560 [wdir] work: error that didn't stop the tool
561 561 $ cat hello.txt
562 562 HELLO
563 563
564 564 $ printf "goodbye\n" > hello.txt
565 565 $ printf "foo\n" > foo.whole
566 566 $ hg add
567 567 adding foo.whole
568 568 $ cat > $TESTTMP/fail.sh <<'EOF'
569 569 > printf 'GOODBYE\n'
570 570 > printf "$@: some\nerror that did stop the tool\n" >&2
571 571 > exit 42 # success despite the stdout output
572 572 > EOF
573 573 $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
574 574 > --config "fix.fail:pattern=hello.txt" \
575 575 > --config "fix.failure=abort" \
576 576 > fix --working-dir
577 577 [wdir] fail: hello.txt: some
578 578 [wdir] fail: error that did stop the tool
579 579 abort: no fixes will be applied
580 580 (use --config fix.failure=continue to apply any successful fixes anyway)
581 581 [255]
582 582 $ cat hello.txt
583 583 goodbye
584 584 $ cat foo.whole
585 585 foo
586 586
587 587 $ hg --config "fix.fail:command=sh $TESTTMP/fail.sh {rootpath}" \
588 588 > --config "fix.fail:pattern=hello.txt" \
589 589 > fix --working-dir
590 590 [wdir] fail: hello.txt: some
591 591 [wdir] fail: error that did stop the tool
592 592 $ cat hello.txt
593 593 goodbye
594 594 $ cat foo.whole
595 595 FOO
596 596
597 597 $ hg --config "fix.fail:command=exit 42" \
598 598 > --config "fix.fail:pattern=hello.txt" \
599 599 > fix --working-dir
600 600 [wdir] fail: exited with status 42
601 601
602 602 $ cd ..
603 603
604 604 Fixing the working directory and its parent revision at the same time should
605 605 check out the replacement revision for the parent. This prevents any new
606 606 uncommitted changes from appearing. We test this for a clean working directory
607 607 and a dirty one. In both cases, all lines/files changed since the grandparent
608 608 will be fixed. The grandparent is the "baserev" for both the parent and the
609 609 working copy.
610 610
611 611 $ hg init fixdotandcleanwdir
612 612 $ cd fixdotandcleanwdir
613 613
614 614 $ printf "hello\n" > hello.whole
615 615 $ printf "world\n" > world.whole
616 616 $ hg commit -Aqm "the parent commit"
617 617
618 618 $ hg parents --template '{rev} {desc}\n'
619 619 0 the parent commit
620 620 $ hg fix --working-dir -r .
621 621 $ hg parents --template '{rev} {desc}\n'
622 622 1 the parent commit
623 623 $ hg cat -r . *.whole
624 624 HELLO
625 625 WORLD
626 626 $ cat *.whole
627 627 HELLO
628 628 WORLD
629 629 $ hg status
630 630
631 631 $ cd ..
632 632
633 633 Same test with a dirty working copy.
634 634
635 635 $ hg init fixdotanddirtywdir
636 636 $ cd fixdotanddirtywdir
637 637
638 638 $ printf "hello\n" > hello.whole
639 639 $ printf "world\n" > world.whole
640 640 $ hg commit -Aqm "the parent commit"
641 641
642 642 $ printf "hello,\n" > hello.whole
643 643 $ printf "world!\n" > world.whole
644 644
645 645 $ hg parents --template '{rev} {desc}\n'
646 646 0 the parent commit
647 647 $ hg fix --working-dir -r .
648 648 $ hg parents --template '{rev} {desc}\n'
649 649 1 the parent commit
650 650 $ hg cat -r . *.whole
651 651 HELLO
652 652 WORLD
653 653 $ cat *.whole
654 654 HELLO,
655 655 WORLD!
656 656 $ hg status
657 657 M hello.whole
658 658 M world.whole
659 659
660 660 $ cd ..
661 661
662 662 When we have a chain of commits that change mutually exclusive lines of code,
663 663 we should be able to do incremental fixing that causes each commit in the chain
664 664 to include fixes made to the previous commits. This prevents children from
665 665 backing out the fixes made in their parents. A dirty working directory is
666 666 conceptually similar to another commit in the chain.
667 667
668 668 $ hg init incrementallyfixchain
669 669 $ cd incrementallyfixchain
670 670
671 671 $ cat > file.changed <<EOF
672 672 > first
673 673 > second
674 674 > third
675 675 > fourth
676 676 > fifth
677 677 > EOF
678 678 $ hg commit -Aqm "the common ancestor (the baserev)"
679 679 $ cat > file.changed <<EOF
680 680 > first (changed)
681 681 > second
682 682 > third
683 683 > fourth
684 684 > fifth
685 685 > EOF
686 686 $ hg commit -Aqm "the first commit to fix"
687 687 $ cat > file.changed <<EOF
688 688 > first (changed)
689 689 > second
690 690 > third (changed)
691 691 > fourth
692 692 > fifth
693 693 > EOF
694 694 $ hg commit -Aqm "the second commit to fix"
695 695 $ cat > file.changed <<EOF
696 696 > first (changed)
697 697 > second
698 698 > third (changed)
699 699 > fourth
700 700 > fifth (changed)
701 701 > EOF
702 702
703 703 $ hg fix -r . -r '.^' --working-dir
704 704
705 705 $ hg parents --template '{rev}\n'
706 706 4
707 707 $ hg cat -r '.^^' file.changed
708 708 first
709 709 second
710 710 third
711 711 fourth
712 712 fifth
713 713 $ hg cat -r '.^' file.changed
714 714 FIRST (CHANGED)
715 715 second
716 716 third
717 717 fourth
718 718 fifth
719 719 $ hg cat -r . file.changed
720 720 FIRST (CHANGED)
721 721 second
722 722 THIRD (CHANGED)
723 723 fourth
724 724 fifth
725 725 $ cat file.changed
726 726 FIRST (CHANGED)
727 727 second
728 728 THIRD (CHANGED)
729 729 fourth
730 730 FIFTH (CHANGED)
731 731
732 732 $ cd ..
733 733
734 734 If we incrementally fix a merge commit, we should fix any lines that changed
735 735 versus either parent. You could imagine only fixing the intersection or some
736 736 other subset, but this is necessary if either parent is being fixed. It
737 737 prevents us from forgetting fixes made in either parent.
738 738
739 739 $ hg init incrementallyfixmergecommit
740 740 $ cd incrementallyfixmergecommit
741 741
742 742 $ printf "a\nb\nc\n" > file.changed
743 743 $ hg commit -Aqm "ancestor"
744 744
745 745 $ printf "aa\nb\nc\n" > file.changed
746 746 $ hg commit -m "change a"
747 747
748 748 $ hg checkout '.^'
749 749 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
750 750 $ printf "a\nb\ncc\n" > file.changed
751 751 $ hg commit -m "change c"
752 752 created new head
753 753
754 754 $ hg merge
755 755 merging file.changed
756 756 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
757 757 (branch merge, don't forget to commit)
758 758 $ hg commit -m "merge"
759 759 $ hg cat -r . file.changed
760 760 aa
761 761 b
762 762 cc
763 763
764 764 $ hg fix -r . --working-dir
765 765 $ hg cat -r . file.changed
766 766 AA
767 767 b
768 768 CC
769 769
770 770 $ cd ..
771 771
772 772 Abort fixing revisions if there is an unfinished operation. We don't want to
773 773 make things worse by editing files or stripping/obsoleting things. Also abort
774 774 fixing the working directory if there are unresolved merge conflicts.
775 775
776 776 $ hg init abortunresolved
777 777 $ cd abortunresolved
778 778
779 779 $ echo "foo1" > foo.whole
780 780 $ hg commit -Aqm "foo 1"
781 781
782 782 $ hg update null
783 783 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
784 784 $ echo "foo2" > foo.whole
785 785 $ hg commit -Aqm "foo 2"
786 786
787 787 $ hg --config extensions.rebase= rebase -r 1 -d 0
788 788 rebasing 1:c3b6dc0e177a "foo 2" (tip)
789 789 merging foo.whole
790 790 warning: conflicts while merging foo.whole! (edit, then use 'hg resolve --mark')
791 791 unresolved conflicts (see hg resolve, then hg rebase --continue)
792 792 [1]
793 793
794 794 $ hg --config extensions.rebase= fix --working-dir
795 795 abort: unresolved conflicts
796 796 (use 'hg resolve')
797 797 [255]
798 798
799 799 $ hg --config extensions.rebase= fix -r .
800 800 abort: rebase in progress
801 801 (use 'hg rebase --continue' or 'hg rebase --abort')
802 802 [255]
803 803
804 804 When fixing a file that was renamed, we should diff against the source of the
805 805 rename for incremental fixing and we should correctly reproduce the rename in
806 806 the replacement revision.
807 807
808 808 $ hg init fixrenamecommit
809 809 $ cd fixrenamecommit
810 810
811 811 $ printf "a\nb\nc\n" > source.changed
812 812 $ hg commit -Aqm "source revision"
813 813 $ hg move source.changed dest.changed
814 814 $ printf "a\nb\ncc\n" > dest.changed
815 815 $ hg commit -m "dest revision"
816 816
817 817 $ hg fix -r .
818 818 $ hg log -r tip --copies --template "{file_copies}\n"
819 819 dest.changed (source.changed)
820 820 $ hg cat -r tip dest.changed
821 821 a
822 822 b
823 823 CC
824 824
825 825 $ cd ..
826 826
827 827 When fixing revisions that remove files we must ensure that the replacement
828 828 actually removes the file, whereas it could accidentally leave it unchanged or
829 829 write an empty string to it.
830 830
831 831 $ hg init fixremovedfile
832 832 $ cd fixremovedfile
833 833
834 834 $ printf "foo\n" > foo.whole
835 835 $ printf "bar\n" > bar.whole
836 836 $ hg commit -Aqm "add files"
837 837 $ hg remove bar.whole
838 838 $ hg commit -m "remove file"
839 839 $ hg status --change .
840 840 R bar.whole
841 841 $ hg fix -r . foo.whole
842 842 $ hg status --change tip
843 843 M foo.whole
844 844 R bar.whole
845 845
846 846 $ cd ..
847 847
848 848 If fixing a revision finds no fixes to make, no replacement revision should be
849 849 created.
850 850
851 851 $ hg init nofixesneeded
852 852 $ cd nofixesneeded
853 853
854 854 $ printf "FOO\n" > foo.whole
855 855 $ hg commit -Aqm "add file"
856 856 $ hg log --template '{rev}\n'
857 857 0
858 858 $ hg fix -r .
859 859 $ hg log --template '{rev}\n'
860 860 0
861 861
862 862 $ cd ..
863 863
864 864 If fixing a commit reverts all the changes in the commit, we replace it with a
865 865 commit that changes no files.
866 866
867 867 $ hg init nochangesleft
868 868 $ cd nochangesleft
869 869
870 870 $ printf "FOO\n" > foo.whole
871 871 $ hg commit -Aqm "add file"
872 872 $ printf "foo\n" > foo.whole
873 873 $ hg commit -m "edit file"
874 874 $ hg status --change .
875 875 M foo.whole
876 876 $ hg fix -r .
877 877 $ hg status --change tip
878 878
879 879 $ cd ..
880 880
881 881 If we fix a parent and child revision together, the child revision must be
882 882 replaced if the parent is replaced, even if the diffs of the child needed no
883 883 fixes. However, we're free to not replace revisions that need no fixes and have
884 884 no ancestors that are replaced.
885 885
886 886 $ hg init mustreplacechild
887 887 $ cd mustreplacechild
888 888
889 889 $ printf "FOO\n" > foo.whole
890 890 $ hg commit -Aqm "add foo"
891 891 $ printf "foo\n" > foo.whole
892 892 $ hg commit -m "edit foo"
893 893 $ printf "BAR\n" > bar.whole
894 894 $ hg commit -Aqm "add bar"
895 895
896 896 $ hg log --graph --template '{rev} {files}'
897 897 @ 2 bar.whole
898 898 |
899 899 o 1 foo.whole
900 900 |
901 901 o 0 foo.whole
902 902
903 903 $ hg fix -r 0:2
904 904 $ hg log --graph --template '{rev} {files}'
905 905 o 4 bar.whole
906 906 |
907 907 o 3
908 908 |
909 909 | @ 2 bar.whole
910 910 | |
911 911 | x 1 foo.whole
912 912 |/
913 913 o 0 foo.whole
914 914
915 915
916 916 $ cd ..
917 917
918 918 It's also possible that the child needs absolutely no changes, but we still
919 919 need to replace it to update its parent. If we skipped replacing the child
920 920 because it had no file content changes, it would become an orphan for no good
921 921 reason.
922 922
923 923 $ hg init mustreplacechildevenifnop
924 924 $ cd mustreplacechildevenifnop
925 925
926 926 $ printf "Foo\n" > foo.whole
927 927 $ hg commit -Aqm "add a bad foo"
928 928 $ printf "FOO\n" > foo.whole
929 929 $ hg commit -m "add a good foo"
930 930 $ hg fix -r . -r '.^'
931 931 $ hg log --graph --template '{rev} {desc}'
932 932 o 3 add a good foo
933 933 |
934 934 o 2 add a bad foo
935 935
936 936 @ 1 add a good foo
937 937 |
938 938 x 0 add a bad foo
939 939
940 940
941 941 $ cd ..
942 942
943 943 Similar to the case above, the child revision may become empty as a result of
944 944 fixing its parent. We should still create an empty replacement child.
945 945 TODO: determine how this should interact with ui.allowemptycommit given that
946 946 the empty replacement could have children.
947 947
948 948 $ hg init mustreplacechildevenifempty
949 949 $ cd mustreplacechildevenifempty
950 950
951 951 $ printf "foo\n" > foo.whole
952 952 $ hg commit -Aqm "add foo"
953 953 $ printf "Foo\n" > foo.whole
954 954 $ hg commit -m "edit foo"
955 955 $ hg fix -r . -r '.^'
956 956 $ hg log --graph --template '{rev} {desc}\n' --stat
957 957 o 3 edit foo
958 958 |
959 959 o 2 add foo
960 960 foo.whole | 1 +
961 961 1 files changed, 1 insertions(+), 0 deletions(-)
962 962
963 963 @ 1 edit foo
964 964 | foo.whole | 2 +-
965 965 | 1 files changed, 1 insertions(+), 1 deletions(-)
966 966 |
967 967 x 0 add foo
968 968 foo.whole | 1 +
969 969 1 files changed, 1 insertions(+), 0 deletions(-)
970 970
971 971
972 972 $ cd ..
973 973
974 974 Fixing a secret commit should replace it with another secret commit.
975 975
976 976 $ hg init fixsecretcommit
977 977 $ cd fixsecretcommit
978 978
979 979 $ printf "foo\n" > foo.whole
980 980 $ hg commit -Aqm "add foo" --secret
981 981 $ hg fix -r .
982 982 $ hg log --template '{rev} {phase}\n'
983 983 1 secret
984 984 0 secret
985 985
986 986 $ cd ..
987 987
988 988 We should also preserve phase when fixing a draft commit while the user has
989 989 their default set to secret.
990 990
991 991 $ hg init respectphasesnewcommit
992 992 $ cd respectphasesnewcommit
993 993
994 994 $ printf "foo\n" > foo.whole
995 995 $ hg commit -Aqm "add foo"
996 996 $ hg --config phases.newcommit=secret fix -r .
997 997 $ hg log --template '{rev} {phase}\n'
998 998 1 draft
999 999 0 draft
1000 1000
1001 1001 $ cd ..
1002 1002
1003 1003 Debug output should show what fixer commands are being subprocessed, which is
1004 1004 useful for anyone trying to set up a new config.
1005 1005
1006 1006 $ hg init debugoutput
1007 1007 $ cd debugoutput
1008 1008
1009 1009 $ printf "foo\nbar\nbaz\n" > foo.changed
1010 1010 $ hg commit -Aqm "foo"
1011 1011 $ printf "Foo\nbar\nBaz\n" > foo.changed
1012 1012 $ hg --debug fix --working-dir
1013 1013 subprocess: * $TESTTMP/uppercase.py 1-1 3-3 (glob)
1014 1014
1015 1015 $ cd ..
1016 1016
1017 1017 Fixing an obsolete revision can cause divergence, so we abort unless the user
1018 1018 configures to allow it. This is not yet smart enough to know whether there is a
1019 1019 successor, but even then it is not likely intentional or idiomatic to fix an
1020 1020 obsolete revision.
1021 1021
1022 1022 $ hg init abortobsoleterev
1023 1023 $ cd abortobsoleterev
1024 1024
1025 1025 $ printf "foo\n" > foo.changed
1026 1026 $ hg commit -Aqm "foo"
1027 1027 $ hg debugobsolete `hg parents --template '{node}'`
1028 1028 obsoleted 1 changesets
1029 1029 $ hg --hidden fix -r 0
1030 1030 abort: fixing obsolete revision could cause divergence
1031 1031 [255]
1032 1032
1033 1033 $ hg --hidden fix -r 0 --config experimental.evolution.allowdivergence=true
1034 1034 $ hg cat -r tip foo.changed
1035 1035 FOO
1036 1036
1037 1037 $ cd ..
1038 1038
1039 1039 Test all of the available substitution values for fixer commands.
1040 1040
1041 1041 $ hg init substitution
1042 1042 $ cd substitution
1043 1043
1044 1044 $ mkdir foo
1045 1045 $ printf "hello\ngoodbye\n" > foo/bar
1046 1046 $ hg add
1047 1047 adding foo/bar
1048 1048 $ hg --config "fix.fail:command=printf '%s\n' '{rootpath}' '{basename}'" \
1049 1049 > --config "fix.fail:linerange='{first}' '{last}'" \
1050 1050 > --config "fix.fail:pattern=foo/bar" \
1051 1051 > fix --working-dir
1052 1052 $ cat foo/bar
1053 1053 foo/bar
1054 1054 bar
1055 1055 1
1056 1056 2
1057 1057
1058 1058 $ cd ..
1059 1059
1060 1060 The --base flag should allow picking the revisions to diff against for changed
1061 1061 files and incremental line formatting.
1062 1062
1063 1063 $ hg init baseflag
1064 1064 $ cd baseflag
1065 1065
1066 1066 $ printf "one\ntwo\n" > foo.changed
1067 1067 $ printf "bar\n" > bar.changed
1068 1068 $ hg commit -Aqm "first"
1069 1069 $ printf "one\nTwo\n" > foo.changed
1070 1070 $ hg commit -m "second"
1071 1071 $ hg fix -w --base .
1072 1072 $ hg status
1073 1073 $ hg fix -w --base null
1074 1074 $ cat foo.changed
1075 1075 ONE
1076 1076 TWO
1077 1077 $ cat bar.changed
1078 1078 BAR
1079 1079
1080 1080 $ cd ..
1081 1081
1082 1082 If the user asks to fix the parent of another commit, they are asking to create
1083 1083 an orphan. We must respect experimental.evolution.allowunstable.
1084 1084
1085 1085 $ hg init allowunstable
1086 1086 $ cd allowunstable
1087 1087
1088 1088 $ printf "one\n" > foo.whole
1089 1089 $ hg commit -Aqm "first"
1090 1090 $ printf "two\n" > foo.whole
1091 1091 $ hg commit -m "second"
1092 1092 $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
1093 1093 abort: can only fix a changeset together with all its descendants
1094 1094 [255]
1095 1095 $ hg fix -r '.^'
1096 1096 1 new orphan changesets
1097 1097 $ hg cat -r 2 foo.whole
1098 1098 ONE
1099 1099
1100 1100 $ cd ..
1101 1101
1102 1102 The --base flag affects the set of files being fixed. So while the --whole flag
1103 1103 makes the base irrelevant for changed line ranges, it still changes the
1104 1104 meaning and effect of the command. In this example, no files or lines are fixed
1105 1105 until we specify the base, but then we do fix unchanged lines.
1106 1106
1107 1107 $ hg init basewhole
1108 1108 $ cd basewhole
1109 1109 $ printf "foo1\n" > foo.changed
1110 1110 $ hg commit -Aqm "first"
1111 1111 $ printf "foo2\n" >> foo.changed
1112 1112 $ printf "bar\n" > bar.changed
1113 1113 $ hg commit -Aqm "second"
1114 1114
1115 1115 $ hg fix --working-dir --whole
1116 1116 $ cat *.changed
1117 1117 bar
1118 1118 foo1
1119 1119 foo2
1120 1120
1121 1121 $ hg fix --working-dir --base 0 --whole
1122 1122 $ cat *.changed
1123 1123 BAR
1124 1124 FOO1
1125 1125 FOO2
1126 1126
1127 1127 $ cd ..
1128 1128
1129 1129 The :fileset subconfig was a misnomer, so we renamed it to :pattern. We will
1130 1130 still accept :fileset by itself as if it were :pattern, but this will issue a
1131 1131 warning.
1132 1132
1133 1133 $ hg init filesetispattern
1134 1134 $ cd filesetispattern
1135 1135
1136 1136 $ printf "foo\n" > foo.whole
1137 1137 $ printf "first\nsecond\n" > bar.txt
1138 1138 $ hg add -q
1139 1139 $ hg fix -w --config fix.sometool:fileset=bar.txt \
1140 1140 > --config fix.sometool:command="sort -r"
1141 1141 the fix.tool:fileset config name is deprecated; please rename it to fix.tool:pattern
1142 1142
1143 1143 $ cat foo.whole
1144 1144 FOO
1145 1145 $ cat bar.txt
1146 1146 second
1147 1147 first
1148 1148
1149 1149 $ cd ..
1150 1150
1151 1151 The execution order of tools can be controlled. This example doesn't work if
1152 1152 you sort after truncating, but the config defines the correct order while the
1153 1153 definitions are out of order (which might imply the incorrect order given the
1154 1154 implementation of fix). The goal is to use multiple tools to select the lowest
1155 1155 5 numbers in the file.
1156 1156
1157 1157 $ hg init priorityexample
1158 1158 $ cd priorityexample
1159 1159
1160 1160 $ cat >> .hg/hgrc <<EOF
1161 1161 > [fix]
1162 1162 > head:command = head --lines=5
1163 1163 > head:pattern = numbers.txt
1164 1164 > head:priority = 1
1165 1165 > sort:command = sort --numeric-sort
1166 1166 > sort:pattern = numbers.txt
1167 1167 > sort:priority = 2
1168 1168 > EOF
1169 1169
1170 1170 $ printf "8\n2\n3\n6\n7\n4\n9\n5\n1\n0\n" > numbers.txt
1171 1171 $ hg add -q
1172 1172 $ hg fix -w
1173 1173 $ cat numbers.txt
1174 1174 0
1175 1175 1
1176 1176 2
1177 1177 3
1178 1178 4
1179 1179
1180 1180 And of course we should be able to break this by reversing the execution order.
1181 1181 Test negative priorities while we're at it.
1182 1182
1183 1183 $ cat >> .hg/hgrc <<EOF
1184 1184 > [fix]
1185 1185 > head:priority = -1
1186 1186 > sort:priority = -2
1187 1187 > EOF
1188 1188 $ printf "8\n2\n3\n6\n7\n4\n9\n5\n1\n0\n" > numbers.txt
1189 1189 $ hg fix -w
1190 1190 $ cat numbers.txt
1191 1191 2
1192 1192 3
1193 1193 6
1194 1194 7
1195 1195 8
1196 1196
1197 1197 $ cd ..
1198 1198
1199 1199 It's possible for repeated applications of a fixer tool to create cycles in the
1200 1200 generated content of a file. For example, two users with different versions of
1201 1201 a code formatter might fight over the formatting when they run hg fix. In the
1202 1202 absence of other changes, this means we could produce commits with the same
1203 1203 hash in subsequent runs of hg fix. This is a problem unless we support
1204 1204 obsolescence cycles well. We avoid this by adding an extra field to the
1205 1205 successor which forces it to have a new hash. That's why this test creates
1206 1206 three revisions instead of two.
1207 1207
1208 1208 $ hg init cyclictool
1209 1209 $ cd cyclictool
1210 1210
1211 1211 $ cat >> .hg/hgrc <<EOF
1212 1212 > [fix]
1213 1213 > swapletters:command = tr ab ba
1214 1214 > swapletters:pattern = foo
1215 1215 > EOF
1216 1216
1217 1217 $ echo ab > foo
1218 1218 $ hg commit -Aqm foo
1219 1219
1220 1220 $ hg fix -r 0
1221 1221 $ hg fix -r 1
1222 1222
1223 1223 $ hg cat -r 0 foo --hidden
1224 1224 ab
1225 1225 $ hg cat -r 1 foo --hidden
1226 1226 ba
1227 1227 $ hg cat -r 2 foo
1228 1228 ab
1229 1229
1230 1230 $ cd ..
1231 1231
@@ -1,3826 +1,3826 b''
1 1 Short help:
2 2
3 3 $ hg
4 4 Mercurial Distributed SCM
5 5
6 6 basic commands:
7 7
8 8 add add the specified files on the next commit
9 9 annotate show changeset information by line for each file
10 10 clone make a copy of an existing repository
11 11 commit commit the specified files or all outstanding changes
12 12 diff diff repository (or selected files)
13 13 export dump the header and diffs for one or more changesets
14 14 forget forget the specified files on the next commit
15 15 init create a new repository in the given directory
16 16 log show revision history of entire repository or files
17 17 merge merge another revision into working directory
18 18 pull pull changes from the specified source
19 19 push push changes to the specified destination
20 20 remove remove the specified files on the next commit
21 21 serve start stand-alone webserver
22 22 status show changed files in the working directory
23 23 summary summarize working directory state
24 24 update update working directory (or switch revisions)
25 25
26 26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27 27
28 28 $ hg -q
29 29 add add the specified files on the next commit
30 30 annotate show changeset information by line for each file
31 31 clone make a copy of an existing repository
32 32 commit commit the specified files or all outstanding changes
33 33 diff diff repository (or selected files)
34 34 export dump the header and diffs for one or more changesets
35 35 forget forget the specified files on the next commit
36 36 init create a new repository in the given directory
37 37 log show revision history of entire repository or files
38 38 merge merge another revision into working directory
39 39 pull pull changes from the specified source
40 40 push push changes to the specified destination
41 41 remove remove the specified files on the next commit
42 42 serve start stand-alone webserver
43 43 status show changed files in the working directory
44 44 summary summarize working directory state
45 45 update update working directory (or switch revisions)
46 46
47 47 Extra extensions will be printed in help output in a non-reliable order since
48 48 the extension is unknown.
49 49 #if no-extraextensions
50 50
51 51 $ hg help
52 52 Mercurial Distributed SCM
53 53
54 54 list of commands:
55 55
56 56 Repository creation:
57 57
58 58 clone make a copy of an existing repository
59 59 init create a new repository in the given directory
60 60
61 61 Remote repository management:
62 62
63 63 incoming show new changesets found in source
64 64 outgoing show changesets not found in the destination
65 65 paths show aliases for remote repositories
66 66 pull pull changes from the specified source
67 67 push push changes to the specified destination
68 68 serve start stand-alone webserver
69 69
70 70 Change creation:
71 71
72 72 commit commit the specified files or all outstanding changes
73 73
74 74 Change manipulation:
75 75
76 76 backout reverse effect of earlier changeset
77 77 graft copy changes from other branches onto the current branch
78 78 merge merge another revision into working directory
79 79
80 80 Change organization:
81 81
82 82 bookmarks create a new bookmark or list existing bookmarks
83 83 branch set or show the current branch name
84 84 branches list repository named branches
85 85 phase set or show the current phase name
86 86 tag add one or more tags for the current or given revision
87 87 tags list repository tags
88 88
89 89 File content management:
90 90
91 91 annotate show changeset information by line for each file
92 92 cat output the current or given revision of files
93 93 copy mark files as copied for the next commit
94 94 diff diff repository (or selected files)
95 95 grep search revision history for a pattern in specified files
96 96
97 97 Change navigation:
98 98
99 99 bisect subdivision search of changesets
100 100 heads show branch heads
101 101 identify identify the working directory or specified revision
102 102 log show revision history of entire repository or files
103 103
104 104 Working directory management:
105 105
106 106 add add the specified files on the next commit
107 107 addremove add all new files, delete all missing files
108 108 files list tracked files
109 109 forget forget the specified files on the next commit
110 110 remove remove the specified files on the next commit
111 111 rename rename files; equivalent of copy + remove
112 112 resolve redo merges or set/view the merge status of files
113 113 revert restore files to their checkout state
114 114 root print the root (top) of the current working directory
115 115 status show changed files in the working directory
116 116 summary summarize working directory state
117 117 update update working directory (or switch revisions)
118 118
119 119 Change import/export:
120 120
121 121 archive create an unversioned archive of a repository revision
122 122 bundle create a bundle file
123 123 export dump the header and diffs for one or more changesets
124 124 import import an ordered set of patches
125 125 unbundle apply one or more bundle files
126 126
127 127 Repository maintenance:
128 128
129 129 manifest output the current or given revision of the project manifest
130 130 recover roll back an interrupted transaction
131 131 verify verify the integrity of the repository
132 132
133 133 Help:
134 134
135 135 config show combined config settings from all hgrc files
136 136 help show help for a given topic or a help overview
137 137 version output version and copyright information
138 138
139 139 additional help topics:
140 140
141 141 Mercurial identifiers:
142 142
143 143 filesets Specifying File Sets
144 144 hgignore Syntax for Mercurial Ignore Files
145 145 patterns File Name Patterns
146 146 revisions Specifying Revisions
147 147 urls URL Paths
148 148
149 149 Mercurial output:
150 150
151 151 color Colorizing Outputs
152 152 dates Date Formats
153 153 diffs Diff Formats
154 154 templating Template Usage
155 155
156 156 Mercurial configuration:
157 157
158 158 config Configuration Files
159 159 environment Environment Variables
160 160 extensions Using Additional Features
161 161 flags Command-line flags
162 162 hgweb Configuring hgweb
163 163 merge-tools Merge Tools
164 164 pager Pager Support
165 165
166 166 Concepts:
167 167
168 168 bundlespec Bundle File Formats
169 169 glossary Glossary
170 170 phases Working with Phases
171 171 subrepos Subrepositories
172 172
173 173 Miscellaneous:
174 174
175 175 deprecated Deprecated Features
176 176 internals Technical implementation topics
177 177 scripting Using Mercurial from scripts and automation
178 178
179 179 (use 'hg help -v' to show built-in aliases and global options)
180 180
181 181 $ hg -q help
182 182 Repository creation:
183 183
184 184 clone make a copy of an existing repository
185 185 init create a new repository in the given directory
186 186
187 187 Remote repository management:
188 188
189 189 incoming show new changesets found in source
190 190 outgoing show changesets not found in the destination
191 191 paths show aliases for remote repositories
192 192 pull pull changes from the specified source
193 193 push push changes to the specified destination
194 194 serve start stand-alone webserver
195 195
196 196 Change creation:
197 197
198 198 commit commit the specified files or all outstanding changes
199 199
200 200 Change manipulation:
201 201
202 202 backout reverse effect of earlier changeset
203 203 graft copy changes from other branches onto the current branch
204 204 merge merge another revision into working directory
205 205
206 206 Change organization:
207 207
208 208 bookmarks create a new bookmark or list existing bookmarks
209 209 branch set or show the current branch name
210 210 branches list repository named branches
211 211 phase set or show the current phase name
212 212 tag add one or more tags for the current or given revision
213 213 tags list repository tags
214 214
215 215 File content management:
216 216
217 217 annotate show changeset information by line for each file
218 218 cat output the current or given revision of files
219 219 copy mark files as copied for the next commit
220 220 diff diff repository (or selected files)
221 221 grep search revision history for a pattern in specified files
222 222
223 223 Change navigation:
224 224
225 225 bisect subdivision search of changesets
226 226 heads show branch heads
227 227 identify identify the working directory or specified revision
228 228 log show revision history of entire repository or files
229 229
230 230 Working directory management:
231 231
232 232 add add the specified files on the next commit
233 233 addremove add all new files, delete all missing files
234 234 files list tracked files
235 235 forget forget the specified files on the next commit
236 236 remove remove the specified files on the next commit
237 237 rename rename files; equivalent of copy + remove
238 238 resolve redo merges or set/view the merge status of files
239 239 revert restore files to their checkout state
240 240 root print the root (top) of the current working directory
241 241 status show changed files in the working directory
242 242 summary summarize working directory state
243 243 update update working directory (or switch revisions)
244 244
245 245 Change import/export:
246 246
247 247 archive create an unversioned archive of a repository revision
248 248 bundle create a bundle file
249 249 export dump the header and diffs for one or more changesets
250 250 import import an ordered set of patches
251 251 unbundle apply one or more bundle files
252 252
253 253 Repository maintenance:
254 254
255 255 manifest output the current or given revision of the project manifest
256 256 recover roll back an interrupted transaction
257 257 verify verify the integrity of the repository
258 258
259 259 Help:
260 260
261 261 config show combined config settings from all hgrc files
262 262 help show help for a given topic or a help overview
263 263 version output version and copyright information
264 264
265 265 additional help topics:
266 266
267 267 Mercurial identifiers:
268 268
269 269 filesets Specifying File Sets
270 270 hgignore Syntax for Mercurial Ignore Files
271 271 patterns File Name Patterns
272 272 revisions Specifying Revisions
273 273 urls URL Paths
274 274
275 275 Mercurial output:
276 276
277 277 color Colorizing Outputs
278 278 dates Date Formats
279 279 diffs Diff Formats
280 280 templating Template Usage
281 281
282 282 Mercurial configuration:
283 283
284 284 config Configuration Files
285 285 environment Environment Variables
286 286 extensions Using Additional Features
287 287 flags Command-line flags
288 288 hgweb Configuring hgweb
289 289 merge-tools Merge Tools
290 290 pager Pager Support
291 291
292 292 Concepts:
293 293
294 294 bundlespec Bundle File Formats
295 295 glossary Glossary
296 296 phases Working with Phases
297 297 subrepos Subrepositories
298 298
299 299 Miscellaneous:
300 300
301 301 deprecated Deprecated Features
302 302 internals Technical implementation topics
303 303 scripting Using Mercurial from scripts and automation
304 304
305 305 Test extension help:
306 306 $ hg help extensions --config extensions.rebase= --config extensions.children=
307 307 Using Additional Features
308 308 """""""""""""""""""""""""
309 309
310 310 Mercurial has the ability to add new features through the use of
311 311 extensions. Extensions may add new commands, add options to existing
312 312 commands, change the default behavior of commands, or implement hooks.
313 313
314 314 To enable the "foo" extension, either shipped with Mercurial or in the
315 315 Python search path, create an entry for it in your configuration file,
316 316 like this:
317 317
318 318 [extensions]
319 319 foo =
320 320
321 321 You may also specify the full path to an extension:
322 322
323 323 [extensions]
324 324 myfeature = ~/.hgext/myfeature.py
325 325
326 326 See 'hg help config' for more information on configuration files.
327 327
328 328 Extensions are not loaded by default for a variety of reasons: they can
329 329 increase startup overhead; they may be meant for advanced usage only; they
330 330 may provide potentially dangerous abilities (such as letting you destroy
331 331 or modify history); they might not be ready for prime time; or they may
332 332 alter some usual behaviors of stock Mercurial. It is thus up to the user
333 333 to activate extensions as needed.
334 334
335 335 To explicitly disable an extension enabled in a configuration file of
336 336 broader scope, prepend its path with !:
337 337
338 338 [extensions]
339 339 # disabling extension bar residing in /path/to/extension/bar.py
340 340 bar = !/path/to/extension/bar.py
341 341 # ditto, but no path was supplied for extension baz
342 342 baz = !
343 343
344 344 enabled extensions:
345 345
346 346 children command to display child changesets (DEPRECATED)
347 347 rebase command to move sets of revisions to a different ancestor
348 348
349 349 disabled extensions:
350 350
351 351 acl hooks for controlling repository access
352 352 blackbox log repository events to a blackbox for debugging
353 353 bugzilla hooks for integrating with the Bugzilla bug tracker
354 354 censor erase file content at a given revision
355 355 churn command to display statistics about repository history
356 356 clonebundles advertise pre-generated bundles to seed clones
357 357 closehead close arbitrary heads without checking them out first
358 358 convert import revisions from foreign VCS repositories into
359 359 Mercurial
360 360 eol automatically manage newlines in repository files
361 361 extdiff command to allow external programs to compare revisions
362 362 factotum http authentication with factotum
363 363 githelp try mapping git commands to Mercurial commands
364 364 gpg commands to sign and verify changesets
365 365 hgk browse the repository in a graphical way
366 366 highlight syntax highlighting for hgweb (requires Pygments)
367 367 histedit interactive history editing
368 368 keyword expand keywords in tracked files
369 369 largefiles track large binary files
370 370 mq manage a stack of patches
371 371 notify hooks for sending email push notifications
372 372 patchbomb command to send changesets as (a series of) patch emails
373 373 purge command to delete untracked files from the working
374 374 directory
375 375 relink recreates hardlinks between repository clones
376 376 schemes extend schemes with shortcuts to repository swarms
377 377 share share a common history between several working directories
378 378 shelve save and restore changes to the working directory
379 379 strip strip changesets and their descendants from history
380 380 transplant command to transplant changesets from another branch
381 381 win32mbcs allow the use of MBCS paths with problematic encodings
382 382 zeroconf discover and advertise repositories on the local network
383 383
384 384 #endif
385 385
386 386 Verify that deprecated extensions are included if --verbose:
387 387
388 388 $ hg -v help extensions | grep children
389 389 children command to display child changesets (DEPRECATED)
390 390
391 391 Verify that extension keywords appear in help templates
392 392
393 393 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
394 394
395 395 Test short command list with verbose option
396 396
397 397 $ hg -v help shortlist
398 398 Mercurial Distributed SCM
399 399
400 400 basic commands:
401 401
402 402 add add the specified files on the next commit
403 403 annotate, blame
404 404 show changeset information by line for each file
405 405 clone make a copy of an existing repository
406 406 commit, ci commit the specified files or all outstanding changes
407 407 diff diff repository (or selected files)
408 408 export dump the header and diffs for one or more changesets
409 409 forget forget the specified files on the next commit
410 410 init create a new repository in the given directory
411 411 log, history show revision history of entire repository or files
412 412 merge merge another revision into working directory
413 413 pull pull changes from the specified source
414 414 push push changes to the specified destination
415 415 remove, rm remove the specified files on the next commit
416 416 serve start stand-alone webserver
417 417 status, st show changed files in the working directory
418 418 summary, sum summarize working directory state
419 419 update, up, checkout, co
420 420 update working directory (or switch revisions)
421 421
422 422 global options ([+] can be repeated):
423 423
424 424 -R --repository REPO repository root directory or name of overlay bundle
425 425 file
426 426 --cwd DIR change working directory
427 427 -y --noninteractive do not prompt, automatically pick the first choice for
428 428 all prompts
429 429 -q --quiet suppress output
430 430 -v --verbose enable additional output
431 431 --color TYPE when to colorize (boolean, always, auto, never, or
432 432 debug)
433 433 --config CONFIG [+] set/override config option (use 'section.name=value')
434 434 --debug enable debugging output
435 435 --debugger start debugger
436 436 --encoding ENCODE set the charset encoding (default: ascii)
437 437 --encodingmode MODE set the charset encoding mode (default: strict)
438 438 --traceback always print a traceback on exception
439 439 --time time how long the command takes
440 440 --profile print command execution profile
441 441 --version output version information and exit
442 442 -h --help display help and exit
443 --hidden consider hidden changesets
443 --hidden consider hidden changesets (default: off)
444 444 --pager TYPE when to paginate (boolean, always, auto, or never)
445 445 (default: auto)
446 446
447 447 (use 'hg help' for the full list of commands)
448 448
449 449 $ hg add -h
450 450 hg add [OPTION]... [FILE]...
451 451
452 452 add the specified files on the next commit
453 453
454 454 Schedule files to be version controlled and added to the repository.
455 455
456 456 The files will be added to the repository at the next commit. To undo an
457 457 add before that, see 'hg forget'.
458 458
459 459 If no names are given, add all files to the repository (except files
460 460 matching ".hgignore").
461 461
462 462 Returns 0 if all files are successfully added.
463 463
464 464 options ([+] can be repeated):
465 465
466 466 -I --include PATTERN [+] include names matching the given patterns
467 467 -X --exclude PATTERN [+] exclude names matching the given patterns
468 468 -S --subrepos recurse into subrepositories
469 469 -n --dry-run do not perform actions, just print output
470 470
471 471 (some details hidden, use --verbose to show complete help)
472 472
473 473 Verbose help for add
474 474
475 475 $ hg add -hv
476 476 hg add [OPTION]... [FILE]...
477 477
478 478 add the specified files on the next commit
479 479
480 480 Schedule files to be version controlled and added to the repository.
481 481
482 482 The files will be added to the repository at the next commit. To undo an
483 483 add before that, see 'hg forget'.
484 484
485 485 If no names are given, add all files to the repository (except files
486 486 matching ".hgignore").
487 487
488 488 Examples:
489 489
490 490 - New (unknown) files are added automatically by 'hg add':
491 491
492 492 $ ls
493 493 foo.c
494 494 $ hg status
495 495 ? foo.c
496 496 $ hg add
497 497 adding foo.c
498 498 $ hg status
499 499 A foo.c
500 500
501 501 - Specific files to be added can be specified:
502 502
503 503 $ ls
504 504 bar.c foo.c
505 505 $ hg status
506 506 ? bar.c
507 507 ? foo.c
508 508 $ hg add bar.c
509 509 $ hg status
510 510 A bar.c
511 511 ? foo.c
512 512
513 513 Returns 0 if all files are successfully added.
514 514
515 515 options ([+] can be repeated):
516 516
517 517 -I --include PATTERN [+] include names matching the given patterns
518 518 -X --exclude PATTERN [+] exclude names matching the given patterns
519 519 -S --subrepos recurse into subrepositories
520 520 -n --dry-run do not perform actions, just print output
521 521
522 522 global options ([+] can be repeated):
523 523
524 524 -R --repository REPO repository root directory or name of overlay bundle
525 525 file
526 526 --cwd DIR change working directory
527 527 -y --noninteractive do not prompt, automatically pick the first choice for
528 528 all prompts
529 529 -q --quiet suppress output
530 530 -v --verbose enable additional output
531 531 --color TYPE when to colorize (boolean, always, auto, never, or
532 532 debug)
533 533 --config CONFIG [+] set/override config option (use 'section.name=value')
534 534 --debug enable debugging output
535 535 --debugger start debugger
536 536 --encoding ENCODE set the charset encoding (default: ascii)
537 537 --encodingmode MODE set the charset encoding mode (default: strict)
538 538 --traceback always print a traceback on exception
539 539 --time time how long the command takes
540 540 --profile print command execution profile
541 541 --version output version information and exit
542 542 -h --help display help and exit
543 --hidden consider hidden changesets
543 --hidden consider hidden changesets (default: off)
544 544 --pager TYPE when to paginate (boolean, always, auto, or never)
545 545 (default: auto)
546 546
547 547 Test the textwidth config option
548 548
549 549 $ hg root -h --config ui.textwidth=50
550 550 hg root
551 551
552 552 print the root (top) of the current working
553 553 directory
554 554
555 555 Print the root directory of the current
556 556 repository.
557 557
558 558 Returns 0 on success.
559 559
560 560 (some details hidden, use --verbose to show
561 561 complete help)
562 562
563 563 Test help option with version option
564 564
565 565 $ hg add -h --version
566 566 Mercurial Distributed SCM (version *) (glob)
567 567 (see https://mercurial-scm.org for more information)
568 568
569 569 Copyright (C) 2005-* Matt Mackall and others (glob)
570 570 This is free software; see the source for copying conditions. There is NO
571 571 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
572 572
573 573 $ hg add --skjdfks
574 574 hg add: option --skjdfks not recognized
575 575 hg add [OPTION]... [FILE]...
576 576
577 577 add the specified files on the next commit
578 578
579 579 options ([+] can be repeated):
580 580
581 581 -I --include PATTERN [+] include names matching the given patterns
582 582 -X --exclude PATTERN [+] exclude names matching the given patterns
583 583 -S --subrepos recurse into subrepositories
584 584 -n --dry-run do not perform actions, just print output
585 585
586 586 (use 'hg add -h' to show more help)
587 587 [255]
588 588
589 589 Test ambiguous command help
590 590
591 591 $ hg help ad
592 592 list of commands:
593 593
594 594 add add the specified files on the next commit
595 595 addremove add all new files, delete all missing files
596 596
597 597 (use 'hg help -v ad' to show built-in aliases and global options)
598 598
599 599 Test command without options
600 600
601 601 $ hg help verify
602 602 hg verify
603 603
604 604 verify the integrity of the repository
605 605
606 606 Verify the integrity of the current repository.
607 607
608 608 This will perform an extensive check of the repository's integrity,
609 609 validating the hashes and checksums of each entry in the changelog,
610 610 manifest, and tracked files, as well as the integrity of their crosslinks
611 611 and indices.
612 612
613 613 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
614 614 information about recovery from corruption of the repository.
615 615
616 616 Returns 0 on success, 1 if errors are encountered.
617 617
618 618 (some details hidden, use --verbose to show complete help)
619 619
620 620 $ hg help diff
621 621 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
622 622
623 623 diff repository (or selected files)
624 624
625 625 Show differences between revisions for the specified files.
626 626
627 627 Differences between files are shown using the unified diff format.
628 628
629 629 Note:
630 630 'hg diff' may generate unexpected results for merges, as it will
631 631 default to comparing against the working directory's first parent
632 632 changeset if no revisions are specified.
633 633
634 634 When two revision arguments are given, then changes are shown between
635 635 those revisions. If only one revision is specified then that revision is
636 636 compared to the working directory, and, when no revisions are specified,
637 637 the working directory files are compared to its first parent.
638 638
639 639 Alternatively you can specify -c/--change with a revision to see the
640 640 changes in that changeset relative to its first parent.
641 641
642 642 Without the -a/--text option, diff will avoid generating diffs of files it
643 643 detects as binary. With -a, diff will generate a diff anyway, probably
644 644 with undesirable results.
645 645
646 646 Use the -g/--git option to generate diffs in the git extended diff format.
647 647 For more information, read 'hg help diffs'.
648 648
649 649 Returns 0 on success.
650 650
651 651 options ([+] can be repeated):
652 652
653 653 -r --rev REV [+] revision
654 654 -c --change REV change made by revision
655 655 -a --text treat all files as text
656 656 -g --git use git extended diff format
657 657 --binary generate binary diffs in git mode (default)
658 658 --nodates omit dates from diff headers
659 659 --noprefix omit a/ and b/ prefixes from filenames
660 660 -p --show-function show which function each change is in
661 661 --reverse produce a diff that undoes the changes
662 662 -w --ignore-all-space ignore white space when comparing lines
663 663 -b --ignore-space-change ignore changes in the amount of white space
664 664 -B --ignore-blank-lines ignore changes whose lines are all blank
665 665 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
666 666 -U --unified NUM number of lines of context to show
667 667 --stat output diffstat-style summary of changes
668 668 --root DIR produce diffs relative to subdirectory
669 669 -I --include PATTERN [+] include names matching the given patterns
670 670 -X --exclude PATTERN [+] exclude names matching the given patterns
671 671 -S --subrepos recurse into subrepositories
672 672
673 673 (some details hidden, use --verbose to show complete help)
674 674
675 675 $ hg help status
676 676 hg status [OPTION]... [FILE]...
677 677
678 678 aliases: st
679 679
680 680 show changed files in the working directory
681 681
682 682 Show status of files in the repository. If names are given, only files
683 683 that match are shown. Files that are clean or ignored or the source of a
684 684 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
685 685 -C/--copies or -A/--all are given. Unless options described with "show
686 686 only ..." are given, the options -mardu are used.
687 687
688 688 Option -q/--quiet hides untracked (unknown and ignored) files unless
689 689 explicitly requested with -u/--unknown or -i/--ignored.
690 690
691 691 Note:
692 692 'hg status' may appear to disagree with diff if permissions have
693 693 changed or a merge has occurred. The standard diff format does not
694 694 report permission changes and diff only reports changes relative to one
695 695 merge parent.
696 696
697 697 If one revision is given, it is used as the base revision. If two
698 698 revisions are given, the differences between them are shown. The --change
699 699 option can also be used as a shortcut to list the changed files of a
700 700 revision from its first parent.
701 701
702 702 The codes used to show the status of files are:
703 703
704 704 M = modified
705 705 A = added
706 706 R = removed
707 707 C = clean
708 708 ! = missing (deleted by non-hg command, but still tracked)
709 709 ? = not tracked
710 710 I = ignored
711 711 = origin of the previous file (with --copies)
712 712
713 713 Returns 0 on success.
714 714
715 715 options ([+] can be repeated):
716 716
717 717 -A --all show status of all files
718 718 -m --modified show only modified files
719 719 -a --added show only added files
720 720 -r --removed show only removed files
721 721 -d --deleted show only deleted (but tracked) files
722 722 -c --clean show only files without changes
723 723 -u --unknown show only unknown (not tracked) files
724 724 -i --ignored show only ignored files
725 725 -n --no-status hide status prefix
726 726 -C --copies show source of copied files
727 727 -0 --print0 end filenames with NUL, for use with xargs
728 728 --rev REV [+] show difference from revision
729 729 --change REV list the changed files of a revision
730 730 -I --include PATTERN [+] include names matching the given patterns
731 731 -X --exclude PATTERN [+] exclude names matching the given patterns
732 732 -S --subrepos recurse into subrepositories
733 733 -T --template TEMPLATE display with template
734 734
735 735 (some details hidden, use --verbose to show complete help)
736 736
737 737 $ hg -q help status
738 738 hg status [OPTION]... [FILE]...
739 739
740 740 show changed files in the working directory
741 741
742 742 $ hg help foo
743 743 abort: no such help topic: foo
744 744 (try 'hg help --keyword foo')
745 745 [255]
746 746
747 747 $ hg skjdfks
748 748 hg: unknown command 'skjdfks'
749 749 (use 'hg help' for a list of commands)
750 750 [255]
751 751
752 752 Typoed command gives suggestion
753 753 $ hg puls
754 754 hg: unknown command 'puls'
755 755 (did you mean one of pull, push?)
756 756 [255]
757 757
758 758 Not enabled extension gets suggested
759 759
760 760 $ hg rebase
761 761 hg: unknown command 'rebase'
762 762 'rebase' is provided by the following extension:
763 763
764 764 rebase command to move sets of revisions to a different ancestor
765 765
766 766 (use 'hg help extensions' for information on enabling extensions)
767 767 [255]
768 768
769 769 Disabled extension gets suggested
770 770 $ hg --config extensions.rebase=! rebase
771 771 hg: unknown command 'rebase'
772 772 'rebase' is provided by the following extension:
773 773
774 774 rebase command to move sets of revisions to a different ancestor
775 775
776 776 (use 'hg help extensions' for information on enabling extensions)
777 777 [255]
778 778
779 779 Make sure that we don't run afoul of the help system thinking that
780 780 this is a section and erroring out weirdly.
781 781
782 782 $ hg .log
783 783 hg: unknown command '.log'
784 784 (did you mean log?)
785 785 [255]
786 786
787 787 $ hg log.
788 788 hg: unknown command 'log.'
789 789 (did you mean log?)
790 790 [255]
791 791 $ hg pu.lh
792 792 hg: unknown command 'pu.lh'
793 793 (did you mean one of pull, push?)
794 794 [255]
795 795
796 796 $ cat > helpext.py <<EOF
797 797 > import os
798 798 > from mercurial import commands, fancyopts, registrar
799 799 >
800 800 > def func(arg):
801 801 > return '%sfoo' % arg
802 802 > class customopt(fancyopts.customopt):
803 803 > def newstate(self, oldstate, newparam, abort):
804 804 > return '%sbar' % oldstate
805 805 > cmdtable = {}
806 806 > command = registrar.command(cmdtable)
807 807 >
808 808 > @command(b'nohelp',
809 809 > [(b'', b'longdesc', 3, b'x'*67),
810 810 > (b'n', b'', None, b'normal desc'),
811 811 > (b'', b'newline', b'', b'line1\nline2'),
812 812 > (b'', b'default-off', False, b'enable X'),
813 813 > (b'', b'default-on', True, b'enable Y'),
814 814 > (b'', b'callableopt', func, b'adds foo'),
815 815 > (b'', b'customopt', customopt(''), b'adds bar'),
816 816 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
817 817 > b'hg nohelp',
818 818 > norepo=True)
819 819 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
820 820 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
821 821 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
822 822 > def nohelp(ui, *args, **kwargs):
823 823 > pass
824 824 >
825 825 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
826 826 > def hashelp(ui, *args, **kwargs):
827 827 > """Extension command's help"""
828 828 > pass
829 829 >
830 830 > def uisetup(ui):
831 831 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
832 832 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
833 833 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
834 834 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
835 835 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
836 836 >
837 837 > EOF
838 838 $ echo '[extensions]' >> $HGRCPATH
839 839 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
840 840
841 841 Test for aliases
842 842
843 843 $ hg help | grep hgalias
844 844 hgalias My doc
845 845
846 846 $ hg help hgalias
847 847 hg hgalias [--remote]
848 848
849 849 alias for: hg summary
850 850
851 851 My doc
852 852
853 853 defined by: helpext
854 854
855 855 options:
856 856
857 857 --remote check for push and pull
858 858
859 859 (some details hidden, use --verbose to show complete help)
860 860 $ hg help hgaliasnodoc
861 861 hg hgaliasnodoc [--remote]
862 862
863 863 alias for: hg summary
864 864
865 865 summarize working directory state
866 866
867 867 This generates a brief summary of the working directory state, including
868 868 parents, branch, commit status, phase and available updates.
869 869
870 870 With the --remote option, this will check the default paths for incoming
871 871 and outgoing changes. This can be time-consuming.
872 872
873 873 Returns 0 on success.
874 874
875 875 defined by: helpext
876 876
877 877 options:
878 878
879 879 --remote check for push and pull
880 880
881 881 (some details hidden, use --verbose to show complete help)
882 882
883 883 $ hg help shellalias
884 884 hg shellalias
885 885
886 886 shell alias for: echo hi
887 887
888 888 (no help text available)
889 889
890 890 defined by: helpext
891 891
892 892 (some details hidden, use --verbose to show complete help)
893 893
894 894 Test command with no help text
895 895
896 896 $ hg help nohelp
897 897 hg nohelp
898 898
899 899 (no help text available)
900 900
901 901 options:
902 902
903 903 --longdesc VALUE
904 904 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
905 905 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
906 906 -n -- normal desc
907 907 --newline VALUE line1 line2
908 --default-off enable X
908 --default-off enable X (default: off)
909 909 --default-on enable Y (default: on)
910 910 --callableopt VALUE adds foo
911 911 --customopt VALUE adds bar
912 912 --customopt-withdefault VALUE adds bar (default: foo)
913 913
914 914 (some details hidden, use --verbose to show complete help)
915 915
916 916 Test that default list of commands includes extension commands that have help,
917 917 but not those that don't, except in verbose mode, when a keyword is passed, or
918 918 when help about the extension is requested.
919 919
920 920 #if no-extraextensions
921 921
922 922 $ hg help | grep hashelp
923 923 hashelp Extension command's help
924 924 $ hg help | grep nohelp
925 925 [1]
926 926 $ hg help -v | grep nohelp
927 927 nohelp (no help text available)
928 928
929 929 $ hg help -k nohelp
930 930 Commands:
931 931
932 932 nohelp hg nohelp
933 933
934 934 Extension Commands:
935 935
936 936 nohelp (no help text available)
937 937
938 938 $ hg help helpext
939 939 helpext extension - no help text available
940 940
941 941 list of commands:
942 942
943 943 hashelp Extension command's help
944 944 nohelp (no help text available)
945 945
946 946 (use 'hg help -v helpext' to show built-in aliases and global options)
947 947
948 948 #endif
949 949
950 950 Test list of internal help commands
951 951
952 952 $ hg help debug
953 953 debug commands (internal and unsupported):
954 954
955 955 debugancestor
956 956 find the ancestor revision of two revisions in a given index
957 957 debugapplystreamclonebundle
958 958 apply a stream clone bundle file
959 959 debugbuilddag
960 960 builds a repo with a given DAG from scratch in the current
961 961 empty repo
962 962 debugbundle lists the contents of a bundle
963 963 debugcapabilities
964 964 lists the capabilities of a remote peer
965 965 debugcheckstate
966 966 validate the correctness of the current dirstate
967 967 debugcolor show available color, effects or style
968 968 debugcommands
969 969 list all available commands and options
970 970 debugcomplete
971 971 returns the completion list associated with the given command
972 972 debugcreatestreamclonebundle
973 973 create a stream clone bundle file
974 974 debugdag format the changelog or an index DAG as a concise textual
975 975 description
976 976 debugdata dump the contents of a data file revision
977 977 debugdate parse and display a date
978 978 debugdeltachain
979 979 dump information about delta chains in a revlog
980 980 debugdirstate
981 981 show the contents of the current dirstate
982 982 debugdiscovery
983 983 runs the changeset discovery protocol in isolation
984 984 debugdownload
985 985 download a resource using Mercurial logic and config
986 986 debugextensions
987 987 show information about active extensions
988 988 debugfileset parse and apply a fileset specification
989 989 debugformat display format information about the current repository
990 990 debugfsinfo show information detected about current filesystem
991 991 debuggetbundle
992 992 retrieves a bundle from a repo
993 993 debugignore display the combined ignore pattern and information about
994 994 ignored files
995 995 debugindex dump index data for a storage primitive
996 996 debugindexdot
997 997 dump an index DAG as a graphviz dot file
998 998 debugindexstats
999 999 show stats related to the changelog index
1000 1000 debuginstall test Mercurial installation
1001 1001 debugknown test whether node ids are known to a repo
1002 1002 debuglocks show or modify state of locks
1003 1003 debugmanifestfulltextcache
1004 1004 show, clear or amend the contents of the manifest fulltext
1005 1005 cache
1006 1006 debugmergestate
1007 1007 print merge state
1008 1008 debugnamecomplete
1009 1009 complete "names" - tags, open branch names, bookmark names
1010 1010 debugobsolete
1011 1011 create arbitrary obsolete marker
1012 1012 debugoptADV (no help text available)
1013 1013 debugoptDEP (no help text available)
1014 1014 debugoptEXP (no help text available)
1015 1015 debugpathcomplete
1016 1016 complete part or all of a tracked path
1017 1017 debugpeer establish a connection to a peer repository
1018 1018 debugpickmergetool
1019 1019 examine which merge tool is chosen for specified file
1020 1020 debugpushkey access the pushkey key/value protocol
1021 1021 debugpvec (no help text available)
1022 1022 debugrebuilddirstate
1023 1023 rebuild the dirstate as it would look like for the given
1024 1024 revision
1025 1025 debugrebuildfncache
1026 1026 rebuild the fncache file
1027 1027 debugrename dump rename information
1028 1028 debugrevlog show data and statistics about a revlog
1029 1029 debugrevlogindex
1030 1030 dump the contents of a revlog index
1031 1031 debugrevspec parse and apply a revision specification
1032 1032 debugserve run a server with advanced settings
1033 1033 debugsetparents
1034 1034 manually set the parents of the current working directory
1035 1035 debugssl test a secure connection to a server
1036 1036 debugsub (no help text available)
1037 1037 debugsuccessorssets
1038 1038 show set of successors for revision
1039 1039 debugtemplate
1040 1040 parse and apply a template
1041 1041 debuguigetpass
1042 1042 show prompt to type password
1043 1043 debuguiprompt
1044 1044 show plain prompt
1045 1045 debugupdatecaches
1046 1046 warm all known caches in the repository
1047 1047 debugupgraderepo
1048 1048 upgrade a repository to use different features
1049 1049 debugwalk show how files match on given patterns
1050 1050 debugwhyunstable
1051 1051 explain instabilities of a changeset
1052 1052 debugwireargs
1053 1053 (no help text available)
1054 1054 debugwireproto
1055 1055 send wire protocol commands to a server
1056 1056
1057 1057 (use 'hg help -v debug' to show built-in aliases and global options)
1058 1058
1059 1059 internals topic renders index of available sub-topics
1060 1060
1061 1061 $ hg help internals
1062 1062 Technical implementation topics
1063 1063 """""""""""""""""""""""""""""""
1064 1064
1065 1065 To access a subtopic, use "hg help internals.{subtopic-name}"
1066 1066
1067 1067 bundle2 Bundle2
1068 1068 bundles Bundles
1069 1069 cbor CBOR
1070 1070 censor Censor
1071 1071 changegroups Changegroups
1072 1072 config Config Registrar
1073 1073 extensions Extension API
1074 1074 requirements Repository Requirements
1075 1075 revlogs Revision Logs
1076 1076 wireprotocol Wire Protocol
1077 1077 wireprotocolrpc
1078 1078 Wire Protocol RPC
1079 1079 wireprotocolv2
1080 1080 Wire Protocol Version 2
1081 1081
1082 1082 sub-topics can be accessed
1083 1083
1084 1084 $ hg help internals.changegroups
1085 1085 Changegroups
1086 1086 """"""""""""
1087 1087
1088 1088 Changegroups are representations of repository revlog data, specifically
1089 1089 the changelog data, root/flat manifest data, treemanifest data, and
1090 1090 filelogs.
1091 1091
1092 1092 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1093 1093 level, versions "1" and "2" are almost exactly the same, with the only
1094 1094 difference being an additional item in the *delta header*. Version "3"
1095 1095 adds support for storage flags in the *delta header* and optionally
1096 1096 exchanging treemanifests (enabled by setting an option on the
1097 1097 "changegroup" part in the bundle2).
1098 1098
1099 1099 Changegroups when not exchanging treemanifests consist of 3 logical
1100 1100 segments:
1101 1101
1102 1102 +---------------------------------+
1103 1103 | | | |
1104 1104 | changeset | manifest | filelogs |
1105 1105 | | | |
1106 1106 | | | |
1107 1107 +---------------------------------+
1108 1108
1109 1109 When exchanging treemanifests, there are 4 logical segments:
1110 1110
1111 1111 +-------------------------------------------------+
1112 1112 | | | | |
1113 1113 | changeset | root | treemanifests | filelogs |
1114 1114 | | manifest | | |
1115 1115 | | | | |
1116 1116 +-------------------------------------------------+
1117 1117
1118 1118 The principle building block of each segment is a *chunk*. A *chunk* is a
1119 1119 framed piece of data:
1120 1120
1121 1121 +---------------------------------------+
1122 1122 | | |
1123 1123 | length | data |
1124 1124 | (4 bytes) | (<length - 4> bytes) |
1125 1125 | | |
1126 1126 +---------------------------------------+
1127 1127
1128 1128 All integers are big-endian signed integers. Each chunk starts with a
1129 1129 32-bit integer indicating the length of the entire chunk (including the
1130 1130 length field itself).
1131 1131
1132 1132 There is a special case chunk that has a value of 0 for the length
1133 1133 ("0x00000000"). We call this an *empty chunk*.
1134 1134
1135 1135 Delta Groups
1136 1136 ============
1137 1137
1138 1138 A *delta group* expresses the content of a revlog as a series of deltas,
1139 1139 or patches against previous revisions.
1140 1140
1141 1141 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1142 1142 to signal the end of the delta group:
1143 1143
1144 1144 +------------------------------------------------------------------------+
1145 1145 | | | | | |
1146 1146 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1147 1147 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1148 1148 | | | | | |
1149 1149 +------------------------------------------------------------------------+
1150 1150
1151 1151 Each *chunk*'s data consists of the following:
1152 1152
1153 1153 +---------------------------------------+
1154 1154 | | |
1155 1155 | delta header | delta data |
1156 1156 | (various by version) | (various) |
1157 1157 | | |
1158 1158 +---------------------------------------+
1159 1159
1160 1160 The *delta data* is a series of *delta*s that describe a diff from an
1161 1161 existing entry (either that the recipient already has, or previously
1162 1162 specified in the bundle/changegroup).
1163 1163
1164 1164 The *delta header* is different between versions "1", "2", and "3" of the
1165 1165 changegroup format.
1166 1166
1167 1167 Version 1 (headerlen=80):
1168 1168
1169 1169 +------------------------------------------------------+
1170 1170 | | | | |
1171 1171 | node | p1 node | p2 node | link node |
1172 1172 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1173 1173 | | | | |
1174 1174 +------------------------------------------------------+
1175 1175
1176 1176 Version 2 (headerlen=100):
1177 1177
1178 1178 +------------------------------------------------------------------+
1179 1179 | | | | | |
1180 1180 | node | p1 node | p2 node | base node | link node |
1181 1181 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1182 1182 | | | | | |
1183 1183 +------------------------------------------------------------------+
1184 1184
1185 1185 Version 3 (headerlen=102):
1186 1186
1187 1187 +------------------------------------------------------------------------------+
1188 1188 | | | | | | |
1189 1189 | node | p1 node | p2 node | base node | link node | flags |
1190 1190 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1191 1191 | | | | | | |
1192 1192 +------------------------------------------------------------------------------+
1193 1193
1194 1194 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1195 1195 contain a series of *delta*s, densely packed (no separators). These deltas
1196 1196 describe a diff from an existing entry (either that the recipient already
1197 1197 has, or previously specified in the bundle/changegroup). The format is
1198 1198 described more fully in "hg help internals.bdiff", but briefly:
1199 1199
1200 1200 +---------------------------------------------------------------+
1201 1201 | | | | |
1202 1202 | start offset | end offset | new length | content |
1203 1203 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1204 1204 | | | | |
1205 1205 +---------------------------------------------------------------+
1206 1206
1207 1207 Please note that the length field in the delta data does *not* include
1208 1208 itself.
1209 1209
1210 1210 In version 1, the delta is always applied against the previous node from
1211 1211 the changegroup or the first parent if this is the first entry in the
1212 1212 changegroup.
1213 1213
1214 1214 In version 2 and up, the delta base node is encoded in the entry in the
1215 1215 changegroup. This allows the delta to be expressed against any parent,
1216 1216 which can result in smaller deltas and more efficient encoding of data.
1217 1217
1218 1218 The *flags* field holds bitwise flags affecting the processing of revision
1219 1219 data. The following flags are defined:
1220 1220
1221 1221 32768
1222 1222 Censored revision. The revision's fulltext has been replaced by censor
1223 1223 metadata. May only occur on file revisions.
1224 1224
1225 1225 16384
1226 1226 Ellipsis revision. Revision hash does not match data (likely due to
1227 1227 rewritten parents).
1228 1228
1229 1229 8192
1230 1230 Externally stored. The revision fulltext contains "key:value" "\n"
1231 1231 delimited metadata defining an object stored elsewhere. Used by the LFS
1232 1232 extension.
1233 1233
1234 1234 For historical reasons, the integer values are identical to revlog version
1235 1235 1 per-revision storage flags and correspond to bits being set in this
1236 1236 2-byte field. Bits were allocated starting from the most-significant bit,
1237 1237 hence the reverse ordering and allocation of these flags.
1238 1238
1239 1239 Changeset Segment
1240 1240 =================
1241 1241
1242 1242 The *changeset segment* consists of a single *delta group* holding
1243 1243 changelog data. The *empty chunk* at the end of the *delta group* denotes
1244 1244 the boundary to the *manifest segment*.
1245 1245
1246 1246 Manifest Segment
1247 1247 ================
1248 1248
1249 1249 The *manifest segment* consists of a single *delta group* holding manifest
1250 1250 data. If treemanifests are in use, it contains only the manifest for the
1251 1251 root directory of the repository. Otherwise, it contains the entire
1252 1252 manifest data. The *empty chunk* at the end of the *delta group* denotes
1253 1253 the boundary to the next segment (either the *treemanifests segment* or
1254 1254 the *filelogs segment*, depending on version and the request options).
1255 1255
1256 1256 Treemanifests Segment
1257 1257 ---------------------
1258 1258
1259 1259 The *treemanifests segment* only exists in changegroup version "3", and
1260 1260 only if the 'treemanifest' param is part of the bundle2 changegroup part
1261 1261 (it is not possible to use changegroup version 3 outside of bundle2).
1262 1262 Aside from the filenames in the *treemanifests segment* containing a
1263 1263 trailing "/" character, it behaves identically to the *filelogs segment*
1264 1264 (see below). The final sub-segment is followed by an *empty chunk*
1265 1265 (logically, a sub-segment with filename size 0). This denotes the boundary
1266 1266 to the *filelogs segment*.
1267 1267
1268 1268 Filelogs Segment
1269 1269 ================
1270 1270
1271 1271 The *filelogs segment* consists of multiple sub-segments, each
1272 1272 corresponding to an individual file whose data is being described:
1273 1273
1274 1274 +--------------------------------------------------+
1275 1275 | | | | | |
1276 1276 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1277 1277 | | | | | (4 bytes) |
1278 1278 | | | | | |
1279 1279 +--------------------------------------------------+
1280 1280
1281 1281 The final filelog sub-segment is followed by an *empty chunk* (logically,
1282 1282 a sub-segment with filename size 0). This denotes the end of the segment
1283 1283 and of the overall changegroup.
1284 1284
1285 1285 Each filelog sub-segment consists of the following:
1286 1286
1287 1287 +------------------------------------------------------+
1288 1288 | | | |
1289 1289 | filename length | filename | delta group |
1290 1290 | (4 bytes) | (<length - 4> bytes) | (various) |
1291 1291 | | | |
1292 1292 +------------------------------------------------------+
1293 1293
1294 1294 That is, a *chunk* consisting of the filename (not terminated or padded)
1295 1295 followed by N chunks constituting the *delta group* for this file. The
1296 1296 *empty chunk* at the end of each *delta group* denotes the boundary to the
1297 1297 next filelog sub-segment.
1298 1298
1299 1299 test advanced, deprecated and experimental options are hidden in command help
1300 1300 $ hg help debugoptADV
1301 1301 hg debugoptADV
1302 1302
1303 1303 (no help text available)
1304 1304
1305 1305 options:
1306 1306
1307 1307 (some details hidden, use --verbose to show complete help)
1308 1308 $ hg help debugoptDEP
1309 1309 hg debugoptDEP
1310 1310
1311 1311 (no help text available)
1312 1312
1313 1313 options:
1314 1314
1315 1315 (some details hidden, use --verbose to show complete help)
1316 1316
1317 1317 $ hg help debugoptEXP
1318 1318 hg debugoptEXP
1319 1319
1320 1320 (no help text available)
1321 1321
1322 1322 options:
1323 1323
1324 1324 (some details hidden, use --verbose to show complete help)
1325 1325
1326 1326 test advanced, deprecated and experimental options are shown with -v
1327 1327 $ hg help -v debugoptADV | grep aopt
1328 1328 --aopt option is (ADVANCED)
1329 1329 $ hg help -v debugoptDEP | grep dopt
1330 1330 --dopt option is (DEPRECATED)
1331 1331 $ hg help -v debugoptEXP | grep eopt
1332 1332 --eopt option is (EXPERIMENTAL)
1333 1333
1334 1334 #if gettext
1335 1335 test deprecated option is hidden with translation with untranslated description
1336 1336 (use many globy for not failing on changed transaction)
1337 1337 $ LANGUAGE=sv hg help debugoptDEP
1338 1338 hg debugoptDEP
1339 1339
1340 1340 (*) (glob)
1341 1341
1342 1342 options:
1343 1343
1344 1344 (some details hidden, use --verbose to show complete help)
1345 1345 #endif
1346 1346
1347 1347 Test commands that collide with topics (issue4240)
1348 1348
1349 1349 $ hg config -hq
1350 1350 hg config [-u] [NAME]...
1351 1351
1352 1352 show combined config settings from all hgrc files
1353 1353 $ hg showconfig -hq
1354 1354 hg config [-u] [NAME]...
1355 1355
1356 1356 show combined config settings from all hgrc files
1357 1357
1358 1358 Test a help topic
1359 1359
1360 1360 $ hg help dates
1361 1361 Date Formats
1362 1362 """"""""""""
1363 1363
1364 1364 Some commands allow the user to specify a date, e.g.:
1365 1365
1366 1366 - backout, commit, import, tag: Specify the commit date.
1367 1367 - log, revert, update: Select revision(s) by date.
1368 1368
1369 1369 Many date formats are valid. Here are some examples:
1370 1370
1371 1371 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1372 1372 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1373 1373 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1374 1374 - "Dec 6" (midnight)
1375 1375 - "13:18" (today assumed)
1376 1376 - "3:39" (3:39AM assumed)
1377 1377 - "3:39pm" (15:39)
1378 1378 - "2006-12-06 13:18:29" (ISO 8601 format)
1379 1379 - "2006-12-6 13:18"
1380 1380 - "2006-12-6"
1381 1381 - "12-6"
1382 1382 - "12/6"
1383 1383 - "12/6/6" (Dec 6 2006)
1384 1384 - "today" (midnight)
1385 1385 - "yesterday" (midnight)
1386 1386 - "now" - right now
1387 1387
1388 1388 Lastly, there is Mercurial's internal format:
1389 1389
1390 1390 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1391 1391
1392 1392 This is the internal representation format for dates. The first number is
1393 1393 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1394 1394 is the offset of the local timezone, in seconds west of UTC (negative if
1395 1395 the timezone is east of UTC).
1396 1396
1397 1397 The log command also accepts date ranges:
1398 1398
1399 1399 - "<DATE" - at or before a given date/time
1400 1400 - ">DATE" - on or after a given date/time
1401 1401 - "DATE to DATE" - a date range, inclusive
1402 1402 - "-DAYS" - within a given number of days of today
1403 1403
1404 1404 Test repeated config section name
1405 1405
1406 1406 $ hg help config.host
1407 1407 "http_proxy.host"
1408 1408 Host name and (optional) port of the proxy server, for example
1409 1409 "myproxy:8000".
1410 1410
1411 1411 "smtp.host"
1412 1412 Host name of mail server, e.g. "mail.example.com".
1413 1413
1414 1414
1415 1415 Test section name with dot
1416 1416
1417 1417 $ hg help config.ui.username
1418 1418 "ui.username"
1419 1419 The committer of a changeset created when running "commit". Typically
1420 1420 a person's name and email address, e.g. "Fred Widget
1421 1421 <fred@example.com>". Environment variables in the username are
1422 1422 expanded.
1423 1423
1424 1424 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1425 1425 empty, e.g. if the system admin set "username =" in the system hgrc,
1426 1426 it has to be specified manually or in a different hgrc file)
1427 1427
1428 1428
1429 1429 $ hg help config.annotate.git
1430 1430 abort: help section not found: config.annotate.git
1431 1431 [255]
1432 1432
1433 1433 $ hg help config.update.check
1434 1434 "commands.update.check"
1435 1435 Determines what level of checking 'hg update' will perform before
1436 1436 moving to a destination revision. Valid values are "abort", "none",
1437 1437 "linear", and "noconflict". "abort" always fails if the working
1438 1438 directory has uncommitted changes. "none" performs no checking, and
1439 1439 may result in a merge with uncommitted changes. "linear" allows any
1440 1440 update as long as it follows a straight line in the revision history,
1441 1441 and may trigger a merge with uncommitted changes. "noconflict" will
1442 1442 allow any update which would not trigger a merge with uncommitted
1443 1443 changes, if any are present. (default: "linear")
1444 1444
1445 1445
1446 1446 $ hg help config.commands.update.check
1447 1447 "commands.update.check"
1448 1448 Determines what level of checking 'hg update' will perform before
1449 1449 moving to a destination revision. Valid values are "abort", "none",
1450 1450 "linear", and "noconflict". "abort" always fails if the working
1451 1451 directory has uncommitted changes. "none" performs no checking, and
1452 1452 may result in a merge with uncommitted changes. "linear" allows any
1453 1453 update as long as it follows a straight line in the revision history,
1454 1454 and may trigger a merge with uncommitted changes. "noconflict" will
1455 1455 allow any update which would not trigger a merge with uncommitted
1456 1456 changes, if any are present. (default: "linear")
1457 1457
1458 1458
1459 1459 $ hg help config.ommands.update.check
1460 1460 abort: help section not found: config.ommands.update.check
1461 1461 [255]
1462 1462
1463 1463 Unrelated trailing paragraphs shouldn't be included
1464 1464
1465 1465 $ hg help config.extramsg | grep '^$'
1466 1466
1467 1467
1468 1468 Test capitalized section name
1469 1469
1470 1470 $ hg help scripting.HGPLAIN > /dev/null
1471 1471
1472 1472 Help subsection:
1473 1473
1474 1474 $ hg help config.charsets |grep "Email example:" > /dev/null
1475 1475 [1]
1476 1476
1477 1477 Show nested definitions
1478 1478 ("profiling.type"[break]"ls"[break]"stat"[break])
1479 1479
1480 1480 $ hg help config.type | egrep '^$'|wc -l
1481 1481 \s*3 (re)
1482 1482
1483 1483 $ hg help config.profiling.type.ls
1484 1484 "profiling.type.ls"
1485 1485 Use Python's built-in instrumenting profiler. This profiler works on
1486 1486 all platforms, but each line number it reports is the first line of
1487 1487 a function. This restriction makes it difficult to identify the
1488 1488 expensive parts of a non-trivial function.
1489 1489
1490 1490
1491 1491 Separate sections from subsections
1492 1492
1493 1493 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1494 1494 "format"
1495 1495 --------
1496 1496
1497 1497 "usegeneraldelta"
1498 1498
1499 1499 "dotencode"
1500 1500
1501 1501 "usefncache"
1502 1502
1503 1503 "usestore"
1504 1504
1505 1505 "profiling"
1506 1506 -----------
1507 1507
1508 1508 "format"
1509 1509
1510 1510 "progress"
1511 1511 ----------
1512 1512
1513 1513 "format"
1514 1514
1515 1515
1516 1516 Last item in help config.*:
1517 1517
1518 1518 $ hg help config.`hg help config|grep '^ "'| \
1519 1519 > tail -1|sed 's![ "]*!!g'`| \
1520 1520 > grep 'hg help -c config' > /dev/null
1521 1521 [1]
1522 1522
1523 1523 note to use help -c for general hg help config:
1524 1524
1525 1525 $ hg help config |grep 'hg help -c config' > /dev/null
1526 1526
1527 1527 Test templating help
1528 1528
1529 1529 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1530 1530 desc String. The text of the changeset description.
1531 1531 diffstat String. Statistics of changes with the following format:
1532 1532 firstline Any text. Returns the first line of text.
1533 1533 nonempty Any text. Returns '(none)' if the string is empty.
1534 1534
1535 1535 Test deprecated items
1536 1536
1537 1537 $ hg help -v templating | grep currentbookmark
1538 1538 currentbookmark
1539 1539 $ hg help templating | (grep currentbookmark || true)
1540 1540
1541 1541 Test help hooks
1542 1542
1543 1543 $ cat > helphook1.py <<EOF
1544 1544 > from mercurial import help
1545 1545 >
1546 1546 > def rewrite(ui, topic, doc):
1547 1547 > return doc + b'\nhelphook1\n'
1548 1548 >
1549 1549 > def extsetup(ui):
1550 1550 > help.addtopichook(b'revisions', rewrite)
1551 1551 > EOF
1552 1552 $ cat > helphook2.py <<EOF
1553 1553 > from mercurial import help
1554 1554 >
1555 1555 > def rewrite(ui, topic, doc):
1556 1556 > return doc + b'\nhelphook2\n'
1557 1557 >
1558 1558 > def extsetup(ui):
1559 1559 > help.addtopichook(b'revisions', rewrite)
1560 1560 > EOF
1561 1561 $ echo '[extensions]' >> $HGRCPATH
1562 1562 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1563 1563 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1564 1564 $ hg help revsets | grep helphook
1565 1565 helphook1
1566 1566 helphook2
1567 1567
1568 1568 help -c should only show debug --debug
1569 1569
1570 1570 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1571 1571 [1]
1572 1572
1573 1573 help -c should only show deprecated for -v
1574 1574
1575 1575 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1576 1576 [1]
1577 1577
1578 1578 Test -s / --system
1579 1579
1580 1580 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1581 1581 > wc -l | sed -e 's/ //g'
1582 1582 0
1583 1583 $ hg help config.files --system unix | grep 'USER' | \
1584 1584 > wc -l | sed -e 's/ //g'
1585 1585 0
1586 1586
1587 1587 Test -e / -c / -k combinations
1588 1588
1589 1589 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1590 1590 Commands:
1591 1591 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1592 1592 Extensions:
1593 1593 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1594 1594 Topics:
1595 1595 Commands:
1596 1596 Extensions:
1597 1597 Extension Commands:
1598 1598 $ hg help -c schemes
1599 1599 abort: no such help topic: schemes
1600 1600 (try 'hg help --keyword schemes')
1601 1601 [255]
1602 1602 $ hg help -e schemes |head -1
1603 1603 schemes extension - extend schemes with shortcuts to repository swarms
1604 1604 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1605 1605 Commands:
1606 1606 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1607 1607 Extensions:
1608 1608 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1609 1609 Extensions:
1610 1610 Commands:
1611 1611 $ hg help -c commit > /dev/null
1612 1612 $ hg help -e -c commit > /dev/null
1613 1613 $ hg help -e commit
1614 1614 abort: no such help topic: commit
1615 1615 (try 'hg help --keyword commit')
1616 1616 [255]
1617 1617
1618 1618 Test keyword search help
1619 1619
1620 1620 $ cat > prefixedname.py <<EOF
1621 1621 > '''matched against word "clone"
1622 1622 > '''
1623 1623 > EOF
1624 1624 $ echo '[extensions]' >> $HGRCPATH
1625 1625 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1626 1626 $ hg help -k clone
1627 1627 Topics:
1628 1628
1629 1629 config Configuration Files
1630 1630 extensions Using Additional Features
1631 1631 glossary Glossary
1632 1632 phases Working with Phases
1633 1633 subrepos Subrepositories
1634 1634 urls URL Paths
1635 1635
1636 1636 Commands:
1637 1637
1638 1638 bookmarks create a new bookmark or list existing bookmarks
1639 1639 clone make a copy of an existing repository
1640 1640 paths show aliases for remote repositories
1641 1641 pull pull changes from the specified source
1642 1642 update update working directory (or switch revisions)
1643 1643
1644 1644 Extensions:
1645 1645
1646 1646 clonebundles advertise pre-generated bundles to seed clones
1647 1647 narrow create clones which fetch history data for subset of files
1648 1648 (EXPERIMENTAL)
1649 1649 prefixedname matched against word "clone"
1650 1650 relink recreates hardlinks between repository clones
1651 1651
1652 1652 Extension Commands:
1653 1653
1654 1654 qclone clone main and patch repository at same time
1655 1655
1656 1656 Test unfound topic
1657 1657
1658 1658 $ hg help nonexistingtopicthatwillneverexisteverever
1659 1659 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1660 1660 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1661 1661 [255]
1662 1662
1663 1663 Test unfound keyword
1664 1664
1665 1665 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1666 1666 abort: no matches
1667 1667 (try 'hg help' for a list of topics)
1668 1668 [255]
1669 1669
1670 1670 Test omit indicating for help
1671 1671
1672 1672 $ cat > addverboseitems.py <<EOF
1673 1673 > '''extension to test omit indicating.
1674 1674 >
1675 1675 > This paragraph is never omitted (for extension)
1676 1676 >
1677 1677 > .. container:: verbose
1678 1678 >
1679 1679 > This paragraph is omitted,
1680 1680 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1681 1681 >
1682 1682 > This paragraph is never omitted, too (for extension)
1683 1683 > '''
1684 1684 > from __future__ import absolute_import
1685 1685 > from mercurial import commands, help
1686 1686 > testtopic = b"""This paragraph is never omitted (for topic).
1687 1687 >
1688 1688 > .. container:: verbose
1689 1689 >
1690 1690 > This paragraph is omitted,
1691 1691 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1692 1692 >
1693 1693 > This paragraph is never omitted, too (for topic)
1694 1694 > """
1695 1695 > def extsetup(ui):
1696 1696 > help.helptable.append(([b"topic-containing-verbose"],
1697 1697 > b"This is the topic to test omit indicating.",
1698 1698 > lambda ui: testtopic))
1699 1699 > EOF
1700 1700 $ echo '[extensions]' >> $HGRCPATH
1701 1701 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1702 1702 $ hg help addverboseitems
1703 1703 addverboseitems extension - extension to test omit indicating.
1704 1704
1705 1705 This paragraph is never omitted (for extension)
1706 1706
1707 1707 This paragraph is never omitted, too (for extension)
1708 1708
1709 1709 (some details hidden, use --verbose to show complete help)
1710 1710
1711 1711 no commands defined
1712 1712 $ hg help -v addverboseitems
1713 1713 addverboseitems extension - extension to test omit indicating.
1714 1714
1715 1715 This paragraph is never omitted (for extension)
1716 1716
1717 1717 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1718 1718 extension)
1719 1719
1720 1720 This paragraph is never omitted, too (for extension)
1721 1721
1722 1722 no commands defined
1723 1723 $ hg help topic-containing-verbose
1724 1724 This is the topic to test omit indicating.
1725 1725 """"""""""""""""""""""""""""""""""""""""""
1726 1726
1727 1727 This paragraph is never omitted (for topic).
1728 1728
1729 1729 This paragraph is never omitted, too (for topic)
1730 1730
1731 1731 (some details hidden, use --verbose to show complete help)
1732 1732 $ hg help -v topic-containing-verbose
1733 1733 This is the topic to test omit indicating.
1734 1734 """"""""""""""""""""""""""""""""""""""""""
1735 1735
1736 1736 This paragraph is never omitted (for topic).
1737 1737
1738 1738 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1739 1739 topic)
1740 1740
1741 1741 This paragraph is never omitted, too (for topic)
1742 1742
1743 1743 Test section lookup
1744 1744
1745 1745 $ hg help revset.merge
1746 1746 "merge()"
1747 1747 Changeset is a merge changeset.
1748 1748
1749 1749 $ hg help glossary.dag
1750 1750 DAG
1751 1751 The repository of changesets of a distributed version control system
1752 1752 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1753 1753 of nodes and edges, where nodes correspond to changesets and edges
1754 1754 imply a parent -> child relation. This graph can be visualized by
1755 1755 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1756 1756 limited by the requirement for children to have at most two parents.
1757 1757
1758 1758
1759 1759 $ hg help hgrc.paths
1760 1760 "paths"
1761 1761 -------
1762 1762
1763 1763 Assigns symbolic names and behavior to repositories.
1764 1764
1765 1765 Options are symbolic names defining the URL or directory that is the
1766 1766 location of the repository. Example:
1767 1767
1768 1768 [paths]
1769 1769 my_server = https://example.com/my_repo
1770 1770 local_path = /home/me/repo
1771 1771
1772 1772 These symbolic names can be used from the command line. To pull from
1773 1773 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1774 1774 local_path'.
1775 1775
1776 1776 Options containing colons (":") denote sub-options that can influence
1777 1777 behavior for that specific path. Example:
1778 1778
1779 1779 [paths]
1780 1780 my_server = https://example.com/my_path
1781 1781 my_server:pushurl = ssh://example.com/my_path
1782 1782
1783 1783 The following sub-options can be defined:
1784 1784
1785 1785 "pushurl"
1786 1786 The URL to use for push operations. If not defined, the location
1787 1787 defined by the path's main entry is used.
1788 1788
1789 1789 "pushrev"
1790 1790 A revset defining which revisions to push by default.
1791 1791
1792 1792 When 'hg push' is executed without a "-r" argument, the revset defined
1793 1793 by this sub-option is evaluated to determine what to push.
1794 1794
1795 1795 For example, a value of "." will push the working directory's revision
1796 1796 by default.
1797 1797
1798 1798 Revsets specifying bookmarks will not result in the bookmark being
1799 1799 pushed.
1800 1800
1801 1801 The following special named paths exist:
1802 1802
1803 1803 "default"
1804 1804 The URL or directory to use when no source or remote is specified.
1805 1805
1806 1806 'hg clone' will automatically define this path to the location the
1807 1807 repository was cloned from.
1808 1808
1809 1809 "default-push"
1810 1810 (deprecated) The URL or directory for the default 'hg push' location.
1811 1811 "default:pushurl" should be used instead.
1812 1812
1813 1813 $ hg help glossary.mcguffin
1814 1814 abort: help section not found: glossary.mcguffin
1815 1815 [255]
1816 1816
1817 1817 $ hg help glossary.mc.guffin
1818 1818 abort: help section not found: glossary.mc.guffin
1819 1819 [255]
1820 1820
1821 1821 $ hg help template.files
1822 1822 files List of strings. All files modified, added, or removed by
1823 1823 this changeset.
1824 1824 files(pattern)
1825 1825 All files of the current changeset matching the pattern. See
1826 1826 'hg help patterns'.
1827 1827
1828 1828 Test section lookup by translated message
1829 1829
1830 1830 str.lower() instead of encoding.lower(str) on translated message might
1831 1831 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1832 1832 as the second or later byte of multi-byte character.
1833 1833
1834 1834 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1835 1835 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1836 1836 replacement makes message meaningless.
1837 1837
1838 1838 This tests that section lookup by translated string isn't broken by
1839 1839 such str.lower().
1840 1840
1841 1841 $ "$PYTHON" <<EOF
1842 1842 > def escape(s):
1843 1843 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1844 1844 > # translation of "record" in ja_JP.cp932
1845 1845 > upper = b"\x8bL\x98^"
1846 1846 > # str.lower()-ed section name should be treated as different one
1847 1847 > lower = b"\x8bl\x98^"
1848 1848 > with open('ambiguous.py', 'wb') as fp:
1849 1849 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1850 1850 > u'''summary of extension
1851 1851 >
1852 1852 > %s
1853 1853 > ----
1854 1854 >
1855 1855 > Upper name should show only this message
1856 1856 >
1857 1857 > %s
1858 1858 > ----
1859 1859 >
1860 1860 > Lower name should show only this message
1861 1861 >
1862 1862 > subsequent section
1863 1863 > ------------------
1864 1864 >
1865 1865 > This should be hidden at 'hg help ambiguous' with section name.
1866 1866 > '''
1867 1867 > """ % (escape(upper), escape(lower)))
1868 1868 > EOF
1869 1869
1870 1870 $ cat >> $HGRCPATH <<EOF
1871 1871 > [extensions]
1872 1872 > ambiguous = ./ambiguous.py
1873 1873 > EOF
1874 1874
1875 1875 $ "$PYTHON" <<EOF | sh
1876 1876 > from mercurial import pycompat
1877 1877 > upper = b"\x8bL\x98^"
1878 1878 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1879 1879 > EOF
1880 1880 \x8bL\x98^ (esc)
1881 1881 ----
1882 1882
1883 1883 Upper name should show only this message
1884 1884
1885 1885
1886 1886 $ "$PYTHON" <<EOF | sh
1887 1887 > from mercurial import pycompat
1888 1888 > lower = b"\x8bl\x98^"
1889 1889 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1890 1890 > EOF
1891 1891 \x8bl\x98^ (esc)
1892 1892 ----
1893 1893
1894 1894 Lower name should show only this message
1895 1895
1896 1896
1897 1897 $ cat >> $HGRCPATH <<EOF
1898 1898 > [extensions]
1899 1899 > ambiguous = !
1900 1900 > EOF
1901 1901
1902 1902 Show help content of disabled extensions
1903 1903
1904 1904 $ cat >> $HGRCPATH <<EOF
1905 1905 > [extensions]
1906 1906 > ambiguous = !./ambiguous.py
1907 1907 > EOF
1908 1908 $ hg help -e ambiguous
1909 1909 ambiguous extension - (no help text available)
1910 1910
1911 1911 (use 'hg help extensions' for information on enabling extensions)
1912 1912
1913 1913 Test dynamic list of merge tools only shows up once
1914 1914 $ hg help merge-tools
1915 1915 Merge Tools
1916 1916 """""""""""
1917 1917
1918 1918 To merge files Mercurial uses merge tools.
1919 1919
1920 1920 A merge tool combines two different versions of a file into a merged file.
1921 1921 Merge tools are given the two files and the greatest common ancestor of
1922 1922 the two file versions, so they can determine the changes made on both
1923 1923 branches.
1924 1924
1925 1925 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1926 1926 backout' and in several extensions.
1927 1927
1928 1928 Usually, the merge tool tries to automatically reconcile the files by
1929 1929 combining all non-overlapping changes that occurred separately in the two
1930 1930 different evolutions of the same initial base file. Furthermore, some
1931 1931 interactive merge programs make it easier to manually resolve conflicting
1932 1932 merges, either in a graphical way, or by inserting some conflict markers.
1933 1933 Mercurial does not include any interactive merge programs but relies on
1934 1934 external tools for that.
1935 1935
1936 1936 Available merge tools
1937 1937 =====================
1938 1938
1939 1939 External merge tools and their properties are configured in the merge-
1940 1940 tools configuration section - see hgrc(5) - but they can often just be
1941 1941 named by their executable.
1942 1942
1943 1943 A merge tool is generally usable if its executable can be found on the
1944 1944 system and if it can handle the merge. The executable is found if it is an
1945 1945 absolute or relative executable path or the name of an application in the
1946 1946 executable search path. The tool is assumed to be able to handle the merge
1947 1947 if it can handle symlinks if the file is a symlink, if it can handle
1948 1948 binary files if the file is binary, and if a GUI is available if the tool
1949 1949 requires a GUI.
1950 1950
1951 1951 There are some internal merge tools which can be used. The internal merge
1952 1952 tools are:
1953 1953
1954 1954 ":dump"
1955 1955 Creates three versions of the files to merge, containing the contents of
1956 1956 local, other and base. These files can then be used to perform a merge
1957 1957 manually. If the file to be merged is named "a.txt", these files will
1958 1958 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1959 1959 they will be placed in the same directory as "a.txt".
1960 1960
1961 1961 This implies premerge. Therefore, files aren't dumped, if premerge runs
1962 1962 successfully. Use :forcedump to forcibly write files out.
1963 1963
1964 1964 (actual capabilities: binary, symlink)
1965 1965
1966 1966 ":fail"
1967 1967 Rather than attempting to merge files that were modified on both
1968 1968 branches, it marks them as unresolved. The resolve command must be used
1969 1969 to resolve these conflicts.
1970 1970
1971 1971 (actual capabilities: binary, symlink)
1972 1972
1973 1973 ":forcedump"
1974 1974 Creates three versions of the files as same as :dump, but omits
1975 1975 premerge.
1976 1976
1977 1977 (actual capabilities: binary, symlink)
1978 1978
1979 1979 ":local"
1980 1980 Uses the local 'p1()' version of files as the merged version.
1981 1981
1982 1982 (actual capabilities: binary, symlink)
1983 1983
1984 1984 ":merge"
1985 1985 Uses the internal non-interactive simple merge algorithm for merging
1986 1986 files. It will fail if there are any conflicts and leave markers in the
1987 1987 partially merged file. Markers will have two sections, one for each side
1988 1988 of merge.
1989 1989
1990 1990 ":merge-local"
1991 1991 Like :merge, but resolve all conflicts non-interactively in favor of the
1992 1992 local 'p1()' changes.
1993 1993
1994 1994 ":merge-other"
1995 1995 Like :merge, but resolve all conflicts non-interactively in favor of the
1996 1996 other 'p2()' changes.
1997 1997
1998 1998 ":merge3"
1999 1999 Uses the internal non-interactive simple merge algorithm for merging
2000 2000 files. It will fail if there are any conflicts and leave markers in the
2001 2001 partially merged file. Marker will have three sections, one from each
2002 2002 side of the merge and one for the base content.
2003 2003
2004 2004 ":other"
2005 2005 Uses the other 'p2()' version of files as the merged version.
2006 2006
2007 2007 (actual capabilities: binary, symlink)
2008 2008
2009 2009 ":prompt"
2010 2010 Asks the user which of the local 'p1()' or the other 'p2()' version to
2011 2011 keep as the merged version.
2012 2012
2013 2013 (actual capabilities: binary, symlink)
2014 2014
2015 2015 ":tagmerge"
2016 2016 Uses the internal tag merge algorithm (experimental).
2017 2017
2018 2018 ":union"
2019 2019 Uses the internal non-interactive simple merge algorithm for merging
2020 2020 files. It will use both left and right sides for conflict regions. No
2021 2021 markers are inserted.
2022 2022
2023 2023 Internal tools are always available and do not require a GUI but will by
2024 2024 default not handle symlinks or binary files. See next section for detail
2025 2025 about "actual capabilities" described above.
2026 2026
2027 2027 Choosing a merge tool
2028 2028 =====================
2029 2029
2030 2030 Mercurial uses these rules when deciding which merge tool to use:
2031 2031
2032 2032 1. If a tool has been specified with the --tool option to merge or
2033 2033 resolve, it is used. If it is the name of a tool in the merge-tools
2034 2034 configuration, its configuration is used. Otherwise the specified tool
2035 2035 must be executable by the shell.
2036 2036 2. If the "HGMERGE" environment variable is present, its value is used and
2037 2037 must be executable by the shell.
2038 2038 3. If the filename of the file to be merged matches any of the patterns in
2039 2039 the merge-patterns configuration section, the first usable merge tool
2040 2040 corresponding to a matching pattern is used.
2041 2041 4. If ui.merge is set it will be considered next. If the value is not the
2042 2042 name of a configured tool, the specified value is used and must be
2043 2043 executable by the shell. Otherwise the named tool is used if it is
2044 2044 usable.
2045 2045 5. If any usable merge tools are present in the merge-tools configuration
2046 2046 section, the one with the highest priority is used.
2047 2047 6. If a program named "hgmerge" can be found on the system, it is used -
2048 2048 but it will by default not be used for symlinks and binary files.
2049 2049 7. If the file to be merged is not binary and is not a symlink, then
2050 2050 internal ":merge" is used.
2051 2051 8. Otherwise, ":prompt" is used.
2052 2052
2053 2053 For historical reason, Mercurial treats merge tools as below while
2054 2054 examining rules above.
2055 2055
2056 2056 step specified via binary symlink
2057 2057 ----------------------------------
2058 2058 1. --tool o/o o/o
2059 2059 2. HGMERGE o/o o/o
2060 2060 3. merge-patterns o/o(*) x/?(*)
2061 2061 4. ui.merge x/?(*) x/?(*)
2062 2062
2063 2063 Each capability column indicates Mercurial behavior for internal/external
2064 2064 merge tools at examining each rule.
2065 2065
2066 2066 - "o": "assume that a tool has capability"
2067 2067 - "x": "assume that a tool does not have capability"
2068 2068 - "?": "check actual capability of a tool"
2069 2069
2070 2070 If "merge.strict-capability-check" configuration is true, Mercurial checks
2071 2071 capabilities of merge tools strictly in (*) cases above (= each capability
2072 2072 column becomes "?/?"). It is false by default for backward compatibility.
2073 2073
2074 2074 Note:
2075 2075 After selecting a merge program, Mercurial will by default attempt to
2076 2076 merge the files using a simple merge algorithm first. Only if it
2077 2077 doesn't succeed because of conflicting changes will Mercurial actually
2078 2078 execute the merge program. Whether to use the simple merge algorithm
2079 2079 first can be controlled by the premerge setting of the merge tool.
2080 2080 Premerge is enabled by default unless the file is binary or a symlink.
2081 2081
2082 2082 See the merge-tools and ui sections of hgrc(5) for details on the
2083 2083 configuration of merge tools.
2084 2084
2085 2085 Compression engines listed in `hg help bundlespec`
2086 2086
2087 2087 $ hg help bundlespec | grep gzip
2088 2088 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2089 2089 An algorithm that produces smaller bundles than "gzip".
2090 2090 This engine will likely produce smaller bundles than "gzip" but will be
2091 2091 "gzip"
2092 2092 better compression than "gzip". It also frequently yields better (?)
2093 2093
2094 2094 Test usage of section marks in help documents
2095 2095
2096 2096 $ cd "$TESTDIR"/../doc
2097 2097 $ "$PYTHON" check-seclevel.py
2098 2098 $ cd $TESTTMP
2099 2099
2100 2100 #if serve
2101 2101
2102 2102 Test the help pages in hgweb.
2103 2103
2104 2104 Dish up an empty repo; serve it cold.
2105 2105
2106 2106 $ hg init "$TESTTMP/test"
2107 2107 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2108 2108 $ cat hg.pid >> $DAEMON_PIDS
2109 2109
2110 2110 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2111 2111 200 Script output follows
2112 2112
2113 2113 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2114 2114 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2115 2115 <head>
2116 2116 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2117 2117 <meta name="robots" content="index, nofollow" />
2118 2118 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2119 2119 <script type="text/javascript" src="/static/mercurial.js"></script>
2120 2120
2121 2121 <title>Help: Index</title>
2122 2122 </head>
2123 2123 <body>
2124 2124
2125 2125 <div class="container">
2126 2126 <div class="menu">
2127 2127 <div class="logo">
2128 2128 <a href="https://mercurial-scm.org/">
2129 2129 <img src="/static/hglogo.png" alt="mercurial" /></a>
2130 2130 </div>
2131 2131 <ul>
2132 2132 <li><a href="/shortlog">log</a></li>
2133 2133 <li><a href="/graph">graph</a></li>
2134 2134 <li><a href="/tags">tags</a></li>
2135 2135 <li><a href="/bookmarks">bookmarks</a></li>
2136 2136 <li><a href="/branches">branches</a></li>
2137 2137 </ul>
2138 2138 <ul>
2139 2139 <li class="active">help</li>
2140 2140 </ul>
2141 2141 </div>
2142 2142
2143 2143 <div class="main">
2144 2144 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2145 2145
2146 2146 <form class="search" action="/log">
2147 2147
2148 2148 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2149 2149 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2150 2150 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2151 2151 </form>
2152 2152 <table class="bigtable">
2153 2153 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2154 2154
2155 2155 <tr><td>
2156 2156 <a href="/help/bundlespec">
2157 2157 bundlespec
2158 2158 </a>
2159 2159 </td><td>
2160 2160 Bundle File Formats
2161 2161 </td></tr>
2162 2162 <tr><td>
2163 2163 <a href="/help/color">
2164 2164 color
2165 2165 </a>
2166 2166 </td><td>
2167 2167 Colorizing Outputs
2168 2168 </td></tr>
2169 2169 <tr><td>
2170 2170 <a href="/help/config">
2171 2171 config
2172 2172 </a>
2173 2173 </td><td>
2174 2174 Configuration Files
2175 2175 </td></tr>
2176 2176 <tr><td>
2177 2177 <a href="/help/dates">
2178 2178 dates
2179 2179 </a>
2180 2180 </td><td>
2181 2181 Date Formats
2182 2182 </td></tr>
2183 2183 <tr><td>
2184 2184 <a href="/help/deprecated">
2185 2185 deprecated
2186 2186 </a>
2187 2187 </td><td>
2188 2188 Deprecated Features
2189 2189 </td></tr>
2190 2190 <tr><td>
2191 2191 <a href="/help/diffs">
2192 2192 diffs
2193 2193 </a>
2194 2194 </td><td>
2195 2195 Diff Formats
2196 2196 </td></tr>
2197 2197 <tr><td>
2198 2198 <a href="/help/environment">
2199 2199 environment
2200 2200 </a>
2201 2201 </td><td>
2202 2202 Environment Variables
2203 2203 </td></tr>
2204 2204 <tr><td>
2205 2205 <a href="/help/extensions">
2206 2206 extensions
2207 2207 </a>
2208 2208 </td><td>
2209 2209 Using Additional Features
2210 2210 </td></tr>
2211 2211 <tr><td>
2212 2212 <a href="/help/filesets">
2213 2213 filesets
2214 2214 </a>
2215 2215 </td><td>
2216 2216 Specifying File Sets
2217 2217 </td></tr>
2218 2218 <tr><td>
2219 2219 <a href="/help/flags">
2220 2220 flags
2221 2221 </a>
2222 2222 </td><td>
2223 2223 Command-line flags
2224 2224 </td></tr>
2225 2225 <tr><td>
2226 2226 <a href="/help/glossary">
2227 2227 glossary
2228 2228 </a>
2229 2229 </td><td>
2230 2230 Glossary
2231 2231 </td></tr>
2232 2232 <tr><td>
2233 2233 <a href="/help/hgignore">
2234 2234 hgignore
2235 2235 </a>
2236 2236 </td><td>
2237 2237 Syntax for Mercurial Ignore Files
2238 2238 </td></tr>
2239 2239 <tr><td>
2240 2240 <a href="/help/hgweb">
2241 2241 hgweb
2242 2242 </a>
2243 2243 </td><td>
2244 2244 Configuring hgweb
2245 2245 </td></tr>
2246 2246 <tr><td>
2247 2247 <a href="/help/internals">
2248 2248 internals
2249 2249 </a>
2250 2250 </td><td>
2251 2251 Technical implementation topics
2252 2252 </td></tr>
2253 2253 <tr><td>
2254 2254 <a href="/help/merge-tools">
2255 2255 merge-tools
2256 2256 </a>
2257 2257 </td><td>
2258 2258 Merge Tools
2259 2259 </td></tr>
2260 2260 <tr><td>
2261 2261 <a href="/help/pager">
2262 2262 pager
2263 2263 </a>
2264 2264 </td><td>
2265 2265 Pager Support
2266 2266 </td></tr>
2267 2267 <tr><td>
2268 2268 <a href="/help/patterns">
2269 2269 patterns
2270 2270 </a>
2271 2271 </td><td>
2272 2272 File Name Patterns
2273 2273 </td></tr>
2274 2274 <tr><td>
2275 2275 <a href="/help/phases">
2276 2276 phases
2277 2277 </a>
2278 2278 </td><td>
2279 2279 Working with Phases
2280 2280 </td></tr>
2281 2281 <tr><td>
2282 2282 <a href="/help/revisions">
2283 2283 revisions
2284 2284 </a>
2285 2285 </td><td>
2286 2286 Specifying Revisions
2287 2287 </td></tr>
2288 2288 <tr><td>
2289 2289 <a href="/help/scripting">
2290 2290 scripting
2291 2291 </a>
2292 2292 </td><td>
2293 2293 Using Mercurial from scripts and automation
2294 2294 </td></tr>
2295 2295 <tr><td>
2296 2296 <a href="/help/subrepos">
2297 2297 subrepos
2298 2298 </a>
2299 2299 </td><td>
2300 2300 Subrepositories
2301 2301 </td></tr>
2302 2302 <tr><td>
2303 2303 <a href="/help/templating">
2304 2304 templating
2305 2305 </a>
2306 2306 </td><td>
2307 2307 Template Usage
2308 2308 </td></tr>
2309 2309 <tr><td>
2310 2310 <a href="/help/urls">
2311 2311 urls
2312 2312 </a>
2313 2313 </td><td>
2314 2314 URL Paths
2315 2315 </td></tr>
2316 2316 <tr><td>
2317 2317 <a href="/help/topic-containing-verbose">
2318 2318 topic-containing-verbose
2319 2319 </a>
2320 2320 </td><td>
2321 2321 This is the topic to test omit indicating.
2322 2322 </td></tr>
2323 2323
2324 2324
2325 2325 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2326 2326
2327 2327 <tr><td>
2328 2328 <a href="/help/add">
2329 2329 add
2330 2330 </a>
2331 2331 </td><td>
2332 2332 add the specified files on the next commit
2333 2333 </td></tr>
2334 2334 <tr><td>
2335 2335 <a href="/help/annotate">
2336 2336 annotate
2337 2337 </a>
2338 2338 </td><td>
2339 2339 show changeset information by line for each file
2340 2340 </td></tr>
2341 2341 <tr><td>
2342 2342 <a href="/help/clone">
2343 2343 clone
2344 2344 </a>
2345 2345 </td><td>
2346 2346 make a copy of an existing repository
2347 2347 </td></tr>
2348 2348 <tr><td>
2349 2349 <a href="/help/commit">
2350 2350 commit
2351 2351 </a>
2352 2352 </td><td>
2353 2353 commit the specified files or all outstanding changes
2354 2354 </td></tr>
2355 2355 <tr><td>
2356 2356 <a href="/help/diff">
2357 2357 diff
2358 2358 </a>
2359 2359 </td><td>
2360 2360 diff repository (or selected files)
2361 2361 </td></tr>
2362 2362 <tr><td>
2363 2363 <a href="/help/export">
2364 2364 export
2365 2365 </a>
2366 2366 </td><td>
2367 2367 dump the header and diffs for one or more changesets
2368 2368 </td></tr>
2369 2369 <tr><td>
2370 2370 <a href="/help/forget">
2371 2371 forget
2372 2372 </a>
2373 2373 </td><td>
2374 2374 forget the specified files on the next commit
2375 2375 </td></tr>
2376 2376 <tr><td>
2377 2377 <a href="/help/init">
2378 2378 init
2379 2379 </a>
2380 2380 </td><td>
2381 2381 create a new repository in the given directory
2382 2382 </td></tr>
2383 2383 <tr><td>
2384 2384 <a href="/help/log">
2385 2385 log
2386 2386 </a>
2387 2387 </td><td>
2388 2388 show revision history of entire repository or files
2389 2389 </td></tr>
2390 2390 <tr><td>
2391 2391 <a href="/help/merge">
2392 2392 merge
2393 2393 </a>
2394 2394 </td><td>
2395 2395 merge another revision into working directory
2396 2396 </td></tr>
2397 2397 <tr><td>
2398 2398 <a href="/help/pull">
2399 2399 pull
2400 2400 </a>
2401 2401 </td><td>
2402 2402 pull changes from the specified source
2403 2403 </td></tr>
2404 2404 <tr><td>
2405 2405 <a href="/help/push">
2406 2406 push
2407 2407 </a>
2408 2408 </td><td>
2409 2409 push changes to the specified destination
2410 2410 </td></tr>
2411 2411 <tr><td>
2412 2412 <a href="/help/remove">
2413 2413 remove
2414 2414 </a>
2415 2415 </td><td>
2416 2416 remove the specified files on the next commit
2417 2417 </td></tr>
2418 2418 <tr><td>
2419 2419 <a href="/help/serve">
2420 2420 serve
2421 2421 </a>
2422 2422 </td><td>
2423 2423 start stand-alone webserver
2424 2424 </td></tr>
2425 2425 <tr><td>
2426 2426 <a href="/help/status">
2427 2427 status
2428 2428 </a>
2429 2429 </td><td>
2430 2430 show changed files in the working directory
2431 2431 </td></tr>
2432 2432 <tr><td>
2433 2433 <a href="/help/summary">
2434 2434 summary
2435 2435 </a>
2436 2436 </td><td>
2437 2437 summarize working directory state
2438 2438 </td></tr>
2439 2439 <tr><td>
2440 2440 <a href="/help/update">
2441 2441 update
2442 2442 </a>
2443 2443 </td><td>
2444 2444 update working directory (or switch revisions)
2445 2445 </td></tr>
2446 2446
2447 2447
2448 2448
2449 2449 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2450 2450
2451 2451 <tr><td>
2452 2452 <a href="/help/addremove">
2453 2453 addremove
2454 2454 </a>
2455 2455 </td><td>
2456 2456 add all new files, delete all missing files
2457 2457 </td></tr>
2458 2458 <tr><td>
2459 2459 <a href="/help/archive">
2460 2460 archive
2461 2461 </a>
2462 2462 </td><td>
2463 2463 create an unversioned archive of a repository revision
2464 2464 </td></tr>
2465 2465 <tr><td>
2466 2466 <a href="/help/backout">
2467 2467 backout
2468 2468 </a>
2469 2469 </td><td>
2470 2470 reverse effect of earlier changeset
2471 2471 </td></tr>
2472 2472 <tr><td>
2473 2473 <a href="/help/bisect">
2474 2474 bisect
2475 2475 </a>
2476 2476 </td><td>
2477 2477 subdivision search of changesets
2478 2478 </td></tr>
2479 2479 <tr><td>
2480 2480 <a href="/help/bookmarks">
2481 2481 bookmarks
2482 2482 </a>
2483 2483 </td><td>
2484 2484 create a new bookmark or list existing bookmarks
2485 2485 </td></tr>
2486 2486 <tr><td>
2487 2487 <a href="/help/branch">
2488 2488 branch
2489 2489 </a>
2490 2490 </td><td>
2491 2491 set or show the current branch name
2492 2492 </td></tr>
2493 2493 <tr><td>
2494 2494 <a href="/help/branches">
2495 2495 branches
2496 2496 </a>
2497 2497 </td><td>
2498 2498 list repository named branches
2499 2499 </td></tr>
2500 2500 <tr><td>
2501 2501 <a href="/help/bundle">
2502 2502 bundle
2503 2503 </a>
2504 2504 </td><td>
2505 2505 create a bundle file
2506 2506 </td></tr>
2507 2507 <tr><td>
2508 2508 <a href="/help/cat">
2509 2509 cat
2510 2510 </a>
2511 2511 </td><td>
2512 2512 output the current or given revision of files
2513 2513 </td></tr>
2514 2514 <tr><td>
2515 2515 <a href="/help/config">
2516 2516 config
2517 2517 </a>
2518 2518 </td><td>
2519 2519 show combined config settings from all hgrc files
2520 2520 </td></tr>
2521 2521 <tr><td>
2522 2522 <a href="/help/copy">
2523 2523 copy
2524 2524 </a>
2525 2525 </td><td>
2526 2526 mark files as copied for the next commit
2527 2527 </td></tr>
2528 2528 <tr><td>
2529 2529 <a href="/help/files">
2530 2530 files
2531 2531 </a>
2532 2532 </td><td>
2533 2533 list tracked files
2534 2534 </td></tr>
2535 2535 <tr><td>
2536 2536 <a href="/help/graft">
2537 2537 graft
2538 2538 </a>
2539 2539 </td><td>
2540 2540 copy changes from other branches onto the current branch
2541 2541 </td></tr>
2542 2542 <tr><td>
2543 2543 <a href="/help/grep">
2544 2544 grep
2545 2545 </a>
2546 2546 </td><td>
2547 2547 search revision history for a pattern in specified files
2548 2548 </td></tr>
2549 2549 <tr><td>
2550 2550 <a href="/help/hashelp">
2551 2551 hashelp
2552 2552 </a>
2553 2553 </td><td>
2554 2554 Extension command's help
2555 2555 </td></tr>
2556 2556 <tr><td>
2557 2557 <a href="/help/heads">
2558 2558 heads
2559 2559 </a>
2560 2560 </td><td>
2561 2561 show branch heads
2562 2562 </td></tr>
2563 2563 <tr><td>
2564 2564 <a href="/help/help">
2565 2565 help
2566 2566 </a>
2567 2567 </td><td>
2568 2568 show help for a given topic or a help overview
2569 2569 </td></tr>
2570 2570 <tr><td>
2571 2571 <a href="/help/hgalias">
2572 2572 hgalias
2573 2573 </a>
2574 2574 </td><td>
2575 2575 My doc
2576 2576 </td></tr>
2577 2577 <tr><td>
2578 2578 <a href="/help/hgaliasnodoc">
2579 2579 hgaliasnodoc
2580 2580 </a>
2581 2581 </td><td>
2582 2582 summarize working directory state
2583 2583 </td></tr>
2584 2584 <tr><td>
2585 2585 <a href="/help/identify">
2586 2586 identify
2587 2587 </a>
2588 2588 </td><td>
2589 2589 identify the working directory or specified revision
2590 2590 </td></tr>
2591 2591 <tr><td>
2592 2592 <a href="/help/import">
2593 2593 import
2594 2594 </a>
2595 2595 </td><td>
2596 2596 import an ordered set of patches
2597 2597 </td></tr>
2598 2598 <tr><td>
2599 2599 <a href="/help/incoming">
2600 2600 incoming
2601 2601 </a>
2602 2602 </td><td>
2603 2603 show new changesets found in source
2604 2604 </td></tr>
2605 2605 <tr><td>
2606 2606 <a href="/help/manifest">
2607 2607 manifest
2608 2608 </a>
2609 2609 </td><td>
2610 2610 output the current or given revision of the project manifest
2611 2611 </td></tr>
2612 2612 <tr><td>
2613 2613 <a href="/help/nohelp">
2614 2614 nohelp
2615 2615 </a>
2616 2616 </td><td>
2617 2617 (no help text available)
2618 2618 </td></tr>
2619 2619 <tr><td>
2620 2620 <a href="/help/outgoing">
2621 2621 outgoing
2622 2622 </a>
2623 2623 </td><td>
2624 2624 show changesets not found in the destination
2625 2625 </td></tr>
2626 2626 <tr><td>
2627 2627 <a href="/help/paths">
2628 2628 paths
2629 2629 </a>
2630 2630 </td><td>
2631 2631 show aliases for remote repositories
2632 2632 </td></tr>
2633 2633 <tr><td>
2634 2634 <a href="/help/phase">
2635 2635 phase
2636 2636 </a>
2637 2637 </td><td>
2638 2638 set or show the current phase name
2639 2639 </td></tr>
2640 2640 <tr><td>
2641 2641 <a href="/help/recover">
2642 2642 recover
2643 2643 </a>
2644 2644 </td><td>
2645 2645 roll back an interrupted transaction
2646 2646 </td></tr>
2647 2647 <tr><td>
2648 2648 <a href="/help/rename">
2649 2649 rename
2650 2650 </a>
2651 2651 </td><td>
2652 2652 rename files; equivalent of copy + remove
2653 2653 </td></tr>
2654 2654 <tr><td>
2655 2655 <a href="/help/resolve">
2656 2656 resolve
2657 2657 </a>
2658 2658 </td><td>
2659 2659 redo merges or set/view the merge status of files
2660 2660 </td></tr>
2661 2661 <tr><td>
2662 2662 <a href="/help/revert">
2663 2663 revert
2664 2664 </a>
2665 2665 </td><td>
2666 2666 restore files to their checkout state
2667 2667 </td></tr>
2668 2668 <tr><td>
2669 2669 <a href="/help/root">
2670 2670 root
2671 2671 </a>
2672 2672 </td><td>
2673 2673 print the root (top) of the current working directory
2674 2674 </td></tr>
2675 2675 <tr><td>
2676 2676 <a href="/help/shellalias">
2677 2677 shellalias
2678 2678 </a>
2679 2679 </td><td>
2680 2680 (no help text available)
2681 2681 </td></tr>
2682 2682 <tr><td>
2683 2683 <a href="/help/tag">
2684 2684 tag
2685 2685 </a>
2686 2686 </td><td>
2687 2687 add one or more tags for the current or given revision
2688 2688 </td></tr>
2689 2689 <tr><td>
2690 2690 <a href="/help/tags">
2691 2691 tags
2692 2692 </a>
2693 2693 </td><td>
2694 2694 list repository tags
2695 2695 </td></tr>
2696 2696 <tr><td>
2697 2697 <a href="/help/unbundle">
2698 2698 unbundle
2699 2699 </a>
2700 2700 </td><td>
2701 2701 apply one or more bundle files
2702 2702 </td></tr>
2703 2703 <tr><td>
2704 2704 <a href="/help/verify">
2705 2705 verify
2706 2706 </a>
2707 2707 </td><td>
2708 2708 verify the integrity of the repository
2709 2709 </td></tr>
2710 2710 <tr><td>
2711 2711 <a href="/help/version">
2712 2712 version
2713 2713 </a>
2714 2714 </td><td>
2715 2715 output version and copyright information
2716 2716 </td></tr>
2717 2717
2718 2718
2719 2719 </table>
2720 2720 </div>
2721 2721 </div>
2722 2722
2723 2723
2724 2724
2725 2725 </body>
2726 2726 </html>
2727 2727
2728 2728
2729 2729 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2730 2730 200 Script output follows
2731 2731
2732 2732 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2733 2733 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2734 2734 <head>
2735 2735 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2736 2736 <meta name="robots" content="index, nofollow" />
2737 2737 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2738 2738 <script type="text/javascript" src="/static/mercurial.js"></script>
2739 2739
2740 2740 <title>Help: add</title>
2741 2741 </head>
2742 2742 <body>
2743 2743
2744 2744 <div class="container">
2745 2745 <div class="menu">
2746 2746 <div class="logo">
2747 2747 <a href="https://mercurial-scm.org/">
2748 2748 <img src="/static/hglogo.png" alt="mercurial" /></a>
2749 2749 </div>
2750 2750 <ul>
2751 2751 <li><a href="/shortlog">log</a></li>
2752 2752 <li><a href="/graph">graph</a></li>
2753 2753 <li><a href="/tags">tags</a></li>
2754 2754 <li><a href="/bookmarks">bookmarks</a></li>
2755 2755 <li><a href="/branches">branches</a></li>
2756 2756 </ul>
2757 2757 <ul>
2758 2758 <li class="active"><a href="/help">help</a></li>
2759 2759 </ul>
2760 2760 </div>
2761 2761
2762 2762 <div class="main">
2763 2763 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2764 2764 <h3>Help: add</h3>
2765 2765
2766 2766 <form class="search" action="/log">
2767 2767
2768 2768 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2769 2769 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2770 2770 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2771 2771 </form>
2772 2772 <div id="doc">
2773 2773 <p>
2774 2774 hg add [OPTION]... [FILE]...
2775 2775 </p>
2776 2776 <p>
2777 2777 add the specified files on the next commit
2778 2778 </p>
2779 2779 <p>
2780 2780 Schedule files to be version controlled and added to the
2781 2781 repository.
2782 2782 </p>
2783 2783 <p>
2784 2784 The files will be added to the repository at the next commit. To
2785 2785 undo an add before that, see 'hg forget'.
2786 2786 </p>
2787 2787 <p>
2788 2788 If no names are given, add all files to the repository (except
2789 2789 files matching &quot;.hgignore&quot;).
2790 2790 </p>
2791 2791 <p>
2792 2792 Examples:
2793 2793 </p>
2794 2794 <ul>
2795 2795 <li> New (unknown) files are added automatically by 'hg add':
2796 2796 <pre>
2797 2797 \$ ls (re)
2798 2798 foo.c
2799 2799 \$ hg status (re)
2800 2800 ? foo.c
2801 2801 \$ hg add (re)
2802 2802 adding foo.c
2803 2803 \$ hg status (re)
2804 2804 A foo.c
2805 2805 </pre>
2806 2806 <li> Specific files to be added can be specified:
2807 2807 <pre>
2808 2808 \$ ls (re)
2809 2809 bar.c foo.c
2810 2810 \$ hg status (re)
2811 2811 ? bar.c
2812 2812 ? foo.c
2813 2813 \$ hg add bar.c (re)
2814 2814 \$ hg status (re)
2815 2815 A bar.c
2816 2816 ? foo.c
2817 2817 </pre>
2818 2818 </ul>
2819 2819 <p>
2820 2820 Returns 0 if all files are successfully added.
2821 2821 </p>
2822 2822 <p>
2823 2823 options ([+] can be repeated):
2824 2824 </p>
2825 2825 <table>
2826 2826 <tr><td>-I</td>
2827 2827 <td>--include PATTERN [+]</td>
2828 2828 <td>include names matching the given patterns</td></tr>
2829 2829 <tr><td>-X</td>
2830 2830 <td>--exclude PATTERN [+]</td>
2831 2831 <td>exclude names matching the given patterns</td></tr>
2832 2832 <tr><td>-S</td>
2833 2833 <td>--subrepos</td>
2834 2834 <td>recurse into subrepositories</td></tr>
2835 2835 <tr><td>-n</td>
2836 2836 <td>--dry-run</td>
2837 2837 <td>do not perform actions, just print output</td></tr>
2838 2838 </table>
2839 2839 <p>
2840 2840 global options ([+] can be repeated):
2841 2841 </p>
2842 2842 <table>
2843 2843 <tr><td>-R</td>
2844 2844 <td>--repository REPO</td>
2845 2845 <td>repository root directory or name of overlay bundle file</td></tr>
2846 2846 <tr><td></td>
2847 2847 <td>--cwd DIR</td>
2848 2848 <td>change working directory</td></tr>
2849 2849 <tr><td>-y</td>
2850 2850 <td>--noninteractive</td>
2851 2851 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2852 2852 <tr><td>-q</td>
2853 2853 <td>--quiet</td>
2854 2854 <td>suppress output</td></tr>
2855 2855 <tr><td>-v</td>
2856 2856 <td>--verbose</td>
2857 2857 <td>enable additional output</td></tr>
2858 2858 <tr><td></td>
2859 2859 <td>--color TYPE</td>
2860 2860 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2861 2861 <tr><td></td>
2862 2862 <td>--config CONFIG [+]</td>
2863 2863 <td>set/override config option (use 'section.name=value')</td></tr>
2864 2864 <tr><td></td>
2865 2865 <td>--debug</td>
2866 2866 <td>enable debugging output</td></tr>
2867 2867 <tr><td></td>
2868 2868 <td>--debugger</td>
2869 2869 <td>start debugger</td></tr>
2870 2870 <tr><td></td>
2871 2871 <td>--encoding ENCODE</td>
2872 2872 <td>set the charset encoding (default: ascii)</td></tr>
2873 2873 <tr><td></td>
2874 2874 <td>--encodingmode MODE</td>
2875 2875 <td>set the charset encoding mode (default: strict)</td></tr>
2876 2876 <tr><td></td>
2877 2877 <td>--traceback</td>
2878 2878 <td>always print a traceback on exception</td></tr>
2879 2879 <tr><td></td>
2880 2880 <td>--time</td>
2881 2881 <td>time how long the command takes</td></tr>
2882 2882 <tr><td></td>
2883 2883 <td>--profile</td>
2884 2884 <td>print command execution profile</td></tr>
2885 2885 <tr><td></td>
2886 2886 <td>--version</td>
2887 2887 <td>output version information and exit</td></tr>
2888 2888 <tr><td>-h</td>
2889 2889 <td>--help</td>
2890 2890 <td>display help and exit</td></tr>
2891 2891 <tr><td></td>
2892 2892 <td>--hidden</td>
2893 <td>consider hidden changesets</td></tr>
2893 <td>consider hidden changesets (default: off)</td></tr>
2894 2894 <tr><td></td>
2895 2895 <td>--pager TYPE</td>
2896 2896 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2897 2897 </table>
2898 2898
2899 2899 </div>
2900 2900 </div>
2901 2901 </div>
2902 2902
2903 2903
2904 2904
2905 2905 </body>
2906 2906 </html>
2907 2907
2908 2908
2909 2909 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2910 2910 200 Script output follows
2911 2911
2912 2912 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2913 2913 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2914 2914 <head>
2915 2915 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2916 2916 <meta name="robots" content="index, nofollow" />
2917 2917 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2918 2918 <script type="text/javascript" src="/static/mercurial.js"></script>
2919 2919
2920 2920 <title>Help: remove</title>
2921 2921 </head>
2922 2922 <body>
2923 2923
2924 2924 <div class="container">
2925 2925 <div class="menu">
2926 2926 <div class="logo">
2927 2927 <a href="https://mercurial-scm.org/">
2928 2928 <img src="/static/hglogo.png" alt="mercurial" /></a>
2929 2929 </div>
2930 2930 <ul>
2931 2931 <li><a href="/shortlog">log</a></li>
2932 2932 <li><a href="/graph">graph</a></li>
2933 2933 <li><a href="/tags">tags</a></li>
2934 2934 <li><a href="/bookmarks">bookmarks</a></li>
2935 2935 <li><a href="/branches">branches</a></li>
2936 2936 </ul>
2937 2937 <ul>
2938 2938 <li class="active"><a href="/help">help</a></li>
2939 2939 </ul>
2940 2940 </div>
2941 2941
2942 2942 <div class="main">
2943 2943 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2944 2944 <h3>Help: remove</h3>
2945 2945
2946 2946 <form class="search" action="/log">
2947 2947
2948 2948 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2949 2949 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2950 2950 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2951 2951 </form>
2952 2952 <div id="doc">
2953 2953 <p>
2954 2954 hg remove [OPTION]... FILE...
2955 2955 </p>
2956 2956 <p>
2957 2957 aliases: rm
2958 2958 </p>
2959 2959 <p>
2960 2960 remove the specified files on the next commit
2961 2961 </p>
2962 2962 <p>
2963 2963 Schedule the indicated files for removal from the current branch.
2964 2964 </p>
2965 2965 <p>
2966 2966 This command schedules the files to be removed at the next commit.
2967 2967 To undo a remove before that, see 'hg revert'. To undo added
2968 2968 files, see 'hg forget'.
2969 2969 </p>
2970 2970 <p>
2971 2971 -A/--after can be used to remove only files that have already
2972 2972 been deleted, -f/--force can be used to force deletion, and -Af
2973 2973 can be used to remove files from the next revision without
2974 2974 deleting them from the working directory.
2975 2975 </p>
2976 2976 <p>
2977 2977 The following table details the behavior of remove for different
2978 2978 file states (columns) and option combinations (rows). The file
2979 2979 states are Added [A], Clean [C], Modified [M] and Missing [!]
2980 2980 (as reported by 'hg status'). The actions are Warn, Remove
2981 2981 (from branch) and Delete (from disk):
2982 2982 </p>
2983 2983 <table>
2984 2984 <tr><td>opt/state</td>
2985 2985 <td>A</td>
2986 2986 <td>C</td>
2987 2987 <td>M</td>
2988 2988 <td>!</td></tr>
2989 2989 <tr><td>none</td>
2990 2990 <td>W</td>
2991 2991 <td>RD</td>
2992 2992 <td>W</td>
2993 2993 <td>R</td></tr>
2994 2994 <tr><td>-f</td>
2995 2995 <td>R</td>
2996 2996 <td>RD</td>
2997 2997 <td>RD</td>
2998 2998 <td>R</td></tr>
2999 2999 <tr><td>-A</td>
3000 3000 <td>W</td>
3001 3001 <td>W</td>
3002 3002 <td>W</td>
3003 3003 <td>R</td></tr>
3004 3004 <tr><td>-Af</td>
3005 3005 <td>R</td>
3006 3006 <td>R</td>
3007 3007 <td>R</td>
3008 3008 <td>R</td></tr>
3009 3009 </table>
3010 3010 <p>
3011 3011 <b>Note:</b>
3012 3012 </p>
3013 3013 <p>
3014 3014 'hg remove' never deletes files in Added [A] state from the
3015 3015 working directory, not even if &quot;--force&quot; is specified.
3016 3016 </p>
3017 3017 <p>
3018 3018 Returns 0 on success, 1 if any warnings encountered.
3019 3019 </p>
3020 3020 <p>
3021 3021 options ([+] can be repeated):
3022 3022 </p>
3023 3023 <table>
3024 3024 <tr><td>-A</td>
3025 3025 <td>--after</td>
3026 3026 <td>record delete for missing files</td></tr>
3027 3027 <tr><td>-f</td>
3028 3028 <td>--force</td>
3029 3029 <td>forget added files, delete modified files</td></tr>
3030 3030 <tr><td>-S</td>
3031 3031 <td>--subrepos</td>
3032 3032 <td>recurse into subrepositories</td></tr>
3033 3033 <tr><td>-I</td>
3034 3034 <td>--include PATTERN [+]</td>
3035 3035 <td>include names matching the given patterns</td></tr>
3036 3036 <tr><td>-X</td>
3037 3037 <td>--exclude PATTERN [+]</td>
3038 3038 <td>exclude names matching the given patterns</td></tr>
3039 3039 <tr><td>-n</td>
3040 3040 <td>--dry-run</td>
3041 3041 <td>do not perform actions, just print output</td></tr>
3042 3042 </table>
3043 3043 <p>
3044 3044 global options ([+] can be repeated):
3045 3045 </p>
3046 3046 <table>
3047 3047 <tr><td>-R</td>
3048 3048 <td>--repository REPO</td>
3049 3049 <td>repository root directory or name of overlay bundle file</td></tr>
3050 3050 <tr><td></td>
3051 3051 <td>--cwd DIR</td>
3052 3052 <td>change working directory</td></tr>
3053 3053 <tr><td>-y</td>
3054 3054 <td>--noninteractive</td>
3055 3055 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3056 3056 <tr><td>-q</td>
3057 3057 <td>--quiet</td>
3058 3058 <td>suppress output</td></tr>
3059 3059 <tr><td>-v</td>
3060 3060 <td>--verbose</td>
3061 3061 <td>enable additional output</td></tr>
3062 3062 <tr><td></td>
3063 3063 <td>--color TYPE</td>
3064 3064 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3065 3065 <tr><td></td>
3066 3066 <td>--config CONFIG [+]</td>
3067 3067 <td>set/override config option (use 'section.name=value')</td></tr>
3068 3068 <tr><td></td>
3069 3069 <td>--debug</td>
3070 3070 <td>enable debugging output</td></tr>
3071 3071 <tr><td></td>
3072 3072 <td>--debugger</td>
3073 3073 <td>start debugger</td></tr>
3074 3074 <tr><td></td>
3075 3075 <td>--encoding ENCODE</td>
3076 3076 <td>set the charset encoding (default: ascii)</td></tr>
3077 3077 <tr><td></td>
3078 3078 <td>--encodingmode MODE</td>
3079 3079 <td>set the charset encoding mode (default: strict)</td></tr>
3080 3080 <tr><td></td>
3081 3081 <td>--traceback</td>
3082 3082 <td>always print a traceback on exception</td></tr>
3083 3083 <tr><td></td>
3084 3084 <td>--time</td>
3085 3085 <td>time how long the command takes</td></tr>
3086 3086 <tr><td></td>
3087 3087 <td>--profile</td>
3088 3088 <td>print command execution profile</td></tr>
3089 3089 <tr><td></td>
3090 3090 <td>--version</td>
3091 3091 <td>output version information and exit</td></tr>
3092 3092 <tr><td>-h</td>
3093 3093 <td>--help</td>
3094 3094 <td>display help and exit</td></tr>
3095 3095 <tr><td></td>
3096 3096 <td>--hidden</td>
3097 <td>consider hidden changesets</td></tr>
3097 <td>consider hidden changesets (default: off)</td></tr>
3098 3098 <tr><td></td>
3099 3099 <td>--pager TYPE</td>
3100 3100 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3101 3101 </table>
3102 3102
3103 3103 </div>
3104 3104 </div>
3105 3105 </div>
3106 3106
3107 3107
3108 3108
3109 3109 </body>
3110 3110 </html>
3111 3111
3112 3112
3113 3113 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3114 3114 200 Script output follows
3115 3115
3116 3116 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3117 3117 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3118 3118 <head>
3119 3119 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3120 3120 <meta name="robots" content="index, nofollow" />
3121 3121 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3122 3122 <script type="text/javascript" src="/static/mercurial.js"></script>
3123 3123
3124 3124 <title>Help: dates</title>
3125 3125 </head>
3126 3126 <body>
3127 3127
3128 3128 <div class="container">
3129 3129 <div class="menu">
3130 3130 <div class="logo">
3131 3131 <a href="https://mercurial-scm.org/">
3132 3132 <img src="/static/hglogo.png" alt="mercurial" /></a>
3133 3133 </div>
3134 3134 <ul>
3135 3135 <li><a href="/shortlog">log</a></li>
3136 3136 <li><a href="/graph">graph</a></li>
3137 3137 <li><a href="/tags">tags</a></li>
3138 3138 <li><a href="/bookmarks">bookmarks</a></li>
3139 3139 <li><a href="/branches">branches</a></li>
3140 3140 </ul>
3141 3141 <ul>
3142 3142 <li class="active"><a href="/help">help</a></li>
3143 3143 </ul>
3144 3144 </div>
3145 3145
3146 3146 <div class="main">
3147 3147 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3148 3148 <h3>Help: dates</h3>
3149 3149
3150 3150 <form class="search" action="/log">
3151 3151
3152 3152 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3153 3153 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3154 3154 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3155 3155 </form>
3156 3156 <div id="doc">
3157 3157 <h1>Date Formats</h1>
3158 3158 <p>
3159 3159 Some commands allow the user to specify a date, e.g.:
3160 3160 </p>
3161 3161 <ul>
3162 3162 <li> backout, commit, import, tag: Specify the commit date.
3163 3163 <li> log, revert, update: Select revision(s) by date.
3164 3164 </ul>
3165 3165 <p>
3166 3166 Many date formats are valid. Here are some examples:
3167 3167 </p>
3168 3168 <ul>
3169 3169 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3170 3170 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3171 3171 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3172 3172 <li> &quot;Dec 6&quot; (midnight)
3173 3173 <li> &quot;13:18&quot; (today assumed)
3174 3174 <li> &quot;3:39&quot; (3:39AM assumed)
3175 3175 <li> &quot;3:39pm&quot; (15:39)
3176 3176 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3177 3177 <li> &quot;2006-12-6 13:18&quot;
3178 3178 <li> &quot;2006-12-6&quot;
3179 3179 <li> &quot;12-6&quot;
3180 3180 <li> &quot;12/6&quot;
3181 3181 <li> &quot;12/6/6&quot; (Dec 6 2006)
3182 3182 <li> &quot;today&quot; (midnight)
3183 3183 <li> &quot;yesterday&quot; (midnight)
3184 3184 <li> &quot;now&quot; - right now
3185 3185 </ul>
3186 3186 <p>
3187 3187 Lastly, there is Mercurial's internal format:
3188 3188 </p>
3189 3189 <ul>
3190 3190 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3191 3191 </ul>
3192 3192 <p>
3193 3193 This is the internal representation format for dates. The first number
3194 3194 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3195 3195 second is the offset of the local timezone, in seconds west of UTC
3196 3196 (negative if the timezone is east of UTC).
3197 3197 </p>
3198 3198 <p>
3199 3199 The log command also accepts date ranges:
3200 3200 </p>
3201 3201 <ul>
3202 3202 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3203 3203 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3204 3204 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3205 3205 <li> &quot;-DAYS&quot; - within a given number of days of today
3206 3206 </ul>
3207 3207
3208 3208 </div>
3209 3209 </div>
3210 3210 </div>
3211 3211
3212 3212
3213 3213
3214 3214 </body>
3215 3215 </html>
3216 3216
3217 3217
3218 3218 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3219 3219 200 Script output follows
3220 3220
3221 3221 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3222 3222 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3223 3223 <head>
3224 3224 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3225 3225 <meta name="robots" content="index, nofollow" />
3226 3226 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3227 3227 <script type="text/javascript" src="/static/mercurial.js"></script>
3228 3228
3229 3229 <title>Help: pager</title>
3230 3230 </head>
3231 3231 <body>
3232 3232
3233 3233 <div class="container">
3234 3234 <div class="menu">
3235 3235 <div class="logo">
3236 3236 <a href="https://mercurial-scm.org/">
3237 3237 <img src="/static/hglogo.png" alt="mercurial" /></a>
3238 3238 </div>
3239 3239 <ul>
3240 3240 <li><a href="/shortlog">log</a></li>
3241 3241 <li><a href="/graph">graph</a></li>
3242 3242 <li><a href="/tags">tags</a></li>
3243 3243 <li><a href="/bookmarks">bookmarks</a></li>
3244 3244 <li><a href="/branches">branches</a></li>
3245 3245 </ul>
3246 3246 <ul>
3247 3247 <li class="active"><a href="/help">help</a></li>
3248 3248 </ul>
3249 3249 </div>
3250 3250
3251 3251 <div class="main">
3252 3252 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3253 3253 <h3>Help: pager</h3>
3254 3254
3255 3255 <form class="search" action="/log">
3256 3256
3257 3257 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3258 3258 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3259 3259 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3260 3260 </form>
3261 3261 <div id="doc">
3262 3262 <h1>Pager Support</h1>
3263 3263 <p>
3264 3264 Some Mercurial commands can produce a lot of output, and Mercurial will
3265 3265 attempt to use a pager to make those commands more pleasant.
3266 3266 </p>
3267 3267 <p>
3268 3268 To set the pager that should be used, set the application variable:
3269 3269 </p>
3270 3270 <pre>
3271 3271 [pager]
3272 3272 pager = less -FRX
3273 3273 </pre>
3274 3274 <p>
3275 3275 If no pager is set in the user or repository configuration, Mercurial uses the
3276 3276 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3277 3277 or system configuration is used. If none of these are set, a default pager will
3278 3278 be used, typically 'less' on Unix and 'more' on Windows.
3279 3279 </p>
3280 3280 <p>
3281 3281 You can disable the pager for certain commands by adding them to the
3282 3282 pager.ignore list:
3283 3283 </p>
3284 3284 <pre>
3285 3285 [pager]
3286 3286 ignore = version, help, update
3287 3287 </pre>
3288 3288 <p>
3289 3289 To ignore global commands like 'hg version' or 'hg help', you have
3290 3290 to specify them in your user configuration file.
3291 3291 </p>
3292 3292 <p>
3293 3293 To control whether the pager is used at all for an individual command,
3294 3294 you can use --pager=&lt;value&gt;:
3295 3295 </p>
3296 3296 <ul>
3297 3297 <li> use as needed: 'auto'.
3298 3298 <li> require the pager: 'yes' or 'on'.
3299 3299 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3300 3300 </ul>
3301 3301 <p>
3302 3302 To globally turn off all attempts to use a pager, set:
3303 3303 </p>
3304 3304 <pre>
3305 3305 [ui]
3306 3306 paginate = never
3307 3307 </pre>
3308 3308 <p>
3309 3309 which will prevent the pager from running.
3310 3310 </p>
3311 3311
3312 3312 </div>
3313 3313 </div>
3314 3314 </div>
3315 3315
3316 3316
3317 3317
3318 3318 </body>
3319 3319 </html>
3320 3320
3321 3321
3322 3322 Sub-topic indexes rendered properly
3323 3323
3324 3324 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3325 3325 200 Script output follows
3326 3326
3327 3327 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3328 3328 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3329 3329 <head>
3330 3330 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3331 3331 <meta name="robots" content="index, nofollow" />
3332 3332 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3333 3333 <script type="text/javascript" src="/static/mercurial.js"></script>
3334 3334
3335 3335 <title>Help: internals</title>
3336 3336 </head>
3337 3337 <body>
3338 3338
3339 3339 <div class="container">
3340 3340 <div class="menu">
3341 3341 <div class="logo">
3342 3342 <a href="https://mercurial-scm.org/">
3343 3343 <img src="/static/hglogo.png" alt="mercurial" /></a>
3344 3344 </div>
3345 3345 <ul>
3346 3346 <li><a href="/shortlog">log</a></li>
3347 3347 <li><a href="/graph">graph</a></li>
3348 3348 <li><a href="/tags">tags</a></li>
3349 3349 <li><a href="/bookmarks">bookmarks</a></li>
3350 3350 <li><a href="/branches">branches</a></li>
3351 3351 </ul>
3352 3352 <ul>
3353 3353 <li><a href="/help">help</a></li>
3354 3354 </ul>
3355 3355 </div>
3356 3356
3357 3357 <div class="main">
3358 3358 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3359 3359
3360 3360 <form class="search" action="/log">
3361 3361
3362 3362 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3363 3363 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3364 3364 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3365 3365 </form>
3366 3366 <table class="bigtable">
3367 3367 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3368 3368
3369 3369 <tr><td>
3370 3370 <a href="/help/internals.bundle2">
3371 3371 bundle2
3372 3372 </a>
3373 3373 </td><td>
3374 3374 Bundle2
3375 3375 </td></tr>
3376 3376 <tr><td>
3377 3377 <a href="/help/internals.bundles">
3378 3378 bundles
3379 3379 </a>
3380 3380 </td><td>
3381 3381 Bundles
3382 3382 </td></tr>
3383 3383 <tr><td>
3384 3384 <a href="/help/internals.cbor">
3385 3385 cbor
3386 3386 </a>
3387 3387 </td><td>
3388 3388 CBOR
3389 3389 </td></tr>
3390 3390 <tr><td>
3391 3391 <a href="/help/internals.censor">
3392 3392 censor
3393 3393 </a>
3394 3394 </td><td>
3395 3395 Censor
3396 3396 </td></tr>
3397 3397 <tr><td>
3398 3398 <a href="/help/internals.changegroups">
3399 3399 changegroups
3400 3400 </a>
3401 3401 </td><td>
3402 3402 Changegroups
3403 3403 </td></tr>
3404 3404 <tr><td>
3405 3405 <a href="/help/internals.config">
3406 3406 config
3407 3407 </a>
3408 3408 </td><td>
3409 3409 Config Registrar
3410 3410 </td></tr>
3411 3411 <tr><td>
3412 3412 <a href="/help/internals.extensions">
3413 3413 extensions
3414 3414 </a>
3415 3415 </td><td>
3416 3416 Extension API
3417 3417 </td></tr>
3418 3418 <tr><td>
3419 3419 <a href="/help/internals.requirements">
3420 3420 requirements
3421 3421 </a>
3422 3422 </td><td>
3423 3423 Repository Requirements
3424 3424 </td></tr>
3425 3425 <tr><td>
3426 3426 <a href="/help/internals.revlogs">
3427 3427 revlogs
3428 3428 </a>
3429 3429 </td><td>
3430 3430 Revision Logs
3431 3431 </td></tr>
3432 3432 <tr><td>
3433 3433 <a href="/help/internals.wireprotocol">
3434 3434 wireprotocol
3435 3435 </a>
3436 3436 </td><td>
3437 3437 Wire Protocol
3438 3438 </td></tr>
3439 3439 <tr><td>
3440 3440 <a href="/help/internals.wireprotocolrpc">
3441 3441 wireprotocolrpc
3442 3442 </a>
3443 3443 </td><td>
3444 3444 Wire Protocol RPC
3445 3445 </td></tr>
3446 3446 <tr><td>
3447 3447 <a href="/help/internals.wireprotocolv2">
3448 3448 wireprotocolv2
3449 3449 </a>
3450 3450 </td><td>
3451 3451 Wire Protocol Version 2
3452 3452 </td></tr>
3453 3453
3454 3454
3455 3455
3456 3456
3457 3457
3458 3458 </table>
3459 3459 </div>
3460 3460 </div>
3461 3461
3462 3462
3463 3463
3464 3464 </body>
3465 3465 </html>
3466 3466
3467 3467
3468 3468 Sub-topic topics rendered properly
3469 3469
3470 3470 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3471 3471 200 Script output follows
3472 3472
3473 3473 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3474 3474 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3475 3475 <head>
3476 3476 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3477 3477 <meta name="robots" content="index, nofollow" />
3478 3478 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3479 3479 <script type="text/javascript" src="/static/mercurial.js"></script>
3480 3480
3481 3481 <title>Help: internals.changegroups</title>
3482 3482 </head>
3483 3483 <body>
3484 3484
3485 3485 <div class="container">
3486 3486 <div class="menu">
3487 3487 <div class="logo">
3488 3488 <a href="https://mercurial-scm.org/">
3489 3489 <img src="/static/hglogo.png" alt="mercurial" /></a>
3490 3490 </div>
3491 3491 <ul>
3492 3492 <li><a href="/shortlog">log</a></li>
3493 3493 <li><a href="/graph">graph</a></li>
3494 3494 <li><a href="/tags">tags</a></li>
3495 3495 <li><a href="/bookmarks">bookmarks</a></li>
3496 3496 <li><a href="/branches">branches</a></li>
3497 3497 </ul>
3498 3498 <ul>
3499 3499 <li class="active"><a href="/help">help</a></li>
3500 3500 </ul>
3501 3501 </div>
3502 3502
3503 3503 <div class="main">
3504 3504 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3505 3505 <h3>Help: internals.changegroups</h3>
3506 3506
3507 3507 <form class="search" action="/log">
3508 3508
3509 3509 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3510 3510 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3511 3511 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3512 3512 </form>
3513 3513 <div id="doc">
3514 3514 <h1>Changegroups</h1>
3515 3515 <p>
3516 3516 Changegroups are representations of repository revlog data, specifically
3517 3517 the changelog data, root/flat manifest data, treemanifest data, and
3518 3518 filelogs.
3519 3519 </p>
3520 3520 <p>
3521 3521 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3522 3522 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3523 3523 only difference being an additional item in the *delta header*. Version
3524 3524 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3525 3525 exchanging treemanifests (enabled by setting an option on the
3526 3526 &quot;changegroup&quot; part in the bundle2).
3527 3527 </p>
3528 3528 <p>
3529 3529 Changegroups when not exchanging treemanifests consist of 3 logical
3530 3530 segments:
3531 3531 </p>
3532 3532 <pre>
3533 3533 +---------------------------------+
3534 3534 | | | |
3535 3535 | changeset | manifest | filelogs |
3536 3536 | | | |
3537 3537 | | | |
3538 3538 +---------------------------------+
3539 3539 </pre>
3540 3540 <p>
3541 3541 When exchanging treemanifests, there are 4 logical segments:
3542 3542 </p>
3543 3543 <pre>
3544 3544 +-------------------------------------------------+
3545 3545 | | | | |
3546 3546 | changeset | root | treemanifests | filelogs |
3547 3547 | | manifest | | |
3548 3548 | | | | |
3549 3549 +-------------------------------------------------+
3550 3550 </pre>
3551 3551 <p>
3552 3552 The principle building block of each segment is a *chunk*. A *chunk*
3553 3553 is a framed piece of data:
3554 3554 </p>
3555 3555 <pre>
3556 3556 +---------------------------------------+
3557 3557 | | |
3558 3558 | length | data |
3559 3559 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3560 3560 | | |
3561 3561 +---------------------------------------+
3562 3562 </pre>
3563 3563 <p>
3564 3564 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3565 3565 integer indicating the length of the entire chunk (including the length field
3566 3566 itself).
3567 3567 </p>
3568 3568 <p>
3569 3569 There is a special case chunk that has a value of 0 for the length
3570 3570 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3571 3571 </p>
3572 3572 <h2>Delta Groups</h2>
3573 3573 <p>
3574 3574 A *delta group* expresses the content of a revlog as a series of deltas,
3575 3575 or patches against previous revisions.
3576 3576 </p>
3577 3577 <p>
3578 3578 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3579 3579 to signal the end of the delta group:
3580 3580 </p>
3581 3581 <pre>
3582 3582 +------------------------------------------------------------------------+
3583 3583 | | | | | |
3584 3584 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3585 3585 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3586 3586 | | | | | |
3587 3587 +------------------------------------------------------------------------+
3588 3588 </pre>
3589 3589 <p>
3590 3590 Each *chunk*'s data consists of the following:
3591 3591 </p>
3592 3592 <pre>
3593 3593 +---------------------------------------+
3594 3594 | | |
3595 3595 | delta header | delta data |
3596 3596 | (various by version) | (various) |
3597 3597 | | |
3598 3598 +---------------------------------------+
3599 3599 </pre>
3600 3600 <p>
3601 3601 The *delta data* is a series of *delta*s that describe a diff from an existing
3602 3602 entry (either that the recipient already has, or previously specified in the
3603 3603 bundle/changegroup).
3604 3604 </p>
3605 3605 <p>
3606 3606 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3607 3607 &quot;3&quot; of the changegroup format.
3608 3608 </p>
3609 3609 <p>
3610 3610 Version 1 (headerlen=80):
3611 3611 </p>
3612 3612 <pre>
3613 3613 +------------------------------------------------------+
3614 3614 | | | | |
3615 3615 | node | p1 node | p2 node | link node |
3616 3616 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3617 3617 | | | | |
3618 3618 +------------------------------------------------------+
3619 3619 </pre>
3620 3620 <p>
3621 3621 Version 2 (headerlen=100):
3622 3622 </p>
3623 3623 <pre>
3624 3624 +------------------------------------------------------------------+
3625 3625 | | | | | |
3626 3626 | node | p1 node | p2 node | base node | link node |
3627 3627 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3628 3628 | | | | | |
3629 3629 +------------------------------------------------------------------+
3630 3630 </pre>
3631 3631 <p>
3632 3632 Version 3 (headerlen=102):
3633 3633 </p>
3634 3634 <pre>
3635 3635 +------------------------------------------------------------------------------+
3636 3636 | | | | | | |
3637 3637 | node | p1 node | p2 node | base node | link node | flags |
3638 3638 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3639 3639 | | | | | | |
3640 3640 +------------------------------------------------------------------------------+
3641 3641 </pre>
3642 3642 <p>
3643 3643 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3644 3644 series of *delta*s, densely packed (no separators). These deltas describe a diff
3645 3645 from an existing entry (either that the recipient already has, or previously
3646 3646 specified in the bundle/changegroup). The format is described more fully in
3647 3647 &quot;hg help internals.bdiff&quot;, but briefly:
3648 3648 </p>
3649 3649 <pre>
3650 3650 +---------------------------------------------------------------+
3651 3651 | | | | |
3652 3652 | start offset | end offset | new length | content |
3653 3653 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3654 3654 | | | | |
3655 3655 +---------------------------------------------------------------+
3656 3656 </pre>
3657 3657 <p>
3658 3658 Please note that the length field in the delta data does *not* include itself.
3659 3659 </p>
3660 3660 <p>
3661 3661 In version 1, the delta is always applied against the previous node from
3662 3662 the changegroup or the first parent if this is the first entry in the
3663 3663 changegroup.
3664 3664 </p>
3665 3665 <p>
3666 3666 In version 2 and up, the delta base node is encoded in the entry in the
3667 3667 changegroup. This allows the delta to be expressed against any parent,
3668 3668 which can result in smaller deltas and more efficient encoding of data.
3669 3669 </p>
3670 3670 <p>
3671 3671 The *flags* field holds bitwise flags affecting the processing of revision
3672 3672 data. The following flags are defined:
3673 3673 </p>
3674 3674 <dl>
3675 3675 <dt>32768
3676 3676 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3677 3677 <dt>16384
3678 3678 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3679 3679 <dt>8192
3680 3680 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3681 3681 </dl>
3682 3682 <p>
3683 3683 For historical reasons, the integer values are identical to revlog version 1
3684 3684 per-revision storage flags and correspond to bits being set in this 2-byte
3685 3685 field. Bits were allocated starting from the most-significant bit, hence the
3686 3686 reverse ordering and allocation of these flags.
3687 3687 </p>
3688 3688 <h2>Changeset Segment</h2>
3689 3689 <p>
3690 3690 The *changeset segment* consists of a single *delta group* holding
3691 3691 changelog data. The *empty chunk* at the end of the *delta group* denotes
3692 3692 the boundary to the *manifest segment*.
3693 3693 </p>
3694 3694 <h2>Manifest Segment</h2>
3695 3695 <p>
3696 3696 The *manifest segment* consists of a single *delta group* holding manifest
3697 3697 data. If treemanifests are in use, it contains only the manifest for the
3698 3698 root directory of the repository. Otherwise, it contains the entire
3699 3699 manifest data. The *empty chunk* at the end of the *delta group* denotes
3700 3700 the boundary to the next segment (either the *treemanifests segment* or the
3701 3701 *filelogs segment*, depending on version and the request options).
3702 3702 </p>
3703 3703 <h3>Treemanifests Segment</h3>
3704 3704 <p>
3705 3705 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3706 3706 only if the 'treemanifest' param is part of the bundle2 changegroup part
3707 3707 (it is not possible to use changegroup version 3 outside of bundle2).
3708 3708 Aside from the filenames in the *treemanifests segment* containing a
3709 3709 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3710 3710 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3711 3711 a sub-segment with filename size 0). This denotes the boundary to the
3712 3712 *filelogs segment*.
3713 3713 </p>
3714 3714 <h2>Filelogs Segment</h2>
3715 3715 <p>
3716 3716 The *filelogs segment* consists of multiple sub-segments, each
3717 3717 corresponding to an individual file whose data is being described:
3718 3718 </p>
3719 3719 <pre>
3720 3720 +--------------------------------------------------+
3721 3721 | | | | | |
3722 3722 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3723 3723 | | | | | (4 bytes) |
3724 3724 | | | | | |
3725 3725 +--------------------------------------------------+
3726 3726 </pre>
3727 3727 <p>
3728 3728 The final filelog sub-segment is followed by an *empty chunk* (logically,
3729 3729 a sub-segment with filename size 0). This denotes the end of the segment
3730 3730 and of the overall changegroup.
3731 3731 </p>
3732 3732 <p>
3733 3733 Each filelog sub-segment consists of the following:
3734 3734 </p>
3735 3735 <pre>
3736 3736 +------------------------------------------------------+
3737 3737 | | | |
3738 3738 | filename length | filename | delta group |
3739 3739 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3740 3740 | | | |
3741 3741 +------------------------------------------------------+
3742 3742 </pre>
3743 3743 <p>
3744 3744 That is, a *chunk* consisting of the filename (not terminated or padded)
3745 3745 followed by N chunks constituting the *delta group* for this file. The
3746 3746 *empty chunk* at the end of each *delta group* denotes the boundary to the
3747 3747 next filelog sub-segment.
3748 3748 </p>
3749 3749
3750 3750 </div>
3751 3751 </div>
3752 3752 </div>
3753 3753
3754 3754
3755 3755
3756 3756 </body>
3757 3757 </html>
3758 3758
3759 3759
3760 3760 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3761 3761 404 Not Found
3762 3762
3763 3763 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3764 3764 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3765 3765 <head>
3766 3766 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3767 3767 <meta name="robots" content="index, nofollow" />
3768 3768 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3769 3769 <script type="text/javascript" src="/static/mercurial.js"></script>
3770 3770
3771 3771 <title>test: error</title>
3772 3772 </head>
3773 3773 <body>
3774 3774
3775 3775 <div class="container">
3776 3776 <div class="menu">
3777 3777 <div class="logo">
3778 3778 <a href="https://mercurial-scm.org/">
3779 3779 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3780 3780 </div>
3781 3781 <ul>
3782 3782 <li><a href="/shortlog">log</a></li>
3783 3783 <li><a href="/graph">graph</a></li>
3784 3784 <li><a href="/tags">tags</a></li>
3785 3785 <li><a href="/bookmarks">bookmarks</a></li>
3786 3786 <li><a href="/branches">branches</a></li>
3787 3787 </ul>
3788 3788 <ul>
3789 3789 <li><a href="/help">help</a></li>
3790 3790 </ul>
3791 3791 </div>
3792 3792
3793 3793 <div class="main">
3794 3794
3795 3795 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3796 3796 <h3>error</h3>
3797 3797
3798 3798
3799 3799 <form class="search" action="/log">
3800 3800
3801 3801 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3802 3802 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3803 3803 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3804 3804 </form>
3805 3805
3806 3806 <div class="description">
3807 3807 <p>
3808 3808 An error occurred while processing your request:
3809 3809 </p>
3810 3810 <p>
3811 3811 Not Found
3812 3812 </p>
3813 3813 </div>
3814 3814 </div>
3815 3815 </div>
3816 3816
3817 3817
3818 3818
3819 3819 </body>
3820 3820 </html>
3821 3821
3822 3822 [1]
3823 3823
3824 3824 $ killdaemons.py
3825 3825
3826 3826 #endif
@@ -1,218 +1,219 b''
1 1 #testcases flat tree
2 2 $ . "$TESTDIR/narrow-library.sh"
3 3
4 4 #if tree
5 5 $ cat << EOF >> $HGRCPATH
6 6 > [experimental]
7 7 > treemanifest = 1
8 8 > EOF
9 9 #endif
10 10
11 11 $ hg init master
12 12 $ cd master
13 13 $ cat >> .hg/hgrc <<EOF
14 14 > [narrow]
15 15 > serveellipses=True
16 16 > EOF
17 17
18 18 $ mkdir inside
19 19 $ echo 'inside' > inside/f
20 20 $ hg add inside/f
21 21 $ hg commit -m 'add inside'
22 22
23 23 $ mkdir widest
24 24 $ echo 'widest' > widest/f
25 25 $ hg add widest/f
26 26 $ hg commit -m 'add widest'
27 27
28 28 $ mkdir outside
29 29 $ echo 'outside' > outside/f
30 30 $ hg add outside/f
31 31 $ hg commit -m 'add outside'
32 32
33 33 $ cd ..
34 34
35 35 narrow clone the inside file
36 36
37 37 $ hg clone --narrow ssh://user@dummy/master narrow --include inside
38 38 requesting all changes
39 39 adding changesets
40 40 adding manifests
41 41 adding file changes
42 42 added 2 changesets with 1 changes to 1 files
43 43 new changesets *:* (glob)
44 44 updating to branch default
45 45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 46 $ cd narrow
47 47 $ hg tracked
48 48 I path:inside
49 49 $ ls
50 50 inside
51 51 $ cat inside/f
52 52 inside
53 53 $ cd ..
54 54
55 55 add more upstream files which we will include in a wider narrow spec
56 56
57 57 $ cd master
58 58
59 59 $ mkdir wider
60 60 $ echo 'wider' > wider/f
61 61 $ hg add wider/f
62 62 $ echo 'widest v2' > widest/f
63 63 $ hg commit -m 'add wider, update widest'
64 64
65 65 $ echo 'widest v3' > widest/f
66 66 $ hg commit -m 'update widest v3'
67 67
68 68 $ echo 'inside v2' > inside/f
69 69 $ hg commit -m 'update inside'
70 70
71 71 $ mkdir outside2
72 72 $ echo 'outside2' > outside2/f
73 73 $ hg add outside2/f
74 74 $ hg commit -m 'add outside2'
75 75
76 76 $ echo 'widest v4' > widest/f
77 77 $ hg commit -m 'update widest v4'
78 78
79 79 $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n"
80 80 7: update widest v4
81 81 6: add outside2
82 82 5: update inside
83 83 4: update widest v3
84 84 3: add wider, update widest
85 85 2: add outside
86 86 1: add widest
87 87 0: add inside
88 88
89 89 $ cd ..
90 90
91 91 Testing the --import-rules flag of `hg tracked` command
92 92
93 93 $ cd narrow
94 94 $ hg tracked --import-rules
95 95 hg tracked: option --import-rules requires argument
96 96 hg tracked [OPTIONS]... [REMOTE]
97 97
98 98 show or change the current narrowspec
99 99
100 100 options ([+] can be repeated):
101 101
102 102 --addinclude VALUE [+] new paths to include
103 103 --removeinclude VALUE [+] old paths to no longer include
104 104 --addexclude VALUE [+] new paths to exclude
105 105 --import-rules VALUE import narrowspecs from a file
106 106 --removeexclude VALUE [+] old paths to no longer exclude
107 107 --clear whether to replace the existing narrowspec
108 (default: off)
108 109 --force-delete-local-changes forces deletion of local changes when
109 narrowing
110 narrowing (default: off)
110 111 -e --ssh CMD specify ssh command to use
111 112 --remotecmd CMD specify hg command to run on the remote side
112 113 --insecure do not verify server certificate (ignoring
113 114 web.cacerts config)
114 115
115 116 (use 'hg tracked -h' to show more help)
116 117 [255]
117 118 $ hg tracked --import-rules doesnotexist
118 119 abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
119 120 [255]
120 121
121 122 $ cat > specs <<EOF
122 123 > %include foo
123 124 > [include]
124 125 > path:widest/
125 126 > [exclude]
126 127 > path:inside/
127 128 > EOF
128 129
129 130 $ hg tracked --import-rules specs
130 131 abort: including other spec files using '%include' is not supported in narrowspec
131 132 [255]
132 133
133 134 $ cat > specs <<EOF
134 135 > [include]
135 136 > outisde
136 137 > [exclude]
137 138 > inside
138 139 > EOF
139 140
140 141 $ hg tracked --import-rules specs
141 142 comparing with ssh://user@dummy/master
142 143 searching for changes
143 144 looking for local changes to affected paths
144 145 deleting data/inside/f.i
145 146 deleting meta/inside/00manifest.i (tree !)
146 147 no changes found
147 148 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
148 149 adding changesets
149 150 adding manifests
150 151 adding file changes
151 152 added 2 changesets with 0 changes to 0 files
152 153 new changesets *:* (glob)
153 154 $ hg tracked
154 155 I path:outisde
155 156 X path:inside
156 157
157 158 Testing the --import-rules flag with --addinclude and --addexclude
158 159
159 160 $ cat > specs <<EOF
160 161 > [include]
161 162 > widest
162 163 > EOF
163 164
164 165 $ hg tracked --import-rules specs --addinclude 'wider/'
165 166 comparing with ssh://user@dummy/master
166 167 searching for changes
167 168 no changes found
168 169 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
169 170 adding changesets
170 171 adding manifests
171 172 adding file changes
172 173 added 3 changesets with 1 changes to 1 files
173 174 new changesets *:* (glob)
174 175 $ hg tracked
175 176 I path:outisde
176 177 I path:wider
177 178 I path:widest
178 179 X path:inside
179 180
180 181 $ cat > specs <<EOF
181 182 > [exclude]
182 183 > outside2
183 184 > EOF
184 185
185 186 $ hg tracked --import-rules specs --addexclude 'widest'
186 187 comparing with ssh://user@dummy/master
187 188 searching for changes
188 189 looking for local changes to affected paths
189 190 deleting data/widest/f.i
190 191 deleting meta/widest/00manifest.i (tree !)
191 192 $ hg tracked
192 193 I path:outisde
193 194 I path:wider
194 195 X path:inside
195 196 X path:outside2
196 197 X path:widest
197 198
198 199 $ hg tracked --import-rules specs --clear
199 200 The --clear option is not yet supported.
200 201 [1]
201 202
202 203 Testing with passing a out of wdir file
203 204
204 205 $ cat > ../nspecs <<EOF
205 206 > [include]
206 207 > widest
207 208 > EOF
208 209
209 210 $ hg tracked --import-rules ../nspecs
210 211 comparing with ssh://user@dummy/master
211 212 searching for changes
212 213 no changes found
213 214 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob)
214 215 adding changesets
215 216 adding manifests
216 217 adding file changes
217 218 added 3 changesets with 0 changes to 0 files
218 219 new changesets *:* (glob)
@@ -1,1089 +1,1089 b''
1 1 #testcases stripbased phasebased
2 2
3 3 $ cat <<EOF >> $HGRCPATH
4 4 > [extensions]
5 5 > mq =
6 6 > shelve =
7 7 > [defaults]
8 8 > diff = --nodates --git
9 9 > qnew = --date '0 0'
10 10 > [shelve]
11 11 > maxbackups = 2
12 12 > EOF
13 13
14 14 #if phasebased
15 15
16 16 $ cat <<EOF >> $HGRCPATH
17 17 > [format]
18 18 > internal-phase = yes
19 19 > EOF
20 20
21 21 #endif
22 22
23 23 $ hg init repo
24 24 $ cd repo
25 25 $ mkdir a b
26 26 $ echo a > a/a
27 27 $ echo b > b/b
28 28 $ echo c > c
29 29 $ echo d > d
30 30 $ echo x > x
31 31 $ hg addremove -q
32 32
33 33 shelve has a help message
34 34 $ hg shelve -h
35 35 hg shelve [OPTION]... [FILE]...
36 36
37 37 save and set aside changes from the working directory
38 38
39 39 Shelving takes files that "hg status" reports as not clean, saves the
40 40 modifications to a bundle (a shelved change), and reverts the files so
41 41 that their state in the working directory becomes clean.
42 42
43 43 To restore these changes to the working directory, using "hg unshelve";
44 44 this will work even if you switch to a different commit.
45 45
46 46 When no files are specified, "hg shelve" saves all not-clean files. If
47 47 specific files or directories are named, only changes to those files are
48 48 shelved.
49 49
50 50 In bare shelve (when no files are specified, without interactive, include
51 51 and exclude option), shelving remembers information if the working
52 52 directory was on newly created branch, in other words working directory
53 53 was on different branch than its first parent. In this situation
54 54 unshelving restores branch information to the working directory.
55 55
56 56 Each shelved change has a name that makes it easier to find later. The
57 57 name of a shelved change defaults to being based on the active bookmark,
58 58 or if there is no active bookmark, the current named branch. To specify a
59 59 different name, use "--name".
60 60
61 61 To see a list of existing shelved changes, use the "--list" option. For
62 62 each shelved change, this will print its name, age, and description; use "
63 63 --patch" or "--stat" for more details.
64 64
65 65 To delete specific shelved changes, use "--delete". To delete all shelved
66 66 changes, use "--cleanup".
67 67
68 68 (use 'hg help -e shelve' to show help for the shelve extension)
69 69
70 70 options ([+] can be repeated):
71 71
72 72 -A --addremove mark new/missing files as added/removed before
73 73 shelving
74 74 -u --unknown store unknown files in the shelve
75 75 --cleanup delete all shelved changes
76 76 --date DATE shelve with the specified commit date
77 77 -d --delete delete the named shelved change(s)
78 -e --edit invoke editor on commit messages
78 -e --edit invoke editor on commit messages (default: off)
79 79 -l --list list current shelves
80 80 -m --message TEXT use text as shelve message
81 81 -n --name NAME use the given name for the shelved commit
82 82 -p --patch output patches for changes (provide the names of the
83 83 shelved changes as positional arguments)
84 84 -i --interactive interactive mode, only works while creating a shelve
85 85 --stat output diffstat-style summary of changes (provide
86 86 the names of the shelved changes as positional
87 87 arguments)
88 88 -I --include PATTERN [+] include names matching the given patterns
89 89 -X --exclude PATTERN [+] exclude names matching the given patterns
90 90 --mq operate on patch repository
91 91
92 92 (some details hidden, use --verbose to show complete help)
93 93
94 94 shelving in an empty repo should be possible
95 95 (this tests also that editor is not invoked, if '--edit' is not
96 96 specified)
97 97
98 98 $ HGEDITOR=cat hg shelve
99 99 shelved as default
100 100 0 files updated, 0 files merged, 5 files removed, 0 files unresolved
101 101
102 102 $ hg unshelve
103 103 unshelving change 'default'
104 104
105 105 $ hg commit -q -m 'initial commit'
106 106
107 107 $ hg shelve
108 108 nothing changed
109 109 [1]
110 110
111 111 make sure shelve files were backed up
112 112
113 113 $ ls .hg/shelve-backup
114 114 default.hg
115 115 default.patch
116 116 default.shelve
117 117
118 118 checks to make sure we dont create a directory or
119 119 hidden file while choosing a new shelve name
120 120
121 121 when we are given a name
122 122
123 123 $ hg shelve -n foo/bar
124 124 abort: shelved change names can not contain slashes
125 125 [255]
126 126 $ hg shelve -n .baz
127 127 abort: shelved change names can not start with '.'
128 128 [255]
129 129 $ hg shelve -n foo\\bar
130 130 abort: shelved change names can not contain slashes
131 131 [255]
132 132
133 133 when shelve has to choose itself
134 134
135 135 $ hg branch x/y -q
136 136 $ hg commit -q -m "Branch commit 0"
137 137 $ hg shelve
138 138 nothing changed
139 139 [1]
140 140 $ hg branch .x -q
141 141 $ hg commit -q -m "Branch commit 1"
142 142 $ hg shelve
143 143 nothing changed
144 144 [1]
145 145 $ hg branch x\\y -q
146 146 $ hg commit -q -m "Branch commit 2"
147 147 $ hg shelve
148 148 nothing changed
149 149 [1]
150 150
151 151 cleaning the branches made for name checking tests
152 152
153 153 $ hg up default -q
154 154 $ hg strip e9177275307e+6a6d231f43d+882bae7c62c2 -q
155 155
156 156 create an mq patch - shelving should work fine with a patch applied
157 157
158 158 $ echo n > n
159 159 $ hg add n
160 160 $ hg commit n -m second
161 161 $ hg qnew second.patch
162 162
163 163 shelve a change that we will delete later
164 164
165 165 $ echo a >> a/a
166 166 $ hg shelve
167 167 shelved as default
168 168 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 169
170 170 set up some more complex changes to shelve
171 171
172 172 $ echo a >> a/a
173 173 $ hg mv b b.rename
174 174 moving b/b to b.rename/b
175 175 $ hg cp c c.copy
176 176 $ hg status -C
177 177 M a/a
178 178 A b.rename/b
179 179 b/b
180 180 A c.copy
181 181 c
182 182 R b/b
183 183
184 184 the common case - no options or filenames
185 185
186 186 $ hg shelve
187 187 shelved as default-01
188 188 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
189 189 $ hg status -C
190 190
191 191 ensure that our shelved changes exist
192 192
193 193 $ hg shelve -l
194 194 default-01 (*)* changes to: [mq]: second.patch (glob)
195 195 default (*)* changes to: [mq]: second.patch (glob)
196 196
197 197 $ hg shelve -l -p default
198 198 default (*)* changes to: [mq]: second.patch (glob)
199 199
200 200 diff --git a/a/a b/a/a
201 201 --- a/a/a
202 202 +++ b/a/a
203 203 @@ -1,1 +1,2 @@
204 204 a
205 205 +a
206 206
207 207 $ hg shelve --list --addremove
208 208 abort: options '--list' and '--addremove' may not be used together
209 209 [255]
210 210
211 211 delete our older shelved change
212 212
213 213 $ hg shelve -d default
214 214 $ hg qfinish -a -q
215 215
216 216 ensure shelve backups aren't overwritten
217 217
218 218 $ ls .hg/shelve-backup/
219 219 default-1.hg
220 220 default-1.patch
221 221 default-1.shelve
222 222 default.hg
223 223 default.patch
224 224 default.shelve
225 225
226 226 local edits should not prevent a shelved change from applying
227 227
228 228 $ printf "z\na\n" > a/a
229 229 $ hg unshelve --keep
230 230 unshelving change 'default-01'
231 231 temporarily committing pending changes (restore with 'hg unshelve --abort')
232 232 rebasing shelved changes
233 233 merging a/a
234 234
235 235 $ hg revert --all -q
236 236 $ rm a/a.orig b.rename/b c.copy
237 237
238 238 apply it and make sure our state is as expected
239 239
240 240 (this also tests that same timestamp prevents backups from being
241 241 removed, even though there are more than 'maxbackups' backups)
242 242
243 243 $ f -t .hg/shelve-backup/default.patch
244 244 .hg/shelve-backup/default.patch: file
245 245 $ touch -t 200001010000 .hg/shelve-backup/default.patch
246 246 $ f -t .hg/shelve-backup/default-1.patch
247 247 .hg/shelve-backup/default-1.patch: file
248 248 $ touch -t 200001010000 .hg/shelve-backup/default-1.patch
249 249
250 250 $ hg unshelve
251 251 unshelving change 'default-01'
252 252 $ hg status -C
253 253 M a/a
254 254 A b.rename/b
255 255 b/b
256 256 A c.copy
257 257 c
258 258 R b/b
259 259 $ hg shelve -l
260 260
261 261 (both of default.hg and default-1.hg should be still kept, because it
262 262 is difficult to decide actual order of them from same timestamp)
263 263
264 264 $ ls .hg/shelve-backup/
265 265 default-01.hg
266 266 default-01.patch
267 267 default-01.shelve
268 268 default-1.hg
269 269 default-1.patch
270 270 default-1.shelve
271 271 default.hg
272 272 default.patch
273 273 default.shelve
274 274
275 275 $ hg unshelve
276 276 abort: no shelved changes to apply!
277 277 [255]
278 278 $ hg unshelve foo
279 279 abort: shelved change 'foo' not found
280 280 [255]
281 281
282 282 named shelves, specific filenames, and "commit messages" should all work
283 283 (this tests also that editor is invoked, if '--edit' is specified)
284 284
285 285 $ hg status -C
286 286 M a/a
287 287 A b.rename/b
288 288 b/b
289 289 A c.copy
290 290 c
291 291 R b/b
292 292 $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a
293 293 wat
294 294
295 295
296 296 HG: Enter commit message. Lines beginning with 'HG:' are removed.
297 297 HG: Leave message empty to abort commit.
298 298 HG: --
299 299 HG: user: shelve@localhost
300 300 HG: branch 'default'
301 301 HG: changed a/a
302 302
303 303 expect "a" to no longer be present, but status otherwise unchanged
304 304
305 305 $ hg status -C
306 306 A b.rename/b
307 307 b/b
308 308 A c.copy
309 309 c
310 310 R b/b
311 311 $ hg shelve -l --stat
312 312 wibble (*) wat (glob)
313 313 a/a | 1 +
314 314 1 files changed, 1 insertions(+), 0 deletions(-)
315 315
316 316 and now "a/a" should reappear
317 317
318 318 $ cd a
319 319 $ hg unshelve -q wibble
320 320 $ cd ..
321 321 $ hg status -C
322 322 M a/a
323 323 A b.rename/b
324 324 b/b
325 325 A c.copy
326 326 c
327 327 R b/b
328 328
329 329 ensure old shelve backups are being deleted automatically
330 330
331 331 $ ls .hg/shelve-backup/
332 332 default-01.hg
333 333 default-01.patch
334 334 default-01.shelve
335 335 wibble.hg
336 336 wibble.patch
337 337 wibble.shelve
338 338
339 339 cause unshelving to result in a merge with 'a' conflicting
340 340
341 341 $ hg shelve -q
342 342 $ echo c>>a/a
343 343 $ hg commit -m second
344 344 $ hg tip --template '{files}\n'
345 345 a/a
346 346
347 347 add an unrelated change that should be preserved
348 348
349 349 $ mkdir foo
350 350 $ echo foo > foo/foo
351 351 $ hg add foo/foo
352 352
353 353 force a conflicted merge to occur
354 354
355 355 $ hg unshelve
356 356 unshelving change 'default'
357 357 temporarily committing pending changes (restore with 'hg unshelve --abort')
358 358 rebasing shelved changes
359 359 merging a/a
360 360 warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
361 361 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
362 362 [1]
363 363 $ hg status -v
364 364 M a/a
365 365 M b.rename/b
366 366 M c.copy
367 367 R b/b
368 368 ? a/a.orig
369 369 # The repository is in an unfinished *unshelve* state.
370 370
371 371 # Unresolved merge conflicts:
372 372 #
373 373 # a/a
374 374 #
375 375 # To mark files as resolved: hg resolve --mark FILE
376 376
377 377 # To continue: hg unshelve --continue
378 378 # To abort: hg unshelve --abort
379 379
380 380
381 381 ensure that we have a merge with unresolved conflicts
382 382
383 383 #if phasebased
384 384 $ hg heads -q --template '{rev}\n'
385 385 8
386 386 5
387 387 $ hg parents -q --template '{rev}\n'
388 388 8
389 389 5
390 390 #endif
391 391
392 392 #if stripbased
393 393 $ hg heads -q --template '{rev}\n'
394 394 5
395 395 4
396 396 $ hg parents -q --template '{rev}\n'
397 397 4
398 398 5
399 399 #endif
400 400
401 401 $ hg status
402 402 M a/a
403 403 M b.rename/b
404 404 M c.copy
405 405 R b/b
406 406 ? a/a.orig
407 407 $ hg diff
408 408 diff --git a/a/a b/a/a
409 409 --- a/a/a
410 410 +++ b/a/a
411 411 @@ -1,2 +1,6 @@
412 412 a
413 413 +<<<<<<< shelve: 2377350b6337 - shelve: pending changes temporary commit
414 414 c
415 415 +=======
416 416 +a
417 417 +>>>>>>> working-copy: a68ec3400638 - shelve: changes to: [mq]: second.patch
418 418 diff --git a/b/b b/b.rename/b
419 419 rename from b/b
420 420 rename to b.rename/b
421 421 diff --git a/c b/c.copy
422 422 copy from c
423 423 copy to c.copy
424 424 $ hg resolve -l
425 425 U a/a
426 426
427 427 $ hg shelve
428 428 abort: unshelve already in progress
429 429 (use 'hg unshelve --continue' or 'hg unshelve --abort')
430 430 [255]
431 431
432 432 abort the unshelve and be happy
433 433
434 434 $ hg status
435 435 M a/a
436 436 M b.rename/b
437 437 M c.copy
438 438 R b/b
439 439 ? a/a.orig
440 440 $ hg unshelve -a
441 441 unshelve of 'default' aborted
442 442 $ hg heads -q
443 443 [37]:2e69b451d1ea (re)
444 444 $ hg parents
445 445 changeset: [37]:2e69b451d1ea (re)
446 446 tag: tip
447 447 parent: 3:509104101065 (?)
448 448 user: test
449 449 date: Thu Jan 01 00:00:00 1970 +0000
450 450 summary: second
451 451
452 452 $ hg resolve -l
453 453 $ hg status
454 454 A foo/foo
455 455 ? a/a.orig
456 456
457 457 try to continue with no unshelve underway
458 458
459 459 $ hg unshelve -c
460 460 abort: no unshelve in progress
461 461 [255]
462 462 $ hg status
463 463 A foo/foo
464 464 ? a/a.orig
465 465
466 466 redo the unshelve to get a conflict
467 467
468 468 $ hg unshelve -q
469 469 warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
470 470 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
471 471 [1]
472 472
473 473 attempt to continue
474 474
475 475 $ hg unshelve -c
476 476 abort: unresolved conflicts, can't continue
477 477 (see 'hg resolve', then 'hg unshelve --continue')
478 478 [255]
479 479
480 480 $ hg revert -r . a/a
481 481 $ hg resolve -m a/a
482 482 (no more unresolved files)
483 483 continue: hg unshelve --continue
484 484
485 485 $ hg commit -m 'commit while unshelve in progress'
486 486 abort: unshelve already in progress
487 487 (use 'hg unshelve --continue' or 'hg unshelve --abort')
488 488 [255]
489 489
490 490 $ hg graft --continue
491 491 abort: no graft in progress
492 492 (continue: hg unshelve --continue)
493 493 [255]
494 494 $ hg unshelve -c
495 495 unshelve of 'default' complete
496 496
497 497 ensure the repo is as we hope
498 498
499 499 $ hg parents
500 500 changeset: [37]:2e69b451d1ea (re)
501 501 tag: tip
502 502 parent: 3:509104101065 (?)
503 503 user: test
504 504 date: Thu Jan 01 00:00:00 1970 +0000
505 505 summary: second
506 506
507 507 $ hg heads -q
508 508 [37]:2e69b451d1ea (re)
509 509
510 510 $ hg status -C
511 511 A b.rename/b
512 512 b/b
513 513 A c.copy
514 514 c
515 515 A foo/foo
516 516 R b/b
517 517 ? a/a.orig
518 518
519 519 there should be no shelves left
520 520
521 521 $ hg shelve -l
522 522
523 523 #if execbit
524 524
525 525 ensure that metadata-only changes are shelved
526 526
527 527 $ chmod +x a/a
528 528 $ hg shelve -q -n execbit a/a
529 529 $ hg status a/a
530 530 $ hg unshelve -q execbit
531 531 $ hg status a/a
532 532 M a/a
533 533 $ hg revert a/a
534 534
535 535 #else
536 536
537 537 Dummy shelve op, to keep rev numbers aligned
538 538
539 539 $ echo foo > a/a
540 540 $ hg shelve -q -n dummy a/a
541 541 $ hg unshelve -q dummy
542 542 $ hg revert a/a
543 543
544 544 #endif
545 545
546 546 #if symlink
547 547
548 548 $ rm a/a
549 549 $ ln -s foo a/a
550 550 $ hg shelve -q -n symlink a/a
551 551 $ hg status a/a
552 552 $ hg unshelve -q -n symlink
553 553 $ hg status a/a
554 554 M a/a
555 555 $ hg revert a/a
556 556
557 557 #else
558 558
559 559 Dummy shelve op, to keep rev numbers aligned
560 560
561 561 $ echo bar > a/a
562 562 $ hg shelve -q -n dummy a/a
563 563 $ hg unshelve -q dummy
564 564 $ hg revert a/a
565 565
566 566 #endif
567 567
568 568 set up another conflict between a commit and a shelved change
569 569
570 570 $ hg revert -q -C -a
571 571 $ rm a/a.orig b.rename/b c.copy
572 572 $ echo a >> a/a
573 573 $ hg shelve -q
574 574 $ echo x >> a/a
575 575 $ hg ci -m 'create conflict'
576 576 $ hg add foo/foo
577 577
578 578 if we resolve a conflict while unshelving, the unshelve should succeed
579 579
580 580 $ hg unshelve --tool :merge-other --keep
581 581 unshelving change 'default'
582 582 temporarily committing pending changes (restore with 'hg unshelve --abort')
583 583 rebasing shelved changes
584 584 merging a/a
585 585 $ hg parents -q
586 586 (4|13):33f7f61e6c5e (re)
587 587 $ hg shelve -l
588 588 default (*)* changes to: second (glob)
589 589 $ hg status
590 590 M a/a
591 591 A foo/foo
592 592 $ cat a/a
593 593 a
594 594 c
595 595 a
596 596 $ cat > a/a << EOF
597 597 > a
598 598 > c
599 599 > x
600 600 > EOF
601 601
602 602 $ HGMERGE=true hg unshelve
603 603 unshelving change 'default'
604 604 temporarily committing pending changes (restore with 'hg unshelve --abort')
605 605 rebasing shelved changes
606 606 merging a/a
607 607 note: unshelved changes already existed in the working copy
608 608 $ hg parents -q
609 609 (4|13):33f7f61e6c5e (re)
610 610 $ hg shelve -l
611 611 $ hg status
612 612 A foo/foo
613 613 $ cat a/a
614 614 a
615 615 c
616 616 x
617 617
618 618 test keep and cleanup
619 619
620 620 $ hg shelve
621 621 shelved as default
622 622 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
623 623 $ hg shelve --list
624 624 default (*)* changes to: create conflict (glob)
625 625 $ hg unshelve -k
626 626 unshelving change 'default'
627 627 $ hg shelve --list
628 628 default (*)* changes to: create conflict (glob)
629 629 $ hg shelve --cleanup
630 630 $ hg shelve --list
631 631
632 632 $ hg shelve --cleanup --delete
633 633 abort: options '--cleanup' and '--delete' may not be used together
634 634 [255]
635 635 $ hg shelve --cleanup --patch
636 636 abort: options '--cleanup' and '--patch' may not be used together
637 637 [255]
638 638 $ hg shelve --cleanup --message MESSAGE
639 639 abort: options '--cleanup' and '--message' may not be used together
640 640 [255]
641 641
642 642 test bookmarks
643 643
644 644 $ hg bookmark test
645 645 $ hg bookmark
646 646 \* test (4|13):33f7f61e6c5e (re)
647 647 $ hg shelve
648 648 shelved as test
649 649 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
650 650 $ hg bookmark
651 651 \* test (4|13):33f7f61e6c5e (re)
652 652 $ hg unshelve
653 653 unshelving change 'test'
654 654 $ hg bookmark
655 655 \* test (4|13):33f7f61e6c5e (re)
656 656
657 657 shelve should still work even if mq is disabled
658 658
659 659 $ hg --config extensions.mq=! shelve
660 660 shelved as test
661 661 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
662 662 $ hg --config extensions.mq=! shelve --list
663 663 test (*)* changes to: create conflict (glob)
664 664 $ hg bookmark
665 665 \* test (4|13):33f7f61e6c5e (re)
666 666 $ hg --config extensions.mq=! unshelve
667 667 unshelving change 'test'
668 668 $ hg bookmark
669 669 \* test (4|13):33f7f61e6c5e (re)
670 670
671 671 Recreate some conflict again
672 672
673 673 $ hg up -C -r 2e69b451d1ea
674 674 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
675 675 (leaving bookmark test)
676 676 $ echo y >> a/a
677 677 $ hg shelve
678 678 shelved as default
679 679 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
680 680 $ hg up test
681 681 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
682 682 (activating bookmark test)
683 683 $ hg bookmark
684 684 \* test (4|13):33f7f61e6c5e (re)
685 685 $ hg unshelve
686 686 unshelving change 'default'
687 687 rebasing shelved changes
688 688 merging a/a
689 689 warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
690 690 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
691 691 [1]
692 692 $ hg bookmark
693 693 test (4|13):33f7f61e6c5e (re)
694 694
695 695 Test that resolving all conflicts in one direction (so that the rebase
696 696 is a no-op), works (issue4398)
697 697
698 698 $ hg revert -a -r .
699 699 reverting a/a
700 700 $ hg resolve -m a/a
701 701 (no more unresolved files)
702 702 continue: hg unshelve --continue
703 703 $ hg unshelve -c
704 704 note: unshelved changes already existed in the working copy
705 705 unshelve of 'default' complete
706 706 $ hg bookmark
707 707 \* test (4|13):33f7f61e6c5e (re)
708 708 $ hg diff
709 709 $ hg status
710 710 ? a/a.orig
711 711 ? foo/foo
712 712 $ hg summary
713 713 parent: (4|13):33f7f61e6c5e tip (re)
714 714 create conflict
715 715 branch: default
716 716 bookmarks: *test
717 717 commit: 2 unknown (clean)
718 718 update: (current)
719 719 phases: 5 draft
720 720
721 721 $ hg shelve --delete --stat
722 722 abort: options '--delete' and '--stat' may not be used together
723 723 [255]
724 724 $ hg shelve --delete --name NAME
725 725 abort: options '--delete' and '--name' may not be used together
726 726 [255]
727 727
728 728 Test interactive shelve
729 729 $ cat <<EOF >> $HGRCPATH
730 730 > [ui]
731 731 > interactive = true
732 732 > EOF
733 733 $ echo 'a' >> a/b
734 734 $ cat a/a >> a/b
735 735 $ echo 'x' >> a/b
736 736 $ mv a/b a/a
737 737 $ echo 'a' >> foo/foo
738 738 $ hg st
739 739 M a/a
740 740 ? a/a.orig
741 741 ? foo/foo
742 742 $ cat a/a
743 743 a
744 744 a
745 745 c
746 746 x
747 747 x
748 748 $ cat foo/foo
749 749 foo
750 750 a
751 751 $ hg shelve --interactive --config ui.interactive=false
752 752 abort: running non-interactively
753 753 [255]
754 754 $ hg shelve --interactive << EOF
755 755 > y
756 756 > y
757 757 > n
758 758 > EOF
759 759 diff --git a/a/a b/a/a
760 760 2 hunks, 2 lines changed
761 761 examine changes to 'a/a'? [Ynesfdaq?] y
762 762
763 763 @@ -1,3 +1,4 @@
764 764 +a
765 765 a
766 766 c
767 767 x
768 768 record change 1/2 to 'a/a'? [Ynesfdaq?] y
769 769
770 770 @@ -1,3 +2,4 @@
771 771 a
772 772 c
773 773 x
774 774 +x
775 775 record change 2/2 to 'a/a'? [Ynesfdaq?] n
776 776
777 777 shelved as test
778 778 merging a/a
779 779 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
780 780 $ cat a/a
781 781 a
782 782 c
783 783 x
784 784 x
785 785 $ cat foo/foo
786 786 foo
787 787 a
788 788 $ hg st
789 789 M a/a
790 790 ? foo/foo
791 791 $ hg bookmark
792 792 \* test (4|13):33f7f61e6c5e (re)
793 793 $ hg unshelve
794 794 unshelving change 'test'
795 795 temporarily committing pending changes (restore with 'hg unshelve --abort')
796 796 rebasing shelved changes
797 797 merging a/a
798 798 $ hg bookmark
799 799 \* test (4|13):33f7f61e6c5e (re)
800 800 $ cat a/a
801 801 a
802 802 a
803 803 c
804 804 x
805 805 x
806 806
807 807 shelve --patch and shelve --stat should work with valid shelfnames
808 808
809 809 $ hg up --clean .
810 810 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
811 811 (leaving bookmark test)
812 812 $ hg shelve --list
813 813 $ echo 'patch a' > shelf-patch-a
814 814 $ hg add shelf-patch-a
815 815 $ hg shelve
816 816 shelved as default
817 817 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
818 818 $ echo 'patch b' > shelf-patch-b
819 819 $ hg add shelf-patch-b
820 820 $ hg shelve
821 821 shelved as default-01
822 822 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
823 823 $ hg shelve --patch default default-01
824 824 default-01 (*)* changes to: create conflict (glob)
825 825
826 826 diff --git a/shelf-patch-b b/shelf-patch-b
827 827 new file mode 100644
828 828 --- /dev/null
829 829 +++ b/shelf-patch-b
830 830 @@ -0,0 +1,1 @@
831 831 +patch b
832 832 default (*)* changes to: create conflict (glob)
833 833
834 834 diff --git a/shelf-patch-a b/shelf-patch-a
835 835 new file mode 100644
836 836 --- /dev/null
837 837 +++ b/shelf-patch-a
838 838 @@ -0,0 +1,1 @@
839 839 +patch a
840 840 $ hg shelve --stat default default-01
841 841 default-01 (*)* changes to: create conflict (glob)
842 842 shelf-patch-b | 1 +
843 843 1 files changed, 1 insertions(+), 0 deletions(-)
844 844 default (*)* changes to: create conflict (glob)
845 845 shelf-patch-a | 1 +
846 846 1 files changed, 1 insertions(+), 0 deletions(-)
847 847 $ hg shelve --patch default
848 848 default (*)* changes to: create conflict (glob)
849 849
850 850 diff --git a/shelf-patch-a b/shelf-patch-a
851 851 new file mode 100644
852 852 --- /dev/null
853 853 +++ b/shelf-patch-a
854 854 @@ -0,0 +1,1 @@
855 855 +patch a
856 856 $ hg shelve --stat default
857 857 default (*)* changes to: create conflict (glob)
858 858 shelf-patch-a | 1 +
859 859 1 files changed, 1 insertions(+), 0 deletions(-)
860 860 $ hg shelve --patch nonexistentshelf
861 861 abort: cannot find shelf nonexistentshelf
862 862 [255]
863 863 $ hg shelve --stat nonexistentshelf
864 864 abort: cannot find shelf nonexistentshelf
865 865 [255]
866 866 $ hg shelve --patch default nonexistentshelf
867 867 abort: cannot find shelf nonexistentshelf
868 868 [255]
869 869
870 870 when the user asks for a patch, we assume they want the most recent shelve if
871 871 they don't provide a shelve name
872 872
873 873 $ hg shelve --patch
874 874 default-01 (*)* changes to: create conflict (glob)
875 875
876 876 diff --git a/shelf-patch-b b/shelf-patch-b
877 877 new file mode 100644
878 878 --- /dev/null
879 879 +++ b/shelf-patch-b
880 880 @@ -0,0 +1,1 @@
881 881 +patch b
882 882
883 883 $ cd ..
884 884
885 885 Shelve from general delta repo uses bundle2 on disk
886 886 --------------------------------------------------
887 887
888 888 no general delta
889 889
890 890 $ hg clone --pull repo bundle1 --config format.usegeneraldelta=0
891 891 requesting all changes
892 892 adding changesets
893 893 adding manifests
894 894 adding file changes
895 895 added 5 changesets with 8 changes to 6 files
896 896 new changesets cc01e2b0c59f:33f7f61e6c5e
897 897 updating to branch default
898 898 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
899 899 $ cd bundle1
900 900 $ echo babar > jungle
901 901 $ hg add jungle
902 902 $ hg shelve
903 903 shelved as default
904 904 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
905 905 $ hg debugbundle .hg/shelved/*.hg
906 906 330882a04d2ce8487636b1fb292e5beea77fa1e3
907 907 $ cd ..
908 908
909 909 with general delta
910 910
911 911 $ hg clone --pull repo bundle2 --config format.usegeneraldelta=1
912 912 requesting all changes
913 913 adding changesets
914 914 adding manifests
915 915 adding file changes
916 916 added 5 changesets with 8 changes to 6 files
917 917 new changesets cc01e2b0c59f:33f7f61e6c5e
918 918 updating to branch default
919 919 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
920 920 $ cd bundle2
921 921 $ echo babar > jungle
922 922 $ hg add jungle
923 923 $ hg shelve
924 924 shelved as default
925 925 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
926 926 $ hg debugbundle .hg/shelved/*.hg
927 927 Stream params: {Compression: BZ}
928 928 changegroup -- {nbchanges: 1, version: 02} (mandatory: True)
929 929 330882a04d2ce8487636b1fb292e5beea77fa1e3
930 930 $ cd ..
931 931
932 932 Test visibility of in-memory changes inside transaction to external hook
933 933 ------------------------------------------------------------------------
934 934
935 935 $ cd repo
936 936
937 937 $ echo xxxx >> x
938 938 $ hg commit -m "#5: changes to invoke rebase"
939 939
940 940 $ cat > $TESTTMP/checkvisibility.sh <<EOF
941 941 > echo "==== \$1:"
942 942 > hg parents --template "VISIBLE {rev}:{node|short}\n"
943 943 > # test that pending changes are hidden
944 944 > unset HG_PENDING
945 945 > hg parents --template "ACTUAL {rev}:{node|short}\n"
946 946 > echo "===="
947 947 > EOF
948 948
949 949 $ cat >> .hg/hgrc <<EOF
950 950 > [defaults]
951 951 > # to fix hash id of temporary revisions
952 952 > unshelve = --date '0 0'
953 953 > EOF
954 954
955 955 "hg unshelve" at REV5 implies steps below:
956 956
957 957 (1) commit changes in the working directory (REV6)
958 958 (2) unbundle shelved revision (REV7)
959 959 (3) rebase: merge REV7 into REV6 (REV6 => REV6, REV7)
960 960 (4) rebase: commit merged revision (REV8)
961 961 (5) rebase: update to REV6 (REV8 => REV6)
962 962 (6) update to REV5 (REV6 => REV5)
963 963 (7) abort transaction
964 964
965 965 == test visibility to external preupdate hook
966 966
967 967 $ cat >> .hg/hgrc <<EOF
968 968 > [hooks]
969 969 > preupdate.visibility = sh $TESTTMP/checkvisibility.sh preupdate
970 970 > EOF
971 971
972 972 $ echo nnnn >> n
973 973
974 974 $ sh $TESTTMP/checkvisibility.sh before-unshelving
975 975 ==== before-unshelving:
976 976 VISIBLE (5|19):703117a2acfb (re)
977 977 ACTUAL (5|19):703117a2acfb (re)
978 978 ====
979 979
980 980 $ hg unshelve --keep default
981 981 temporarily committing pending changes (restore with 'hg unshelve --abort')
982 982 rebasing shelved changes
983 983 ==== preupdate:
984 984 VISIBLE (6|20):54c00d20fb3f (re)
985 985 ACTUAL (5|19):703117a2acfb (re)
986 986 ====
987 987 ==== preupdate:
988 988 VISIBLE (8|21):8efe6f7537dc (re)
989 989 ACTUAL (5|19):703117a2acfb (re)
990 990 ====
991 991 ==== preupdate:
992 992 VISIBLE (6|20):54c00d20fb3f (re)
993 993 ACTUAL (5|19):703117a2acfb (re)
994 994 ====
995 995
996 996 $ cat >> .hg/hgrc <<EOF
997 997 > [hooks]
998 998 > preupdate.visibility =
999 999 > EOF
1000 1000
1001 1001 $ sh $TESTTMP/checkvisibility.sh after-unshelving
1002 1002 ==== after-unshelving:
1003 1003 VISIBLE (5|19):703117a2acfb (re)
1004 1004 ACTUAL (5|19):703117a2acfb (re)
1005 1005 ====
1006 1006
1007 1007 == test visibility to external update hook
1008 1008
1009 1009 $ hg update -q -C 703117a2acfb
1010 1010
1011 1011 $ cat >> .hg/hgrc <<EOF
1012 1012 > [hooks]
1013 1013 > update.visibility = sh $TESTTMP/checkvisibility.sh update
1014 1014 > EOF
1015 1015
1016 1016 $ echo nnnn >> n
1017 1017
1018 1018 $ sh $TESTTMP/checkvisibility.sh before-unshelving
1019 1019 ==== before-unshelving:
1020 1020 VISIBLE (5|19):703117a2acfb (re)
1021 1021 ACTUAL (5|19):703117a2acfb (re)
1022 1022 ====
1023 1023
1024 1024 $ hg unshelve --keep default
1025 1025 temporarily committing pending changes (restore with 'hg unshelve --abort')
1026 1026 rebasing shelved changes
1027 1027 ==== update:
1028 1028 VISIBLE (6|20):54c00d20fb3f (re)
1029 1029 VISIBLE 1?7:492ed9d705e5 (re)
1030 1030 ACTUAL (5|19):703117a2acfb (re)
1031 1031 ====
1032 1032 ==== update:
1033 1033 VISIBLE (6|20):54c00d20fb3f (re)
1034 1034 ACTUAL (5|19):703117a2acfb (re)
1035 1035 ====
1036 1036 ==== update:
1037 1037 VISIBLE (5|19):703117a2acfb (re)
1038 1038 ACTUAL (5|19):703117a2acfb (re)
1039 1039 ====
1040 1040
1041 1041 $ cat >> .hg/hgrc <<EOF
1042 1042 > [hooks]
1043 1043 > update.visibility =
1044 1044 > EOF
1045 1045
1046 1046 $ sh $TESTTMP/checkvisibility.sh after-unshelving
1047 1047 ==== after-unshelving:
1048 1048 VISIBLE (5|19):703117a2acfb (re)
1049 1049 ACTUAL (5|19):703117a2acfb (re)
1050 1050 ====
1051 1051
1052 1052 $ cd ..
1053 1053
1054 1054 Keep active bookmark while (un)shelving even on shared repo (issue4940)
1055 1055 -----------------------------------------------------------------------
1056 1056
1057 1057 $ cat <<EOF >> $HGRCPATH
1058 1058 > [extensions]
1059 1059 > share =
1060 1060 > EOF
1061 1061
1062 1062 $ hg bookmarks -R repo
1063 1063 test (4|13):33f7f61e6c5e (re)
1064 1064 $ hg share -B repo share
1065 1065 updating working directory
1066 1066 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
1067 1067 $ cd share
1068 1068
1069 1069 $ hg bookmarks
1070 1070 test (4|13):33f7f61e6c5e (re)
1071 1071 $ hg bookmarks foo
1072 1072 $ hg bookmarks
1073 1073 \* foo (5|19):703117a2acfb (re)
1074 1074 test (4|13):33f7f61e6c5e (re)
1075 1075 $ echo x >> x
1076 1076 $ hg shelve
1077 1077 shelved as foo
1078 1078 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1079 1079 $ hg bookmarks
1080 1080 \* foo (5|19):703117a2acfb (re)
1081 1081 test (4|13):33f7f61e6c5e (re)
1082 1082
1083 1083 $ hg unshelve
1084 1084 unshelving change 'foo'
1085 1085 $ hg bookmarks
1086 1086 \* foo (5|19):703117a2acfb (re)
1087 1087 test (4|13):33f7f61e6c5e (re)
1088 1088
1089 1089 $ cd ..
@@ -1,400 +1,401 b''
1 1 Test uncommit - set up the config
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [experimental]
5 5 > evolution.createmarkers=True
6 6 > evolution.allowunstable=True
7 7 > [extensions]
8 8 > uncommit =
9 9 > drawdag=$TESTDIR/drawdag.py
10 10 > EOF
11 11
12 12 Build up a repo
13 13
14 14 $ hg init repo
15 15 $ cd repo
16 16 $ hg bookmark foo
17 17
18 18 Help for uncommit
19 19
20 20 $ hg help uncommit
21 21 hg uncommit [OPTION]... [FILE]...
22 22
23 23 uncommit part or all of a local changeset
24 24
25 25 This command undoes the effect of a local commit, returning the affected
26 26 files to their uncommitted state. This means that files modified or
27 27 deleted in the changeset will be left unchanged, and so will remain
28 28 modified in the working directory.
29 29
30 30 If no files are specified, the commit will be pruned, unless --keep is
31 31 given.
32 32
33 33 (use 'hg help -e uncommit' to show help for the uncommit extension)
34 34
35 35 options ([+] can be repeated):
36 36
37 --keep allow an empty commit after uncommiting
37 --keep allow an empty commit after uncommiting (default:
38 off)
38 39 -I --include PATTERN [+] include names matching the given patterns
39 40 -X --exclude PATTERN [+] exclude names matching the given patterns
40 41
41 42 (some details hidden, use --verbose to show complete help)
42 43
43 44 Uncommit with no commits should fail
44 45
45 46 $ hg uncommit
46 47 abort: cannot uncommit null changeset
47 48 (no changeset checked out)
48 49 [255]
49 50
50 51 Create some commits
51 52
52 53 $ touch files
53 54 $ hg add files
54 55 $ for i in a ab abc abcd abcde; do echo $i > files; echo $i > file-$i; hg add file-$i; hg commit -m "added file-$i"; done
55 56 $ ls
56 57 file-a
57 58 file-ab
58 59 file-abc
59 60 file-abcd
60 61 file-abcde
61 62 files
62 63
63 64 $ hg log -G -T '{rev}:{node} {desc}' --hidden
64 65 @ 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
65 66 |
66 67 o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
67 68 |
68 69 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
69 70 |
70 71 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
71 72 |
72 73 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
73 74
74 75 Simple uncommit off the top, also moves bookmark
75 76
76 77 $ hg bookmark
77 78 * foo 4:6c4fd43ed714
78 79 $ hg uncommit
79 80 $ hg status
80 81 M files
81 82 A file-abcde
82 83 $ hg bookmark
83 84 * foo 3:6db330d65db4
84 85
85 86 $ hg log -G -T '{rev}:{node} {desc}' --hidden
86 87 x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
87 88 |
88 89 @ 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
89 90 |
90 91 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
91 92 |
92 93 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
93 94 |
94 95 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
95 96
96 97
97 98 Recommit
98 99
99 100 $ hg commit -m 'new change abcde'
100 101 $ hg status
101 102 $ hg heads -T '{rev}:{node} {desc}'
102 103 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol)
103 104
104 105 Uncommit of non-existent and unchanged files has no effect
105 106 $ hg uncommit nothinghere
106 107 nothing to uncommit
107 108 [1]
108 109 $ hg status
109 110 $ hg uncommit file-abc
110 111 nothing to uncommit
111 112 [1]
112 113 $ hg status
113 114
114 115 Try partial uncommit, also moves bookmark
115 116
116 117 $ hg bookmark
117 118 * foo 5:0c07a3ccda77
118 119 $ hg uncommit files
119 120 $ hg status
120 121 M files
121 122 $ hg bookmark
122 123 * foo 6:3727deee06f7
123 124 $ hg heads -T '{rev}:{node} {desc}'
124 125 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol)
125 126 $ hg log -r . -p -T '{rev}:{node} {desc}'
126 127 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 6db330d65db4 -r 3727deee06f7 file-abcde
127 128 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
128 129 +++ b/file-abcde Thu Jan 01 00:00:00 1970 +0000
129 130 @@ -0,0 +1,1 @@
130 131 +abcde
131 132
132 133 $ hg log -G -T '{rev}:{node} {desc}' --hidden
133 134 @ 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
134 135 |
135 136 | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
136 137 |/
137 138 | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
138 139 |/
139 140 o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
140 141 |
141 142 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
142 143 |
143 144 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
144 145 |
145 146 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
146 147
147 148 $ hg commit -m 'update files for abcde'
148 149
149 150 Uncommit with dirty state
150 151
151 152 $ echo "foo" >> files
152 153 $ cat files
153 154 abcde
154 155 foo
155 156 $ hg status
156 157 M files
157 158 $ hg uncommit
158 159 abort: uncommitted changes
159 160 [255]
160 161 $ hg uncommit files
161 162 $ cat files
162 163 abcde
163 164 foo
164 165 $ hg commit --amend -m "files abcde + foo"
165 166
166 167 Testing the 'experimental.uncommitondirtywdir' config
167 168
168 169 $ echo "bar" >> files
169 170 $ hg uncommit
170 171 abort: uncommitted changes
171 172 [255]
172 173 $ hg uncommit --config experimental.uncommitondirtywdir=True
173 174 $ hg commit -m "files abcde + foo"
174 175
175 176 Uncommit in the middle of a stack, does not move bookmark
176 177
177 178 $ hg checkout '.^^^'
178 179 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
179 180 (leaving bookmark foo)
180 181 $ hg log -r . -p -T '{rev}:{node} {desc}'
181 182 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc
182 183 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
183 184 +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000
184 185 @@ -0,0 +1,1 @@
185 186 +abc
186 187 diff -r 69a232e754b0 -r abf2df566fc1 files
187 188 --- a/files Thu Jan 01 00:00:00 1970 +0000
188 189 +++ b/files Thu Jan 01 00:00:00 1970 +0000
189 190 @@ -1,1 +1,1 @@
190 191 -ab
191 192 +abc
192 193
193 194 $ hg bookmark
194 195 foo 10:48e5bd7cd583
195 196 $ hg uncommit
196 197 3 new orphan changesets
197 198 $ hg status
198 199 M files
199 200 A file-abc
200 201 $ hg heads -T '{rev}:{node} {desc}'
201 202 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol)
202 203 $ hg bookmark
203 204 foo 10:48e5bd7cd583
204 205 $ hg commit -m 'new abc'
205 206 created new head
206 207
207 208 Partial uncommit in the middle, does not move bookmark
208 209
209 210 $ hg checkout '.^'
210 211 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
211 212 $ hg log -r . -p -T '{rev}:{node} {desc}'
212 213 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab
213 214 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
214 215 +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000
215 216 @@ -0,0 +1,1 @@
216 217 +ab
217 218 diff -r 3004d2d9b508 -r 69a232e754b0 files
218 219 --- a/files Thu Jan 01 00:00:00 1970 +0000
219 220 +++ b/files Thu Jan 01 00:00:00 1970 +0000
220 221 @@ -1,1 +1,1 @@
221 222 -a
222 223 +ab
223 224
224 225 $ hg bookmark
225 226 foo 10:48e5bd7cd583
226 227 $ hg uncommit file-ab
227 228 1 new orphan changesets
228 229 $ hg status
229 230 A file-ab
230 231
231 232 $ hg heads -T '{rev}:{node} {desc}\n'
232 233 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
233 234 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
234 235 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
235 236
236 237 $ hg bookmark
237 238 foo 10:48e5bd7cd583
238 239 $ hg commit -m 'update ab'
239 240 $ hg status
240 241 $ hg heads -T '{rev}:{node} {desc}\n'
241 242 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
242 243 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
243 244 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
244 245
245 246 $ hg log -G -T '{rev}:{node} {desc}' --hidden
246 247 @ 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
247 248 |
248 249 o 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
249 250 |
250 251 | * 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
251 252 | |
252 253 | | * 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
253 254 | | |
254 255 | | | x 9:8a6b58c173ca6a2e3745d8bd86698718d664bc6c files abcde + foo
255 256 | | |/
256 257 | | | x 8:39ad452c7f684a55d161c574340c5766c4569278 update files for abcde
257 258 | | |/
258 259 | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde
259 260 | | |/
260 261 | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
261 262 | | |
262 263 | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
263 264 | | |/
264 265 | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
265 266 | | |/
266 267 | | * 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
267 268 | | |
268 269 | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
269 270 | |/
270 271 | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
271 272 |/
272 273 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
273 274
274 275 Uncommit with draft parent
275 276
276 277 $ hg uncommit
277 278 $ hg phase -r .
278 279 12: draft
279 280 $ hg commit -m 'update ab again'
280 281
281 282 Phase is preserved
282 283
283 284 $ hg uncommit --keep --config phases.new-commit=secret
284 285 $ hg phase -r .
285 286 15: draft
286 287 $ hg commit --amend -m 'update ab again'
287 288
288 289 Uncommit with public parent
289 290
290 291 $ hg phase -p "::.^"
291 292 $ hg uncommit
292 293 $ hg phase -r .
293 294 12: public
294 295
295 296 Partial uncommit with public parent
296 297
297 298 $ echo xyz > xyz
298 299 $ hg add xyz
299 300 $ hg commit -m "update ab and add xyz"
300 301 $ hg uncommit xyz
301 302 $ hg status
302 303 A xyz
303 304 $ hg phase -r .
304 305 18: draft
305 306 $ hg phase -r ".^"
306 307 12: public
307 308
308 309 Uncommit leaving an empty changeset
309 310
310 311 $ cd $TESTTMP
311 312 $ hg init repo1
312 313 $ cd repo1
313 314 $ hg debugdrawdag <<'EOS'
314 315 > Q
315 316 > |
316 317 > P
317 318 > EOS
318 319 $ hg up Q -q
319 320 $ hg uncommit --keep
320 321 $ hg log -G -T '{desc} FILES: {files}'
321 322 @ Q FILES:
322 323 |
323 324 | x Q FILES: Q
324 325 |/
325 326 o P FILES: P
326 327
327 328 $ hg status
328 329 A Q
329 330
330 331 $ cd ..
331 332 $ rm -rf repo1
332 333
333 334 Testing uncommit while merge
334 335
335 336 $ hg init repo2
336 337 $ cd repo2
337 338
338 339 Create some history
339 340
340 341 $ touch a
341 342 $ hg add a
342 343 $ for i in 1 2 3; do echo $i > a; hg commit -m "a $i"; done
343 344 $ hg checkout 0
344 345 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
345 346 $ touch b
346 347 $ hg add b
347 348 $ for i in 1 2 3; do echo $i > b; hg commit -m "b $i"; done
348 349 created new head
349 350 $ hg log -G -T '{rev}:{node} {desc}' --hidden
350 351 @ 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3
351 352 |
352 353 o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2
353 354 |
354 355 o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1
355 356 |
356 357 | o 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3
357 358 | |
358 359 | o 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2
359 360 |/
360 361 o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
361 362
362 363
363 364 Add and expect uncommit to fail on both merge working dir and merge changeset
364 365
365 366 $ hg merge 2
366 367 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
367 368 (branch merge, don't forget to commit)
368 369
369 370 $ hg uncommit
370 371 abort: outstanding uncommitted merge
371 372 [255]
372 373
373 374 $ hg uncommit --config experimental.uncommitondirtywdir=True
374 375 abort: cannot uncommit while merging
375 376 [255]
376 377
377 378 $ hg status
378 379 M a
379 380 $ hg commit -m 'merge a and b'
380 381
381 382 $ hg uncommit
382 383 abort: cannot uncommit merge changeset
383 384 [255]
384 385
385 386 $ hg status
386 387 $ hg log -G -T '{rev}:{node} {desc}' --hidden
387 388 @ 6:c03b9c37bc67bf504d4912061cfb527b47a63c6e merge a and b
388 389 |\
389 390 | o 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3
390 391 | |
391 392 | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2
392 393 | |
393 394 | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1
394 395 | |
395 396 o | 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3
396 397 | |
397 398 o | 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2
398 399 |/
399 400 o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
400 401
General Comments 0
You need to be logged in to leave comments. Login now