##// END OF EJS Templates
help: normalize extension shadow hint
Matt Mackall -
r22112:d968f474 default
parent child Browse files
Show More
@@ -1,513 +1,513 b''
1 # help.py - help data for mercurial
1 # help.py - help data for mercurial
2 #
2 #
3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import gettext, _
8 from i18n import gettext, _
9 import itertools, sys, os
9 import itertools, sys, os
10 import error
10 import error
11 import extensions, revset, fileset, templatekw, templatefilters, filemerge
11 import extensions, revset, fileset, templatekw, templatefilters, filemerge
12 import encoding, util, minirst
12 import encoding, util, minirst
13 import cmdutil
13 import cmdutil
14
14
15 def listexts(header, exts, indent=1, showdeprecated=False):
15 def listexts(header, exts, indent=1, showdeprecated=False):
16 '''return a text listing of the given extensions'''
16 '''return a text listing of the given extensions'''
17 rst = []
17 rst = []
18 if exts:
18 if exts:
19 rst.append('\n%s\n\n' % header)
19 rst.append('\n%s\n\n' % header)
20 for name, desc in sorted(exts.iteritems()):
20 for name, desc in sorted(exts.iteritems()):
21 if '(DEPRECATED)' in desc and not showdeprecated:
21 if '(DEPRECATED)' in desc and not showdeprecated:
22 continue
22 continue
23 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
23 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
24 return rst
24 return rst
25
25
26 def extshelp():
26 def extshelp():
27 rst = loaddoc('extensions')().splitlines(True)
27 rst = loaddoc('extensions')().splitlines(True)
28 rst.extend(listexts(
28 rst.extend(listexts(
29 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
29 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
30 rst.extend(listexts(_('disabled extensions:'), extensions.disabled()))
30 rst.extend(listexts(_('disabled extensions:'), extensions.disabled()))
31 doc = ''.join(rst)
31 doc = ''.join(rst)
32 return doc
32 return doc
33
33
34 def optrst(options, verbose):
34 def optrst(options, verbose):
35 data = []
35 data = []
36 multioccur = False
36 multioccur = False
37 for option in options:
37 for option in options:
38 if len(option) == 5:
38 if len(option) == 5:
39 shortopt, longopt, default, desc, optlabel = option
39 shortopt, longopt, default, desc, optlabel = option
40 else:
40 else:
41 shortopt, longopt, default, desc = option
41 shortopt, longopt, default, desc = option
42 optlabel = _("VALUE") # default label
42 optlabel = _("VALUE") # default label
43
43
44 if not verbose and ("DEPRECATED" in desc or _("DEPRECATED") in desc):
44 if not verbose and ("DEPRECATED" in desc or _("DEPRECATED") in desc):
45 continue
45 continue
46
46
47 so = ''
47 so = ''
48 if shortopt:
48 if shortopt:
49 so = '-' + shortopt
49 so = '-' + shortopt
50 lo = '--' + longopt
50 lo = '--' + longopt
51 if default:
51 if default:
52 desc += _(" (default: %s)") % default
52 desc += _(" (default: %s)") % default
53
53
54 if isinstance(default, list):
54 if isinstance(default, list):
55 lo += " %s [+]" % optlabel
55 lo += " %s [+]" % optlabel
56 multioccur = True
56 multioccur = True
57 elif (default is not None) and not isinstance(default, bool):
57 elif (default is not None) and not isinstance(default, bool):
58 lo += " %s" % optlabel
58 lo += " %s" % optlabel
59
59
60 data.append((so, lo, desc))
60 data.append((so, lo, desc))
61
61
62 rst = minirst.maketable(data, 1)
62 rst = minirst.maketable(data, 1)
63
63
64 if multioccur:
64 if multioccur:
65 rst.append(_("\n[+] marked option can be specified multiple times\n"))
65 rst.append(_("\n[+] marked option can be specified multiple times\n"))
66
66
67 return ''.join(rst)
67 return ''.join(rst)
68
68
69 def indicateomitted(rst, omitted, notomitted=None):
69 def indicateomitted(rst, omitted, notomitted=None):
70 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
70 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
71 if notomitted:
71 if notomitted:
72 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
72 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
73
73
74 def topicmatch(kw):
74 def topicmatch(kw):
75 """Return help topics matching kw.
75 """Return help topics matching kw.
76
76
77 Returns {'section': [(name, summary), ...], ...} where section is
77 Returns {'section': [(name, summary), ...], ...} where section is
78 one of topics, commands, extensions, or extensioncommands.
78 one of topics, commands, extensions, or extensioncommands.
79 """
79 """
80 kw = encoding.lower(kw)
80 kw = encoding.lower(kw)
81 def lowercontains(container):
81 def lowercontains(container):
82 return kw in encoding.lower(container) # translated in helptable
82 return kw in encoding.lower(container) # translated in helptable
83 results = {'topics': [],
83 results = {'topics': [],
84 'commands': [],
84 'commands': [],
85 'extensions': [],
85 'extensions': [],
86 'extensioncommands': [],
86 'extensioncommands': [],
87 }
87 }
88 for names, header, doc in helptable:
88 for names, header, doc in helptable:
89 if (sum(map(lowercontains, names))
89 if (sum(map(lowercontains, names))
90 or lowercontains(header)
90 or lowercontains(header)
91 or lowercontains(doc())):
91 or lowercontains(doc())):
92 results['topics'].append((names[0], header))
92 results['topics'].append((names[0], header))
93 import commands # avoid cycle
93 import commands # avoid cycle
94 for cmd, entry in commands.table.iteritems():
94 for cmd, entry in commands.table.iteritems():
95 if len(entry) == 3:
95 if len(entry) == 3:
96 summary = entry[2]
96 summary = entry[2]
97 else:
97 else:
98 summary = ''
98 summary = ''
99 # translate docs *before* searching there
99 # translate docs *before* searching there
100 docs = _(getattr(entry[0], '__doc__', None)) or ''
100 docs = _(getattr(entry[0], '__doc__', None)) or ''
101 if kw in cmd or lowercontains(summary) or lowercontains(docs):
101 if kw in cmd or lowercontains(summary) or lowercontains(docs):
102 doclines = docs.splitlines()
102 doclines = docs.splitlines()
103 if doclines:
103 if doclines:
104 summary = doclines[0]
104 summary = doclines[0]
105 cmdname = cmd.split('|')[0].lstrip('^')
105 cmdname = cmd.split('|')[0].lstrip('^')
106 results['commands'].append((cmdname, summary))
106 results['commands'].append((cmdname, summary))
107 for name, docs in itertools.chain(
107 for name, docs in itertools.chain(
108 extensions.enabled(False).iteritems(),
108 extensions.enabled(False).iteritems(),
109 extensions.disabled().iteritems()):
109 extensions.disabled().iteritems()):
110 # extensions.load ignores the UI argument
110 # extensions.load ignores the UI argument
111 mod = extensions.load(None, name, '')
111 mod = extensions.load(None, name, '')
112 name = name.split('.')[-1]
112 name = name.split('.')[-1]
113 if lowercontains(name) or lowercontains(docs):
113 if lowercontains(name) or lowercontains(docs):
114 # extension docs are already translated
114 # extension docs are already translated
115 results['extensions'].append((name, docs.splitlines()[0]))
115 results['extensions'].append((name, docs.splitlines()[0]))
116 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
116 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
117 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
117 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
118 cmdname = cmd.split('|')[0].lstrip('^')
118 cmdname = cmd.split('|')[0].lstrip('^')
119 if entry[0].__doc__:
119 if entry[0].__doc__:
120 cmddoc = gettext(entry[0].__doc__).splitlines()[0]
120 cmddoc = gettext(entry[0].__doc__).splitlines()[0]
121 else:
121 else:
122 cmddoc = _('(no help text available)')
122 cmddoc = _('(no help text available)')
123 results['extensioncommands'].append((cmdname, cmddoc))
123 results['extensioncommands'].append((cmdname, cmddoc))
124 return results
124 return results
125
125
126 def loaddoc(topic):
126 def loaddoc(topic):
127 """Return a delayed loader for help/topic.txt."""
127 """Return a delayed loader for help/topic.txt."""
128
128
129 def loader():
129 def loader():
130 if util.mainfrozen():
130 if util.mainfrozen():
131 module = sys.executable
131 module = sys.executable
132 else:
132 else:
133 module = __file__
133 module = __file__
134 base = os.path.dirname(module)
134 base = os.path.dirname(module)
135
135
136 for dir in ('.', '..'):
136 for dir in ('.', '..'):
137 docdir = os.path.join(base, dir, 'help')
137 docdir = os.path.join(base, dir, 'help')
138 if os.path.isdir(docdir):
138 if os.path.isdir(docdir):
139 break
139 break
140
140
141 path = os.path.join(docdir, topic + ".txt")
141 path = os.path.join(docdir, topic + ".txt")
142 doc = gettext(util.readfile(path))
142 doc = gettext(util.readfile(path))
143 for rewriter in helphooks.get(topic, []):
143 for rewriter in helphooks.get(topic, []):
144 doc = rewriter(topic, doc)
144 doc = rewriter(topic, doc)
145 return doc
145 return doc
146
146
147 return loader
147 return loader
148
148
149 helptable = sorted([
149 helptable = sorted([
150 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
150 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
151 (["dates"], _("Date Formats"), loaddoc('dates')),
151 (["dates"], _("Date Formats"), loaddoc('dates')),
152 (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
152 (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
153 (['environment', 'env'], _('Environment Variables'),
153 (['environment', 'env'], _('Environment Variables'),
154 loaddoc('environment')),
154 loaddoc('environment')),
155 (['revisions', 'revs'], _('Specifying Single Revisions'),
155 (['revisions', 'revs'], _('Specifying Single Revisions'),
156 loaddoc('revisions')),
156 loaddoc('revisions')),
157 (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'),
157 (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'),
158 loaddoc('multirevs')),
158 loaddoc('multirevs')),
159 (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')),
159 (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')),
160 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')),
160 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')),
161 (['diffs'], _('Diff Formats'), loaddoc('diffs')),
161 (['diffs'], _('Diff Formats'), loaddoc('diffs')),
162 (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')),
162 (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')),
163 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
163 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
164 loaddoc('templates')),
164 loaddoc('templates')),
165 (['urls'], _('URL Paths'), loaddoc('urls')),
165 (['urls'], _('URL Paths'), loaddoc('urls')),
166 (["extensions"], _("Using Additional Features"), extshelp),
166 (["extensions"], _("Using Additional Features"), extshelp),
167 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')),
167 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')),
168 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
168 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
169 (["glossary"], _("Glossary"), loaddoc('glossary')),
169 (["glossary"], _("Glossary"), loaddoc('glossary')),
170 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
170 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
171 loaddoc('hgignore')),
171 loaddoc('hgignore')),
172 (["phases"], _("Working with Phases"), loaddoc('phases')),
172 (["phases"], _("Working with Phases"), loaddoc('phases')),
173 ])
173 ])
174
174
175 # Map topics to lists of callable taking the current topic help and
175 # Map topics to lists of callable taking the current topic help and
176 # returning the updated version
176 # returning the updated version
177 helphooks = {}
177 helphooks = {}
178
178
179 def addtopichook(topic, rewriter):
179 def addtopichook(topic, rewriter):
180 helphooks.setdefault(topic, []).append(rewriter)
180 helphooks.setdefault(topic, []).append(rewriter)
181
181
182 def makeitemsdoc(topic, doc, marker, items):
182 def makeitemsdoc(topic, doc, marker, items):
183 """Extract docstring from the items key to function mapping, build a
183 """Extract docstring from the items key to function mapping, build a
184 .single documentation block and use it to overwrite the marker in doc
184 .single documentation block and use it to overwrite the marker in doc
185 """
185 """
186 entries = []
186 entries = []
187 for name in sorted(items):
187 for name in sorted(items):
188 text = (items[name].__doc__ or '').rstrip()
188 text = (items[name].__doc__ or '').rstrip()
189 if not text:
189 if not text:
190 continue
190 continue
191 text = gettext(text)
191 text = gettext(text)
192 lines = text.splitlines()
192 lines = text.splitlines()
193 doclines = [(lines[0])]
193 doclines = [(lines[0])]
194 for l in lines[1:]:
194 for l in lines[1:]:
195 # Stop once we find some Python doctest
195 # Stop once we find some Python doctest
196 if l.strip().startswith('>>>'):
196 if l.strip().startswith('>>>'):
197 break
197 break
198 doclines.append(' ' + l.strip())
198 doclines.append(' ' + l.strip())
199 entries.append('\n'.join(doclines))
199 entries.append('\n'.join(doclines))
200 entries = '\n\n'.join(entries)
200 entries = '\n\n'.join(entries)
201 return doc.replace(marker, entries)
201 return doc.replace(marker, entries)
202
202
203 def addtopicsymbols(topic, marker, symbols):
203 def addtopicsymbols(topic, marker, symbols):
204 def add(topic, doc):
204 def add(topic, doc):
205 return makeitemsdoc(topic, doc, marker, symbols)
205 return makeitemsdoc(topic, doc, marker, symbols)
206 addtopichook(topic, add)
206 addtopichook(topic, add)
207
207
208 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
208 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
209 addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
209 addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
210 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
210 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
211 addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords)
211 addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords)
212 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
212 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
213
213
214 def help_(ui, name, unknowncmd=False, full=True, **opts):
214 def help_(ui, name, unknowncmd=False, full=True, **opts):
215 '''
215 '''
216 Generate the help for 'name' as unformatted restructured text. If
216 Generate the help for 'name' as unformatted restructured text. If
217 'name' is None, describe the commands available.
217 'name' is None, describe the commands available.
218 '''
218 '''
219
219
220 import commands # avoid cycle
220 import commands # avoid cycle
221
221
222 def helpcmd(name):
222 def helpcmd(name):
223 try:
223 try:
224 aliases, entry = cmdutil.findcmd(name, commands.table,
224 aliases, entry = cmdutil.findcmd(name, commands.table,
225 strict=unknowncmd)
225 strict=unknowncmd)
226 except error.AmbiguousCommand, inst:
226 except error.AmbiguousCommand, inst:
227 # py3k fix: except vars can't be used outside the scope of the
227 # py3k fix: except vars can't be used outside the scope of the
228 # except block, nor can be used inside a lambda. python issue4617
228 # except block, nor can be used inside a lambda. python issue4617
229 prefix = inst.args[0]
229 prefix = inst.args[0]
230 select = lambda c: c.lstrip('^').startswith(prefix)
230 select = lambda c: c.lstrip('^').startswith(prefix)
231 rst = helplist(select)
231 rst = helplist(select)
232 return rst
232 return rst
233
233
234 rst = []
234 rst = []
235
235
236 # check if it's an invalid alias and display its error if it is
236 # check if it's an invalid alias and display its error if it is
237 if getattr(entry[0], 'badalias', False):
237 if getattr(entry[0], 'badalias', False):
238 if not unknowncmd:
238 if not unknowncmd:
239 ui.pushbuffer()
239 ui.pushbuffer()
240 entry[0](ui)
240 entry[0](ui)
241 rst.append(ui.popbuffer())
241 rst.append(ui.popbuffer())
242 return rst
242 return rst
243
243
244 # synopsis
244 # synopsis
245 if len(entry) > 2:
245 if len(entry) > 2:
246 if entry[2].startswith('hg'):
246 if entry[2].startswith('hg'):
247 rst.append("%s\n" % entry[2])
247 rst.append("%s\n" % entry[2])
248 else:
248 else:
249 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
249 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
250 else:
250 else:
251 rst.append('hg %s\n' % aliases[0])
251 rst.append('hg %s\n' % aliases[0])
252 # aliases
252 # aliases
253 if full and not ui.quiet and len(aliases) > 1:
253 if full and not ui.quiet and len(aliases) > 1:
254 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
254 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
255 rst.append('\n')
255 rst.append('\n')
256
256
257 # description
257 # description
258 doc = gettext(entry[0].__doc__)
258 doc = gettext(entry[0].__doc__)
259 if not doc:
259 if not doc:
260 doc = _("(no help text available)")
260 doc = _("(no help text available)")
261 if util.safehasattr(entry[0], 'definition'): # aliased command
261 if util.safehasattr(entry[0], 'definition'): # aliased command
262 if entry[0].definition.startswith('!'): # shell alias
262 if entry[0].definition.startswith('!'): # shell alias
263 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
263 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
264 else:
264 else:
265 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
265 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
266 doc = doc.splitlines(True)
266 doc = doc.splitlines(True)
267 if ui.quiet or not full:
267 if ui.quiet or not full:
268 rst.append(doc[0])
268 rst.append(doc[0])
269 else:
269 else:
270 rst.extend(doc)
270 rst.extend(doc)
271 rst.append('\n')
271 rst.append('\n')
272
272
273 # check if this command shadows a non-trivial (multi-line)
273 # check if this command shadows a non-trivial (multi-line)
274 # extension help text
274 # extension help text
275 try:
275 try:
276 mod = extensions.find(name)
276 mod = extensions.find(name)
277 doc = gettext(mod.__doc__) or ''
277 doc = gettext(mod.__doc__) or ''
278 if '\n' in doc.strip():
278 if '\n' in doc.strip():
279 msg = _('use "hg help -e %s" to show help for '
279 msg = _('(use "hg help -e %s" to show help for '
280 'the %s extension') % (name, name)
280 'the %s extension)') % (name, name)
281 rst.append('\n%s\n' % msg)
281 rst.append('\n%s\n' % msg)
282 except KeyError:
282 except KeyError:
283 pass
283 pass
284
284
285 # options
285 # options
286 if not ui.quiet and entry[1]:
286 if not ui.quiet and entry[1]:
287 rst.append('\n%s\n\n' % _("options:"))
287 rst.append('\n%s\n\n' % _("options:"))
288 rst.append(optrst(entry[1], ui.verbose))
288 rst.append(optrst(entry[1], ui.verbose))
289
289
290 if ui.verbose:
290 if ui.verbose:
291 rst.append('\n%s\n\n' % _("global options:"))
291 rst.append('\n%s\n\n' % _("global options:"))
292 rst.append(optrst(commands.globalopts, ui.verbose))
292 rst.append(optrst(commands.globalopts, ui.verbose))
293
293
294 if not ui.verbose:
294 if not ui.verbose:
295 if not full:
295 if not full:
296 rst.append(_('\n(use "hg %s -h" to show more help)\n')
296 rst.append(_('\n(use "hg %s -h" to show more help)\n')
297 % name)
297 % name)
298 elif not ui.quiet:
298 elif not ui.quiet:
299 rst.append(_('\n(some details hidden, use --verbose '
299 rst.append(_('\n(some details hidden, use --verbose '
300 'to show complete help)'))
300 'to show complete help)'))
301
301
302 return rst
302 return rst
303
303
304
304
305 def helplist(select=None):
305 def helplist(select=None):
306 # list of commands
306 # list of commands
307 if name == "shortlist":
307 if name == "shortlist":
308 header = _('basic commands:\n\n')
308 header = _('basic commands:\n\n')
309 elif name == "debug":
309 elif name == "debug":
310 header = _('debug commands (internal and unsupported):\n\n')
310 header = _('debug commands (internal and unsupported):\n\n')
311 else:
311 else:
312 header = _('list of commands:\n\n')
312 header = _('list of commands:\n\n')
313
313
314 h = {}
314 h = {}
315 cmds = {}
315 cmds = {}
316 for c, e in commands.table.iteritems():
316 for c, e in commands.table.iteritems():
317 f = c.split("|", 1)[0]
317 f = c.split("|", 1)[0]
318 if select and not select(f):
318 if select and not select(f):
319 continue
319 continue
320 if (not select and name != 'shortlist' and
320 if (not select and name != 'shortlist' and
321 e[0].__module__ != commands.__name__):
321 e[0].__module__ != commands.__name__):
322 continue
322 continue
323 if name == "shortlist" and not f.startswith("^"):
323 if name == "shortlist" and not f.startswith("^"):
324 continue
324 continue
325 f = f.lstrip("^")
325 f = f.lstrip("^")
326 if not ui.debugflag and f.startswith("debug") and name != "debug":
326 if not ui.debugflag and f.startswith("debug") and name != "debug":
327 continue
327 continue
328 doc = e[0].__doc__
328 doc = e[0].__doc__
329 if doc and 'DEPRECATED' in doc and not ui.verbose:
329 if doc and 'DEPRECATED' in doc and not ui.verbose:
330 continue
330 continue
331 doc = gettext(doc)
331 doc = gettext(doc)
332 if not doc:
332 if not doc:
333 doc = _("(no help text available)")
333 doc = _("(no help text available)")
334 h[f] = doc.splitlines()[0].rstrip()
334 h[f] = doc.splitlines()[0].rstrip()
335 cmds[f] = c.lstrip("^")
335 cmds[f] = c.lstrip("^")
336
336
337 rst = []
337 rst = []
338 if not h:
338 if not h:
339 if not ui.quiet:
339 if not ui.quiet:
340 rst.append(_('no commands defined\n'))
340 rst.append(_('no commands defined\n'))
341 return rst
341 return rst
342
342
343 if not ui.quiet:
343 if not ui.quiet:
344 rst.append(header)
344 rst.append(header)
345 fns = sorted(h)
345 fns = sorted(h)
346 for f in fns:
346 for f in fns:
347 if ui.verbose:
347 if ui.verbose:
348 commacmds = cmds[f].replace("|",", ")
348 commacmds = cmds[f].replace("|",", ")
349 rst.append(" :%s: %s\n" % (commacmds, h[f]))
349 rst.append(" :%s: %s\n" % (commacmds, h[f]))
350 else:
350 else:
351 rst.append(' :%s: %s\n' % (f, h[f]))
351 rst.append(' :%s: %s\n' % (f, h[f]))
352
352
353 if not name:
353 if not name:
354 exts = listexts(_('enabled extensions:'), extensions.enabled())
354 exts = listexts(_('enabled extensions:'), extensions.enabled())
355 if exts:
355 if exts:
356 rst.append('\n')
356 rst.append('\n')
357 rst.extend(exts)
357 rst.extend(exts)
358
358
359 rst.append(_("\nadditional help topics:\n\n"))
359 rst.append(_("\nadditional help topics:\n\n"))
360 topics = []
360 topics = []
361 for names, header, doc in helptable:
361 for names, header, doc in helptable:
362 topics.append((names[0], header))
362 topics.append((names[0], header))
363 for t, desc in topics:
363 for t, desc in topics:
364 rst.append(" :%s: %s\n" % (t, desc))
364 rst.append(" :%s: %s\n" % (t, desc))
365
365
366 optlist = []
366 optlist = []
367 if not ui.quiet:
367 if not ui.quiet:
368 if ui.verbose:
368 if ui.verbose:
369 optlist.append((_("global options:"), commands.globalopts))
369 optlist.append((_("global options:"), commands.globalopts))
370 if name == 'shortlist':
370 if name == 'shortlist':
371 optlist.append((_('use "hg help" for the full list '
371 optlist.append((_('use "hg help" for the full list '
372 'of commands'), ()))
372 'of commands'), ()))
373 else:
373 else:
374 if name == 'shortlist':
374 if name == 'shortlist':
375 msg = _('use "hg help" for the full list of commands '
375 msg = _('use "hg help" for the full list of commands '
376 'or "hg -v" for details')
376 'or "hg -v" for details')
377 elif name and not full:
377 elif name and not full:
378 msg = _('use "hg help %s" to show the full help '
378 msg = _('use "hg help %s" to show the full help '
379 'text') % name
379 'text') % name
380 else:
380 else:
381 msg = _('use "hg -v help%s" to show builtin aliases and '
381 msg = _('use "hg -v help%s" to show builtin aliases and '
382 'global options') % (name and " " + name or "")
382 'global options') % (name and " " + name or "")
383 optlist.append((msg, ()))
383 optlist.append((msg, ()))
384
384
385 if optlist:
385 if optlist:
386 for title, options in optlist:
386 for title, options in optlist:
387 rst.append('\n%s\n' % title)
387 rst.append('\n%s\n' % title)
388 if options:
388 if options:
389 rst.append('\n%s\n' % optrst(options, ui.verbose))
389 rst.append('\n%s\n' % optrst(options, ui.verbose))
390 return rst
390 return rst
391
391
392 def helptopic(name):
392 def helptopic(name):
393 for names, header, doc in helptable:
393 for names, header, doc in helptable:
394 if name in names:
394 if name in names:
395 break
395 break
396 else:
396 else:
397 raise error.UnknownCommand(name)
397 raise error.UnknownCommand(name)
398
398
399 rst = [minirst.section(header)]
399 rst = [minirst.section(header)]
400
400
401 # description
401 # description
402 if not doc:
402 if not doc:
403 rst.append(" %s\n" % _("(no help text available)"))
403 rst.append(" %s\n" % _("(no help text available)"))
404 if callable(doc):
404 if callable(doc):
405 rst += [" %s\n" % l for l in doc().splitlines()]
405 rst += [" %s\n" % l for l in doc().splitlines()]
406
406
407 if not ui.verbose:
407 if not ui.verbose:
408 omitted = (_('use "hg help -v %s" to show more complete help') %
408 omitted = (_('use "hg help -v %s" to show more complete help') %
409 name)
409 name)
410 indicateomitted(rst, omitted)
410 indicateomitted(rst, omitted)
411
411
412 try:
412 try:
413 cmdutil.findcmd(name, commands.table)
413 cmdutil.findcmd(name, commands.table)
414 rst.append(_('\nuse "hg help -c %s" to see help for '
414 rst.append(_('\nuse "hg help -c %s" to see help for '
415 'the %s command\n') % (name, name))
415 'the %s command\n') % (name, name))
416 except error.UnknownCommand:
416 except error.UnknownCommand:
417 pass
417 pass
418 return rst
418 return rst
419
419
420 def helpext(name):
420 def helpext(name):
421 try:
421 try:
422 mod = extensions.find(name)
422 mod = extensions.find(name)
423 doc = gettext(mod.__doc__) or _('no help text available')
423 doc = gettext(mod.__doc__) or _('no help text available')
424 except KeyError:
424 except KeyError:
425 mod = None
425 mod = None
426 doc = extensions.disabledext(name)
426 doc = extensions.disabledext(name)
427 if not doc:
427 if not doc:
428 raise error.UnknownCommand(name)
428 raise error.UnknownCommand(name)
429
429
430 if '\n' not in doc:
430 if '\n' not in doc:
431 head, tail = doc, ""
431 head, tail = doc, ""
432 else:
432 else:
433 head, tail = doc.split('\n', 1)
433 head, tail = doc.split('\n', 1)
434 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)]
434 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)]
435 if tail:
435 if tail:
436 rst.extend(tail.splitlines(True))
436 rst.extend(tail.splitlines(True))
437 rst.append('\n')
437 rst.append('\n')
438
438
439 if not ui.verbose:
439 if not ui.verbose:
440 omitted = (_('use "hg help -v %s" to show more complete help') %
440 omitted = (_('use "hg help -v %s" to show more complete help') %
441 name)
441 name)
442 indicateomitted(rst, omitted)
442 indicateomitted(rst, omitted)
443
443
444 if mod:
444 if mod:
445 try:
445 try:
446 ct = mod.cmdtable
446 ct = mod.cmdtable
447 except AttributeError:
447 except AttributeError:
448 ct = {}
448 ct = {}
449 modcmds = set([c.split('|', 1)[0] for c in ct])
449 modcmds = set([c.split('|', 1)[0] for c in ct])
450 rst.extend(helplist(modcmds.__contains__))
450 rst.extend(helplist(modcmds.__contains__))
451 else:
451 else:
452 rst.append(_('use "hg help extensions" for information on enabling '
452 rst.append(_('use "hg help extensions" for information on enabling '
453 'extensions\n'))
453 'extensions\n'))
454 return rst
454 return rst
455
455
456 def helpextcmd(name):
456 def helpextcmd(name):
457 cmd, ext, mod = extensions.disabledcmd(ui, name,
457 cmd, ext, mod = extensions.disabledcmd(ui, name,
458 ui.configbool('ui', 'strict'))
458 ui.configbool('ui', 'strict'))
459 doc = gettext(mod.__doc__).splitlines()[0]
459 doc = gettext(mod.__doc__).splitlines()[0]
460
460
461 rst = listexts(_("'%s' is provided by the following "
461 rst = listexts(_("'%s' is provided by the following "
462 "extension:") % cmd, {ext: doc}, indent=4)
462 "extension:") % cmd, {ext: doc}, indent=4)
463 rst.append('\n')
463 rst.append('\n')
464 rst.append(_('use "hg help extensions" for information on enabling '
464 rst.append(_('use "hg help extensions" for information on enabling '
465 'extensions\n'))
465 'extensions\n'))
466 return rst
466 return rst
467
467
468
468
469 rst = []
469 rst = []
470 kw = opts.get('keyword')
470 kw = opts.get('keyword')
471 if kw:
471 if kw:
472 matches = topicmatch(kw)
472 matches = topicmatch(kw)
473 for t, title in (('topics', _('Topics')),
473 for t, title in (('topics', _('Topics')),
474 ('commands', _('Commands')),
474 ('commands', _('Commands')),
475 ('extensions', _('Extensions')),
475 ('extensions', _('Extensions')),
476 ('extensioncommands', _('Extension Commands'))):
476 ('extensioncommands', _('Extension Commands'))):
477 if matches[t]:
477 if matches[t]:
478 rst.append('%s:\n\n' % title)
478 rst.append('%s:\n\n' % title)
479 rst.extend(minirst.maketable(sorted(matches[t]), 1))
479 rst.extend(minirst.maketable(sorted(matches[t]), 1))
480 rst.append('\n')
480 rst.append('\n')
481 if not rst:
481 if not rst:
482 msg = _('no matches')
482 msg = _('no matches')
483 hint = _('try "hg help" for a list of topics')
483 hint = _('try "hg help" for a list of topics')
484 raise util.Abort(msg, hint=hint)
484 raise util.Abort(msg, hint=hint)
485 elif name and name != 'shortlist':
485 elif name and name != 'shortlist':
486 if unknowncmd:
486 if unknowncmd:
487 queries = (helpextcmd,)
487 queries = (helpextcmd,)
488 elif opts.get('extension'):
488 elif opts.get('extension'):
489 queries = (helpext,)
489 queries = (helpext,)
490 elif opts.get('command'):
490 elif opts.get('command'):
491 queries = (helpcmd,)
491 queries = (helpcmd,)
492 else:
492 else:
493 queries = (helptopic, helpcmd, helpext, helpextcmd)
493 queries = (helptopic, helpcmd, helpext, helpextcmd)
494 for f in queries:
494 for f in queries:
495 try:
495 try:
496 rst = f(name)
496 rst = f(name)
497 break
497 break
498 except error.UnknownCommand:
498 except error.UnknownCommand:
499 pass
499 pass
500 else:
500 else:
501 if unknowncmd:
501 if unknowncmd:
502 raise error.UnknownCommand(name)
502 raise error.UnknownCommand(name)
503 else:
503 else:
504 msg = _('no such help topic: %s') % name
504 msg = _('no such help topic: %s') % name
505 hint = _('try "hg help --keyword %s"') % name
505 hint = _('try "hg help --keyword %s"') % name
506 raise util.Abort(msg, hint=hint)
506 raise util.Abort(msg, hint=hint)
507 else:
507 else:
508 # program name
508 # program name
509 if not ui.quiet:
509 if not ui.quiet:
510 rst = [_("Mercurial Distributed SCM\n"), '\n']
510 rst = [_("Mercurial Distributed SCM\n"), '\n']
511 rst.extend(helplist())
511 rst.extend(helplist())
512
512
513 return ''.join(rst)
513 return ''.join(rst)
@@ -1,916 +1,916 b''
1 Test basic extension support
1 Test basic extension support
2
2
3 $ cat > foobar.py <<EOF
3 $ cat > foobar.py <<EOF
4 > import os
4 > import os
5 > from mercurial import cmdutil, commands
5 > from mercurial import cmdutil, commands
6 > cmdtable = {}
6 > cmdtable = {}
7 > command = cmdutil.command(cmdtable)
7 > command = cmdutil.command(cmdtable)
8 > def uisetup(ui):
8 > def uisetup(ui):
9 > ui.write("uisetup called\\n")
9 > ui.write("uisetup called\\n")
10 > def reposetup(ui, repo):
10 > def reposetup(ui, repo):
11 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
11 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
12 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
12 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
13 > @command('foo', [], 'hg foo')
13 > @command('foo', [], 'hg foo')
14 > def foo(ui, *args, **kwargs):
14 > def foo(ui, *args, **kwargs):
15 > ui.write("Foo\\n")
15 > ui.write("Foo\\n")
16 > @command('bar', [], 'hg bar', norepo=True)
16 > @command('bar', [], 'hg bar', norepo=True)
17 > def bar(ui, *args, **kwargs):
17 > def bar(ui, *args, **kwargs):
18 > ui.write("Bar\\n")
18 > ui.write("Bar\\n")
19 > EOF
19 > EOF
20 $ abspath=`pwd`/foobar.py
20 $ abspath=`pwd`/foobar.py
21
21
22 $ mkdir barfoo
22 $ mkdir barfoo
23 $ cp foobar.py barfoo/__init__.py
23 $ cp foobar.py barfoo/__init__.py
24 $ barfoopath=`pwd`/barfoo
24 $ barfoopath=`pwd`/barfoo
25
25
26 $ hg init a
26 $ hg init a
27 $ cd a
27 $ cd a
28 $ echo foo > file
28 $ echo foo > file
29 $ hg add file
29 $ hg add file
30 $ hg commit -m 'add file'
30 $ hg commit -m 'add file'
31
31
32 $ echo '[extensions]' >> $HGRCPATH
32 $ echo '[extensions]' >> $HGRCPATH
33 $ echo "foobar = $abspath" >> $HGRCPATH
33 $ echo "foobar = $abspath" >> $HGRCPATH
34 $ hg foo
34 $ hg foo
35 uisetup called
35 uisetup called
36 reposetup called for a
36 reposetup called for a
37 ui == repo.ui
37 ui == repo.ui
38 Foo
38 Foo
39
39
40 $ cd ..
40 $ cd ..
41 $ hg clone a b
41 $ hg clone a b
42 uisetup called
42 uisetup called
43 reposetup called for a
43 reposetup called for a
44 ui == repo.ui
44 ui == repo.ui
45 reposetup called for b
45 reposetup called for b
46 ui == repo.ui
46 ui == repo.ui
47 updating to branch default
47 updating to branch default
48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
49
49
50 $ hg bar
50 $ hg bar
51 uisetup called
51 uisetup called
52 Bar
52 Bar
53 $ echo 'foobar = !' >> $HGRCPATH
53 $ echo 'foobar = !' >> $HGRCPATH
54
54
55 module/__init__.py-style
55 module/__init__.py-style
56
56
57 $ echo "barfoo = $barfoopath" >> $HGRCPATH
57 $ echo "barfoo = $barfoopath" >> $HGRCPATH
58 $ cd a
58 $ cd a
59 $ hg foo
59 $ hg foo
60 uisetup called
60 uisetup called
61 reposetup called for a
61 reposetup called for a
62 ui == repo.ui
62 ui == repo.ui
63 Foo
63 Foo
64 $ echo 'barfoo = !' >> $HGRCPATH
64 $ echo 'barfoo = !' >> $HGRCPATH
65
65
66 Check that extensions are loaded in phases:
66 Check that extensions are loaded in phases:
67
67
68 $ cat > foo.py <<EOF
68 $ cat > foo.py <<EOF
69 > import os
69 > import os
70 > name = os.path.basename(__file__).rsplit('.', 1)[0]
70 > name = os.path.basename(__file__).rsplit('.', 1)[0]
71 > print "1) %s imported" % name
71 > print "1) %s imported" % name
72 > def uisetup(ui):
72 > def uisetup(ui):
73 > print "2) %s uisetup" % name
73 > print "2) %s uisetup" % name
74 > def extsetup():
74 > def extsetup():
75 > print "3) %s extsetup" % name
75 > print "3) %s extsetup" % name
76 > def reposetup(ui, repo):
76 > def reposetup(ui, repo):
77 > print "4) %s reposetup" % name
77 > print "4) %s reposetup" % name
78 > EOF
78 > EOF
79
79
80 $ cp foo.py bar.py
80 $ cp foo.py bar.py
81 $ echo 'foo = foo.py' >> $HGRCPATH
81 $ echo 'foo = foo.py' >> $HGRCPATH
82 $ echo 'bar = bar.py' >> $HGRCPATH
82 $ echo 'bar = bar.py' >> $HGRCPATH
83
83
84 Command with no output, we just want to see the extensions loaded:
84 Command with no output, we just want to see the extensions loaded:
85
85
86 $ hg paths
86 $ hg paths
87 1) foo imported
87 1) foo imported
88 1) bar imported
88 1) bar imported
89 2) foo uisetup
89 2) foo uisetup
90 2) bar uisetup
90 2) bar uisetup
91 3) foo extsetup
91 3) foo extsetup
92 3) bar extsetup
92 3) bar extsetup
93 4) foo reposetup
93 4) foo reposetup
94 4) bar reposetup
94 4) bar reposetup
95
95
96 Check hgweb's load order:
96 Check hgweb's load order:
97
97
98 $ cat > hgweb.cgi <<EOF
98 $ cat > hgweb.cgi <<EOF
99 > #!/usr/bin/env python
99 > #!/usr/bin/env python
100 > from mercurial import demandimport; demandimport.enable()
100 > from mercurial import demandimport; demandimport.enable()
101 > from mercurial.hgweb import hgweb
101 > from mercurial.hgweb import hgweb
102 > from mercurial.hgweb import wsgicgi
102 > from mercurial.hgweb import wsgicgi
103 > application = hgweb('.', 'test repo')
103 > application = hgweb('.', 'test repo')
104 > wsgicgi.launch(application)
104 > wsgicgi.launch(application)
105 > EOF
105 > EOF
106
106
107 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
107 $ REQUEST_METHOD='GET' PATH_INFO='/' SCRIPT_NAME='' QUERY_STRING='' \
108 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
108 > SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
109 > | grep '^[0-9]) ' # ignores HTML output
109 > | grep '^[0-9]) ' # ignores HTML output
110 1) foo imported
110 1) foo imported
111 1) bar imported
111 1) bar imported
112 2) foo uisetup
112 2) foo uisetup
113 2) bar uisetup
113 2) bar uisetup
114 3) foo extsetup
114 3) foo extsetup
115 3) bar extsetup
115 3) bar extsetup
116 4) foo reposetup
116 4) foo reposetup
117 4) bar reposetup
117 4) bar reposetup
118 4) foo reposetup
118 4) foo reposetup
119 4) bar reposetup
119 4) bar reposetup
120
120
121 $ echo 'foo = !' >> $HGRCPATH
121 $ echo 'foo = !' >> $HGRCPATH
122 $ echo 'bar = !' >> $HGRCPATH
122 $ echo 'bar = !' >> $HGRCPATH
123
123
124 Check "from __future__ import absolute_import" support for external libraries
124 Check "from __future__ import absolute_import" support for external libraries
125
125
126 #if windows
126 #if windows
127 $ PATHSEP=";"
127 $ PATHSEP=";"
128 #else
128 #else
129 $ PATHSEP=":"
129 $ PATHSEP=":"
130 #endif
130 #endif
131 $ export PATHSEP
131 $ export PATHSEP
132
132
133 $ mkdir $TESTTMP/libroot
133 $ mkdir $TESTTMP/libroot
134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
134 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
135 $ mkdir $TESTTMP/libroot/mod
135 $ mkdir $TESTTMP/libroot/mod
136 $ touch $TESTTMP/libroot/mod/__init__.py
136 $ touch $TESTTMP/libroot/mod/__init__.py
137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
137 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
138
138
139 #if absimport
139 #if absimport
140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
140 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF
141 > from __future__ import absolute_import
141 > from __future__ import absolute_import
142 > import ambig # should load "libroot/ambig.py"
142 > import ambig # should load "libroot/ambig.py"
143 > s = ambig.s
143 > s = ambig.s
144 > EOF
144 > EOF
145 $ cat > loadabs.py <<EOF
145 $ cat > loadabs.py <<EOF
146 > import mod.ambigabs as ambigabs
146 > import mod.ambigabs as ambigabs
147 > def extsetup():
147 > def extsetup():
148 > print 'ambigabs.s=%s' % ambigabs.s
148 > print 'ambigabs.s=%s' % ambigabs.s
149 > EOF
149 > EOF
150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
150 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
151 ambigabs.s=libroot/ambig.py
151 ambigabs.s=libroot/ambig.py
152 $TESTTMP/a (glob)
152 $TESTTMP/a (glob)
153 #endif
153 #endif
154
154
155 #if no-py3k
155 #if no-py3k
156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
156 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF
157 > import ambig # should load "libroot/mod/ambig.py"
157 > import ambig # should load "libroot/mod/ambig.py"
158 > s = ambig.s
158 > s = ambig.s
159 > EOF
159 > EOF
160 $ cat > loadrel.py <<EOF
160 $ cat > loadrel.py <<EOF
161 > import mod.ambigrel as ambigrel
161 > import mod.ambigrel as ambigrel
162 > def extsetup():
162 > def extsetup():
163 > print 'ambigrel.s=%s' % ambigrel.s
163 > print 'ambigrel.s=%s' % ambigrel.s
164 > EOF
164 > EOF
165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
165 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
166 ambigrel.s=libroot/mod/ambig.py
166 ambigrel.s=libroot/mod/ambig.py
167 $TESTTMP/a (glob)
167 $TESTTMP/a (glob)
168 #endif
168 #endif
169
169
170 Check absolute/relative import of extension specific modules
170 Check absolute/relative import of extension specific modules
171
171
172 $ mkdir $TESTTMP/extroot
172 $ mkdir $TESTTMP/extroot
173 $ cat > $TESTTMP/extroot/bar.py <<EOF
173 $ cat > $TESTTMP/extroot/bar.py <<EOF
174 > s = 'this is extroot.bar'
174 > s = 'this is extroot.bar'
175 > EOF
175 > EOF
176 $ mkdir $TESTTMP/extroot/sub1
176 $ mkdir $TESTTMP/extroot/sub1
177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
177 $ cat > $TESTTMP/extroot/sub1/__init__.py <<EOF
178 > s = 'this is extroot.sub1.__init__'
178 > s = 'this is extroot.sub1.__init__'
179 > EOF
179 > EOF
180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
180 $ cat > $TESTTMP/extroot/sub1/baz.py <<EOF
181 > s = 'this is extroot.sub1.baz'
181 > s = 'this is extroot.sub1.baz'
182 > EOF
182 > EOF
183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
184 > s = 'this is extroot.__init__'
184 > s = 'this is extroot.__init__'
185 > import foo
185 > import foo
186 > def extsetup(ui):
186 > def extsetup(ui):
187 > ui.write('(extroot) ', foo.func(), '\n')
187 > ui.write('(extroot) ', foo.func(), '\n')
188 > EOF
188 > EOF
189
189
190 $ cat > $TESTTMP/extroot/foo.py <<EOF
190 $ cat > $TESTTMP/extroot/foo.py <<EOF
191 > # test absolute import
191 > # test absolute import
192 > buf = []
192 > buf = []
193 > def func():
193 > def func():
194 > # "not locals" case
194 > # "not locals" case
195 > import extroot.bar
195 > import extroot.bar
196 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
196 > buf.append('import extroot.bar in func(): %s' % extroot.bar.s)
197 > return '\n(extroot) '.join(buf)
197 > return '\n(extroot) '.join(buf)
198 > # "fromlist == ('*',)" case
198 > # "fromlist == ('*',)" case
199 > from extroot.bar import *
199 > from extroot.bar import *
200 > buf.append('from extroot.bar import *: %s' % s)
200 > buf.append('from extroot.bar import *: %s' % s)
201 > # "not fromlist" and "if '.' in name" case
201 > # "not fromlist" and "if '.' in name" case
202 > import extroot.sub1.baz
202 > import extroot.sub1.baz
203 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
203 > buf.append('import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
204 > # "not fromlist" and NOT "if '.' in name" case
204 > # "not fromlist" and NOT "if '.' in name" case
205 > import extroot
205 > import extroot
206 > buf.append('import extroot: %s' % extroot.s)
206 > buf.append('import extroot: %s' % extroot.s)
207 > # NOT "not fromlist" and NOT "level != -1" case
207 > # NOT "not fromlist" and NOT "level != -1" case
208 > from extroot.bar import s
208 > from extroot.bar import s
209 > buf.append('from extroot.bar import s: %s' % s)
209 > buf.append('from extroot.bar import s: %s' % s)
210 > EOF
210 > EOF
211 $ hg --config extensions.extroot=$TESTTMP/extroot root
211 $ hg --config extensions.extroot=$TESTTMP/extroot root
212 (extroot) from extroot.bar import *: this is extroot.bar
212 (extroot) from extroot.bar import *: this is extroot.bar
213 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
213 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
214 (extroot) import extroot: this is extroot.__init__
214 (extroot) import extroot: this is extroot.__init__
215 (extroot) from extroot.bar import s: this is extroot.bar
215 (extroot) from extroot.bar import s: this is extroot.bar
216 (extroot) import extroot.bar in func(): this is extroot.bar
216 (extroot) import extroot.bar in func(): this is extroot.bar
217 $TESTTMP/a (glob)
217 $TESTTMP/a (glob)
218
218
219 #if no-py3k
219 #if no-py3k
220 $ rm "$TESTTMP"/extroot/foo.*
220 $ rm "$TESTTMP"/extroot/foo.*
221 $ cat > $TESTTMP/extroot/foo.py <<EOF
221 $ cat > $TESTTMP/extroot/foo.py <<EOF
222 > # test relative import
222 > # test relative import
223 > buf = []
223 > buf = []
224 > def func():
224 > def func():
225 > # "not locals" case
225 > # "not locals" case
226 > import bar
226 > import bar
227 > buf.append('import bar in func(): %s' % bar.s)
227 > buf.append('import bar in func(): %s' % bar.s)
228 > return '\n(extroot) '.join(buf)
228 > return '\n(extroot) '.join(buf)
229 > # "fromlist == ('*',)" case
229 > # "fromlist == ('*',)" case
230 > from bar import *
230 > from bar import *
231 > buf.append('from bar import *: %s' % s)
231 > buf.append('from bar import *: %s' % s)
232 > # "not fromlist" and "if '.' in name" case
232 > # "not fromlist" and "if '.' in name" case
233 > import sub1.baz
233 > import sub1.baz
234 > buf.append('import sub1.baz: %s' % sub1.baz.s)
234 > buf.append('import sub1.baz: %s' % sub1.baz.s)
235 > # "not fromlist" and NOT "if '.' in name" case
235 > # "not fromlist" and NOT "if '.' in name" case
236 > import sub1
236 > import sub1
237 > buf.append('import sub1: %s' % sub1.s)
237 > buf.append('import sub1: %s' % sub1.s)
238 > # NOT "not fromlist" and NOT "level != -1" case
238 > # NOT "not fromlist" and NOT "level != -1" case
239 > from bar import s
239 > from bar import s
240 > buf.append('from bar import s: %s' % s)
240 > buf.append('from bar import s: %s' % s)
241 > EOF
241 > EOF
242 $ hg --config extensions.extroot=$TESTTMP/extroot root
242 $ hg --config extensions.extroot=$TESTTMP/extroot root
243 (extroot) from bar import *: this is extroot.bar
243 (extroot) from bar import *: this is extroot.bar
244 (extroot) import sub1.baz: this is extroot.sub1.baz
244 (extroot) import sub1.baz: this is extroot.sub1.baz
245 (extroot) import sub1: this is extroot.sub1.__init__
245 (extroot) import sub1: this is extroot.sub1.__init__
246 (extroot) from bar import s: this is extroot.bar
246 (extroot) from bar import s: this is extroot.bar
247 (extroot) import bar in func(): this is extroot.bar
247 (extroot) import bar in func(): this is extroot.bar
248 $TESTTMP/a (glob)
248 $TESTTMP/a (glob)
249 #endif
249 #endif
250
250
251 $ cd ..
251 $ cd ..
252
252
253 hide outer repo
253 hide outer repo
254 $ hg init
254 $ hg init
255
255
256 $ cat > empty.py <<EOF
256 $ cat > empty.py <<EOF
257 > '''empty cmdtable
257 > '''empty cmdtable
258 > '''
258 > '''
259 > cmdtable = {}
259 > cmdtable = {}
260 > EOF
260 > EOF
261 $ emptypath=`pwd`/empty.py
261 $ emptypath=`pwd`/empty.py
262 $ echo "empty = $emptypath" >> $HGRCPATH
262 $ echo "empty = $emptypath" >> $HGRCPATH
263 $ hg help empty
263 $ hg help empty
264 empty extension - empty cmdtable
264 empty extension - empty cmdtable
265
265
266 no commands defined
266 no commands defined
267
267
268
268
269 $ echo 'empty = !' >> $HGRCPATH
269 $ echo 'empty = !' >> $HGRCPATH
270
270
271 $ cat > debugextension.py <<EOF
271 $ cat > debugextension.py <<EOF
272 > '''only debugcommands
272 > '''only debugcommands
273 > '''
273 > '''
274 > from mercurial import cmdutil
274 > from mercurial import cmdutil
275 > cmdtable = {}
275 > cmdtable = {}
276 > command = cmdutil.command(cmdtable)
276 > command = cmdutil.command(cmdtable)
277 > @command('debugfoobar', [], 'hg debugfoobar')
277 > @command('debugfoobar', [], 'hg debugfoobar')
278 > def debugfoobar(ui, repo, *args, **opts):
278 > def debugfoobar(ui, repo, *args, **opts):
279 > "yet another debug command"
279 > "yet another debug command"
280 > pass
280 > pass
281 > @command('foo', [], 'hg foo')
281 > @command('foo', [], 'hg foo')
282 > def foo(ui, repo, *args, **opts):
282 > def foo(ui, repo, *args, **opts):
283 > """yet another foo command
283 > """yet another foo command
284 > This command has been DEPRECATED since forever.
284 > This command has been DEPRECATED since forever.
285 > """
285 > """
286 > pass
286 > pass
287 > EOF
287 > EOF
288 $ debugpath=`pwd`/debugextension.py
288 $ debugpath=`pwd`/debugextension.py
289 $ echo "debugextension = $debugpath" >> $HGRCPATH
289 $ echo "debugextension = $debugpath" >> $HGRCPATH
290
290
291 $ hg help debugextension
291 $ hg help debugextension
292 debugextension extension - only debugcommands
292 debugextension extension - only debugcommands
293
293
294 no commands defined
294 no commands defined
295
295
296
296
297 $ hg --verbose help debugextension
297 $ hg --verbose help debugextension
298 debugextension extension - only debugcommands
298 debugextension extension - only debugcommands
299
299
300 list of commands:
300 list of commands:
301
301
302 foo yet another foo command
302 foo yet another foo command
303
303
304 global options:
304 global options:
305
305
306 -R --repository REPO repository root directory or name of overlay bundle
306 -R --repository REPO repository root directory or name of overlay bundle
307 file
307 file
308 --cwd DIR change working directory
308 --cwd DIR change working directory
309 -y --noninteractive do not prompt, automatically pick the first choice for
309 -y --noninteractive do not prompt, automatically pick the first choice for
310 all prompts
310 all prompts
311 -q --quiet suppress output
311 -q --quiet suppress output
312 -v --verbose enable additional output
312 -v --verbose enable additional output
313 --config CONFIG [+] set/override config option (use 'section.name=value')
313 --config CONFIG [+] set/override config option (use 'section.name=value')
314 --debug enable debugging output
314 --debug enable debugging output
315 --debugger start debugger
315 --debugger start debugger
316 --encoding ENCODE set the charset encoding (default: ascii)
316 --encoding ENCODE set the charset encoding (default: ascii)
317 --encodingmode MODE set the charset encoding mode (default: strict)
317 --encodingmode MODE set the charset encoding mode (default: strict)
318 --traceback always print a traceback on exception
318 --traceback always print a traceback on exception
319 --time time how long the command takes
319 --time time how long the command takes
320 --profile print command execution profile
320 --profile print command execution profile
321 --version output version information and exit
321 --version output version information and exit
322 -h --help display help and exit
322 -h --help display help and exit
323 --hidden consider hidden changesets
323 --hidden consider hidden changesets
324
324
325 [+] marked option can be specified multiple times
325 [+] marked option can be specified multiple times
326
326
327
327
328
328
329
329
330
330
331
331
332 $ hg --debug help debugextension
332 $ hg --debug help debugextension
333 debugextension extension - only debugcommands
333 debugextension extension - only debugcommands
334
334
335 list of commands:
335 list of commands:
336
336
337 debugfoobar yet another debug command
337 debugfoobar yet another debug command
338 foo yet another foo command
338 foo yet another foo command
339
339
340 global options:
340 global options:
341
341
342 -R --repository REPO repository root directory or name of overlay bundle
342 -R --repository REPO repository root directory or name of overlay bundle
343 file
343 file
344 --cwd DIR change working directory
344 --cwd DIR change working directory
345 -y --noninteractive do not prompt, automatically pick the first choice for
345 -y --noninteractive do not prompt, automatically pick the first choice for
346 all prompts
346 all prompts
347 -q --quiet suppress output
347 -q --quiet suppress output
348 -v --verbose enable additional output
348 -v --verbose enable additional output
349 --config CONFIG [+] set/override config option (use 'section.name=value')
349 --config CONFIG [+] set/override config option (use 'section.name=value')
350 --debug enable debugging output
350 --debug enable debugging output
351 --debugger start debugger
351 --debugger start debugger
352 --encoding ENCODE set the charset encoding (default: ascii)
352 --encoding ENCODE set the charset encoding (default: ascii)
353 --encodingmode MODE set the charset encoding mode (default: strict)
353 --encodingmode MODE set the charset encoding mode (default: strict)
354 --traceback always print a traceback on exception
354 --traceback always print a traceback on exception
355 --time time how long the command takes
355 --time time how long the command takes
356 --profile print command execution profile
356 --profile print command execution profile
357 --version output version information and exit
357 --version output version information and exit
358 -h --help display help and exit
358 -h --help display help and exit
359 --hidden consider hidden changesets
359 --hidden consider hidden changesets
360
360
361 [+] marked option can be specified multiple times
361 [+] marked option can be specified multiple times
362
362
363
363
364
364
365
365
366
366
367 $ echo 'debugextension = !' >> $HGRCPATH
367 $ echo 'debugextension = !' >> $HGRCPATH
368
368
369 Extension module help vs command help:
369 Extension module help vs command help:
370
370
371 $ echo 'extdiff =' >> $HGRCPATH
371 $ echo 'extdiff =' >> $HGRCPATH
372 $ hg help extdiff
372 $ hg help extdiff
373 hg extdiff [OPT]... [FILE]...
373 hg extdiff [OPT]... [FILE]...
374
374
375 use external program to diff repository (or selected files)
375 use external program to diff repository (or selected files)
376
376
377 Show differences between revisions for the specified files, using an
377 Show differences between revisions for the specified files, using an
378 external program. The default program used is diff, with default options
378 external program. The default program used is diff, with default options
379 "-Npru".
379 "-Npru".
380
380
381 To select a different program, use the -p/--program option. The program
381 To select a different program, use the -p/--program option. The program
382 will be passed the names of two directories to compare. To pass additional
382 will be passed the names of two directories to compare. To pass additional
383 options to the program, use -o/--option. These will be passed before the
383 options to the program, use -o/--option. These will be passed before the
384 names of the directories to compare.
384 names of the directories to compare.
385
385
386 When two revision arguments are given, then changes are shown between
386 When two revision arguments are given, then changes are shown between
387 those revisions. If only one revision is specified then that revision is
387 those revisions. If only one revision is specified then that revision is
388 compared to the working directory, and, when no revisions are specified,
388 compared to the working directory, and, when no revisions are specified,
389 the working directory files are compared to its parent.
389 the working directory files are compared to its parent.
390
390
391 use "hg help -e extdiff" to show help for the extdiff extension
391 (use "hg help -e extdiff" to show help for the extdiff extension)
392
392
393 options:
393 options:
394
394
395 -p --program CMD comparison program to run
395 -p --program CMD comparison program to run
396 -o --option OPT [+] pass option to comparison program
396 -o --option OPT [+] pass option to comparison program
397 -r --rev REV [+] revision
397 -r --rev REV [+] revision
398 -c --change REV change made by revision
398 -c --change REV change made by revision
399 -I --include PATTERN [+] include names matching the given patterns
399 -I --include PATTERN [+] include names matching the given patterns
400 -X --exclude PATTERN [+] exclude names matching the given patterns
400 -X --exclude PATTERN [+] exclude names matching the given patterns
401
401
402 [+] marked option can be specified multiple times
402 [+] marked option can be specified multiple times
403
403
404 (some details hidden, use --verbose to show complete help)
404 (some details hidden, use --verbose to show complete help)
405
405
406
406
407
407
408
408
409
409
410
410
411
411
412
412
413
413
414
414
415 $ hg help --extension extdiff
415 $ hg help --extension extdiff
416 extdiff extension - command to allow external programs to compare revisions
416 extdiff extension - command to allow external programs to compare revisions
417
417
418 The extdiff Mercurial extension allows you to use external programs to compare
418 The extdiff Mercurial extension allows you to use external programs to compare
419 revisions, or revision with working directory. The external diff programs are
419 revisions, or revision with working directory. The external diff programs are
420 called with a configurable set of options and two non-option arguments: paths
420 called with a configurable set of options and two non-option arguments: paths
421 to directories containing snapshots of files to compare.
421 to directories containing snapshots of files to compare.
422
422
423 The extdiff extension also allows you to configure new diff commands, so you
423 The extdiff extension also allows you to configure new diff commands, so you
424 do not need to type "hg extdiff -p kdiff3" always.
424 do not need to type "hg extdiff -p kdiff3" always.
425
425
426 [extdiff]
426 [extdiff]
427 # add new command that runs GNU diff(1) in 'context diff' mode
427 # add new command that runs GNU diff(1) in 'context diff' mode
428 cdiff = gdiff -Nprc5
428 cdiff = gdiff -Nprc5
429 ## or the old way:
429 ## or the old way:
430 #cmd.cdiff = gdiff
430 #cmd.cdiff = gdiff
431 #opts.cdiff = -Nprc5
431 #opts.cdiff = -Nprc5
432
432
433 # add new command called vdiff, runs kdiff3
433 # add new command called vdiff, runs kdiff3
434 vdiff = kdiff3
434 vdiff = kdiff3
435
435
436 # add new command called meld, runs meld (no need to name twice)
436 # add new command called meld, runs meld (no need to name twice)
437 meld =
437 meld =
438
438
439 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
439 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
440 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
440 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
441 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
441 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
442 # your .vimrc
442 # your .vimrc
443 vimdiff = gvim -f "+next" \
443 vimdiff = gvim -f "+next" \
444 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
444 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
445
445
446 Tool arguments can include variables that are expanded at runtime:
446 Tool arguments can include variables that are expanded at runtime:
447
447
448 $parent1, $plabel1 - filename, descriptive label of first parent
448 $parent1, $plabel1 - filename, descriptive label of first parent
449 $child, $clabel - filename, descriptive label of child revision
449 $child, $clabel - filename, descriptive label of child revision
450 $parent2, $plabel2 - filename, descriptive label of second parent
450 $parent2, $plabel2 - filename, descriptive label of second parent
451 $root - repository root
451 $root - repository root
452 $parent is an alias for $parent1.
452 $parent is an alias for $parent1.
453
453
454 The extdiff extension will look in your [diff-tools] and [merge-tools]
454 The extdiff extension will look in your [diff-tools] and [merge-tools]
455 sections for diff tool arguments, when none are specified in [extdiff].
455 sections for diff tool arguments, when none are specified in [extdiff].
456
456
457 [extdiff]
457 [extdiff]
458 kdiff3 =
458 kdiff3 =
459
459
460 [diff-tools]
460 [diff-tools]
461 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
461 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
462
462
463 You can use -I/-X and list of file or directory names like normal "hg diff"
463 You can use -I/-X and list of file or directory names like normal "hg diff"
464 command. The extdiff extension makes snapshots of only needed files, so
464 command. The extdiff extension makes snapshots of only needed files, so
465 running the external diff program will actually be pretty fast (at least
465 running the external diff program will actually be pretty fast (at least
466 faster than having to compare the entire tree).
466 faster than having to compare the entire tree).
467
467
468 list of commands:
468 list of commands:
469
469
470 extdiff use external program to diff repository (or selected files)
470 extdiff use external program to diff repository (or selected files)
471
471
472 use "hg -v help extdiff" to show builtin aliases and global options
472 use "hg -v help extdiff" to show builtin aliases and global options
473
473
474
474
475
475
476
476
477
477
478
478
479
479
480
480
481
481
482
482
483
483
484
484
485
485
486
486
487
487
488
488
489 $ echo 'extdiff = !' >> $HGRCPATH
489 $ echo 'extdiff = !' >> $HGRCPATH
490
490
491 Test help topic with same name as extension
491 Test help topic with same name as extension
492
492
493 $ cat > multirevs.py <<EOF
493 $ cat > multirevs.py <<EOF
494 > from mercurial import cmdutil, commands
494 > from mercurial import cmdutil, commands
495 > cmdtable = {}
495 > cmdtable = {}
496 > command = cmdutil.command(cmdtable)
496 > command = cmdutil.command(cmdtable)
497 > """multirevs extension
497 > """multirevs extension
498 > Big multi-line module docstring."""
498 > Big multi-line module docstring."""
499 > @command('multirevs', [], 'ARG', norepo=True)
499 > @command('multirevs', [], 'ARG', norepo=True)
500 > def multirevs(ui, repo, arg, *args, **opts):
500 > def multirevs(ui, repo, arg, *args, **opts):
501 > """multirevs command"""
501 > """multirevs command"""
502 > pass
502 > pass
503 > EOF
503 > EOF
504 $ echo "multirevs = multirevs.py" >> $HGRCPATH
504 $ echo "multirevs = multirevs.py" >> $HGRCPATH
505
505
506 $ hg help multirevs
506 $ hg help multirevs
507 Specifying Multiple Revisions
507 Specifying Multiple Revisions
508 """""""""""""""""""""""""""""
508 """""""""""""""""""""""""""""
509
509
510 When Mercurial accepts more than one revision, they may be specified
510 When Mercurial accepts more than one revision, they may be specified
511 individually, or provided as a topologically continuous range, separated
511 individually, or provided as a topologically continuous range, separated
512 by the ":" character.
512 by the ":" character.
513
513
514 The syntax of range notation is [BEGIN]:[END], where BEGIN and END are
514 The syntax of range notation is [BEGIN]:[END], where BEGIN and END are
515 revision identifiers. Both BEGIN and END are optional. If BEGIN is not
515 revision identifiers. Both BEGIN and END are optional. If BEGIN is not
516 specified, it defaults to revision number 0. If END is not specified, it
516 specified, it defaults to revision number 0. If END is not specified, it
517 defaults to the tip. The range ":" thus means "all revisions".
517 defaults to the tip. The range ":" thus means "all revisions".
518
518
519 If BEGIN is greater than END, revisions are treated in reverse order.
519 If BEGIN is greater than END, revisions are treated in reverse order.
520
520
521 A range acts as a closed interval. This means that a range of 3:5 gives 3,
521 A range acts as a closed interval. This means that a range of 3:5 gives 3,
522 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
522 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
523
523
524 use "hg help -c multirevs" to see help for the multirevs command
524 use "hg help -c multirevs" to see help for the multirevs command
525
525
526
526
527
527
528
528
529
529
530
530
531 $ hg help -c multirevs
531 $ hg help -c multirevs
532 hg multirevs ARG
532 hg multirevs ARG
533
533
534 multirevs command
534 multirevs command
535
535
536 (some details hidden, use --verbose to show complete help)
536 (some details hidden, use --verbose to show complete help)
537
537
538
538
539
539
540 $ hg multirevs
540 $ hg multirevs
541 hg multirevs: invalid arguments
541 hg multirevs: invalid arguments
542 hg multirevs ARG
542 hg multirevs ARG
543
543
544 multirevs command
544 multirevs command
545
545
546 (use "hg multirevs -h" to show more help)
546 (use "hg multirevs -h" to show more help)
547 [255]
547 [255]
548
548
549
549
550
550
551 $ echo "multirevs = !" >> $HGRCPATH
551 $ echo "multirevs = !" >> $HGRCPATH
552
552
553 Issue811: Problem loading extensions twice (by site and by user)
553 Issue811: Problem loading extensions twice (by site and by user)
554
554
555 $ debugpath=`pwd`/debugissue811.py
555 $ debugpath=`pwd`/debugissue811.py
556 $ cat > debugissue811.py <<EOF
556 $ cat > debugissue811.py <<EOF
557 > '''show all loaded extensions
557 > '''show all loaded extensions
558 > '''
558 > '''
559 > from mercurial import cmdutil, commands, extensions
559 > from mercurial import cmdutil, commands, extensions
560 > cmdtable = {}
560 > cmdtable = {}
561 > command = cmdutil.command(cmdtable)
561 > command = cmdutil.command(cmdtable)
562 > @command('debugextensions', [], 'hg debugextensions', norepo=True)
562 > @command('debugextensions', [], 'hg debugextensions', norepo=True)
563 > def debugextensions(ui):
563 > def debugextensions(ui):
564 > "yet another debug command"
564 > "yet another debug command"
565 > ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
565 > ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
566 > EOF
566 > EOF
567 $ echo "debugissue811 = $debugpath" >> $HGRCPATH
567 $ echo "debugissue811 = $debugpath" >> $HGRCPATH
568 $ echo "mq=" >> $HGRCPATH
568 $ echo "mq=" >> $HGRCPATH
569 $ echo "strip=" >> $HGRCPATH
569 $ echo "strip=" >> $HGRCPATH
570 $ echo "hgext.mq=" >> $HGRCPATH
570 $ echo "hgext.mq=" >> $HGRCPATH
571 $ echo "hgext/mq=" >> $HGRCPATH
571 $ echo "hgext/mq=" >> $HGRCPATH
572
572
573 Show extensions:
573 Show extensions:
574 (note that mq force load strip, also checking it's not loaded twice)
574 (note that mq force load strip, also checking it's not loaded twice)
575
575
576 $ hg debugextensions
576 $ hg debugextensions
577 debugissue811
577 debugissue811
578 strip
578 strip
579 mq
579 mq
580
580
581 Disabled extension commands:
581 Disabled extension commands:
582
582
583 $ ORGHGRCPATH=$HGRCPATH
583 $ ORGHGRCPATH=$HGRCPATH
584 $ HGRCPATH=
584 $ HGRCPATH=
585 $ export HGRCPATH
585 $ export HGRCPATH
586 $ hg help email
586 $ hg help email
587 'email' is provided by the following extension:
587 'email' is provided by the following extension:
588
588
589 patchbomb command to send changesets as (a series of) patch emails
589 patchbomb command to send changesets as (a series of) patch emails
590
590
591 use "hg help extensions" for information on enabling extensions
591 use "hg help extensions" for information on enabling extensions
592
592
593
593
594 $ hg qdel
594 $ hg qdel
595 hg: unknown command 'qdel'
595 hg: unknown command 'qdel'
596 'qdelete' is provided by the following extension:
596 'qdelete' is provided by the following extension:
597
597
598 mq manage a stack of patches
598 mq manage a stack of patches
599
599
600 use "hg help extensions" for information on enabling extensions
600 use "hg help extensions" for information on enabling extensions
601 [255]
601 [255]
602
602
603
603
604 $ hg churn
604 $ hg churn
605 hg: unknown command 'churn'
605 hg: unknown command 'churn'
606 'churn' is provided by the following extension:
606 'churn' is provided by the following extension:
607
607
608 churn command to display statistics about repository history
608 churn command to display statistics about repository history
609
609
610 use "hg help extensions" for information on enabling extensions
610 use "hg help extensions" for information on enabling extensions
611 [255]
611 [255]
612
612
613
613
614
614
615 Disabled extensions:
615 Disabled extensions:
616
616
617 $ hg help churn
617 $ hg help churn
618 churn extension - command to display statistics about repository history
618 churn extension - command to display statistics about repository history
619
619
620 use "hg help extensions" for information on enabling extensions
620 use "hg help extensions" for information on enabling extensions
621
621
622 $ hg help patchbomb
622 $ hg help patchbomb
623 patchbomb extension - command to send changesets as (a series of) patch emails
623 patchbomb extension - command to send changesets as (a series of) patch emails
624
624
625 use "hg help extensions" for information on enabling extensions
625 use "hg help extensions" for information on enabling extensions
626
626
627
627
628 Broken disabled extension and command:
628 Broken disabled extension and command:
629
629
630 $ mkdir hgext
630 $ mkdir hgext
631 $ echo > hgext/__init__.py
631 $ echo > hgext/__init__.py
632 $ cat > hgext/broken.py <<EOF
632 $ cat > hgext/broken.py <<EOF
633 > "broken extension'
633 > "broken extension'
634 > EOF
634 > EOF
635 $ cat > path.py <<EOF
635 $ cat > path.py <<EOF
636 > import os, sys
636 > import os, sys
637 > sys.path.insert(0, os.environ['HGEXTPATH'])
637 > sys.path.insert(0, os.environ['HGEXTPATH'])
638 > EOF
638 > EOF
639 $ HGEXTPATH=`pwd`
639 $ HGEXTPATH=`pwd`
640 $ export HGEXTPATH
640 $ export HGEXTPATH
641
641
642 $ hg --config extensions.path=./path.py help broken
642 $ hg --config extensions.path=./path.py help broken
643 broken extension - (no help text available)
643 broken extension - (no help text available)
644
644
645 use "hg help extensions" for information on enabling extensions
645 use "hg help extensions" for information on enabling extensions
646
646
647
647
648 $ cat > hgext/forest.py <<EOF
648 $ cat > hgext/forest.py <<EOF
649 > cmdtable = None
649 > cmdtable = None
650 > EOF
650 > EOF
651 $ hg --config extensions.path=./path.py help foo > /dev/null
651 $ hg --config extensions.path=./path.py help foo > /dev/null
652 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
652 warning: error finding commands in $TESTTMP/hgext/forest.py (glob)
653 abort: no such help topic: foo
653 abort: no such help topic: foo
654 (try "hg help --keyword foo")
654 (try "hg help --keyword foo")
655 [255]
655 [255]
656
656
657 $ cat > throw.py <<EOF
657 $ cat > throw.py <<EOF
658 > from mercurial import cmdutil, commands
658 > from mercurial import cmdutil, commands
659 > cmdtable = {}
659 > cmdtable = {}
660 > command = cmdutil.command(cmdtable)
660 > command = cmdutil.command(cmdtable)
661 > class Bogon(Exception): pass
661 > class Bogon(Exception): pass
662 > @command('throw', [], 'hg throw', norepo=True)
662 > @command('throw', [], 'hg throw', norepo=True)
663 > def throw(ui, **opts):
663 > def throw(ui, **opts):
664 > """throws an exception"""
664 > """throws an exception"""
665 > raise Bogon()
665 > raise Bogon()
666 > EOF
666 > EOF
667 No declared supported version, extension complains:
667 No declared supported version, extension complains:
668 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
668 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
669 ** Unknown exception encountered with possibly-broken third-party extension throw
669 ** Unknown exception encountered with possibly-broken third-party extension throw
670 ** which supports versions unknown of Mercurial.
670 ** which supports versions unknown of Mercurial.
671 ** Please disable throw and try your action again.
671 ** Please disable throw and try your action again.
672 ** If that fixes the bug please report it to the extension author.
672 ** If that fixes the bug please report it to the extension author.
673 ** Python * (glob)
673 ** Python * (glob)
674 ** Mercurial Distributed SCM * (glob)
674 ** Mercurial Distributed SCM * (glob)
675 ** Extensions loaded: throw
675 ** Extensions loaded: throw
676 empty declaration of supported version, extension complains:
676 empty declaration of supported version, extension complains:
677 $ echo "testedwith = ''" >> throw.py
677 $ echo "testedwith = ''" >> throw.py
678 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
678 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
679 ** Unknown exception encountered with possibly-broken third-party extension throw
679 ** Unknown exception encountered with possibly-broken third-party extension throw
680 ** which supports versions unknown of Mercurial.
680 ** which supports versions unknown of Mercurial.
681 ** Please disable throw and try your action again.
681 ** Please disable throw and try your action again.
682 ** If that fixes the bug please report it to the extension author.
682 ** If that fixes the bug please report it to the extension author.
683 ** Python * (glob)
683 ** Python * (glob)
684 ** Mercurial Distributed SCM (*) (glob)
684 ** Mercurial Distributed SCM (*) (glob)
685 ** Extensions loaded: throw
685 ** Extensions loaded: throw
686 If the extension specifies a buglink, show that:
686 If the extension specifies a buglink, show that:
687 $ echo 'buglink = "http://example.com/bts"' >> throw.py
687 $ echo 'buglink = "http://example.com/bts"' >> throw.py
688 $ rm -f throw.pyc throw.pyo
688 $ rm -f throw.pyc throw.pyo
689 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
689 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
690 ** Unknown exception encountered with possibly-broken third-party extension throw
690 ** Unknown exception encountered with possibly-broken third-party extension throw
691 ** which supports versions unknown of Mercurial.
691 ** which supports versions unknown of Mercurial.
692 ** Please disable throw and try your action again.
692 ** Please disable throw and try your action again.
693 ** If that fixes the bug please report it to http://example.com/bts
693 ** If that fixes the bug please report it to http://example.com/bts
694 ** Python * (glob)
694 ** Python * (glob)
695 ** Mercurial Distributed SCM (*) (glob)
695 ** Mercurial Distributed SCM (*) (glob)
696 ** Extensions loaded: throw
696 ** Extensions loaded: throw
697 If the extensions declare outdated versions, accuse the older extension first:
697 If the extensions declare outdated versions, accuse the older extension first:
698 $ echo "from mercurial import util" >> older.py
698 $ echo "from mercurial import util" >> older.py
699 $ echo "util.version = lambda:'2.2'" >> older.py
699 $ echo "util.version = lambda:'2.2'" >> older.py
700 $ echo "testedwith = '1.9.3'" >> older.py
700 $ echo "testedwith = '1.9.3'" >> older.py
701 $ echo "testedwith = '2.1.1'" >> throw.py
701 $ echo "testedwith = '2.1.1'" >> throw.py
702 $ rm -f throw.pyc throw.pyo
702 $ rm -f throw.pyc throw.pyo
703 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
703 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
704 > throw 2>&1 | egrep '^\*\*'
704 > throw 2>&1 | egrep '^\*\*'
705 ** Unknown exception encountered with possibly-broken third-party extension older
705 ** Unknown exception encountered with possibly-broken third-party extension older
706 ** which supports versions 1.9.3 of Mercurial.
706 ** which supports versions 1.9.3 of Mercurial.
707 ** Please disable older and try your action again.
707 ** Please disable older and try your action again.
708 ** If that fixes the bug please report it to the extension author.
708 ** If that fixes the bug please report it to the extension author.
709 ** Python * (glob)
709 ** Python * (glob)
710 ** Mercurial Distributed SCM (version 2.2)
710 ** Mercurial Distributed SCM (version 2.2)
711 ** Extensions loaded: throw, older
711 ** Extensions loaded: throw, older
712 One extension only tested with older, one only with newer versions:
712 One extension only tested with older, one only with newer versions:
713 $ echo "util.version = lambda:'2.1.0'" >> older.py
713 $ echo "util.version = lambda:'2.1.0'" >> older.py
714 $ rm -f older.pyc older.pyo
714 $ rm -f older.pyc older.pyo
715 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
715 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
716 > throw 2>&1 | egrep '^\*\*'
716 > throw 2>&1 | egrep '^\*\*'
717 ** Unknown exception encountered with possibly-broken third-party extension older
717 ** Unknown exception encountered with possibly-broken third-party extension older
718 ** which supports versions 1.9.3 of Mercurial.
718 ** which supports versions 1.9.3 of Mercurial.
719 ** Please disable older and try your action again.
719 ** Please disable older and try your action again.
720 ** If that fixes the bug please report it to the extension author.
720 ** If that fixes the bug please report it to the extension author.
721 ** Python * (glob)
721 ** Python * (glob)
722 ** Mercurial Distributed SCM (version 2.1.0)
722 ** Mercurial Distributed SCM (version 2.1.0)
723 ** Extensions loaded: throw, older
723 ** Extensions loaded: throw, older
724 Older extension is tested with current version, the other only with newer:
724 Older extension is tested with current version, the other only with newer:
725 $ echo "util.version = lambda:'1.9.3'" >> older.py
725 $ echo "util.version = lambda:'1.9.3'" >> older.py
726 $ rm -f older.pyc older.pyo
726 $ rm -f older.pyc older.pyo
727 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
727 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
728 > throw 2>&1 | egrep '^\*\*'
728 > throw 2>&1 | egrep '^\*\*'
729 ** Unknown exception encountered with possibly-broken third-party extension throw
729 ** Unknown exception encountered with possibly-broken third-party extension throw
730 ** which supports versions 2.1.1 of Mercurial.
730 ** which supports versions 2.1.1 of Mercurial.
731 ** Please disable throw and try your action again.
731 ** Please disable throw and try your action again.
732 ** If that fixes the bug please report it to http://example.com/bts
732 ** If that fixes the bug please report it to http://example.com/bts
733 ** Python * (glob)
733 ** Python * (glob)
734 ** Mercurial Distributed SCM (version 1.9.3)
734 ** Mercurial Distributed SCM (version 1.9.3)
735 ** Extensions loaded: throw, older
735 ** Extensions loaded: throw, older
736
736
737 Declare the version as supporting this hg version, show regular bts link:
737 Declare the version as supporting this hg version, show regular bts link:
738 $ hgver=`python -c 'from mercurial import util; print util.version().split("+")[0]'`
738 $ hgver=`python -c 'from mercurial import util; print util.version().split("+")[0]'`
739 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
739 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
740 $ rm -f throw.pyc throw.pyo
740 $ rm -f throw.pyc throw.pyo
741 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
741 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
742 ** unknown exception encountered, please report by visiting
742 ** unknown exception encountered, please report by visiting
743 ** http://mercurial.selenic.com/wiki/BugTracker
743 ** http://mercurial.selenic.com/wiki/BugTracker
744 ** Python * (glob)
744 ** Python * (glob)
745 ** Mercurial Distributed SCM (*) (glob)
745 ** Mercurial Distributed SCM (*) (glob)
746 ** Extensions loaded: throw
746 ** Extensions loaded: throw
747
747
748 Test version number support in 'hg version':
748 Test version number support in 'hg version':
749 $ echo '__version__ = (1, 2, 3)' >> throw.py
749 $ echo '__version__ = (1, 2, 3)' >> throw.py
750 $ rm -f throw.pyc throw.pyo
750 $ rm -f throw.pyc throw.pyo
751 $ hg version -v
751 $ hg version -v
752 Mercurial Distributed SCM (version *) (glob)
752 Mercurial Distributed SCM (version *) (glob)
753 (see http://mercurial.selenic.com for more information)
753 (see http://mercurial.selenic.com for more information)
754
754
755 Copyright (C) 2005-* Matt Mackall and others (glob)
755 Copyright (C) 2005-* Matt Mackall and others (glob)
756 This is free software; see the source for copying conditions. There is NO
756 This is free software; see the source for copying conditions. There is NO
757 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
757 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
758
758
759 Enabled extensions:
759 Enabled extensions:
760
760
761
761
762 $ hg version -v --config extensions.throw=throw.py
762 $ hg version -v --config extensions.throw=throw.py
763 Mercurial Distributed SCM (version *) (glob)
763 Mercurial Distributed SCM (version *) (glob)
764 (see http://mercurial.selenic.com for more information)
764 (see http://mercurial.selenic.com for more information)
765
765
766 Copyright (C) 2005-* Matt Mackall and others (glob)
766 Copyright (C) 2005-* Matt Mackall and others (glob)
767 This is free software; see the source for copying conditions. There is NO
767 This is free software; see the source for copying conditions. There is NO
768 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
768 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
769
769
770 Enabled extensions:
770 Enabled extensions:
771
771
772 throw 1.2.3
772 throw 1.2.3
773 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
773 $ echo 'getversion = lambda: "1.twentythree"' >> throw.py
774 $ rm -f throw.pyc throw.pyo
774 $ rm -f throw.pyc throw.pyo
775 $ hg version -v --config extensions.throw=throw.py
775 $ hg version -v --config extensions.throw=throw.py
776 Mercurial Distributed SCM (version *) (glob)
776 Mercurial Distributed SCM (version *) (glob)
777 (see http://mercurial.selenic.com for more information)
777 (see http://mercurial.selenic.com for more information)
778
778
779 Copyright (C) 2005-* Matt Mackall and others (glob)
779 Copyright (C) 2005-* Matt Mackall and others (glob)
780 This is free software; see the source for copying conditions. There is NO
780 This is free software; see the source for copying conditions. There is NO
781 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
781 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
782
782
783 Enabled extensions:
783 Enabled extensions:
784
784
785 throw 1.twentythree
785 throw 1.twentythree
786
786
787 Restore HGRCPATH
787 Restore HGRCPATH
788
788
789 $ HGRCPATH=$ORGHGRCPATH
789 $ HGRCPATH=$ORGHGRCPATH
790 $ export HGRCPATH
790 $ export HGRCPATH
791
791
792 Commands handling multiple repositories at a time should invoke only
792 Commands handling multiple repositories at a time should invoke only
793 "reposetup()" of extensions enabling in the target repository.
793 "reposetup()" of extensions enabling in the target repository.
794
794
795 $ mkdir reposetup-test
795 $ mkdir reposetup-test
796 $ cd reposetup-test
796 $ cd reposetup-test
797
797
798 $ cat > $TESTTMP/reposetuptest.py <<EOF
798 $ cat > $TESTTMP/reposetuptest.py <<EOF
799 > from mercurial import extensions
799 > from mercurial import extensions
800 > def reposetup(ui, repo):
800 > def reposetup(ui, repo):
801 > ui.write('reposetup() for %s\n' % (repo.root))
801 > ui.write('reposetup() for %s\n' % (repo.root))
802 > EOF
802 > EOF
803 $ hg init src
803 $ hg init src
804 $ echo a > src/a
804 $ echo a > src/a
805 $ hg -R src commit -Am '#0 at src/a'
805 $ hg -R src commit -Am '#0 at src/a'
806 adding a
806 adding a
807 $ echo '[extensions]' >> src/.hg/hgrc
807 $ echo '[extensions]' >> src/.hg/hgrc
808 $ echo '# enable extension locally' >> src/.hg/hgrc
808 $ echo '# enable extension locally' >> src/.hg/hgrc
809 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
809 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
810 $ hg -R src status
810 $ hg -R src status
811 reposetup() for $TESTTMP/reposetup-test/src (glob)
811 reposetup() for $TESTTMP/reposetup-test/src (glob)
812
812
813 $ hg clone -U src clone-dst1
813 $ hg clone -U src clone-dst1
814 reposetup() for $TESTTMP/reposetup-test/src (glob)
814 reposetup() for $TESTTMP/reposetup-test/src (glob)
815 $ hg init push-dst1
815 $ hg init push-dst1
816 $ hg -q -R src push push-dst1
816 $ hg -q -R src push push-dst1
817 reposetup() for $TESTTMP/reposetup-test/src (glob)
817 reposetup() for $TESTTMP/reposetup-test/src (glob)
818 $ hg init pull-src1
818 $ hg init pull-src1
819 $ hg -q -R pull-src1 pull src
819 $ hg -q -R pull-src1 pull src
820 reposetup() for $TESTTMP/reposetup-test/src (glob)
820 reposetup() for $TESTTMP/reposetup-test/src (glob)
821
821
822 $ echo '[extensions]' >> $HGRCPATH
822 $ echo '[extensions]' >> $HGRCPATH
823 $ echo '# disable extension globally and explicitly' >> $HGRCPATH
823 $ echo '# disable extension globally and explicitly' >> $HGRCPATH
824 $ echo 'reposetuptest = !' >> $HGRCPATH
824 $ echo 'reposetuptest = !' >> $HGRCPATH
825 $ hg clone -U src clone-dst2
825 $ hg clone -U src clone-dst2
826 reposetup() for $TESTTMP/reposetup-test/src (glob)
826 reposetup() for $TESTTMP/reposetup-test/src (glob)
827 $ hg init push-dst2
827 $ hg init push-dst2
828 $ hg -q -R src push push-dst2
828 $ hg -q -R src push push-dst2
829 reposetup() for $TESTTMP/reposetup-test/src (glob)
829 reposetup() for $TESTTMP/reposetup-test/src (glob)
830 $ hg init pull-src2
830 $ hg init pull-src2
831 $ hg -q -R pull-src2 pull src
831 $ hg -q -R pull-src2 pull src
832 reposetup() for $TESTTMP/reposetup-test/src (glob)
832 reposetup() for $TESTTMP/reposetup-test/src (glob)
833
833
834 $ echo '[extensions]' >> $HGRCPATH
834 $ echo '[extensions]' >> $HGRCPATH
835 $ echo '# enable extension globally' >> $HGRCPATH
835 $ echo '# enable extension globally' >> $HGRCPATH
836 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> $HGRCPATH
836 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> $HGRCPATH
837 $ hg clone -U src clone-dst3
837 $ hg clone -U src clone-dst3
838 reposetup() for $TESTTMP/reposetup-test/src (glob)
838 reposetup() for $TESTTMP/reposetup-test/src (glob)
839 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
839 reposetup() for $TESTTMP/reposetup-test/clone-dst3 (glob)
840 $ hg init push-dst3
840 $ hg init push-dst3
841 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
841 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
842 $ hg -q -R src push push-dst3
842 $ hg -q -R src push push-dst3
843 reposetup() for $TESTTMP/reposetup-test/src (glob)
843 reposetup() for $TESTTMP/reposetup-test/src (glob)
844 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
844 reposetup() for $TESTTMP/reposetup-test/push-dst3 (glob)
845 $ hg init pull-src3
845 $ hg init pull-src3
846 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
846 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
847 $ hg -q -R pull-src3 pull src
847 $ hg -q -R pull-src3 pull src
848 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
848 reposetup() for $TESTTMP/reposetup-test/pull-src3 (glob)
849 reposetup() for $TESTTMP/reposetup-test/src (glob)
849 reposetup() for $TESTTMP/reposetup-test/src (glob)
850
850
851 $ echo '[extensions]' >> src/.hg/hgrc
851 $ echo '[extensions]' >> src/.hg/hgrc
852 $ echo '# disable extension locally' >> src/.hg/hgrc
852 $ echo '# disable extension locally' >> src/.hg/hgrc
853 $ echo 'reposetuptest = !' >> src/.hg/hgrc
853 $ echo 'reposetuptest = !' >> src/.hg/hgrc
854 $ hg clone -U src clone-dst4
854 $ hg clone -U src clone-dst4
855 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
855 reposetup() for $TESTTMP/reposetup-test/clone-dst4 (glob)
856 $ hg init push-dst4
856 $ hg init push-dst4
857 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
857 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
858 $ hg -q -R src push push-dst4
858 $ hg -q -R src push push-dst4
859 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
859 reposetup() for $TESTTMP/reposetup-test/push-dst4 (glob)
860 $ hg init pull-src4
860 $ hg init pull-src4
861 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
861 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
862 $ hg -q -R pull-src4 pull src
862 $ hg -q -R pull-src4 pull src
863 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
863 reposetup() for $TESTTMP/reposetup-test/pull-src4 (glob)
864
864
865 disabling in command line overlays with all configuration
865 disabling in command line overlays with all configuration
866 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
866 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
867 $ hg --config extensions.reposetuptest=! init push-dst5
867 $ hg --config extensions.reposetuptest=! init push-dst5
868 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
868 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
869 $ hg --config extensions.reposetuptest=! init pull-src5
869 $ hg --config extensions.reposetuptest=! init pull-src5
870 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
870 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
871
871
872 $ echo '[extensions]' >> $HGRCPATH
872 $ echo '[extensions]' >> $HGRCPATH
873 $ echo '# disable extension globally and explicitly' >> $HGRCPATH
873 $ echo '# disable extension globally and explicitly' >> $HGRCPATH
874 $ echo 'reposetuptest = !' >> $HGRCPATH
874 $ echo 'reposetuptest = !' >> $HGRCPATH
875 $ hg init parent
875 $ hg init parent
876 $ hg init parent/sub1
876 $ hg init parent/sub1
877 $ echo 1 > parent/sub1/1
877 $ echo 1 > parent/sub1/1
878 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
878 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
879 adding 1
879 adding 1
880 $ hg init parent/sub2
880 $ hg init parent/sub2
881 $ hg init parent/sub2/sub21
881 $ hg init parent/sub2/sub21
882 $ echo 21 > parent/sub2/sub21/21
882 $ echo 21 > parent/sub2/sub21/21
883 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
883 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
884 adding 21
884 adding 21
885 $ cat > parent/sub2/.hgsub <<EOF
885 $ cat > parent/sub2/.hgsub <<EOF
886 > sub21 = sub21
886 > sub21 = sub21
887 > EOF
887 > EOF
888 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
888 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
889 adding .hgsub
889 adding .hgsub
890 $ hg init parent/sub3
890 $ hg init parent/sub3
891 $ echo 3 > parent/sub3/3
891 $ echo 3 > parent/sub3/3
892 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
892 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
893 adding 3
893 adding 3
894 $ cat > parent/.hgsub <<EOF
894 $ cat > parent/.hgsub <<EOF
895 > sub1 = sub1
895 > sub1 = sub1
896 > sub2 = sub2
896 > sub2 = sub2
897 > sub3 = sub3
897 > sub3 = sub3
898 > EOF
898 > EOF
899 $ hg -R parent commit -Am '#0 at parent'
899 $ hg -R parent commit -Am '#0 at parent'
900 adding .hgsub
900 adding .hgsub
901 $ echo '[extensions]' >> parent/.hg/hgrc
901 $ echo '[extensions]' >> parent/.hg/hgrc
902 $ echo '# enable extension locally' >> parent/.hg/hgrc
902 $ echo '# enable extension locally' >> parent/.hg/hgrc
903 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
903 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
904 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
904 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
905 $ hg -R parent status -S -A
905 $ hg -R parent status -S -A
906 reposetup() for $TESTTMP/reposetup-test/parent (glob)
906 reposetup() for $TESTTMP/reposetup-test/parent (glob)
907 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
907 reposetup() for $TESTTMP/reposetup-test/parent/sub2 (glob)
908 C .hgsub
908 C .hgsub
909 C .hgsubstate
909 C .hgsubstate
910 C sub1/1
910 C sub1/1
911 C sub2/.hgsub
911 C sub2/.hgsub
912 C sub2/.hgsubstate
912 C sub2/.hgsubstate
913 C sub2/sub21/21
913 C sub2/sub21/21
914 C sub3/3
914 C sub3/3
915
915
916 $ cd ..
916 $ cd ..
@@ -1,551 +1,551 b''
1 $ echo "[extensions]" >> $HGRCPATH
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "strip=" >> $HGRCPATH
2 $ echo "strip=" >> $HGRCPATH
3
3
4 $ restore() {
4 $ restore() {
5 > hg unbundle -q .hg/strip-backup/*
5 > hg unbundle -q .hg/strip-backup/*
6 > rm .hg/strip-backup/*
6 > rm .hg/strip-backup/*
7 > }
7 > }
8 $ teststrip() {
8 $ teststrip() {
9 > hg up -C $1
9 > hg up -C $1
10 > echo % before update $1, strip $2
10 > echo % before update $1, strip $2
11 > hg parents
11 > hg parents
12 > hg --traceback strip $2
12 > hg --traceback strip $2
13 > echo % after update $1, strip $2
13 > echo % after update $1, strip $2
14 > hg parents
14 > hg parents
15 > restore
15 > restore
16 > }
16 > }
17
17
18 $ hg init test
18 $ hg init test
19 $ cd test
19 $ cd test
20
20
21 $ echo foo > bar
21 $ echo foo > bar
22 $ hg ci -Ama
22 $ hg ci -Ama
23 adding bar
23 adding bar
24
24
25 $ echo more >> bar
25 $ echo more >> bar
26 $ hg ci -Amb
26 $ hg ci -Amb
27
27
28 $ echo blah >> bar
28 $ echo blah >> bar
29 $ hg ci -Amc
29 $ hg ci -Amc
30
30
31 $ hg up 1
31 $ hg up 1
32 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
33 $ echo blah >> bar
33 $ echo blah >> bar
34 $ hg ci -Amd
34 $ hg ci -Amd
35 created new head
35 created new head
36
36
37 $ echo final >> bar
37 $ echo final >> bar
38 $ hg ci -Ame
38 $ hg ci -Ame
39
39
40 $ hg log
40 $ hg log
41 changeset: 4:443431ffac4f
41 changeset: 4:443431ffac4f
42 tag: tip
42 tag: tip
43 user: test
43 user: test
44 date: Thu Jan 01 00:00:00 1970 +0000
44 date: Thu Jan 01 00:00:00 1970 +0000
45 summary: e
45 summary: e
46
46
47 changeset: 3:65bd5f99a4a3
47 changeset: 3:65bd5f99a4a3
48 parent: 1:ef3a871183d7
48 parent: 1:ef3a871183d7
49 user: test
49 user: test
50 date: Thu Jan 01 00:00:00 1970 +0000
50 date: Thu Jan 01 00:00:00 1970 +0000
51 summary: d
51 summary: d
52
52
53 changeset: 2:264128213d29
53 changeset: 2:264128213d29
54 user: test
54 user: test
55 date: Thu Jan 01 00:00:00 1970 +0000
55 date: Thu Jan 01 00:00:00 1970 +0000
56 summary: c
56 summary: c
57
57
58 changeset: 1:ef3a871183d7
58 changeset: 1:ef3a871183d7
59 user: test
59 user: test
60 date: Thu Jan 01 00:00:00 1970 +0000
60 date: Thu Jan 01 00:00:00 1970 +0000
61 summary: b
61 summary: b
62
62
63 changeset: 0:9ab35a2d17cb
63 changeset: 0:9ab35a2d17cb
64 user: test
64 user: test
65 date: Thu Jan 01 00:00:00 1970 +0000
65 date: Thu Jan 01 00:00:00 1970 +0000
66 summary: a
66 summary: a
67
67
68
68
69 $ teststrip 4 4
69 $ teststrip 4 4
70 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
71 % before update 4, strip 4
71 % before update 4, strip 4
72 changeset: 4:443431ffac4f
72 changeset: 4:443431ffac4f
73 tag: tip
73 tag: tip
74 user: test
74 user: test
75 date: Thu Jan 01 00:00:00 1970 +0000
75 date: Thu Jan 01 00:00:00 1970 +0000
76 summary: e
76 summary: e
77
77
78 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
79 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
79 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
80 % after update 4, strip 4
80 % after update 4, strip 4
81 changeset: 3:65bd5f99a4a3
81 changeset: 3:65bd5f99a4a3
82 tag: tip
82 tag: tip
83 parent: 1:ef3a871183d7
83 parent: 1:ef3a871183d7
84 user: test
84 user: test
85 date: Thu Jan 01 00:00:00 1970 +0000
85 date: Thu Jan 01 00:00:00 1970 +0000
86 summary: d
86 summary: d
87
87
88 $ teststrip 4 3
88 $ teststrip 4 3
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 % before update 4, strip 3
90 % before update 4, strip 3
91 changeset: 4:443431ffac4f
91 changeset: 4:443431ffac4f
92 tag: tip
92 tag: tip
93 user: test
93 user: test
94 date: Thu Jan 01 00:00:00 1970 +0000
94 date: Thu Jan 01 00:00:00 1970 +0000
95 summary: e
95 summary: e
96
96
97 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
98 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
98 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
99 % after update 4, strip 3
99 % after update 4, strip 3
100 changeset: 1:ef3a871183d7
100 changeset: 1:ef3a871183d7
101 user: test
101 user: test
102 date: Thu Jan 01 00:00:00 1970 +0000
102 date: Thu Jan 01 00:00:00 1970 +0000
103 summary: b
103 summary: b
104
104
105 $ teststrip 1 4
105 $ teststrip 1 4
106 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
106 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
107 % before update 1, strip 4
107 % before update 1, strip 4
108 changeset: 1:ef3a871183d7
108 changeset: 1:ef3a871183d7
109 user: test
109 user: test
110 date: Thu Jan 01 00:00:00 1970 +0000
110 date: Thu Jan 01 00:00:00 1970 +0000
111 summary: b
111 summary: b
112
112
113 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
113 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
114 % after update 1, strip 4
114 % after update 1, strip 4
115 changeset: 1:ef3a871183d7
115 changeset: 1:ef3a871183d7
116 user: test
116 user: test
117 date: Thu Jan 01 00:00:00 1970 +0000
117 date: Thu Jan 01 00:00:00 1970 +0000
118 summary: b
118 summary: b
119
119
120 $ teststrip 4 2
120 $ teststrip 4 2
121 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
121 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 % before update 4, strip 2
122 % before update 4, strip 2
123 changeset: 4:443431ffac4f
123 changeset: 4:443431ffac4f
124 tag: tip
124 tag: tip
125 user: test
125 user: test
126 date: Thu Jan 01 00:00:00 1970 +0000
126 date: Thu Jan 01 00:00:00 1970 +0000
127 summary: e
127 summary: e
128
128
129 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
129 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
130 % after update 4, strip 2
130 % after update 4, strip 2
131 changeset: 3:443431ffac4f
131 changeset: 3:443431ffac4f
132 tag: tip
132 tag: tip
133 user: test
133 user: test
134 date: Thu Jan 01 00:00:00 1970 +0000
134 date: Thu Jan 01 00:00:00 1970 +0000
135 summary: e
135 summary: e
136
136
137 $ teststrip 4 1
137 $ teststrip 4 1
138 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
138 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
139 % before update 4, strip 1
139 % before update 4, strip 1
140 changeset: 4:264128213d29
140 changeset: 4:264128213d29
141 tag: tip
141 tag: tip
142 parent: 1:ef3a871183d7
142 parent: 1:ef3a871183d7
143 user: test
143 user: test
144 date: Thu Jan 01 00:00:00 1970 +0000
144 date: Thu Jan 01 00:00:00 1970 +0000
145 summary: c
145 summary: c
146
146
147 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
147 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
148 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
148 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
149 % after update 4, strip 1
149 % after update 4, strip 1
150 changeset: 0:9ab35a2d17cb
150 changeset: 0:9ab35a2d17cb
151 tag: tip
151 tag: tip
152 user: test
152 user: test
153 date: Thu Jan 01 00:00:00 1970 +0000
153 date: Thu Jan 01 00:00:00 1970 +0000
154 summary: a
154 summary: a
155
155
156 $ teststrip null 4
156 $ teststrip null 4
157 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
157 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
158 % before update null, strip 4
158 % before update null, strip 4
159 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
159 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
160 % after update null, strip 4
160 % after update null, strip 4
161
161
162 $ hg log
162 $ hg log
163 changeset: 4:264128213d29
163 changeset: 4:264128213d29
164 tag: tip
164 tag: tip
165 parent: 1:ef3a871183d7
165 parent: 1:ef3a871183d7
166 user: test
166 user: test
167 date: Thu Jan 01 00:00:00 1970 +0000
167 date: Thu Jan 01 00:00:00 1970 +0000
168 summary: c
168 summary: c
169
169
170 changeset: 3:443431ffac4f
170 changeset: 3:443431ffac4f
171 user: test
171 user: test
172 date: Thu Jan 01 00:00:00 1970 +0000
172 date: Thu Jan 01 00:00:00 1970 +0000
173 summary: e
173 summary: e
174
174
175 changeset: 2:65bd5f99a4a3
175 changeset: 2:65bd5f99a4a3
176 user: test
176 user: test
177 date: Thu Jan 01 00:00:00 1970 +0000
177 date: Thu Jan 01 00:00:00 1970 +0000
178 summary: d
178 summary: d
179
179
180 changeset: 1:ef3a871183d7
180 changeset: 1:ef3a871183d7
181 user: test
181 user: test
182 date: Thu Jan 01 00:00:00 1970 +0000
182 date: Thu Jan 01 00:00:00 1970 +0000
183 summary: b
183 summary: b
184
184
185 changeset: 0:9ab35a2d17cb
185 changeset: 0:9ab35a2d17cb
186 user: test
186 user: test
187 date: Thu Jan 01 00:00:00 1970 +0000
187 date: Thu Jan 01 00:00:00 1970 +0000
188 summary: a
188 summary: a
189
189
190
190
191 $ hg up -C 2
191 $ hg up -C 2
192 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
192 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 $ hg merge 4
193 $ hg merge 4
194 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
194 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
195 (branch merge, don't forget to commit)
195 (branch merge, don't forget to commit)
196
196
197 before strip of merge parent
197 before strip of merge parent
198
198
199 $ hg parents
199 $ hg parents
200 changeset: 2:65bd5f99a4a3
200 changeset: 2:65bd5f99a4a3
201 user: test
201 user: test
202 date: Thu Jan 01 00:00:00 1970 +0000
202 date: Thu Jan 01 00:00:00 1970 +0000
203 summary: d
203 summary: d
204
204
205 changeset: 4:264128213d29
205 changeset: 4:264128213d29
206 tag: tip
206 tag: tip
207 parent: 1:ef3a871183d7
207 parent: 1:ef3a871183d7
208 user: test
208 user: test
209 date: Thu Jan 01 00:00:00 1970 +0000
209 date: Thu Jan 01 00:00:00 1970 +0000
210 summary: c
210 summary: c
211
211
212 $ hg strip 4
212 $ hg strip 4
213 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
214 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
214 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
215
215
216 after strip of merge parent
216 after strip of merge parent
217
217
218 $ hg parents
218 $ hg parents
219 changeset: 1:ef3a871183d7
219 changeset: 1:ef3a871183d7
220 user: test
220 user: test
221 date: Thu Jan 01 00:00:00 1970 +0000
221 date: Thu Jan 01 00:00:00 1970 +0000
222 summary: b
222 summary: b
223
223
224 $ restore
224 $ restore
225
225
226 $ hg up
226 $ hg up
227 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
227 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
228 $ hg log -G
228 $ hg log -G
229 @ changeset: 4:264128213d29
229 @ changeset: 4:264128213d29
230 | tag: tip
230 | tag: tip
231 | parent: 1:ef3a871183d7
231 | parent: 1:ef3a871183d7
232 | user: test
232 | user: test
233 | date: Thu Jan 01 00:00:00 1970 +0000
233 | date: Thu Jan 01 00:00:00 1970 +0000
234 | summary: c
234 | summary: c
235 |
235 |
236 | o changeset: 3:443431ffac4f
236 | o changeset: 3:443431ffac4f
237 | | user: test
237 | | user: test
238 | | date: Thu Jan 01 00:00:00 1970 +0000
238 | | date: Thu Jan 01 00:00:00 1970 +0000
239 | | summary: e
239 | | summary: e
240 | |
240 | |
241 | o changeset: 2:65bd5f99a4a3
241 | o changeset: 2:65bd5f99a4a3
242 |/ user: test
242 |/ user: test
243 | date: Thu Jan 01 00:00:00 1970 +0000
243 | date: Thu Jan 01 00:00:00 1970 +0000
244 | summary: d
244 | summary: d
245 |
245 |
246 o changeset: 1:ef3a871183d7
246 o changeset: 1:ef3a871183d7
247 | user: test
247 | user: test
248 | date: Thu Jan 01 00:00:00 1970 +0000
248 | date: Thu Jan 01 00:00:00 1970 +0000
249 | summary: b
249 | summary: b
250 |
250 |
251 o changeset: 0:9ab35a2d17cb
251 o changeset: 0:9ab35a2d17cb
252 user: test
252 user: test
253 date: Thu Jan 01 00:00:00 1970 +0000
253 date: Thu Jan 01 00:00:00 1970 +0000
254 summary: a
254 summary: a
255
255
256
256
257 2 is parent of 3, only one strip should happen
257 2 is parent of 3, only one strip should happen
258
258
259 $ hg strip "roots(2)" 3
259 $ hg strip "roots(2)" 3
260 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
260 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
261 $ hg log -G
261 $ hg log -G
262 @ changeset: 2:264128213d29
262 @ changeset: 2:264128213d29
263 | tag: tip
263 | tag: tip
264 | user: test
264 | user: test
265 | date: Thu Jan 01 00:00:00 1970 +0000
265 | date: Thu Jan 01 00:00:00 1970 +0000
266 | summary: c
266 | summary: c
267 |
267 |
268 o changeset: 1:ef3a871183d7
268 o changeset: 1:ef3a871183d7
269 | user: test
269 | user: test
270 | date: Thu Jan 01 00:00:00 1970 +0000
270 | date: Thu Jan 01 00:00:00 1970 +0000
271 | summary: b
271 | summary: b
272 |
272 |
273 o changeset: 0:9ab35a2d17cb
273 o changeset: 0:9ab35a2d17cb
274 user: test
274 user: test
275 date: Thu Jan 01 00:00:00 1970 +0000
275 date: Thu Jan 01 00:00:00 1970 +0000
276 summary: a
276 summary: a
277
277
278 $ restore
278 $ restore
279 $ hg log -G
279 $ hg log -G
280 o changeset: 4:443431ffac4f
280 o changeset: 4:443431ffac4f
281 | tag: tip
281 | tag: tip
282 | user: test
282 | user: test
283 | date: Thu Jan 01 00:00:00 1970 +0000
283 | date: Thu Jan 01 00:00:00 1970 +0000
284 | summary: e
284 | summary: e
285 |
285 |
286 o changeset: 3:65bd5f99a4a3
286 o changeset: 3:65bd5f99a4a3
287 | parent: 1:ef3a871183d7
287 | parent: 1:ef3a871183d7
288 | user: test
288 | user: test
289 | date: Thu Jan 01 00:00:00 1970 +0000
289 | date: Thu Jan 01 00:00:00 1970 +0000
290 | summary: d
290 | summary: d
291 |
291 |
292 | @ changeset: 2:264128213d29
292 | @ changeset: 2:264128213d29
293 |/ user: test
293 |/ user: test
294 | date: Thu Jan 01 00:00:00 1970 +0000
294 | date: Thu Jan 01 00:00:00 1970 +0000
295 | summary: c
295 | summary: c
296 |
296 |
297 o changeset: 1:ef3a871183d7
297 o changeset: 1:ef3a871183d7
298 | user: test
298 | user: test
299 | date: Thu Jan 01 00:00:00 1970 +0000
299 | date: Thu Jan 01 00:00:00 1970 +0000
300 | summary: b
300 | summary: b
301 |
301 |
302 o changeset: 0:9ab35a2d17cb
302 o changeset: 0:9ab35a2d17cb
303 user: test
303 user: test
304 date: Thu Jan 01 00:00:00 1970 +0000
304 date: Thu Jan 01 00:00:00 1970 +0000
305 summary: a
305 summary: a
306
306
307
307
308 2 different branches: 2 strips
308 2 different branches: 2 strips
309
309
310 $ hg strip 2 4
310 $ hg strip 2 4
311 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
311 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
312 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
312 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
313 $ hg log -G
313 $ hg log -G
314 o changeset: 2:65bd5f99a4a3
314 o changeset: 2:65bd5f99a4a3
315 | tag: tip
315 | tag: tip
316 | user: test
316 | user: test
317 | date: Thu Jan 01 00:00:00 1970 +0000
317 | date: Thu Jan 01 00:00:00 1970 +0000
318 | summary: d
318 | summary: d
319 |
319 |
320 @ changeset: 1:ef3a871183d7
320 @ changeset: 1:ef3a871183d7
321 | user: test
321 | user: test
322 | date: Thu Jan 01 00:00:00 1970 +0000
322 | date: Thu Jan 01 00:00:00 1970 +0000
323 | summary: b
323 | summary: b
324 |
324 |
325 o changeset: 0:9ab35a2d17cb
325 o changeset: 0:9ab35a2d17cb
326 user: test
326 user: test
327 date: Thu Jan 01 00:00:00 1970 +0000
327 date: Thu Jan 01 00:00:00 1970 +0000
328 summary: a
328 summary: a
329
329
330 $ restore
330 $ restore
331
331
332 2 different branches and a common ancestor: 1 strip
332 2 different branches and a common ancestor: 1 strip
333
333
334 $ hg strip 1 "2|4"
334 $ hg strip 1 "2|4"
335 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
335 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
336 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
336 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
337 $ restore
337 $ restore
338
338
339 verify fncache is kept up-to-date
339 verify fncache is kept up-to-date
340
340
341 $ touch a
341 $ touch a
342 $ hg ci -qAm a
342 $ hg ci -qAm a
343 $ cat .hg/store/fncache | sort
343 $ cat .hg/store/fncache | sort
344 data/a.i
344 data/a.i
345 data/bar.i
345 data/bar.i
346 $ hg strip tip
346 $ hg strip tip
347 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
347 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
348 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
348 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
349 $ cat .hg/store/fncache
349 $ cat .hg/store/fncache
350 data/bar.i
350 data/bar.i
351
351
352 stripping an empty revset
352 stripping an empty revset
353
353
354 $ hg strip "1 and not 1"
354 $ hg strip "1 and not 1"
355 abort: empty revision set
355 abort: empty revision set
356 [255]
356 [255]
357
357
358 remove branchy history for qimport tests
358 remove branchy history for qimport tests
359
359
360 $ hg strip 3
360 $ hg strip 3
361 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
361 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
362
362
363
363
364 strip of applied mq should cleanup status file
364 strip of applied mq should cleanup status file
365
365
366 $ echo "mq=" >> $HGRCPATH
366 $ echo "mq=" >> $HGRCPATH
367 $ hg up -C 3
367 $ hg up -C 3
368 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
368 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
369 $ echo fooagain >> bar
369 $ echo fooagain >> bar
370 $ hg ci -mf
370 $ hg ci -mf
371 $ hg qimport -r tip:2
371 $ hg qimport -r tip:2
372
372
373 applied patches before strip
373 applied patches before strip
374
374
375 $ hg qapplied
375 $ hg qapplied
376 2.diff
376 2.diff
377 3.diff
377 3.diff
378 4.diff
378 4.diff
379
379
380 stripping revision in queue
380 stripping revision in queue
381
381
382 $ hg strip 3
382 $ hg strip 3
383 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
383 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
384 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
384 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
385
385
386 applied patches after stripping rev in queue
386 applied patches after stripping rev in queue
387
387
388 $ hg qapplied
388 $ hg qapplied
389 2.diff
389 2.diff
390
390
391 stripping ancestor of queue
391 stripping ancestor of queue
392
392
393 $ hg strip 1
393 $ hg strip 1
394 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
394 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
395 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
395 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
396
396
397 applied patches after stripping ancestor of queue
397 applied patches after stripping ancestor of queue
398
398
399 $ hg qapplied
399 $ hg qapplied
400
400
401 Verify strip protects against stripping wc parent when there are uncommitted mods
401 Verify strip protects against stripping wc parent when there are uncommitted mods
402
402
403 $ echo b > b
403 $ echo b > b
404 $ hg add b
404 $ hg add b
405 $ hg ci -m 'b'
405 $ hg ci -m 'b'
406 $ hg log --graph
406 $ hg log --graph
407 @ changeset: 1:7519abd79d14
407 @ changeset: 1:7519abd79d14
408 | tag: tip
408 | tag: tip
409 | user: test
409 | user: test
410 | date: Thu Jan 01 00:00:00 1970 +0000
410 | date: Thu Jan 01 00:00:00 1970 +0000
411 | summary: b
411 | summary: b
412 |
412 |
413 o changeset: 0:9ab35a2d17cb
413 o changeset: 0:9ab35a2d17cb
414 user: test
414 user: test
415 date: Thu Jan 01 00:00:00 1970 +0000
415 date: Thu Jan 01 00:00:00 1970 +0000
416 summary: a
416 summary: a
417
417
418
418
419 $ echo c > b
419 $ echo c > b
420 $ echo c > bar
420 $ echo c > bar
421 $ hg strip tip
421 $ hg strip tip
422 abort: local changes found
422 abort: local changes found
423 [255]
423 [255]
424 $ hg strip tip --keep
424 $ hg strip tip --keep
425 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
425 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
426 $ hg log --graph
426 $ hg log --graph
427 @ changeset: 0:9ab35a2d17cb
427 @ changeset: 0:9ab35a2d17cb
428 tag: tip
428 tag: tip
429 user: test
429 user: test
430 date: Thu Jan 01 00:00:00 1970 +0000
430 date: Thu Jan 01 00:00:00 1970 +0000
431 summary: a
431 summary: a
432
432
433 $ hg status
433 $ hg status
434 M bar
434 M bar
435 ? b
435 ? b
436
436
437 Strip adds, removes, modifies with --keep
437 Strip adds, removes, modifies with --keep
438
438
439 $ touch b
439 $ touch b
440 $ hg add b
440 $ hg add b
441 $ hg commit -mb
441 $ hg commit -mb
442 $ touch c
442 $ touch c
443
443
444 ... with a clean working dir
444 ... with a clean working dir
445
445
446 $ hg add c
446 $ hg add c
447 $ hg rm bar
447 $ hg rm bar
448 $ hg commit -mc
448 $ hg commit -mc
449 $ hg status
449 $ hg status
450 $ hg strip --keep tip
450 $ hg strip --keep tip
451 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
451 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
452 $ hg status
452 $ hg status
453 ! bar
453 ! bar
454 ? c
454 ? c
455
455
456 ... with a dirty working dir
456 ... with a dirty working dir
457
457
458 $ hg add c
458 $ hg add c
459 $ hg rm bar
459 $ hg rm bar
460 $ hg commit -mc
460 $ hg commit -mc
461 $ hg status
461 $ hg status
462 $ echo b > b
462 $ echo b > b
463 $ echo d > d
463 $ echo d > d
464 $ hg strip --keep tip
464 $ hg strip --keep tip
465 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
465 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
466 $ hg status
466 $ hg status
467 M b
467 M b
468 ! bar
468 ! bar
469 ? c
469 ? c
470 ? d
470 ? d
471 $ cd ..
471 $ cd ..
472
472
473 stripping many nodes on a complex graph (issue3299)
473 stripping many nodes on a complex graph (issue3299)
474
474
475 $ hg init issue3299
475 $ hg init issue3299
476 $ cd issue3299
476 $ cd issue3299
477 $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
477 $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
478 $ hg strip 'not ancestors(x)'
478 $ hg strip 'not ancestors(x)'
479 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
479 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
480
480
481 test hg strip -B bookmark
481 test hg strip -B bookmark
482
482
483 $ cd ..
483 $ cd ..
484 $ hg init bookmarks
484 $ hg init bookmarks
485 $ cd bookmarks
485 $ cd bookmarks
486 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b'
486 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b'
487 $ hg bookmark -r 'a' 'todelete'
487 $ hg bookmark -r 'a' 'todelete'
488 $ hg bookmark -r 'b' 'B'
488 $ hg bookmark -r 'b' 'B'
489 $ hg bookmark -r 'b' 'nostrip'
489 $ hg bookmark -r 'b' 'nostrip'
490 $ hg bookmark -r 'c' 'delete'
490 $ hg bookmark -r 'c' 'delete'
491 $ hg up -C todelete
491 $ hg up -C todelete
492 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
492 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
493 (activating bookmark todelete)
493 (activating bookmark todelete)
494 $ hg strip -B nostrip
494 $ hg strip -B nostrip
495 bookmark 'nostrip' deleted
495 bookmark 'nostrip' deleted
496 abort: empty revision set
496 abort: empty revision set
497 [255]
497 [255]
498 $ hg strip -B todelete
498 $ hg strip -B todelete
499 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
499 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
500 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
500 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
501 bookmark 'todelete' deleted
501 bookmark 'todelete' deleted
502 $ hg id -ir dcbb326fdec2
502 $ hg id -ir dcbb326fdec2
503 abort: unknown revision 'dcbb326fdec2'!
503 abort: unknown revision 'dcbb326fdec2'!
504 [255]
504 [255]
505 $ hg id -ir d62d843c9a01
505 $ hg id -ir d62d843c9a01
506 d62d843c9a01
506 d62d843c9a01
507 $ hg bookmarks
507 $ hg bookmarks
508 B 9:ff43616e5d0f
508 B 9:ff43616e5d0f
509 delete 6:2702dd0c91e7
509 delete 6:2702dd0c91e7
510 $ hg strip -B delete
510 $ hg strip -B delete
511 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
511 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
512 bookmark 'delete' deleted
512 bookmark 'delete' deleted
513 $ hg id -ir 6:2702dd0c91e7
513 $ hg id -ir 6:2702dd0c91e7
514 abort: unknown revision '2702dd0c91e7'!
514 abort: unknown revision '2702dd0c91e7'!
515 [255]
515 [255]
516 $ hg update B
516 $ hg update B
517 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
517 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
518 (activating bookmark B)
518 (activating bookmark B)
519 $ echo a > a
519 $ echo a > a
520 $ hg add a
520 $ hg add a
521 $ hg strip -B B
521 $ hg strip -B B
522 abort: local changes found
522 abort: local changes found
523 [255]
523 [255]
524 $ hg bookmarks
524 $ hg bookmarks
525 * B 6:ff43616e5d0f
525 * B 6:ff43616e5d0f
526
526
527 Make sure no one adds back a -b option:
527 Make sure no one adds back a -b option:
528
528
529 $ hg strip -b tip
529 $ hg strip -b tip
530 hg strip: option -b not recognized
530 hg strip: option -b not recognized
531 hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...
531 hg strip [-k] [-f] [-n] [-B bookmark] [-r] REV...
532
532
533 strip changesets and all their descendants from the repository
533 strip changesets and all their descendants from the repository
534
534
535 use "hg help -e strip" to show help for the strip extension
535 (use "hg help -e strip" to show help for the strip extension)
536
536
537 options:
537 options:
538
538
539 -r --rev REV [+] strip specified revision (optional, can specify revisions
539 -r --rev REV [+] strip specified revision (optional, can specify revisions
540 without this option)
540 without this option)
541 -f --force force removal of changesets, discard uncommitted changes
541 -f --force force removal of changesets, discard uncommitted changes
542 (no backup)
542 (no backup)
543 --no-backup no backups
543 --no-backup no backups
544 -k --keep do not modify working copy during strip
544 -k --keep do not modify working copy during strip
545 -B --bookmark VALUE remove revs only reachable from given bookmark
545 -B --bookmark VALUE remove revs only reachable from given bookmark
546 --mq operate on patch repository
546 --mq operate on patch repository
547
547
548 [+] marked option can be specified multiple times
548 [+] marked option can be specified multiple times
549
549
550 (use "hg strip -h" to show more help)
550 (use "hg strip -h" to show more help)
551 [255]
551 [255]
General Comments 0
You need to be logged in to leave comments. Login now