##// END OF EJS Templates
commands: add debugdeltachain command...
Gregory Szorc -
r27263:4efb36ec default
parent child Browse files
Show More
@@ -1,6852 +1,6963 b''
1 # commands.py - command processing for mercurial
1 # commands.py - command processing for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 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 node import hex, bin, nullhex, nullid, nullrev, short
8 from node import hex, bin, nullhex, nullid, nullrev, short
9 from lock import release
9 from lock import release
10 from i18n import _
10 from i18n import _
11 import os, re, difflib, time, tempfile, errno, shlex
11 import os, re, difflib, time, tempfile, errno, shlex
12 import sys, socket
12 import sys, socket
13 import hg, scmutil, util, revlog, copies, error, bookmarks
13 import hg, scmutil, util, revlog, copies, error, bookmarks
14 import patch, help, encoding, templatekw, discovery
14 import patch, help, encoding, templatekw, discovery
15 import archival, changegroup, cmdutil, hbisect
15 import archival, changegroup, cmdutil, hbisect
16 import sshserver, hgweb
16 import sshserver, hgweb
17 import extensions
17 import extensions
18 import merge as mergemod
18 import merge as mergemod
19 import minirst, revset, fileset
19 import minirst, revset, fileset
20 import dagparser, context, simplemerge, graphmod, copies
20 import dagparser, context, simplemerge, graphmod, copies
21 import random, operator
21 import random, operator
22 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
22 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
23 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
23 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
24 import ui as uimod
24 import ui as uimod
25 import streamclone
25 import streamclone
26
26
27 table = {}
27 table = {}
28
28
29 command = cmdutil.command(table)
29 command = cmdutil.command(table)
30
30
31 # Space delimited list of commands that don't require local repositories.
31 # Space delimited list of commands that don't require local repositories.
32 # This should be populated by passing norepo=True into the @command decorator.
32 # This should be populated by passing norepo=True into the @command decorator.
33 norepo = ''
33 norepo = ''
34 # Space delimited list of commands that optionally require local repositories.
34 # Space delimited list of commands that optionally require local repositories.
35 # This should be populated by passing optionalrepo=True into the @command
35 # This should be populated by passing optionalrepo=True into the @command
36 # decorator.
36 # decorator.
37 optionalrepo = ''
37 optionalrepo = ''
38 # Space delimited list of commands that will examine arguments looking for
38 # Space delimited list of commands that will examine arguments looking for
39 # a repository. This should be populated by passing inferrepo=True into the
39 # a repository. This should be populated by passing inferrepo=True into the
40 # @command decorator.
40 # @command decorator.
41 inferrepo = ''
41 inferrepo = ''
42
42
43 # label constants
43 # label constants
44 # until 3.5, bookmarks.current was the advertised name, not
44 # until 3.5, bookmarks.current was the advertised name, not
45 # bookmarks.active, so we must use both to avoid breaking old
45 # bookmarks.active, so we must use both to avoid breaking old
46 # custom styles
46 # custom styles
47 activebookmarklabel = 'bookmarks.active bookmarks.current'
47 activebookmarklabel = 'bookmarks.active bookmarks.current'
48
48
49 # common command options
49 # common command options
50
50
51 globalopts = [
51 globalopts = [
52 ('R', 'repository', '',
52 ('R', 'repository', '',
53 _('repository root directory or name of overlay bundle file'),
53 _('repository root directory or name of overlay bundle file'),
54 _('REPO')),
54 _('REPO')),
55 ('', 'cwd', '',
55 ('', 'cwd', '',
56 _('change working directory'), _('DIR')),
56 _('change working directory'), _('DIR')),
57 ('y', 'noninteractive', None,
57 ('y', 'noninteractive', None,
58 _('do not prompt, automatically pick the first choice for all prompts')),
58 _('do not prompt, automatically pick the first choice for all prompts')),
59 ('q', 'quiet', None, _('suppress output')),
59 ('q', 'quiet', None, _('suppress output')),
60 ('v', 'verbose', None, _('enable additional output')),
60 ('v', 'verbose', None, _('enable additional output')),
61 ('', 'config', [],
61 ('', 'config', [],
62 _('set/override config option (use \'section.name=value\')'),
62 _('set/override config option (use \'section.name=value\')'),
63 _('CONFIG')),
63 _('CONFIG')),
64 ('', 'debug', None, _('enable debugging output')),
64 ('', 'debug', None, _('enable debugging output')),
65 ('', 'debugger', None, _('start debugger')),
65 ('', 'debugger', None, _('start debugger')),
66 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
66 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
67 _('ENCODE')),
67 _('ENCODE')),
68 ('', 'encodingmode', encoding.encodingmode,
68 ('', 'encodingmode', encoding.encodingmode,
69 _('set the charset encoding mode'), _('MODE')),
69 _('set the charset encoding mode'), _('MODE')),
70 ('', 'traceback', None, _('always print a traceback on exception')),
70 ('', 'traceback', None, _('always print a traceback on exception')),
71 ('', 'time', None, _('time how long the command takes')),
71 ('', 'time', None, _('time how long the command takes')),
72 ('', 'profile', None, _('print command execution profile')),
72 ('', 'profile', None, _('print command execution profile')),
73 ('', 'version', None, _('output version information and exit')),
73 ('', 'version', None, _('output version information and exit')),
74 ('h', 'help', None, _('display help and exit')),
74 ('h', 'help', None, _('display help and exit')),
75 ('', 'hidden', False, _('consider hidden changesets')),
75 ('', 'hidden', False, _('consider hidden changesets')),
76 ]
76 ]
77
77
78 dryrunopts = [('n', 'dry-run', None,
78 dryrunopts = [('n', 'dry-run', None,
79 _('do not perform actions, just print output'))]
79 _('do not perform actions, just print output'))]
80
80
81 remoteopts = [
81 remoteopts = [
82 ('e', 'ssh', '',
82 ('e', 'ssh', '',
83 _('specify ssh command to use'), _('CMD')),
83 _('specify ssh command to use'), _('CMD')),
84 ('', 'remotecmd', '',
84 ('', 'remotecmd', '',
85 _('specify hg command to run on the remote side'), _('CMD')),
85 _('specify hg command to run on the remote side'), _('CMD')),
86 ('', 'insecure', None,
86 ('', 'insecure', None,
87 _('do not verify server certificate (ignoring web.cacerts config)')),
87 _('do not verify server certificate (ignoring web.cacerts config)')),
88 ]
88 ]
89
89
90 walkopts = [
90 walkopts = [
91 ('I', 'include', [],
91 ('I', 'include', [],
92 _('include names matching the given patterns'), _('PATTERN')),
92 _('include names matching the given patterns'), _('PATTERN')),
93 ('X', 'exclude', [],
93 ('X', 'exclude', [],
94 _('exclude names matching the given patterns'), _('PATTERN')),
94 _('exclude names matching the given patterns'), _('PATTERN')),
95 ]
95 ]
96
96
97 commitopts = [
97 commitopts = [
98 ('m', 'message', '',
98 ('m', 'message', '',
99 _('use text as commit message'), _('TEXT')),
99 _('use text as commit message'), _('TEXT')),
100 ('l', 'logfile', '',
100 ('l', 'logfile', '',
101 _('read commit message from file'), _('FILE')),
101 _('read commit message from file'), _('FILE')),
102 ]
102 ]
103
103
104 commitopts2 = [
104 commitopts2 = [
105 ('d', 'date', '',
105 ('d', 'date', '',
106 _('record the specified date as commit date'), _('DATE')),
106 _('record the specified date as commit date'), _('DATE')),
107 ('u', 'user', '',
107 ('u', 'user', '',
108 _('record the specified user as committer'), _('USER')),
108 _('record the specified user as committer'), _('USER')),
109 ]
109 ]
110
110
111 # hidden for now
111 # hidden for now
112 formatteropts = [
112 formatteropts = [
113 ('T', 'template', '',
113 ('T', 'template', '',
114 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
114 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
115 ]
115 ]
116
116
117 templateopts = [
117 templateopts = [
118 ('', 'style', '',
118 ('', 'style', '',
119 _('display using template map file (DEPRECATED)'), _('STYLE')),
119 _('display using template map file (DEPRECATED)'), _('STYLE')),
120 ('T', 'template', '',
120 ('T', 'template', '',
121 _('display with template'), _('TEMPLATE')),
121 _('display with template'), _('TEMPLATE')),
122 ]
122 ]
123
123
124 logopts = [
124 logopts = [
125 ('p', 'patch', None, _('show patch')),
125 ('p', 'patch', None, _('show patch')),
126 ('g', 'git', None, _('use git extended diff format')),
126 ('g', 'git', None, _('use git extended diff format')),
127 ('l', 'limit', '',
127 ('l', 'limit', '',
128 _('limit number of changes displayed'), _('NUM')),
128 _('limit number of changes displayed'), _('NUM')),
129 ('M', 'no-merges', None, _('do not show merges')),
129 ('M', 'no-merges', None, _('do not show merges')),
130 ('', 'stat', None, _('output diffstat-style summary of changes')),
130 ('', 'stat', None, _('output diffstat-style summary of changes')),
131 ('G', 'graph', None, _("show the revision DAG")),
131 ('G', 'graph', None, _("show the revision DAG")),
132 ] + templateopts
132 ] + templateopts
133
133
134 diffopts = [
134 diffopts = [
135 ('a', 'text', None, _('treat all files as text')),
135 ('a', 'text', None, _('treat all files as text')),
136 ('g', 'git', None, _('use git extended diff format')),
136 ('g', 'git', None, _('use git extended diff format')),
137 ('', 'nodates', None, _('omit dates from diff headers'))
137 ('', 'nodates', None, _('omit dates from diff headers'))
138 ]
138 ]
139
139
140 diffwsopts = [
140 diffwsopts = [
141 ('w', 'ignore-all-space', None,
141 ('w', 'ignore-all-space', None,
142 _('ignore white space when comparing lines')),
142 _('ignore white space when comparing lines')),
143 ('b', 'ignore-space-change', None,
143 ('b', 'ignore-space-change', None,
144 _('ignore changes in the amount of white space')),
144 _('ignore changes in the amount of white space')),
145 ('B', 'ignore-blank-lines', None,
145 ('B', 'ignore-blank-lines', None,
146 _('ignore changes whose lines are all blank')),
146 _('ignore changes whose lines are all blank')),
147 ]
147 ]
148
148
149 diffopts2 = [
149 diffopts2 = [
150 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
150 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
151 ('p', 'show-function', None, _('show which function each change is in')),
151 ('p', 'show-function', None, _('show which function each change is in')),
152 ('', 'reverse', None, _('produce a diff that undoes the changes')),
152 ('', 'reverse', None, _('produce a diff that undoes the changes')),
153 ] + diffwsopts + [
153 ] + diffwsopts + [
154 ('U', 'unified', '',
154 ('U', 'unified', '',
155 _('number of lines of context to show'), _('NUM')),
155 _('number of lines of context to show'), _('NUM')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
156 ('', 'stat', None, _('output diffstat-style summary of changes')),
157 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
157 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
158 ]
158 ]
159
159
160 mergetoolopts = [
160 mergetoolopts = [
161 ('t', 'tool', '', _('specify merge tool')),
161 ('t', 'tool', '', _('specify merge tool')),
162 ]
162 ]
163
163
164 similarityopts = [
164 similarityopts = [
165 ('s', 'similarity', '',
165 ('s', 'similarity', '',
166 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
166 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
167 ]
167 ]
168
168
169 subrepoopts = [
169 subrepoopts = [
170 ('S', 'subrepos', None,
170 ('S', 'subrepos', None,
171 _('recurse into subrepositories'))
171 _('recurse into subrepositories'))
172 ]
172 ]
173
173
174 debugrevlogopts = [
174 debugrevlogopts = [
175 ('c', 'changelog', False, _('open changelog')),
175 ('c', 'changelog', False, _('open changelog')),
176 ('m', 'manifest', False, _('open manifest')),
176 ('m', 'manifest', False, _('open manifest')),
177 ('', 'dir', False, _('open directory manifest')),
177 ('', 'dir', False, _('open directory manifest')),
178 ]
178 ]
179
179
180 # Commands start here, listed alphabetically
180 # Commands start here, listed alphabetically
181
181
182 @command('^add',
182 @command('^add',
183 walkopts + subrepoopts + dryrunopts,
183 walkopts + subrepoopts + dryrunopts,
184 _('[OPTION]... [FILE]...'),
184 _('[OPTION]... [FILE]...'),
185 inferrepo=True)
185 inferrepo=True)
186 def add(ui, repo, *pats, **opts):
186 def add(ui, repo, *pats, **opts):
187 """add the specified files on the next commit
187 """add the specified files on the next commit
188
188
189 Schedule files to be version controlled and added to the
189 Schedule files to be version controlled and added to the
190 repository.
190 repository.
191
191
192 The files will be added to the repository at the next commit. To
192 The files will be added to the repository at the next commit. To
193 undo an add before that, see :hg:`forget`.
193 undo an add before that, see :hg:`forget`.
194
194
195 If no names are given, add all files to the repository.
195 If no names are given, add all files to the repository.
196
196
197 .. container:: verbose
197 .. container:: verbose
198
198
199 Examples:
199 Examples:
200
200
201 - New (unknown) files are added
201 - New (unknown) files are added
202 automatically by :hg:`add`::
202 automatically by :hg:`add`::
203
203
204 $ ls
204 $ ls
205 foo.c
205 foo.c
206 $ hg status
206 $ hg status
207 ? foo.c
207 ? foo.c
208 $ hg add
208 $ hg add
209 adding foo.c
209 adding foo.c
210 $ hg status
210 $ hg status
211 A foo.c
211 A foo.c
212
212
213 - Specific files to be added can be specified::
213 - Specific files to be added can be specified::
214
214
215 $ ls
215 $ ls
216 bar.c foo.c
216 bar.c foo.c
217 $ hg status
217 $ hg status
218 ? bar.c
218 ? bar.c
219 ? foo.c
219 ? foo.c
220 $ hg add bar.c
220 $ hg add bar.c
221 $ hg status
221 $ hg status
222 A bar.c
222 A bar.c
223 ? foo.c
223 ? foo.c
224
224
225 Returns 0 if all files are successfully added.
225 Returns 0 if all files are successfully added.
226 """
226 """
227
227
228 m = scmutil.match(repo[None], pats, opts)
228 m = scmutil.match(repo[None], pats, opts)
229 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
229 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
230 return rejected and 1 or 0
230 return rejected and 1 or 0
231
231
232 @command('addremove',
232 @command('addremove',
233 similarityopts + subrepoopts + walkopts + dryrunopts,
233 similarityopts + subrepoopts + walkopts + dryrunopts,
234 _('[OPTION]... [FILE]...'),
234 _('[OPTION]... [FILE]...'),
235 inferrepo=True)
235 inferrepo=True)
236 def addremove(ui, repo, *pats, **opts):
236 def addremove(ui, repo, *pats, **opts):
237 """add all new files, delete all missing files
237 """add all new files, delete all missing files
238
238
239 Add all new files and remove all missing files from the
239 Add all new files and remove all missing files from the
240 repository.
240 repository.
241
241
242 New files are ignored if they match any of the patterns in
242 New files are ignored if they match any of the patterns in
243 ``.hgignore``. As with add, these changes take effect at the next
243 ``.hgignore``. As with add, these changes take effect at the next
244 commit.
244 commit.
245
245
246 Use the -s/--similarity option to detect renamed files. This
246 Use the -s/--similarity option to detect renamed files. This
247 option takes a percentage between 0 (disabled) and 100 (files must
247 option takes a percentage between 0 (disabled) and 100 (files must
248 be identical) as its parameter. With a parameter greater than 0,
248 be identical) as its parameter. With a parameter greater than 0,
249 this compares every removed file with every added file and records
249 this compares every removed file with every added file and records
250 those similar enough as renames. Detecting renamed files this way
250 those similar enough as renames. Detecting renamed files this way
251 can be expensive. After using this option, :hg:`status -C` can be
251 can be expensive. After using this option, :hg:`status -C` can be
252 used to check which files were identified as moved or renamed. If
252 used to check which files were identified as moved or renamed. If
253 not specified, -s/--similarity defaults to 100 and only renames of
253 not specified, -s/--similarity defaults to 100 and only renames of
254 identical files are detected.
254 identical files are detected.
255
255
256 .. container:: verbose
256 .. container:: verbose
257
257
258 Examples:
258 Examples:
259
259
260 - A number of files (bar.c and foo.c) are new,
260 - A number of files (bar.c and foo.c) are new,
261 while foobar.c has been removed (without using :hg:`remove`)
261 while foobar.c has been removed (without using :hg:`remove`)
262 from the repository::
262 from the repository::
263
263
264 $ ls
264 $ ls
265 bar.c foo.c
265 bar.c foo.c
266 $ hg status
266 $ hg status
267 ! foobar.c
267 ! foobar.c
268 ? bar.c
268 ? bar.c
269 ? foo.c
269 ? foo.c
270 $ hg addremove
270 $ hg addremove
271 adding bar.c
271 adding bar.c
272 adding foo.c
272 adding foo.c
273 removing foobar.c
273 removing foobar.c
274 $ hg status
274 $ hg status
275 A bar.c
275 A bar.c
276 A foo.c
276 A foo.c
277 R foobar.c
277 R foobar.c
278
278
279 - A file foobar.c was moved to foo.c without using :hg:`rename`.
279 - A file foobar.c was moved to foo.c without using :hg:`rename`.
280 Afterwards, it was edited slightly::
280 Afterwards, it was edited slightly::
281
281
282 $ ls
282 $ ls
283 foo.c
283 foo.c
284 $ hg status
284 $ hg status
285 ! foobar.c
285 ! foobar.c
286 ? foo.c
286 ? foo.c
287 $ hg addremove --similarity 90
287 $ hg addremove --similarity 90
288 removing foobar.c
288 removing foobar.c
289 adding foo.c
289 adding foo.c
290 recording removal of foobar.c as rename to foo.c (94% similar)
290 recording removal of foobar.c as rename to foo.c (94% similar)
291 $ hg status -C
291 $ hg status -C
292 A foo.c
292 A foo.c
293 foobar.c
293 foobar.c
294 R foobar.c
294 R foobar.c
295
295
296 Returns 0 if all files are successfully added.
296 Returns 0 if all files are successfully added.
297 """
297 """
298 try:
298 try:
299 sim = float(opts.get('similarity') or 100)
299 sim = float(opts.get('similarity') or 100)
300 except ValueError:
300 except ValueError:
301 raise error.Abort(_('similarity must be a number'))
301 raise error.Abort(_('similarity must be a number'))
302 if sim < 0 or sim > 100:
302 if sim < 0 or sim > 100:
303 raise error.Abort(_('similarity must be between 0 and 100'))
303 raise error.Abort(_('similarity must be between 0 and 100'))
304 matcher = scmutil.match(repo[None], pats, opts)
304 matcher = scmutil.match(repo[None], pats, opts)
305 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
305 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
306
306
307 @command('^annotate|blame',
307 @command('^annotate|blame',
308 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
308 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
309 ('', 'follow', None,
309 ('', 'follow', None,
310 _('follow copies/renames and list the filename (DEPRECATED)')),
310 _('follow copies/renames and list the filename (DEPRECATED)')),
311 ('', 'no-follow', None, _("don't follow copies and renames")),
311 ('', 'no-follow', None, _("don't follow copies and renames")),
312 ('a', 'text', None, _('treat all files as text')),
312 ('a', 'text', None, _('treat all files as text')),
313 ('u', 'user', None, _('list the author (long with -v)')),
313 ('u', 'user', None, _('list the author (long with -v)')),
314 ('f', 'file', None, _('list the filename')),
314 ('f', 'file', None, _('list the filename')),
315 ('d', 'date', None, _('list the date (short with -q)')),
315 ('d', 'date', None, _('list the date (short with -q)')),
316 ('n', 'number', None, _('list the revision number (default)')),
316 ('n', 'number', None, _('list the revision number (default)')),
317 ('c', 'changeset', None, _('list the changeset')),
317 ('c', 'changeset', None, _('list the changeset')),
318 ('l', 'line-number', None, _('show line number at the first appearance'))
318 ('l', 'line-number', None, _('show line number at the first appearance'))
319 ] + diffwsopts + walkopts + formatteropts,
319 ] + diffwsopts + walkopts + formatteropts,
320 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
320 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
321 inferrepo=True)
321 inferrepo=True)
322 def annotate(ui, repo, *pats, **opts):
322 def annotate(ui, repo, *pats, **opts):
323 """show changeset information by line for each file
323 """show changeset information by line for each file
324
324
325 List changes in files, showing the revision id responsible for
325 List changes in files, showing the revision id responsible for
326 each line
326 each line
327
327
328 This command is useful for discovering when a change was made and
328 This command is useful for discovering when a change was made and
329 by whom.
329 by whom.
330
330
331 Without the -a/--text option, annotate will avoid processing files
331 Without the -a/--text option, annotate will avoid processing files
332 it detects as binary. With -a, annotate will annotate the file
332 it detects as binary. With -a, annotate will annotate the file
333 anyway, although the results will probably be neither useful
333 anyway, although the results will probably be neither useful
334 nor desirable.
334 nor desirable.
335
335
336 Returns 0 on success.
336 Returns 0 on success.
337 """
337 """
338 if not pats:
338 if not pats:
339 raise error.Abort(_('at least one filename or pattern is required'))
339 raise error.Abort(_('at least one filename or pattern is required'))
340
340
341 if opts.get('follow'):
341 if opts.get('follow'):
342 # --follow is deprecated and now just an alias for -f/--file
342 # --follow is deprecated and now just an alias for -f/--file
343 # to mimic the behavior of Mercurial before version 1.5
343 # to mimic the behavior of Mercurial before version 1.5
344 opts['file'] = True
344 opts['file'] = True
345
345
346 ctx = scmutil.revsingle(repo, opts.get('rev'))
346 ctx = scmutil.revsingle(repo, opts.get('rev'))
347
347
348 fm = ui.formatter('annotate', opts)
348 fm = ui.formatter('annotate', opts)
349 if ui.quiet:
349 if ui.quiet:
350 datefunc = util.shortdate
350 datefunc = util.shortdate
351 else:
351 else:
352 datefunc = util.datestr
352 datefunc = util.datestr
353 if ctx.rev() is None:
353 if ctx.rev() is None:
354 def hexfn(node):
354 def hexfn(node):
355 if node is None:
355 if node is None:
356 return None
356 return None
357 else:
357 else:
358 return fm.hexfunc(node)
358 return fm.hexfunc(node)
359 if opts.get('changeset'):
359 if opts.get('changeset'):
360 # omit "+" suffix which is appended to node hex
360 # omit "+" suffix which is appended to node hex
361 def formatrev(rev):
361 def formatrev(rev):
362 if rev is None:
362 if rev is None:
363 return '%d' % ctx.p1().rev()
363 return '%d' % ctx.p1().rev()
364 else:
364 else:
365 return '%d' % rev
365 return '%d' % rev
366 else:
366 else:
367 def formatrev(rev):
367 def formatrev(rev):
368 if rev is None:
368 if rev is None:
369 return '%d+' % ctx.p1().rev()
369 return '%d+' % ctx.p1().rev()
370 else:
370 else:
371 return '%d ' % rev
371 return '%d ' % rev
372 def formathex(hex):
372 def formathex(hex):
373 if hex is None:
373 if hex is None:
374 return '%s+' % fm.hexfunc(ctx.p1().node())
374 return '%s+' % fm.hexfunc(ctx.p1().node())
375 else:
375 else:
376 return '%s ' % hex
376 return '%s ' % hex
377 else:
377 else:
378 hexfn = fm.hexfunc
378 hexfn = fm.hexfunc
379 formatrev = formathex = str
379 formatrev = formathex = str
380
380
381 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
381 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
382 ('number', ' ', lambda x: x[0].rev(), formatrev),
382 ('number', ' ', lambda x: x[0].rev(), formatrev),
383 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
383 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
384 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
384 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
385 ('file', ' ', lambda x: x[0].path(), str),
385 ('file', ' ', lambda x: x[0].path(), str),
386 ('line_number', ':', lambda x: x[1], str),
386 ('line_number', ':', lambda x: x[1], str),
387 ]
387 ]
388 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
388 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
389
389
390 if (not opts.get('user') and not opts.get('changeset')
390 if (not opts.get('user') and not opts.get('changeset')
391 and not opts.get('date') and not opts.get('file')):
391 and not opts.get('date') and not opts.get('file')):
392 opts['number'] = True
392 opts['number'] = True
393
393
394 linenumber = opts.get('line_number') is not None
394 linenumber = opts.get('line_number') is not None
395 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
395 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
396 raise error.Abort(_('at least one of -n/-c is required for -l'))
396 raise error.Abort(_('at least one of -n/-c is required for -l'))
397
397
398 if fm:
398 if fm:
399 def makefunc(get, fmt):
399 def makefunc(get, fmt):
400 return get
400 return get
401 else:
401 else:
402 def makefunc(get, fmt):
402 def makefunc(get, fmt):
403 return lambda x: fmt(get(x))
403 return lambda x: fmt(get(x))
404 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
404 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
405 if opts.get(op)]
405 if opts.get(op)]
406 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
406 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
407 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
407 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
408 if opts.get(op))
408 if opts.get(op))
409
409
410 def bad(x, y):
410 def bad(x, y):
411 raise error.Abort("%s: %s" % (x, y))
411 raise error.Abort("%s: %s" % (x, y))
412
412
413 m = scmutil.match(ctx, pats, opts, badfn=bad)
413 m = scmutil.match(ctx, pats, opts, badfn=bad)
414
414
415 follow = not opts.get('no_follow')
415 follow = not opts.get('no_follow')
416 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
416 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
417 whitespace=True)
417 whitespace=True)
418 for abs in ctx.walk(m):
418 for abs in ctx.walk(m):
419 fctx = ctx[abs]
419 fctx = ctx[abs]
420 if not opts.get('text') and util.binary(fctx.data()):
420 if not opts.get('text') and util.binary(fctx.data()):
421 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
421 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
422 continue
422 continue
423
423
424 lines = fctx.annotate(follow=follow, linenumber=linenumber,
424 lines = fctx.annotate(follow=follow, linenumber=linenumber,
425 diffopts=diffopts)
425 diffopts=diffopts)
426 formats = []
426 formats = []
427 pieces = []
427 pieces = []
428
428
429 for f, sep in funcmap:
429 for f, sep in funcmap:
430 l = [f(n) for n, dummy in lines]
430 l = [f(n) for n, dummy in lines]
431 if l:
431 if l:
432 if fm:
432 if fm:
433 formats.append(['%s' for x in l])
433 formats.append(['%s' for x in l])
434 else:
434 else:
435 sizes = [encoding.colwidth(x) for x in l]
435 sizes = [encoding.colwidth(x) for x in l]
436 ml = max(sizes)
436 ml = max(sizes)
437 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
437 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
438 pieces.append(l)
438 pieces.append(l)
439
439
440 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
440 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
441 fm.startitem()
441 fm.startitem()
442 fm.write(fields, "".join(f), *p)
442 fm.write(fields, "".join(f), *p)
443 fm.write('line', ": %s", l[1])
443 fm.write('line', ": %s", l[1])
444
444
445 if lines and not lines[-1][1].endswith('\n'):
445 if lines and not lines[-1][1].endswith('\n'):
446 fm.plain('\n')
446 fm.plain('\n')
447
447
448 fm.end()
448 fm.end()
449
449
450 @command('archive',
450 @command('archive',
451 [('', 'no-decode', None, _('do not pass files through decoders')),
451 [('', 'no-decode', None, _('do not pass files through decoders')),
452 ('p', 'prefix', '', _('directory prefix for files in archive'),
452 ('p', 'prefix', '', _('directory prefix for files in archive'),
453 _('PREFIX')),
453 _('PREFIX')),
454 ('r', 'rev', '', _('revision to distribute'), _('REV')),
454 ('r', 'rev', '', _('revision to distribute'), _('REV')),
455 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
455 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
456 ] + subrepoopts + walkopts,
456 ] + subrepoopts + walkopts,
457 _('[OPTION]... DEST'))
457 _('[OPTION]... DEST'))
458 def archive(ui, repo, dest, **opts):
458 def archive(ui, repo, dest, **opts):
459 '''create an unversioned archive of a repository revision
459 '''create an unversioned archive of a repository revision
460
460
461 By default, the revision used is the parent of the working
461 By default, the revision used is the parent of the working
462 directory; use -r/--rev to specify a different revision.
462 directory; use -r/--rev to specify a different revision.
463
463
464 The archive type is automatically detected based on file
464 The archive type is automatically detected based on file
465 extension (or override using -t/--type).
465 extension (or override using -t/--type).
466
466
467 .. container:: verbose
467 .. container:: verbose
468
468
469 Examples:
469 Examples:
470
470
471 - create a zip file containing the 1.0 release::
471 - create a zip file containing the 1.0 release::
472
472
473 hg archive -r 1.0 project-1.0.zip
473 hg archive -r 1.0 project-1.0.zip
474
474
475 - create a tarball excluding .hg files::
475 - create a tarball excluding .hg files::
476
476
477 hg archive project.tar.gz -X ".hg*"
477 hg archive project.tar.gz -X ".hg*"
478
478
479 Valid types are:
479 Valid types are:
480
480
481 :``files``: a directory full of files (default)
481 :``files``: a directory full of files (default)
482 :``tar``: tar archive, uncompressed
482 :``tar``: tar archive, uncompressed
483 :``tbz2``: tar archive, compressed using bzip2
483 :``tbz2``: tar archive, compressed using bzip2
484 :``tgz``: tar archive, compressed using gzip
484 :``tgz``: tar archive, compressed using gzip
485 :``uzip``: zip archive, uncompressed
485 :``uzip``: zip archive, uncompressed
486 :``zip``: zip archive, compressed using deflate
486 :``zip``: zip archive, compressed using deflate
487
487
488 The exact name of the destination archive or directory is given
488 The exact name of the destination archive or directory is given
489 using a format string; see :hg:`help export` for details.
489 using a format string; see :hg:`help export` for details.
490
490
491 Each member added to an archive file has a directory prefix
491 Each member added to an archive file has a directory prefix
492 prepended. Use -p/--prefix to specify a format string for the
492 prepended. Use -p/--prefix to specify a format string for the
493 prefix. The default is the basename of the archive, with suffixes
493 prefix. The default is the basename of the archive, with suffixes
494 removed.
494 removed.
495
495
496 Returns 0 on success.
496 Returns 0 on success.
497 '''
497 '''
498
498
499 ctx = scmutil.revsingle(repo, opts.get('rev'))
499 ctx = scmutil.revsingle(repo, opts.get('rev'))
500 if not ctx:
500 if not ctx:
501 raise error.Abort(_('no working directory: please specify a revision'))
501 raise error.Abort(_('no working directory: please specify a revision'))
502 node = ctx.node()
502 node = ctx.node()
503 dest = cmdutil.makefilename(repo, dest, node)
503 dest = cmdutil.makefilename(repo, dest, node)
504 if os.path.realpath(dest) == repo.root:
504 if os.path.realpath(dest) == repo.root:
505 raise error.Abort(_('repository root cannot be destination'))
505 raise error.Abort(_('repository root cannot be destination'))
506
506
507 kind = opts.get('type') or archival.guesskind(dest) or 'files'
507 kind = opts.get('type') or archival.guesskind(dest) or 'files'
508 prefix = opts.get('prefix')
508 prefix = opts.get('prefix')
509
509
510 if dest == '-':
510 if dest == '-':
511 if kind == 'files':
511 if kind == 'files':
512 raise error.Abort(_('cannot archive plain files to stdout'))
512 raise error.Abort(_('cannot archive plain files to stdout'))
513 dest = cmdutil.makefileobj(repo, dest)
513 dest = cmdutil.makefileobj(repo, dest)
514 if not prefix:
514 if not prefix:
515 prefix = os.path.basename(repo.root) + '-%h'
515 prefix = os.path.basename(repo.root) + '-%h'
516
516
517 prefix = cmdutil.makefilename(repo, prefix, node)
517 prefix = cmdutil.makefilename(repo, prefix, node)
518 matchfn = scmutil.match(ctx, [], opts)
518 matchfn = scmutil.match(ctx, [], opts)
519 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
519 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
520 matchfn, prefix, subrepos=opts.get('subrepos'))
520 matchfn, prefix, subrepos=opts.get('subrepos'))
521
521
522 @command('backout',
522 @command('backout',
523 [('', 'merge', None, _('merge with old dirstate parent after backout')),
523 [('', 'merge', None, _('merge with old dirstate parent after backout')),
524 ('', 'commit', None, _('commit if no conflicts were encountered')),
524 ('', 'commit', None, _('commit if no conflicts were encountered')),
525 ('', 'parent', '',
525 ('', 'parent', '',
526 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
526 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
527 ('r', 'rev', '', _('revision to backout'), _('REV')),
527 ('r', 'rev', '', _('revision to backout'), _('REV')),
528 ('e', 'edit', False, _('invoke editor on commit messages')),
528 ('e', 'edit', False, _('invoke editor on commit messages')),
529 ] + mergetoolopts + walkopts + commitopts + commitopts2,
529 ] + mergetoolopts + walkopts + commitopts + commitopts2,
530 _('[OPTION]... [-r] REV'))
530 _('[OPTION]... [-r] REV'))
531 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
531 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
532 '''reverse effect of earlier changeset
532 '''reverse effect of earlier changeset
533
533
534 Prepare a new changeset with the effect of REV undone in the
534 Prepare a new changeset with the effect of REV undone in the
535 current working directory.
535 current working directory.
536
536
537 If REV is the parent of the working directory, then this new changeset
537 If REV is the parent of the working directory, then this new changeset
538 is committed automatically. Otherwise, hg needs to merge the
538 is committed automatically. Otherwise, hg needs to merge the
539 changes and the merged result is left uncommitted.
539 changes and the merged result is left uncommitted.
540
540
541 .. note::
541 .. note::
542
542
543 backout cannot be used to fix either an unwanted or
543 backout cannot be used to fix either an unwanted or
544 incorrect merge.
544 incorrect merge.
545
545
546 .. container:: verbose
546 .. container:: verbose
547
547
548 Examples:
548 Examples:
549
549
550 - Reverse the effect of the parent of the working directory.
550 - Reverse the effect of the parent of the working directory.
551 This backout will be committed immediately::
551 This backout will be committed immediately::
552
552
553 hg backout -r .
553 hg backout -r .
554
554
555 - Reverse the effect of previous bad revision 23::
555 - Reverse the effect of previous bad revision 23::
556
556
557 hg backout -r 23
557 hg backout -r 23
558 hg commit -m "Backout revision 23"
558 hg commit -m "Backout revision 23"
559
559
560 - Reverse the effect of previous bad revision 23 and
560 - Reverse the effect of previous bad revision 23 and
561 commit the backout immediately::
561 commit the backout immediately::
562
562
563 hg backout -r 23 --commit
563 hg backout -r 23 --commit
564
564
565 By default, the pending changeset will have one parent,
565 By default, the pending changeset will have one parent,
566 maintaining a linear history. With --merge, the pending
566 maintaining a linear history. With --merge, the pending
567 changeset will instead have two parents: the old parent of the
567 changeset will instead have two parents: the old parent of the
568 working directory and a new child of REV that simply undoes REV.
568 working directory and a new child of REV that simply undoes REV.
569
569
570 Before version 1.7, the behavior without --merge was equivalent
570 Before version 1.7, the behavior without --merge was equivalent
571 to specifying --merge followed by :hg:`update --clean .` to
571 to specifying --merge followed by :hg:`update --clean .` to
572 cancel the merge and leave the child of REV as a head to be
572 cancel the merge and leave the child of REV as a head to be
573 merged separately.
573 merged separately.
574
574
575 See :hg:`help dates` for a list of formats valid for -d/--date.
575 See :hg:`help dates` for a list of formats valid for -d/--date.
576
576
577 See :hg:`help revert` for a way to restore files to the state
577 See :hg:`help revert` for a way to restore files to the state
578 of another revision.
578 of another revision.
579
579
580 Returns 0 on success, 1 if nothing to backout or there are unresolved
580 Returns 0 on success, 1 if nothing to backout or there are unresolved
581 files.
581 files.
582 '''
582 '''
583 wlock = lock = None
583 wlock = lock = None
584 try:
584 try:
585 wlock = repo.wlock()
585 wlock = repo.wlock()
586 lock = repo.lock()
586 lock = repo.lock()
587 return _dobackout(ui, repo, node, rev, commit, **opts)
587 return _dobackout(ui, repo, node, rev, commit, **opts)
588 finally:
588 finally:
589 release(lock, wlock)
589 release(lock, wlock)
590
590
591 def _dobackout(ui, repo, node=None, rev=None, commit=False, **opts):
591 def _dobackout(ui, repo, node=None, rev=None, commit=False, **opts):
592 if rev and node:
592 if rev and node:
593 raise error.Abort(_("please specify just one revision"))
593 raise error.Abort(_("please specify just one revision"))
594
594
595 if not rev:
595 if not rev:
596 rev = node
596 rev = node
597
597
598 if not rev:
598 if not rev:
599 raise error.Abort(_("please specify a revision to backout"))
599 raise error.Abort(_("please specify a revision to backout"))
600
600
601 date = opts.get('date')
601 date = opts.get('date')
602 if date:
602 if date:
603 opts['date'] = util.parsedate(date)
603 opts['date'] = util.parsedate(date)
604
604
605 cmdutil.checkunfinished(repo)
605 cmdutil.checkunfinished(repo)
606 cmdutil.bailifchanged(repo)
606 cmdutil.bailifchanged(repo)
607 node = scmutil.revsingle(repo, rev).node()
607 node = scmutil.revsingle(repo, rev).node()
608
608
609 op1, op2 = repo.dirstate.parents()
609 op1, op2 = repo.dirstate.parents()
610 if not repo.changelog.isancestor(node, op1):
610 if not repo.changelog.isancestor(node, op1):
611 raise error.Abort(_('cannot backout change that is not an ancestor'))
611 raise error.Abort(_('cannot backout change that is not an ancestor'))
612
612
613 p1, p2 = repo.changelog.parents(node)
613 p1, p2 = repo.changelog.parents(node)
614 if p1 == nullid:
614 if p1 == nullid:
615 raise error.Abort(_('cannot backout a change with no parents'))
615 raise error.Abort(_('cannot backout a change with no parents'))
616 if p2 != nullid:
616 if p2 != nullid:
617 if not opts.get('parent'):
617 if not opts.get('parent'):
618 raise error.Abort(_('cannot backout a merge changeset'))
618 raise error.Abort(_('cannot backout a merge changeset'))
619 p = repo.lookup(opts['parent'])
619 p = repo.lookup(opts['parent'])
620 if p not in (p1, p2):
620 if p not in (p1, p2):
621 raise error.Abort(_('%s is not a parent of %s') %
621 raise error.Abort(_('%s is not a parent of %s') %
622 (short(p), short(node)))
622 (short(p), short(node)))
623 parent = p
623 parent = p
624 else:
624 else:
625 if opts.get('parent'):
625 if opts.get('parent'):
626 raise error.Abort(_('cannot use --parent on non-merge changeset'))
626 raise error.Abort(_('cannot use --parent on non-merge changeset'))
627 parent = p1
627 parent = p1
628
628
629 # the backout should appear on the same branch
629 # the backout should appear on the same branch
630 try:
630 try:
631 branch = repo.dirstate.branch()
631 branch = repo.dirstate.branch()
632 bheads = repo.branchheads(branch)
632 bheads = repo.branchheads(branch)
633 rctx = scmutil.revsingle(repo, hex(parent))
633 rctx = scmutil.revsingle(repo, hex(parent))
634 if not opts.get('merge') and op1 != node:
634 if not opts.get('merge') and op1 != node:
635 dsguard = cmdutil.dirstateguard(repo, 'backout')
635 dsguard = cmdutil.dirstateguard(repo, 'backout')
636 try:
636 try:
637 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
637 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
638 'backout')
638 'backout')
639 stats = mergemod.update(repo, parent, True, True, False,
639 stats = mergemod.update(repo, parent, True, True, False,
640 node, False)
640 node, False)
641 repo.setparents(op1, op2)
641 repo.setparents(op1, op2)
642 dsguard.close()
642 dsguard.close()
643 hg._showstats(repo, stats)
643 hg._showstats(repo, stats)
644 if stats[3]:
644 if stats[3]:
645 repo.ui.status(_("use 'hg resolve' to retry unresolved "
645 repo.ui.status(_("use 'hg resolve' to retry unresolved "
646 "file merges\n"))
646 "file merges\n"))
647 return 1
647 return 1
648 elif not commit:
648 elif not commit:
649 msg = _("changeset %s backed out, "
649 msg = _("changeset %s backed out, "
650 "don't forget to commit.\n")
650 "don't forget to commit.\n")
651 ui.status(msg % short(node))
651 ui.status(msg % short(node))
652 return 0
652 return 0
653 finally:
653 finally:
654 ui.setconfig('ui', 'forcemerge', '', '')
654 ui.setconfig('ui', 'forcemerge', '', '')
655 lockmod.release(dsguard)
655 lockmod.release(dsguard)
656 else:
656 else:
657 hg.clean(repo, node, show_stats=False)
657 hg.clean(repo, node, show_stats=False)
658 repo.dirstate.setbranch(branch)
658 repo.dirstate.setbranch(branch)
659 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
659 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
660
660
661
661
662 def commitfunc(ui, repo, message, match, opts):
662 def commitfunc(ui, repo, message, match, opts):
663 editform = 'backout'
663 editform = 'backout'
664 e = cmdutil.getcommiteditor(editform=editform, **opts)
664 e = cmdutil.getcommiteditor(editform=editform, **opts)
665 if not message:
665 if not message:
666 # we don't translate commit messages
666 # we don't translate commit messages
667 message = "Backed out changeset %s" % short(node)
667 message = "Backed out changeset %s" % short(node)
668 e = cmdutil.getcommiteditor(edit=True, editform=editform)
668 e = cmdutil.getcommiteditor(edit=True, editform=editform)
669 return repo.commit(message, opts.get('user'), opts.get('date'),
669 return repo.commit(message, opts.get('user'), opts.get('date'),
670 match, editor=e)
670 match, editor=e)
671 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
671 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
672 if not newnode:
672 if not newnode:
673 ui.status(_("nothing changed\n"))
673 ui.status(_("nothing changed\n"))
674 return 1
674 return 1
675 cmdutil.commitstatus(repo, newnode, branch, bheads)
675 cmdutil.commitstatus(repo, newnode, branch, bheads)
676
676
677 def nice(node):
677 def nice(node):
678 return '%d:%s' % (repo.changelog.rev(node), short(node))
678 return '%d:%s' % (repo.changelog.rev(node), short(node))
679 ui.status(_('changeset %s backs out changeset %s\n') %
679 ui.status(_('changeset %s backs out changeset %s\n') %
680 (nice(repo.changelog.tip()), nice(node)))
680 (nice(repo.changelog.tip()), nice(node)))
681 if opts.get('merge') and op1 != node:
681 if opts.get('merge') and op1 != node:
682 hg.clean(repo, op1, show_stats=False)
682 hg.clean(repo, op1, show_stats=False)
683 ui.status(_('merging with changeset %s\n')
683 ui.status(_('merging with changeset %s\n')
684 % nice(repo.changelog.tip()))
684 % nice(repo.changelog.tip()))
685 try:
685 try:
686 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
686 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
687 'backout')
687 'backout')
688 return hg.merge(repo, hex(repo.changelog.tip()))
688 return hg.merge(repo, hex(repo.changelog.tip()))
689 finally:
689 finally:
690 ui.setconfig('ui', 'forcemerge', '', '')
690 ui.setconfig('ui', 'forcemerge', '', '')
691 finally:
691 finally:
692 # TODO: get rid of this meaningless try/finally enclosing.
692 # TODO: get rid of this meaningless try/finally enclosing.
693 # this is kept only to reduce changes in a patch.
693 # this is kept only to reduce changes in a patch.
694 pass
694 pass
695 return 0
695 return 0
696
696
697 @command('bisect',
697 @command('bisect',
698 [('r', 'reset', False, _('reset bisect state')),
698 [('r', 'reset', False, _('reset bisect state')),
699 ('g', 'good', False, _('mark changeset good')),
699 ('g', 'good', False, _('mark changeset good')),
700 ('b', 'bad', False, _('mark changeset bad')),
700 ('b', 'bad', False, _('mark changeset bad')),
701 ('s', 'skip', False, _('skip testing changeset')),
701 ('s', 'skip', False, _('skip testing changeset')),
702 ('e', 'extend', False, _('extend the bisect range')),
702 ('e', 'extend', False, _('extend the bisect range')),
703 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
703 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
704 ('U', 'noupdate', False, _('do not update to target'))],
704 ('U', 'noupdate', False, _('do not update to target'))],
705 _("[-gbsr] [-U] [-c CMD] [REV]"))
705 _("[-gbsr] [-U] [-c CMD] [REV]"))
706 def bisect(ui, repo, rev=None, extra=None, command=None,
706 def bisect(ui, repo, rev=None, extra=None, command=None,
707 reset=None, good=None, bad=None, skip=None, extend=None,
707 reset=None, good=None, bad=None, skip=None, extend=None,
708 noupdate=None):
708 noupdate=None):
709 """subdivision search of changesets
709 """subdivision search of changesets
710
710
711 This command helps to find changesets which introduce problems. To
711 This command helps to find changesets which introduce problems. To
712 use, mark the earliest changeset you know exhibits the problem as
712 use, mark the earliest changeset you know exhibits the problem as
713 bad, then mark the latest changeset which is free from the problem
713 bad, then mark the latest changeset which is free from the problem
714 as good. Bisect will update your working directory to a revision
714 as good. Bisect will update your working directory to a revision
715 for testing (unless the -U/--noupdate option is specified). Once
715 for testing (unless the -U/--noupdate option is specified). Once
716 you have performed tests, mark the working directory as good or
716 you have performed tests, mark the working directory as good or
717 bad, and bisect will either update to another candidate changeset
717 bad, and bisect will either update to another candidate changeset
718 or announce that it has found the bad revision.
718 or announce that it has found the bad revision.
719
719
720 As a shortcut, you can also use the revision argument to mark a
720 As a shortcut, you can also use the revision argument to mark a
721 revision as good or bad without checking it out first.
721 revision as good or bad without checking it out first.
722
722
723 If you supply a command, it will be used for automatic bisection.
723 If you supply a command, it will be used for automatic bisection.
724 The environment variable HG_NODE will contain the ID of the
724 The environment variable HG_NODE will contain the ID of the
725 changeset being tested. The exit status of the command will be
725 changeset being tested. The exit status of the command will be
726 used to mark revisions as good or bad: status 0 means good, 125
726 used to mark revisions as good or bad: status 0 means good, 125
727 means to skip the revision, 127 (command not found) will abort the
727 means to skip the revision, 127 (command not found) will abort the
728 bisection, and any other non-zero exit status means the revision
728 bisection, and any other non-zero exit status means the revision
729 is bad.
729 is bad.
730
730
731 .. container:: verbose
731 .. container:: verbose
732
732
733 Some examples:
733 Some examples:
734
734
735 - start a bisection with known bad revision 34, and good revision 12::
735 - start a bisection with known bad revision 34, and good revision 12::
736
736
737 hg bisect --bad 34
737 hg bisect --bad 34
738 hg bisect --good 12
738 hg bisect --good 12
739
739
740 - advance the current bisection by marking current revision as good or
740 - advance the current bisection by marking current revision as good or
741 bad::
741 bad::
742
742
743 hg bisect --good
743 hg bisect --good
744 hg bisect --bad
744 hg bisect --bad
745
745
746 - mark the current revision, or a known revision, to be skipped (e.g. if
746 - mark the current revision, or a known revision, to be skipped (e.g. if
747 that revision is not usable because of another issue)::
747 that revision is not usable because of another issue)::
748
748
749 hg bisect --skip
749 hg bisect --skip
750 hg bisect --skip 23
750 hg bisect --skip 23
751
751
752 - skip all revisions that do not touch directories ``foo`` or ``bar``::
752 - skip all revisions that do not touch directories ``foo`` or ``bar``::
753
753
754 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
754 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
755
755
756 - forget the current bisection::
756 - forget the current bisection::
757
757
758 hg bisect --reset
758 hg bisect --reset
759
759
760 - use 'make && make tests' to automatically find the first broken
760 - use 'make && make tests' to automatically find the first broken
761 revision::
761 revision::
762
762
763 hg bisect --reset
763 hg bisect --reset
764 hg bisect --bad 34
764 hg bisect --bad 34
765 hg bisect --good 12
765 hg bisect --good 12
766 hg bisect --command "make && make tests"
766 hg bisect --command "make && make tests"
767
767
768 - see all changesets whose states are already known in the current
768 - see all changesets whose states are already known in the current
769 bisection::
769 bisection::
770
770
771 hg log -r "bisect(pruned)"
771 hg log -r "bisect(pruned)"
772
772
773 - see the changeset currently being bisected (especially useful
773 - see the changeset currently being bisected (especially useful
774 if running with -U/--noupdate)::
774 if running with -U/--noupdate)::
775
775
776 hg log -r "bisect(current)"
776 hg log -r "bisect(current)"
777
777
778 - see all changesets that took part in the current bisection::
778 - see all changesets that took part in the current bisection::
779
779
780 hg log -r "bisect(range)"
780 hg log -r "bisect(range)"
781
781
782 - you can even get a nice graph::
782 - you can even get a nice graph::
783
783
784 hg log --graph -r "bisect(range)"
784 hg log --graph -r "bisect(range)"
785
785
786 See :hg:`help revsets` for more about the `bisect()` keyword.
786 See :hg:`help revsets` for more about the `bisect()` keyword.
787
787
788 Returns 0 on success.
788 Returns 0 on success.
789 """
789 """
790 def extendbisectrange(nodes, good):
790 def extendbisectrange(nodes, good):
791 # bisect is incomplete when it ends on a merge node and
791 # bisect is incomplete when it ends on a merge node and
792 # one of the parent was not checked.
792 # one of the parent was not checked.
793 parents = repo[nodes[0]].parents()
793 parents = repo[nodes[0]].parents()
794 if len(parents) > 1:
794 if len(parents) > 1:
795 if good:
795 if good:
796 side = state['bad']
796 side = state['bad']
797 else:
797 else:
798 side = state['good']
798 side = state['good']
799 num = len(set(i.node() for i in parents) & set(side))
799 num = len(set(i.node() for i in parents) & set(side))
800 if num == 1:
800 if num == 1:
801 return parents[0].ancestor(parents[1])
801 return parents[0].ancestor(parents[1])
802 return None
802 return None
803
803
804 def print_result(nodes, good):
804 def print_result(nodes, good):
805 displayer = cmdutil.show_changeset(ui, repo, {})
805 displayer = cmdutil.show_changeset(ui, repo, {})
806 if len(nodes) == 1:
806 if len(nodes) == 1:
807 # narrowed it down to a single revision
807 # narrowed it down to a single revision
808 if good:
808 if good:
809 ui.write(_("The first good revision is:\n"))
809 ui.write(_("The first good revision is:\n"))
810 else:
810 else:
811 ui.write(_("The first bad revision is:\n"))
811 ui.write(_("The first bad revision is:\n"))
812 displayer.show(repo[nodes[0]])
812 displayer.show(repo[nodes[0]])
813 extendnode = extendbisectrange(nodes, good)
813 extendnode = extendbisectrange(nodes, good)
814 if extendnode is not None:
814 if extendnode is not None:
815 ui.write(_('Not all ancestors of this changeset have been'
815 ui.write(_('Not all ancestors of this changeset have been'
816 ' checked.\nUse bisect --extend to continue the '
816 ' checked.\nUse bisect --extend to continue the '
817 'bisection from\nthe common ancestor, %s.\n')
817 'bisection from\nthe common ancestor, %s.\n')
818 % extendnode)
818 % extendnode)
819 else:
819 else:
820 # multiple possible revisions
820 # multiple possible revisions
821 if good:
821 if good:
822 ui.write(_("Due to skipped revisions, the first "
822 ui.write(_("Due to skipped revisions, the first "
823 "good revision could be any of:\n"))
823 "good revision could be any of:\n"))
824 else:
824 else:
825 ui.write(_("Due to skipped revisions, the first "
825 ui.write(_("Due to skipped revisions, the first "
826 "bad revision could be any of:\n"))
826 "bad revision could be any of:\n"))
827 for n in nodes:
827 for n in nodes:
828 displayer.show(repo[n])
828 displayer.show(repo[n])
829 displayer.close()
829 displayer.close()
830
830
831 def check_state(state, interactive=True):
831 def check_state(state, interactive=True):
832 if not state['good'] or not state['bad']:
832 if not state['good'] or not state['bad']:
833 if (good or bad or skip or reset) and interactive:
833 if (good or bad or skip or reset) and interactive:
834 return
834 return
835 if not state['good']:
835 if not state['good']:
836 raise error.Abort(_('cannot bisect (no known good revisions)'))
836 raise error.Abort(_('cannot bisect (no known good revisions)'))
837 else:
837 else:
838 raise error.Abort(_('cannot bisect (no known bad revisions)'))
838 raise error.Abort(_('cannot bisect (no known bad revisions)'))
839 return True
839 return True
840
840
841 # backward compatibility
841 # backward compatibility
842 if rev in "good bad reset init".split():
842 if rev in "good bad reset init".split():
843 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
843 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
844 cmd, rev, extra = rev, extra, None
844 cmd, rev, extra = rev, extra, None
845 if cmd == "good":
845 if cmd == "good":
846 good = True
846 good = True
847 elif cmd == "bad":
847 elif cmd == "bad":
848 bad = True
848 bad = True
849 else:
849 else:
850 reset = True
850 reset = True
851 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
851 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
852 raise error.Abort(_('incompatible arguments'))
852 raise error.Abort(_('incompatible arguments'))
853
853
854 cmdutil.checkunfinished(repo)
854 cmdutil.checkunfinished(repo)
855
855
856 if reset:
856 if reset:
857 p = repo.join("bisect.state")
857 p = repo.join("bisect.state")
858 if os.path.exists(p):
858 if os.path.exists(p):
859 os.unlink(p)
859 os.unlink(p)
860 return
860 return
861
861
862 state = hbisect.load_state(repo)
862 state = hbisect.load_state(repo)
863
863
864 if command:
864 if command:
865 changesets = 1
865 changesets = 1
866 if noupdate:
866 if noupdate:
867 try:
867 try:
868 node = state['current'][0]
868 node = state['current'][0]
869 except LookupError:
869 except LookupError:
870 raise error.Abort(_('current bisect revision is unknown - '
870 raise error.Abort(_('current bisect revision is unknown - '
871 'start a new bisect to fix'))
871 'start a new bisect to fix'))
872 else:
872 else:
873 node, p2 = repo.dirstate.parents()
873 node, p2 = repo.dirstate.parents()
874 if p2 != nullid:
874 if p2 != nullid:
875 raise error.Abort(_('current bisect revision is a merge'))
875 raise error.Abort(_('current bisect revision is a merge'))
876 try:
876 try:
877 while changesets:
877 while changesets:
878 # update state
878 # update state
879 state['current'] = [node]
879 state['current'] = [node]
880 hbisect.save_state(repo, state)
880 hbisect.save_state(repo, state)
881 status = ui.system(command, environ={'HG_NODE': hex(node)})
881 status = ui.system(command, environ={'HG_NODE': hex(node)})
882 if status == 125:
882 if status == 125:
883 transition = "skip"
883 transition = "skip"
884 elif status == 0:
884 elif status == 0:
885 transition = "good"
885 transition = "good"
886 # status < 0 means process was killed
886 # status < 0 means process was killed
887 elif status == 127:
887 elif status == 127:
888 raise error.Abort(_("failed to execute %s") % command)
888 raise error.Abort(_("failed to execute %s") % command)
889 elif status < 0:
889 elif status < 0:
890 raise error.Abort(_("%s killed") % command)
890 raise error.Abort(_("%s killed") % command)
891 else:
891 else:
892 transition = "bad"
892 transition = "bad"
893 ctx = scmutil.revsingle(repo, rev, node)
893 ctx = scmutil.revsingle(repo, rev, node)
894 rev = None # clear for future iterations
894 rev = None # clear for future iterations
895 state[transition].append(ctx.node())
895 state[transition].append(ctx.node())
896 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
896 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
897 check_state(state, interactive=False)
897 check_state(state, interactive=False)
898 # bisect
898 # bisect
899 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
899 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
900 # update to next check
900 # update to next check
901 node = nodes[0]
901 node = nodes[0]
902 if not noupdate:
902 if not noupdate:
903 cmdutil.bailifchanged(repo)
903 cmdutil.bailifchanged(repo)
904 hg.clean(repo, node, show_stats=False)
904 hg.clean(repo, node, show_stats=False)
905 finally:
905 finally:
906 state['current'] = [node]
906 state['current'] = [node]
907 hbisect.save_state(repo, state)
907 hbisect.save_state(repo, state)
908 print_result(nodes, bgood)
908 print_result(nodes, bgood)
909 return
909 return
910
910
911 # update state
911 # update state
912
912
913 if rev:
913 if rev:
914 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
914 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
915 else:
915 else:
916 nodes = [repo.lookup('.')]
916 nodes = [repo.lookup('.')]
917
917
918 if good or bad or skip:
918 if good or bad or skip:
919 if good:
919 if good:
920 state['good'] += nodes
920 state['good'] += nodes
921 elif bad:
921 elif bad:
922 state['bad'] += nodes
922 state['bad'] += nodes
923 elif skip:
923 elif skip:
924 state['skip'] += nodes
924 state['skip'] += nodes
925 hbisect.save_state(repo, state)
925 hbisect.save_state(repo, state)
926
926
927 if not check_state(state):
927 if not check_state(state):
928 return
928 return
929
929
930 # actually bisect
930 # actually bisect
931 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
931 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
932 if extend:
932 if extend:
933 if not changesets:
933 if not changesets:
934 extendnode = extendbisectrange(nodes, good)
934 extendnode = extendbisectrange(nodes, good)
935 if extendnode is not None:
935 if extendnode is not None:
936 ui.write(_("Extending search to changeset %d:%s\n")
936 ui.write(_("Extending search to changeset %d:%s\n")
937 % (extendnode.rev(), extendnode))
937 % (extendnode.rev(), extendnode))
938 state['current'] = [extendnode.node()]
938 state['current'] = [extendnode.node()]
939 hbisect.save_state(repo, state)
939 hbisect.save_state(repo, state)
940 if noupdate:
940 if noupdate:
941 return
941 return
942 cmdutil.bailifchanged(repo)
942 cmdutil.bailifchanged(repo)
943 return hg.clean(repo, extendnode.node())
943 return hg.clean(repo, extendnode.node())
944 raise error.Abort(_("nothing to extend"))
944 raise error.Abort(_("nothing to extend"))
945
945
946 if changesets == 0:
946 if changesets == 0:
947 print_result(nodes, good)
947 print_result(nodes, good)
948 else:
948 else:
949 assert len(nodes) == 1 # only a single node can be tested next
949 assert len(nodes) == 1 # only a single node can be tested next
950 node = nodes[0]
950 node = nodes[0]
951 # compute the approximate number of remaining tests
951 # compute the approximate number of remaining tests
952 tests, size = 0, 2
952 tests, size = 0, 2
953 while size <= changesets:
953 while size <= changesets:
954 tests, size = tests + 1, size * 2
954 tests, size = tests + 1, size * 2
955 rev = repo.changelog.rev(node)
955 rev = repo.changelog.rev(node)
956 ui.write(_("Testing changeset %d:%s "
956 ui.write(_("Testing changeset %d:%s "
957 "(%d changesets remaining, ~%d tests)\n")
957 "(%d changesets remaining, ~%d tests)\n")
958 % (rev, short(node), changesets, tests))
958 % (rev, short(node), changesets, tests))
959 state['current'] = [node]
959 state['current'] = [node]
960 hbisect.save_state(repo, state)
960 hbisect.save_state(repo, state)
961 if not noupdate:
961 if not noupdate:
962 cmdutil.bailifchanged(repo)
962 cmdutil.bailifchanged(repo)
963 return hg.clean(repo, node)
963 return hg.clean(repo, node)
964
964
965 @command('bookmarks|bookmark',
965 @command('bookmarks|bookmark',
966 [('f', 'force', False, _('force')),
966 [('f', 'force', False, _('force')),
967 ('r', 'rev', '', _('revision'), _('REV')),
967 ('r', 'rev', '', _('revision'), _('REV')),
968 ('d', 'delete', False, _('delete a given bookmark')),
968 ('d', 'delete', False, _('delete a given bookmark')),
969 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
969 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
970 ('i', 'inactive', False, _('mark a bookmark inactive')),
970 ('i', 'inactive', False, _('mark a bookmark inactive')),
971 ] + formatteropts,
971 ] + formatteropts,
972 _('hg bookmarks [OPTIONS]... [NAME]...'))
972 _('hg bookmarks [OPTIONS]... [NAME]...'))
973 def bookmark(ui, repo, *names, **opts):
973 def bookmark(ui, repo, *names, **opts):
974 '''create a new bookmark or list existing bookmarks
974 '''create a new bookmark or list existing bookmarks
975
975
976 Bookmarks are labels on changesets to help track lines of development.
976 Bookmarks are labels on changesets to help track lines of development.
977 Bookmarks are unversioned and can be moved, renamed and deleted.
977 Bookmarks are unversioned and can be moved, renamed and deleted.
978 Deleting or moving a bookmark has no effect on the associated changesets.
978 Deleting or moving a bookmark has no effect on the associated changesets.
979
979
980 Creating or updating to a bookmark causes it to be marked as 'active'.
980 Creating or updating to a bookmark causes it to be marked as 'active'.
981 The active bookmark is indicated with a '*'.
981 The active bookmark is indicated with a '*'.
982 When a commit is made, the active bookmark will advance to the new commit.
982 When a commit is made, the active bookmark will advance to the new commit.
983 A plain :hg:`update` will also advance an active bookmark, if possible.
983 A plain :hg:`update` will also advance an active bookmark, if possible.
984 Updating away from a bookmark will cause it to be deactivated.
984 Updating away from a bookmark will cause it to be deactivated.
985
985
986 Bookmarks can be pushed and pulled between repositories (see
986 Bookmarks can be pushed and pulled between repositories (see
987 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
987 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
988 diverged, a new 'divergent bookmark' of the form 'name@path' will
988 diverged, a new 'divergent bookmark' of the form 'name@path' will
989 be created. Using :hg:`merge` will resolve the divergence.
989 be created. Using :hg:`merge` will resolve the divergence.
990
990
991 A bookmark named '@' has the special property that :hg:`clone` will
991 A bookmark named '@' has the special property that :hg:`clone` will
992 check it out by default if it exists.
992 check it out by default if it exists.
993
993
994 .. container:: verbose
994 .. container:: verbose
995
995
996 Examples:
996 Examples:
997
997
998 - create an active bookmark for a new line of development::
998 - create an active bookmark for a new line of development::
999
999
1000 hg book new-feature
1000 hg book new-feature
1001
1001
1002 - create an inactive bookmark as a place marker::
1002 - create an inactive bookmark as a place marker::
1003
1003
1004 hg book -i reviewed
1004 hg book -i reviewed
1005
1005
1006 - create an inactive bookmark on another changeset::
1006 - create an inactive bookmark on another changeset::
1007
1007
1008 hg book -r .^ tested
1008 hg book -r .^ tested
1009
1009
1010 - rename bookmark turkey to dinner::
1010 - rename bookmark turkey to dinner::
1011
1011
1012 hg book -m turkey dinner
1012 hg book -m turkey dinner
1013
1013
1014 - move the '@' bookmark from another branch::
1014 - move the '@' bookmark from another branch::
1015
1015
1016 hg book -f @
1016 hg book -f @
1017 '''
1017 '''
1018 force = opts.get('force')
1018 force = opts.get('force')
1019 rev = opts.get('rev')
1019 rev = opts.get('rev')
1020 delete = opts.get('delete')
1020 delete = opts.get('delete')
1021 rename = opts.get('rename')
1021 rename = opts.get('rename')
1022 inactive = opts.get('inactive')
1022 inactive = opts.get('inactive')
1023
1023
1024 def checkformat(mark):
1024 def checkformat(mark):
1025 mark = mark.strip()
1025 mark = mark.strip()
1026 if not mark:
1026 if not mark:
1027 raise error.Abort(_("bookmark names cannot consist entirely of "
1027 raise error.Abort(_("bookmark names cannot consist entirely of "
1028 "whitespace"))
1028 "whitespace"))
1029 scmutil.checknewlabel(repo, mark, 'bookmark')
1029 scmutil.checknewlabel(repo, mark, 'bookmark')
1030 return mark
1030 return mark
1031
1031
1032 def checkconflict(repo, mark, cur, force=False, target=None):
1032 def checkconflict(repo, mark, cur, force=False, target=None):
1033 if mark in marks and not force:
1033 if mark in marks and not force:
1034 if target:
1034 if target:
1035 if marks[mark] == target and target == cur:
1035 if marks[mark] == target and target == cur:
1036 # re-activating a bookmark
1036 # re-activating a bookmark
1037 return
1037 return
1038 anc = repo.changelog.ancestors([repo[target].rev()])
1038 anc = repo.changelog.ancestors([repo[target].rev()])
1039 bmctx = repo[marks[mark]]
1039 bmctx = repo[marks[mark]]
1040 divs = [repo[b].node() for b in marks
1040 divs = [repo[b].node() for b in marks
1041 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
1041 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
1042
1042
1043 # allow resolving a single divergent bookmark even if moving
1043 # allow resolving a single divergent bookmark even if moving
1044 # the bookmark across branches when a revision is specified
1044 # the bookmark across branches when a revision is specified
1045 # that contains a divergent bookmark
1045 # that contains a divergent bookmark
1046 if bmctx.rev() not in anc and target in divs:
1046 if bmctx.rev() not in anc and target in divs:
1047 bookmarks.deletedivergent(repo, [target], mark)
1047 bookmarks.deletedivergent(repo, [target], mark)
1048 return
1048 return
1049
1049
1050 deletefrom = [b for b in divs
1050 deletefrom = [b for b in divs
1051 if repo[b].rev() in anc or b == target]
1051 if repo[b].rev() in anc or b == target]
1052 bookmarks.deletedivergent(repo, deletefrom, mark)
1052 bookmarks.deletedivergent(repo, deletefrom, mark)
1053 if bookmarks.validdest(repo, bmctx, repo[target]):
1053 if bookmarks.validdest(repo, bmctx, repo[target]):
1054 ui.status(_("moving bookmark '%s' forward from %s\n") %
1054 ui.status(_("moving bookmark '%s' forward from %s\n") %
1055 (mark, short(bmctx.node())))
1055 (mark, short(bmctx.node())))
1056 return
1056 return
1057 raise error.Abort(_("bookmark '%s' already exists "
1057 raise error.Abort(_("bookmark '%s' already exists "
1058 "(use -f to force)") % mark)
1058 "(use -f to force)") % mark)
1059 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
1059 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
1060 and not force):
1060 and not force):
1061 raise error.Abort(
1061 raise error.Abort(
1062 _("a bookmark cannot have the name of an existing branch"))
1062 _("a bookmark cannot have the name of an existing branch"))
1063
1063
1064 if delete and rename:
1064 if delete and rename:
1065 raise error.Abort(_("--delete and --rename are incompatible"))
1065 raise error.Abort(_("--delete and --rename are incompatible"))
1066 if delete and rev:
1066 if delete and rev:
1067 raise error.Abort(_("--rev is incompatible with --delete"))
1067 raise error.Abort(_("--rev is incompatible with --delete"))
1068 if rename and rev:
1068 if rename and rev:
1069 raise error.Abort(_("--rev is incompatible with --rename"))
1069 raise error.Abort(_("--rev is incompatible with --rename"))
1070 if not names and (delete or rev):
1070 if not names and (delete or rev):
1071 raise error.Abort(_("bookmark name required"))
1071 raise error.Abort(_("bookmark name required"))
1072
1072
1073 if delete or rename or names or inactive:
1073 if delete or rename or names or inactive:
1074 wlock = lock = tr = None
1074 wlock = lock = tr = None
1075 try:
1075 try:
1076 wlock = repo.wlock()
1076 wlock = repo.wlock()
1077 lock = repo.lock()
1077 lock = repo.lock()
1078 cur = repo.changectx('.').node()
1078 cur = repo.changectx('.').node()
1079 marks = repo._bookmarks
1079 marks = repo._bookmarks
1080 if delete:
1080 if delete:
1081 tr = repo.transaction('bookmark')
1081 tr = repo.transaction('bookmark')
1082 for mark in names:
1082 for mark in names:
1083 if mark not in marks:
1083 if mark not in marks:
1084 raise error.Abort(_("bookmark '%s' does not exist") %
1084 raise error.Abort(_("bookmark '%s' does not exist") %
1085 mark)
1085 mark)
1086 if mark == repo._activebookmark:
1086 if mark == repo._activebookmark:
1087 bookmarks.deactivate(repo)
1087 bookmarks.deactivate(repo)
1088 del marks[mark]
1088 del marks[mark]
1089
1089
1090 elif rename:
1090 elif rename:
1091 tr = repo.transaction('bookmark')
1091 tr = repo.transaction('bookmark')
1092 if not names:
1092 if not names:
1093 raise error.Abort(_("new bookmark name required"))
1093 raise error.Abort(_("new bookmark name required"))
1094 elif len(names) > 1:
1094 elif len(names) > 1:
1095 raise error.Abort(_("only one new bookmark name allowed"))
1095 raise error.Abort(_("only one new bookmark name allowed"))
1096 mark = checkformat(names[0])
1096 mark = checkformat(names[0])
1097 if rename not in marks:
1097 if rename not in marks:
1098 raise error.Abort(_("bookmark '%s' does not exist")
1098 raise error.Abort(_("bookmark '%s' does not exist")
1099 % rename)
1099 % rename)
1100 checkconflict(repo, mark, cur, force)
1100 checkconflict(repo, mark, cur, force)
1101 marks[mark] = marks[rename]
1101 marks[mark] = marks[rename]
1102 if repo._activebookmark == rename and not inactive:
1102 if repo._activebookmark == rename and not inactive:
1103 bookmarks.activate(repo, mark)
1103 bookmarks.activate(repo, mark)
1104 del marks[rename]
1104 del marks[rename]
1105 elif names:
1105 elif names:
1106 tr = repo.transaction('bookmark')
1106 tr = repo.transaction('bookmark')
1107 newact = None
1107 newact = None
1108 for mark in names:
1108 for mark in names:
1109 mark = checkformat(mark)
1109 mark = checkformat(mark)
1110 if newact is None:
1110 if newact is None:
1111 newact = mark
1111 newact = mark
1112 if inactive and mark == repo._activebookmark:
1112 if inactive and mark == repo._activebookmark:
1113 bookmarks.deactivate(repo)
1113 bookmarks.deactivate(repo)
1114 return
1114 return
1115 tgt = cur
1115 tgt = cur
1116 if rev:
1116 if rev:
1117 tgt = scmutil.revsingle(repo, rev).node()
1117 tgt = scmutil.revsingle(repo, rev).node()
1118 checkconflict(repo, mark, cur, force, tgt)
1118 checkconflict(repo, mark, cur, force, tgt)
1119 marks[mark] = tgt
1119 marks[mark] = tgt
1120 if not inactive and cur == marks[newact] and not rev:
1120 if not inactive and cur == marks[newact] and not rev:
1121 bookmarks.activate(repo, newact)
1121 bookmarks.activate(repo, newact)
1122 elif cur != tgt and newact == repo._activebookmark:
1122 elif cur != tgt and newact == repo._activebookmark:
1123 bookmarks.deactivate(repo)
1123 bookmarks.deactivate(repo)
1124 elif inactive:
1124 elif inactive:
1125 if len(marks) == 0:
1125 if len(marks) == 0:
1126 ui.status(_("no bookmarks set\n"))
1126 ui.status(_("no bookmarks set\n"))
1127 elif not repo._activebookmark:
1127 elif not repo._activebookmark:
1128 ui.status(_("no active bookmark\n"))
1128 ui.status(_("no active bookmark\n"))
1129 else:
1129 else:
1130 bookmarks.deactivate(repo)
1130 bookmarks.deactivate(repo)
1131 if tr is not None:
1131 if tr is not None:
1132 marks.recordchange(tr)
1132 marks.recordchange(tr)
1133 tr.close()
1133 tr.close()
1134 finally:
1134 finally:
1135 lockmod.release(tr, lock, wlock)
1135 lockmod.release(tr, lock, wlock)
1136 else: # show bookmarks
1136 else: # show bookmarks
1137 fm = ui.formatter('bookmarks', opts)
1137 fm = ui.formatter('bookmarks', opts)
1138 hexfn = fm.hexfunc
1138 hexfn = fm.hexfunc
1139 marks = repo._bookmarks
1139 marks = repo._bookmarks
1140 if len(marks) == 0 and not fm:
1140 if len(marks) == 0 and not fm:
1141 ui.status(_("no bookmarks set\n"))
1141 ui.status(_("no bookmarks set\n"))
1142 for bmark, n in sorted(marks.iteritems()):
1142 for bmark, n in sorted(marks.iteritems()):
1143 active = repo._activebookmark
1143 active = repo._activebookmark
1144 if bmark == active:
1144 if bmark == active:
1145 prefix, label = '*', activebookmarklabel
1145 prefix, label = '*', activebookmarklabel
1146 else:
1146 else:
1147 prefix, label = ' ', ''
1147 prefix, label = ' ', ''
1148
1148
1149 fm.startitem()
1149 fm.startitem()
1150 if not ui.quiet:
1150 if not ui.quiet:
1151 fm.plain(' %s ' % prefix, label=label)
1151 fm.plain(' %s ' % prefix, label=label)
1152 fm.write('bookmark', '%s', bmark, label=label)
1152 fm.write('bookmark', '%s', bmark, label=label)
1153 pad = " " * (25 - encoding.colwidth(bmark))
1153 pad = " " * (25 - encoding.colwidth(bmark))
1154 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1154 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1155 repo.changelog.rev(n), hexfn(n), label=label)
1155 repo.changelog.rev(n), hexfn(n), label=label)
1156 fm.data(active=(bmark == active))
1156 fm.data(active=(bmark == active))
1157 fm.plain('\n')
1157 fm.plain('\n')
1158 fm.end()
1158 fm.end()
1159
1159
1160 @command('branch',
1160 @command('branch',
1161 [('f', 'force', None,
1161 [('f', 'force', None,
1162 _('set branch name even if it shadows an existing branch')),
1162 _('set branch name even if it shadows an existing branch')),
1163 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1163 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1164 _('[-fC] [NAME]'))
1164 _('[-fC] [NAME]'))
1165 def branch(ui, repo, label=None, **opts):
1165 def branch(ui, repo, label=None, **opts):
1166 """set or show the current branch name
1166 """set or show the current branch name
1167
1167
1168 .. note::
1168 .. note::
1169
1169
1170 Branch names are permanent and global. Use :hg:`bookmark` to create a
1170 Branch names are permanent and global. Use :hg:`bookmark` to create a
1171 light-weight bookmark instead. See :hg:`help glossary` for more
1171 light-weight bookmark instead. See :hg:`help glossary` for more
1172 information about named branches and bookmarks.
1172 information about named branches and bookmarks.
1173
1173
1174 With no argument, show the current branch name. With one argument,
1174 With no argument, show the current branch name. With one argument,
1175 set the working directory branch name (the branch will not exist
1175 set the working directory branch name (the branch will not exist
1176 in the repository until the next commit). Standard practice
1176 in the repository until the next commit). Standard practice
1177 recommends that primary development take place on the 'default'
1177 recommends that primary development take place on the 'default'
1178 branch.
1178 branch.
1179
1179
1180 Unless -f/--force is specified, branch will not let you set a
1180 Unless -f/--force is specified, branch will not let you set a
1181 branch name that already exists.
1181 branch name that already exists.
1182
1182
1183 Use -C/--clean to reset the working directory branch to that of
1183 Use -C/--clean to reset the working directory branch to that of
1184 the parent of the working directory, negating a previous branch
1184 the parent of the working directory, negating a previous branch
1185 change.
1185 change.
1186
1186
1187 Use the command :hg:`update` to switch to an existing branch. Use
1187 Use the command :hg:`update` to switch to an existing branch. Use
1188 :hg:`commit --close-branch` to mark this branch head as closed.
1188 :hg:`commit --close-branch` to mark this branch head as closed.
1189 When all heads of the branch are closed, the branch will be
1189 When all heads of the branch are closed, the branch will be
1190 considered closed.
1190 considered closed.
1191
1191
1192 Returns 0 on success.
1192 Returns 0 on success.
1193 """
1193 """
1194 if label:
1194 if label:
1195 label = label.strip()
1195 label = label.strip()
1196
1196
1197 if not opts.get('clean') and not label:
1197 if not opts.get('clean') and not label:
1198 ui.write("%s\n" % repo.dirstate.branch())
1198 ui.write("%s\n" % repo.dirstate.branch())
1199 return
1199 return
1200
1200
1201 wlock = repo.wlock()
1201 wlock = repo.wlock()
1202 try:
1202 try:
1203 if opts.get('clean'):
1203 if opts.get('clean'):
1204 label = repo[None].p1().branch()
1204 label = repo[None].p1().branch()
1205 repo.dirstate.setbranch(label)
1205 repo.dirstate.setbranch(label)
1206 ui.status(_('reset working directory to branch %s\n') % label)
1206 ui.status(_('reset working directory to branch %s\n') % label)
1207 elif label:
1207 elif label:
1208 if not opts.get('force') and label in repo.branchmap():
1208 if not opts.get('force') and label in repo.branchmap():
1209 if label not in [p.branch() for p in repo[None].parents()]:
1209 if label not in [p.branch() for p in repo[None].parents()]:
1210 raise error.Abort(_('a branch of the same name already'
1210 raise error.Abort(_('a branch of the same name already'
1211 ' exists'),
1211 ' exists'),
1212 # i18n: "it" refers to an existing branch
1212 # i18n: "it" refers to an existing branch
1213 hint=_("use 'hg update' to switch to it"))
1213 hint=_("use 'hg update' to switch to it"))
1214 scmutil.checknewlabel(repo, label, 'branch')
1214 scmutil.checknewlabel(repo, label, 'branch')
1215 repo.dirstate.setbranch(label)
1215 repo.dirstate.setbranch(label)
1216 ui.status(_('marked working directory as branch %s\n') % label)
1216 ui.status(_('marked working directory as branch %s\n') % label)
1217
1217
1218 # find any open named branches aside from default
1218 # find any open named branches aside from default
1219 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1219 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1220 if n != "default" and not c]
1220 if n != "default" and not c]
1221 if not others:
1221 if not others:
1222 ui.status(_('(branches are permanent and global, '
1222 ui.status(_('(branches are permanent and global, '
1223 'did you want a bookmark?)\n'))
1223 'did you want a bookmark?)\n'))
1224 finally:
1224 finally:
1225 wlock.release()
1225 wlock.release()
1226
1226
1227 @command('branches',
1227 @command('branches',
1228 [('a', 'active', False,
1228 [('a', 'active', False,
1229 _('show only branches that have unmerged heads (DEPRECATED)')),
1229 _('show only branches that have unmerged heads (DEPRECATED)')),
1230 ('c', 'closed', False, _('show normal and closed branches')),
1230 ('c', 'closed', False, _('show normal and closed branches')),
1231 ] + formatteropts,
1231 ] + formatteropts,
1232 _('[-ac]'))
1232 _('[-ac]'))
1233 def branches(ui, repo, active=False, closed=False, **opts):
1233 def branches(ui, repo, active=False, closed=False, **opts):
1234 """list repository named branches
1234 """list repository named branches
1235
1235
1236 List the repository's named branches, indicating which ones are
1236 List the repository's named branches, indicating which ones are
1237 inactive. If -c/--closed is specified, also list branches which have
1237 inactive. If -c/--closed is specified, also list branches which have
1238 been marked closed (see :hg:`commit --close-branch`).
1238 been marked closed (see :hg:`commit --close-branch`).
1239
1239
1240 Use the command :hg:`update` to switch to an existing branch.
1240 Use the command :hg:`update` to switch to an existing branch.
1241
1241
1242 Returns 0.
1242 Returns 0.
1243 """
1243 """
1244
1244
1245 fm = ui.formatter('branches', opts)
1245 fm = ui.formatter('branches', opts)
1246 hexfunc = fm.hexfunc
1246 hexfunc = fm.hexfunc
1247
1247
1248 allheads = set(repo.heads())
1248 allheads = set(repo.heads())
1249 branches = []
1249 branches = []
1250 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1250 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1251 isactive = not isclosed and bool(set(heads) & allheads)
1251 isactive = not isclosed and bool(set(heads) & allheads)
1252 branches.append((tag, repo[tip], isactive, not isclosed))
1252 branches.append((tag, repo[tip], isactive, not isclosed))
1253 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1253 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1254 reverse=True)
1254 reverse=True)
1255
1255
1256 for tag, ctx, isactive, isopen in branches:
1256 for tag, ctx, isactive, isopen in branches:
1257 if active and not isactive:
1257 if active and not isactive:
1258 continue
1258 continue
1259 if isactive:
1259 if isactive:
1260 label = 'branches.active'
1260 label = 'branches.active'
1261 notice = ''
1261 notice = ''
1262 elif not isopen:
1262 elif not isopen:
1263 if not closed:
1263 if not closed:
1264 continue
1264 continue
1265 label = 'branches.closed'
1265 label = 'branches.closed'
1266 notice = _(' (closed)')
1266 notice = _(' (closed)')
1267 else:
1267 else:
1268 label = 'branches.inactive'
1268 label = 'branches.inactive'
1269 notice = _(' (inactive)')
1269 notice = _(' (inactive)')
1270 current = (tag == repo.dirstate.branch())
1270 current = (tag == repo.dirstate.branch())
1271 if current:
1271 if current:
1272 label = 'branches.current'
1272 label = 'branches.current'
1273
1273
1274 fm.startitem()
1274 fm.startitem()
1275 fm.write('branch', '%s', tag, label=label)
1275 fm.write('branch', '%s', tag, label=label)
1276 rev = ctx.rev()
1276 rev = ctx.rev()
1277 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1277 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1278 fmt = ' ' * padsize + ' %d:%s'
1278 fmt = ' ' * padsize + ' %d:%s'
1279 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1279 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1280 label='log.changeset changeset.%s' % ctx.phasestr())
1280 label='log.changeset changeset.%s' % ctx.phasestr())
1281 fm.data(active=isactive, closed=not isopen, current=current)
1281 fm.data(active=isactive, closed=not isopen, current=current)
1282 if not ui.quiet:
1282 if not ui.quiet:
1283 fm.plain(notice)
1283 fm.plain(notice)
1284 fm.plain('\n')
1284 fm.plain('\n')
1285 fm.end()
1285 fm.end()
1286
1286
1287 @command('bundle',
1287 @command('bundle',
1288 [('f', 'force', None, _('run even when the destination is unrelated')),
1288 [('f', 'force', None, _('run even when the destination is unrelated')),
1289 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1289 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1290 _('REV')),
1290 _('REV')),
1291 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1291 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1292 _('BRANCH')),
1292 _('BRANCH')),
1293 ('', 'base', [],
1293 ('', 'base', [],
1294 _('a base changeset assumed to be available at the destination'),
1294 _('a base changeset assumed to be available at the destination'),
1295 _('REV')),
1295 _('REV')),
1296 ('a', 'all', None, _('bundle all changesets in the repository')),
1296 ('a', 'all', None, _('bundle all changesets in the repository')),
1297 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1297 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1298 ] + remoteopts,
1298 ] + remoteopts,
1299 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1299 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1300 def bundle(ui, repo, fname, dest=None, **opts):
1300 def bundle(ui, repo, fname, dest=None, **opts):
1301 """create a changegroup file
1301 """create a changegroup file
1302
1302
1303 Generate a compressed changegroup file collecting changesets not
1303 Generate a compressed changegroup file collecting changesets not
1304 known to be in another repository.
1304 known to be in another repository.
1305
1305
1306 If you omit the destination repository, then hg assumes the
1306 If you omit the destination repository, then hg assumes the
1307 destination will have all the nodes you specify with --base
1307 destination will have all the nodes you specify with --base
1308 parameters. To create a bundle containing all changesets, use
1308 parameters. To create a bundle containing all changesets, use
1309 -a/--all (or --base null).
1309 -a/--all (or --base null).
1310
1310
1311 You can change bundle format with the -t/--type option. You can
1311 You can change bundle format with the -t/--type option. You can
1312 specify a compression, a bundle version or both using a dash
1312 specify a compression, a bundle version or both using a dash
1313 (comp-version). The available compression methods are: none, bzip2,
1313 (comp-version). The available compression methods are: none, bzip2,
1314 and gzip (by default, bundles are compressed using bzip2). The
1314 and gzip (by default, bundles are compressed using bzip2). The
1315 available format are: v1, v2 (default to most suitable).
1315 available format are: v1, v2 (default to most suitable).
1316
1316
1317 The bundle file can then be transferred using conventional means
1317 The bundle file can then be transferred using conventional means
1318 and applied to another repository with the unbundle or pull
1318 and applied to another repository with the unbundle or pull
1319 command. This is useful when direct push and pull are not
1319 command. This is useful when direct push and pull are not
1320 available or when exporting an entire repository is undesirable.
1320 available or when exporting an entire repository is undesirable.
1321
1321
1322 Applying bundles preserves all changeset contents including
1322 Applying bundles preserves all changeset contents including
1323 permissions, copy/rename information, and revision history.
1323 permissions, copy/rename information, and revision history.
1324
1324
1325 Returns 0 on success, 1 if no changes found.
1325 Returns 0 on success, 1 if no changes found.
1326 """
1326 """
1327 revs = None
1327 revs = None
1328 if 'rev' in opts:
1328 if 'rev' in opts:
1329 revs = scmutil.revrange(repo, opts['rev'])
1329 revs = scmutil.revrange(repo, opts['rev'])
1330
1330
1331 bundletype = opts.get('type', 'bzip2').lower()
1331 bundletype = opts.get('type', 'bzip2').lower()
1332 try:
1332 try:
1333 bcompression, cgversion, params = exchange.parsebundlespec(
1333 bcompression, cgversion, params = exchange.parsebundlespec(
1334 repo, bundletype, strict=False)
1334 repo, bundletype, strict=False)
1335 except error.UnsupportedBundleSpecification as e:
1335 except error.UnsupportedBundleSpecification as e:
1336 raise error.Abort(str(e),
1336 raise error.Abort(str(e),
1337 hint=_('see "hg help bundle" for supported '
1337 hint=_('see "hg help bundle" for supported '
1338 'values for --type'))
1338 'values for --type'))
1339
1339
1340 # Packed bundles are a pseudo bundle format for now.
1340 # Packed bundles are a pseudo bundle format for now.
1341 if cgversion == 's1':
1341 if cgversion == 's1':
1342 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1342 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1343 hint=_('use "hg debugcreatestreamclonebundle"'))
1343 hint=_('use "hg debugcreatestreamclonebundle"'))
1344
1344
1345 if opts.get('all'):
1345 if opts.get('all'):
1346 base = ['null']
1346 base = ['null']
1347 else:
1347 else:
1348 base = scmutil.revrange(repo, opts.get('base'))
1348 base = scmutil.revrange(repo, opts.get('base'))
1349 # TODO: get desired bundlecaps from command line.
1349 # TODO: get desired bundlecaps from command line.
1350 bundlecaps = None
1350 bundlecaps = None
1351 if base:
1351 if base:
1352 if dest:
1352 if dest:
1353 raise error.Abort(_("--base is incompatible with specifying "
1353 raise error.Abort(_("--base is incompatible with specifying "
1354 "a destination"))
1354 "a destination"))
1355 common = [repo.lookup(rev) for rev in base]
1355 common = [repo.lookup(rev) for rev in base]
1356 heads = revs and map(repo.lookup, revs) or revs
1356 heads = revs and map(repo.lookup, revs) or revs
1357 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1357 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1358 common=common, bundlecaps=bundlecaps,
1358 common=common, bundlecaps=bundlecaps,
1359 version=cgversion)
1359 version=cgversion)
1360 outgoing = None
1360 outgoing = None
1361 else:
1361 else:
1362 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1362 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1363 dest, branches = hg.parseurl(dest, opts.get('branch'))
1363 dest, branches = hg.parseurl(dest, opts.get('branch'))
1364 other = hg.peer(repo, opts, dest)
1364 other = hg.peer(repo, opts, dest)
1365 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1365 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1366 heads = revs and map(repo.lookup, revs) or revs
1366 heads = revs and map(repo.lookup, revs) or revs
1367 outgoing = discovery.findcommonoutgoing(repo, other,
1367 outgoing = discovery.findcommonoutgoing(repo, other,
1368 onlyheads=heads,
1368 onlyheads=heads,
1369 force=opts.get('force'),
1369 force=opts.get('force'),
1370 portable=True)
1370 portable=True)
1371 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1371 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1372 bundlecaps, version=cgversion)
1372 bundlecaps, version=cgversion)
1373 if not cg:
1373 if not cg:
1374 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1374 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1375 return 1
1375 return 1
1376
1376
1377 if cgversion == '01': #bundle1
1377 if cgversion == '01': #bundle1
1378 if bcompression is None:
1378 if bcompression is None:
1379 bcompression = 'UN'
1379 bcompression = 'UN'
1380 bversion = 'HG10' + bcompression
1380 bversion = 'HG10' + bcompression
1381 bcompression = None
1381 bcompression = None
1382 else:
1382 else:
1383 assert cgversion == '02'
1383 assert cgversion == '02'
1384 bversion = 'HG20'
1384 bversion = 'HG20'
1385
1385
1386
1386
1387 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1387 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1388
1388
1389 @command('cat',
1389 @command('cat',
1390 [('o', 'output', '',
1390 [('o', 'output', '',
1391 _('print output to file with formatted name'), _('FORMAT')),
1391 _('print output to file with formatted name'), _('FORMAT')),
1392 ('r', 'rev', '', _('print the given revision'), _('REV')),
1392 ('r', 'rev', '', _('print the given revision'), _('REV')),
1393 ('', 'decode', None, _('apply any matching decode filter')),
1393 ('', 'decode', None, _('apply any matching decode filter')),
1394 ] + walkopts,
1394 ] + walkopts,
1395 _('[OPTION]... FILE...'),
1395 _('[OPTION]... FILE...'),
1396 inferrepo=True)
1396 inferrepo=True)
1397 def cat(ui, repo, file1, *pats, **opts):
1397 def cat(ui, repo, file1, *pats, **opts):
1398 """output the current or given revision of files
1398 """output the current or given revision of files
1399
1399
1400 Print the specified files as they were at the given revision. If
1400 Print the specified files as they were at the given revision. If
1401 no revision is given, the parent of the working directory is used.
1401 no revision is given, the parent of the working directory is used.
1402
1402
1403 Output may be to a file, in which case the name of the file is
1403 Output may be to a file, in which case the name of the file is
1404 given using a format string. The formatting rules as follows:
1404 given using a format string. The formatting rules as follows:
1405
1405
1406 :``%%``: literal "%" character
1406 :``%%``: literal "%" character
1407 :``%s``: basename of file being printed
1407 :``%s``: basename of file being printed
1408 :``%d``: dirname of file being printed, or '.' if in repository root
1408 :``%d``: dirname of file being printed, or '.' if in repository root
1409 :``%p``: root-relative path name of file being printed
1409 :``%p``: root-relative path name of file being printed
1410 :``%H``: changeset hash (40 hexadecimal digits)
1410 :``%H``: changeset hash (40 hexadecimal digits)
1411 :``%R``: changeset revision number
1411 :``%R``: changeset revision number
1412 :``%h``: short-form changeset hash (12 hexadecimal digits)
1412 :``%h``: short-form changeset hash (12 hexadecimal digits)
1413 :``%r``: zero-padded changeset revision number
1413 :``%r``: zero-padded changeset revision number
1414 :``%b``: basename of the exporting repository
1414 :``%b``: basename of the exporting repository
1415
1415
1416 Returns 0 on success.
1416 Returns 0 on success.
1417 """
1417 """
1418 ctx = scmutil.revsingle(repo, opts.get('rev'))
1418 ctx = scmutil.revsingle(repo, opts.get('rev'))
1419 m = scmutil.match(ctx, (file1,) + pats, opts)
1419 m = scmutil.match(ctx, (file1,) + pats, opts)
1420
1420
1421 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1421 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1422
1422
1423 @command('^clone',
1423 @command('^clone',
1424 [('U', 'noupdate', None, _('the clone will include an empty working '
1424 [('U', 'noupdate', None, _('the clone will include an empty working '
1425 'directory (only a repository)')),
1425 'directory (only a repository)')),
1426 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1426 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1427 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1427 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1428 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1428 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1429 ('', 'pull', None, _('use pull protocol to copy metadata')),
1429 ('', 'pull', None, _('use pull protocol to copy metadata')),
1430 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1430 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1431 ] + remoteopts,
1431 ] + remoteopts,
1432 _('[OPTION]... SOURCE [DEST]'),
1432 _('[OPTION]... SOURCE [DEST]'),
1433 norepo=True)
1433 norepo=True)
1434 def clone(ui, source, dest=None, **opts):
1434 def clone(ui, source, dest=None, **opts):
1435 """make a copy of an existing repository
1435 """make a copy of an existing repository
1436
1436
1437 Create a copy of an existing repository in a new directory.
1437 Create a copy of an existing repository in a new directory.
1438
1438
1439 If no destination directory name is specified, it defaults to the
1439 If no destination directory name is specified, it defaults to the
1440 basename of the source.
1440 basename of the source.
1441
1441
1442 The location of the source is added to the new repository's
1442 The location of the source is added to the new repository's
1443 ``.hg/hgrc`` file, as the default to be used for future pulls.
1443 ``.hg/hgrc`` file, as the default to be used for future pulls.
1444
1444
1445 Only local paths and ``ssh://`` URLs are supported as
1445 Only local paths and ``ssh://`` URLs are supported as
1446 destinations. For ``ssh://`` destinations, no working directory or
1446 destinations. For ``ssh://`` destinations, no working directory or
1447 ``.hg/hgrc`` will be created on the remote side.
1447 ``.hg/hgrc`` will be created on the remote side.
1448
1448
1449 To pull only a subset of changesets, specify one or more revisions
1449 To pull only a subset of changesets, specify one or more revisions
1450 identifiers with -r/--rev or branches with -b/--branch. The
1450 identifiers with -r/--rev or branches with -b/--branch. The
1451 resulting clone will contain only the specified changesets and
1451 resulting clone will contain only the specified changesets and
1452 their ancestors. These options (or 'clone src#rev dest') imply
1452 their ancestors. These options (or 'clone src#rev dest') imply
1453 --pull, even for local source repositories. Note that specifying a
1453 --pull, even for local source repositories. Note that specifying a
1454 tag will include the tagged changeset but not the changeset
1454 tag will include the tagged changeset but not the changeset
1455 containing the tag.
1455 containing the tag.
1456
1456
1457 If the source repository has a bookmark called '@' set, that
1457 If the source repository has a bookmark called '@' set, that
1458 revision will be checked out in the new repository by default.
1458 revision will be checked out in the new repository by default.
1459
1459
1460 To check out a particular version, use -u/--update, or
1460 To check out a particular version, use -u/--update, or
1461 -U/--noupdate to create a clone with no working directory.
1461 -U/--noupdate to create a clone with no working directory.
1462
1462
1463 .. container:: verbose
1463 .. container:: verbose
1464
1464
1465 For efficiency, hardlinks are used for cloning whenever the
1465 For efficiency, hardlinks are used for cloning whenever the
1466 source and destination are on the same filesystem (note this
1466 source and destination are on the same filesystem (note this
1467 applies only to the repository data, not to the working
1467 applies only to the repository data, not to the working
1468 directory). Some filesystems, such as AFS, implement hardlinking
1468 directory). Some filesystems, such as AFS, implement hardlinking
1469 incorrectly, but do not report errors. In these cases, use the
1469 incorrectly, but do not report errors. In these cases, use the
1470 --pull option to avoid hardlinking.
1470 --pull option to avoid hardlinking.
1471
1471
1472 In some cases, you can clone repositories and the working
1472 In some cases, you can clone repositories and the working
1473 directory using full hardlinks with ::
1473 directory using full hardlinks with ::
1474
1474
1475 $ cp -al REPO REPOCLONE
1475 $ cp -al REPO REPOCLONE
1476
1476
1477 This is the fastest way to clone, but it is not always safe. The
1477 This is the fastest way to clone, but it is not always safe. The
1478 operation is not atomic (making sure REPO is not modified during
1478 operation is not atomic (making sure REPO is not modified during
1479 the operation is up to you) and you have to make sure your
1479 the operation is up to you) and you have to make sure your
1480 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1480 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1481 so). Also, this is not compatible with certain extensions that
1481 so). Also, this is not compatible with certain extensions that
1482 place their metadata under the .hg directory, such as mq.
1482 place their metadata under the .hg directory, such as mq.
1483
1483
1484 Mercurial will update the working directory to the first applicable
1484 Mercurial will update the working directory to the first applicable
1485 revision from this list:
1485 revision from this list:
1486
1486
1487 a) null if -U or the source repository has no changesets
1487 a) null if -U or the source repository has no changesets
1488 b) if -u . and the source repository is local, the first parent of
1488 b) if -u . and the source repository is local, the first parent of
1489 the source repository's working directory
1489 the source repository's working directory
1490 c) the changeset specified with -u (if a branch name, this means the
1490 c) the changeset specified with -u (if a branch name, this means the
1491 latest head of that branch)
1491 latest head of that branch)
1492 d) the changeset specified with -r
1492 d) the changeset specified with -r
1493 e) the tipmost head specified with -b
1493 e) the tipmost head specified with -b
1494 f) the tipmost head specified with the url#branch source syntax
1494 f) the tipmost head specified with the url#branch source syntax
1495 g) the revision marked with the '@' bookmark, if present
1495 g) the revision marked with the '@' bookmark, if present
1496 h) the tipmost head of the default branch
1496 h) the tipmost head of the default branch
1497 i) tip
1497 i) tip
1498
1498
1499 Examples:
1499 Examples:
1500
1500
1501 - clone a remote repository to a new directory named hg/::
1501 - clone a remote repository to a new directory named hg/::
1502
1502
1503 hg clone http://selenic.com/hg
1503 hg clone http://selenic.com/hg
1504
1504
1505 - create a lightweight local clone::
1505 - create a lightweight local clone::
1506
1506
1507 hg clone project/ project-feature/
1507 hg clone project/ project-feature/
1508
1508
1509 - clone from an absolute path on an ssh server (note double-slash)::
1509 - clone from an absolute path on an ssh server (note double-slash)::
1510
1510
1511 hg clone ssh://user@server//home/projects/alpha/
1511 hg clone ssh://user@server//home/projects/alpha/
1512
1512
1513 - do a high-speed clone over a LAN while checking out a
1513 - do a high-speed clone over a LAN while checking out a
1514 specified version::
1514 specified version::
1515
1515
1516 hg clone --uncompressed http://server/repo -u 1.5
1516 hg clone --uncompressed http://server/repo -u 1.5
1517
1517
1518 - create a repository without changesets after a particular revision::
1518 - create a repository without changesets after a particular revision::
1519
1519
1520 hg clone -r 04e544 experimental/ good/
1520 hg clone -r 04e544 experimental/ good/
1521
1521
1522 - clone (and track) a particular named branch::
1522 - clone (and track) a particular named branch::
1523
1523
1524 hg clone http://selenic.com/hg#stable
1524 hg clone http://selenic.com/hg#stable
1525
1525
1526 See :hg:`help urls` for details on specifying URLs.
1526 See :hg:`help urls` for details on specifying URLs.
1527
1527
1528 Returns 0 on success.
1528 Returns 0 on success.
1529 """
1529 """
1530 if opts.get('noupdate') and opts.get('updaterev'):
1530 if opts.get('noupdate') and opts.get('updaterev'):
1531 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1531 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1532
1532
1533 r = hg.clone(ui, opts, source, dest,
1533 r = hg.clone(ui, opts, source, dest,
1534 pull=opts.get('pull'),
1534 pull=opts.get('pull'),
1535 stream=opts.get('uncompressed'),
1535 stream=opts.get('uncompressed'),
1536 rev=opts.get('rev'),
1536 rev=opts.get('rev'),
1537 update=opts.get('updaterev') or not opts.get('noupdate'),
1537 update=opts.get('updaterev') or not opts.get('noupdate'),
1538 branch=opts.get('branch'),
1538 branch=opts.get('branch'),
1539 shareopts=opts.get('shareopts'))
1539 shareopts=opts.get('shareopts'))
1540
1540
1541 return r is None
1541 return r is None
1542
1542
1543 @command('^commit|ci',
1543 @command('^commit|ci',
1544 [('A', 'addremove', None,
1544 [('A', 'addremove', None,
1545 _('mark new/missing files as added/removed before committing')),
1545 _('mark new/missing files as added/removed before committing')),
1546 ('', 'close-branch', None,
1546 ('', 'close-branch', None,
1547 _('mark a branch head as closed')),
1547 _('mark a branch head as closed')),
1548 ('', 'amend', None, _('amend the parent of the working directory')),
1548 ('', 'amend', None, _('amend the parent of the working directory')),
1549 ('s', 'secret', None, _('use the secret phase for committing')),
1549 ('s', 'secret', None, _('use the secret phase for committing')),
1550 ('e', 'edit', None, _('invoke editor on commit messages')),
1550 ('e', 'edit', None, _('invoke editor on commit messages')),
1551 ('i', 'interactive', None, _('use interactive mode')),
1551 ('i', 'interactive', None, _('use interactive mode')),
1552 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1552 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1553 _('[OPTION]... [FILE]...'),
1553 _('[OPTION]... [FILE]...'),
1554 inferrepo=True)
1554 inferrepo=True)
1555 def commit(ui, repo, *pats, **opts):
1555 def commit(ui, repo, *pats, **opts):
1556 """commit the specified files or all outstanding changes
1556 """commit the specified files or all outstanding changes
1557
1557
1558 Commit changes to the given files into the repository. Unlike a
1558 Commit changes to the given files into the repository. Unlike a
1559 centralized SCM, this operation is a local operation. See
1559 centralized SCM, this operation is a local operation. See
1560 :hg:`push` for a way to actively distribute your changes.
1560 :hg:`push` for a way to actively distribute your changes.
1561
1561
1562 If a list of files is omitted, all changes reported by :hg:`status`
1562 If a list of files is omitted, all changes reported by :hg:`status`
1563 will be committed.
1563 will be committed.
1564
1564
1565 If you are committing the result of a merge, do not provide any
1565 If you are committing the result of a merge, do not provide any
1566 filenames or -I/-X filters.
1566 filenames or -I/-X filters.
1567
1567
1568 If no commit message is specified, Mercurial starts your
1568 If no commit message is specified, Mercurial starts your
1569 configured editor where you can enter a message. In case your
1569 configured editor where you can enter a message. In case your
1570 commit fails, you will find a backup of your message in
1570 commit fails, you will find a backup of your message in
1571 ``.hg/last-message.txt``.
1571 ``.hg/last-message.txt``.
1572
1572
1573 The --close-branch flag can be used to mark the current branch
1573 The --close-branch flag can be used to mark the current branch
1574 head closed. When all heads of a branch are closed, the branch
1574 head closed. When all heads of a branch are closed, the branch
1575 will be considered closed and no longer listed.
1575 will be considered closed and no longer listed.
1576
1576
1577 The --amend flag can be used to amend the parent of the
1577 The --amend flag can be used to amend the parent of the
1578 working directory with a new commit that contains the changes
1578 working directory with a new commit that contains the changes
1579 in the parent in addition to those currently reported by :hg:`status`,
1579 in the parent in addition to those currently reported by :hg:`status`,
1580 if there are any. The old commit is stored in a backup bundle in
1580 if there are any. The old commit is stored in a backup bundle in
1581 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1581 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1582 on how to restore it).
1582 on how to restore it).
1583
1583
1584 Message, user and date are taken from the amended commit unless
1584 Message, user and date are taken from the amended commit unless
1585 specified. When a message isn't specified on the command line,
1585 specified. When a message isn't specified on the command line,
1586 the editor will open with the message of the amended commit.
1586 the editor will open with the message of the amended commit.
1587
1587
1588 It is not possible to amend public changesets (see :hg:`help phases`)
1588 It is not possible to amend public changesets (see :hg:`help phases`)
1589 or changesets that have children.
1589 or changesets that have children.
1590
1590
1591 See :hg:`help dates` for a list of formats valid for -d/--date.
1591 See :hg:`help dates` for a list of formats valid for -d/--date.
1592
1592
1593 Returns 0 on success, 1 if nothing changed.
1593 Returns 0 on success, 1 if nothing changed.
1594
1594
1595 .. container:: verbose
1595 .. container:: verbose
1596
1596
1597 Examples:
1597 Examples:
1598
1598
1599 - commit all files ending in .py::
1599 - commit all files ending in .py::
1600
1600
1601 hg commit --include "set:**.py"
1601 hg commit --include "set:**.py"
1602
1602
1603 - commit all non-binary files::
1603 - commit all non-binary files::
1604
1604
1605 hg commit --exclude "set:binary()"
1605 hg commit --exclude "set:binary()"
1606
1606
1607 - amend the current commit and set the date to now::
1607 - amend the current commit and set the date to now::
1608
1608
1609 hg commit --amend --date now
1609 hg commit --amend --date now
1610 """
1610 """
1611 wlock = lock = None
1611 wlock = lock = None
1612 try:
1612 try:
1613 wlock = repo.wlock()
1613 wlock = repo.wlock()
1614 lock = repo.lock()
1614 lock = repo.lock()
1615 return _docommit(ui, repo, *pats, **opts)
1615 return _docommit(ui, repo, *pats, **opts)
1616 finally:
1616 finally:
1617 release(lock, wlock)
1617 release(lock, wlock)
1618
1618
1619 def _docommit(ui, repo, *pats, **opts):
1619 def _docommit(ui, repo, *pats, **opts):
1620 if opts.get('interactive'):
1620 if opts.get('interactive'):
1621 opts.pop('interactive')
1621 opts.pop('interactive')
1622 cmdutil.dorecord(ui, repo, commit, None, False,
1622 cmdutil.dorecord(ui, repo, commit, None, False,
1623 cmdutil.recordfilter, *pats, **opts)
1623 cmdutil.recordfilter, *pats, **opts)
1624 return
1624 return
1625
1625
1626 if opts.get('subrepos'):
1626 if opts.get('subrepos'):
1627 if opts.get('amend'):
1627 if opts.get('amend'):
1628 raise error.Abort(_('cannot amend with --subrepos'))
1628 raise error.Abort(_('cannot amend with --subrepos'))
1629 # Let --subrepos on the command line override config setting.
1629 # Let --subrepos on the command line override config setting.
1630 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1630 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1631
1631
1632 cmdutil.checkunfinished(repo, commit=True)
1632 cmdutil.checkunfinished(repo, commit=True)
1633
1633
1634 branch = repo[None].branch()
1634 branch = repo[None].branch()
1635 bheads = repo.branchheads(branch)
1635 bheads = repo.branchheads(branch)
1636
1636
1637 extra = {}
1637 extra = {}
1638 if opts.get('close_branch'):
1638 if opts.get('close_branch'):
1639 extra['close'] = 1
1639 extra['close'] = 1
1640
1640
1641 if not bheads:
1641 if not bheads:
1642 raise error.Abort(_('can only close branch heads'))
1642 raise error.Abort(_('can only close branch heads'))
1643 elif opts.get('amend'):
1643 elif opts.get('amend'):
1644 if repo[None].parents()[0].p1().branch() != branch and \
1644 if repo[None].parents()[0].p1().branch() != branch and \
1645 repo[None].parents()[0].p2().branch() != branch:
1645 repo[None].parents()[0].p2().branch() != branch:
1646 raise error.Abort(_('can only close branch heads'))
1646 raise error.Abort(_('can only close branch heads'))
1647
1647
1648 if opts.get('amend'):
1648 if opts.get('amend'):
1649 if ui.configbool('ui', 'commitsubrepos'):
1649 if ui.configbool('ui', 'commitsubrepos'):
1650 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1650 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1651
1651
1652 old = repo['.']
1652 old = repo['.']
1653 if not old.mutable():
1653 if not old.mutable():
1654 raise error.Abort(_('cannot amend public changesets'))
1654 raise error.Abort(_('cannot amend public changesets'))
1655 if len(repo[None].parents()) > 1:
1655 if len(repo[None].parents()) > 1:
1656 raise error.Abort(_('cannot amend while merging'))
1656 raise error.Abort(_('cannot amend while merging'))
1657 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1657 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1658 if not allowunstable and old.children():
1658 if not allowunstable and old.children():
1659 raise error.Abort(_('cannot amend changeset with children'))
1659 raise error.Abort(_('cannot amend changeset with children'))
1660
1660
1661 newextra = extra.copy()
1661 newextra = extra.copy()
1662 newextra['branch'] = branch
1662 newextra['branch'] = branch
1663 extra = newextra
1663 extra = newextra
1664 # commitfunc is used only for temporary amend commit by cmdutil.amend
1664 # commitfunc is used only for temporary amend commit by cmdutil.amend
1665 def commitfunc(ui, repo, message, match, opts):
1665 def commitfunc(ui, repo, message, match, opts):
1666 return repo.commit(message,
1666 return repo.commit(message,
1667 opts.get('user') or old.user(),
1667 opts.get('user') or old.user(),
1668 opts.get('date') or old.date(),
1668 opts.get('date') or old.date(),
1669 match,
1669 match,
1670 extra=extra)
1670 extra=extra)
1671
1671
1672 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1672 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1673 if node == old.node():
1673 if node == old.node():
1674 ui.status(_("nothing changed\n"))
1674 ui.status(_("nothing changed\n"))
1675 return 1
1675 return 1
1676 else:
1676 else:
1677 def commitfunc(ui, repo, message, match, opts):
1677 def commitfunc(ui, repo, message, match, opts):
1678 backup = ui.backupconfig('phases', 'new-commit')
1678 backup = ui.backupconfig('phases', 'new-commit')
1679 baseui = repo.baseui
1679 baseui = repo.baseui
1680 basebackup = baseui.backupconfig('phases', 'new-commit')
1680 basebackup = baseui.backupconfig('phases', 'new-commit')
1681 try:
1681 try:
1682 if opts.get('secret'):
1682 if opts.get('secret'):
1683 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1683 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1684 # Propagate to subrepos
1684 # Propagate to subrepos
1685 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1685 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1686
1686
1687 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1687 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1688 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1688 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1689 return repo.commit(message, opts.get('user'), opts.get('date'),
1689 return repo.commit(message, opts.get('user'), opts.get('date'),
1690 match,
1690 match,
1691 editor=editor,
1691 editor=editor,
1692 extra=extra)
1692 extra=extra)
1693 finally:
1693 finally:
1694 ui.restoreconfig(backup)
1694 ui.restoreconfig(backup)
1695 repo.baseui.restoreconfig(basebackup)
1695 repo.baseui.restoreconfig(basebackup)
1696
1696
1697
1697
1698 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1698 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1699
1699
1700 if not node:
1700 if not node:
1701 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1701 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1702 if stat[3]:
1702 if stat[3]:
1703 ui.status(_("nothing changed (%d missing files, see "
1703 ui.status(_("nothing changed (%d missing files, see "
1704 "'hg status')\n") % len(stat[3]))
1704 "'hg status')\n") % len(stat[3]))
1705 else:
1705 else:
1706 ui.status(_("nothing changed\n"))
1706 ui.status(_("nothing changed\n"))
1707 return 1
1707 return 1
1708
1708
1709 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1709 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1710
1710
1711 @command('config|showconfig|debugconfig',
1711 @command('config|showconfig|debugconfig',
1712 [('u', 'untrusted', None, _('show untrusted configuration options')),
1712 [('u', 'untrusted', None, _('show untrusted configuration options')),
1713 ('e', 'edit', None, _('edit user config')),
1713 ('e', 'edit', None, _('edit user config')),
1714 ('l', 'local', None, _('edit repository config')),
1714 ('l', 'local', None, _('edit repository config')),
1715 ('g', 'global', None, _('edit global config'))],
1715 ('g', 'global', None, _('edit global config'))],
1716 _('[-u] [NAME]...'),
1716 _('[-u] [NAME]...'),
1717 optionalrepo=True)
1717 optionalrepo=True)
1718 def config(ui, repo, *values, **opts):
1718 def config(ui, repo, *values, **opts):
1719 """show combined config settings from all hgrc files
1719 """show combined config settings from all hgrc files
1720
1720
1721 With no arguments, print names and values of all config items.
1721 With no arguments, print names and values of all config items.
1722
1722
1723 With one argument of the form section.name, print just the value
1723 With one argument of the form section.name, print just the value
1724 of that config item.
1724 of that config item.
1725
1725
1726 With multiple arguments, print names and values of all config
1726 With multiple arguments, print names and values of all config
1727 items with matching section names.
1727 items with matching section names.
1728
1728
1729 With --edit, start an editor on the user-level config file. With
1729 With --edit, start an editor on the user-level config file. With
1730 --global, edit the system-wide config file. With --local, edit the
1730 --global, edit the system-wide config file. With --local, edit the
1731 repository-level config file.
1731 repository-level config file.
1732
1732
1733 With --debug, the source (filename and line number) is printed
1733 With --debug, the source (filename and line number) is printed
1734 for each config item.
1734 for each config item.
1735
1735
1736 See :hg:`help config` for more information about config files.
1736 See :hg:`help config` for more information about config files.
1737
1737
1738 Returns 0 on success, 1 if NAME does not exist.
1738 Returns 0 on success, 1 if NAME does not exist.
1739
1739
1740 """
1740 """
1741
1741
1742 if opts.get('edit') or opts.get('local') or opts.get('global'):
1742 if opts.get('edit') or opts.get('local') or opts.get('global'):
1743 if opts.get('local') and opts.get('global'):
1743 if opts.get('local') and opts.get('global'):
1744 raise error.Abort(_("can't use --local and --global together"))
1744 raise error.Abort(_("can't use --local and --global together"))
1745
1745
1746 if opts.get('local'):
1746 if opts.get('local'):
1747 if not repo:
1747 if not repo:
1748 raise error.Abort(_("can't use --local outside a repository"))
1748 raise error.Abort(_("can't use --local outside a repository"))
1749 paths = [repo.join('hgrc')]
1749 paths = [repo.join('hgrc')]
1750 elif opts.get('global'):
1750 elif opts.get('global'):
1751 paths = scmutil.systemrcpath()
1751 paths = scmutil.systemrcpath()
1752 else:
1752 else:
1753 paths = scmutil.userrcpath()
1753 paths = scmutil.userrcpath()
1754
1754
1755 for f in paths:
1755 for f in paths:
1756 if os.path.exists(f):
1756 if os.path.exists(f):
1757 break
1757 break
1758 else:
1758 else:
1759 if opts.get('global'):
1759 if opts.get('global'):
1760 samplehgrc = uimod.samplehgrcs['global']
1760 samplehgrc = uimod.samplehgrcs['global']
1761 elif opts.get('local'):
1761 elif opts.get('local'):
1762 samplehgrc = uimod.samplehgrcs['local']
1762 samplehgrc = uimod.samplehgrcs['local']
1763 else:
1763 else:
1764 samplehgrc = uimod.samplehgrcs['user']
1764 samplehgrc = uimod.samplehgrcs['user']
1765
1765
1766 f = paths[0]
1766 f = paths[0]
1767 fp = open(f, "w")
1767 fp = open(f, "w")
1768 fp.write(samplehgrc)
1768 fp.write(samplehgrc)
1769 fp.close()
1769 fp.close()
1770
1770
1771 editor = ui.geteditor()
1771 editor = ui.geteditor()
1772 ui.system("%s \"%s\"" % (editor, f),
1772 ui.system("%s \"%s\"" % (editor, f),
1773 onerr=error.Abort, errprefix=_("edit failed"))
1773 onerr=error.Abort, errprefix=_("edit failed"))
1774 return
1774 return
1775
1775
1776 for f in scmutil.rcpath():
1776 for f in scmutil.rcpath():
1777 ui.debug('read config from: %s\n' % f)
1777 ui.debug('read config from: %s\n' % f)
1778 untrusted = bool(opts.get('untrusted'))
1778 untrusted = bool(opts.get('untrusted'))
1779 if values:
1779 if values:
1780 sections = [v for v in values if '.' not in v]
1780 sections = [v for v in values if '.' not in v]
1781 items = [v for v in values if '.' in v]
1781 items = [v for v in values if '.' in v]
1782 if len(items) > 1 or items and sections:
1782 if len(items) > 1 or items and sections:
1783 raise error.Abort(_('only one config item permitted'))
1783 raise error.Abort(_('only one config item permitted'))
1784 matched = False
1784 matched = False
1785 for section, name, value in ui.walkconfig(untrusted=untrusted):
1785 for section, name, value in ui.walkconfig(untrusted=untrusted):
1786 value = str(value).replace('\n', '\\n')
1786 value = str(value).replace('\n', '\\n')
1787 sectname = section + '.' + name
1787 sectname = section + '.' + name
1788 if values:
1788 if values:
1789 for v in values:
1789 for v in values:
1790 if v == section:
1790 if v == section:
1791 ui.debug('%s: ' %
1791 ui.debug('%s: ' %
1792 ui.configsource(section, name, untrusted))
1792 ui.configsource(section, name, untrusted))
1793 ui.write('%s=%s\n' % (sectname, value))
1793 ui.write('%s=%s\n' % (sectname, value))
1794 matched = True
1794 matched = True
1795 elif v == sectname:
1795 elif v == sectname:
1796 ui.debug('%s: ' %
1796 ui.debug('%s: ' %
1797 ui.configsource(section, name, untrusted))
1797 ui.configsource(section, name, untrusted))
1798 ui.write(value, '\n')
1798 ui.write(value, '\n')
1799 matched = True
1799 matched = True
1800 else:
1800 else:
1801 ui.debug('%s: ' %
1801 ui.debug('%s: ' %
1802 ui.configsource(section, name, untrusted))
1802 ui.configsource(section, name, untrusted))
1803 ui.write('%s=%s\n' % (sectname, value))
1803 ui.write('%s=%s\n' % (sectname, value))
1804 matched = True
1804 matched = True
1805 if matched:
1805 if matched:
1806 return 0
1806 return 0
1807 return 1
1807 return 1
1808
1808
1809 @command('copy|cp',
1809 @command('copy|cp',
1810 [('A', 'after', None, _('record a copy that has already occurred')),
1810 [('A', 'after', None, _('record a copy that has already occurred')),
1811 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1811 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1812 ] + walkopts + dryrunopts,
1812 ] + walkopts + dryrunopts,
1813 _('[OPTION]... [SOURCE]... DEST'))
1813 _('[OPTION]... [SOURCE]... DEST'))
1814 def copy(ui, repo, *pats, **opts):
1814 def copy(ui, repo, *pats, **opts):
1815 """mark files as copied for the next commit
1815 """mark files as copied for the next commit
1816
1816
1817 Mark dest as having copies of source files. If dest is a
1817 Mark dest as having copies of source files. If dest is a
1818 directory, copies are put in that directory. If dest is a file,
1818 directory, copies are put in that directory. If dest is a file,
1819 the source must be a single file.
1819 the source must be a single file.
1820
1820
1821 By default, this command copies the contents of files as they
1821 By default, this command copies the contents of files as they
1822 exist in the working directory. If invoked with -A/--after, the
1822 exist in the working directory. If invoked with -A/--after, the
1823 operation is recorded, but no copying is performed.
1823 operation is recorded, but no copying is performed.
1824
1824
1825 This command takes effect with the next commit. To undo a copy
1825 This command takes effect with the next commit. To undo a copy
1826 before that, see :hg:`revert`.
1826 before that, see :hg:`revert`.
1827
1827
1828 Returns 0 on success, 1 if errors are encountered.
1828 Returns 0 on success, 1 if errors are encountered.
1829 """
1829 """
1830 wlock = repo.wlock(False)
1830 wlock = repo.wlock(False)
1831 try:
1831 try:
1832 return cmdutil.copy(ui, repo, pats, opts)
1832 return cmdutil.copy(ui, repo, pats, opts)
1833 finally:
1833 finally:
1834 wlock.release()
1834 wlock.release()
1835
1835
1836 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1836 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1837 def debugancestor(ui, repo, *args):
1837 def debugancestor(ui, repo, *args):
1838 """find the ancestor revision of two revisions in a given index"""
1838 """find the ancestor revision of two revisions in a given index"""
1839 if len(args) == 3:
1839 if len(args) == 3:
1840 index, rev1, rev2 = args
1840 index, rev1, rev2 = args
1841 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1841 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1842 lookup = r.lookup
1842 lookup = r.lookup
1843 elif len(args) == 2:
1843 elif len(args) == 2:
1844 if not repo:
1844 if not repo:
1845 raise error.Abort(_("there is no Mercurial repository here "
1845 raise error.Abort(_("there is no Mercurial repository here "
1846 "(.hg not found)"))
1846 "(.hg not found)"))
1847 rev1, rev2 = args
1847 rev1, rev2 = args
1848 r = repo.changelog
1848 r = repo.changelog
1849 lookup = repo.lookup
1849 lookup = repo.lookup
1850 else:
1850 else:
1851 raise error.Abort(_('either two or three arguments required'))
1851 raise error.Abort(_('either two or three arguments required'))
1852 a = r.ancestor(lookup(rev1), lookup(rev2))
1852 a = r.ancestor(lookup(rev1), lookup(rev2))
1853 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1853 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1854
1854
1855 @command('debugbuilddag',
1855 @command('debugbuilddag',
1856 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1856 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1857 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1857 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1858 ('n', 'new-file', None, _('add new file at each rev'))],
1858 ('n', 'new-file', None, _('add new file at each rev'))],
1859 _('[OPTION]... [TEXT]'))
1859 _('[OPTION]... [TEXT]'))
1860 def debugbuilddag(ui, repo, text=None,
1860 def debugbuilddag(ui, repo, text=None,
1861 mergeable_file=False,
1861 mergeable_file=False,
1862 overwritten_file=False,
1862 overwritten_file=False,
1863 new_file=False):
1863 new_file=False):
1864 """builds a repo with a given DAG from scratch in the current empty repo
1864 """builds a repo with a given DAG from scratch in the current empty repo
1865
1865
1866 The description of the DAG is read from stdin if not given on the
1866 The description of the DAG is read from stdin if not given on the
1867 command line.
1867 command line.
1868
1868
1869 Elements:
1869 Elements:
1870
1870
1871 - "+n" is a linear run of n nodes based on the current default parent
1871 - "+n" is a linear run of n nodes based on the current default parent
1872 - "." is a single node based on the current default parent
1872 - "." is a single node based on the current default parent
1873 - "$" resets the default parent to null (implied at the start);
1873 - "$" resets the default parent to null (implied at the start);
1874 otherwise the default parent is always the last node created
1874 otherwise the default parent is always the last node created
1875 - "<p" sets the default parent to the backref p
1875 - "<p" sets the default parent to the backref p
1876 - "*p" is a fork at parent p, which is a backref
1876 - "*p" is a fork at parent p, which is a backref
1877 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1877 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1878 - "/p2" is a merge of the preceding node and p2
1878 - "/p2" is a merge of the preceding node and p2
1879 - ":tag" defines a local tag for the preceding node
1879 - ":tag" defines a local tag for the preceding node
1880 - "@branch" sets the named branch for subsequent nodes
1880 - "@branch" sets the named branch for subsequent nodes
1881 - "#...\\n" is a comment up to the end of the line
1881 - "#...\\n" is a comment up to the end of the line
1882
1882
1883 Whitespace between the above elements is ignored.
1883 Whitespace between the above elements is ignored.
1884
1884
1885 A backref is either
1885 A backref is either
1886
1886
1887 - a number n, which references the node curr-n, where curr is the current
1887 - a number n, which references the node curr-n, where curr is the current
1888 node, or
1888 node, or
1889 - the name of a local tag you placed earlier using ":tag", or
1889 - the name of a local tag you placed earlier using ":tag", or
1890 - empty to denote the default parent.
1890 - empty to denote the default parent.
1891
1891
1892 All string valued-elements are either strictly alphanumeric, or must
1892 All string valued-elements are either strictly alphanumeric, or must
1893 be enclosed in double quotes ("..."), with "\\" as escape character.
1893 be enclosed in double quotes ("..."), with "\\" as escape character.
1894 """
1894 """
1895
1895
1896 if text is None:
1896 if text is None:
1897 ui.status(_("reading DAG from stdin\n"))
1897 ui.status(_("reading DAG from stdin\n"))
1898 text = ui.fin.read()
1898 text = ui.fin.read()
1899
1899
1900 cl = repo.changelog
1900 cl = repo.changelog
1901 if len(cl) > 0:
1901 if len(cl) > 0:
1902 raise error.Abort(_('repository is not empty'))
1902 raise error.Abort(_('repository is not empty'))
1903
1903
1904 # determine number of revs in DAG
1904 # determine number of revs in DAG
1905 total = 0
1905 total = 0
1906 for type, data in dagparser.parsedag(text):
1906 for type, data in dagparser.parsedag(text):
1907 if type == 'n':
1907 if type == 'n':
1908 total += 1
1908 total += 1
1909
1909
1910 if mergeable_file:
1910 if mergeable_file:
1911 linesperrev = 2
1911 linesperrev = 2
1912 # make a file with k lines per rev
1912 # make a file with k lines per rev
1913 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1913 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1914 initialmergedlines.append("")
1914 initialmergedlines.append("")
1915
1915
1916 tags = []
1916 tags = []
1917
1917
1918 lock = tr = None
1918 lock = tr = None
1919 try:
1919 try:
1920 lock = repo.lock()
1920 lock = repo.lock()
1921 tr = repo.transaction("builddag")
1921 tr = repo.transaction("builddag")
1922
1922
1923 at = -1
1923 at = -1
1924 atbranch = 'default'
1924 atbranch = 'default'
1925 nodeids = []
1925 nodeids = []
1926 id = 0
1926 id = 0
1927 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1927 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1928 for type, data in dagparser.parsedag(text):
1928 for type, data in dagparser.parsedag(text):
1929 if type == 'n':
1929 if type == 'n':
1930 ui.note(('node %s\n' % str(data)))
1930 ui.note(('node %s\n' % str(data)))
1931 id, ps = data
1931 id, ps = data
1932
1932
1933 files = []
1933 files = []
1934 fctxs = {}
1934 fctxs = {}
1935
1935
1936 p2 = None
1936 p2 = None
1937 if mergeable_file:
1937 if mergeable_file:
1938 fn = "mf"
1938 fn = "mf"
1939 p1 = repo[ps[0]]
1939 p1 = repo[ps[0]]
1940 if len(ps) > 1:
1940 if len(ps) > 1:
1941 p2 = repo[ps[1]]
1941 p2 = repo[ps[1]]
1942 pa = p1.ancestor(p2)
1942 pa = p1.ancestor(p2)
1943 base, local, other = [x[fn].data() for x in (pa, p1,
1943 base, local, other = [x[fn].data() for x in (pa, p1,
1944 p2)]
1944 p2)]
1945 m3 = simplemerge.Merge3Text(base, local, other)
1945 m3 = simplemerge.Merge3Text(base, local, other)
1946 ml = [l.strip() for l in m3.merge_lines()]
1946 ml = [l.strip() for l in m3.merge_lines()]
1947 ml.append("")
1947 ml.append("")
1948 elif at > 0:
1948 elif at > 0:
1949 ml = p1[fn].data().split("\n")
1949 ml = p1[fn].data().split("\n")
1950 else:
1950 else:
1951 ml = initialmergedlines
1951 ml = initialmergedlines
1952 ml[id * linesperrev] += " r%i" % id
1952 ml[id * linesperrev] += " r%i" % id
1953 mergedtext = "\n".join(ml)
1953 mergedtext = "\n".join(ml)
1954 files.append(fn)
1954 files.append(fn)
1955 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1955 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1956
1956
1957 if overwritten_file:
1957 if overwritten_file:
1958 fn = "of"
1958 fn = "of"
1959 files.append(fn)
1959 files.append(fn)
1960 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1960 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1961
1961
1962 if new_file:
1962 if new_file:
1963 fn = "nf%i" % id
1963 fn = "nf%i" % id
1964 files.append(fn)
1964 files.append(fn)
1965 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1965 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1966 if len(ps) > 1:
1966 if len(ps) > 1:
1967 if not p2:
1967 if not p2:
1968 p2 = repo[ps[1]]
1968 p2 = repo[ps[1]]
1969 for fn in p2:
1969 for fn in p2:
1970 if fn.startswith("nf"):
1970 if fn.startswith("nf"):
1971 files.append(fn)
1971 files.append(fn)
1972 fctxs[fn] = p2[fn]
1972 fctxs[fn] = p2[fn]
1973
1973
1974 def fctxfn(repo, cx, path):
1974 def fctxfn(repo, cx, path):
1975 return fctxs.get(path)
1975 return fctxs.get(path)
1976
1976
1977 if len(ps) == 0 or ps[0] < 0:
1977 if len(ps) == 0 or ps[0] < 0:
1978 pars = [None, None]
1978 pars = [None, None]
1979 elif len(ps) == 1:
1979 elif len(ps) == 1:
1980 pars = [nodeids[ps[0]], None]
1980 pars = [nodeids[ps[0]], None]
1981 else:
1981 else:
1982 pars = [nodeids[p] for p in ps]
1982 pars = [nodeids[p] for p in ps]
1983 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1983 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1984 date=(id, 0),
1984 date=(id, 0),
1985 user="debugbuilddag",
1985 user="debugbuilddag",
1986 extra={'branch': atbranch})
1986 extra={'branch': atbranch})
1987 nodeid = repo.commitctx(cx)
1987 nodeid = repo.commitctx(cx)
1988 nodeids.append(nodeid)
1988 nodeids.append(nodeid)
1989 at = id
1989 at = id
1990 elif type == 'l':
1990 elif type == 'l':
1991 id, name = data
1991 id, name = data
1992 ui.note(('tag %s\n' % name))
1992 ui.note(('tag %s\n' % name))
1993 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1993 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1994 elif type == 'a':
1994 elif type == 'a':
1995 ui.note(('branch %s\n' % data))
1995 ui.note(('branch %s\n' % data))
1996 atbranch = data
1996 atbranch = data
1997 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1997 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1998 tr.close()
1998 tr.close()
1999
1999
2000 if tags:
2000 if tags:
2001 repo.vfs.write("localtags", "".join(tags))
2001 repo.vfs.write("localtags", "".join(tags))
2002 finally:
2002 finally:
2003 ui.progress(_('building'), None)
2003 ui.progress(_('building'), None)
2004 release(tr, lock)
2004 release(tr, lock)
2005
2005
2006 @command('debugbundle',
2006 @command('debugbundle',
2007 [('a', 'all', None, _('show all details'))],
2007 [('a', 'all', None, _('show all details'))],
2008 _('FILE'),
2008 _('FILE'),
2009 norepo=True)
2009 norepo=True)
2010 def debugbundle(ui, bundlepath, all=None, **opts):
2010 def debugbundle(ui, bundlepath, all=None, **opts):
2011 """lists the contents of a bundle"""
2011 """lists the contents of a bundle"""
2012 f = hg.openpath(ui, bundlepath)
2012 f = hg.openpath(ui, bundlepath)
2013 try:
2013 try:
2014 gen = exchange.readbundle(ui, f, bundlepath)
2014 gen = exchange.readbundle(ui, f, bundlepath)
2015 if isinstance(gen, bundle2.unbundle20):
2015 if isinstance(gen, bundle2.unbundle20):
2016 return _debugbundle2(ui, gen, all=all, **opts)
2016 return _debugbundle2(ui, gen, all=all, **opts)
2017 if all:
2017 if all:
2018 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
2018 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
2019
2019
2020 def showchunks(named):
2020 def showchunks(named):
2021 ui.write("\n%s\n" % named)
2021 ui.write("\n%s\n" % named)
2022 chain = None
2022 chain = None
2023 while True:
2023 while True:
2024 chunkdata = gen.deltachunk(chain)
2024 chunkdata = gen.deltachunk(chain)
2025 if not chunkdata:
2025 if not chunkdata:
2026 break
2026 break
2027 node = chunkdata['node']
2027 node = chunkdata['node']
2028 p1 = chunkdata['p1']
2028 p1 = chunkdata['p1']
2029 p2 = chunkdata['p2']
2029 p2 = chunkdata['p2']
2030 cs = chunkdata['cs']
2030 cs = chunkdata['cs']
2031 deltabase = chunkdata['deltabase']
2031 deltabase = chunkdata['deltabase']
2032 delta = chunkdata['delta']
2032 delta = chunkdata['delta']
2033 ui.write("%s %s %s %s %s %s\n" %
2033 ui.write("%s %s %s %s %s %s\n" %
2034 (hex(node), hex(p1), hex(p2),
2034 (hex(node), hex(p1), hex(p2),
2035 hex(cs), hex(deltabase), len(delta)))
2035 hex(cs), hex(deltabase), len(delta)))
2036 chain = node
2036 chain = node
2037
2037
2038 chunkdata = gen.changelogheader()
2038 chunkdata = gen.changelogheader()
2039 showchunks("changelog")
2039 showchunks("changelog")
2040 chunkdata = gen.manifestheader()
2040 chunkdata = gen.manifestheader()
2041 showchunks("manifest")
2041 showchunks("manifest")
2042 while True:
2042 while True:
2043 chunkdata = gen.filelogheader()
2043 chunkdata = gen.filelogheader()
2044 if not chunkdata:
2044 if not chunkdata:
2045 break
2045 break
2046 fname = chunkdata['filename']
2046 fname = chunkdata['filename']
2047 showchunks(fname)
2047 showchunks(fname)
2048 else:
2048 else:
2049 if isinstance(gen, bundle2.unbundle20):
2049 if isinstance(gen, bundle2.unbundle20):
2050 raise error.Abort(_('use debugbundle2 for this file'))
2050 raise error.Abort(_('use debugbundle2 for this file'))
2051 chunkdata = gen.changelogheader()
2051 chunkdata = gen.changelogheader()
2052 chain = None
2052 chain = None
2053 while True:
2053 while True:
2054 chunkdata = gen.deltachunk(chain)
2054 chunkdata = gen.deltachunk(chain)
2055 if not chunkdata:
2055 if not chunkdata:
2056 break
2056 break
2057 node = chunkdata['node']
2057 node = chunkdata['node']
2058 ui.write("%s\n" % hex(node))
2058 ui.write("%s\n" % hex(node))
2059 chain = node
2059 chain = node
2060 finally:
2060 finally:
2061 f.close()
2061 f.close()
2062
2062
2063 def _debugbundle2(ui, gen, **opts):
2063 def _debugbundle2(ui, gen, **opts):
2064 """lists the contents of a bundle2"""
2064 """lists the contents of a bundle2"""
2065 if not isinstance(gen, bundle2.unbundle20):
2065 if not isinstance(gen, bundle2.unbundle20):
2066 raise error.Abort(_('not a bundle2 file'))
2066 raise error.Abort(_('not a bundle2 file'))
2067 ui.write(('Stream params: %s\n' % repr(gen.params)))
2067 ui.write(('Stream params: %s\n' % repr(gen.params)))
2068 for part in gen.iterparts():
2068 for part in gen.iterparts():
2069 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
2069 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
2070 if part.type == 'changegroup':
2070 if part.type == 'changegroup':
2071 version = part.params.get('version', '01')
2071 version = part.params.get('version', '01')
2072 cg = changegroup.packermap[version][1](part, 'UN')
2072 cg = changegroup.packermap[version][1](part, 'UN')
2073 chunkdata = cg.changelogheader()
2073 chunkdata = cg.changelogheader()
2074 chain = None
2074 chain = None
2075 while True:
2075 while True:
2076 chunkdata = cg.deltachunk(chain)
2076 chunkdata = cg.deltachunk(chain)
2077 if not chunkdata:
2077 if not chunkdata:
2078 break
2078 break
2079 node = chunkdata['node']
2079 node = chunkdata['node']
2080 ui.write(" %s\n" % hex(node))
2080 ui.write(" %s\n" % hex(node))
2081 chain = node
2081 chain = node
2082
2082
2083 @command('debugcreatestreamclonebundle', [], 'FILE')
2083 @command('debugcreatestreamclonebundle', [], 'FILE')
2084 def debugcreatestreamclonebundle(ui, repo, fname):
2084 def debugcreatestreamclonebundle(ui, repo, fname):
2085 """create a stream clone bundle file
2085 """create a stream clone bundle file
2086
2086
2087 Stream bundles are special bundles that are essentially archives of
2087 Stream bundles are special bundles that are essentially archives of
2088 revlog files. They are commonly used for cloning very quickly.
2088 revlog files. They are commonly used for cloning very quickly.
2089 """
2089 """
2090 requirements, gen = streamclone.generatebundlev1(repo)
2090 requirements, gen = streamclone.generatebundlev1(repo)
2091 changegroup.writechunks(ui, gen, fname)
2091 changegroup.writechunks(ui, gen, fname)
2092
2092
2093 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
2093 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
2094
2094
2095 @command('debugapplystreamclonebundle', [], 'FILE')
2095 @command('debugapplystreamclonebundle', [], 'FILE')
2096 def debugapplystreamclonebundle(ui, repo, fname):
2096 def debugapplystreamclonebundle(ui, repo, fname):
2097 """apply a stream clone bundle file"""
2097 """apply a stream clone bundle file"""
2098 f = hg.openpath(ui, fname)
2098 f = hg.openpath(ui, fname)
2099 gen = exchange.readbundle(ui, f, fname)
2099 gen = exchange.readbundle(ui, f, fname)
2100 gen.apply(repo)
2100 gen.apply(repo)
2101
2101
2102 @command('debugcheckstate', [], '')
2102 @command('debugcheckstate', [], '')
2103 def debugcheckstate(ui, repo):
2103 def debugcheckstate(ui, repo):
2104 """validate the correctness of the current dirstate"""
2104 """validate the correctness of the current dirstate"""
2105 parent1, parent2 = repo.dirstate.parents()
2105 parent1, parent2 = repo.dirstate.parents()
2106 m1 = repo[parent1].manifest()
2106 m1 = repo[parent1].manifest()
2107 m2 = repo[parent2].manifest()
2107 m2 = repo[parent2].manifest()
2108 errors = 0
2108 errors = 0
2109 for f in repo.dirstate:
2109 for f in repo.dirstate:
2110 state = repo.dirstate[f]
2110 state = repo.dirstate[f]
2111 if state in "nr" and f not in m1:
2111 if state in "nr" and f not in m1:
2112 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
2112 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
2113 errors += 1
2113 errors += 1
2114 if state in "a" and f in m1:
2114 if state in "a" and f in m1:
2115 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
2115 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
2116 errors += 1
2116 errors += 1
2117 if state in "m" and f not in m1 and f not in m2:
2117 if state in "m" and f not in m1 and f not in m2:
2118 ui.warn(_("%s in state %s, but not in either manifest\n") %
2118 ui.warn(_("%s in state %s, but not in either manifest\n") %
2119 (f, state))
2119 (f, state))
2120 errors += 1
2120 errors += 1
2121 for f in m1:
2121 for f in m1:
2122 state = repo.dirstate[f]
2122 state = repo.dirstate[f]
2123 if state not in "nrm":
2123 if state not in "nrm":
2124 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
2124 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
2125 errors += 1
2125 errors += 1
2126 if errors:
2126 if errors:
2127 error = _(".hg/dirstate inconsistent with current parent's manifest")
2127 error = _(".hg/dirstate inconsistent with current parent's manifest")
2128 raise error.Abort(error)
2128 raise error.Abort(error)
2129
2129
2130 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
2130 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
2131 def debugcommands(ui, cmd='', *args):
2131 def debugcommands(ui, cmd='', *args):
2132 """list all available commands and options"""
2132 """list all available commands and options"""
2133 for cmd, vals in sorted(table.iteritems()):
2133 for cmd, vals in sorted(table.iteritems()):
2134 cmd = cmd.split('|')[0].strip('^')
2134 cmd = cmd.split('|')[0].strip('^')
2135 opts = ', '.join([i[1] for i in vals[1]])
2135 opts = ', '.join([i[1] for i in vals[1]])
2136 ui.write('%s: %s\n' % (cmd, opts))
2136 ui.write('%s: %s\n' % (cmd, opts))
2137
2137
2138 @command('debugcomplete',
2138 @command('debugcomplete',
2139 [('o', 'options', None, _('show the command options'))],
2139 [('o', 'options', None, _('show the command options'))],
2140 _('[-o] CMD'),
2140 _('[-o] CMD'),
2141 norepo=True)
2141 norepo=True)
2142 def debugcomplete(ui, cmd='', **opts):
2142 def debugcomplete(ui, cmd='', **opts):
2143 """returns the completion list associated with the given command"""
2143 """returns the completion list associated with the given command"""
2144
2144
2145 if opts.get('options'):
2145 if opts.get('options'):
2146 options = []
2146 options = []
2147 otables = [globalopts]
2147 otables = [globalopts]
2148 if cmd:
2148 if cmd:
2149 aliases, entry = cmdutil.findcmd(cmd, table, False)
2149 aliases, entry = cmdutil.findcmd(cmd, table, False)
2150 otables.append(entry[1])
2150 otables.append(entry[1])
2151 for t in otables:
2151 for t in otables:
2152 for o in t:
2152 for o in t:
2153 if "(DEPRECATED)" in o[3]:
2153 if "(DEPRECATED)" in o[3]:
2154 continue
2154 continue
2155 if o[0]:
2155 if o[0]:
2156 options.append('-%s' % o[0])
2156 options.append('-%s' % o[0])
2157 options.append('--%s' % o[1])
2157 options.append('--%s' % o[1])
2158 ui.write("%s\n" % "\n".join(options))
2158 ui.write("%s\n" % "\n".join(options))
2159 return
2159 return
2160
2160
2161 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2161 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2162 if ui.verbose:
2162 if ui.verbose:
2163 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2163 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2164 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2164 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2165
2165
2166 @command('debugdag',
2166 @command('debugdag',
2167 [('t', 'tags', None, _('use tags as labels')),
2167 [('t', 'tags', None, _('use tags as labels')),
2168 ('b', 'branches', None, _('annotate with branch names')),
2168 ('b', 'branches', None, _('annotate with branch names')),
2169 ('', 'dots', None, _('use dots for runs')),
2169 ('', 'dots', None, _('use dots for runs')),
2170 ('s', 'spaces', None, _('separate elements by spaces'))],
2170 ('s', 'spaces', None, _('separate elements by spaces'))],
2171 _('[OPTION]... [FILE [REV]...]'),
2171 _('[OPTION]... [FILE [REV]...]'),
2172 optionalrepo=True)
2172 optionalrepo=True)
2173 def debugdag(ui, repo, file_=None, *revs, **opts):
2173 def debugdag(ui, repo, file_=None, *revs, **opts):
2174 """format the changelog or an index DAG as a concise textual description
2174 """format the changelog or an index DAG as a concise textual description
2175
2175
2176 If you pass a revlog index, the revlog's DAG is emitted. If you list
2176 If you pass a revlog index, the revlog's DAG is emitted. If you list
2177 revision numbers, they get labeled in the output as rN.
2177 revision numbers, they get labeled in the output as rN.
2178
2178
2179 Otherwise, the changelog DAG of the current repo is emitted.
2179 Otherwise, the changelog DAG of the current repo is emitted.
2180 """
2180 """
2181 spaces = opts.get('spaces')
2181 spaces = opts.get('spaces')
2182 dots = opts.get('dots')
2182 dots = opts.get('dots')
2183 if file_:
2183 if file_:
2184 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2184 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2185 revs = set((int(r) for r in revs))
2185 revs = set((int(r) for r in revs))
2186 def events():
2186 def events():
2187 for r in rlog:
2187 for r in rlog:
2188 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2188 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2189 if p != -1))
2189 if p != -1))
2190 if r in revs:
2190 if r in revs:
2191 yield 'l', (r, "r%i" % r)
2191 yield 'l', (r, "r%i" % r)
2192 elif repo:
2192 elif repo:
2193 cl = repo.changelog
2193 cl = repo.changelog
2194 tags = opts.get('tags')
2194 tags = opts.get('tags')
2195 branches = opts.get('branches')
2195 branches = opts.get('branches')
2196 if tags:
2196 if tags:
2197 labels = {}
2197 labels = {}
2198 for l, n in repo.tags().items():
2198 for l, n in repo.tags().items():
2199 labels.setdefault(cl.rev(n), []).append(l)
2199 labels.setdefault(cl.rev(n), []).append(l)
2200 def events():
2200 def events():
2201 b = "default"
2201 b = "default"
2202 for r in cl:
2202 for r in cl:
2203 if branches:
2203 if branches:
2204 newb = cl.read(cl.node(r))[5]['branch']
2204 newb = cl.read(cl.node(r))[5]['branch']
2205 if newb != b:
2205 if newb != b:
2206 yield 'a', newb
2206 yield 'a', newb
2207 b = newb
2207 b = newb
2208 yield 'n', (r, list(p for p in cl.parentrevs(r)
2208 yield 'n', (r, list(p for p in cl.parentrevs(r)
2209 if p != -1))
2209 if p != -1))
2210 if tags:
2210 if tags:
2211 ls = labels.get(r)
2211 ls = labels.get(r)
2212 if ls:
2212 if ls:
2213 for l in ls:
2213 for l in ls:
2214 yield 'l', (r, l)
2214 yield 'l', (r, l)
2215 else:
2215 else:
2216 raise error.Abort(_('need repo for changelog dag'))
2216 raise error.Abort(_('need repo for changelog dag'))
2217
2217
2218 for line in dagparser.dagtextlines(events(),
2218 for line in dagparser.dagtextlines(events(),
2219 addspaces=spaces,
2219 addspaces=spaces,
2220 wraplabels=True,
2220 wraplabels=True,
2221 wrapannotations=True,
2221 wrapannotations=True,
2222 wrapnonlinear=dots,
2222 wrapnonlinear=dots,
2223 usedots=dots,
2223 usedots=dots,
2224 maxlinewidth=70):
2224 maxlinewidth=70):
2225 ui.write(line)
2225 ui.write(line)
2226 ui.write("\n")
2226 ui.write("\n")
2227
2227
2228 @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV'))
2228 @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV'))
2229 def debugdata(ui, repo, file_, rev=None, **opts):
2229 def debugdata(ui, repo, file_, rev=None, **opts):
2230 """dump the contents of a data file revision"""
2230 """dump the contents of a data file revision"""
2231 if opts.get('changelog') or opts.get('manifest'):
2231 if opts.get('changelog') or opts.get('manifest'):
2232 file_, rev = None, file_
2232 file_, rev = None, file_
2233 elif rev is None:
2233 elif rev is None:
2234 raise error.CommandError('debugdata', _('invalid arguments'))
2234 raise error.CommandError('debugdata', _('invalid arguments'))
2235 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2235 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2236 try:
2236 try:
2237 ui.write(r.revision(r.lookup(rev)))
2237 ui.write(r.revision(r.lookup(rev)))
2238 except KeyError:
2238 except KeyError:
2239 raise error.Abort(_('invalid revision identifier %s') % rev)
2239 raise error.Abort(_('invalid revision identifier %s') % rev)
2240
2240
2241 @command('debugdate',
2241 @command('debugdate',
2242 [('e', 'extended', None, _('try extended date formats'))],
2242 [('e', 'extended', None, _('try extended date formats'))],
2243 _('[-e] DATE [RANGE]'),
2243 _('[-e] DATE [RANGE]'),
2244 norepo=True, optionalrepo=True)
2244 norepo=True, optionalrepo=True)
2245 def debugdate(ui, date, range=None, **opts):
2245 def debugdate(ui, date, range=None, **opts):
2246 """parse and display a date"""
2246 """parse and display a date"""
2247 if opts["extended"]:
2247 if opts["extended"]:
2248 d = util.parsedate(date, util.extendeddateformats)
2248 d = util.parsedate(date, util.extendeddateformats)
2249 else:
2249 else:
2250 d = util.parsedate(date)
2250 d = util.parsedate(date)
2251 ui.write(("internal: %s %s\n") % d)
2251 ui.write(("internal: %s %s\n") % d)
2252 ui.write(("standard: %s\n") % util.datestr(d))
2252 ui.write(("standard: %s\n") % util.datestr(d))
2253 if range:
2253 if range:
2254 m = util.matchdate(range)
2254 m = util.matchdate(range)
2255 ui.write(("match: %s\n") % m(d[0]))
2255 ui.write(("match: %s\n") % m(d[0]))
2256
2256
2257 @command('debugdiscovery',
2257 @command('debugdiscovery',
2258 [('', 'old', None, _('use old-style discovery')),
2258 [('', 'old', None, _('use old-style discovery')),
2259 ('', 'nonheads', None,
2259 ('', 'nonheads', None,
2260 _('use old-style discovery with non-heads included')),
2260 _('use old-style discovery with non-heads included')),
2261 ] + remoteopts,
2261 ] + remoteopts,
2262 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2262 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2263 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2263 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2264 """runs the changeset discovery protocol in isolation"""
2264 """runs the changeset discovery protocol in isolation"""
2265 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2265 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2266 opts.get('branch'))
2266 opts.get('branch'))
2267 remote = hg.peer(repo, opts, remoteurl)
2267 remote = hg.peer(repo, opts, remoteurl)
2268 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2268 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2269
2269
2270 # make sure tests are repeatable
2270 # make sure tests are repeatable
2271 random.seed(12323)
2271 random.seed(12323)
2272
2272
2273 def doit(localheads, remoteheads, remote=remote):
2273 def doit(localheads, remoteheads, remote=remote):
2274 if opts.get('old'):
2274 if opts.get('old'):
2275 if localheads:
2275 if localheads:
2276 raise error.Abort('cannot use localheads with old style '
2276 raise error.Abort('cannot use localheads with old style '
2277 'discovery')
2277 'discovery')
2278 if not util.safehasattr(remote, 'branches'):
2278 if not util.safehasattr(remote, 'branches'):
2279 # enable in-client legacy support
2279 # enable in-client legacy support
2280 remote = localrepo.locallegacypeer(remote.local())
2280 remote = localrepo.locallegacypeer(remote.local())
2281 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2281 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2282 force=True)
2282 force=True)
2283 common = set(common)
2283 common = set(common)
2284 if not opts.get('nonheads'):
2284 if not opts.get('nonheads'):
2285 ui.write(("unpruned common: %s\n") %
2285 ui.write(("unpruned common: %s\n") %
2286 " ".join(sorted(short(n) for n in common)))
2286 " ".join(sorted(short(n) for n in common)))
2287 dag = dagutil.revlogdag(repo.changelog)
2287 dag = dagutil.revlogdag(repo.changelog)
2288 all = dag.ancestorset(dag.internalizeall(common))
2288 all = dag.ancestorset(dag.internalizeall(common))
2289 common = dag.externalizeall(dag.headsetofconnecteds(all))
2289 common = dag.externalizeall(dag.headsetofconnecteds(all))
2290 else:
2290 else:
2291 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2291 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2292 common = set(common)
2292 common = set(common)
2293 rheads = set(hds)
2293 rheads = set(hds)
2294 lheads = set(repo.heads())
2294 lheads = set(repo.heads())
2295 ui.write(("common heads: %s\n") %
2295 ui.write(("common heads: %s\n") %
2296 " ".join(sorted(short(n) for n in common)))
2296 " ".join(sorted(short(n) for n in common)))
2297 if lheads <= common:
2297 if lheads <= common:
2298 ui.write(("local is subset\n"))
2298 ui.write(("local is subset\n"))
2299 elif rheads <= common:
2299 elif rheads <= common:
2300 ui.write(("remote is subset\n"))
2300 ui.write(("remote is subset\n"))
2301
2301
2302 serverlogs = opts.get('serverlog')
2302 serverlogs = opts.get('serverlog')
2303 if serverlogs:
2303 if serverlogs:
2304 for filename in serverlogs:
2304 for filename in serverlogs:
2305 logfile = open(filename, 'r')
2305 logfile = open(filename, 'r')
2306 try:
2306 try:
2307 line = logfile.readline()
2307 line = logfile.readline()
2308 while line:
2308 while line:
2309 parts = line.strip().split(';')
2309 parts = line.strip().split(';')
2310 op = parts[1]
2310 op = parts[1]
2311 if op == 'cg':
2311 if op == 'cg':
2312 pass
2312 pass
2313 elif op == 'cgss':
2313 elif op == 'cgss':
2314 doit(parts[2].split(' '), parts[3].split(' '))
2314 doit(parts[2].split(' '), parts[3].split(' '))
2315 elif op == 'unb':
2315 elif op == 'unb':
2316 doit(parts[3].split(' '), parts[2].split(' '))
2316 doit(parts[3].split(' '), parts[2].split(' '))
2317 line = logfile.readline()
2317 line = logfile.readline()
2318 finally:
2318 finally:
2319 logfile.close()
2319 logfile.close()
2320
2320
2321 else:
2321 else:
2322 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2322 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2323 opts.get('remote_head'))
2323 opts.get('remote_head'))
2324 localrevs = opts.get('local_head')
2324 localrevs = opts.get('local_head')
2325 doit(localrevs, remoterevs)
2325 doit(localrevs, remoterevs)
2326
2326
2327 @command('debugextensions', formatteropts, [], norepo=True)
2327 @command('debugextensions', formatteropts, [], norepo=True)
2328 def debugextensions(ui, **opts):
2328 def debugextensions(ui, **opts):
2329 '''show information about active extensions'''
2329 '''show information about active extensions'''
2330 exts = extensions.extensions(ui)
2330 exts = extensions.extensions(ui)
2331 fm = ui.formatter('debugextensions', opts)
2331 fm = ui.formatter('debugextensions', opts)
2332 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2332 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2333 extsource = extmod.__file__
2333 extsource = extmod.__file__
2334 exttestedwith = getattr(extmod, 'testedwith', None)
2334 exttestedwith = getattr(extmod, 'testedwith', None)
2335 if exttestedwith is not None:
2335 if exttestedwith is not None:
2336 exttestedwith = exttestedwith.split()
2336 exttestedwith = exttestedwith.split()
2337 extbuglink = getattr(extmod, 'buglink', None)
2337 extbuglink = getattr(extmod, 'buglink', None)
2338
2338
2339 fm.startitem()
2339 fm.startitem()
2340
2340
2341 if ui.quiet or ui.verbose:
2341 if ui.quiet or ui.verbose:
2342 fm.write('name', '%s\n', extname)
2342 fm.write('name', '%s\n', extname)
2343 else:
2343 else:
2344 fm.write('name', '%s', extname)
2344 fm.write('name', '%s', extname)
2345 if not exttestedwith:
2345 if not exttestedwith:
2346 fm.plain(_(' (untested!)\n'))
2346 fm.plain(_(' (untested!)\n'))
2347 else:
2347 else:
2348 if exttestedwith == ['internal'] or \
2348 if exttestedwith == ['internal'] or \
2349 util.version() in exttestedwith:
2349 util.version() in exttestedwith:
2350 fm.plain('\n')
2350 fm.plain('\n')
2351 else:
2351 else:
2352 lasttestedversion = exttestedwith[-1]
2352 lasttestedversion = exttestedwith[-1]
2353 fm.plain(' (%s!)\n' % lasttestedversion)
2353 fm.plain(' (%s!)\n' % lasttestedversion)
2354
2354
2355 fm.condwrite(ui.verbose and extsource, 'source',
2355 fm.condwrite(ui.verbose and extsource, 'source',
2356 _(' location: %s\n'), extsource or "")
2356 _(' location: %s\n'), extsource or "")
2357
2357
2358 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2358 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2359 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2359 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2360
2360
2361 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2361 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2362 _(' bug reporting: %s\n'), extbuglink or "")
2362 _(' bug reporting: %s\n'), extbuglink or "")
2363
2363
2364 fm.end()
2364 fm.end()
2365
2365
2366 @command('debugfileset',
2366 @command('debugfileset',
2367 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2367 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2368 _('[-r REV] FILESPEC'))
2368 _('[-r REV] FILESPEC'))
2369 def debugfileset(ui, repo, expr, **opts):
2369 def debugfileset(ui, repo, expr, **opts):
2370 '''parse and apply a fileset specification'''
2370 '''parse and apply a fileset specification'''
2371 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2371 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2372 if ui.verbose:
2372 if ui.verbose:
2373 tree = fileset.parse(expr)
2373 tree = fileset.parse(expr)
2374 ui.note(fileset.prettyformat(tree), "\n")
2374 ui.note(fileset.prettyformat(tree), "\n")
2375
2375
2376 for f in ctx.getfileset(expr):
2376 for f in ctx.getfileset(expr):
2377 ui.write("%s\n" % f)
2377 ui.write("%s\n" % f)
2378
2378
2379 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2379 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2380 def debugfsinfo(ui, path="."):
2380 def debugfsinfo(ui, path="."):
2381 """show information detected about current filesystem"""
2381 """show information detected about current filesystem"""
2382 util.writefile('.debugfsinfo', '')
2382 util.writefile('.debugfsinfo', '')
2383 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2383 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2384 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2384 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2385 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2385 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2386 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2386 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2387 and 'yes' or 'no'))
2387 and 'yes' or 'no'))
2388 os.unlink('.debugfsinfo')
2388 os.unlink('.debugfsinfo')
2389
2389
2390 @command('debuggetbundle',
2390 @command('debuggetbundle',
2391 [('H', 'head', [], _('id of head node'), _('ID')),
2391 [('H', 'head', [], _('id of head node'), _('ID')),
2392 ('C', 'common', [], _('id of common node'), _('ID')),
2392 ('C', 'common', [], _('id of common node'), _('ID')),
2393 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2393 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2394 _('REPO FILE [-H|-C ID]...'),
2394 _('REPO FILE [-H|-C ID]...'),
2395 norepo=True)
2395 norepo=True)
2396 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2396 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2397 """retrieves a bundle from a repo
2397 """retrieves a bundle from a repo
2398
2398
2399 Every ID must be a full-length hex node id string. Saves the bundle to the
2399 Every ID must be a full-length hex node id string. Saves the bundle to the
2400 given file.
2400 given file.
2401 """
2401 """
2402 repo = hg.peer(ui, opts, repopath)
2402 repo = hg.peer(ui, opts, repopath)
2403 if not repo.capable('getbundle'):
2403 if not repo.capable('getbundle'):
2404 raise error.Abort("getbundle() not supported by target repository")
2404 raise error.Abort("getbundle() not supported by target repository")
2405 args = {}
2405 args = {}
2406 if common:
2406 if common:
2407 args['common'] = [bin(s) for s in common]
2407 args['common'] = [bin(s) for s in common]
2408 if head:
2408 if head:
2409 args['heads'] = [bin(s) for s in head]
2409 args['heads'] = [bin(s) for s in head]
2410 # TODO: get desired bundlecaps from command line.
2410 # TODO: get desired bundlecaps from command line.
2411 args['bundlecaps'] = None
2411 args['bundlecaps'] = None
2412 bundle = repo.getbundle('debug', **args)
2412 bundle = repo.getbundle('debug', **args)
2413
2413
2414 bundletype = opts.get('type', 'bzip2').lower()
2414 bundletype = opts.get('type', 'bzip2').lower()
2415 btypes = {'none': 'HG10UN',
2415 btypes = {'none': 'HG10UN',
2416 'bzip2': 'HG10BZ',
2416 'bzip2': 'HG10BZ',
2417 'gzip': 'HG10GZ',
2417 'gzip': 'HG10GZ',
2418 'bundle2': 'HG20'}
2418 'bundle2': 'HG20'}
2419 bundletype = btypes.get(bundletype)
2419 bundletype = btypes.get(bundletype)
2420 if bundletype not in changegroup.bundletypes:
2420 if bundletype not in changegroup.bundletypes:
2421 raise error.Abort(_('unknown bundle type specified with --type'))
2421 raise error.Abort(_('unknown bundle type specified with --type'))
2422 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2422 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2423
2423
2424 @command('debugignore', [], '')
2424 @command('debugignore', [], '')
2425 def debugignore(ui, repo, *values, **opts):
2425 def debugignore(ui, repo, *values, **opts):
2426 """display the combined ignore pattern"""
2426 """display the combined ignore pattern"""
2427 ignore = repo.dirstate._ignore
2427 ignore = repo.dirstate._ignore
2428 includepat = getattr(ignore, 'includepat', None)
2428 includepat = getattr(ignore, 'includepat', None)
2429 if includepat is not None:
2429 if includepat is not None:
2430 ui.write("%s\n" % includepat)
2430 ui.write("%s\n" % includepat)
2431 else:
2431 else:
2432 raise error.Abort(_("no ignore patterns found"))
2432 raise error.Abort(_("no ignore patterns found"))
2433
2433
2434 @command('debugindex', debugrevlogopts +
2434 @command('debugindex', debugrevlogopts +
2435 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2435 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2436 _('[-f FORMAT] -c|-m|FILE'),
2436 _('[-f FORMAT] -c|-m|FILE'),
2437 optionalrepo=True)
2437 optionalrepo=True)
2438 def debugindex(ui, repo, file_=None, **opts):
2438 def debugindex(ui, repo, file_=None, **opts):
2439 """dump the contents of an index file"""
2439 """dump the contents of an index file"""
2440 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2440 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2441 format = opts.get('format', 0)
2441 format = opts.get('format', 0)
2442 if format not in (0, 1):
2442 if format not in (0, 1):
2443 raise error.Abort(_("unknown format %d") % format)
2443 raise error.Abort(_("unknown format %d") % format)
2444
2444
2445 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2445 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2446 if generaldelta:
2446 if generaldelta:
2447 basehdr = ' delta'
2447 basehdr = ' delta'
2448 else:
2448 else:
2449 basehdr = ' base'
2449 basehdr = ' base'
2450
2450
2451 if ui.debugflag:
2451 if ui.debugflag:
2452 shortfn = hex
2452 shortfn = hex
2453 else:
2453 else:
2454 shortfn = short
2454 shortfn = short
2455
2455
2456 # There might not be anything in r, so have a sane default
2456 # There might not be anything in r, so have a sane default
2457 idlen = 12
2457 idlen = 12
2458 for i in r:
2458 for i in r:
2459 idlen = len(shortfn(r.node(i)))
2459 idlen = len(shortfn(r.node(i)))
2460 break
2460 break
2461
2461
2462 if format == 0:
2462 if format == 0:
2463 ui.write(" rev offset length " + basehdr + " linkrev"
2463 ui.write(" rev offset length " + basehdr + " linkrev"
2464 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2464 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2465 elif format == 1:
2465 elif format == 1:
2466 ui.write(" rev flag offset length"
2466 ui.write(" rev flag offset length"
2467 " size " + basehdr + " link p1 p2"
2467 " size " + basehdr + " link p1 p2"
2468 " %s\n" % "nodeid".rjust(idlen))
2468 " %s\n" % "nodeid".rjust(idlen))
2469
2469
2470 for i in r:
2470 for i in r:
2471 node = r.node(i)
2471 node = r.node(i)
2472 if generaldelta:
2472 if generaldelta:
2473 base = r.deltaparent(i)
2473 base = r.deltaparent(i)
2474 else:
2474 else:
2475 base = r.chainbase(i)
2475 base = r.chainbase(i)
2476 if format == 0:
2476 if format == 0:
2477 try:
2477 try:
2478 pp = r.parents(node)
2478 pp = r.parents(node)
2479 except Exception:
2479 except Exception:
2480 pp = [nullid, nullid]
2480 pp = [nullid, nullid]
2481 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2481 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2482 i, r.start(i), r.length(i), base, r.linkrev(i),
2482 i, r.start(i), r.length(i), base, r.linkrev(i),
2483 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2483 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2484 elif format == 1:
2484 elif format == 1:
2485 pr = r.parentrevs(i)
2485 pr = r.parentrevs(i)
2486 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2486 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2487 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2487 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2488 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2488 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2489
2489
2490 @command('debugindexdot', debugrevlogopts,
2490 @command('debugindexdot', debugrevlogopts,
2491 _('-c|-m|FILE'), optionalrepo=True)
2491 _('-c|-m|FILE'), optionalrepo=True)
2492 def debugindexdot(ui, repo, file_=None, **opts):
2492 def debugindexdot(ui, repo, file_=None, **opts):
2493 """dump an index DAG as a graphviz dot file"""
2493 """dump an index DAG as a graphviz dot file"""
2494 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts)
2494 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts)
2495 ui.write(("digraph G {\n"))
2495 ui.write(("digraph G {\n"))
2496 for i in r:
2496 for i in r:
2497 node = r.node(i)
2497 node = r.node(i)
2498 pp = r.parents(node)
2498 pp = r.parents(node)
2499 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2499 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2500 if pp[1] != nullid:
2500 if pp[1] != nullid:
2501 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2501 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2502 ui.write("}\n")
2502 ui.write("}\n")
2503
2503
2504 @command('debugdeltachain',
2505 debugrevlogopts + formatteropts,
2506 _('-c|-m|FILE'),
2507 optionalrepo=True)
2508 def debugdeltachain(ui, repo, file_=None, **opts):
2509 """dump information about delta chains in a revlog
2510
2511 Output can be templatized. Available template keywords are:
2512
2513 rev revision number
2514 chainid delta chain identifier (numbered by unique base)
2515 chainlen delta chain length to this revision
2516 prevrev previous revision in delta chain
2517 deltatype role of delta / how it was computed
2518 compsize compressed size of revision
2519 uncompsize uncompressed size of revision
2520 chainsize total size of compressed revisions in chain
2521 chainratio total chain size divided by uncompressed revision size
2522 (new delta chains typically start at ratio 2.00)
2523 lindist linear distance from base revision in delta chain to end
2524 of this revision
2525 extradist total size of revisions not part of this delta chain from
2526 base of delta chain to end of this revision; a measurement
2527 of how much extra data we need to read/seek across to read
2528 the delta chain for this revision
2529 extraratio extradist divided by chainsize; another representation of
2530 how much unrelated data is needed to load this delta chain
2531 """
2532 r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
2533 index = r.index
2534 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2535
2536 def revinfo(rev):
2537 iterrev = rev
2538 e = index[iterrev]
2539 chain = []
2540 compsize = e[1]
2541 uncompsize = e[2]
2542 chainsize = 0
2543
2544 if generaldelta:
2545 if e[3] == e[5]:
2546 deltatype = 'p1'
2547 elif e[3] == e[6]:
2548 deltatype = 'p2'
2549 elif e[3] == rev - 1:
2550 deltatype = 'prev'
2551 elif e[3] == rev:
2552 deltatype = 'base'
2553 else:
2554 deltatype = 'other'
2555 else:
2556 if e[3] == rev:
2557 deltatype = 'base'
2558 else:
2559 deltatype = 'prev'
2560
2561 while iterrev != e[3]:
2562 chain.append(iterrev)
2563 chainsize += e[1]
2564 if generaldelta:
2565 iterrev = e[3]
2566 else:
2567 iterrev -= 1
2568 e = index[iterrev]
2569 else:
2570 chainsize += e[1]
2571 chain.append(iterrev)
2572
2573 chain.reverse()
2574 return compsize, uncompsize, deltatype, chain, chainsize
2575
2576 fm = ui.formatter('debugdeltachain', opts)
2577
2578 fm.plain(' rev chain# chainlen prev delta '
2579 'size rawsize chainsize ratio lindist extradist '
2580 'extraratio\n')
2581
2582 chainbases = {}
2583 for rev in r:
2584 comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
2585 chainbase = chain[0]
2586 chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
2587 basestart = r.start(chainbase)
2588 revstart = r.start(rev)
2589 lineardist = revstart + comp - basestart
2590 extradist = lineardist - chainsize
2591 try:
2592 prevrev = chain[-2]
2593 except IndexError:
2594 prevrev = -1
2595
2596 chainratio = float(chainsize) / float(uncomp)
2597 extraratio = float(extradist) / float(chainsize)
2598
2599 fm.startitem()
2600 fm.write('rev chainid chainlen prevrev deltatype compsize '
2601 'uncompsize chainsize chainratio lindist extradist '
2602 'extraratio',
2603 '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n',
2604 rev, chainid, len(chain), prevrev, deltatype, comp,
2605 uncomp, chainsize, chainratio, lineardist, extradist,
2606 extraratio,
2607 rev=rev, chainid=chainid, chainlen=len(chain),
2608 prevrev=prevrev, deltatype=deltatype, compsize=comp,
2609 uncompsize=uncomp, chainsize=chainsize,
2610 chainratio=chainratio, lindist=lineardist,
2611 extradist=extradist, extraratio=extraratio)
2612
2613 fm.end()
2614
2504 @command('debuginstall', [], '', norepo=True)
2615 @command('debuginstall', [], '', norepo=True)
2505 def debuginstall(ui):
2616 def debuginstall(ui):
2506 '''test Mercurial installation
2617 '''test Mercurial installation
2507
2618
2508 Returns 0 on success.
2619 Returns 0 on success.
2509 '''
2620 '''
2510
2621
2511 def writetemp(contents):
2622 def writetemp(contents):
2512 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2623 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2513 f = os.fdopen(fd, "wb")
2624 f = os.fdopen(fd, "wb")
2514 f.write(contents)
2625 f.write(contents)
2515 f.close()
2626 f.close()
2516 return name
2627 return name
2517
2628
2518 problems = 0
2629 problems = 0
2519
2630
2520 # encoding
2631 # encoding
2521 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2632 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2522 try:
2633 try:
2523 encoding.fromlocal("test")
2634 encoding.fromlocal("test")
2524 except error.Abort as inst:
2635 except error.Abort as inst:
2525 ui.write(" %s\n" % inst)
2636 ui.write(" %s\n" % inst)
2526 ui.write(_(" (check that your locale is properly set)\n"))
2637 ui.write(_(" (check that your locale is properly set)\n"))
2527 problems += 1
2638 problems += 1
2528
2639
2529 # Python
2640 # Python
2530 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2641 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2531 ui.status(_("checking Python version (%s)\n")
2642 ui.status(_("checking Python version (%s)\n")
2532 % ("%s.%s.%s" % sys.version_info[:3]))
2643 % ("%s.%s.%s" % sys.version_info[:3]))
2533 ui.status(_("checking Python lib (%s)...\n")
2644 ui.status(_("checking Python lib (%s)...\n")
2534 % os.path.dirname(os.__file__))
2645 % os.path.dirname(os.__file__))
2535
2646
2536 # compiled modules
2647 # compiled modules
2537 ui.status(_("checking installed modules (%s)...\n")
2648 ui.status(_("checking installed modules (%s)...\n")
2538 % os.path.dirname(__file__))
2649 % os.path.dirname(__file__))
2539 try:
2650 try:
2540 import bdiff, mpatch, base85, osutil
2651 import bdiff, mpatch, base85, osutil
2541 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2652 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2542 except Exception as inst:
2653 except Exception as inst:
2543 ui.write(" %s\n" % inst)
2654 ui.write(" %s\n" % inst)
2544 ui.write(_(" One or more extensions could not be found"))
2655 ui.write(_(" One or more extensions could not be found"))
2545 ui.write(_(" (check that you compiled the extensions)\n"))
2656 ui.write(_(" (check that you compiled the extensions)\n"))
2546 problems += 1
2657 problems += 1
2547
2658
2548 # templates
2659 # templates
2549 import templater
2660 import templater
2550 p = templater.templatepaths()
2661 p = templater.templatepaths()
2551 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2662 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2552 if p:
2663 if p:
2553 m = templater.templatepath("map-cmdline.default")
2664 m = templater.templatepath("map-cmdline.default")
2554 if m:
2665 if m:
2555 # template found, check if it is working
2666 # template found, check if it is working
2556 try:
2667 try:
2557 templater.templater(m)
2668 templater.templater(m)
2558 except Exception as inst:
2669 except Exception as inst:
2559 ui.write(" %s\n" % inst)
2670 ui.write(" %s\n" % inst)
2560 p = None
2671 p = None
2561 else:
2672 else:
2562 ui.write(_(" template 'default' not found\n"))
2673 ui.write(_(" template 'default' not found\n"))
2563 p = None
2674 p = None
2564 else:
2675 else:
2565 ui.write(_(" no template directories found\n"))
2676 ui.write(_(" no template directories found\n"))
2566 if not p:
2677 if not p:
2567 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2678 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2568 problems += 1
2679 problems += 1
2569
2680
2570 # editor
2681 # editor
2571 ui.status(_("checking commit editor...\n"))
2682 ui.status(_("checking commit editor...\n"))
2572 editor = ui.geteditor()
2683 editor = ui.geteditor()
2573 editor = util.expandpath(editor)
2684 editor = util.expandpath(editor)
2574 cmdpath = util.findexe(shlex.split(editor)[0])
2685 cmdpath = util.findexe(shlex.split(editor)[0])
2575 if not cmdpath:
2686 if not cmdpath:
2576 if editor == 'vi':
2687 if editor == 'vi':
2577 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2688 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2578 ui.write(_(" (specify a commit editor in your configuration"
2689 ui.write(_(" (specify a commit editor in your configuration"
2579 " file)\n"))
2690 " file)\n"))
2580 else:
2691 else:
2581 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2692 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2582 ui.write(_(" (specify a commit editor in your configuration"
2693 ui.write(_(" (specify a commit editor in your configuration"
2583 " file)\n"))
2694 " file)\n"))
2584 problems += 1
2695 problems += 1
2585
2696
2586 # check username
2697 # check username
2587 ui.status(_("checking username...\n"))
2698 ui.status(_("checking username...\n"))
2588 try:
2699 try:
2589 ui.username()
2700 ui.username()
2590 except error.Abort as e:
2701 except error.Abort as e:
2591 ui.write(" %s\n" % e)
2702 ui.write(" %s\n" % e)
2592 ui.write(_(" (specify a username in your configuration file)\n"))
2703 ui.write(_(" (specify a username in your configuration file)\n"))
2593 problems += 1
2704 problems += 1
2594
2705
2595 if not problems:
2706 if not problems:
2596 ui.status(_("no problems detected\n"))
2707 ui.status(_("no problems detected\n"))
2597 else:
2708 else:
2598 ui.write(_("%s problems detected,"
2709 ui.write(_("%s problems detected,"
2599 " please check your install!\n") % problems)
2710 " please check your install!\n") % problems)
2600
2711
2601 return problems
2712 return problems
2602
2713
2603 @command('debugknown', [], _('REPO ID...'), norepo=True)
2714 @command('debugknown', [], _('REPO ID...'), norepo=True)
2604 def debugknown(ui, repopath, *ids, **opts):
2715 def debugknown(ui, repopath, *ids, **opts):
2605 """test whether node ids are known to a repo
2716 """test whether node ids are known to a repo
2606
2717
2607 Every ID must be a full-length hex node id string. Returns a list of 0s
2718 Every ID must be a full-length hex node id string. Returns a list of 0s
2608 and 1s indicating unknown/known.
2719 and 1s indicating unknown/known.
2609 """
2720 """
2610 repo = hg.peer(ui, opts, repopath)
2721 repo = hg.peer(ui, opts, repopath)
2611 if not repo.capable('known'):
2722 if not repo.capable('known'):
2612 raise error.Abort("known() not supported by target repository")
2723 raise error.Abort("known() not supported by target repository")
2613 flags = repo.known([bin(s) for s in ids])
2724 flags = repo.known([bin(s) for s in ids])
2614 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2725 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2615
2726
2616 @command('debuglabelcomplete', [], _('LABEL...'))
2727 @command('debuglabelcomplete', [], _('LABEL...'))
2617 def debuglabelcomplete(ui, repo, *args):
2728 def debuglabelcomplete(ui, repo, *args):
2618 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2729 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2619 debugnamecomplete(ui, repo, *args)
2730 debugnamecomplete(ui, repo, *args)
2620
2731
2621 @command('debugmergestate', [], '')
2732 @command('debugmergestate', [], '')
2622 def debugmergestate(ui, repo, *args):
2733 def debugmergestate(ui, repo, *args):
2623 """print merge state
2734 """print merge state
2624
2735
2625 Use --verbose to print out information about whether v1 or v2 merge state
2736 Use --verbose to print out information about whether v1 or v2 merge state
2626 was chosen."""
2737 was chosen."""
2627 def _hashornull(h):
2738 def _hashornull(h):
2628 if h == nullhex:
2739 if h == nullhex:
2629 return 'null'
2740 return 'null'
2630 else:
2741 else:
2631 return h
2742 return h
2632
2743
2633 def printrecords(version):
2744 def printrecords(version):
2634 ui.write(('* version %s records\n') % version)
2745 ui.write(('* version %s records\n') % version)
2635 if version == 1:
2746 if version == 1:
2636 records = v1records
2747 records = v1records
2637 else:
2748 else:
2638 records = v2records
2749 records = v2records
2639
2750
2640 for rtype, record in records:
2751 for rtype, record in records:
2641 # pretty print some record types
2752 # pretty print some record types
2642 if rtype == 'L':
2753 if rtype == 'L':
2643 ui.write(('local: %s\n') % record)
2754 ui.write(('local: %s\n') % record)
2644 elif rtype == 'O':
2755 elif rtype == 'O':
2645 ui.write(('other: %s\n') % record)
2756 ui.write(('other: %s\n') % record)
2646 elif rtype == 'm':
2757 elif rtype == 'm':
2647 driver, mdstate = record.split('\0', 1)
2758 driver, mdstate = record.split('\0', 1)
2648 ui.write(('merge driver: %s (state "%s")\n')
2759 ui.write(('merge driver: %s (state "%s")\n')
2649 % (driver, mdstate))
2760 % (driver, mdstate))
2650 elif rtype in 'FDC':
2761 elif rtype in 'FDC':
2651 r = record.split('\0')
2762 r = record.split('\0')
2652 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2763 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2653 if version == 1:
2764 if version == 1:
2654 onode = 'not stored in v1 format'
2765 onode = 'not stored in v1 format'
2655 flags = r[7]
2766 flags = r[7]
2656 else:
2767 else:
2657 onode, flags = r[7:9]
2768 onode, flags = r[7:9]
2658 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
2769 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
2659 % (f, rtype, state, _hashornull(hash)))
2770 % (f, rtype, state, _hashornull(hash)))
2660 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2771 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2661 ui.write((' ancestor path: %s (node %s)\n')
2772 ui.write((' ancestor path: %s (node %s)\n')
2662 % (afile, _hashornull(anode)))
2773 % (afile, _hashornull(anode)))
2663 ui.write((' other path: %s (node %s)\n')
2774 ui.write((' other path: %s (node %s)\n')
2664 % (ofile, _hashornull(onode)))
2775 % (ofile, _hashornull(onode)))
2665 else:
2776 else:
2666 ui.write(('unrecognized entry: %s\t%s\n')
2777 ui.write(('unrecognized entry: %s\t%s\n')
2667 % (rtype, record.replace('\0', '\t')))
2778 % (rtype, record.replace('\0', '\t')))
2668
2779
2669 # Avoid mergestate.read() since it may raise an exception for unsupported
2780 # Avoid mergestate.read() since it may raise an exception for unsupported
2670 # merge state records. We shouldn't be doing this, but this is OK since this
2781 # merge state records. We shouldn't be doing this, but this is OK since this
2671 # command is pretty low-level.
2782 # command is pretty low-level.
2672 ms = mergemod.mergestate(repo)
2783 ms = mergemod.mergestate(repo)
2673
2784
2674 # sort so that reasonable information is on top
2785 # sort so that reasonable information is on top
2675 v1records = ms._readrecordsv1()
2786 v1records = ms._readrecordsv1()
2676 v2records = ms._readrecordsv2()
2787 v2records = ms._readrecordsv2()
2677 order = 'LOm'
2788 order = 'LOm'
2678 def key(r):
2789 def key(r):
2679 idx = order.find(r[0])
2790 idx = order.find(r[0])
2680 if idx == -1:
2791 if idx == -1:
2681 return (1, r[1])
2792 return (1, r[1])
2682 else:
2793 else:
2683 return (0, idx)
2794 return (0, idx)
2684 v1records.sort(key=key)
2795 v1records.sort(key=key)
2685 v2records.sort(key=key)
2796 v2records.sort(key=key)
2686
2797
2687 if not v1records and not v2records:
2798 if not v1records and not v2records:
2688 ui.write(('no merge state found\n'))
2799 ui.write(('no merge state found\n'))
2689 elif not v2records:
2800 elif not v2records:
2690 ui.note(('no version 2 merge state\n'))
2801 ui.note(('no version 2 merge state\n'))
2691 printrecords(1)
2802 printrecords(1)
2692 elif ms._v1v2match(v1records, v2records):
2803 elif ms._v1v2match(v1records, v2records):
2693 ui.note(('v1 and v2 states match: using v2\n'))
2804 ui.note(('v1 and v2 states match: using v2\n'))
2694 printrecords(2)
2805 printrecords(2)
2695 else:
2806 else:
2696 ui.note(('v1 and v2 states mismatch: using v1\n'))
2807 ui.note(('v1 and v2 states mismatch: using v1\n'))
2697 printrecords(1)
2808 printrecords(1)
2698 if ui.verbose:
2809 if ui.verbose:
2699 printrecords(2)
2810 printrecords(2)
2700
2811
2701 @command('debugnamecomplete', [], _('NAME...'))
2812 @command('debugnamecomplete', [], _('NAME...'))
2702 def debugnamecomplete(ui, repo, *args):
2813 def debugnamecomplete(ui, repo, *args):
2703 '''complete "names" - tags, open branch names, bookmark names'''
2814 '''complete "names" - tags, open branch names, bookmark names'''
2704
2815
2705 names = set()
2816 names = set()
2706 # since we previously only listed open branches, we will handle that
2817 # since we previously only listed open branches, we will handle that
2707 # specially (after this for loop)
2818 # specially (after this for loop)
2708 for name, ns in repo.names.iteritems():
2819 for name, ns in repo.names.iteritems():
2709 if name != 'branches':
2820 if name != 'branches':
2710 names.update(ns.listnames(repo))
2821 names.update(ns.listnames(repo))
2711 names.update(tag for (tag, heads, tip, closed)
2822 names.update(tag for (tag, heads, tip, closed)
2712 in repo.branchmap().iterbranches() if not closed)
2823 in repo.branchmap().iterbranches() if not closed)
2713 completions = set()
2824 completions = set()
2714 if not args:
2825 if not args:
2715 args = ['']
2826 args = ['']
2716 for a in args:
2827 for a in args:
2717 completions.update(n for n in names if n.startswith(a))
2828 completions.update(n for n in names if n.startswith(a))
2718 ui.write('\n'.join(sorted(completions)))
2829 ui.write('\n'.join(sorted(completions)))
2719 ui.write('\n')
2830 ui.write('\n')
2720
2831
2721 @command('debuglocks',
2832 @command('debuglocks',
2722 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2833 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2723 ('W', 'force-wlock', None,
2834 ('W', 'force-wlock', None,
2724 _('free the working state lock (DANGEROUS)'))],
2835 _('free the working state lock (DANGEROUS)'))],
2725 _('[OPTION]...'))
2836 _('[OPTION]...'))
2726 def debuglocks(ui, repo, **opts):
2837 def debuglocks(ui, repo, **opts):
2727 """show or modify state of locks
2838 """show or modify state of locks
2728
2839
2729 By default, this command will show which locks are held. This
2840 By default, this command will show which locks are held. This
2730 includes the user and process holding the lock, the amount of time
2841 includes the user and process holding the lock, the amount of time
2731 the lock has been held, and the machine name where the process is
2842 the lock has been held, and the machine name where the process is
2732 running if it's not local.
2843 running if it's not local.
2733
2844
2734 Locks protect the integrity of Mercurial's data, so should be
2845 Locks protect the integrity of Mercurial's data, so should be
2735 treated with care. System crashes or other interruptions may cause
2846 treated with care. System crashes or other interruptions may cause
2736 locks to not be properly released, though Mercurial will usually
2847 locks to not be properly released, though Mercurial will usually
2737 detect and remove such stale locks automatically.
2848 detect and remove such stale locks automatically.
2738
2849
2739 However, detecting stale locks may not always be possible (for
2850 However, detecting stale locks may not always be possible (for
2740 instance, on a shared filesystem). Removing locks may also be
2851 instance, on a shared filesystem). Removing locks may also be
2741 blocked by filesystem permissions.
2852 blocked by filesystem permissions.
2742
2853
2743 Returns 0 if no locks are held.
2854 Returns 0 if no locks are held.
2744
2855
2745 """
2856 """
2746
2857
2747 if opts.get('force_lock'):
2858 if opts.get('force_lock'):
2748 repo.svfs.unlink('lock')
2859 repo.svfs.unlink('lock')
2749 if opts.get('force_wlock'):
2860 if opts.get('force_wlock'):
2750 repo.vfs.unlink('wlock')
2861 repo.vfs.unlink('wlock')
2751 if opts.get('force_lock') or opts.get('force_lock'):
2862 if opts.get('force_lock') or opts.get('force_lock'):
2752 return 0
2863 return 0
2753
2864
2754 now = time.time()
2865 now = time.time()
2755 held = 0
2866 held = 0
2756
2867
2757 def report(vfs, name, method):
2868 def report(vfs, name, method):
2758 # this causes stale locks to get reaped for more accurate reporting
2869 # this causes stale locks to get reaped for more accurate reporting
2759 try:
2870 try:
2760 l = method(False)
2871 l = method(False)
2761 except error.LockHeld:
2872 except error.LockHeld:
2762 l = None
2873 l = None
2763
2874
2764 if l:
2875 if l:
2765 l.release()
2876 l.release()
2766 else:
2877 else:
2767 try:
2878 try:
2768 stat = vfs.lstat(name)
2879 stat = vfs.lstat(name)
2769 age = now - stat.st_mtime
2880 age = now - stat.st_mtime
2770 user = util.username(stat.st_uid)
2881 user = util.username(stat.st_uid)
2771 locker = vfs.readlock(name)
2882 locker = vfs.readlock(name)
2772 if ":" in locker:
2883 if ":" in locker:
2773 host, pid = locker.split(':')
2884 host, pid = locker.split(':')
2774 if host == socket.gethostname():
2885 if host == socket.gethostname():
2775 locker = 'user %s, process %s' % (user, pid)
2886 locker = 'user %s, process %s' % (user, pid)
2776 else:
2887 else:
2777 locker = 'user %s, process %s, host %s' \
2888 locker = 'user %s, process %s, host %s' \
2778 % (user, pid, host)
2889 % (user, pid, host)
2779 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2890 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2780 return 1
2891 return 1
2781 except OSError as e:
2892 except OSError as e:
2782 if e.errno != errno.ENOENT:
2893 if e.errno != errno.ENOENT:
2783 raise
2894 raise
2784
2895
2785 ui.write("%-6s free\n" % (name + ":"))
2896 ui.write("%-6s free\n" % (name + ":"))
2786 return 0
2897 return 0
2787
2898
2788 held += report(repo.svfs, "lock", repo.lock)
2899 held += report(repo.svfs, "lock", repo.lock)
2789 held += report(repo.vfs, "wlock", repo.wlock)
2900 held += report(repo.vfs, "wlock", repo.wlock)
2790
2901
2791 return held
2902 return held
2792
2903
2793 @command('debugobsolete',
2904 @command('debugobsolete',
2794 [('', 'flags', 0, _('markers flag')),
2905 [('', 'flags', 0, _('markers flag')),
2795 ('', 'record-parents', False,
2906 ('', 'record-parents', False,
2796 _('record parent information for the precursor')),
2907 _('record parent information for the precursor')),
2797 ('r', 'rev', [], _('display markers relevant to REV')),
2908 ('r', 'rev', [], _('display markers relevant to REV')),
2798 ] + commitopts2,
2909 ] + commitopts2,
2799 _('[OBSOLETED [REPLACEMENT ...]]'))
2910 _('[OBSOLETED [REPLACEMENT ...]]'))
2800 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2911 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2801 """create arbitrary obsolete marker
2912 """create arbitrary obsolete marker
2802
2913
2803 With no arguments, displays the list of obsolescence markers."""
2914 With no arguments, displays the list of obsolescence markers."""
2804
2915
2805 def parsenodeid(s):
2916 def parsenodeid(s):
2806 try:
2917 try:
2807 # We do not use revsingle/revrange functions here to accept
2918 # We do not use revsingle/revrange functions here to accept
2808 # arbitrary node identifiers, possibly not present in the
2919 # arbitrary node identifiers, possibly not present in the
2809 # local repository.
2920 # local repository.
2810 n = bin(s)
2921 n = bin(s)
2811 if len(n) != len(nullid):
2922 if len(n) != len(nullid):
2812 raise TypeError()
2923 raise TypeError()
2813 return n
2924 return n
2814 except TypeError:
2925 except TypeError:
2815 raise error.Abort('changeset references must be full hexadecimal '
2926 raise error.Abort('changeset references must be full hexadecimal '
2816 'node identifiers')
2927 'node identifiers')
2817
2928
2818 if precursor is not None:
2929 if precursor is not None:
2819 if opts['rev']:
2930 if opts['rev']:
2820 raise error.Abort('cannot select revision when creating marker')
2931 raise error.Abort('cannot select revision when creating marker')
2821 metadata = {}
2932 metadata = {}
2822 metadata['user'] = opts['user'] or ui.username()
2933 metadata['user'] = opts['user'] or ui.username()
2823 succs = tuple(parsenodeid(succ) for succ in successors)
2934 succs = tuple(parsenodeid(succ) for succ in successors)
2824 l = repo.lock()
2935 l = repo.lock()
2825 try:
2936 try:
2826 tr = repo.transaction('debugobsolete')
2937 tr = repo.transaction('debugobsolete')
2827 try:
2938 try:
2828 date = opts.get('date')
2939 date = opts.get('date')
2829 if date:
2940 if date:
2830 date = util.parsedate(date)
2941 date = util.parsedate(date)
2831 else:
2942 else:
2832 date = None
2943 date = None
2833 prec = parsenodeid(precursor)
2944 prec = parsenodeid(precursor)
2834 parents = None
2945 parents = None
2835 if opts['record_parents']:
2946 if opts['record_parents']:
2836 if prec not in repo.unfiltered():
2947 if prec not in repo.unfiltered():
2837 raise error.Abort('cannot used --record-parents on '
2948 raise error.Abort('cannot used --record-parents on '
2838 'unknown changesets')
2949 'unknown changesets')
2839 parents = repo.unfiltered()[prec].parents()
2950 parents = repo.unfiltered()[prec].parents()
2840 parents = tuple(p.node() for p in parents)
2951 parents = tuple(p.node() for p in parents)
2841 repo.obsstore.create(tr, prec, succs, opts['flags'],
2952 repo.obsstore.create(tr, prec, succs, opts['flags'],
2842 parents=parents, date=date,
2953 parents=parents, date=date,
2843 metadata=metadata)
2954 metadata=metadata)
2844 tr.close()
2955 tr.close()
2845 except ValueError as exc:
2956 except ValueError as exc:
2846 raise error.Abort(_('bad obsmarker input: %s') % exc)
2957 raise error.Abort(_('bad obsmarker input: %s') % exc)
2847 finally:
2958 finally:
2848 tr.release()
2959 tr.release()
2849 finally:
2960 finally:
2850 l.release()
2961 l.release()
2851 else:
2962 else:
2852 if opts['rev']:
2963 if opts['rev']:
2853 revs = scmutil.revrange(repo, opts['rev'])
2964 revs = scmutil.revrange(repo, opts['rev'])
2854 nodes = [repo[r].node() for r in revs]
2965 nodes = [repo[r].node() for r in revs]
2855 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2966 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2856 markers.sort(key=lambda x: x._data)
2967 markers.sort(key=lambda x: x._data)
2857 else:
2968 else:
2858 markers = obsolete.getmarkers(repo)
2969 markers = obsolete.getmarkers(repo)
2859
2970
2860 for m in markers:
2971 for m in markers:
2861 cmdutil.showmarker(ui, m)
2972 cmdutil.showmarker(ui, m)
2862
2973
2863 @command('debugpathcomplete',
2974 @command('debugpathcomplete',
2864 [('f', 'full', None, _('complete an entire path')),
2975 [('f', 'full', None, _('complete an entire path')),
2865 ('n', 'normal', None, _('show only normal files')),
2976 ('n', 'normal', None, _('show only normal files')),
2866 ('a', 'added', None, _('show only added files')),
2977 ('a', 'added', None, _('show only added files')),
2867 ('r', 'removed', None, _('show only removed files'))],
2978 ('r', 'removed', None, _('show only removed files'))],
2868 _('FILESPEC...'))
2979 _('FILESPEC...'))
2869 def debugpathcomplete(ui, repo, *specs, **opts):
2980 def debugpathcomplete(ui, repo, *specs, **opts):
2870 '''complete part or all of a tracked path
2981 '''complete part or all of a tracked path
2871
2982
2872 This command supports shells that offer path name completion. It
2983 This command supports shells that offer path name completion. It
2873 currently completes only files already known to the dirstate.
2984 currently completes only files already known to the dirstate.
2874
2985
2875 Completion extends only to the next path segment unless
2986 Completion extends only to the next path segment unless
2876 --full is specified, in which case entire paths are used.'''
2987 --full is specified, in which case entire paths are used.'''
2877
2988
2878 def complete(path, acceptable):
2989 def complete(path, acceptable):
2879 dirstate = repo.dirstate
2990 dirstate = repo.dirstate
2880 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2991 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2881 rootdir = repo.root + os.sep
2992 rootdir = repo.root + os.sep
2882 if spec != repo.root and not spec.startswith(rootdir):
2993 if spec != repo.root and not spec.startswith(rootdir):
2883 return [], []
2994 return [], []
2884 if os.path.isdir(spec):
2995 if os.path.isdir(spec):
2885 spec += '/'
2996 spec += '/'
2886 spec = spec[len(rootdir):]
2997 spec = spec[len(rootdir):]
2887 fixpaths = os.sep != '/'
2998 fixpaths = os.sep != '/'
2888 if fixpaths:
2999 if fixpaths:
2889 spec = spec.replace(os.sep, '/')
3000 spec = spec.replace(os.sep, '/')
2890 speclen = len(spec)
3001 speclen = len(spec)
2891 fullpaths = opts['full']
3002 fullpaths = opts['full']
2892 files, dirs = set(), set()
3003 files, dirs = set(), set()
2893 adddir, addfile = dirs.add, files.add
3004 adddir, addfile = dirs.add, files.add
2894 for f, st in dirstate.iteritems():
3005 for f, st in dirstate.iteritems():
2895 if f.startswith(spec) and st[0] in acceptable:
3006 if f.startswith(spec) and st[0] in acceptable:
2896 if fixpaths:
3007 if fixpaths:
2897 f = f.replace('/', os.sep)
3008 f = f.replace('/', os.sep)
2898 if fullpaths:
3009 if fullpaths:
2899 addfile(f)
3010 addfile(f)
2900 continue
3011 continue
2901 s = f.find(os.sep, speclen)
3012 s = f.find(os.sep, speclen)
2902 if s >= 0:
3013 if s >= 0:
2903 adddir(f[:s])
3014 adddir(f[:s])
2904 else:
3015 else:
2905 addfile(f)
3016 addfile(f)
2906 return files, dirs
3017 return files, dirs
2907
3018
2908 acceptable = ''
3019 acceptable = ''
2909 if opts['normal']:
3020 if opts['normal']:
2910 acceptable += 'nm'
3021 acceptable += 'nm'
2911 if opts['added']:
3022 if opts['added']:
2912 acceptable += 'a'
3023 acceptable += 'a'
2913 if opts['removed']:
3024 if opts['removed']:
2914 acceptable += 'r'
3025 acceptable += 'r'
2915 cwd = repo.getcwd()
3026 cwd = repo.getcwd()
2916 if not specs:
3027 if not specs:
2917 specs = ['.']
3028 specs = ['.']
2918
3029
2919 files, dirs = set(), set()
3030 files, dirs = set(), set()
2920 for spec in specs:
3031 for spec in specs:
2921 f, d = complete(spec, acceptable or 'nmar')
3032 f, d = complete(spec, acceptable or 'nmar')
2922 files.update(f)
3033 files.update(f)
2923 dirs.update(d)
3034 dirs.update(d)
2924 files.update(dirs)
3035 files.update(dirs)
2925 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
3036 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2926 ui.write('\n')
3037 ui.write('\n')
2927
3038
2928 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
3039 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2929 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
3040 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2930 '''access the pushkey key/value protocol
3041 '''access the pushkey key/value protocol
2931
3042
2932 With two args, list the keys in the given namespace.
3043 With two args, list the keys in the given namespace.
2933
3044
2934 With five args, set a key to new if it currently is set to old.
3045 With five args, set a key to new if it currently is set to old.
2935 Reports success or failure.
3046 Reports success or failure.
2936 '''
3047 '''
2937
3048
2938 target = hg.peer(ui, {}, repopath)
3049 target = hg.peer(ui, {}, repopath)
2939 if keyinfo:
3050 if keyinfo:
2940 key, old, new = keyinfo
3051 key, old, new = keyinfo
2941 r = target.pushkey(namespace, key, old, new)
3052 r = target.pushkey(namespace, key, old, new)
2942 ui.status(str(r) + '\n')
3053 ui.status(str(r) + '\n')
2943 return not r
3054 return not r
2944 else:
3055 else:
2945 for k, v in sorted(target.listkeys(namespace).iteritems()):
3056 for k, v in sorted(target.listkeys(namespace).iteritems()):
2946 ui.write("%s\t%s\n" % (k.encode('string-escape'),
3057 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2947 v.encode('string-escape')))
3058 v.encode('string-escape')))
2948
3059
2949 @command('debugpvec', [], _('A B'))
3060 @command('debugpvec', [], _('A B'))
2950 def debugpvec(ui, repo, a, b=None):
3061 def debugpvec(ui, repo, a, b=None):
2951 ca = scmutil.revsingle(repo, a)
3062 ca = scmutil.revsingle(repo, a)
2952 cb = scmutil.revsingle(repo, b)
3063 cb = scmutil.revsingle(repo, b)
2953 pa = pvec.ctxpvec(ca)
3064 pa = pvec.ctxpvec(ca)
2954 pb = pvec.ctxpvec(cb)
3065 pb = pvec.ctxpvec(cb)
2955 if pa == pb:
3066 if pa == pb:
2956 rel = "="
3067 rel = "="
2957 elif pa > pb:
3068 elif pa > pb:
2958 rel = ">"
3069 rel = ">"
2959 elif pa < pb:
3070 elif pa < pb:
2960 rel = "<"
3071 rel = "<"
2961 elif pa | pb:
3072 elif pa | pb:
2962 rel = "|"
3073 rel = "|"
2963 ui.write(_("a: %s\n") % pa)
3074 ui.write(_("a: %s\n") % pa)
2964 ui.write(_("b: %s\n") % pb)
3075 ui.write(_("b: %s\n") % pb)
2965 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
3076 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2966 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
3077 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2967 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
3078 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2968 pa.distance(pb), rel))
3079 pa.distance(pb), rel))
2969
3080
2970 @command('debugrebuilddirstate|debugrebuildstate',
3081 @command('debugrebuilddirstate|debugrebuildstate',
2971 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
3082 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2972 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
3083 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2973 'the working copy parent')),
3084 'the working copy parent')),
2974 ],
3085 ],
2975 _('[-r REV]'))
3086 _('[-r REV]'))
2976 def debugrebuilddirstate(ui, repo, rev, **opts):
3087 def debugrebuilddirstate(ui, repo, rev, **opts):
2977 """rebuild the dirstate as it would look like for the given revision
3088 """rebuild the dirstate as it would look like for the given revision
2978
3089
2979 If no revision is specified the first current parent will be used.
3090 If no revision is specified the first current parent will be used.
2980
3091
2981 The dirstate will be set to the files of the given revision.
3092 The dirstate will be set to the files of the given revision.
2982 The actual working directory content or existing dirstate
3093 The actual working directory content or existing dirstate
2983 information such as adds or removes is not considered.
3094 information such as adds or removes is not considered.
2984
3095
2985 ``minimal`` will only rebuild the dirstate status for files that claim to be
3096 ``minimal`` will only rebuild the dirstate status for files that claim to be
2986 tracked but are not in the parent manifest, or that exist in the parent
3097 tracked but are not in the parent manifest, or that exist in the parent
2987 manifest but are not in the dirstate. It will not change adds, removes, or
3098 manifest but are not in the dirstate. It will not change adds, removes, or
2988 modified files that are in the working copy parent.
3099 modified files that are in the working copy parent.
2989
3100
2990 One use of this command is to make the next :hg:`status` invocation
3101 One use of this command is to make the next :hg:`status` invocation
2991 check the actual file content.
3102 check the actual file content.
2992 """
3103 """
2993 ctx = scmutil.revsingle(repo, rev)
3104 ctx = scmutil.revsingle(repo, rev)
2994 wlock = repo.wlock()
3105 wlock = repo.wlock()
2995 try:
3106 try:
2996 dirstate = repo.dirstate
3107 dirstate = repo.dirstate
2997 changedfiles = None
3108 changedfiles = None
2998 # See command doc for what minimal does.
3109 # See command doc for what minimal does.
2999 if opts.get('minimal'):
3110 if opts.get('minimal'):
3000 manifestfiles = set(ctx.manifest().keys())
3111 manifestfiles = set(ctx.manifest().keys())
3001 dirstatefiles = set(dirstate)
3112 dirstatefiles = set(dirstate)
3002 manifestonly = manifestfiles - dirstatefiles
3113 manifestonly = manifestfiles - dirstatefiles
3003 dsonly = dirstatefiles - manifestfiles
3114 dsonly = dirstatefiles - manifestfiles
3004 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
3115 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a')
3005 changedfiles = manifestonly | dsnotadded
3116 changedfiles = manifestonly | dsnotadded
3006
3117
3007 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
3118 dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles)
3008 finally:
3119 finally:
3009 wlock.release()
3120 wlock.release()
3010
3121
3011 @command('debugrebuildfncache', [], '')
3122 @command('debugrebuildfncache', [], '')
3012 def debugrebuildfncache(ui, repo):
3123 def debugrebuildfncache(ui, repo):
3013 """rebuild the fncache file"""
3124 """rebuild the fncache file"""
3014 repair.rebuildfncache(ui, repo)
3125 repair.rebuildfncache(ui, repo)
3015
3126
3016 @command('debugrename',
3127 @command('debugrename',
3017 [('r', 'rev', '', _('revision to debug'), _('REV'))],
3128 [('r', 'rev', '', _('revision to debug'), _('REV'))],
3018 _('[-r REV] FILE'))
3129 _('[-r REV] FILE'))
3019 def debugrename(ui, repo, file1, *pats, **opts):
3130 def debugrename(ui, repo, file1, *pats, **opts):
3020 """dump rename information"""
3131 """dump rename information"""
3021
3132
3022 ctx = scmutil.revsingle(repo, opts.get('rev'))
3133 ctx = scmutil.revsingle(repo, opts.get('rev'))
3023 m = scmutil.match(ctx, (file1,) + pats, opts)
3134 m = scmutil.match(ctx, (file1,) + pats, opts)
3024 for abs in ctx.walk(m):
3135 for abs in ctx.walk(m):
3025 fctx = ctx[abs]
3136 fctx = ctx[abs]
3026 o = fctx.filelog().renamed(fctx.filenode())
3137 o = fctx.filelog().renamed(fctx.filenode())
3027 rel = m.rel(abs)
3138 rel = m.rel(abs)
3028 if o:
3139 if o:
3029 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
3140 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
3030 else:
3141 else:
3031 ui.write(_("%s not renamed\n") % rel)
3142 ui.write(_("%s not renamed\n") % rel)
3032
3143
3033 @command('debugrevlog', debugrevlogopts +
3144 @command('debugrevlog', debugrevlogopts +
3034 [('d', 'dump', False, _('dump index data'))],
3145 [('d', 'dump', False, _('dump index data'))],
3035 _('-c|-m|FILE'),
3146 _('-c|-m|FILE'),
3036 optionalrepo=True)
3147 optionalrepo=True)
3037 def debugrevlog(ui, repo, file_=None, **opts):
3148 def debugrevlog(ui, repo, file_=None, **opts):
3038 """show data and statistics about a revlog"""
3149 """show data and statistics about a revlog"""
3039 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
3150 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
3040
3151
3041 if opts.get("dump"):
3152 if opts.get("dump"):
3042 numrevs = len(r)
3153 numrevs = len(r)
3043 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
3154 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
3044 " rawsize totalsize compression heads chainlen\n")
3155 " rawsize totalsize compression heads chainlen\n")
3045 ts = 0
3156 ts = 0
3046 heads = set()
3157 heads = set()
3047
3158
3048 for rev in xrange(numrevs):
3159 for rev in xrange(numrevs):
3049 dbase = r.deltaparent(rev)
3160 dbase = r.deltaparent(rev)
3050 if dbase == -1:
3161 if dbase == -1:
3051 dbase = rev
3162 dbase = rev
3052 cbase = r.chainbase(rev)
3163 cbase = r.chainbase(rev)
3053 clen = r.chainlen(rev)
3164 clen = r.chainlen(rev)
3054 p1, p2 = r.parentrevs(rev)
3165 p1, p2 = r.parentrevs(rev)
3055 rs = r.rawsize(rev)
3166 rs = r.rawsize(rev)
3056 ts = ts + rs
3167 ts = ts + rs
3057 heads -= set(r.parentrevs(rev))
3168 heads -= set(r.parentrevs(rev))
3058 heads.add(rev)
3169 heads.add(rev)
3059 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
3170 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
3060 "%11d %5d %8d\n" %
3171 "%11d %5d %8d\n" %
3061 (rev, p1, p2, r.start(rev), r.end(rev),
3172 (rev, p1, p2, r.start(rev), r.end(rev),
3062 r.start(dbase), r.start(cbase),
3173 r.start(dbase), r.start(cbase),
3063 r.start(p1), r.start(p2),
3174 r.start(p1), r.start(p2),
3064 rs, ts, ts / r.end(rev), len(heads), clen))
3175 rs, ts, ts / r.end(rev), len(heads), clen))
3065 return 0
3176 return 0
3066
3177
3067 v = r.version
3178 v = r.version
3068 format = v & 0xFFFF
3179 format = v & 0xFFFF
3069 flags = []
3180 flags = []
3070 gdelta = False
3181 gdelta = False
3071 if v & revlog.REVLOGNGINLINEDATA:
3182 if v & revlog.REVLOGNGINLINEDATA:
3072 flags.append('inline')
3183 flags.append('inline')
3073 if v & revlog.REVLOGGENERALDELTA:
3184 if v & revlog.REVLOGGENERALDELTA:
3074 gdelta = True
3185 gdelta = True
3075 flags.append('generaldelta')
3186 flags.append('generaldelta')
3076 if not flags:
3187 if not flags:
3077 flags = ['(none)']
3188 flags = ['(none)']
3078
3189
3079 nummerges = 0
3190 nummerges = 0
3080 numfull = 0
3191 numfull = 0
3081 numprev = 0
3192 numprev = 0
3082 nump1 = 0
3193 nump1 = 0
3083 nump2 = 0
3194 nump2 = 0
3084 numother = 0
3195 numother = 0
3085 nump1prev = 0
3196 nump1prev = 0
3086 nump2prev = 0
3197 nump2prev = 0
3087 chainlengths = []
3198 chainlengths = []
3088
3199
3089 datasize = [None, 0, 0L]
3200 datasize = [None, 0, 0L]
3090 fullsize = [None, 0, 0L]
3201 fullsize = [None, 0, 0L]
3091 deltasize = [None, 0, 0L]
3202 deltasize = [None, 0, 0L]
3092
3203
3093 def addsize(size, l):
3204 def addsize(size, l):
3094 if l[0] is None or size < l[0]:
3205 if l[0] is None or size < l[0]:
3095 l[0] = size
3206 l[0] = size
3096 if size > l[1]:
3207 if size > l[1]:
3097 l[1] = size
3208 l[1] = size
3098 l[2] += size
3209 l[2] += size
3099
3210
3100 numrevs = len(r)
3211 numrevs = len(r)
3101 for rev in xrange(numrevs):
3212 for rev in xrange(numrevs):
3102 p1, p2 = r.parentrevs(rev)
3213 p1, p2 = r.parentrevs(rev)
3103 delta = r.deltaparent(rev)
3214 delta = r.deltaparent(rev)
3104 if format > 0:
3215 if format > 0:
3105 addsize(r.rawsize(rev), datasize)
3216 addsize(r.rawsize(rev), datasize)
3106 if p2 != nullrev:
3217 if p2 != nullrev:
3107 nummerges += 1
3218 nummerges += 1
3108 size = r.length(rev)
3219 size = r.length(rev)
3109 if delta == nullrev:
3220 if delta == nullrev:
3110 chainlengths.append(0)
3221 chainlengths.append(0)
3111 numfull += 1
3222 numfull += 1
3112 addsize(size, fullsize)
3223 addsize(size, fullsize)
3113 else:
3224 else:
3114 chainlengths.append(chainlengths[delta] + 1)
3225 chainlengths.append(chainlengths[delta] + 1)
3115 addsize(size, deltasize)
3226 addsize(size, deltasize)
3116 if delta == rev - 1:
3227 if delta == rev - 1:
3117 numprev += 1
3228 numprev += 1
3118 if delta == p1:
3229 if delta == p1:
3119 nump1prev += 1
3230 nump1prev += 1
3120 elif delta == p2:
3231 elif delta == p2:
3121 nump2prev += 1
3232 nump2prev += 1
3122 elif delta == p1:
3233 elif delta == p1:
3123 nump1 += 1
3234 nump1 += 1
3124 elif delta == p2:
3235 elif delta == p2:
3125 nump2 += 1
3236 nump2 += 1
3126 elif delta != nullrev:
3237 elif delta != nullrev:
3127 numother += 1
3238 numother += 1
3128
3239
3129 # Adjust size min value for empty cases
3240 # Adjust size min value for empty cases
3130 for size in (datasize, fullsize, deltasize):
3241 for size in (datasize, fullsize, deltasize):
3131 if size[0] is None:
3242 if size[0] is None:
3132 size[0] = 0
3243 size[0] = 0
3133
3244
3134 numdeltas = numrevs - numfull
3245 numdeltas = numrevs - numfull
3135 numoprev = numprev - nump1prev - nump2prev
3246 numoprev = numprev - nump1prev - nump2prev
3136 totalrawsize = datasize[2]
3247 totalrawsize = datasize[2]
3137 datasize[2] /= numrevs
3248 datasize[2] /= numrevs
3138 fulltotal = fullsize[2]
3249 fulltotal = fullsize[2]
3139 fullsize[2] /= numfull
3250 fullsize[2] /= numfull
3140 deltatotal = deltasize[2]
3251 deltatotal = deltasize[2]
3141 if numrevs - numfull > 0:
3252 if numrevs - numfull > 0:
3142 deltasize[2] /= numrevs - numfull
3253 deltasize[2] /= numrevs - numfull
3143 totalsize = fulltotal + deltatotal
3254 totalsize = fulltotal + deltatotal
3144 avgchainlen = sum(chainlengths) / numrevs
3255 avgchainlen = sum(chainlengths) / numrevs
3145 maxchainlen = max(chainlengths)
3256 maxchainlen = max(chainlengths)
3146 compratio = 1
3257 compratio = 1
3147 if totalsize:
3258 if totalsize:
3148 compratio = totalrawsize / totalsize
3259 compratio = totalrawsize / totalsize
3149
3260
3150 basedfmtstr = '%%%dd\n'
3261 basedfmtstr = '%%%dd\n'
3151 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3262 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3152
3263
3153 def dfmtstr(max):
3264 def dfmtstr(max):
3154 return basedfmtstr % len(str(max))
3265 return basedfmtstr % len(str(max))
3155 def pcfmtstr(max, padding=0):
3266 def pcfmtstr(max, padding=0):
3156 return basepcfmtstr % (len(str(max)), ' ' * padding)
3267 return basepcfmtstr % (len(str(max)), ' ' * padding)
3157
3268
3158 def pcfmt(value, total):
3269 def pcfmt(value, total):
3159 if total:
3270 if total:
3160 return (value, 100 * float(value) / total)
3271 return (value, 100 * float(value) / total)
3161 else:
3272 else:
3162 return value, 100.0
3273 return value, 100.0
3163
3274
3164 ui.write(('format : %d\n') % format)
3275 ui.write(('format : %d\n') % format)
3165 ui.write(('flags : %s\n') % ', '.join(flags))
3276 ui.write(('flags : %s\n') % ', '.join(flags))
3166
3277
3167 ui.write('\n')
3278 ui.write('\n')
3168 fmt = pcfmtstr(totalsize)
3279 fmt = pcfmtstr(totalsize)
3169 fmt2 = dfmtstr(totalsize)
3280 fmt2 = dfmtstr(totalsize)
3170 ui.write(('revisions : ') + fmt2 % numrevs)
3281 ui.write(('revisions : ') + fmt2 % numrevs)
3171 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3282 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3172 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3283 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3173 ui.write(('revisions : ') + fmt2 % numrevs)
3284 ui.write(('revisions : ') + fmt2 % numrevs)
3174 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3285 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3175 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3286 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3176 ui.write(('revision size : ') + fmt2 % totalsize)
3287 ui.write(('revision size : ') + fmt2 % totalsize)
3177 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3288 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3178 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3289 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3179
3290
3180 ui.write('\n')
3291 ui.write('\n')
3181 fmt = dfmtstr(max(avgchainlen, compratio))
3292 fmt = dfmtstr(max(avgchainlen, compratio))
3182 ui.write(('avg chain length : ') + fmt % avgchainlen)
3293 ui.write(('avg chain length : ') + fmt % avgchainlen)
3183 ui.write(('max chain length : ') + fmt % maxchainlen)
3294 ui.write(('max chain length : ') + fmt % maxchainlen)
3184 ui.write(('compression ratio : ') + fmt % compratio)
3295 ui.write(('compression ratio : ') + fmt % compratio)
3185
3296
3186 if format > 0:
3297 if format > 0:
3187 ui.write('\n')
3298 ui.write('\n')
3188 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3299 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3189 % tuple(datasize))
3300 % tuple(datasize))
3190 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3301 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3191 % tuple(fullsize))
3302 % tuple(fullsize))
3192 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3303 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3193 % tuple(deltasize))
3304 % tuple(deltasize))
3194
3305
3195 if numdeltas > 0:
3306 if numdeltas > 0:
3196 ui.write('\n')
3307 ui.write('\n')
3197 fmt = pcfmtstr(numdeltas)
3308 fmt = pcfmtstr(numdeltas)
3198 fmt2 = pcfmtstr(numdeltas, 4)
3309 fmt2 = pcfmtstr(numdeltas, 4)
3199 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3310 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3200 if numprev > 0:
3311 if numprev > 0:
3201 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3312 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3202 numprev))
3313 numprev))
3203 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3314 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3204 numprev))
3315 numprev))
3205 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3316 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3206 numprev))
3317 numprev))
3207 if gdelta:
3318 if gdelta:
3208 ui.write(('deltas against p1 : ')
3319 ui.write(('deltas against p1 : ')
3209 + fmt % pcfmt(nump1, numdeltas))
3320 + fmt % pcfmt(nump1, numdeltas))
3210 ui.write(('deltas against p2 : ')
3321 ui.write(('deltas against p2 : ')
3211 + fmt % pcfmt(nump2, numdeltas))
3322 + fmt % pcfmt(nump2, numdeltas))
3212 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3323 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3213 numdeltas))
3324 numdeltas))
3214
3325
3215 @command('debugrevspec',
3326 @command('debugrevspec',
3216 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3327 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3217 ('REVSPEC'))
3328 ('REVSPEC'))
3218 def debugrevspec(ui, repo, expr, **opts):
3329 def debugrevspec(ui, repo, expr, **opts):
3219 """parse and apply a revision specification
3330 """parse and apply a revision specification
3220
3331
3221 Use --verbose to print the parsed tree before and after aliases
3332 Use --verbose to print the parsed tree before and after aliases
3222 expansion.
3333 expansion.
3223 """
3334 """
3224 if ui.verbose:
3335 if ui.verbose:
3225 tree = revset.parse(expr, lookup=repo.__contains__)
3336 tree = revset.parse(expr, lookup=repo.__contains__)
3226 ui.note(revset.prettyformat(tree), "\n")
3337 ui.note(revset.prettyformat(tree), "\n")
3227 newtree = revset.findaliases(ui, tree)
3338 newtree = revset.findaliases(ui, tree)
3228 if newtree != tree:
3339 if newtree != tree:
3229 ui.note(revset.prettyformat(newtree), "\n")
3340 ui.note(revset.prettyformat(newtree), "\n")
3230 tree = newtree
3341 tree = newtree
3231 newtree = revset.foldconcat(tree)
3342 newtree = revset.foldconcat(tree)
3232 if newtree != tree:
3343 if newtree != tree:
3233 ui.note(revset.prettyformat(newtree), "\n")
3344 ui.note(revset.prettyformat(newtree), "\n")
3234 if opts["optimize"]:
3345 if opts["optimize"]:
3235 weight, optimizedtree = revset.optimize(newtree, True)
3346 weight, optimizedtree = revset.optimize(newtree, True)
3236 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3347 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3237 func = revset.match(ui, expr, repo)
3348 func = revset.match(ui, expr, repo)
3238 revs = func(repo)
3349 revs = func(repo)
3239 if ui.verbose:
3350 if ui.verbose:
3240 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3351 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3241 for c in revs:
3352 for c in revs:
3242 ui.write("%s\n" % c)
3353 ui.write("%s\n" % c)
3243
3354
3244 @command('debugsetparents', [], _('REV1 [REV2]'))
3355 @command('debugsetparents', [], _('REV1 [REV2]'))
3245 def debugsetparents(ui, repo, rev1, rev2=None):
3356 def debugsetparents(ui, repo, rev1, rev2=None):
3246 """manually set the parents of the current working directory
3357 """manually set the parents of the current working directory
3247
3358
3248 This is useful for writing repository conversion tools, but should
3359 This is useful for writing repository conversion tools, but should
3249 be used with care. For example, neither the working directory nor the
3360 be used with care. For example, neither the working directory nor the
3250 dirstate is updated, so file status may be incorrect after running this
3361 dirstate is updated, so file status may be incorrect after running this
3251 command.
3362 command.
3252
3363
3253 Returns 0 on success.
3364 Returns 0 on success.
3254 """
3365 """
3255
3366
3256 r1 = scmutil.revsingle(repo, rev1).node()
3367 r1 = scmutil.revsingle(repo, rev1).node()
3257 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3368 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3258
3369
3259 wlock = repo.wlock()
3370 wlock = repo.wlock()
3260 try:
3371 try:
3261 repo.dirstate.beginparentchange()
3372 repo.dirstate.beginparentchange()
3262 repo.setparents(r1, r2)
3373 repo.setparents(r1, r2)
3263 repo.dirstate.endparentchange()
3374 repo.dirstate.endparentchange()
3264 finally:
3375 finally:
3265 wlock.release()
3376 wlock.release()
3266
3377
3267 @command('debugdirstate|debugstate',
3378 @command('debugdirstate|debugstate',
3268 [('', 'nodates', None, _('do not display the saved mtime')),
3379 [('', 'nodates', None, _('do not display the saved mtime')),
3269 ('', 'datesort', None, _('sort by saved mtime'))],
3380 ('', 'datesort', None, _('sort by saved mtime'))],
3270 _('[OPTION]...'))
3381 _('[OPTION]...'))
3271 def debugstate(ui, repo, **opts):
3382 def debugstate(ui, repo, **opts):
3272 """show the contents of the current dirstate"""
3383 """show the contents of the current dirstate"""
3273
3384
3274 nodates = opts.get('nodates')
3385 nodates = opts.get('nodates')
3275 datesort = opts.get('datesort')
3386 datesort = opts.get('datesort')
3276
3387
3277 timestr = ""
3388 timestr = ""
3278 if datesort:
3389 if datesort:
3279 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3390 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3280 else:
3391 else:
3281 keyfunc = None # sort by filename
3392 keyfunc = None # sort by filename
3282 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3393 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3283 if ent[3] == -1:
3394 if ent[3] == -1:
3284 timestr = 'unset '
3395 timestr = 'unset '
3285 elif nodates:
3396 elif nodates:
3286 timestr = 'set '
3397 timestr = 'set '
3287 else:
3398 else:
3288 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3399 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3289 time.localtime(ent[3]))
3400 time.localtime(ent[3]))
3290 if ent[1] & 0o20000:
3401 if ent[1] & 0o20000:
3291 mode = 'lnk'
3402 mode = 'lnk'
3292 else:
3403 else:
3293 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3404 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3294 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3405 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3295 for f in repo.dirstate.copies():
3406 for f in repo.dirstate.copies():
3296 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3407 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3297
3408
3298 @command('debugsub',
3409 @command('debugsub',
3299 [('r', 'rev', '',
3410 [('r', 'rev', '',
3300 _('revision to check'), _('REV'))],
3411 _('revision to check'), _('REV'))],
3301 _('[-r REV] [REV]'))
3412 _('[-r REV] [REV]'))
3302 def debugsub(ui, repo, rev=None):
3413 def debugsub(ui, repo, rev=None):
3303 ctx = scmutil.revsingle(repo, rev, None)
3414 ctx = scmutil.revsingle(repo, rev, None)
3304 for k, v in sorted(ctx.substate.items()):
3415 for k, v in sorted(ctx.substate.items()):
3305 ui.write(('path %s\n') % k)
3416 ui.write(('path %s\n') % k)
3306 ui.write((' source %s\n') % v[0])
3417 ui.write((' source %s\n') % v[0])
3307 ui.write((' revision %s\n') % v[1])
3418 ui.write((' revision %s\n') % v[1])
3308
3419
3309 @command('debugsuccessorssets',
3420 @command('debugsuccessorssets',
3310 [],
3421 [],
3311 _('[REV]'))
3422 _('[REV]'))
3312 def debugsuccessorssets(ui, repo, *revs):
3423 def debugsuccessorssets(ui, repo, *revs):
3313 """show set of successors for revision
3424 """show set of successors for revision
3314
3425
3315 A successors set of changeset A is a consistent group of revisions that
3426 A successors set of changeset A is a consistent group of revisions that
3316 succeed A. It contains non-obsolete changesets only.
3427 succeed A. It contains non-obsolete changesets only.
3317
3428
3318 In most cases a changeset A has a single successors set containing a single
3429 In most cases a changeset A has a single successors set containing a single
3319 successor (changeset A replaced by A').
3430 successor (changeset A replaced by A').
3320
3431
3321 A changeset that is made obsolete with no successors are called "pruned".
3432 A changeset that is made obsolete with no successors are called "pruned".
3322 Such changesets have no successors sets at all.
3433 Such changesets have no successors sets at all.
3323
3434
3324 A changeset that has been "split" will have a successors set containing
3435 A changeset that has been "split" will have a successors set containing
3325 more than one successor.
3436 more than one successor.
3326
3437
3327 A changeset that has been rewritten in multiple different ways is called
3438 A changeset that has been rewritten in multiple different ways is called
3328 "divergent". Such changesets have multiple successor sets (each of which
3439 "divergent". Such changesets have multiple successor sets (each of which
3329 may also be split, i.e. have multiple successors).
3440 may also be split, i.e. have multiple successors).
3330
3441
3331 Results are displayed as follows::
3442 Results are displayed as follows::
3332
3443
3333 <rev1>
3444 <rev1>
3334 <successors-1A>
3445 <successors-1A>
3335 <rev2>
3446 <rev2>
3336 <successors-2A>
3447 <successors-2A>
3337 <successors-2B1> <successors-2B2> <successors-2B3>
3448 <successors-2B1> <successors-2B2> <successors-2B3>
3338
3449
3339 Here rev2 has two possible (i.e. divergent) successors sets. The first
3450 Here rev2 has two possible (i.e. divergent) successors sets. The first
3340 holds one element, whereas the second holds three (i.e. the changeset has
3451 holds one element, whereas the second holds three (i.e. the changeset has
3341 been split).
3452 been split).
3342 """
3453 """
3343 # passed to successorssets caching computation from one call to another
3454 # passed to successorssets caching computation from one call to another
3344 cache = {}
3455 cache = {}
3345 ctx2str = str
3456 ctx2str = str
3346 node2str = short
3457 node2str = short
3347 if ui.debug():
3458 if ui.debug():
3348 def ctx2str(ctx):
3459 def ctx2str(ctx):
3349 return ctx.hex()
3460 return ctx.hex()
3350 node2str = hex
3461 node2str = hex
3351 for rev in scmutil.revrange(repo, revs):
3462 for rev in scmutil.revrange(repo, revs):
3352 ctx = repo[rev]
3463 ctx = repo[rev]
3353 ui.write('%s\n'% ctx2str(ctx))
3464 ui.write('%s\n'% ctx2str(ctx))
3354 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3465 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3355 if succsset:
3466 if succsset:
3356 ui.write(' ')
3467 ui.write(' ')
3357 ui.write(node2str(succsset[0]))
3468 ui.write(node2str(succsset[0]))
3358 for node in succsset[1:]:
3469 for node in succsset[1:]:
3359 ui.write(' ')
3470 ui.write(' ')
3360 ui.write(node2str(node))
3471 ui.write(node2str(node))
3361 ui.write('\n')
3472 ui.write('\n')
3362
3473
3363 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3474 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3364 def debugwalk(ui, repo, *pats, **opts):
3475 def debugwalk(ui, repo, *pats, **opts):
3365 """show how files match on given patterns"""
3476 """show how files match on given patterns"""
3366 m = scmutil.match(repo[None], pats, opts)
3477 m = scmutil.match(repo[None], pats, opts)
3367 items = list(repo.walk(m))
3478 items = list(repo.walk(m))
3368 if not items:
3479 if not items:
3369 return
3480 return
3370 f = lambda fn: fn
3481 f = lambda fn: fn
3371 if ui.configbool('ui', 'slash') and os.sep != '/':
3482 if ui.configbool('ui', 'slash') and os.sep != '/':
3372 f = lambda fn: util.normpath(fn)
3483 f = lambda fn: util.normpath(fn)
3373 fmt = 'f %%-%ds %%-%ds %%s' % (
3484 fmt = 'f %%-%ds %%-%ds %%s' % (
3374 max([len(abs) for abs in items]),
3485 max([len(abs) for abs in items]),
3375 max([len(m.rel(abs)) for abs in items]))
3486 max([len(m.rel(abs)) for abs in items]))
3376 for abs in items:
3487 for abs in items:
3377 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3488 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3378 ui.write("%s\n" % line.rstrip())
3489 ui.write("%s\n" % line.rstrip())
3379
3490
3380 @command('debugwireargs',
3491 @command('debugwireargs',
3381 [('', 'three', '', 'three'),
3492 [('', 'three', '', 'three'),
3382 ('', 'four', '', 'four'),
3493 ('', 'four', '', 'four'),
3383 ('', 'five', '', 'five'),
3494 ('', 'five', '', 'five'),
3384 ] + remoteopts,
3495 ] + remoteopts,
3385 _('REPO [OPTIONS]... [ONE [TWO]]'),
3496 _('REPO [OPTIONS]... [ONE [TWO]]'),
3386 norepo=True)
3497 norepo=True)
3387 def debugwireargs(ui, repopath, *vals, **opts):
3498 def debugwireargs(ui, repopath, *vals, **opts):
3388 repo = hg.peer(ui, opts, repopath)
3499 repo = hg.peer(ui, opts, repopath)
3389 for opt in remoteopts:
3500 for opt in remoteopts:
3390 del opts[opt[1]]
3501 del opts[opt[1]]
3391 args = {}
3502 args = {}
3392 for k, v in opts.iteritems():
3503 for k, v in opts.iteritems():
3393 if v:
3504 if v:
3394 args[k] = v
3505 args[k] = v
3395 # run twice to check that we don't mess up the stream for the next command
3506 # run twice to check that we don't mess up the stream for the next command
3396 res1 = repo.debugwireargs(*vals, **args)
3507 res1 = repo.debugwireargs(*vals, **args)
3397 res2 = repo.debugwireargs(*vals, **args)
3508 res2 = repo.debugwireargs(*vals, **args)
3398 ui.write("%s\n" % res1)
3509 ui.write("%s\n" % res1)
3399 if res1 != res2:
3510 if res1 != res2:
3400 ui.warn("%s\n" % res2)
3511 ui.warn("%s\n" % res2)
3401
3512
3402 @command('^diff',
3513 @command('^diff',
3403 [('r', 'rev', [], _('revision'), _('REV')),
3514 [('r', 'rev', [], _('revision'), _('REV')),
3404 ('c', 'change', '', _('change made by revision'), _('REV'))
3515 ('c', 'change', '', _('change made by revision'), _('REV'))
3405 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3516 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3406 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3517 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3407 inferrepo=True)
3518 inferrepo=True)
3408 def diff(ui, repo, *pats, **opts):
3519 def diff(ui, repo, *pats, **opts):
3409 """diff repository (or selected files)
3520 """diff repository (or selected files)
3410
3521
3411 Show differences between revisions for the specified files.
3522 Show differences between revisions for the specified files.
3412
3523
3413 Differences between files are shown using the unified diff format.
3524 Differences between files are shown using the unified diff format.
3414
3525
3415 .. note::
3526 .. note::
3416
3527
3417 diff may generate unexpected results for merges, as it will
3528 diff may generate unexpected results for merges, as it will
3418 default to comparing against the working directory's first
3529 default to comparing against the working directory's first
3419 parent changeset if no revisions are specified.
3530 parent changeset if no revisions are specified.
3420
3531
3421 When two revision arguments are given, then changes are shown
3532 When two revision arguments are given, then changes are shown
3422 between those revisions. If only one revision is specified then
3533 between those revisions. If only one revision is specified then
3423 that revision is compared to the working directory, and, when no
3534 that revision is compared to the working directory, and, when no
3424 revisions are specified, the working directory files are compared
3535 revisions are specified, the working directory files are compared
3425 to its parent.
3536 to its parent.
3426
3537
3427 Alternatively you can specify -c/--change with a revision to see
3538 Alternatively you can specify -c/--change with a revision to see
3428 the changes in that changeset relative to its first parent.
3539 the changes in that changeset relative to its first parent.
3429
3540
3430 Without the -a/--text option, diff will avoid generating diffs of
3541 Without the -a/--text option, diff will avoid generating diffs of
3431 files it detects as binary. With -a, diff will generate a diff
3542 files it detects as binary. With -a, diff will generate a diff
3432 anyway, probably with undesirable results.
3543 anyway, probably with undesirable results.
3433
3544
3434 Use the -g/--git option to generate diffs in the git extended diff
3545 Use the -g/--git option to generate diffs in the git extended diff
3435 format. For more information, read :hg:`help diffs`.
3546 format. For more information, read :hg:`help diffs`.
3436
3547
3437 .. container:: verbose
3548 .. container:: verbose
3438
3549
3439 Examples:
3550 Examples:
3440
3551
3441 - compare a file in the current working directory to its parent::
3552 - compare a file in the current working directory to its parent::
3442
3553
3443 hg diff foo.c
3554 hg diff foo.c
3444
3555
3445 - compare two historical versions of a directory, with rename info::
3556 - compare two historical versions of a directory, with rename info::
3446
3557
3447 hg diff --git -r 1.0:1.2 lib/
3558 hg diff --git -r 1.0:1.2 lib/
3448
3559
3449 - get change stats relative to the last change on some date::
3560 - get change stats relative to the last change on some date::
3450
3561
3451 hg diff --stat -r "date('may 2')"
3562 hg diff --stat -r "date('may 2')"
3452
3563
3453 - diff all newly-added files that contain a keyword::
3564 - diff all newly-added files that contain a keyword::
3454
3565
3455 hg diff "set:added() and grep(GNU)"
3566 hg diff "set:added() and grep(GNU)"
3456
3567
3457 - compare a revision and its parents::
3568 - compare a revision and its parents::
3458
3569
3459 hg diff -c 9353 # compare against first parent
3570 hg diff -c 9353 # compare against first parent
3460 hg diff -r 9353^:9353 # same using revset syntax
3571 hg diff -r 9353^:9353 # same using revset syntax
3461 hg diff -r 9353^2:9353 # compare against the second parent
3572 hg diff -r 9353^2:9353 # compare against the second parent
3462
3573
3463 Returns 0 on success.
3574 Returns 0 on success.
3464 """
3575 """
3465
3576
3466 revs = opts.get('rev')
3577 revs = opts.get('rev')
3467 change = opts.get('change')
3578 change = opts.get('change')
3468 stat = opts.get('stat')
3579 stat = opts.get('stat')
3469 reverse = opts.get('reverse')
3580 reverse = opts.get('reverse')
3470
3581
3471 if revs and change:
3582 if revs and change:
3472 msg = _('cannot specify --rev and --change at the same time')
3583 msg = _('cannot specify --rev and --change at the same time')
3473 raise error.Abort(msg)
3584 raise error.Abort(msg)
3474 elif change:
3585 elif change:
3475 node2 = scmutil.revsingle(repo, change, None).node()
3586 node2 = scmutil.revsingle(repo, change, None).node()
3476 node1 = repo[node2].p1().node()
3587 node1 = repo[node2].p1().node()
3477 else:
3588 else:
3478 node1, node2 = scmutil.revpair(repo, revs)
3589 node1, node2 = scmutil.revpair(repo, revs)
3479
3590
3480 if reverse:
3591 if reverse:
3481 node1, node2 = node2, node1
3592 node1, node2 = node2, node1
3482
3593
3483 diffopts = patch.diffallopts(ui, opts)
3594 diffopts = patch.diffallopts(ui, opts)
3484 m = scmutil.match(repo[node2], pats, opts)
3595 m = scmutil.match(repo[node2], pats, opts)
3485 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3596 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3486 listsubrepos=opts.get('subrepos'),
3597 listsubrepos=opts.get('subrepos'),
3487 root=opts.get('root'))
3598 root=opts.get('root'))
3488
3599
3489 @command('^export',
3600 @command('^export',
3490 [('o', 'output', '',
3601 [('o', 'output', '',
3491 _('print output to file with formatted name'), _('FORMAT')),
3602 _('print output to file with formatted name'), _('FORMAT')),
3492 ('', 'switch-parent', None, _('diff against the second parent')),
3603 ('', 'switch-parent', None, _('diff against the second parent')),
3493 ('r', 'rev', [], _('revisions to export'), _('REV')),
3604 ('r', 'rev', [], _('revisions to export'), _('REV')),
3494 ] + diffopts,
3605 ] + diffopts,
3495 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3606 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3496 def export(ui, repo, *changesets, **opts):
3607 def export(ui, repo, *changesets, **opts):
3497 """dump the header and diffs for one or more changesets
3608 """dump the header and diffs for one or more changesets
3498
3609
3499 Print the changeset header and diffs for one or more revisions.
3610 Print the changeset header and diffs for one or more revisions.
3500 If no revision is given, the parent of the working directory is used.
3611 If no revision is given, the parent of the working directory is used.
3501
3612
3502 The information shown in the changeset header is: author, date,
3613 The information shown in the changeset header is: author, date,
3503 branch name (if non-default), changeset hash, parent(s) and commit
3614 branch name (if non-default), changeset hash, parent(s) and commit
3504 comment.
3615 comment.
3505
3616
3506 .. note::
3617 .. note::
3507
3618
3508 export may generate unexpected diff output for merge
3619 export may generate unexpected diff output for merge
3509 changesets, as it will compare the merge changeset against its
3620 changesets, as it will compare the merge changeset against its
3510 first parent only.
3621 first parent only.
3511
3622
3512 Output may be to a file, in which case the name of the file is
3623 Output may be to a file, in which case the name of the file is
3513 given using a format string. The formatting rules are as follows:
3624 given using a format string. The formatting rules are as follows:
3514
3625
3515 :``%%``: literal "%" character
3626 :``%%``: literal "%" character
3516 :``%H``: changeset hash (40 hexadecimal digits)
3627 :``%H``: changeset hash (40 hexadecimal digits)
3517 :``%N``: number of patches being generated
3628 :``%N``: number of patches being generated
3518 :``%R``: changeset revision number
3629 :``%R``: changeset revision number
3519 :``%b``: basename of the exporting repository
3630 :``%b``: basename of the exporting repository
3520 :``%h``: short-form changeset hash (12 hexadecimal digits)
3631 :``%h``: short-form changeset hash (12 hexadecimal digits)
3521 :``%m``: first line of the commit message (only alphanumeric characters)
3632 :``%m``: first line of the commit message (only alphanumeric characters)
3522 :``%n``: zero-padded sequence number, starting at 1
3633 :``%n``: zero-padded sequence number, starting at 1
3523 :``%r``: zero-padded changeset revision number
3634 :``%r``: zero-padded changeset revision number
3524
3635
3525 Without the -a/--text option, export will avoid generating diffs
3636 Without the -a/--text option, export will avoid generating diffs
3526 of files it detects as binary. With -a, export will generate a
3637 of files it detects as binary. With -a, export will generate a
3527 diff anyway, probably with undesirable results.
3638 diff anyway, probably with undesirable results.
3528
3639
3529 Use the -g/--git option to generate diffs in the git extended diff
3640 Use the -g/--git option to generate diffs in the git extended diff
3530 format. See :hg:`help diffs` for more information.
3641 format. See :hg:`help diffs` for more information.
3531
3642
3532 With the --switch-parent option, the diff will be against the
3643 With the --switch-parent option, the diff will be against the
3533 second parent. It can be useful to review a merge.
3644 second parent. It can be useful to review a merge.
3534
3645
3535 .. container:: verbose
3646 .. container:: verbose
3536
3647
3537 Examples:
3648 Examples:
3538
3649
3539 - use export and import to transplant a bugfix to the current
3650 - use export and import to transplant a bugfix to the current
3540 branch::
3651 branch::
3541
3652
3542 hg export -r 9353 | hg import -
3653 hg export -r 9353 | hg import -
3543
3654
3544 - export all the changesets between two revisions to a file with
3655 - export all the changesets between two revisions to a file with
3545 rename information::
3656 rename information::
3546
3657
3547 hg export --git -r 123:150 > changes.txt
3658 hg export --git -r 123:150 > changes.txt
3548
3659
3549 - split outgoing changes into a series of patches with
3660 - split outgoing changes into a series of patches with
3550 descriptive names::
3661 descriptive names::
3551
3662
3552 hg export -r "outgoing()" -o "%n-%m.patch"
3663 hg export -r "outgoing()" -o "%n-%m.patch"
3553
3664
3554 Returns 0 on success.
3665 Returns 0 on success.
3555 """
3666 """
3556 changesets += tuple(opts.get('rev', []))
3667 changesets += tuple(opts.get('rev', []))
3557 if not changesets:
3668 if not changesets:
3558 changesets = ['.']
3669 changesets = ['.']
3559 revs = scmutil.revrange(repo, changesets)
3670 revs = scmutil.revrange(repo, changesets)
3560 if not revs:
3671 if not revs:
3561 raise error.Abort(_("export requires at least one changeset"))
3672 raise error.Abort(_("export requires at least one changeset"))
3562 if len(revs) > 1:
3673 if len(revs) > 1:
3563 ui.note(_('exporting patches:\n'))
3674 ui.note(_('exporting patches:\n'))
3564 else:
3675 else:
3565 ui.note(_('exporting patch:\n'))
3676 ui.note(_('exporting patch:\n'))
3566 cmdutil.export(repo, revs, template=opts.get('output'),
3677 cmdutil.export(repo, revs, template=opts.get('output'),
3567 switch_parent=opts.get('switch_parent'),
3678 switch_parent=opts.get('switch_parent'),
3568 opts=patch.diffallopts(ui, opts))
3679 opts=patch.diffallopts(ui, opts))
3569
3680
3570 @command('files',
3681 @command('files',
3571 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3682 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3572 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3683 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3573 ] + walkopts + formatteropts + subrepoopts,
3684 ] + walkopts + formatteropts + subrepoopts,
3574 _('[OPTION]... [PATTERN]...'))
3685 _('[OPTION]... [PATTERN]...'))
3575 def files(ui, repo, *pats, **opts):
3686 def files(ui, repo, *pats, **opts):
3576 """list tracked files
3687 """list tracked files
3577
3688
3578 Print files under Mercurial control in the working directory or
3689 Print files under Mercurial control in the working directory or
3579 specified revision whose names match the given patterns (excluding
3690 specified revision whose names match the given patterns (excluding
3580 removed files).
3691 removed files).
3581
3692
3582 If no patterns are given to match, this command prints the names
3693 If no patterns are given to match, this command prints the names
3583 of all files under Mercurial control in the working directory.
3694 of all files under Mercurial control in the working directory.
3584
3695
3585 .. container:: verbose
3696 .. container:: verbose
3586
3697
3587 Examples:
3698 Examples:
3588
3699
3589 - list all files under the current directory::
3700 - list all files under the current directory::
3590
3701
3591 hg files .
3702 hg files .
3592
3703
3593 - shows sizes and flags for current revision::
3704 - shows sizes and flags for current revision::
3594
3705
3595 hg files -vr .
3706 hg files -vr .
3596
3707
3597 - list all files named README::
3708 - list all files named README::
3598
3709
3599 hg files -I "**/README"
3710 hg files -I "**/README"
3600
3711
3601 - list all binary files::
3712 - list all binary files::
3602
3713
3603 hg files "set:binary()"
3714 hg files "set:binary()"
3604
3715
3605 - find files containing a regular expression::
3716 - find files containing a regular expression::
3606
3717
3607 hg files "set:grep('bob')"
3718 hg files "set:grep('bob')"
3608
3719
3609 - search tracked file contents with xargs and grep::
3720 - search tracked file contents with xargs and grep::
3610
3721
3611 hg files -0 | xargs -0 grep foo
3722 hg files -0 | xargs -0 grep foo
3612
3723
3613 See :hg:`help patterns` and :hg:`help filesets` for more information
3724 See :hg:`help patterns` and :hg:`help filesets` for more information
3614 on specifying file patterns.
3725 on specifying file patterns.
3615
3726
3616 Returns 0 if a match is found, 1 otherwise.
3727 Returns 0 if a match is found, 1 otherwise.
3617
3728
3618 """
3729 """
3619 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3730 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3620
3731
3621 end = '\n'
3732 end = '\n'
3622 if opts.get('print0'):
3733 if opts.get('print0'):
3623 end = '\0'
3734 end = '\0'
3624 fm = ui.formatter('files', opts)
3735 fm = ui.formatter('files', opts)
3625 fmt = '%s' + end
3736 fmt = '%s' + end
3626
3737
3627 m = scmutil.match(ctx, pats, opts)
3738 m = scmutil.match(ctx, pats, opts)
3628 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3739 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3629
3740
3630 fm.end()
3741 fm.end()
3631
3742
3632 return ret
3743 return ret
3633
3744
3634 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3745 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3635 def forget(ui, repo, *pats, **opts):
3746 def forget(ui, repo, *pats, **opts):
3636 """forget the specified files on the next commit
3747 """forget the specified files on the next commit
3637
3748
3638 Mark the specified files so they will no longer be tracked
3749 Mark the specified files so they will no longer be tracked
3639 after the next commit.
3750 after the next commit.
3640
3751
3641 This only removes files from the current branch, not from the
3752 This only removes files from the current branch, not from the
3642 entire project history, and it does not delete them from the
3753 entire project history, and it does not delete them from the
3643 working directory.
3754 working directory.
3644
3755
3645 To delete the file from the working directory, see :hg:`remove`.
3756 To delete the file from the working directory, see :hg:`remove`.
3646
3757
3647 To undo a forget before the next commit, see :hg:`add`.
3758 To undo a forget before the next commit, see :hg:`add`.
3648
3759
3649 .. container:: verbose
3760 .. container:: verbose
3650
3761
3651 Examples:
3762 Examples:
3652
3763
3653 - forget newly-added binary files::
3764 - forget newly-added binary files::
3654
3765
3655 hg forget "set:added() and binary()"
3766 hg forget "set:added() and binary()"
3656
3767
3657 - forget files that would be excluded by .hgignore::
3768 - forget files that would be excluded by .hgignore::
3658
3769
3659 hg forget "set:hgignore()"
3770 hg forget "set:hgignore()"
3660
3771
3661 Returns 0 on success.
3772 Returns 0 on success.
3662 """
3773 """
3663
3774
3664 if not pats:
3775 if not pats:
3665 raise error.Abort(_('no files specified'))
3776 raise error.Abort(_('no files specified'))
3666
3777
3667 m = scmutil.match(repo[None], pats, opts)
3778 m = scmutil.match(repo[None], pats, opts)
3668 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3779 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3669 return rejected and 1 or 0
3780 return rejected and 1 or 0
3670
3781
3671 @command(
3782 @command(
3672 'graft',
3783 'graft',
3673 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3784 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3674 ('c', 'continue', False, _('resume interrupted graft')),
3785 ('c', 'continue', False, _('resume interrupted graft')),
3675 ('e', 'edit', False, _('invoke editor on commit messages')),
3786 ('e', 'edit', False, _('invoke editor on commit messages')),
3676 ('', 'log', None, _('append graft info to log message')),
3787 ('', 'log', None, _('append graft info to log message')),
3677 ('f', 'force', False, _('force graft')),
3788 ('f', 'force', False, _('force graft')),
3678 ('D', 'currentdate', False,
3789 ('D', 'currentdate', False,
3679 _('record the current date as commit date')),
3790 _('record the current date as commit date')),
3680 ('U', 'currentuser', False,
3791 ('U', 'currentuser', False,
3681 _('record the current user as committer'), _('DATE'))]
3792 _('record the current user as committer'), _('DATE'))]
3682 + commitopts2 + mergetoolopts + dryrunopts,
3793 + commitopts2 + mergetoolopts + dryrunopts,
3683 _('[OPTION]... [-r] REV...'))
3794 _('[OPTION]... [-r] REV...'))
3684 def graft(ui, repo, *revs, **opts):
3795 def graft(ui, repo, *revs, **opts):
3685 '''copy changes from other branches onto the current branch
3796 '''copy changes from other branches onto the current branch
3686
3797
3687 This command uses Mercurial's merge logic to copy individual
3798 This command uses Mercurial's merge logic to copy individual
3688 changes from other branches without merging branches in the
3799 changes from other branches without merging branches in the
3689 history graph. This is sometimes known as 'backporting' or
3800 history graph. This is sometimes known as 'backporting' or
3690 'cherry-picking'. By default, graft will copy user, date, and
3801 'cherry-picking'. By default, graft will copy user, date, and
3691 description from the source changesets.
3802 description from the source changesets.
3692
3803
3693 Changesets that are ancestors of the current revision, that have
3804 Changesets that are ancestors of the current revision, that have
3694 already been grafted, or that are merges will be skipped.
3805 already been grafted, or that are merges will be skipped.
3695
3806
3696 If --log is specified, log messages will have a comment appended
3807 If --log is specified, log messages will have a comment appended
3697 of the form::
3808 of the form::
3698
3809
3699 (grafted from CHANGESETHASH)
3810 (grafted from CHANGESETHASH)
3700
3811
3701 If --force is specified, revisions will be grafted even if they
3812 If --force is specified, revisions will be grafted even if they
3702 are already ancestors of or have been grafted to the destination.
3813 are already ancestors of or have been grafted to the destination.
3703 This is useful when the revisions have since been backed out.
3814 This is useful when the revisions have since been backed out.
3704
3815
3705 If a graft merge results in conflicts, the graft process is
3816 If a graft merge results in conflicts, the graft process is
3706 interrupted so that the current merge can be manually resolved.
3817 interrupted so that the current merge can be manually resolved.
3707 Once all conflicts are addressed, the graft process can be
3818 Once all conflicts are addressed, the graft process can be
3708 continued with the -c/--continue option.
3819 continued with the -c/--continue option.
3709
3820
3710 .. note::
3821 .. note::
3711
3822
3712 The -c/--continue option does not reapply earlier options, except
3823 The -c/--continue option does not reapply earlier options, except
3713 for --force.
3824 for --force.
3714
3825
3715 .. container:: verbose
3826 .. container:: verbose
3716
3827
3717 Examples:
3828 Examples:
3718
3829
3719 - copy a single change to the stable branch and edit its description::
3830 - copy a single change to the stable branch and edit its description::
3720
3831
3721 hg update stable
3832 hg update stable
3722 hg graft --edit 9393
3833 hg graft --edit 9393
3723
3834
3724 - graft a range of changesets with one exception, updating dates::
3835 - graft a range of changesets with one exception, updating dates::
3725
3836
3726 hg graft -D "2085::2093 and not 2091"
3837 hg graft -D "2085::2093 and not 2091"
3727
3838
3728 - continue a graft after resolving conflicts::
3839 - continue a graft after resolving conflicts::
3729
3840
3730 hg graft -c
3841 hg graft -c
3731
3842
3732 - show the source of a grafted changeset::
3843 - show the source of a grafted changeset::
3733
3844
3734 hg log --debug -r .
3845 hg log --debug -r .
3735
3846
3736 See :hg:`help revisions` and :hg:`help revsets` for more about
3847 See :hg:`help revisions` and :hg:`help revsets` for more about
3737 specifying revisions.
3848 specifying revisions.
3738
3849
3739 Returns 0 on successful completion.
3850 Returns 0 on successful completion.
3740 '''
3851 '''
3741 wlock = None
3852 wlock = None
3742 try:
3853 try:
3743 wlock = repo.wlock()
3854 wlock = repo.wlock()
3744 return _dograft(ui, repo, *revs, **opts)
3855 return _dograft(ui, repo, *revs, **opts)
3745 finally:
3856 finally:
3746 release(wlock)
3857 release(wlock)
3747
3858
3748 def _dograft(ui, repo, *revs, **opts):
3859 def _dograft(ui, repo, *revs, **opts):
3749 revs = list(revs)
3860 revs = list(revs)
3750 revs.extend(opts['rev'])
3861 revs.extend(opts['rev'])
3751
3862
3752 if not opts.get('user') and opts.get('currentuser'):
3863 if not opts.get('user') and opts.get('currentuser'):
3753 opts['user'] = ui.username()
3864 opts['user'] = ui.username()
3754 if not opts.get('date') and opts.get('currentdate'):
3865 if not opts.get('date') and opts.get('currentdate'):
3755 opts['date'] = "%d %d" % util.makedate()
3866 opts['date'] = "%d %d" % util.makedate()
3756
3867
3757 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3868 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3758
3869
3759 cont = False
3870 cont = False
3760 if opts['continue']:
3871 if opts['continue']:
3761 cont = True
3872 cont = True
3762 if revs:
3873 if revs:
3763 raise error.Abort(_("can't specify --continue and revisions"))
3874 raise error.Abort(_("can't specify --continue and revisions"))
3764 # read in unfinished revisions
3875 # read in unfinished revisions
3765 try:
3876 try:
3766 nodes = repo.vfs.read('graftstate').splitlines()
3877 nodes = repo.vfs.read('graftstate').splitlines()
3767 revs = [repo[node].rev() for node in nodes]
3878 revs = [repo[node].rev() for node in nodes]
3768 except IOError as inst:
3879 except IOError as inst:
3769 if inst.errno != errno.ENOENT:
3880 if inst.errno != errno.ENOENT:
3770 raise
3881 raise
3771 raise error.Abort(_("no graft state found, can't continue"))
3882 raise error.Abort(_("no graft state found, can't continue"))
3772 else:
3883 else:
3773 cmdutil.checkunfinished(repo)
3884 cmdutil.checkunfinished(repo)
3774 cmdutil.bailifchanged(repo)
3885 cmdutil.bailifchanged(repo)
3775 if not revs:
3886 if not revs:
3776 raise error.Abort(_('no revisions specified'))
3887 raise error.Abort(_('no revisions specified'))
3777 revs = scmutil.revrange(repo, revs)
3888 revs = scmutil.revrange(repo, revs)
3778
3889
3779 skipped = set()
3890 skipped = set()
3780 # check for merges
3891 # check for merges
3781 for rev in repo.revs('%ld and merge()', revs):
3892 for rev in repo.revs('%ld and merge()', revs):
3782 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3893 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3783 skipped.add(rev)
3894 skipped.add(rev)
3784 revs = [r for r in revs if r not in skipped]
3895 revs = [r for r in revs if r not in skipped]
3785 if not revs:
3896 if not revs:
3786 return -1
3897 return -1
3787
3898
3788 # Don't check in the --continue case, in effect retaining --force across
3899 # Don't check in the --continue case, in effect retaining --force across
3789 # --continues. That's because without --force, any revisions we decided to
3900 # --continues. That's because without --force, any revisions we decided to
3790 # skip would have been filtered out here, so they wouldn't have made their
3901 # skip would have been filtered out here, so they wouldn't have made their
3791 # way to the graftstate. With --force, any revisions we would have otherwise
3902 # way to the graftstate. With --force, any revisions we would have otherwise
3792 # skipped would not have been filtered out, and if they hadn't been applied
3903 # skipped would not have been filtered out, and if they hadn't been applied
3793 # already, they'd have been in the graftstate.
3904 # already, they'd have been in the graftstate.
3794 if not (cont or opts.get('force')):
3905 if not (cont or opts.get('force')):
3795 # check for ancestors of dest branch
3906 # check for ancestors of dest branch
3796 crev = repo['.'].rev()
3907 crev = repo['.'].rev()
3797 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3908 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3798 # Cannot use x.remove(y) on smart set, this has to be a list.
3909 # Cannot use x.remove(y) on smart set, this has to be a list.
3799 # XXX make this lazy in the future
3910 # XXX make this lazy in the future
3800 revs = list(revs)
3911 revs = list(revs)
3801 # don't mutate while iterating, create a copy
3912 # don't mutate while iterating, create a copy
3802 for rev in list(revs):
3913 for rev in list(revs):
3803 if rev in ancestors:
3914 if rev in ancestors:
3804 ui.warn(_('skipping ancestor revision %d:%s\n') %
3915 ui.warn(_('skipping ancestor revision %d:%s\n') %
3805 (rev, repo[rev]))
3916 (rev, repo[rev]))
3806 # XXX remove on list is slow
3917 # XXX remove on list is slow
3807 revs.remove(rev)
3918 revs.remove(rev)
3808 if not revs:
3919 if not revs:
3809 return -1
3920 return -1
3810
3921
3811 # analyze revs for earlier grafts
3922 # analyze revs for earlier grafts
3812 ids = {}
3923 ids = {}
3813 for ctx in repo.set("%ld", revs):
3924 for ctx in repo.set("%ld", revs):
3814 ids[ctx.hex()] = ctx.rev()
3925 ids[ctx.hex()] = ctx.rev()
3815 n = ctx.extra().get('source')
3926 n = ctx.extra().get('source')
3816 if n:
3927 if n:
3817 ids[n] = ctx.rev()
3928 ids[n] = ctx.rev()
3818
3929
3819 # check ancestors for earlier grafts
3930 # check ancestors for earlier grafts
3820 ui.debug('scanning for duplicate grafts\n')
3931 ui.debug('scanning for duplicate grafts\n')
3821
3932
3822 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3933 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3823 ctx = repo[rev]
3934 ctx = repo[rev]
3824 n = ctx.extra().get('source')
3935 n = ctx.extra().get('source')
3825 if n in ids:
3936 if n in ids:
3826 try:
3937 try:
3827 r = repo[n].rev()
3938 r = repo[n].rev()
3828 except error.RepoLookupError:
3939 except error.RepoLookupError:
3829 r = None
3940 r = None
3830 if r in revs:
3941 if r in revs:
3831 ui.warn(_('skipping revision %d:%s '
3942 ui.warn(_('skipping revision %d:%s '
3832 '(already grafted to %d:%s)\n')
3943 '(already grafted to %d:%s)\n')
3833 % (r, repo[r], rev, ctx))
3944 % (r, repo[r], rev, ctx))
3834 revs.remove(r)
3945 revs.remove(r)
3835 elif ids[n] in revs:
3946 elif ids[n] in revs:
3836 if r is None:
3947 if r is None:
3837 ui.warn(_('skipping already grafted revision %d:%s '
3948 ui.warn(_('skipping already grafted revision %d:%s '
3838 '(%d:%s also has unknown origin %s)\n')
3949 '(%d:%s also has unknown origin %s)\n')
3839 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3950 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3840 else:
3951 else:
3841 ui.warn(_('skipping already grafted revision %d:%s '
3952 ui.warn(_('skipping already grafted revision %d:%s '
3842 '(%d:%s also has origin %d:%s)\n')
3953 '(%d:%s also has origin %d:%s)\n')
3843 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3954 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3844 revs.remove(ids[n])
3955 revs.remove(ids[n])
3845 elif ctx.hex() in ids:
3956 elif ctx.hex() in ids:
3846 r = ids[ctx.hex()]
3957 r = ids[ctx.hex()]
3847 ui.warn(_('skipping already grafted revision %d:%s '
3958 ui.warn(_('skipping already grafted revision %d:%s '
3848 '(was grafted from %d:%s)\n') %
3959 '(was grafted from %d:%s)\n') %
3849 (r, repo[r], rev, ctx))
3960 (r, repo[r], rev, ctx))
3850 revs.remove(r)
3961 revs.remove(r)
3851 if not revs:
3962 if not revs:
3852 return -1
3963 return -1
3853
3964
3854 try:
3965 try:
3855 for pos, ctx in enumerate(repo.set("%ld", revs)):
3966 for pos, ctx in enumerate(repo.set("%ld", revs)):
3856 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3967 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3857 ctx.description().split('\n', 1)[0])
3968 ctx.description().split('\n', 1)[0])
3858 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3969 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3859 if names:
3970 if names:
3860 desc += ' (%s)' % ' '.join(names)
3971 desc += ' (%s)' % ' '.join(names)
3861 ui.status(_('grafting %s\n') % desc)
3972 ui.status(_('grafting %s\n') % desc)
3862 if opts.get('dry_run'):
3973 if opts.get('dry_run'):
3863 continue
3974 continue
3864
3975
3865 extra = ctx.extra().copy()
3976 extra = ctx.extra().copy()
3866 del extra['branch']
3977 del extra['branch']
3867 source = extra.get('source')
3978 source = extra.get('source')
3868 if source:
3979 if source:
3869 extra['intermediate-source'] = ctx.hex()
3980 extra['intermediate-source'] = ctx.hex()
3870 else:
3981 else:
3871 extra['source'] = ctx.hex()
3982 extra['source'] = ctx.hex()
3872 user = ctx.user()
3983 user = ctx.user()
3873 if opts.get('user'):
3984 if opts.get('user'):
3874 user = opts['user']
3985 user = opts['user']
3875 date = ctx.date()
3986 date = ctx.date()
3876 if opts.get('date'):
3987 if opts.get('date'):
3877 date = opts['date']
3988 date = opts['date']
3878 message = ctx.description()
3989 message = ctx.description()
3879 if opts.get('log'):
3990 if opts.get('log'):
3880 message += '\n(grafted from %s)' % ctx.hex()
3991 message += '\n(grafted from %s)' % ctx.hex()
3881
3992
3882 # we don't merge the first commit when continuing
3993 # we don't merge the first commit when continuing
3883 if not cont:
3994 if not cont:
3884 # perform the graft merge with p1(rev) as 'ancestor'
3995 # perform the graft merge with p1(rev) as 'ancestor'
3885 try:
3996 try:
3886 # ui.forcemerge is an internal variable, do not document
3997 # ui.forcemerge is an internal variable, do not document
3887 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3998 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3888 'graft')
3999 'graft')
3889 stats = mergemod.graft(repo, ctx, ctx.p1(),
4000 stats = mergemod.graft(repo, ctx, ctx.p1(),
3890 ['local', 'graft'])
4001 ['local', 'graft'])
3891 finally:
4002 finally:
3892 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
4003 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3893 # report any conflicts
4004 # report any conflicts
3894 if stats and stats[3] > 0:
4005 if stats and stats[3] > 0:
3895 # write out state for --continue
4006 # write out state for --continue
3896 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
4007 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3897 repo.vfs.write('graftstate', ''.join(nodelines))
4008 repo.vfs.write('graftstate', ''.join(nodelines))
3898 extra = ''
4009 extra = ''
3899 if opts.get('user'):
4010 if opts.get('user'):
3900 extra += ' --user %s' % opts['user']
4011 extra += ' --user %s' % opts['user']
3901 if opts.get('date'):
4012 if opts.get('date'):
3902 extra += ' --date %s' % opts['date']
4013 extra += ' --date %s' % opts['date']
3903 if opts.get('log'):
4014 if opts.get('log'):
3904 extra += ' --log'
4015 extra += ' --log'
3905 hint=_('use hg resolve and hg graft --continue%s') % extra
4016 hint=_('use hg resolve and hg graft --continue%s') % extra
3906 raise error.Abort(
4017 raise error.Abort(
3907 _("unresolved conflicts, can't continue"),
4018 _("unresolved conflicts, can't continue"),
3908 hint=hint)
4019 hint=hint)
3909 else:
4020 else:
3910 cont = False
4021 cont = False
3911
4022
3912 # commit
4023 # commit
3913 node = repo.commit(text=message, user=user,
4024 node = repo.commit(text=message, user=user,
3914 date=date, extra=extra, editor=editor)
4025 date=date, extra=extra, editor=editor)
3915 if node is None:
4026 if node is None:
3916 ui.warn(
4027 ui.warn(
3917 _('note: graft of %d:%s created no changes to commit\n') %
4028 _('note: graft of %d:%s created no changes to commit\n') %
3918 (ctx.rev(), ctx))
4029 (ctx.rev(), ctx))
3919 finally:
4030 finally:
3920 # TODO: get rid of this meaningless try/finally enclosing.
4031 # TODO: get rid of this meaningless try/finally enclosing.
3921 # this is kept only to reduce changes in a patch.
4032 # this is kept only to reduce changes in a patch.
3922 pass
4033 pass
3923
4034
3924 # remove state when we complete successfully
4035 # remove state when we complete successfully
3925 if not opts.get('dry_run'):
4036 if not opts.get('dry_run'):
3926 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
4037 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3927
4038
3928 return 0
4039 return 0
3929
4040
3930 @command('grep',
4041 @command('grep',
3931 [('0', 'print0', None, _('end fields with NUL')),
4042 [('0', 'print0', None, _('end fields with NUL')),
3932 ('', 'all', None, _('print all revisions that match')),
4043 ('', 'all', None, _('print all revisions that match')),
3933 ('a', 'text', None, _('treat all files as text')),
4044 ('a', 'text', None, _('treat all files as text')),
3934 ('f', 'follow', None,
4045 ('f', 'follow', None,
3935 _('follow changeset history,'
4046 _('follow changeset history,'
3936 ' or file history across copies and renames')),
4047 ' or file history across copies and renames')),
3937 ('i', 'ignore-case', None, _('ignore case when matching')),
4048 ('i', 'ignore-case', None, _('ignore case when matching')),
3938 ('l', 'files-with-matches', None,
4049 ('l', 'files-with-matches', None,
3939 _('print only filenames and revisions that match')),
4050 _('print only filenames and revisions that match')),
3940 ('n', 'line-number', None, _('print matching line numbers')),
4051 ('n', 'line-number', None, _('print matching line numbers')),
3941 ('r', 'rev', [],
4052 ('r', 'rev', [],
3942 _('only search files changed within revision range'), _('REV')),
4053 _('only search files changed within revision range'), _('REV')),
3943 ('u', 'user', None, _('list the author (long with -v)')),
4054 ('u', 'user', None, _('list the author (long with -v)')),
3944 ('d', 'date', None, _('list the date (short with -q)')),
4055 ('d', 'date', None, _('list the date (short with -q)')),
3945 ] + walkopts,
4056 ] + walkopts,
3946 _('[OPTION]... PATTERN [FILE]...'),
4057 _('[OPTION]... PATTERN [FILE]...'),
3947 inferrepo=True)
4058 inferrepo=True)
3948 def grep(ui, repo, pattern, *pats, **opts):
4059 def grep(ui, repo, pattern, *pats, **opts):
3949 """search for a pattern in specified files and revisions
4060 """search for a pattern in specified files and revisions
3950
4061
3951 Search revisions of files for a regular expression.
4062 Search revisions of files for a regular expression.
3952
4063
3953 This command behaves differently than Unix grep. It only accepts
4064 This command behaves differently than Unix grep. It only accepts
3954 Python/Perl regexps. It searches repository history, not the
4065 Python/Perl regexps. It searches repository history, not the
3955 working directory. It always prints the revision number in which a
4066 working directory. It always prints the revision number in which a
3956 match appears.
4067 match appears.
3957
4068
3958 By default, grep only prints output for the first revision of a
4069 By default, grep only prints output for the first revision of a
3959 file in which it finds a match. To get it to print every revision
4070 file in which it finds a match. To get it to print every revision
3960 that contains a change in match status ("-" for a match that
4071 that contains a change in match status ("-" for a match that
3961 becomes a non-match, or "+" for a non-match that becomes a match),
4072 becomes a non-match, or "+" for a non-match that becomes a match),
3962 use the --all flag.
4073 use the --all flag.
3963
4074
3964 Returns 0 if a match is found, 1 otherwise.
4075 Returns 0 if a match is found, 1 otherwise.
3965 """
4076 """
3966 reflags = re.M
4077 reflags = re.M
3967 if opts.get('ignore_case'):
4078 if opts.get('ignore_case'):
3968 reflags |= re.I
4079 reflags |= re.I
3969 try:
4080 try:
3970 regexp = util.re.compile(pattern, reflags)
4081 regexp = util.re.compile(pattern, reflags)
3971 except re.error as inst:
4082 except re.error as inst:
3972 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
4083 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3973 return 1
4084 return 1
3974 sep, eol = ':', '\n'
4085 sep, eol = ':', '\n'
3975 if opts.get('print0'):
4086 if opts.get('print0'):
3976 sep = eol = '\0'
4087 sep = eol = '\0'
3977
4088
3978 getfile = util.lrucachefunc(repo.file)
4089 getfile = util.lrucachefunc(repo.file)
3979
4090
3980 def matchlines(body):
4091 def matchlines(body):
3981 begin = 0
4092 begin = 0
3982 linenum = 0
4093 linenum = 0
3983 while begin < len(body):
4094 while begin < len(body):
3984 match = regexp.search(body, begin)
4095 match = regexp.search(body, begin)
3985 if not match:
4096 if not match:
3986 break
4097 break
3987 mstart, mend = match.span()
4098 mstart, mend = match.span()
3988 linenum += body.count('\n', begin, mstart) + 1
4099 linenum += body.count('\n', begin, mstart) + 1
3989 lstart = body.rfind('\n', begin, mstart) + 1 or begin
4100 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3990 begin = body.find('\n', mend) + 1 or len(body) + 1
4101 begin = body.find('\n', mend) + 1 or len(body) + 1
3991 lend = begin - 1
4102 lend = begin - 1
3992 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
4103 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3993
4104
3994 class linestate(object):
4105 class linestate(object):
3995 def __init__(self, line, linenum, colstart, colend):
4106 def __init__(self, line, linenum, colstart, colend):
3996 self.line = line
4107 self.line = line
3997 self.linenum = linenum
4108 self.linenum = linenum
3998 self.colstart = colstart
4109 self.colstart = colstart
3999 self.colend = colend
4110 self.colend = colend
4000
4111
4001 def __hash__(self):
4112 def __hash__(self):
4002 return hash((self.linenum, self.line))
4113 return hash((self.linenum, self.line))
4003
4114
4004 def __eq__(self, other):
4115 def __eq__(self, other):
4005 return self.line == other.line
4116 return self.line == other.line
4006
4117
4007 def __iter__(self):
4118 def __iter__(self):
4008 yield (self.line[:self.colstart], '')
4119 yield (self.line[:self.colstart], '')
4009 yield (self.line[self.colstart:self.colend], 'grep.match')
4120 yield (self.line[self.colstart:self.colend], 'grep.match')
4010 rest = self.line[self.colend:]
4121 rest = self.line[self.colend:]
4011 while rest != '':
4122 while rest != '':
4012 match = regexp.search(rest)
4123 match = regexp.search(rest)
4013 if not match:
4124 if not match:
4014 yield (rest, '')
4125 yield (rest, '')
4015 break
4126 break
4016 mstart, mend = match.span()
4127 mstart, mend = match.span()
4017 yield (rest[:mstart], '')
4128 yield (rest[:mstart], '')
4018 yield (rest[mstart:mend], 'grep.match')
4129 yield (rest[mstart:mend], 'grep.match')
4019 rest = rest[mend:]
4130 rest = rest[mend:]
4020
4131
4021 matches = {}
4132 matches = {}
4022 copies = {}
4133 copies = {}
4023 def grepbody(fn, rev, body):
4134 def grepbody(fn, rev, body):
4024 matches[rev].setdefault(fn, [])
4135 matches[rev].setdefault(fn, [])
4025 m = matches[rev][fn]
4136 m = matches[rev][fn]
4026 for lnum, cstart, cend, line in matchlines(body):
4137 for lnum, cstart, cend, line in matchlines(body):
4027 s = linestate(line, lnum, cstart, cend)
4138 s = linestate(line, lnum, cstart, cend)
4028 m.append(s)
4139 m.append(s)
4029
4140
4030 def difflinestates(a, b):
4141 def difflinestates(a, b):
4031 sm = difflib.SequenceMatcher(None, a, b)
4142 sm = difflib.SequenceMatcher(None, a, b)
4032 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
4143 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
4033 if tag == 'insert':
4144 if tag == 'insert':
4034 for i in xrange(blo, bhi):
4145 for i in xrange(blo, bhi):
4035 yield ('+', b[i])
4146 yield ('+', b[i])
4036 elif tag == 'delete':
4147 elif tag == 'delete':
4037 for i in xrange(alo, ahi):
4148 for i in xrange(alo, ahi):
4038 yield ('-', a[i])
4149 yield ('-', a[i])
4039 elif tag == 'replace':
4150 elif tag == 'replace':
4040 for i in xrange(alo, ahi):
4151 for i in xrange(alo, ahi):
4041 yield ('-', a[i])
4152 yield ('-', a[i])
4042 for i in xrange(blo, bhi):
4153 for i in xrange(blo, bhi):
4043 yield ('+', b[i])
4154 yield ('+', b[i])
4044
4155
4045 def display(fn, ctx, pstates, states):
4156 def display(fn, ctx, pstates, states):
4046 rev = ctx.rev()
4157 rev = ctx.rev()
4047 if ui.quiet:
4158 if ui.quiet:
4048 datefunc = util.shortdate
4159 datefunc = util.shortdate
4049 else:
4160 else:
4050 datefunc = util.datestr
4161 datefunc = util.datestr
4051 found = False
4162 found = False
4052 @util.cachefunc
4163 @util.cachefunc
4053 def binary():
4164 def binary():
4054 flog = getfile(fn)
4165 flog = getfile(fn)
4055 return util.binary(flog.read(ctx.filenode(fn)))
4166 return util.binary(flog.read(ctx.filenode(fn)))
4056
4167
4057 if opts.get('all'):
4168 if opts.get('all'):
4058 iter = difflinestates(pstates, states)
4169 iter = difflinestates(pstates, states)
4059 else:
4170 else:
4060 iter = [('', l) for l in states]
4171 iter = [('', l) for l in states]
4061 for change, l in iter:
4172 for change, l in iter:
4062 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
4173 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
4063
4174
4064 if opts.get('line_number'):
4175 if opts.get('line_number'):
4065 cols.append((str(l.linenum), 'grep.linenumber'))
4176 cols.append((str(l.linenum), 'grep.linenumber'))
4066 if opts.get('all'):
4177 if opts.get('all'):
4067 cols.append((change, 'grep.change'))
4178 cols.append((change, 'grep.change'))
4068 if opts.get('user'):
4179 if opts.get('user'):
4069 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
4180 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
4070 if opts.get('date'):
4181 if opts.get('date'):
4071 cols.append((datefunc(ctx.date()), 'grep.date'))
4182 cols.append((datefunc(ctx.date()), 'grep.date'))
4072 for col, label in cols[:-1]:
4183 for col, label in cols[:-1]:
4073 ui.write(col, label=label)
4184 ui.write(col, label=label)
4074 ui.write(sep, label='grep.sep')
4185 ui.write(sep, label='grep.sep')
4075 ui.write(cols[-1][0], label=cols[-1][1])
4186 ui.write(cols[-1][0], label=cols[-1][1])
4076 if not opts.get('files_with_matches'):
4187 if not opts.get('files_with_matches'):
4077 ui.write(sep, label='grep.sep')
4188 ui.write(sep, label='grep.sep')
4078 if not opts.get('text') and binary():
4189 if not opts.get('text') and binary():
4079 ui.write(" Binary file matches")
4190 ui.write(" Binary file matches")
4080 else:
4191 else:
4081 for s, label in l:
4192 for s, label in l:
4082 ui.write(s, label=label)
4193 ui.write(s, label=label)
4083 ui.write(eol)
4194 ui.write(eol)
4084 found = True
4195 found = True
4085 if opts.get('files_with_matches'):
4196 if opts.get('files_with_matches'):
4086 break
4197 break
4087 return found
4198 return found
4088
4199
4089 skip = {}
4200 skip = {}
4090 revfiles = {}
4201 revfiles = {}
4091 matchfn = scmutil.match(repo[None], pats, opts)
4202 matchfn = scmutil.match(repo[None], pats, opts)
4092 found = False
4203 found = False
4093 follow = opts.get('follow')
4204 follow = opts.get('follow')
4094
4205
4095 def prep(ctx, fns):
4206 def prep(ctx, fns):
4096 rev = ctx.rev()
4207 rev = ctx.rev()
4097 pctx = ctx.p1()
4208 pctx = ctx.p1()
4098 parent = pctx.rev()
4209 parent = pctx.rev()
4099 matches.setdefault(rev, {})
4210 matches.setdefault(rev, {})
4100 matches.setdefault(parent, {})
4211 matches.setdefault(parent, {})
4101 files = revfiles.setdefault(rev, [])
4212 files = revfiles.setdefault(rev, [])
4102 for fn in fns:
4213 for fn in fns:
4103 flog = getfile(fn)
4214 flog = getfile(fn)
4104 try:
4215 try:
4105 fnode = ctx.filenode(fn)
4216 fnode = ctx.filenode(fn)
4106 except error.LookupError:
4217 except error.LookupError:
4107 continue
4218 continue
4108
4219
4109 copied = flog.renamed(fnode)
4220 copied = flog.renamed(fnode)
4110 copy = follow and copied and copied[0]
4221 copy = follow and copied and copied[0]
4111 if copy:
4222 if copy:
4112 copies.setdefault(rev, {})[fn] = copy
4223 copies.setdefault(rev, {})[fn] = copy
4113 if fn in skip:
4224 if fn in skip:
4114 if copy:
4225 if copy:
4115 skip[copy] = True
4226 skip[copy] = True
4116 continue
4227 continue
4117 files.append(fn)
4228 files.append(fn)
4118
4229
4119 if fn not in matches[rev]:
4230 if fn not in matches[rev]:
4120 grepbody(fn, rev, flog.read(fnode))
4231 grepbody(fn, rev, flog.read(fnode))
4121
4232
4122 pfn = copy or fn
4233 pfn = copy or fn
4123 if pfn not in matches[parent]:
4234 if pfn not in matches[parent]:
4124 try:
4235 try:
4125 fnode = pctx.filenode(pfn)
4236 fnode = pctx.filenode(pfn)
4126 grepbody(pfn, parent, flog.read(fnode))
4237 grepbody(pfn, parent, flog.read(fnode))
4127 except error.LookupError:
4238 except error.LookupError:
4128 pass
4239 pass
4129
4240
4130 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4241 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4131 rev = ctx.rev()
4242 rev = ctx.rev()
4132 parent = ctx.p1().rev()
4243 parent = ctx.p1().rev()
4133 for fn in sorted(revfiles.get(rev, [])):
4244 for fn in sorted(revfiles.get(rev, [])):
4134 states = matches[rev][fn]
4245 states = matches[rev][fn]
4135 copy = copies.get(rev, {}).get(fn)
4246 copy = copies.get(rev, {}).get(fn)
4136 if fn in skip:
4247 if fn in skip:
4137 if copy:
4248 if copy:
4138 skip[copy] = True
4249 skip[copy] = True
4139 continue
4250 continue
4140 pstates = matches.get(parent, {}).get(copy or fn, [])
4251 pstates = matches.get(parent, {}).get(copy or fn, [])
4141 if pstates or states:
4252 if pstates or states:
4142 r = display(fn, ctx, pstates, states)
4253 r = display(fn, ctx, pstates, states)
4143 found = found or r
4254 found = found or r
4144 if r and not opts.get('all'):
4255 if r and not opts.get('all'):
4145 skip[fn] = True
4256 skip[fn] = True
4146 if copy:
4257 if copy:
4147 skip[copy] = True
4258 skip[copy] = True
4148 del matches[rev]
4259 del matches[rev]
4149 del revfiles[rev]
4260 del revfiles[rev]
4150
4261
4151 return not found
4262 return not found
4152
4263
4153 @command('heads',
4264 @command('heads',
4154 [('r', 'rev', '',
4265 [('r', 'rev', '',
4155 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
4266 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
4156 ('t', 'topo', False, _('show topological heads only')),
4267 ('t', 'topo', False, _('show topological heads only')),
4157 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
4268 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
4158 ('c', 'closed', False, _('show normal and closed branch heads')),
4269 ('c', 'closed', False, _('show normal and closed branch heads')),
4159 ] + templateopts,
4270 ] + templateopts,
4160 _('[-ct] [-r STARTREV] [REV]...'))
4271 _('[-ct] [-r STARTREV] [REV]...'))
4161 def heads(ui, repo, *branchrevs, **opts):
4272 def heads(ui, repo, *branchrevs, **opts):
4162 """show branch heads
4273 """show branch heads
4163
4274
4164 With no arguments, show all open branch heads in the repository.
4275 With no arguments, show all open branch heads in the repository.
4165 Branch heads are changesets that have no descendants on the
4276 Branch heads are changesets that have no descendants on the
4166 same branch. They are where development generally takes place and
4277 same branch. They are where development generally takes place and
4167 are the usual targets for update and merge operations.
4278 are the usual targets for update and merge operations.
4168
4279
4169 If one or more REVs are given, only open branch heads on the
4280 If one or more REVs are given, only open branch heads on the
4170 branches associated with the specified changesets are shown. This
4281 branches associated with the specified changesets are shown. This
4171 means that you can use :hg:`heads .` to see the heads on the
4282 means that you can use :hg:`heads .` to see the heads on the
4172 currently checked-out branch.
4283 currently checked-out branch.
4173
4284
4174 If -c/--closed is specified, also show branch heads marked closed
4285 If -c/--closed is specified, also show branch heads marked closed
4175 (see :hg:`commit --close-branch`).
4286 (see :hg:`commit --close-branch`).
4176
4287
4177 If STARTREV is specified, only those heads that are descendants of
4288 If STARTREV is specified, only those heads that are descendants of
4178 STARTREV will be displayed.
4289 STARTREV will be displayed.
4179
4290
4180 If -t/--topo is specified, named branch mechanics will be ignored and only
4291 If -t/--topo is specified, named branch mechanics will be ignored and only
4181 topological heads (changesets with no children) will be shown.
4292 topological heads (changesets with no children) will be shown.
4182
4293
4183 Returns 0 if matching heads are found, 1 if not.
4294 Returns 0 if matching heads are found, 1 if not.
4184 """
4295 """
4185
4296
4186 start = None
4297 start = None
4187 if 'rev' in opts:
4298 if 'rev' in opts:
4188 start = scmutil.revsingle(repo, opts['rev'], None).node()
4299 start = scmutil.revsingle(repo, opts['rev'], None).node()
4189
4300
4190 if opts.get('topo'):
4301 if opts.get('topo'):
4191 heads = [repo[h] for h in repo.heads(start)]
4302 heads = [repo[h] for h in repo.heads(start)]
4192 else:
4303 else:
4193 heads = []
4304 heads = []
4194 for branch in repo.branchmap():
4305 for branch in repo.branchmap():
4195 heads += repo.branchheads(branch, start, opts.get('closed'))
4306 heads += repo.branchheads(branch, start, opts.get('closed'))
4196 heads = [repo[h] for h in heads]
4307 heads = [repo[h] for h in heads]
4197
4308
4198 if branchrevs:
4309 if branchrevs:
4199 branches = set(repo[br].branch() for br in branchrevs)
4310 branches = set(repo[br].branch() for br in branchrevs)
4200 heads = [h for h in heads if h.branch() in branches]
4311 heads = [h for h in heads if h.branch() in branches]
4201
4312
4202 if opts.get('active') and branchrevs:
4313 if opts.get('active') and branchrevs:
4203 dagheads = repo.heads(start)
4314 dagheads = repo.heads(start)
4204 heads = [h for h in heads if h.node() in dagheads]
4315 heads = [h for h in heads if h.node() in dagheads]
4205
4316
4206 if branchrevs:
4317 if branchrevs:
4207 haveheads = set(h.branch() for h in heads)
4318 haveheads = set(h.branch() for h in heads)
4208 if branches - haveheads:
4319 if branches - haveheads:
4209 headless = ', '.join(b for b in branches - haveheads)
4320 headless = ', '.join(b for b in branches - haveheads)
4210 msg = _('no open branch heads found on branches %s')
4321 msg = _('no open branch heads found on branches %s')
4211 if opts.get('rev'):
4322 if opts.get('rev'):
4212 msg += _(' (started at %s)') % opts['rev']
4323 msg += _(' (started at %s)') % opts['rev']
4213 ui.warn((msg + '\n') % headless)
4324 ui.warn((msg + '\n') % headless)
4214
4325
4215 if not heads:
4326 if not heads:
4216 return 1
4327 return 1
4217
4328
4218 heads = sorted(heads, key=lambda x: -x.rev())
4329 heads = sorted(heads, key=lambda x: -x.rev())
4219 displayer = cmdutil.show_changeset(ui, repo, opts)
4330 displayer = cmdutil.show_changeset(ui, repo, opts)
4220 for ctx in heads:
4331 for ctx in heads:
4221 displayer.show(ctx)
4332 displayer.show(ctx)
4222 displayer.close()
4333 displayer.close()
4223
4334
4224 @command('help',
4335 @command('help',
4225 [('e', 'extension', None, _('show only help for extensions')),
4336 [('e', 'extension', None, _('show only help for extensions')),
4226 ('c', 'command', None, _('show only help for commands')),
4337 ('c', 'command', None, _('show only help for commands')),
4227 ('k', 'keyword', None, _('show topics matching keyword')),
4338 ('k', 'keyword', None, _('show topics matching keyword')),
4228 ],
4339 ],
4229 _('[-eck] [TOPIC]'),
4340 _('[-eck] [TOPIC]'),
4230 norepo=True)
4341 norepo=True)
4231 def help_(ui, name=None, **opts):
4342 def help_(ui, name=None, **opts):
4232 """show help for a given topic or a help overview
4343 """show help for a given topic or a help overview
4233
4344
4234 With no arguments, print a list of commands with short help messages.
4345 With no arguments, print a list of commands with short help messages.
4235
4346
4236 Given a topic, extension, or command name, print help for that
4347 Given a topic, extension, or command name, print help for that
4237 topic.
4348 topic.
4238
4349
4239 Returns 0 if successful.
4350 Returns 0 if successful.
4240 """
4351 """
4241
4352
4242 textwidth = min(ui.termwidth(), 80) - 2
4353 textwidth = min(ui.termwidth(), 80) - 2
4243
4354
4244 keep = []
4355 keep = []
4245 if ui.verbose:
4356 if ui.verbose:
4246 keep.append('verbose')
4357 keep.append('verbose')
4247 if sys.platform.startswith('win'):
4358 if sys.platform.startswith('win'):
4248 keep.append('windows')
4359 keep.append('windows')
4249 elif sys.platform == 'OpenVMS':
4360 elif sys.platform == 'OpenVMS':
4250 keep.append('vms')
4361 keep.append('vms')
4251 elif sys.platform == 'plan9':
4362 elif sys.platform == 'plan9':
4252 keep.append('plan9')
4363 keep.append('plan9')
4253 else:
4364 else:
4254 keep.append('unix')
4365 keep.append('unix')
4255 keep.append(sys.platform.lower())
4366 keep.append(sys.platform.lower())
4256
4367
4257 section = None
4368 section = None
4258 if name and '.' in name:
4369 if name and '.' in name:
4259 name, section = name.split('.', 1)
4370 name, section = name.split('.', 1)
4260 section = section.lower()
4371 section = section.lower()
4261
4372
4262 text = help.help_(ui, name, **opts)
4373 text = help.help_(ui, name, **opts)
4263
4374
4264 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4375 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4265 section=section)
4376 section=section)
4266
4377
4267 # We could have been given a weird ".foo" section without a name
4378 # We could have been given a weird ".foo" section without a name
4268 # to look for, or we could have simply failed to found "foo.bar"
4379 # to look for, or we could have simply failed to found "foo.bar"
4269 # because bar isn't a section of foo
4380 # because bar isn't a section of foo
4270 if section and not (formatted and name):
4381 if section and not (formatted and name):
4271 raise error.Abort(_("help section not found"))
4382 raise error.Abort(_("help section not found"))
4272
4383
4273 if 'verbose' in pruned:
4384 if 'verbose' in pruned:
4274 keep.append('omitted')
4385 keep.append('omitted')
4275 else:
4386 else:
4276 keep.append('notomitted')
4387 keep.append('notomitted')
4277 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4388 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4278 section=section)
4389 section=section)
4279 ui.write(formatted)
4390 ui.write(formatted)
4280
4391
4281
4392
4282 @command('identify|id',
4393 @command('identify|id',
4283 [('r', 'rev', '',
4394 [('r', 'rev', '',
4284 _('identify the specified revision'), _('REV')),
4395 _('identify the specified revision'), _('REV')),
4285 ('n', 'num', None, _('show local revision number')),
4396 ('n', 'num', None, _('show local revision number')),
4286 ('i', 'id', None, _('show global revision id')),
4397 ('i', 'id', None, _('show global revision id')),
4287 ('b', 'branch', None, _('show branch')),
4398 ('b', 'branch', None, _('show branch')),
4288 ('t', 'tags', None, _('show tags')),
4399 ('t', 'tags', None, _('show tags')),
4289 ('B', 'bookmarks', None, _('show bookmarks')),
4400 ('B', 'bookmarks', None, _('show bookmarks')),
4290 ] + remoteopts,
4401 ] + remoteopts,
4291 _('[-nibtB] [-r REV] [SOURCE]'),
4402 _('[-nibtB] [-r REV] [SOURCE]'),
4292 optionalrepo=True)
4403 optionalrepo=True)
4293 def identify(ui, repo, source=None, rev=None,
4404 def identify(ui, repo, source=None, rev=None,
4294 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4405 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4295 """identify the working directory or specified revision
4406 """identify the working directory or specified revision
4296
4407
4297 Print a summary identifying the repository state at REV using one or
4408 Print a summary identifying the repository state at REV using one or
4298 two parent hash identifiers, followed by a "+" if the working
4409 two parent hash identifiers, followed by a "+" if the working
4299 directory has uncommitted changes, the branch name (if not default),
4410 directory has uncommitted changes, the branch name (if not default),
4300 a list of tags, and a list of bookmarks.
4411 a list of tags, and a list of bookmarks.
4301
4412
4302 When REV is not given, print a summary of the current state of the
4413 When REV is not given, print a summary of the current state of the
4303 repository.
4414 repository.
4304
4415
4305 Specifying a path to a repository root or Mercurial bundle will
4416 Specifying a path to a repository root or Mercurial bundle will
4306 cause lookup to operate on that repository/bundle.
4417 cause lookup to operate on that repository/bundle.
4307
4418
4308 .. container:: verbose
4419 .. container:: verbose
4309
4420
4310 Examples:
4421 Examples:
4311
4422
4312 - generate a build identifier for the working directory::
4423 - generate a build identifier for the working directory::
4313
4424
4314 hg id --id > build-id.dat
4425 hg id --id > build-id.dat
4315
4426
4316 - find the revision corresponding to a tag::
4427 - find the revision corresponding to a tag::
4317
4428
4318 hg id -n -r 1.3
4429 hg id -n -r 1.3
4319
4430
4320 - check the most recent revision of a remote repository::
4431 - check the most recent revision of a remote repository::
4321
4432
4322 hg id -r tip http://selenic.com/hg/
4433 hg id -r tip http://selenic.com/hg/
4323
4434
4324 See :hg:`log` for generating more information about specific revisions,
4435 See :hg:`log` for generating more information about specific revisions,
4325 including full hash identifiers.
4436 including full hash identifiers.
4326
4437
4327 Returns 0 if successful.
4438 Returns 0 if successful.
4328 """
4439 """
4329
4440
4330 if not repo and not source:
4441 if not repo and not source:
4331 raise error.Abort(_("there is no Mercurial repository here "
4442 raise error.Abort(_("there is no Mercurial repository here "
4332 "(.hg not found)"))
4443 "(.hg not found)"))
4333
4444
4334 if ui.debugflag:
4445 if ui.debugflag:
4335 hexfunc = hex
4446 hexfunc = hex
4336 else:
4447 else:
4337 hexfunc = short
4448 hexfunc = short
4338 default = not (num or id or branch or tags or bookmarks)
4449 default = not (num or id or branch or tags or bookmarks)
4339 output = []
4450 output = []
4340 revs = []
4451 revs = []
4341
4452
4342 if source:
4453 if source:
4343 source, branches = hg.parseurl(ui.expandpath(source))
4454 source, branches = hg.parseurl(ui.expandpath(source))
4344 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4455 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4345 repo = peer.local()
4456 repo = peer.local()
4346 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4457 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4347
4458
4348 if not repo:
4459 if not repo:
4349 if num or branch or tags:
4460 if num or branch or tags:
4350 raise error.Abort(
4461 raise error.Abort(
4351 _("can't query remote revision number, branch, or tags"))
4462 _("can't query remote revision number, branch, or tags"))
4352 if not rev and revs:
4463 if not rev and revs:
4353 rev = revs[0]
4464 rev = revs[0]
4354 if not rev:
4465 if not rev:
4355 rev = "tip"
4466 rev = "tip"
4356
4467
4357 remoterev = peer.lookup(rev)
4468 remoterev = peer.lookup(rev)
4358 if default or id:
4469 if default or id:
4359 output = [hexfunc(remoterev)]
4470 output = [hexfunc(remoterev)]
4360
4471
4361 def getbms():
4472 def getbms():
4362 bms = []
4473 bms = []
4363
4474
4364 if 'bookmarks' in peer.listkeys('namespaces'):
4475 if 'bookmarks' in peer.listkeys('namespaces'):
4365 hexremoterev = hex(remoterev)
4476 hexremoterev = hex(remoterev)
4366 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4477 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4367 if bmr == hexremoterev]
4478 if bmr == hexremoterev]
4368
4479
4369 return sorted(bms)
4480 return sorted(bms)
4370
4481
4371 if bookmarks:
4482 if bookmarks:
4372 output.extend(getbms())
4483 output.extend(getbms())
4373 elif default and not ui.quiet:
4484 elif default and not ui.quiet:
4374 # multiple bookmarks for a single parent separated by '/'
4485 # multiple bookmarks for a single parent separated by '/'
4375 bm = '/'.join(getbms())
4486 bm = '/'.join(getbms())
4376 if bm:
4487 if bm:
4377 output.append(bm)
4488 output.append(bm)
4378 else:
4489 else:
4379 ctx = scmutil.revsingle(repo, rev, None)
4490 ctx = scmutil.revsingle(repo, rev, None)
4380
4491
4381 if ctx.rev() is None:
4492 if ctx.rev() is None:
4382 ctx = repo[None]
4493 ctx = repo[None]
4383 parents = ctx.parents()
4494 parents = ctx.parents()
4384 taglist = []
4495 taglist = []
4385 for p in parents:
4496 for p in parents:
4386 taglist.extend(p.tags())
4497 taglist.extend(p.tags())
4387
4498
4388 changed = ""
4499 changed = ""
4389 if default or id or num:
4500 if default or id or num:
4390 if (any(repo.status())
4501 if (any(repo.status())
4391 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4502 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4392 changed = '+'
4503 changed = '+'
4393 if default or id:
4504 if default or id:
4394 output = ["%s%s" %
4505 output = ["%s%s" %
4395 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4506 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4396 if num:
4507 if num:
4397 output.append("%s%s" %
4508 output.append("%s%s" %
4398 ('+'.join([str(p.rev()) for p in parents]), changed))
4509 ('+'.join([str(p.rev()) for p in parents]), changed))
4399 else:
4510 else:
4400 if default or id:
4511 if default or id:
4401 output = [hexfunc(ctx.node())]
4512 output = [hexfunc(ctx.node())]
4402 if num:
4513 if num:
4403 output.append(str(ctx.rev()))
4514 output.append(str(ctx.rev()))
4404 taglist = ctx.tags()
4515 taglist = ctx.tags()
4405
4516
4406 if default and not ui.quiet:
4517 if default and not ui.quiet:
4407 b = ctx.branch()
4518 b = ctx.branch()
4408 if b != 'default':
4519 if b != 'default':
4409 output.append("(%s)" % b)
4520 output.append("(%s)" % b)
4410
4521
4411 # multiple tags for a single parent separated by '/'
4522 # multiple tags for a single parent separated by '/'
4412 t = '/'.join(taglist)
4523 t = '/'.join(taglist)
4413 if t:
4524 if t:
4414 output.append(t)
4525 output.append(t)
4415
4526
4416 # multiple bookmarks for a single parent separated by '/'
4527 # multiple bookmarks for a single parent separated by '/'
4417 bm = '/'.join(ctx.bookmarks())
4528 bm = '/'.join(ctx.bookmarks())
4418 if bm:
4529 if bm:
4419 output.append(bm)
4530 output.append(bm)
4420 else:
4531 else:
4421 if branch:
4532 if branch:
4422 output.append(ctx.branch())
4533 output.append(ctx.branch())
4423
4534
4424 if tags:
4535 if tags:
4425 output.extend(taglist)
4536 output.extend(taglist)
4426
4537
4427 if bookmarks:
4538 if bookmarks:
4428 output.extend(ctx.bookmarks())
4539 output.extend(ctx.bookmarks())
4429
4540
4430 ui.write("%s\n" % ' '.join(output))
4541 ui.write("%s\n" % ' '.join(output))
4431
4542
4432 @command('import|patch',
4543 @command('import|patch',
4433 [('p', 'strip', 1,
4544 [('p', 'strip', 1,
4434 _('directory strip option for patch. This has the same '
4545 _('directory strip option for patch. This has the same '
4435 'meaning as the corresponding patch option'), _('NUM')),
4546 'meaning as the corresponding patch option'), _('NUM')),
4436 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4547 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4437 ('e', 'edit', False, _('invoke editor on commit messages')),
4548 ('e', 'edit', False, _('invoke editor on commit messages')),
4438 ('f', 'force', None,
4549 ('f', 'force', None,
4439 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4550 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4440 ('', 'no-commit', None,
4551 ('', 'no-commit', None,
4441 _("don't commit, just update the working directory")),
4552 _("don't commit, just update the working directory")),
4442 ('', 'bypass', None,
4553 ('', 'bypass', None,
4443 _("apply patch without touching the working directory")),
4554 _("apply patch without touching the working directory")),
4444 ('', 'partial', None,
4555 ('', 'partial', None,
4445 _('commit even if some hunks fail')),
4556 _('commit even if some hunks fail')),
4446 ('', 'exact', None,
4557 ('', 'exact', None,
4447 _('apply patch to the nodes from which it was generated')),
4558 _('apply patch to the nodes from which it was generated')),
4448 ('', 'prefix', '',
4559 ('', 'prefix', '',
4449 _('apply patch to subdirectory'), _('DIR')),
4560 _('apply patch to subdirectory'), _('DIR')),
4450 ('', 'import-branch', None,
4561 ('', 'import-branch', None,
4451 _('use any branch information in patch (implied by --exact)'))] +
4562 _('use any branch information in patch (implied by --exact)'))] +
4452 commitopts + commitopts2 + similarityopts,
4563 commitopts + commitopts2 + similarityopts,
4453 _('[OPTION]... PATCH...'))
4564 _('[OPTION]... PATCH...'))
4454 def import_(ui, repo, patch1=None, *patches, **opts):
4565 def import_(ui, repo, patch1=None, *patches, **opts):
4455 """import an ordered set of patches
4566 """import an ordered set of patches
4456
4567
4457 Import a list of patches and commit them individually (unless
4568 Import a list of patches and commit them individually (unless
4458 --no-commit is specified).
4569 --no-commit is specified).
4459
4570
4460 Because import first applies changes to the working directory,
4571 Because import first applies changes to the working directory,
4461 import will abort if there are outstanding changes.
4572 import will abort if there are outstanding changes.
4462
4573
4463 You can import a patch straight from a mail message. Even patches
4574 You can import a patch straight from a mail message. Even patches
4464 as attachments work (to use the body part, it must have type
4575 as attachments work (to use the body part, it must have type
4465 text/plain or text/x-patch). From and Subject headers of email
4576 text/plain or text/x-patch). From and Subject headers of email
4466 message are used as default committer and commit message. All
4577 message are used as default committer and commit message. All
4467 text/plain body parts before first diff are added to commit
4578 text/plain body parts before first diff are added to commit
4468 message.
4579 message.
4469
4580
4470 If the imported patch was generated by :hg:`export`, user and
4581 If the imported patch was generated by :hg:`export`, user and
4471 description from patch override values from message headers and
4582 description from patch override values from message headers and
4472 body. Values given on command line with -m/--message and -u/--user
4583 body. Values given on command line with -m/--message and -u/--user
4473 override these.
4584 override these.
4474
4585
4475 If --exact is specified, import will set the working directory to
4586 If --exact is specified, import will set the working directory to
4476 the parent of each patch before applying it, and will abort if the
4587 the parent of each patch before applying it, and will abort if the
4477 resulting changeset has a different ID than the one recorded in
4588 resulting changeset has a different ID than the one recorded in
4478 the patch. This may happen due to character set problems or other
4589 the patch. This may happen due to character set problems or other
4479 deficiencies in the text patch format.
4590 deficiencies in the text patch format.
4480
4591
4481 Use --bypass to apply and commit patches directly to the
4592 Use --bypass to apply and commit patches directly to the
4482 repository, not touching the working directory. Without --exact,
4593 repository, not touching the working directory. Without --exact,
4483 patches will be applied on top of the working directory parent
4594 patches will be applied on top of the working directory parent
4484 revision.
4595 revision.
4485
4596
4486 With -s/--similarity, hg will attempt to discover renames and
4597 With -s/--similarity, hg will attempt to discover renames and
4487 copies in the patch in the same way as :hg:`addremove`.
4598 copies in the patch in the same way as :hg:`addremove`.
4488
4599
4489 Use --partial to ensure a changeset will be created from the patch
4600 Use --partial to ensure a changeset will be created from the patch
4490 even if some hunks fail to apply. Hunks that fail to apply will be
4601 even if some hunks fail to apply. Hunks that fail to apply will be
4491 written to a <target-file>.rej file. Conflicts can then be resolved
4602 written to a <target-file>.rej file. Conflicts can then be resolved
4492 by hand before :hg:`commit --amend` is run to update the created
4603 by hand before :hg:`commit --amend` is run to update the created
4493 changeset. This flag exists to let people import patches that
4604 changeset. This flag exists to let people import patches that
4494 partially apply without losing the associated metadata (author,
4605 partially apply without losing the associated metadata (author,
4495 date, description, ...). Note that when none of the hunk applies
4606 date, description, ...). Note that when none of the hunk applies
4496 cleanly, :hg:`import --partial` will create an empty changeset,
4607 cleanly, :hg:`import --partial` will create an empty changeset,
4497 importing only the patch metadata.
4608 importing only the patch metadata.
4498
4609
4499 It is possible to use external patch programs to perform the patch
4610 It is possible to use external patch programs to perform the patch
4500 by setting the ``ui.patch`` configuration option. For the default
4611 by setting the ``ui.patch`` configuration option. For the default
4501 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4612 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4502 See :hg:`help config` for more information about configuration
4613 See :hg:`help config` for more information about configuration
4503 files and how to use these options.
4614 files and how to use these options.
4504
4615
4505 To read a patch from standard input, use "-" as the patch name. If
4616 To read a patch from standard input, use "-" as the patch name. If
4506 a URL is specified, the patch will be downloaded from it.
4617 a URL is specified, the patch will be downloaded from it.
4507 See :hg:`help dates` for a list of formats valid for -d/--date.
4618 See :hg:`help dates` for a list of formats valid for -d/--date.
4508
4619
4509 .. container:: verbose
4620 .. container:: verbose
4510
4621
4511 Examples:
4622 Examples:
4512
4623
4513 - import a traditional patch from a website and detect renames::
4624 - import a traditional patch from a website and detect renames::
4514
4625
4515 hg import -s 80 http://example.com/bugfix.patch
4626 hg import -s 80 http://example.com/bugfix.patch
4516
4627
4517 - import a changeset from an hgweb server::
4628 - import a changeset from an hgweb server::
4518
4629
4519 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4630 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4520
4631
4521 - import all the patches in an Unix-style mbox::
4632 - import all the patches in an Unix-style mbox::
4522
4633
4523 hg import incoming-patches.mbox
4634 hg import incoming-patches.mbox
4524
4635
4525 - attempt to exactly restore an exported changeset (not always
4636 - attempt to exactly restore an exported changeset (not always
4526 possible)::
4637 possible)::
4527
4638
4528 hg import --exact proposed-fix.patch
4639 hg import --exact proposed-fix.patch
4529
4640
4530 - use an external tool to apply a patch which is too fuzzy for
4641 - use an external tool to apply a patch which is too fuzzy for
4531 the default internal tool.
4642 the default internal tool.
4532
4643
4533 hg import --config ui.patch="patch --merge" fuzzy.patch
4644 hg import --config ui.patch="patch --merge" fuzzy.patch
4534
4645
4535 - change the default fuzzing from 2 to a less strict 7
4646 - change the default fuzzing from 2 to a less strict 7
4536
4647
4537 hg import --config ui.fuzz=7 fuzz.patch
4648 hg import --config ui.fuzz=7 fuzz.patch
4538
4649
4539 Returns 0 on success, 1 on partial success (see --partial).
4650 Returns 0 on success, 1 on partial success (see --partial).
4540 """
4651 """
4541
4652
4542 if not patch1:
4653 if not patch1:
4543 raise error.Abort(_('need at least one patch to import'))
4654 raise error.Abort(_('need at least one patch to import'))
4544
4655
4545 patches = (patch1,) + patches
4656 patches = (patch1,) + patches
4546
4657
4547 date = opts.get('date')
4658 date = opts.get('date')
4548 if date:
4659 if date:
4549 opts['date'] = util.parsedate(date)
4660 opts['date'] = util.parsedate(date)
4550
4661
4551 update = not opts.get('bypass')
4662 update = not opts.get('bypass')
4552 if not update and opts.get('no_commit'):
4663 if not update and opts.get('no_commit'):
4553 raise error.Abort(_('cannot use --no-commit with --bypass'))
4664 raise error.Abort(_('cannot use --no-commit with --bypass'))
4554 try:
4665 try:
4555 sim = float(opts.get('similarity') or 0)
4666 sim = float(opts.get('similarity') or 0)
4556 except ValueError:
4667 except ValueError:
4557 raise error.Abort(_('similarity must be a number'))
4668 raise error.Abort(_('similarity must be a number'))
4558 if sim < 0 or sim > 100:
4669 if sim < 0 or sim > 100:
4559 raise error.Abort(_('similarity must be between 0 and 100'))
4670 raise error.Abort(_('similarity must be between 0 and 100'))
4560 if sim and not update:
4671 if sim and not update:
4561 raise error.Abort(_('cannot use --similarity with --bypass'))
4672 raise error.Abort(_('cannot use --similarity with --bypass'))
4562 if opts.get('exact') and opts.get('edit'):
4673 if opts.get('exact') and opts.get('edit'):
4563 raise error.Abort(_('cannot use --exact with --edit'))
4674 raise error.Abort(_('cannot use --exact with --edit'))
4564 if opts.get('exact') and opts.get('prefix'):
4675 if opts.get('exact') and opts.get('prefix'):
4565 raise error.Abort(_('cannot use --exact with --prefix'))
4676 raise error.Abort(_('cannot use --exact with --prefix'))
4566
4677
4567 base = opts["base"]
4678 base = opts["base"]
4568 wlock = dsguard = lock = tr = None
4679 wlock = dsguard = lock = tr = None
4569 msgs = []
4680 msgs = []
4570 ret = 0
4681 ret = 0
4571
4682
4572
4683
4573 try:
4684 try:
4574 try:
4685 try:
4575 wlock = repo.wlock()
4686 wlock = repo.wlock()
4576
4687
4577 if update:
4688 if update:
4578 cmdutil.checkunfinished(repo)
4689 cmdutil.checkunfinished(repo)
4579 if (opts.get('exact') or not opts.get('force')) and update:
4690 if (opts.get('exact') or not opts.get('force')) and update:
4580 cmdutil.bailifchanged(repo)
4691 cmdutil.bailifchanged(repo)
4581
4692
4582 if not opts.get('no_commit'):
4693 if not opts.get('no_commit'):
4583 lock = repo.lock()
4694 lock = repo.lock()
4584 tr = repo.transaction('import')
4695 tr = repo.transaction('import')
4585 else:
4696 else:
4586 dsguard = cmdutil.dirstateguard(repo, 'import')
4697 dsguard = cmdutil.dirstateguard(repo, 'import')
4587 parents = repo[None].parents()
4698 parents = repo[None].parents()
4588 for patchurl in patches:
4699 for patchurl in patches:
4589 if patchurl == '-':
4700 if patchurl == '-':
4590 ui.status(_('applying patch from stdin\n'))
4701 ui.status(_('applying patch from stdin\n'))
4591 patchfile = ui.fin
4702 patchfile = ui.fin
4592 patchurl = 'stdin' # for error message
4703 patchurl = 'stdin' # for error message
4593 else:
4704 else:
4594 patchurl = os.path.join(base, patchurl)
4705 patchurl = os.path.join(base, patchurl)
4595 ui.status(_('applying %s\n') % patchurl)
4706 ui.status(_('applying %s\n') % patchurl)
4596 patchfile = hg.openpath(ui, patchurl)
4707 patchfile = hg.openpath(ui, patchurl)
4597
4708
4598 haspatch = False
4709 haspatch = False
4599 for hunk in patch.split(patchfile):
4710 for hunk in patch.split(patchfile):
4600 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4711 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4601 parents, opts,
4712 parents, opts,
4602 msgs, hg.clean)
4713 msgs, hg.clean)
4603 if msg:
4714 if msg:
4604 haspatch = True
4715 haspatch = True
4605 ui.note(msg + '\n')
4716 ui.note(msg + '\n')
4606 if update or opts.get('exact'):
4717 if update or opts.get('exact'):
4607 parents = repo[None].parents()
4718 parents = repo[None].parents()
4608 else:
4719 else:
4609 parents = [repo[node]]
4720 parents = [repo[node]]
4610 if rej:
4721 if rej:
4611 ui.write_err(_("patch applied partially\n"))
4722 ui.write_err(_("patch applied partially\n"))
4612 ui.write_err(_("(fix the .rej files and run "
4723 ui.write_err(_("(fix the .rej files and run "
4613 "`hg commit --amend`)\n"))
4724 "`hg commit --amend`)\n"))
4614 ret = 1
4725 ret = 1
4615 break
4726 break
4616
4727
4617 if not haspatch:
4728 if not haspatch:
4618 raise error.Abort(_('%s: no diffs found') % patchurl)
4729 raise error.Abort(_('%s: no diffs found') % patchurl)
4619
4730
4620 if tr:
4731 if tr:
4621 tr.close()
4732 tr.close()
4622 if msgs:
4733 if msgs:
4623 repo.savecommitmessage('\n* * *\n'.join(msgs))
4734 repo.savecommitmessage('\n* * *\n'.join(msgs))
4624 if dsguard:
4735 if dsguard:
4625 dsguard.close()
4736 dsguard.close()
4626 return ret
4737 return ret
4627 finally:
4738 finally:
4628 # TODO: get rid of this meaningless try/finally enclosing.
4739 # TODO: get rid of this meaningless try/finally enclosing.
4629 # this is kept only to reduce changes in a patch.
4740 # this is kept only to reduce changes in a patch.
4630 pass
4741 pass
4631 finally:
4742 finally:
4632 if tr:
4743 if tr:
4633 tr.release()
4744 tr.release()
4634 release(lock, dsguard, wlock)
4745 release(lock, dsguard, wlock)
4635
4746
4636 @command('incoming|in',
4747 @command('incoming|in',
4637 [('f', 'force', None,
4748 [('f', 'force', None,
4638 _('run even if remote repository is unrelated')),
4749 _('run even if remote repository is unrelated')),
4639 ('n', 'newest-first', None, _('show newest record first')),
4750 ('n', 'newest-first', None, _('show newest record first')),
4640 ('', 'bundle', '',
4751 ('', 'bundle', '',
4641 _('file to store the bundles into'), _('FILE')),
4752 _('file to store the bundles into'), _('FILE')),
4642 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4753 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4643 ('B', 'bookmarks', False, _("compare bookmarks")),
4754 ('B', 'bookmarks', False, _("compare bookmarks")),
4644 ('b', 'branch', [],
4755 ('b', 'branch', [],
4645 _('a specific branch you would like to pull'), _('BRANCH')),
4756 _('a specific branch you would like to pull'), _('BRANCH')),
4646 ] + logopts + remoteopts + subrepoopts,
4757 ] + logopts + remoteopts + subrepoopts,
4647 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4758 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4648 def incoming(ui, repo, source="default", **opts):
4759 def incoming(ui, repo, source="default", **opts):
4649 """show new changesets found in source
4760 """show new changesets found in source
4650
4761
4651 Show new changesets found in the specified path/URL or the default
4762 Show new changesets found in the specified path/URL or the default
4652 pull location. These are the changesets that would have been pulled
4763 pull location. These are the changesets that would have been pulled
4653 if a pull at the time you issued this command.
4764 if a pull at the time you issued this command.
4654
4765
4655 See pull for valid source format details.
4766 See pull for valid source format details.
4656
4767
4657 .. container:: verbose
4768 .. container:: verbose
4658
4769
4659 With -B/--bookmarks, the result of bookmark comparison between
4770 With -B/--bookmarks, the result of bookmark comparison between
4660 local and remote repositories is displayed. With -v/--verbose,
4771 local and remote repositories is displayed. With -v/--verbose,
4661 status is also displayed for each bookmark like below::
4772 status is also displayed for each bookmark like below::
4662
4773
4663 BM1 01234567890a added
4774 BM1 01234567890a added
4664 BM2 1234567890ab advanced
4775 BM2 1234567890ab advanced
4665 BM3 234567890abc diverged
4776 BM3 234567890abc diverged
4666 BM4 34567890abcd changed
4777 BM4 34567890abcd changed
4667
4778
4668 The action taken locally when pulling depends on the
4779 The action taken locally when pulling depends on the
4669 status of each bookmark:
4780 status of each bookmark:
4670
4781
4671 :``added``: pull will create it
4782 :``added``: pull will create it
4672 :``advanced``: pull will update it
4783 :``advanced``: pull will update it
4673 :``diverged``: pull will create a divergent bookmark
4784 :``diverged``: pull will create a divergent bookmark
4674 :``changed``: result depends on remote changesets
4785 :``changed``: result depends on remote changesets
4675
4786
4676 From the point of view of pulling behavior, bookmark
4787 From the point of view of pulling behavior, bookmark
4677 existing only in the remote repository are treated as ``added``,
4788 existing only in the remote repository are treated as ``added``,
4678 even if it is in fact locally deleted.
4789 even if it is in fact locally deleted.
4679
4790
4680 .. container:: verbose
4791 .. container:: verbose
4681
4792
4682 For remote repository, using --bundle avoids downloading the
4793 For remote repository, using --bundle avoids downloading the
4683 changesets twice if the incoming is followed by a pull.
4794 changesets twice if the incoming is followed by a pull.
4684
4795
4685 Examples:
4796 Examples:
4686
4797
4687 - show incoming changes with patches and full description::
4798 - show incoming changes with patches and full description::
4688
4799
4689 hg incoming -vp
4800 hg incoming -vp
4690
4801
4691 - show incoming changes excluding merges, store a bundle::
4802 - show incoming changes excluding merges, store a bundle::
4692
4803
4693 hg in -vpM --bundle incoming.hg
4804 hg in -vpM --bundle incoming.hg
4694 hg pull incoming.hg
4805 hg pull incoming.hg
4695
4806
4696 - briefly list changes inside a bundle::
4807 - briefly list changes inside a bundle::
4697
4808
4698 hg in changes.hg -T "{desc|firstline}\\n"
4809 hg in changes.hg -T "{desc|firstline}\\n"
4699
4810
4700 Returns 0 if there are incoming changes, 1 otherwise.
4811 Returns 0 if there are incoming changes, 1 otherwise.
4701 """
4812 """
4702 if opts.get('graph'):
4813 if opts.get('graph'):
4703 cmdutil.checkunsupportedgraphflags([], opts)
4814 cmdutil.checkunsupportedgraphflags([], opts)
4704 def display(other, chlist, displayer):
4815 def display(other, chlist, displayer):
4705 revdag = cmdutil.graphrevs(other, chlist, opts)
4816 revdag = cmdutil.graphrevs(other, chlist, opts)
4706 cmdutil.displaygraph(ui, repo, revdag, displayer,
4817 cmdutil.displaygraph(ui, repo, revdag, displayer,
4707 graphmod.asciiedges)
4818 graphmod.asciiedges)
4708
4819
4709 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4820 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4710 return 0
4821 return 0
4711
4822
4712 if opts.get('bundle') and opts.get('subrepos'):
4823 if opts.get('bundle') and opts.get('subrepos'):
4713 raise error.Abort(_('cannot combine --bundle and --subrepos'))
4824 raise error.Abort(_('cannot combine --bundle and --subrepos'))
4714
4825
4715 if opts.get('bookmarks'):
4826 if opts.get('bookmarks'):
4716 source, branches = hg.parseurl(ui.expandpath(source),
4827 source, branches = hg.parseurl(ui.expandpath(source),
4717 opts.get('branch'))
4828 opts.get('branch'))
4718 other = hg.peer(repo, opts, source)
4829 other = hg.peer(repo, opts, source)
4719 if 'bookmarks' not in other.listkeys('namespaces'):
4830 if 'bookmarks' not in other.listkeys('namespaces'):
4720 ui.warn(_("remote doesn't support bookmarks\n"))
4831 ui.warn(_("remote doesn't support bookmarks\n"))
4721 return 0
4832 return 0
4722 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4833 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4723 return bookmarks.incoming(ui, repo, other)
4834 return bookmarks.incoming(ui, repo, other)
4724
4835
4725 repo._subtoppath = ui.expandpath(source)
4836 repo._subtoppath = ui.expandpath(source)
4726 try:
4837 try:
4727 return hg.incoming(ui, repo, source, opts)
4838 return hg.incoming(ui, repo, source, opts)
4728 finally:
4839 finally:
4729 del repo._subtoppath
4840 del repo._subtoppath
4730
4841
4731
4842
4732 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4843 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4733 norepo=True)
4844 norepo=True)
4734 def init(ui, dest=".", **opts):
4845 def init(ui, dest=".", **opts):
4735 """create a new repository in the given directory
4846 """create a new repository in the given directory
4736
4847
4737 Initialize a new repository in the given directory. If the given
4848 Initialize a new repository in the given directory. If the given
4738 directory does not exist, it will be created.
4849 directory does not exist, it will be created.
4739
4850
4740 If no directory is given, the current directory is used.
4851 If no directory is given, the current directory is used.
4741
4852
4742 It is possible to specify an ``ssh://`` URL as the destination.
4853 It is possible to specify an ``ssh://`` URL as the destination.
4743 See :hg:`help urls` for more information.
4854 See :hg:`help urls` for more information.
4744
4855
4745 Returns 0 on success.
4856 Returns 0 on success.
4746 """
4857 """
4747 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4858 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4748
4859
4749 @command('locate',
4860 @command('locate',
4750 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4861 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4751 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4862 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4752 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4863 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4753 ] + walkopts,
4864 ] + walkopts,
4754 _('[OPTION]... [PATTERN]...'))
4865 _('[OPTION]... [PATTERN]...'))
4755 def locate(ui, repo, *pats, **opts):
4866 def locate(ui, repo, *pats, **opts):
4756 """locate files matching specific patterns (DEPRECATED)
4867 """locate files matching specific patterns (DEPRECATED)
4757
4868
4758 Print files under Mercurial control in the working directory whose
4869 Print files under Mercurial control in the working directory whose
4759 names match the given patterns.
4870 names match the given patterns.
4760
4871
4761 By default, this command searches all directories in the working
4872 By default, this command searches all directories in the working
4762 directory. To search just the current directory and its
4873 directory. To search just the current directory and its
4763 subdirectories, use "--include .".
4874 subdirectories, use "--include .".
4764
4875
4765 If no patterns are given to match, this command prints the names
4876 If no patterns are given to match, this command prints the names
4766 of all files under Mercurial control in the working directory.
4877 of all files under Mercurial control in the working directory.
4767
4878
4768 If you want to feed the output of this command into the "xargs"
4879 If you want to feed the output of this command into the "xargs"
4769 command, use the -0 option to both this command and "xargs". This
4880 command, use the -0 option to both this command and "xargs". This
4770 will avoid the problem of "xargs" treating single filenames that
4881 will avoid the problem of "xargs" treating single filenames that
4771 contain whitespace as multiple filenames.
4882 contain whitespace as multiple filenames.
4772
4883
4773 See :hg:`help files` for a more versatile command.
4884 See :hg:`help files` for a more versatile command.
4774
4885
4775 Returns 0 if a match is found, 1 otherwise.
4886 Returns 0 if a match is found, 1 otherwise.
4776 """
4887 """
4777 if opts.get('print0'):
4888 if opts.get('print0'):
4778 end = '\0'
4889 end = '\0'
4779 else:
4890 else:
4780 end = '\n'
4891 end = '\n'
4781 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4892 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4782
4893
4783 ret = 1
4894 ret = 1
4784 ctx = repo[rev]
4895 ctx = repo[rev]
4785 m = scmutil.match(ctx, pats, opts, default='relglob',
4896 m = scmutil.match(ctx, pats, opts, default='relglob',
4786 badfn=lambda x, y: False)
4897 badfn=lambda x, y: False)
4787
4898
4788 for abs in ctx.matches(m):
4899 for abs in ctx.matches(m):
4789 if opts.get('fullpath'):
4900 if opts.get('fullpath'):
4790 ui.write(repo.wjoin(abs), end)
4901 ui.write(repo.wjoin(abs), end)
4791 else:
4902 else:
4792 ui.write(((pats and m.rel(abs)) or abs), end)
4903 ui.write(((pats and m.rel(abs)) or abs), end)
4793 ret = 0
4904 ret = 0
4794
4905
4795 return ret
4906 return ret
4796
4907
4797 @command('^log|history',
4908 @command('^log|history',
4798 [('f', 'follow', None,
4909 [('f', 'follow', None,
4799 _('follow changeset history, or file history across copies and renames')),
4910 _('follow changeset history, or file history across copies and renames')),
4800 ('', 'follow-first', None,
4911 ('', 'follow-first', None,
4801 _('only follow the first parent of merge changesets (DEPRECATED)')),
4912 _('only follow the first parent of merge changesets (DEPRECATED)')),
4802 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4913 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4803 ('C', 'copies', None, _('show copied files')),
4914 ('C', 'copies', None, _('show copied files')),
4804 ('k', 'keyword', [],
4915 ('k', 'keyword', [],
4805 _('do case-insensitive search for a given text'), _('TEXT')),
4916 _('do case-insensitive search for a given text'), _('TEXT')),
4806 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4917 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4807 ('', 'removed', None, _('include revisions where files were removed')),
4918 ('', 'removed', None, _('include revisions where files were removed')),
4808 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4919 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4809 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4920 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4810 ('', 'only-branch', [],
4921 ('', 'only-branch', [],
4811 _('show only changesets within the given named branch (DEPRECATED)'),
4922 _('show only changesets within the given named branch (DEPRECATED)'),
4812 _('BRANCH')),
4923 _('BRANCH')),
4813 ('b', 'branch', [],
4924 ('b', 'branch', [],
4814 _('show changesets within the given named branch'), _('BRANCH')),
4925 _('show changesets within the given named branch'), _('BRANCH')),
4815 ('P', 'prune', [],
4926 ('P', 'prune', [],
4816 _('do not display revision or any of its ancestors'), _('REV')),
4927 _('do not display revision or any of its ancestors'), _('REV')),
4817 ] + logopts + walkopts,
4928 ] + logopts + walkopts,
4818 _('[OPTION]... [FILE]'),
4929 _('[OPTION]... [FILE]'),
4819 inferrepo=True)
4930 inferrepo=True)
4820 def log(ui, repo, *pats, **opts):
4931 def log(ui, repo, *pats, **opts):
4821 """show revision history of entire repository or files
4932 """show revision history of entire repository or files
4822
4933
4823 Print the revision history of the specified files or the entire
4934 Print the revision history of the specified files or the entire
4824 project.
4935 project.
4825
4936
4826 If no revision range is specified, the default is ``tip:0`` unless
4937 If no revision range is specified, the default is ``tip:0`` unless
4827 --follow is set, in which case the working directory parent is
4938 --follow is set, in which case the working directory parent is
4828 used as the starting revision.
4939 used as the starting revision.
4829
4940
4830 File history is shown without following rename or copy history of
4941 File history is shown without following rename or copy history of
4831 files. Use -f/--follow with a filename to follow history across
4942 files. Use -f/--follow with a filename to follow history across
4832 renames and copies. --follow without a filename will only show
4943 renames and copies. --follow without a filename will only show
4833 ancestors or descendants of the starting revision.
4944 ancestors or descendants of the starting revision.
4834
4945
4835 By default this command prints revision number and changeset id,
4946 By default this command prints revision number and changeset id,
4836 tags, non-trivial parents, user, date and time, and a summary for
4947 tags, non-trivial parents, user, date and time, and a summary for
4837 each commit. When the -v/--verbose switch is used, the list of
4948 each commit. When the -v/--verbose switch is used, the list of
4838 changed files and full commit message are shown.
4949 changed files and full commit message are shown.
4839
4950
4840 With --graph the revisions are shown as an ASCII art DAG with the most
4951 With --graph the revisions are shown as an ASCII art DAG with the most
4841 recent changeset at the top.
4952 recent changeset at the top.
4842 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4953 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4843 and '+' represents a fork where the changeset from the lines below is a
4954 and '+' represents a fork where the changeset from the lines below is a
4844 parent of the 'o' merge on the same line.
4955 parent of the 'o' merge on the same line.
4845
4956
4846 .. note::
4957 .. note::
4847
4958
4848 log -p/--patch may generate unexpected diff output for merge
4959 log -p/--patch may generate unexpected diff output for merge
4849 changesets, as it will only compare the merge changeset against
4960 changesets, as it will only compare the merge changeset against
4850 its first parent. Also, only files different from BOTH parents
4961 its first parent. Also, only files different from BOTH parents
4851 will appear in files:.
4962 will appear in files:.
4852
4963
4853 .. note::
4964 .. note::
4854
4965
4855 for performance reasons, log FILE may omit duplicate changes
4966 for performance reasons, log FILE may omit duplicate changes
4856 made on branches and will not show removals or mode changes. To
4967 made on branches and will not show removals or mode changes. To
4857 see all such changes, use the --removed switch.
4968 see all such changes, use the --removed switch.
4858
4969
4859 .. container:: verbose
4970 .. container:: verbose
4860
4971
4861 Some examples:
4972 Some examples:
4862
4973
4863 - changesets with full descriptions and file lists::
4974 - changesets with full descriptions and file lists::
4864
4975
4865 hg log -v
4976 hg log -v
4866
4977
4867 - changesets ancestral to the working directory::
4978 - changesets ancestral to the working directory::
4868
4979
4869 hg log -f
4980 hg log -f
4870
4981
4871 - last 10 commits on the current branch::
4982 - last 10 commits on the current branch::
4872
4983
4873 hg log -l 10 -b .
4984 hg log -l 10 -b .
4874
4985
4875 - changesets showing all modifications of a file, including removals::
4986 - changesets showing all modifications of a file, including removals::
4876
4987
4877 hg log --removed file.c
4988 hg log --removed file.c
4878
4989
4879 - all changesets that touch a directory, with diffs, excluding merges::
4990 - all changesets that touch a directory, with diffs, excluding merges::
4880
4991
4881 hg log -Mp lib/
4992 hg log -Mp lib/
4882
4993
4883 - all revision numbers that match a keyword::
4994 - all revision numbers that match a keyword::
4884
4995
4885 hg log -k bug --template "{rev}\\n"
4996 hg log -k bug --template "{rev}\\n"
4886
4997
4887 - the full hash identifier of the working directory parent::
4998 - the full hash identifier of the working directory parent::
4888
4999
4889 hg log -r . --template "{node}\\n"
5000 hg log -r . --template "{node}\\n"
4890
5001
4891 - list available log templates::
5002 - list available log templates::
4892
5003
4893 hg log -T list
5004 hg log -T list
4894
5005
4895 - check if a given changeset is included in a tagged release::
5006 - check if a given changeset is included in a tagged release::
4896
5007
4897 hg log -r "a21ccf and ancestor(1.9)"
5008 hg log -r "a21ccf and ancestor(1.9)"
4898
5009
4899 - find all changesets by some user in a date range::
5010 - find all changesets by some user in a date range::
4900
5011
4901 hg log -k alice -d "may 2008 to jul 2008"
5012 hg log -k alice -d "may 2008 to jul 2008"
4902
5013
4903 - summary of all changesets after the last tag::
5014 - summary of all changesets after the last tag::
4904
5015
4905 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
5016 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4906
5017
4907 See :hg:`help dates` for a list of formats valid for -d/--date.
5018 See :hg:`help dates` for a list of formats valid for -d/--date.
4908
5019
4909 See :hg:`help revisions` and :hg:`help revsets` for more about
5020 See :hg:`help revisions` and :hg:`help revsets` for more about
4910 specifying revisions.
5021 specifying revisions.
4911
5022
4912 See :hg:`help templates` for more about pre-packaged styles and
5023 See :hg:`help templates` for more about pre-packaged styles and
4913 specifying custom templates.
5024 specifying custom templates.
4914
5025
4915 Returns 0 on success.
5026 Returns 0 on success.
4916
5027
4917 """
5028 """
4918 if opts.get('follow') and opts.get('rev'):
5029 if opts.get('follow') and opts.get('rev'):
4919 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
5030 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4920 del opts['follow']
5031 del opts['follow']
4921
5032
4922 if opts.get('graph'):
5033 if opts.get('graph'):
4923 return cmdutil.graphlog(ui, repo, *pats, **opts)
5034 return cmdutil.graphlog(ui, repo, *pats, **opts)
4924
5035
4925 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
5036 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4926 limit = cmdutil.loglimit(opts)
5037 limit = cmdutil.loglimit(opts)
4927 count = 0
5038 count = 0
4928
5039
4929 getrenamed = None
5040 getrenamed = None
4930 if opts.get('copies'):
5041 if opts.get('copies'):
4931 endrev = None
5042 endrev = None
4932 if opts.get('rev'):
5043 if opts.get('rev'):
4933 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
5044 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4934 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
5045 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4935
5046
4936 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
5047 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4937 for rev in revs:
5048 for rev in revs:
4938 if count == limit:
5049 if count == limit:
4939 break
5050 break
4940 ctx = repo[rev]
5051 ctx = repo[rev]
4941 copies = None
5052 copies = None
4942 if getrenamed is not None and rev:
5053 if getrenamed is not None and rev:
4943 copies = []
5054 copies = []
4944 for fn in ctx.files():
5055 for fn in ctx.files():
4945 rename = getrenamed(fn, rev)
5056 rename = getrenamed(fn, rev)
4946 if rename:
5057 if rename:
4947 copies.append((fn, rename[0]))
5058 copies.append((fn, rename[0]))
4948 if filematcher:
5059 if filematcher:
4949 revmatchfn = filematcher(ctx.rev())
5060 revmatchfn = filematcher(ctx.rev())
4950 else:
5061 else:
4951 revmatchfn = None
5062 revmatchfn = None
4952 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
5063 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4953 if displayer.flush(ctx):
5064 if displayer.flush(ctx):
4954 count += 1
5065 count += 1
4955
5066
4956 displayer.close()
5067 displayer.close()
4957
5068
4958 @command('manifest',
5069 @command('manifest',
4959 [('r', 'rev', '', _('revision to display'), _('REV')),
5070 [('r', 'rev', '', _('revision to display'), _('REV')),
4960 ('', 'all', False, _("list files from all revisions"))]
5071 ('', 'all', False, _("list files from all revisions"))]
4961 + formatteropts,
5072 + formatteropts,
4962 _('[-r REV]'))
5073 _('[-r REV]'))
4963 def manifest(ui, repo, node=None, rev=None, **opts):
5074 def manifest(ui, repo, node=None, rev=None, **opts):
4964 """output the current or given revision of the project manifest
5075 """output the current or given revision of the project manifest
4965
5076
4966 Print a list of version controlled files for the given revision.
5077 Print a list of version controlled files for the given revision.
4967 If no revision is given, the first parent of the working directory
5078 If no revision is given, the first parent of the working directory
4968 is used, or the null revision if no revision is checked out.
5079 is used, or the null revision if no revision is checked out.
4969
5080
4970 With -v, print file permissions, symlink and executable bits.
5081 With -v, print file permissions, symlink and executable bits.
4971 With --debug, print file revision hashes.
5082 With --debug, print file revision hashes.
4972
5083
4973 If option --all is specified, the list of all files from all revisions
5084 If option --all is specified, the list of all files from all revisions
4974 is printed. This includes deleted and renamed files.
5085 is printed. This includes deleted and renamed files.
4975
5086
4976 Returns 0 on success.
5087 Returns 0 on success.
4977 """
5088 """
4978
5089
4979 fm = ui.formatter('manifest', opts)
5090 fm = ui.formatter('manifest', opts)
4980
5091
4981 if opts.get('all'):
5092 if opts.get('all'):
4982 if rev or node:
5093 if rev or node:
4983 raise error.Abort(_("can't specify a revision with --all"))
5094 raise error.Abort(_("can't specify a revision with --all"))
4984
5095
4985 res = []
5096 res = []
4986 prefix = "data/"
5097 prefix = "data/"
4987 suffix = ".i"
5098 suffix = ".i"
4988 plen = len(prefix)
5099 plen = len(prefix)
4989 slen = len(suffix)
5100 slen = len(suffix)
4990 lock = repo.lock()
5101 lock = repo.lock()
4991 try:
5102 try:
4992 for fn, b, size in repo.store.datafiles():
5103 for fn, b, size in repo.store.datafiles():
4993 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
5104 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4994 res.append(fn[plen:-slen])
5105 res.append(fn[plen:-slen])
4995 finally:
5106 finally:
4996 lock.release()
5107 lock.release()
4997 for f in res:
5108 for f in res:
4998 fm.startitem()
5109 fm.startitem()
4999 fm.write("path", '%s\n', f)
5110 fm.write("path", '%s\n', f)
5000 fm.end()
5111 fm.end()
5001 return
5112 return
5002
5113
5003 if rev and node:
5114 if rev and node:
5004 raise error.Abort(_("please specify just one revision"))
5115 raise error.Abort(_("please specify just one revision"))
5005
5116
5006 if not node:
5117 if not node:
5007 node = rev
5118 node = rev
5008
5119
5009 char = {'l': '@', 'x': '*', '': ''}
5120 char = {'l': '@', 'x': '*', '': ''}
5010 mode = {'l': '644', 'x': '755', '': '644'}
5121 mode = {'l': '644', 'x': '755', '': '644'}
5011 ctx = scmutil.revsingle(repo, node)
5122 ctx = scmutil.revsingle(repo, node)
5012 mf = ctx.manifest()
5123 mf = ctx.manifest()
5013 for f in ctx:
5124 for f in ctx:
5014 fm.startitem()
5125 fm.startitem()
5015 fl = ctx[f].flags()
5126 fl = ctx[f].flags()
5016 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
5127 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
5017 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
5128 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
5018 fm.write('path', '%s\n', f)
5129 fm.write('path', '%s\n', f)
5019 fm.end()
5130 fm.end()
5020
5131
5021 @command('^merge',
5132 @command('^merge',
5022 [('f', 'force', None,
5133 [('f', 'force', None,
5023 _('force a merge including outstanding changes (DEPRECATED)')),
5134 _('force a merge including outstanding changes (DEPRECATED)')),
5024 ('r', 'rev', '', _('revision to merge'), _('REV')),
5135 ('r', 'rev', '', _('revision to merge'), _('REV')),
5025 ('P', 'preview', None,
5136 ('P', 'preview', None,
5026 _('review revisions to merge (no merge is performed)'))
5137 _('review revisions to merge (no merge is performed)'))
5027 ] + mergetoolopts,
5138 ] + mergetoolopts,
5028 _('[-P] [-f] [[-r] REV]'))
5139 _('[-P] [-f] [[-r] REV]'))
5029 def merge(ui, repo, node=None, **opts):
5140 def merge(ui, repo, node=None, **opts):
5030 """merge another revision into working directory
5141 """merge another revision into working directory
5031
5142
5032 The current working directory is updated with all changes made in
5143 The current working directory is updated with all changes made in
5033 the requested revision since the last common predecessor revision.
5144 the requested revision since the last common predecessor revision.
5034
5145
5035 Files that changed between either parent are marked as changed for
5146 Files that changed between either parent are marked as changed for
5036 the next commit and a commit must be performed before any further
5147 the next commit and a commit must be performed before any further
5037 updates to the repository are allowed. The next commit will have
5148 updates to the repository are allowed. The next commit will have
5038 two parents.
5149 two parents.
5039
5150
5040 ``--tool`` can be used to specify the merge tool used for file
5151 ``--tool`` can be used to specify the merge tool used for file
5041 merges. It overrides the HGMERGE environment variable and your
5152 merges. It overrides the HGMERGE environment variable and your
5042 configuration files. See :hg:`help merge-tools` for options.
5153 configuration files. See :hg:`help merge-tools` for options.
5043
5154
5044 If no revision is specified, the working directory's parent is a
5155 If no revision is specified, the working directory's parent is a
5045 head revision, and the current branch contains exactly one other
5156 head revision, and the current branch contains exactly one other
5046 head, the other head is merged with by default. Otherwise, an
5157 head, the other head is merged with by default. Otherwise, an
5047 explicit revision with which to merge with must be provided.
5158 explicit revision with which to merge with must be provided.
5048
5159
5049 :hg:`resolve` must be used to resolve unresolved files.
5160 :hg:`resolve` must be used to resolve unresolved files.
5050
5161
5051 To undo an uncommitted merge, use :hg:`update --clean .` which
5162 To undo an uncommitted merge, use :hg:`update --clean .` which
5052 will check out a clean copy of the original merge parent, losing
5163 will check out a clean copy of the original merge parent, losing
5053 all changes.
5164 all changes.
5054
5165
5055 Returns 0 on success, 1 if there are unresolved files.
5166 Returns 0 on success, 1 if there are unresolved files.
5056 """
5167 """
5057
5168
5058 if opts.get('rev') and node:
5169 if opts.get('rev') and node:
5059 raise error.Abort(_("please specify just one revision"))
5170 raise error.Abort(_("please specify just one revision"))
5060 if not node:
5171 if not node:
5061 node = opts.get('rev')
5172 node = opts.get('rev')
5062
5173
5063 if node:
5174 if node:
5064 node = scmutil.revsingle(repo, node).node()
5175 node = scmutil.revsingle(repo, node).node()
5065
5176
5066 if not node:
5177 if not node:
5067 node = repo[destutil.destmerge(repo)].node()
5178 node = repo[destutil.destmerge(repo)].node()
5068
5179
5069 if opts.get('preview'):
5180 if opts.get('preview'):
5070 # find nodes that are ancestors of p2 but not of p1
5181 # find nodes that are ancestors of p2 but not of p1
5071 p1 = repo.lookup('.')
5182 p1 = repo.lookup('.')
5072 p2 = repo.lookup(node)
5183 p2 = repo.lookup(node)
5073 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
5184 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
5074
5185
5075 displayer = cmdutil.show_changeset(ui, repo, opts)
5186 displayer = cmdutil.show_changeset(ui, repo, opts)
5076 for node in nodes:
5187 for node in nodes:
5077 displayer.show(repo[node])
5188 displayer.show(repo[node])
5078 displayer.close()
5189 displayer.close()
5079 return 0
5190 return 0
5080
5191
5081 try:
5192 try:
5082 # ui.forcemerge is an internal variable, do not document
5193 # ui.forcemerge is an internal variable, do not document
5083 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
5194 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
5084 return hg.merge(repo, node, force=opts.get('force'))
5195 return hg.merge(repo, node, force=opts.get('force'))
5085 finally:
5196 finally:
5086 ui.setconfig('ui', 'forcemerge', '', 'merge')
5197 ui.setconfig('ui', 'forcemerge', '', 'merge')
5087
5198
5088 @command('outgoing|out',
5199 @command('outgoing|out',
5089 [('f', 'force', None, _('run even when the destination is unrelated')),
5200 [('f', 'force', None, _('run even when the destination is unrelated')),
5090 ('r', 'rev', [],
5201 ('r', 'rev', [],
5091 _('a changeset intended to be included in the destination'), _('REV')),
5202 _('a changeset intended to be included in the destination'), _('REV')),
5092 ('n', 'newest-first', None, _('show newest record first')),
5203 ('n', 'newest-first', None, _('show newest record first')),
5093 ('B', 'bookmarks', False, _('compare bookmarks')),
5204 ('B', 'bookmarks', False, _('compare bookmarks')),
5094 ('b', 'branch', [], _('a specific branch you would like to push'),
5205 ('b', 'branch', [], _('a specific branch you would like to push'),
5095 _('BRANCH')),
5206 _('BRANCH')),
5096 ] + logopts + remoteopts + subrepoopts,
5207 ] + logopts + remoteopts + subrepoopts,
5097 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
5208 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
5098 def outgoing(ui, repo, dest=None, **opts):
5209 def outgoing(ui, repo, dest=None, **opts):
5099 """show changesets not found in the destination
5210 """show changesets not found in the destination
5100
5211
5101 Show changesets not found in the specified destination repository
5212 Show changesets not found in the specified destination repository
5102 or the default push location. These are the changesets that would
5213 or the default push location. These are the changesets that would
5103 be pushed if a push was requested.
5214 be pushed if a push was requested.
5104
5215
5105 See pull for details of valid destination formats.
5216 See pull for details of valid destination formats.
5106
5217
5107 .. container:: verbose
5218 .. container:: verbose
5108
5219
5109 With -B/--bookmarks, the result of bookmark comparison between
5220 With -B/--bookmarks, the result of bookmark comparison between
5110 local and remote repositories is displayed. With -v/--verbose,
5221 local and remote repositories is displayed. With -v/--verbose,
5111 status is also displayed for each bookmark like below::
5222 status is also displayed for each bookmark like below::
5112
5223
5113 BM1 01234567890a added
5224 BM1 01234567890a added
5114 BM2 deleted
5225 BM2 deleted
5115 BM3 234567890abc advanced
5226 BM3 234567890abc advanced
5116 BM4 34567890abcd diverged
5227 BM4 34567890abcd diverged
5117 BM5 4567890abcde changed
5228 BM5 4567890abcde changed
5118
5229
5119 The action taken when pushing depends on the
5230 The action taken when pushing depends on the
5120 status of each bookmark:
5231 status of each bookmark:
5121
5232
5122 :``added``: push with ``-B`` will create it
5233 :``added``: push with ``-B`` will create it
5123 :``deleted``: push with ``-B`` will delete it
5234 :``deleted``: push with ``-B`` will delete it
5124 :``advanced``: push will update it
5235 :``advanced``: push will update it
5125 :``diverged``: push with ``-B`` will update it
5236 :``diverged``: push with ``-B`` will update it
5126 :``changed``: push with ``-B`` will update it
5237 :``changed``: push with ``-B`` will update it
5127
5238
5128 From the point of view of pushing behavior, bookmarks
5239 From the point of view of pushing behavior, bookmarks
5129 existing only in the remote repository are treated as
5240 existing only in the remote repository are treated as
5130 ``deleted``, even if it is in fact added remotely.
5241 ``deleted``, even if it is in fact added remotely.
5131
5242
5132 Returns 0 if there are outgoing changes, 1 otherwise.
5243 Returns 0 if there are outgoing changes, 1 otherwise.
5133 """
5244 """
5134 if opts.get('graph'):
5245 if opts.get('graph'):
5135 cmdutil.checkunsupportedgraphflags([], opts)
5246 cmdutil.checkunsupportedgraphflags([], opts)
5136 o, other = hg._outgoing(ui, repo, dest, opts)
5247 o, other = hg._outgoing(ui, repo, dest, opts)
5137 if not o:
5248 if not o:
5138 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5249 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5139 return
5250 return
5140
5251
5141 revdag = cmdutil.graphrevs(repo, o, opts)
5252 revdag = cmdutil.graphrevs(repo, o, opts)
5142 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
5253 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
5143 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
5254 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
5144 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5255 cmdutil.outgoinghooks(ui, repo, other, opts, o)
5145 return 0
5256 return 0
5146
5257
5147 if opts.get('bookmarks'):
5258 if opts.get('bookmarks'):
5148 dest = ui.expandpath(dest or 'default-push', dest or 'default')
5259 dest = ui.expandpath(dest or 'default-push', dest or 'default')
5149 dest, branches = hg.parseurl(dest, opts.get('branch'))
5260 dest, branches = hg.parseurl(dest, opts.get('branch'))
5150 other = hg.peer(repo, opts, dest)
5261 other = hg.peer(repo, opts, dest)
5151 if 'bookmarks' not in other.listkeys('namespaces'):
5262 if 'bookmarks' not in other.listkeys('namespaces'):
5152 ui.warn(_("remote doesn't support bookmarks\n"))
5263 ui.warn(_("remote doesn't support bookmarks\n"))
5153 return 0
5264 return 0
5154 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
5265 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
5155 return bookmarks.outgoing(ui, repo, other)
5266 return bookmarks.outgoing(ui, repo, other)
5156
5267
5157 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
5268 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
5158 try:
5269 try:
5159 return hg.outgoing(ui, repo, dest, opts)
5270 return hg.outgoing(ui, repo, dest, opts)
5160 finally:
5271 finally:
5161 del repo._subtoppath
5272 del repo._subtoppath
5162
5273
5163 @command('parents',
5274 @command('parents',
5164 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
5275 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
5165 ] + templateopts,
5276 ] + templateopts,
5166 _('[-r REV] [FILE]'),
5277 _('[-r REV] [FILE]'),
5167 inferrepo=True)
5278 inferrepo=True)
5168 def parents(ui, repo, file_=None, **opts):
5279 def parents(ui, repo, file_=None, **opts):
5169 """show the parents of the working directory or revision (DEPRECATED)
5280 """show the parents of the working directory or revision (DEPRECATED)
5170
5281
5171 Print the working directory's parent revisions. If a revision is
5282 Print the working directory's parent revisions. If a revision is
5172 given via -r/--rev, the parent of that revision will be printed.
5283 given via -r/--rev, the parent of that revision will be printed.
5173 If a file argument is given, the revision in which the file was
5284 If a file argument is given, the revision in which the file was
5174 last changed (before the working directory revision or the
5285 last changed (before the working directory revision or the
5175 argument to --rev if given) is printed.
5286 argument to --rev if given) is printed.
5176
5287
5177 See :hg:`summary` and :hg:`help revsets` for related information.
5288 See :hg:`summary` and :hg:`help revsets` for related information.
5178
5289
5179 Returns 0 on success.
5290 Returns 0 on success.
5180 """
5291 """
5181
5292
5182 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5293 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5183
5294
5184 if file_:
5295 if file_:
5185 m = scmutil.match(ctx, (file_,), opts)
5296 m = scmutil.match(ctx, (file_,), opts)
5186 if m.anypats() or len(m.files()) != 1:
5297 if m.anypats() or len(m.files()) != 1:
5187 raise error.Abort(_('can only specify an explicit filename'))
5298 raise error.Abort(_('can only specify an explicit filename'))
5188 file_ = m.files()[0]
5299 file_ = m.files()[0]
5189 filenodes = []
5300 filenodes = []
5190 for cp in ctx.parents():
5301 for cp in ctx.parents():
5191 if not cp:
5302 if not cp:
5192 continue
5303 continue
5193 try:
5304 try:
5194 filenodes.append(cp.filenode(file_))
5305 filenodes.append(cp.filenode(file_))
5195 except error.LookupError:
5306 except error.LookupError:
5196 pass
5307 pass
5197 if not filenodes:
5308 if not filenodes:
5198 raise error.Abort(_("'%s' not found in manifest!") % file_)
5309 raise error.Abort(_("'%s' not found in manifest!") % file_)
5199 p = []
5310 p = []
5200 for fn in filenodes:
5311 for fn in filenodes:
5201 fctx = repo.filectx(file_, fileid=fn)
5312 fctx = repo.filectx(file_, fileid=fn)
5202 p.append(fctx.node())
5313 p.append(fctx.node())
5203 else:
5314 else:
5204 p = [cp.node() for cp in ctx.parents()]
5315 p = [cp.node() for cp in ctx.parents()]
5205
5316
5206 displayer = cmdutil.show_changeset(ui, repo, opts)
5317 displayer = cmdutil.show_changeset(ui, repo, opts)
5207 for n in p:
5318 for n in p:
5208 if n != nullid:
5319 if n != nullid:
5209 displayer.show(repo[n])
5320 displayer.show(repo[n])
5210 displayer.close()
5321 displayer.close()
5211
5322
5212 @command('paths', [], _('[NAME]'), optionalrepo=True)
5323 @command('paths', [], _('[NAME]'), optionalrepo=True)
5213 def paths(ui, repo, search=None):
5324 def paths(ui, repo, search=None):
5214 """show aliases for remote repositories
5325 """show aliases for remote repositories
5215
5326
5216 Show definition of symbolic path name NAME. If no name is given,
5327 Show definition of symbolic path name NAME. If no name is given,
5217 show definition of all available names.
5328 show definition of all available names.
5218
5329
5219 Option -q/--quiet suppresses all output when searching for NAME
5330 Option -q/--quiet suppresses all output when searching for NAME
5220 and shows only the path names when listing all definitions.
5331 and shows only the path names when listing all definitions.
5221
5332
5222 Path names are defined in the [paths] section of your
5333 Path names are defined in the [paths] section of your
5223 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5334 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5224 repository, ``.hg/hgrc`` is used, too.
5335 repository, ``.hg/hgrc`` is used, too.
5225
5336
5226 The path names ``default`` and ``default-push`` have a special
5337 The path names ``default`` and ``default-push`` have a special
5227 meaning. When performing a push or pull operation, they are used
5338 meaning. When performing a push or pull operation, they are used
5228 as fallbacks if no location is specified on the command-line.
5339 as fallbacks if no location is specified on the command-line.
5229 When ``default-push`` is set, it will be used for push and
5340 When ``default-push`` is set, it will be used for push and
5230 ``default`` will be used for pull; otherwise ``default`` is used
5341 ``default`` will be used for pull; otherwise ``default`` is used
5231 as the fallback for both. When cloning a repository, the clone
5342 as the fallback for both. When cloning a repository, the clone
5232 source is written as ``default`` in ``.hg/hgrc``. Note that
5343 source is written as ``default`` in ``.hg/hgrc``. Note that
5233 ``default`` and ``default-push`` apply to all inbound (e.g.
5344 ``default`` and ``default-push`` apply to all inbound (e.g.
5234 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5345 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5235 :hg:`bundle`) operations.
5346 :hg:`bundle`) operations.
5236
5347
5237 See :hg:`help urls` for more information.
5348 See :hg:`help urls` for more information.
5238
5349
5239 Returns 0 on success.
5350 Returns 0 on success.
5240 """
5351 """
5241 if search:
5352 if search:
5242 for name, path in sorted(ui.paths.iteritems()):
5353 for name, path in sorted(ui.paths.iteritems()):
5243 if name == search:
5354 if name == search:
5244 ui.status("%s\n" % util.hidepassword(path.loc))
5355 ui.status("%s\n" % util.hidepassword(path.loc))
5245 return
5356 return
5246 if not ui.quiet:
5357 if not ui.quiet:
5247 ui.warn(_("not found!\n"))
5358 ui.warn(_("not found!\n"))
5248 return 1
5359 return 1
5249 else:
5360 else:
5250 for name, path in sorted(ui.paths.iteritems()):
5361 for name, path in sorted(ui.paths.iteritems()):
5251 if ui.quiet:
5362 if ui.quiet:
5252 ui.write("%s\n" % name)
5363 ui.write("%s\n" % name)
5253 else:
5364 else:
5254 ui.write("%s = %s\n" % (name,
5365 ui.write("%s = %s\n" % (name,
5255 util.hidepassword(path.loc)))
5366 util.hidepassword(path.loc)))
5256
5367
5257 @command('phase',
5368 @command('phase',
5258 [('p', 'public', False, _('set changeset phase to public')),
5369 [('p', 'public', False, _('set changeset phase to public')),
5259 ('d', 'draft', False, _('set changeset phase to draft')),
5370 ('d', 'draft', False, _('set changeset phase to draft')),
5260 ('s', 'secret', False, _('set changeset phase to secret')),
5371 ('s', 'secret', False, _('set changeset phase to secret')),
5261 ('f', 'force', False, _('allow to move boundary backward')),
5372 ('f', 'force', False, _('allow to move boundary backward')),
5262 ('r', 'rev', [], _('target revision'), _('REV')),
5373 ('r', 'rev', [], _('target revision'), _('REV')),
5263 ],
5374 ],
5264 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5375 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5265 def phase(ui, repo, *revs, **opts):
5376 def phase(ui, repo, *revs, **opts):
5266 """set or show the current phase name
5377 """set or show the current phase name
5267
5378
5268 With no argument, show the phase name of the current revision(s).
5379 With no argument, show the phase name of the current revision(s).
5269
5380
5270 With one of -p/--public, -d/--draft or -s/--secret, change the
5381 With one of -p/--public, -d/--draft or -s/--secret, change the
5271 phase value of the specified revisions.
5382 phase value of the specified revisions.
5272
5383
5273 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5384 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5274 lower phase to an higher phase. Phases are ordered as follows::
5385 lower phase to an higher phase. Phases are ordered as follows::
5275
5386
5276 public < draft < secret
5387 public < draft < secret
5277
5388
5278 Returns 0 on success, 1 if some phases could not be changed.
5389 Returns 0 on success, 1 if some phases could not be changed.
5279
5390
5280 (For more information about the phases concept, see :hg:`help phases`.)
5391 (For more information about the phases concept, see :hg:`help phases`.)
5281 """
5392 """
5282 # search for a unique phase argument
5393 # search for a unique phase argument
5283 targetphase = None
5394 targetphase = None
5284 for idx, name in enumerate(phases.phasenames):
5395 for idx, name in enumerate(phases.phasenames):
5285 if opts[name]:
5396 if opts[name]:
5286 if targetphase is not None:
5397 if targetphase is not None:
5287 raise error.Abort(_('only one phase can be specified'))
5398 raise error.Abort(_('only one phase can be specified'))
5288 targetphase = idx
5399 targetphase = idx
5289
5400
5290 # look for specified revision
5401 # look for specified revision
5291 revs = list(revs)
5402 revs = list(revs)
5292 revs.extend(opts['rev'])
5403 revs.extend(opts['rev'])
5293 if not revs:
5404 if not revs:
5294 # display both parents as the second parent phase can influence
5405 # display both parents as the second parent phase can influence
5295 # the phase of a merge commit
5406 # the phase of a merge commit
5296 revs = [c.rev() for c in repo[None].parents()]
5407 revs = [c.rev() for c in repo[None].parents()]
5297
5408
5298 revs = scmutil.revrange(repo, revs)
5409 revs = scmutil.revrange(repo, revs)
5299
5410
5300 lock = None
5411 lock = None
5301 ret = 0
5412 ret = 0
5302 if targetphase is None:
5413 if targetphase is None:
5303 # display
5414 # display
5304 for r in revs:
5415 for r in revs:
5305 ctx = repo[r]
5416 ctx = repo[r]
5306 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5417 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5307 else:
5418 else:
5308 tr = None
5419 tr = None
5309 lock = repo.lock()
5420 lock = repo.lock()
5310 try:
5421 try:
5311 tr = repo.transaction("phase")
5422 tr = repo.transaction("phase")
5312 # set phase
5423 # set phase
5313 if not revs:
5424 if not revs:
5314 raise error.Abort(_('empty revision set'))
5425 raise error.Abort(_('empty revision set'))
5315 nodes = [repo[r].node() for r in revs]
5426 nodes = [repo[r].node() for r in revs]
5316 # moving revision from public to draft may hide them
5427 # moving revision from public to draft may hide them
5317 # We have to check result on an unfiltered repository
5428 # We have to check result on an unfiltered repository
5318 unfi = repo.unfiltered()
5429 unfi = repo.unfiltered()
5319 getphase = unfi._phasecache.phase
5430 getphase = unfi._phasecache.phase
5320 olddata = [getphase(unfi, r) for r in unfi]
5431 olddata = [getphase(unfi, r) for r in unfi]
5321 phases.advanceboundary(repo, tr, targetphase, nodes)
5432 phases.advanceboundary(repo, tr, targetphase, nodes)
5322 if opts['force']:
5433 if opts['force']:
5323 phases.retractboundary(repo, tr, targetphase, nodes)
5434 phases.retractboundary(repo, tr, targetphase, nodes)
5324 tr.close()
5435 tr.close()
5325 finally:
5436 finally:
5326 if tr is not None:
5437 if tr is not None:
5327 tr.release()
5438 tr.release()
5328 lock.release()
5439 lock.release()
5329 getphase = unfi._phasecache.phase
5440 getphase = unfi._phasecache.phase
5330 newdata = [getphase(unfi, r) for r in unfi]
5441 newdata = [getphase(unfi, r) for r in unfi]
5331 changes = sum(newdata[r] != olddata[r] for r in unfi)
5442 changes = sum(newdata[r] != olddata[r] for r in unfi)
5332 cl = unfi.changelog
5443 cl = unfi.changelog
5333 rejected = [n for n in nodes
5444 rejected = [n for n in nodes
5334 if newdata[cl.rev(n)] < targetphase]
5445 if newdata[cl.rev(n)] < targetphase]
5335 if rejected:
5446 if rejected:
5336 ui.warn(_('cannot move %i changesets to a higher '
5447 ui.warn(_('cannot move %i changesets to a higher '
5337 'phase, use --force\n') % len(rejected))
5448 'phase, use --force\n') % len(rejected))
5338 ret = 1
5449 ret = 1
5339 if changes:
5450 if changes:
5340 msg = _('phase changed for %i changesets\n') % changes
5451 msg = _('phase changed for %i changesets\n') % changes
5341 if ret:
5452 if ret:
5342 ui.status(msg)
5453 ui.status(msg)
5343 else:
5454 else:
5344 ui.note(msg)
5455 ui.note(msg)
5345 else:
5456 else:
5346 ui.warn(_('no phases changed\n'))
5457 ui.warn(_('no phases changed\n'))
5347 return ret
5458 return ret
5348
5459
5349 def postincoming(ui, repo, modheads, optupdate, checkout):
5460 def postincoming(ui, repo, modheads, optupdate, checkout):
5350 if modheads == 0:
5461 if modheads == 0:
5351 return
5462 return
5352 if optupdate:
5463 if optupdate:
5353 try:
5464 try:
5354 brev = checkout
5465 brev = checkout
5355 movemarkfrom = None
5466 movemarkfrom = None
5356 if not checkout:
5467 if not checkout:
5357 updata = destutil.destupdate(repo)
5468 updata = destutil.destupdate(repo)
5358 checkout, movemarkfrom, brev = updata
5469 checkout, movemarkfrom, brev = updata
5359 ret = hg.update(repo, checkout)
5470 ret = hg.update(repo, checkout)
5360 except error.UpdateAbort as inst:
5471 except error.UpdateAbort as inst:
5361 msg = _("not updating: %s") % str(inst)
5472 msg = _("not updating: %s") % str(inst)
5362 hint = inst.hint
5473 hint = inst.hint
5363 raise error.UpdateAbort(msg, hint=hint)
5474 raise error.UpdateAbort(msg, hint=hint)
5364 if not ret and not checkout:
5475 if not ret and not checkout:
5365 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5476 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5366 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5477 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5367 return ret
5478 return ret
5368 if modheads > 1:
5479 if modheads > 1:
5369 currentbranchheads = len(repo.branchheads())
5480 currentbranchheads = len(repo.branchheads())
5370 if currentbranchheads == modheads:
5481 if currentbranchheads == modheads:
5371 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5482 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5372 elif currentbranchheads > 1:
5483 elif currentbranchheads > 1:
5373 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5484 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5374 "merge)\n"))
5485 "merge)\n"))
5375 else:
5486 else:
5376 ui.status(_("(run 'hg heads' to see heads)\n"))
5487 ui.status(_("(run 'hg heads' to see heads)\n"))
5377 else:
5488 else:
5378 ui.status(_("(run 'hg update' to get a working copy)\n"))
5489 ui.status(_("(run 'hg update' to get a working copy)\n"))
5379
5490
5380 @command('^pull',
5491 @command('^pull',
5381 [('u', 'update', None,
5492 [('u', 'update', None,
5382 _('update to new branch head if changesets were pulled')),
5493 _('update to new branch head if changesets were pulled')),
5383 ('f', 'force', None, _('run even when remote repository is unrelated')),
5494 ('f', 'force', None, _('run even when remote repository is unrelated')),
5384 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5495 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5385 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5496 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5386 ('b', 'branch', [], _('a specific branch you would like to pull'),
5497 ('b', 'branch', [], _('a specific branch you would like to pull'),
5387 _('BRANCH')),
5498 _('BRANCH')),
5388 ] + remoteopts,
5499 ] + remoteopts,
5389 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5500 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5390 def pull(ui, repo, source="default", **opts):
5501 def pull(ui, repo, source="default", **opts):
5391 """pull changes from the specified source
5502 """pull changes from the specified source
5392
5503
5393 Pull changes from a remote repository to a local one.
5504 Pull changes from a remote repository to a local one.
5394
5505
5395 This finds all changes from the repository at the specified path
5506 This finds all changes from the repository at the specified path
5396 or URL and adds them to a local repository (the current one unless
5507 or URL and adds them to a local repository (the current one unless
5397 -R is specified). By default, this does not update the copy of the
5508 -R is specified). By default, this does not update the copy of the
5398 project in the working directory.
5509 project in the working directory.
5399
5510
5400 Use :hg:`incoming` if you want to see what would have been added
5511 Use :hg:`incoming` if you want to see what would have been added
5401 by a pull at the time you issued this command. If you then decide
5512 by a pull at the time you issued this command. If you then decide
5402 to add those changes to the repository, you should use :hg:`pull
5513 to add those changes to the repository, you should use :hg:`pull
5403 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5514 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5404
5515
5405 If SOURCE is omitted, the 'default' path will be used.
5516 If SOURCE is omitted, the 'default' path will be used.
5406 See :hg:`help urls` for more information.
5517 See :hg:`help urls` for more information.
5407
5518
5408 Returns 0 on success, 1 if an update had unresolved files.
5519 Returns 0 on success, 1 if an update had unresolved files.
5409 """
5520 """
5410 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5521 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5411 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5522 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5412 other = hg.peer(repo, opts, source)
5523 other = hg.peer(repo, opts, source)
5413 try:
5524 try:
5414 revs, checkout = hg.addbranchrevs(repo, other, branches,
5525 revs, checkout = hg.addbranchrevs(repo, other, branches,
5415 opts.get('rev'))
5526 opts.get('rev'))
5416
5527
5417
5528
5418 pullopargs = {}
5529 pullopargs = {}
5419 if opts.get('bookmark'):
5530 if opts.get('bookmark'):
5420 if not revs:
5531 if not revs:
5421 revs = []
5532 revs = []
5422 # The list of bookmark used here is not the one used to actually
5533 # The list of bookmark used here is not the one used to actually
5423 # update the bookmark name. This can result in the revision pulled
5534 # update the bookmark name. This can result in the revision pulled
5424 # not ending up with the name of the bookmark because of a race
5535 # not ending up with the name of the bookmark because of a race
5425 # condition on the server. (See issue 4689 for details)
5536 # condition on the server. (See issue 4689 for details)
5426 remotebookmarks = other.listkeys('bookmarks')
5537 remotebookmarks = other.listkeys('bookmarks')
5427 pullopargs['remotebookmarks'] = remotebookmarks
5538 pullopargs['remotebookmarks'] = remotebookmarks
5428 for b in opts['bookmark']:
5539 for b in opts['bookmark']:
5429 if b not in remotebookmarks:
5540 if b not in remotebookmarks:
5430 raise error.Abort(_('remote bookmark %s not found!') % b)
5541 raise error.Abort(_('remote bookmark %s not found!') % b)
5431 revs.append(remotebookmarks[b])
5542 revs.append(remotebookmarks[b])
5432
5543
5433 if revs:
5544 if revs:
5434 try:
5545 try:
5435 # When 'rev' is a bookmark name, we cannot guarantee that it
5546 # When 'rev' is a bookmark name, we cannot guarantee that it
5436 # will be updated with that name because of a race condition
5547 # will be updated with that name because of a race condition
5437 # server side. (See issue 4689 for details)
5548 # server side. (See issue 4689 for details)
5438 oldrevs = revs
5549 oldrevs = revs
5439 revs = [] # actually, nodes
5550 revs = [] # actually, nodes
5440 for r in oldrevs:
5551 for r in oldrevs:
5441 node = other.lookup(r)
5552 node = other.lookup(r)
5442 revs.append(node)
5553 revs.append(node)
5443 if r == checkout:
5554 if r == checkout:
5444 checkout = node
5555 checkout = node
5445 except error.CapabilityError:
5556 except error.CapabilityError:
5446 err = _("other repository doesn't support revision lookup, "
5557 err = _("other repository doesn't support revision lookup, "
5447 "so a rev cannot be specified.")
5558 "so a rev cannot be specified.")
5448 raise error.Abort(err)
5559 raise error.Abort(err)
5449
5560
5450 pullopargs.update(opts.get('opargs', {}))
5561 pullopargs.update(opts.get('opargs', {}))
5451 modheads = exchange.pull(repo, other, heads=revs,
5562 modheads = exchange.pull(repo, other, heads=revs,
5452 force=opts.get('force'),
5563 force=opts.get('force'),
5453 bookmarks=opts.get('bookmark', ()),
5564 bookmarks=opts.get('bookmark', ()),
5454 opargs=pullopargs).cgresult
5565 opargs=pullopargs).cgresult
5455 if checkout:
5566 if checkout:
5456 checkout = str(repo.changelog.rev(checkout))
5567 checkout = str(repo.changelog.rev(checkout))
5457 repo._subtoppath = source
5568 repo._subtoppath = source
5458 try:
5569 try:
5459 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5570 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5460
5571
5461 finally:
5572 finally:
5462 del repo._subtoppath
5573 del repo._subtoppath
5463
5574
5464 finally:
5575 finally:
5465 other.close()
5576 other.close()
5466 return ret
5577 return ret
5467
5578
5468 @command('^push',
5579 @command('^push',
5469 [('f', 'force', None, _('force push')),
5580 [('f', 'force', None, _('force push')),
5470 ('r', 'rev', [],
5581 ('r', 'rev', [],
5471 _('a changeset intended to be included in the destination'),
5582 _('a changeset intended to be included in the destination'),
5472 _('REV')),
5583 _('REV')),
5473 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5584 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5474 ('b', 'branch', [],
5585 ('b', 'branch', [],
5475 _('a specific branch you would like to push'), _('BRANCH')),
5586 _('a specific branch you would like to push'), _('BRANCH')),
5476 ('', 'new-branch', False, _('allow pushing a new branch')),
5587 ('', 'new-branch', False, _('allow pushing a new branch')),
5477 ] + remoteopts,
5588 ] + remoteopts,
5478 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5589 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5479 def push(ui, repo, dest=None, **opts):
5590 def push(ui, repo, dest=None, **opts):
5480 """push changes to the specified destination
5591 """push changes to the specified destination
5481
5592
5482 Push changesets from the local repository to the specified
5593 Push changesets from the local repository to the specified
5483 destination.
5594 destination.
5484
5595
5485 This operation is symmetrical to pull: it is identical to a pull
5596 This operation is symmetrical to pull: it is identical to a pull
5486 in the destination repository from the current one.
5597 in the destination repository from the current one.
5487
5598
5488 By default, push will not allow creation of new heads at the
5599 By default, push will not allow creation of new heads at the
5489 destination, since multiple heads would make it unclear which head
5600 destination, since multiple heads would make it unclear which head
5490 to use. In this situation, it is recommended to pull and merge
5601 to use. In this situation, it is recommended to pull and merge
5491 before pushing.
5602 before pushing.
5492
5603
5493 Use --new-branch if you want to allow push to create a new named
5604 Use --new-branch if you want to allow push to create a new named
5494 branch that is not present at the destination. This allows you to
5605 branch that is not present at the destination. This allows you to
5495 only create a new branch without forcing other changes.
5606 only create a new branch without forcing other changes.
5496
5607
5497 .. note::
5608 .. note::
5498
5609
5499 Extra care should be taken with the -f/--force option,
5610 Extra care should be taken with the -f/--force option,
5500 which will push all new heads on all branches, an action which will
5611 which will push all new heads on all branches, an action which will
5501 almost always cause confusion for collaborators.
5612 almost always cause confusion for collaborators.
5502
5613
5503 If -r/--rev is used, the specified revision and all its ancestors
5614 If -r/--rev is used, the specified revision and all its ancestors
5504 will be pushed to the remote repository.
5615 will be pushed to the remote repository.
5505
5616
5506 If -B/--bookmark is used, the specified bookmarked revision, its
5617 If -B/--bookmark is used, the specified bookmarked revision, its
5507 ancestors, and the bookmark will be pushed to the remote
5618 ancestors, and the bookmark will be pushed to the remote
5508 repository.
5619 repository.
5509
5620
5510 Please see :hg:`help urls` for important details about ``ssh://``
5621 Please see :hg:`help urls` for important details about ``ssh://``
5511 URLs. If DESTINATION is omitted, a default path will be used.
5622 URLs. If DESTINATION is omitted, a default path will be used.
5512
5623
5513 Returns 0 if push was successful, 1 if nothing to push.
5624 Returns 0 if push was successful, 1 if nothing to push.
5514 """
5625 """
5515
5626
5516 if opts.get('bookmark'):
5627 if opts.get('bookmark'):
5517 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5628 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5518 for b in opts['bookmark']:
5629 for b in opts['bookmark']:
5519 # translate -B options to -r so changesets get pushed
5630 # translate -B options to -r so changesets get pushed
5520 if b in repo._bookmarks:
5631 if b in repo._bookmarks:
5521 opts.setdefault('rev', []).append(b)
5632 opts.setdefault('rev', []).append(b)
5522 else:
5633 else:
5523 # if we try to push a deleted bookmark, translate it to null
5634 # if we try to push a deleted bookmark, translate it to null
5524 # this lets simultaneous -r, -b options continue working
5635 # this lets simultaneous -r, -b options continue working
5525 opts.setdefault('rev', []).append("null")
5636 opts.setdefault('rev', []).append("null")
5526
5637
5527 path = ui.paths.getpath(dest, default='default')
5638 path = ui.paths.getpath(dest, default='default')
5528 if not path:
5639 if not path:
5529 raise error.Abort(_('default repository not configured!'),
5640 raise error.Abort(_('default repository not configured!'),
5530 hint=_('see the "path" section in "hg help config"'))
5641 hint=_('see the "path" section in "hg help config"'))
5531 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5642 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5532 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5643 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5533 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5644 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5534 other = hg.peer(repo, opts, dest)
5645 other = hg.peer(repo, opts, dest)
5535
5646
5536 if revs:
5647 if revs:
5537 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5648 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5538 if not revs:
5649 if not revs:
5539 raise error.Abort(_("specified revisions evaluate to an empty set"),
5650 raise error.Abort(_("specified revisions evaluate to an empty set"),
5540 hint=_("use different revision arguments"))
5651 hint=_("use different revision arguments"))
5541
5652
5542 repo._subtoppath = dest
5653 repo._subtoppath = dest
5543 try:
5654 try:
5544 # push subrepos depth-first for coherent ordering
5655 # push subrepos depth-first for coherent ordering
5545 c = repo['']
5656 c = repo['']
5546 subs = c.substate # only repos that are committed
5657 subs = c.substate # only repos that are committed
5547 for s in sorted(subs):
5658 for s in sorted(subs):
5548 result = c.sub(s).push(opts)
5659 result = c.sub(s).push(opts)
5549 if result == 0:
5660 if result == 0:
5550 return not result
5661 return not result
5551 finally:
5662 finally:
5552 del repo._subtoppath
5663 del repo._subtoppath
5553 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5664 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5554 newbranch=opts.get('new_branch'),
5665 newbranch=opts.get('new_branch'),
5555 bookmarks=opts.get('bookmark', ()),
5666 bookmarks=opts.get('bookmark', ()),
5556 opargs=opts.get('opargs'))
5667 opargs=opts.get('opargs'))
5557
5668
5558 result = not pushop.cgresult
5669 result = not pushop.cgresult
5559
5670
5560 if pushop.bkresult is not None:
5671 if pushop.bkresult is not None:
5561 if pushop.bkresult == 2:
5672 if pushop.bkresult == 2:
5562 result = 2
5673 result = 2
5563 elif not result and pushop.bkresult:
5674 elif not result and pushop.bkresult:
5564 result = 2
5675 result = 2
5565
5676
5566 return result
5677 return result
5567
5678
5568 @command('recover', [])
5679 @command('recover', [])
5569 def recover(ui, repo):
5680 def recover(ui, repo):
5570 """roll back an interrupted transaction
5681 """roll back an interrupted transaction
5571
5682
5572 Recover from an interrupted commit or pull.
5683 Recover from an interrupted commit or pull.
5573
5684
5574 This command tries to fix the repository status after an
5685 This command tries to fix the repository status after an
5575 interrupted operation. It should only be necessary when Mercurial
5686 interrupted operation. It should only be necessary when Mercurial
5576 suggests it.
5687 suggests it.
5577
5688
5578 Returns 0 if successful, 1 if nothing to recover or verify fails.
5689 Returns 0 if successful, 1 if nothing to recover or verify fails.
5579 """
5690 """
5580 if repo.recover():
5691 if repo.recover():
5581 return hg.verify(repo)
5692 return hg.verify(repo)
5582 return 1
5693 return 1
5583
5694
5584 @command('^remove|rm',
5695 @command('^remove|rm',
5585 [('A', 'after', None, _('record delete for missing files')),
5696 [('A', 'after', None, _('record delete for missing files')),
5586 ('f', 'force', None,
5697 ('f', 'force', None,
5587 _('remove (and delete) file even if added or modified')),
5698 _('remove (and delete) file even if added or modified')),
5588 ] + subrepoopts + walkopts,
5699 ] + subrepoopts + walkopts,
5589 _('[OPTION]... FILE...'),
5700 _('[OPTION]... FILE...'),
5590 inferrepo=True)
5701 inferrepo=True)
5591 def remove(ui, repo, *pats, **opts):
5702 def remove(ui, repo, *pats, **opts):
5592 """remove the specified files on the next commit
5703 """remove the specified files on the next commit
5593
5704
5594 Schedule the indicated files for removal from the current branch.
5705 Schedule the indicated files for removal from the current branch.
5595
5706
5596 This command schedules the files to be removed at the next commit.
5707 This command schedules the files to be removed at the next commit.
5597 To undo a remove before that, see :hg:`revert`. To undo added
5708 To undo a remove before that, see :hg:`revert`. To undo added
5598 files, see :hg:`forget`.
5709 files, see :hg:`forget`.
5599
5710
5600 .. container:: verbose
5711 .. container:: verbose
5601
5712
5602 -A/--after can be used to remove only files that have already
5713 -A/--after can be used to remove only files that have already
5603 been deleted, -f/--force can be used to force deletion, and -Af
5714 been deleted, -f/--force can be used to force deletion, and -Af
5604 can be used to remove files from the next revision without
5715 can be used to remove files from the next revision without
5605 deleting them from the working directory.
5716 deleting them from the working directory.
5606
5717
5607 The following table details the behavior of remove for different
5718 The following table details the behavior of remove for different
5608 file states (columns) and option combinations (rows). The file
5719 file states (columns) and option combinations (rows). The file
5609 states are Added [A], Clean [C], Modified [M] and Missing [!]
5720 states are Added [A], Clean [C], Modified [M] and Missing [!]
5610 (as reported by :hg:`status`). The actions are Warn, Remove
5721 (as reported by :hg:`status`). The actions are Warn, Remove
5611 (from branch) and Delete (from disk):
5722 (from branch) and Delete (from disk):
5612
5723
5613 ========= == == == ==
5724 ========= == == == ==
5614 opt/state A C M !
5725 opt/state A C M !
5615 ========= == == == ==
5726 ========= == == == ==
5616 none W RD W R
5727 none W RD W R
5617 -f R RD RD R
5728 -f R RD RD R
5618 -A W W W R
5729 -A W W W R
5619 -Af R R R R
5730 -Af R R R R
5620 ========= == == == ==
5731 ========= == == == ==
5621
5732
5622 Note that remove never deletes files in Added [A] state from the
5733 Note that remove never deletes files in Added [A] state from the
5623 working directory, not even if option --force is specified.
5734 working directory, not even if option --force is specified.
5624
5735
5625 Returns 0 on success, 1 if any warnings encountered.
5736 Returns 0 on success, 1 if any warnings encountered.
5626 """
5737 """
5627
5738
5628 after, force = opts.get('after'), opts.get('force')
5739 after, force = opts.get('after'), opts.get('force')
5629 if not pats and not after:
5740 if not pats and not after:
5630 raise error.Abort(_('no files specified'))
5741 raise error.Abort(_('no files specified'))
5631
5742
5632 m = scmutil.match(repo[None], pats, opts)
5743 m = scmutil.match(repo[None], pats, opts)
5633 subrepos = opts.get('subrepos')
5744 subrepos = opts.get('subrepos')
5634 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5745 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5635
5746
5636 @command('rename|move|mv',
5747 @command('rename|move|mv',
5637 [('A', 'after', None, _('record a rename that has already occurred')),
5748 [('A', 'after', None, _('record a rename that has already occurred')),
5638 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5749 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5639 ] + walkopts + dryrunopts,
5750 ] + walkopts + dryrunopts,
5640 _('[OPTION]... SOURCE... DEST'))
5751 _('[OPTION]... SOURCE... DEST'))
5641 def rename(ui, repo, *pats, **opts):
5752 def rename(ui, repo, *pats, **opts):
5642 """rename files; equivalent of copy + remove
5753 """rename files; equivalent of copy + remove
5643
5754
5644 Mark dest as copies of sources; mark sources for deletion. If dest
5755 Mark dest as copies of sources; mark sources for deletion. If dest
5645 is a directory, copies are put in that directory. If dest is a
5756 is a directory, copies are put in that directory. If dest is a
5646 file, there can only be one source.
5757 file, there can only be one source.
5647
5758
5648 By default, this command copies the contents of files as they
5759 By default, this command copies the contents of files as they
5649 exist in the working directory. If invoked with -A/--after, the
5760 exist in the working directory. If invoked with -A/--after, the
5650 operation is recorded, but no copying is performed.
5761 operation is recorded, but no copying is performed.
5651
5762
5652 This command takes effect at the next commit. To undo a rename
5763 This command takes effect at the next commit. To undo a rename
5653 before that, see :hg:`revert`.
5764 before that, see :hg:`revert`.
5654
5765
5655 Returns 0 on success, 1 if errors are encountered.
5766 Returns 0 on success, 1 if errors are encountered.
5656 """
5767 """
5657 wlock = repo.wlock(False)
5768 wlock = repo.wlock(False)
5658 try:
5769 try:
5659 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5770 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5660 finally:
5771 finally:
5661 wlock.release()
5772 wlock.release()
5662
5773
5663 @command('resolve',
5774 @command('resolve',
5664 [('a', 'all', None, _('select all unresolved files')),
5775 [('a', 'all', None, _('select all unresolved files')),
5665 ('l', 'list', None, _('list state of files needing merge')),
5776 ('l', 'list', None, _('list state of files needing merge')),
5666 ('m', 'mark', None, _('mark files as resolved')),
5777 ('m', 'mark', None, _('mark files as resolved')),
5667 ('u', 'unmark', None, _('mark files as unresolved')),
5778 ('u', 'unmark', None, _('mark files as unresolved')),
5668 ('n', 'no-status', None, _('hide status prefix'))]
5779 ('n', 'no-status', None, _('hide status prefix'))]
5669 + mergetoolopts + walkopts + formatteropts,
5780 + mergetoolopts + walkopts + formatteropts,
5670 _('[OPTION]... [FILE]...'),
5781 _('[OPTION]... [FILE]...'),
5671 inferrepo=True)
5782 inferrepo=True)
5672 def resolve(ui, repo, *pats, **opts):
5783 def resolve(ui, repo, *pats, **opts):
5673 """redo merges or set/view the merge status of files
5784 """redo merges or set/view the merge status of files
5674
5785
5675 Merges with unresolved conflicts are often the result of
5786 Merges with unresolved conflicts are often the result of
5676 non-interactive merging using the ``internal:merge`` configuration
5787 non-interactive merging using the ``internal:merge`` configuration
5677 setting, or a command-line merge tool like ``diff3``. The resolve
5788 setting, or a command-line merge tool like ``diff3``. The resolve
5678 command is used to manage the files involved in a merge, after
5789 command is used to manage the files involved in a merge, after
5679 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5790 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5680 working directory must have two parents). See :hg:`help
5791 working directory must have two parents). See :hg:`help
5681 merge-tools` for information on configuring merge tools.
5792 merge-tools` for information on configuring merge tools.
5682
5793
5683 The resolve command can be used in the following ways:
5794 The resolve command can be used in the following ways:
5684
5795
5685 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5796 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5686 files, discarding any previous merge attempts. Re-merging is not
5797 files, discarding any previous merge attempts. Re-merging is not
5687 performed for files already marked as resolved. Use ``--all/-a``
5798 performed for files already marked as resolved. Use ``--all/-a``
5688 to select all unresolved files. ``--tool`` can be used to specify
5799 to select all unresolved files. ``--tool`` can be used to specify
5689 the merge tool used for the given files. It overrides the HGMERGE
5800 the merge tool used for the given files. It overrides the HGMERGE
5690 environment variable and your configuration files. Previous file
5801 environment variable and your configuration files. Previous file
5691 contents are saved with a ``.orig`` suffix.
5802 contents are saved with a ``.orig`` suffix.
5692
5803
5693 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5804 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5694 (e.g. after having manually fixed-up the files). The default is
5805 (e.g. after having manually fixed-up the files). The default is
5695 to mark all unresolved files.
5806 to mark all unresolved files.
5696
5807
5697 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5808 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5698 default is to mark all resolved files.
5809 default is to mark all resolved files.
5699
5810
5700 - :hg:`resolve -l`: list files which had or still have conflicts.
5811 - :hg:`resolve -l`: list files which had or still have conflicts.
5701 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5812 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5702
5813
5703 Note that Mercurial will not let you commit files with unresolved
5814 Note that Mercurial will not let you commit files with unresolved
5704 merge conflicts. You must use :hg:`resolve -m ...` before you can
5815 merge conflicts. You must use :hg:`resolve -m ...` before you can
5705 commit after a conflicting merge.
5816 commit after a conflicting merge.
5706
5817
5707 Returns 0 on success, 1 if any files fail a resolve attempt.
5818 Returns 0 on success, 1 if any files fail a resolve attempt.
5708 """
5819 """
5709
5820
5710 all, mark, unmark, show, nostatus = \
5821 all, mark, unmark, show, nostatus = \
5711 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5822 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5712
5823
5713 if (show and (mark or unmark)) or (mark and unmark):
5824 if (show and (mark or unmark)) or (mark and unmark):
5714 raise error.Abort(_("too many options specified"))
5825 raise error.Abort(_("too many options specified"))
5715 if pats and all:
5826 if pats and all:
5716 raise error.Abort(_("can't specify --all and patterns"))
5827 raise error.Abort(_("can't specify --all and patterns"))
5717 if not (all or pats or show or mark or unmark):
5828 if not (all or pats or show or mark or unmark):
5718 raise error.Abort(_('no files or directories specified'),
5829 raise error.Abort(_('no files or directories specified'),
5719 hint=('use --all to re-merge all unresolved files'))
5830 hint=('use --all to re-merge all unresolved files'))
5720
5831
5721 if show:
5832 if show:
5722 fm = ui.formatter('resolve', opts)
5833 fm = ui.formatter('resolve', opts)
5723 ms = mergemod.mergestate.read(repo)
5834 ms = mergemod.mergestate.read(repo)
5724 m = scmutil.match(repo[None], pats, opts)
5835 m = scmutil.match(repo[None], pats, opts)
5725 for f in ms:
5836 for f in ms:
5726 if not m(f):
5837 if not m(f):
5727 continue
5838 continue
5728 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
5839 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved',
5729 'd': 'driverresolved'}[ms[f]]
5840 'd': 'driverresolved'}[ms[f]]
5730 fm.startitem()
5841 fm.startitem()
5731 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5842 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5732 fm.write('path', '%s\n', f, label=l)
5843 fm.write('path', '%s\n', f, label=l)
5733 fm.end()
5844 fm.end()
5734 return 0
5845 return 0
5735
5846
5736 wlock = repo.wlock()
5847 wlock = repo.wlock()
5737 try:
5848 try:
5738 ms = mergemod.mergestate.read(repo)
5849 ms = mergemod.mergestate.read(repo)
5739
5850
5740 if not (ms.active() or repo.dirstate.p2() != nullid):
5851 if not (ms.active() or repo.dirstate.p2() != nullid):
5741 raise error.Abort(
5852 raise error.Abort(
5742 _('resolve command not applicable when not merging'))
5853 _('resolve command not applicable when not merging'))
5743
5854
5744 wctx = repo[None]
5855 wctx = repo[None]
5745
5856
5746 if ms.mergedriver and ms.mdstate() == 'u':
5857 if ms.mergedriver and ms.mdstate() == 'u':
5747 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5858 proceed = mergemod.driverpreprocess(repo, ms, wctx)
5748 ms.commit()
5859 ms.commit()
5749 # allow mark and unmark to go through
5860 # allow mark and unmark to go through
5750 if not mark and not unmark and not proceed:
5861 if not mark and not unmark and not proceed:
5751 return 1
5862 return 1
5752
5863
5753 m = scmutil.match(wctx, pats, opts)
5864 m = scmutil.match(wctx, pats, opts)
5754 ret = 0
5865 ret = 0
5755 didwork = False
5866 didwork = False
5756 runconclude = False
5867 runconclude = False
5757
5868
5758 tocomplete = []
5869 tocomplete = []
5759 for f in ms:
5870 for f in ms:
5760 if not m(f):
5871 if not m(f):
5761 continue
5872 continue
5762
5873
5763 didwork = True
5874 didwork = True
5764
5875
5765 # don't let driver-resolved files be marked, and run the conclude
5876 # don't let driver-resolved files be marked, and run the conclude
5766 # step if asked to resolve
5877 # step if asked to resolve
5767 if ms[f] == "d":
5878 if ms[f] == "d":
5768 exact = m.exact(f)
5879 exact = m.exact(f)
5769 if mark:
5880 if mark:
5770 if exact:
5881 if exact:
5771 ui.warn(_('not marking %s as it is driver-resolved\n')
5882 ui.warn(_('not marking %s as it is driver-resolved\n')
5772 % f)
5883 % f)
5773 elif unmark:
5884 elif unmark:
5774 if exact:
5885 if exact:
5775 ui.warn(_('not unmarking %s as it is driver-resolved\n')
5886 ui.warn(_('not unmarking %s as it is driver-resolved\n')
5776 % f)
5887 % f)
5777 else:
5888 else:
5778 runconclude = True
5889 runconclude = True
5779 continue
5890 continue
5780
5891
5781 if mark:
5892 if mark:
5782 ms.mark(f, "r")
5893 ms.mark(f, "r")
5783 elif unmark:
5894 elif unmark:
5784 ms.mark(f, "u")
5895 ms.mark(f, "u")
5785 else:
5896 else:
5786 # backup pre-resolve (merge uses .orig for its own purposes)
5897 # backup pre-resolve (merge uses .orig for its own purposes)
5787 a = repo.wjoin(f)
5898 a = repo.wjoin(f)
5788 try:
5899 try:
5789 util.copyfile(a, a + ".resolve")
5900 util.copyfile(a, a + ".resolve")
5790 except (IOError, OSError) as inst:
5901 except (IOError, OSError) as inst:
5791 if inst.errno != errno.ENOENT:
5902 if inst.errno != errno.ENOENT:
5792 raise
5903 raise
5793
5904
5794 try:
5905 try:
5795 # preresolve file
5906 # preresolve file
5796 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5907 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5797 'resolve')
5908 'resolve')
5798 complete, r = ms.preresolve(f, wctx)
5909 complete, r = ms.preresolve(f, wctx)
5799 if not complete:
5910 if not complete:
5800 tocomplete.append(f)
5911 tocomplete.append(f)
5801 elif r:
5912 elif r:
5802 ret = 1
5913 ret = 1
5803 finally:
5914 finally:
5804 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5915 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5805 ms.commit()
5916 ms.commit()
5806
5917
5807 # replace filemerge's .orig file with our resolve file, but only
5918 # replace filemerge's .orig file with our resolve file, but only
5808 # for merges that are complete
5919 # for merges that are complete
5809 if complete:
5920 if complete:
5810 try:
5921 try:
5811 util.rename(a + ".resolve",
5922 util.rename(a + ".resolve",
5812 cmdutil.origpath(ui, repo, a))
5923 cmdutil.origpath(ui, repo, a))
5813 except OSError as inst:
5924 except OSError as inst:
5814 if inst.errno != errno.ENOENT:
5925 if inst.errno != errno.ENOENT:
5815 raise
5926 raise
5816
5927
5817 for f in tocomplete:
5928 for f in tocomplete:
5818 try:
5929 try:
5819 # resolve file
5930 # resolve file
5820 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5931 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5821 'resolve')
5932 'resolve')
5822 r = ms.resolve(f, wctx)
5933 r = ms.resolve(f, wctx)
5823 if r:
5934 if r:
5824 ret = 1
5935 ret = 1
5825 finally:
5936 finally:
5826 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5937 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5827 ms.commit()
5938 ms.commit()
5828
5939
5829 # replace filemerge's .orig file with our resolve file
5940 # replace filemerge's .orig file with our resolve file
5830 a = repo.wjoin(f)
5941 a = repo.wjoin(f)
5831 try:
5942 try:
5832 util.rename(a + ".resolve", cmdutil.origpath(ui, repo, a))
5943 util.rename(a + ".resolve", cmdutil.origpath(ui, repo, a))
5833 except OSError as inst:
5944 except OSError as inst:
5834 if inst.errno != errno.ENOENT:
5945 if inst.errno != errno.ENOENT:
5835 raise
5946 raise
5836
5947
5837 ms.commit()
5948 ms.commit()
5838 ms.recordactions()
5949 ms.recordactions()
5839
5950
5840 if not didwork and pats:
5951 if not didwork and pats:
5841 ui.warn(_("arguments do not match paths that need resolving\n"))
5952 ui.warn(_("arguments do not match paths that need resolving\n"))
5842 elif ms.mergedriver and ms.mdstate() != 's':
5953 elif ms.mergedriver and ms.mdstate() != 's':
5843 # run conclude step when either a driver-resolved file is requested
5954 # run conclude step when either a driver-resolved file is requested
5844 # or there are no driver-resolved files
5955 # or there are no driver-resolved files
5845 # we can't use 'ret' to determine whether any files are unresolved
5956 # we can't use 'ret' to determine whether any files are unresolved
5846 # because we might not have tried to resolve some
5957 # because we might not have tried to resolve some
5847 if ((runconclude or not list(ms.driverresolved()))
5958 if ((runconclude or not list(ms.driverresolved()))
5848 and not list(ms.unresolved())):
5959 and not list(ms.unresolved())):
5849 proceed = mergemod.driverconclude(repo, ms, wctx)
5960 proceed = mergemod.driverconclude(repo, ms, wctx)
5850 ms.commit()
5961 ms.commit()
5851 if not proceed:
5962 if not proceed:
5852 return 1
5963 return 1
5853
5964
5854 finally:
5965 finally:
5855 wlock.release()
5966 wlock.release()
5856
5967
5857 # Nudge users into finishing an unfinished operation
5968 # Nudge users into finishing an unfinished operation
5858 unresolvedf = list(ms.unresolved())
5969 unresolvedf = list(ms.unresolved())
5859 driverresolvedf = list(ms.driverresolved())
5970 driverresolvedf = list(ms.driverresolved())
5860 if not unresolvedf and not driverresolvedf:
5971 if not unresolvedf and not driverresolvedf:
5861 ui.status(_('(no more unresolved files)\n'))
5972 ui.status(_('(no more unresolved files)\n'))
5862 elif not unresolvedf:
5973 elif not unresolvedf:
5863 ui.status(_('(no more unresolved files -- '
5974 ui.status(_('(no more unresolved files -- '
5864 'run "hg resolve --all" to conclude)\n'))
5975 'run "hg resolve --all" to conclude)\n'))
5865
5976
5866 return ret
5977 return ret
5867
5978
5868 @command('revert',
5979 @command('revert',
5869 [('a', 'all', None, _('revert all changes when no arguments given')),
5980 [('a', 'all', None, _('revert all changes when no arguments given')),
5870 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5981 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5871 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5982 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5872 ('C', 'no-backup', None, _('do not save backup copies of files')),
5983 ('C', 'no-backup', None, _('do not save backup copies of files')),
5873 ('i', 'interactive', None,
5984 ('i', 'interactive', None,
5874 _('interactively select the changes (EXPERIMENTAL)')),
5985 _('interactively select the changes (EXPERIMENTAL)')),
5875 ] + walkopts + dryrunopts,
5986 ] + walkopts + dryrunopts,
5876 _('[OPTION]... [-r REV] [NAME]...'))
5987 _('[OPTION]... [-r REV] [NAME]...'))
5877 def revert(ui, repo, *pats, **opts):
5988 def revert(ui, repo, *pats, **opts):
5878 """restore files to their checkout state
5989 """restore files to their checkout state
5879
5990
5880 .. note::
5991 .. note::
5881
5992
5882 To check out earlier revisions, you should use :hg:`update REV`.
5993 To check out earlier revisions, you should use :hg:`update REV`.
5883 To cancel an uncommitted merge (and lose your changes),
5994 To cancel an uncommitted merge (and lose your changes),
5884 use :hg:`update --clean .`.
5995 use :hg:`update --clean .`.
5885
5996
5886 With no revision specified, revert the specified files or directories
5997 With no revision specified, revert the specified files or directories
5887 to the contents they had in the parent of the working directory.
5998 to the contents they had in the parent of the working directory.
5888 This restores the contents of files to an unmodified
5999 This restores the contents of files to an unmodified
5889 state and unschedules adds, removes, copies, and renames. If the
6000 state and unschedules adds, removes, copies, and renames. If the
5890 working directory has two parents, you must explicitly specify a
6001 working directory has two parents, you must explicitly specify a
5891 revision.
6002 revision.
5892
6003
5893 Using the -r/--rev or -d/--date options, revert the given files or
6004 Using the -r/--rev or -d/--date options, revert the given files or
5894 directories to their states as of a specific revision. Because
6005 directories to their states as of a specific revision. Because
5895 revert does not change the working directory parents, this will
6006 revert does not change the working directory parents, this will
5896 cause these files to appear modified. This can be helpful to "back
6007 cause these files to appear modified. This can be helpful to "back
5897 out" some or all of an earlier change. See :hg:`backout` for a
6008 out" some or all of an earlier change. See :hg:`backout` for a
5898 related method.
6009 related method.
5899
6010
5900 Modified files are saved with a .orig suffix before reverting.
6011 Modified files are saved with a .orig suffix before reverting.
5901 To disable these backups, use --no-backup.
6012 To disable these backups, use --no-backup.
5902
6013
5903 See :hg:`help dates` for a list of formats valid for -d/--date.
6014 See :hg:`help dates` for a list of formats valid for -d/--date.
5904
6015
5905 See :hg:`help backout` for a way to reverse the effect of an
6016 See :hg:`help backout` for a way to reverse the effect of an
5906 earlier changeset.
6017 earlier changeset.
5907
6018
5908 Returns 0 on success.
6019 Returns 0 on success.
5909 """
6020 """
5910
6021
5911 if opts.get("date"):
6022 if opts.get("date"):
5912 if opts.get("rev"):
6023 if opts.get("rev"):
5913 raise error.Abort(_("you can't specify a revision and a date"))
6024 raise error.Abort(_("you can't specify a revision and a date"))
5914 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
6025 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5915
6026
5916 parent, p2 = repo.dirstate.parents()
6027 parent, p2 = repo.dirstate.parents()
5917 if not opts.get('rev') and p2 != nullid:
6028 if not opts.get('rev') and p2 != nullid:
5918 # revert after merge is a trap for new users (issue2915)
6029 # revert after merge is a trap for new users (issue2915)
5919 raise error.Abort(_('uncommitted merge with no revision specified'),
6030 raise error.Abort(_('uncommitted merge with no revision specified'),
5920 hint=_('use "hg update" or see "hg help revert"'))
6031 hint=_('use "hg update" or see "hg help revert"'))
5921
6032
5922 ctx = scmutil.revsingle(repo, opts.get('rev'))
6033 ctx = scmutil.revsingle(repo, opts.get('rev'))
5923
6034
5924 if (not (pats or opts.get('include') or opts.get('exclude') or
6035 if (not (pats or opts.get('include') or opts.get('exclude') or
5925 opts.get('all') or opts.get('interactive'))):
6036 opts.get('all') or opts.get('interactive'))):
5926 msg = _("no files or directories specified")
6037 msg = _("no files or directories specified")
5927 if p2 != nullid:
6038 if p2 != nullid:
5928 hint = _("uncommitted merge, use --all to discard all changes,"
6039 hint = _("uncommitted merge, use --all to discard all changes,"
5929 " or 'hg update -C .' to abort the merge")
6040 " or 'hg update -C .' to abort the merge")
5930 raise error.Abort(msg, hint=hint)
6041 raise error.Abort(msg, hint=hint)
5931 dirty = any(repo.status())
6042 dirty = any(repo.status())
5932 node = ctx.node()
6043 node = ctx.node()
5933 if node != parent:
6044 if node != parent:
5934 if dirty:
6045 if dirty:
5935 hint = _("uncommitted changes, use --all to discard all"
6046 hint = _("uncommitted changes, use --all to discard all"
5936 " changes, or 'hg update %s' to update") % ctx.rev()
6047 " changes, or 'hg update %s' to update") % ctx.rev()
5937 else:
6048 else:
5938 hint = _("use --all to revert all files,"
6049 hint = _("use --all to revert all files,"
5939 " or 'hg update %s' to update") % ctx.rev()
6050 " or 'hg update %s' to update") % ctx.rev()
5940 elif dirty:
6051 elif dirty:
5941 hint = _("uncommitted changes, use --all to discard all changes")
6052 hint = _("uncommitted changes, use --all to discard all changes")
5942 else:
6053 else:
5943 hint = _("use --all to revert all files")
6054 hint = _("use --all to revert all files")
5944 raise error.Abort(msg, hint=hint)
6055 raise error.Abort(msg, hint=hint)
5945
6056
5946 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
6057 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5947
6058
5948 @command('rollback', dryrunopts +
6059 @command('rollback', dryrunopts +
5949 [('f', 'force', False, _('ignore safety measures'))])
6060 [('f', 'force', False, _('ignore safety measures'))])
5950 def rollback(ui, repo, **opts):
6061 def rollback(ui, repo, **opts):
5951 """roll back the last transaction (DANGEROUS) (DEPRECATED)
6062 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5952
6063
5953 Please use :hg:`commit --amend` instead of rollback to correct
6064 Please use :hg:`commit --amend` instead of rollback to correct
5954 mistakes in the last commit.
6065 mistakes in the last commit.
5955
6066
5956 This command should be used with care. There is only one level of
6067 This command should be used with care. There is only one level of
5957 rollback, and there is no way to undo a rollback. It will also
6068 rollback, and there is no way to undo a rollback. It will also
5958 restore the dirstate at the time of the last transaction, losing
6069 restore the dirstate at the time of the last transaction, losing
5959 any dirstate changes since that time. This command does not alter
6070 any dirstate changes since that time. This command does not alter
5960 the working directory.
6071 the working directory.
5961
6072
5962 Transactions are used to encapsulate the effects of all commands
6073 Transactions are used to encapsulate the effects of all commands
5963 that create new changesets or propagate existing changesets into a
6074 that create new changesets or propagate existing changesets into a
5964 repository.
6075 repository.
5965
6076
5966 .. container:: verbose
6077 .. container:: verbose
5967
6078
5968 For example, the following commands are transactional, and their
6079 For example, the following commands are transactional, and their
5969 effects can be rolled back:
6080 effects can be rolled back:
5970
6081
5971 - commit
6082 - commit
5972 - import
6083 - import
5973 - pull
6084 - pull
5974 - push (with this repository as the destination)
6085 - push (with this repository as the destination)
5975 - unbundle
6086 - unbundle
5976
6087
5977 To avoid permanent data loss, rollback will refuse to rollback a
6088 To avoid permanent data loss, rollback will refuse to rollback a
5978 commit transaction if it isn't checked out. Use --force to
6089 commit transaction if it isn't checked out. Use --force to
5979 override this protection.
6090 override this protection.
5980
6091
5981 This command is not intended for use on public repositories. Once
6092 This command is not intended for use on public repositories. Once
5982 changes are visible for pull by other users, rolling a transaction
6093 changes are visible for pull by other users, rolling a transaction
5983 back locally is ineffective (someone else may already have pulled
6094 back locally is ineffective (someone else may already have pulled
5984 the changes). Furthermore, a race is possible with readers of the
6095 the changes). Furthermore, a race is possible with readers of the
5985 repository; for example an in-progress pull from the repository
6096 repository; for example an in-progress pull from the repository
5986 may fail if a rollback is performed.
6097 may fail if a rollback is performed.
5987
6098
5988 Returns 0 on success, 1 if no rollback data is available.
6099 Returns 0 on success, 1 if no rollback data is available.
5989 """
6100 """
5990 return repo.rollback(dryrun=opts.get('dry_run'),
6101 return repo.rollback(dryrun=opts.get('dry_run'),
5991 force=opts.get('force'))
6102 force=opts.get('force'))
5992
6103
5993 @command('root', [])
6104 @command('root', [])
5994 def root(ui, repo):
6105 def root(ui, repo):
5995 """print the root (top) of the current working directory
6106 """print the root (top) of the current working directory
5996
6107
5997 Print the root directory of the current repository.
6108 Print the root directory of the current repository.
5998
6109
5999 Returns 0 on success.
6110 Returns 0 on success.
6000 """
6111 """
6001 ui.write(repo.root + "\n")
6112 ui.write(repo.root + "\n")
6002
6113
6003 @command('^serve',
6114 @command('^serve',
6004 [('A', 'accesslog', '', _('name of access log file to write to'),
6115 [('A', 'accesslog', '', _('name of access log file to write to'),
6005 _('FILE')),
6116 _('FILE')),
6006 ('d', 'daemon', None, _('run server in background')),
6117 ('d', 'daemon', None, _('run server in background')),
6007 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
6118 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
6008 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
6119 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
6009 # use string type, then we can check if something was passed
6120 # use string type, then we can check if something was passed
6010 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
6121 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
6011 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
6122 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
6012 _('ADDR')),
6123 _('ADDR')),
6013 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
6124 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
6014 _('PREFIX')),
6125 _('PREFIX')),
6015 ('n', 'name', '',
6126 ('n', 'name', '',
6016 _('name to show in web pages (default: working directory)'), _('NAME')),
6127 _('name to show in web pages (default: working directory)'), _('NAME')),
6017 ('', 'web-conf', '',
6128 ('', 'web-conf', '',
6018 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
6129 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
6019 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
6130 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
6020 _('FILE')),
6131 _('FILE')),
6021 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
6132 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
6022 ('', 'stdio', None, _('for remote clients')),
6133 ('', 'stdio', None, _('for remote clients')),
6023 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
6134 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
6024 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
6135 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
6025 ('', 'style', '', _('template style to use'), _('STYLE')),
6136 ('', 'style', '', _('template style to use'), _('STYLE')),
6026 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
6137 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
6027 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
6138 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
6028 _('[OPTION]...'),
6139 _('[OPTION]...'),
6029 optionalrepo=True)
6140 optionalrepo=True)
6030 def serve(ui, repo, **opts):
6141 def serve(ui, repo, **opts):
6031 """start stand-alone webserver
6142 """start stand-alone webserver
6032
6143
6033 Start a local HTTP repository browser and pull server. You can use
6144 Start a local HTTP repository browser and pull server. You can use
6034 this for ad-hoc sharing and browsing of repositories. It is
6145 this for ad-hoc sharing and browsing of repositories. It is
6035 recommended to use a real web server to serve a repository for
6146 recommended to use a real web server to serve a repository for
6036 longer periods of time.
6147 longer periods of time.
6037
6148
6038 Please note that the server does not implement access control.
6149 Please note that the server does not implement access control.
6039 This means that, by default, anybody can read from the server and
6150 This means that, by default, anybody can read from the server and
6040 nobody can write to it by default. Set the ``web.allow_push``
6151 nobody can write to it by default. Set the ``web.allow_push``
6041 option to ``*`` to allow everybody to push to the server. You
6152 option to ``*`` to allow everybody to push to the server. You
6042 should use a real web server if you need to authenticate users.
6153 should use a real web server if you need to authenticate users.
6043
6154
6044 By default, the server logs accesses to stdout and errors to
6155 By default, the server logs accesses to stdout and errors to
6045 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6156 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
6046 files.
6157 files.
6047
6158
6048 To have the server choose a free port number to listen on, specify
6159 To have the server choose a free port number to listen on, specify
6049 a port number of 0; in this case, the server will print the port
6160 a port number of 0; in this case, the server will print the port
6050 number it uses.
6161 number it uses.
6051
6162
6052 Returns 0 on success.
6163 Returns 0 on success.
6053 """
6164 """
6054
6165
6055 if opts["stdio"] and opts["cmdserver"]:
6166 if opts["stdio"] and opts["cmdserver"]:
6056 raise error.Abort(_("cannot use --stdio with --cmdserver"))
6167 raise error.Abort(_("cannot use --stdio with --cmdserver"))
6057
6168
6058 if opts["stdio"]:
6169 if opts["stdio"]:
6059 if repo is None:
6170 if repo is None:
6060 raise error.RepoError(_("there is no Mercurial repository here"
6171 raise error.RepoError(_("there is no Mercurial repository here"
6061 " (.hg not found)"))
6172 " (.hg not found)"))
6062 s = sshserver.sshserver(ui, repo)
6173 s = sshserver.sshserver(ui, repo)
6063 s.serve_forever()
6174 s.serve_forever()
6064
6175
6065 if opts["cmdserver"]:
6176 if opts["cmdserver"]:
6066 import commandserver
6177 import commandserver
6067 service = commandserver.createservice(ui, repo, opts)
6178 service = commandserver.createservice(ui, repo, opts)
6068 else:
6179 else:
6069 service = hgweb.createservice(ui, repo, opts)
6180 service = hgweb.createservice(ui, repo, opts)
6070 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
6181 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
6071
6182
6072 @command('^status|st',
6183 @command('^status|st',
6073 [('A', 'all', None, _('show status of all files')),
6184 [('A', 'all', None, _('show status of all files')),
6074 ('m', 'modified', None, _('show only modified files')),
6185 ('m', 'modified', None, _('show only modified files')),
6075 ('a', 'added', None, _('show only added files')),
6186 ('a', 'added', None, _('show only added files')),
6076 ('r', 'removed', None, _('show only removed files')),
6187 ('r', 'removed', None, _('show only removed files')),
6077 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
6188 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
6078 ('c', 'clean', None, _('show only files without changes')),
6189 ('c', 'clean', None, _('show only files without changes')),
6079 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
6190 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
6080 ('i', 'ignored', None, _('show only ignored files')),
6191 ('i', 'ignored', None, _('show only ignored files')),
6081 ('n', 'no-status', None, _('hide status prefix')),
6192 ('n', 'no-status', None, _('hide status prefix')),
6082 ('C', 'copies', None, _('show source of copied files')),
6193 ('C', 'copies', None, _('show source of copied files')),
6083 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
6194 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
6084 ('', 'rev', [], _('show difference from revision'), _('REV')),
6195 ('', 'rev', [], _('show difference from revision'), _('REV')),
6085 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
6196 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
6086 ] + walkopts + subrepoopts + formatteropts,
6197 ] + walkopts + subrepoopts + formatteropts,
6087 _('[OPTION]... [FILE]...'),
6198 _('[OPTION]... [FILE]...'),
6088 inferrepo=True)
6199 inferrepo=True)
6089 def status(ui, repo, *pats, **opts):
6200 def status(ui, repo, *pats, **opts):
6090 """show changed files in the working directory
6201 """show changed files in the working directory
6091
6202
6092 Show status of files in the repository. If names are given, only
6203 Show status of files in the repository. If names are given, only
6093 files that match are shown. Files that are clean or ignored or
6204 files that match are shown. Files that are clean or ignored or
6094 the source of a copy/move operation, are not listed unless
6205 the source of a copy/move operation, are not listed unless
6095 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6206 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
6096 Unless options described with "show only ..." are given, the
6207 Unless options described with "show only ..." are given, the
6097 options -mardu are used.
6208 options -mardu are used.
6098
6209
6099 Option -q/--quiet hides untracked (unknown and ignored) files
6210 Option -q/--quiet hides untracked (unknown and ignored) files
6100 unless explicitly requested with -u/--unknown or -i/--ignored.
6211 unless explicitly requested with -u/--unknown or -i/--ignored.
6101
6212
6102 .. note::
6213 .. note::
6103
6214
6104 status may appear to disagree with diff if permissions have
6215 status may appear to disagree with diff if permissions have
6105 changed or a merge has occurred. The standard diff format does
6216 changed or a merge has occurred. The standard diff format does
6106 not report permission changes and diff only reports changes
6217 not report permission changes and diff only reports changes
6107 relative to one merge parent.
6218 relative to one merge parent.
6108
6219
6109 If one revision is given, it is used as the base revision.
6220 If one revision is given, it is used as the base revision.
6110 If two revisions are given, the differences between them are
6221 If two revisions are given, the differences between them are
6111 shown. The --change option can also be used as a shortcut to list
6222 shown. The --change option can also be used as a shortcut to list
6112 the changed files of a revision from its first parent.
6223 the changed files of a revision from its first parent.
6113
6224
6114 The codes used to show the status of files are::
6225 The codes used to show the status of files are::
6115
6226
6116 M = modified
6227 M = modified
6117 A = added
6228 A = added
6118 R = removed
6229 R = removed
6119 C = clean
6230 C = clean
6120 ! = missing (deleted by non-hg command, but still tracked)
6231 ! = missing (deleted by non-hg command, but still tracked)
6121 ? = not tracked
6232 ? = not tracked
6122 I = ignored
6233 I = ignored
6123 = origin of the previous file (with --copies)
6234 = origin of the previous file (with --copies)
6124
6235
6125 .. container:: verbose
6236 .. container:: verbose
6126
6237
6127 Examples:
6238 Examples:
6128
6239
6129 - show changes in the working directory relative to a
6240 - show changes in the working directory relative to a
6130 changeset::
6241 changeset::
6131
6242
6132 hg status --rev 9353
6243 hg status --rev 9353
6133
6244
6134 - show changes in the working directory relative to the
6245 - show changes in the working directory relative to the
6135 current directory (see :hg:`help patterns` for more information)::
6246 current directory (see :hg:`help patterns` for more information)::
6136
6247
6137 hg status re:
6248 hg status re:
6138
6249
6139 - show all changes including copies in an existing changeset::
6250 - show all changes including copies in an existing changeset::
6140
6251
6141 hg status --copies --change 9353
6252 hg status --copies --change 9353
6142
6253
6143 - get a NUL separated list of added files, suitable for xargs::
6254 - get a NUL separated list of added files, suitable for xargs::
6144
6255
6145 hg status -an0
6256 hg status -an0
6146
6257
6147 Returns 0 on success.
6258 Returns 0 on success.
6148 """
6259 """
6149
6260
6150 revs = opts.get('rev')
6261 revs = opts.get('rev')
6151 change = opts.get('change')
6262 change = opts.get('change')
6152
6263
6153 if revs and change:
6264 if revs and change:
6154 msg = _('cannot specify --rev and --change at the same time')
6265 msg = _('cannot specify --rev and --change at the same time')
6155 raise error.Abort(msg)
6266 raise error.Abort(msg)
6156 elif change:
6267 elif change:
6157 node2 = scmutil.revsingle(repo, change, None).node()
6268 node2 = scmutil.revsingle(repo, change, None).node()
6158 node1 = repo[node2].p1().node()
6269 node1 = repo[node2].p1().node()
6159 else:
6270 else:
6160 node1, node2 = scmutil.revpair(repo, revs)
6271 node1, node2 = scmutil.revpair(repo, revs)
6161
6272
6162 if pats:
6273 if pats:
6163 cwd = repo.getcwd()
6274 cwd = repo.getcwd()
6164 else:
6275 else:
6165 cwd = ''
6276 cwd = ''
6166
6277
6167 if opts.get('print0'):
6278 if opts.get('print0'):
6168 end = '\0'
6279 end = '\0'
6169 else:
6280 else:
6170 end = '\n'
6281 end = '\n'
6171 copy = {}
6282 copy = {}
6172 states = 'modified added removed deleted unknown ignored clean'.split()
6283 states = 'modified added removed deleted unknown ignored clean'.split()
6173 show = [k for k in states if opts.get(k)]
6284 show = [k for k in states if opts.get(k)]
6174 if opts.get('all'):
6285 if opts.get('all'):
6175 show += ui.quiet and (states[:4] + ['clean']) or states
6286 show += ui.quiet and (states[:4] + ['clean']) or states
6176 if not show:
6287 if not show:
6177 if ui.quiet:
6288 if ui.quiet:
6178 show = states[:4]
6289 show = states[:4]
6179 else:
6290 else:
6180 show = states[:5]
6291 show = states[:5]
6181
6292
6182 m = scmutil.match(repo[node2], pats, opts)
6293 m = scmutil.match(repo[node2], pats, opts)
6183 stat = repo.status(node1, node2, m,
6294 stat = repo.status(node1, node2, m,
6184 'ignored' in show, 'clean' in show, 'unknown' in show,
6295 'ignored' in show, 'clean' in show, 'unknown' in show,
6185 opts.get('subrepos'))
6296 opts.get('subrepos'))
6186 changestates = zip(states, 'MAR!?IC', stat)
6297 changestates = zip(states, 'MAR!?IC', stat)
6187
6298
6188 if (opts.get('all') or opts.get('copies')
6299 if (opts.get('all') or opts.get('copies')
6189 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6300 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6190 copy = copies.pathcopies(repo[node1], repo[node2], m)
6301 copy = copies.pathcopies(repo[node1], repo[node2], m)
6191
6302
6192 fm = ui.formatter('status', opts)
6303 fm = ui.formatter('status', opts)
6193 fmt = '%s' + end
6304 fmt = '%s' + end
6194 showchar = not opts.get('no_status')
6305 showchar = not opts.get('no_status')
6195
6306
6196 for state, char, files in changestates:
6307 for state, char, files in changestates:
6197 if state in show:
6308 if state in show:
6198 label = 'status.' + state
6309 label = 'status.' + state
6199 for f in files:
6310 for f in files:
6200 fm.startitem()
6311 fm.startitem()
6201 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6312 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6202 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6313 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6203 if f in copy:
6314 if f in copy:
6204 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6315 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6205 label='status.copied')
6316 label='status.copied')
6206 fm.end()
6317 fm.end()
6207
6318
6208 @command('^summary|sum',
6319 @command('^summary|sum',
6209 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6320 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6210 def summary(ui, repo, **opts):
6321 def summary(ui, repo, **opts):
6211 """summarize working directory state
6322 """summarize working directory state
6212
6323
6213 This generates a brief summary of the working directory state,
6324 This generates a brief summary of the working directory state,
6214 including parents, branch, commit status, phase and available updates.
6325 including parents, branch, commit status, phase and available updates.
6215
6326
6216 With the --remote option, this will check the default paths for
6327 With the --remote option, this will check the default paths for
6217 incoming and outgoing changes. This can be time-consuming.
6328 incoming and outgoing changes. This can be time-consuming.
6218
6329
6219 Returns 0 on success.
6330 Returns 0 on success.
6220 """
6331 """
6221
6332
6222 ctx = repo[None]
6333 ctx = repo[None]
6223 parents = ctx.parents()
6334 parents = ctx.parents()
6224 pnode = parents[0].node()
6335 pnode = parents[0].node()
6225 marks = []
6336 marks = []
6226
6337
6227 for p in parents:
6338 for p in parents:
6228 # label with log.changeset (instead of log.parent) since this
6339 # label with log.changeset (instead of log.parent) since this
6229 # shows a working directory parent *changeset*:
6340 # shows a working directory parent *changeset*:
6230 # i18n: column positioning for "hg summary"
6341 # i18n: column positioning for "hg summary"
6231 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6342 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6232 label='log.changeset changeset.%s' % p.phasestr())
6343 label='log.changeset changeset.%s' % p.phasestr())
6233 ui.write(' '.join(p.tags()), label='log.tag')
6344 ui.write(' '.join(p.tags()), label='log.tag')
6234 if p.bookmarks():
6345 if p.bookmarks():
6235 marks.extend(p.bookmarks())
6346 marks.extend(p.bookmarks())
6236 if p.rev() == -1:
6347 if p.rev() == -1:
6237 if not len(repo):
6348 if not len(repo):
6238 ui.write(_(' (empty repository)'))
6349 ui.write(_(' (empty repository)'))
6239 else:
6350 else:
6240 ui.write(_(' (no revision checked out)'))
6351 ui.write(_(' (no revision checked out)'))
6241 ui.write('\n')
6352 ui.write('\n')
6242 if p.description():
6353 if p.description():
6243 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6354 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6244 label='log.summary')
6355 label='log.summary')
6245
6356
6246 branch = ctx.branch()
6357 branch = ctx.branch()
6247 bheads = repo.branchheads(branch)
6358 bheads = repo.branchheads(branch)
6248 # i18n: column positioning for "hg summary"
6359 # i18n: column positioning for "hg summary"
6249 m = _('branch: %s\n') % branch
6360 m = _('branch: %s\n') % branch
6250 if branch != 'default':
6361 if branch != 'default':
6251 ui.write(m, label='log.branch')
6362 ui.write(m, label='log.branch')
6252 else:
6363 else:
6253 ui.status(m, label='log.branch')
6364 ui.status(m, label='log.branch')
6254
6365
6255 if marks:
6366 if marks:
6256 active = repo._activebookmark
6367 active = repo._activebookmark
6257 # i18n: column positioning for "hg summary"
6368 # i18n: column positioning for "hg summary"
6258 ui.write(_('bookmarks:'), label='log.bookmark')
6369 ui.write(_('bookmarks:'), label='log.bookmark')
6259 if active is not None:
6370 if active is not None:
6260 if active in marks:
6371 if active in marks:
6261 ui.write(' *' + active, label=activebookmarklabel)
6372 ui.write(' *' + active, label=activebookmarklabel)
6262 marks.remove(active)
6373 marks.remove(active)
6263 else:
6374 else:
6264 ui.write(' [%s]' % active, label=activebookmarklabel)
6375 ui.write(' [%s]' % active, label=activebookmarklabel)
6265 for m in marks:
6376 for m in marks:
6266 ui.write(' ' + m, label='log.bookmark')
6377 ui.write(' ' + m, label='log.bookmark')
6267 ui.write('\n', label='log.bookmark')
6378 ui.write('\n', label='log.bookmark')
6268
6379
6269 status = repo.status(unknown=True)
6380 status = repo.status(unknown=True)
6270
6381
6271 c = repo.dirstate.copies()
6382 c = repo.dirstate.copies()
6272 copied, renamed = [], []
6383 copied, renamed = [], []
6273 for d, s in c.iteritems():
6384 for d, s in c.iteritems():
6274 if s in status.removed:
6385 if s in status.removed:
6275 status.removed.remove(s)
6386 status.removed.remove(s)
6276 renamed.append(d)
6387 renamed.append(d)
6277 else:
6388 else:
6278 copied.append(d)
6389 copied.append(d)
6279 if d in status.added:
6390 if d in status.added:
6280 status.added.remove(d)
6391 status.added.remove(d)
6281
6392
6282 try:
6393 try:
6283 ms = mergemod.mergestate.read(repo)
6394 ms = mergemod.mergestate.read(repo)
6284 except error.UnsupportedMergeRecords as e:
6395 except error.UnsupportedMergeRecords as e:
6285 s = ' '.join(e.recordtypes)
6396 s = ' '.join(e.recordtypes)
6286 ui.warn(
6397 ui.warn(
6287 _('warning: merge state has unsupported record types: %s\n') % s)
6398 _('warning: merge state has unsupported record types: %s\n') % s)
6288 unresolved = 0
6399 unresolved = 0
6289 else:
6400 else:
6290 unresolved = [f for f in ms if ms[f] == 'u']
6401 unresolved = [f for f in ms if ms[f] == 'u']
6291
6402
6292 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6403 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6293
6404
6294 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6405 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6295 (ui.label(_('%d added'), 'status.added'), status.added),
6406 (ui.label(_('%d added'), 'status.added'), status.added),
6296 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6407 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6297 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6408 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6298 (ui.label(_('%d copied'), 'status.copied'), copied),
6409 (ui.label(_('%d copied'), 'status.copied'), copied),
6299 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6410 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6300 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6411 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6301 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6412 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6302 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6413 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6303 t = []
6414 t = []
6304 for l, s in labels:
6415 for l, s in labels:
6305 if s:
6416 if s:
6306 t.append(l % len(s))
6417 t.append(l % len(s))
6307
6418
6308 t = ', '.join(t)
6419 t = ', '.join(t)
6309 cleanworkdir = False
6420 cleanworkdir = False
6310
6421
6311 if repo.vfs.exists('graftstate'):
6422 if repo.vfs.exists('graftstate'):
6312 t += _(' (graft in progress)')
6423 t += _(' (graft in progress)')
6313 if repo.vfs.exists('updatestate'):
6424 if repo.vfs.exists('updatestate'):
6314 t += _(' (interrupted update)')
6425 t += _(' (interrupted update)')
6315 elif len(parents) > 1:
6426 elif len(parents) > 1:
6316 t += _(' (merge)')
6427 t += _(' (merge)')
6317 elif branch != parents[0].branch():
6428 elif branch != parents[0].branch():
6318 t += _(' (new branch)')
6429 t += _(' (new branch)')
6319 elif (parents[0].closesbranch() and
6430 elif (parents[0].closesbranch() and
6320 pnode in repo.branchheads(branch, closed=True)):
6431 pnode in repo.branchheads(branch, closed=True)):
6321 t += _(' (head closed)')
6432 t += _(' (head closed)')
6322 elif not (status.modified or status.added or status.removed or renamed or
6433 elif not (status.modified or status.added or status.removed or renamed or
6323 copied or subs):
6434 copied or subs):
6324 t += _(' (clean)')
6435 t += _(' (clean)')
6325 cleanworkdir = True
6436 cleanworkdir = True
6326 elif pnode not in bheads:
6437 elif pnode not in bheads:
6327 t += _(' (new branch head)')
6438 t += _(' (new branch head)')
6328
6439
6329 if parents:
6440 if parents:
6330 pendingphase = max(p.phase() for p in parents)
6441 pendingphase = max(p.phase() for p in parents)
6331 else:
6442 else:
6332 pendingphase = phases.public
6443 pendingphase = phases.public
6333
6444
6334 if pendingphase > phases.newcommitphase(ui):
6445 if pendingphase > phases.newcommitphase(ui):
6335 t += ' (%s)' % phases.phasenames[pendingphase]
6446 t += ' (%s)' % phases.phasenames[pendingphase]
6336
6447
6337 if cleanworkdir:
6448 if cleanworkdir:
6338 # i18n: column positioning for "hg summary"
6449 # i18n: column positioning for "hg summary"
6339 ui.status(_('commit: %s\n') % t.strip())
6450 ui.status(_('commit: %s\n') % t.strip())
6340 else:
6451 else:
6341 # i18n: column positioning for "hg summary"
6452 # i18n: column positioning for "hg summary"
6342 ui.write(_('commit: %s\n') % t.strip())
6453 ui.write(_('commit: %s\n') % t.strip())
6343
6454
6344 # all ancestors of branch heads - all ancestors of parent = new csets
6455 # all ancestors of branch heads - all ancestors of parent = new csets
6345 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6456 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6346 bheads))
6457 bheads))
6347
6458
6348 if new == 0:
6459 if new == 0:
6349 # i18n: column positioning for "hg summary"
6460 # i18n: column positioning for "hg summary"
6350 ui.status(_('update: (current)\n'))
6461 ui.status(_('update: (current)\n'))
6351 elif pnode not in bheads:
6462 elif pnode not in bheads:
6352 # i18n: column positioning for "hg summary"
6463 # i18n: column positioning for "hg summary"
6353 ui.write(_('update: %d new changesets (update)\n') % new)
6464 ui.write(_('update: %d new changesets (update)\n') % new)
6354 else:
6465 else:
6355 # i18n: column positioning for "hg summary"
6466 # i18n: column positioning for "hg summary"
6356 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6467 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6357 (new, len(bheads)))
6468 (new, len(bheads)))
6358
6469
6359 t = []
6470 t = []
6360 draft = len(repo.revs('draft()'))
6471 draft = len(repo.revs('draft()'))
6361 if draft:
6472 if draft:
6362 t.append(_('%d draft') % draft)
6473 t.append(_('%d draft') % draft)
6363 secret = len(repo.revs('secret()'))
6474 secret = len(repo.revs('secret()'))
6364 if secret:
6475 if secret:
6365 t.append(_('%d secret') % secret)
6476 t.append(_('%d secret') % secret)
6366
6477
6367 if draft or secret:
6478 if draft or secret:
6368 ui.status(_('phases: %s\n') % ', '.join(t))
6479 ui.status(_('phases: %s\n') % ', '.join(t))
6369
6480
6370 cmdutil.summaryhooks(ui, repo)
6481 cmdutil.summaryhooks(ui, repo)
6371
6482
6372 if opts.get('remote'):
6483 if opts.get('remote'):
6373 needsincoming, needsoutgoing = True, True
6484 needsincoming, needsoutgoing = True, True
6374 else:
6485 else:
6375 needsincoming, needsoutgoing = False, False
6486 needsincoming, needsoutgoing = False, False
6376 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6487 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6377 if i:
6488 if i:
6378 needsincoming = True
6489 needsincoming = True
6379 if o:
6490 if o:
6380 needsoutgoing = True
6491 needsoutgoing = True
6381 if not needsincoming and not needsoutgoing:
6492 if not needsincoming and not needsoutgoing:
6382 return
6493 return
6383
6494
6384 def getincoming():
6495 def getincoming():
6385 source, branches = hg.parseurl(ui.expandpath('default'))
6496 source, branches = hg.parseurl(ui.expandpath('default'))
6386 sbranch = branches[0]
6497 sbranch = branches[0]
6387 try:
6498 try:
6388 other = hg.peer(repo, {}, source)
6499 other = hg.peer(repo, {}, source)
6389 except error.RepoError:
6500 except error.RepoError:
6390 if opts.get('remote'):
6501 if opts.get('remote'):
6391 raise
6502 raise
6392 return source, sbranch, None, None, None
6503 return source, sbranch, None, None, None
6393 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6504 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6394 if revs:
6505 if revs:
6395 revs = [other.lookup(rev) for rev in revs]
6506 revs = [other.lookup(rev) for rev in revs]
6396 ui.debug('comparing with %s\n' % util.hidepassword(source))
6507 ui.debug('comparing with %s\n' % util.hidepassword(source))
6397 repo.ui.pushbuffer()
6508 repo.ui.pushbuffer()
6398 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6509 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6399 repo.ui.popbuffer()
6510 repo.ui.popbuffer()
6400 return source, sbranch, other, commoninc, commoninc[1]
6511 return source, sbranch, other, commoninc, commoninc[1]
6401
6512
6402 if needsincoming:
6513 if needsincoming:
6403 source, sbranch, sother, commoninc, incoming = getincoming()
6514 source, sbranch, sother, commoninc, incoming = getincoming()
6404 else:
6515 else:
6405 source = sbranch = sother = commoninc = incoming = None
6516 source = sbranch = sother = commoninc = incoming = None
6406
6517
6407 def getoutgoing():
6518 def getoutgoing():
6408 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6519 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6409 dbranch = branches[0]
6520 dbranch = branches[0]
6410 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6521 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6411 if source != dest:
6522 if source != dest:
6412 try:
6523 try:
6413 dother = hg.peer(repo, {}, dest)
6524 dother = hg.peer(repo, {}, dest)
6414 except error.RepoError:
6525 except error.RepoError:
6415 if opts.get('remote'):
6526 if opts.get('remote'):
6416 raise
6527 raise
6417 return dest, dbranch, None, None
6528 return dest, dbranch, None, None
6418 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6529 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6419 elif sother is None:
6530 elif sother is None:
6420 # there is no explicit destination peer, but source one is invalid
6531 # there is no explicit destination peer, but source one is invalid
6421 return dest, dbranch, None, None
6532 return dest, dbranch, None, None
6422 else:
6533 else:
6423 dother = sother
6534 dother = sother
6424 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6535 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6425 common = None
6536 common = None
6426 else:
6537 else:
6427 common = commoninc
6538 common = commoninc
6428 if revs:
6539 if revs:
6429 revs = [repo.lookup(rev) for rev in revs]
6540 revs = [repo.lookup(rev) for rev in revs]
6430 repo.ui.pushbuffer()
6541 repo.ui.pushbuffer()
6431 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6542 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6432 commoninc=common)
6543 commoninc=common)
6433 repo.ui.popbuffer()
6544 repo.ui.popbuffer()
6434 return dest, dbranch, dother, outgoing
6545 return dest, dbranch, dother, outgoing
6435
6546
6436 if needsoutgoing:
6547 if needsoutgoing:
6437 dest, dbranch, dother, outgoing = getoutgoing()
6548 dest, dbranch, dother, outgoing = getoutgoing()
6438 else:
6549 else:
6439 dest = dbranch = dother = outgoing = None
6550 dest = dbranch = dother = outgoing = None
6440
6551
6441 if opts.get('remote'):
6552 if opts.get('remote'):
6442 t = []
6553 t = []
6443 if incoming:
6554 if incoming:
6444 t.append(_('1 or more incoming'))
6555 t.append(_('1 or more incoming'))
6445 o = outgoing.missing
6556 o = outgoing.missing
6446 if o:
6557 if o:
6447 t.append(_('%d outgoing') % len(o))
6558 t.append(_('%d outgoing') % len(o))
6448 other = dother or sother
6559 other = dother or sother
6449 if 'bookmarks' in other.listkeys('namespaces'):
6560 if 'bookmarks' in other.listkeys('namespaces'):
6450 counts = bookmarks.summary(repo, other)
6561 counts = bookmarks.summary(repo, other)
6451 if counts[0] > 0:
6562 if counts[0] > 0:
6452 t.append(_('%d incoming bookmarks') % counts[0])
6563 t.append(_('%d incoming bookmarks') % counts[0])
6453 if counts[1] > 0:
6564 if counts[1] > 0:
6454 t.append(_('%d outgoing bookmarks') % counts[1])
6565 t.append(_('%d outgoing bookmarks') % counts[1])
6455
6566
6456 if t:
6567 if t:
6457 # i18n: column positioning for "hg summary"
6568 # i18n: column positioning for "hg summary"
6458 ui.write(_('remote: %s\n') % (', '.join(t)))
6569 ui.write(_('remote: %s\n') % (', '.join(t)))
6459 else:
6570 else:
6460 # i18n: column positioning for "hg summary"
6571 # i18n: column positioning for "hg summary"
6461 ui.status(_('remote: (synced)\n'))
6572 ui.status(_('remote: (synced)\n'))
6462
6573
6463 cmdutil.summaryremotehooks(ui, repo, opts,
6574 cmdutil.summaryremotehooks(ui, repo, opts,
6464 ((source, sbranch, sother, commoninc),
6575 ((source, sbranch, sother, commoninc),
6465 (dest, dbranch, dother, outgoing)))
6576 (dest, dbranch, dother, outgoing)))
6466
6577
6467 @command('tag',
6578 @command('tag',
6468 [('f', 'force', None, _('force tag')),
6579 [('f', 'force', None, _('force tag')),
6469 ('l', 'local', None, _('make the tag local')),
6580 ('l', 'local', None, _('make the tag local')),
6470 ('r', 'rev', '', _('revision to tag'), _('REV')),
6581 ('r', 'rev', '', _('revision to tag'), _('REV')),
6471 ('', 'remove', None, _('remove a tag')),
6582 ('', 'remove', None, _('remove a tag')),
6472 # -l/--local is already there, commitopts cannot be used
6583 # -l/--local is already there, commitopts cannot be used
6473 ('e', 'edit', None, _('invoke editor on commit messages')),
6584 ('e', 'edit', None, _('invoke editor on commit messages')),
6474 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6585 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6475 ] + commitopts2,
6586 ] + commitopts2,
6476 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6587 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6477 def tag(ui, repo, name1, *names, **opts):
6588 def tag(ui, repo, name1, *names, **opts):
6478 """add one or more tags for the current or given revision
6589 """add one or more tags for the current or given revision
6479
6590
6480 Name a particular revision using <name>.
6591 Name a particular revision using <name>.
6481
6592
6482 Tags are used to name particular revisions of the repository and are
6593 Tags are used to name particular revisions of the repository and are
6483 very useful to compare different revisions, to go back to significant
6594 very useful to compare different revisions, to go back to significant
6484 earlier versions or to mark branch points as releases, etc. Changing
6595 earlier versions or to mark branch points as releases, etc. Changing
6485 an existing tag is normally disallowed; use -f/--force to override.
6596 an existing tag is normally disallowed; use -f/--force to override.
6486
6597
6487 If no revision is given, the parent of the working directory is
6598 If no revision is given, the parent of the working directory is
6488 used.
6599 used.
6489
6600
6490 To facilitate version control, distribution, and merging of tags,
6601 To facilitate version control, distribution, and merging of tags,
6491 they are stored as a file named ".hgtags" which is managed similarly
6602 they are stored as a file named ".hgtags" which is managed similarly
6492 to other project files and can be hand-edited if necessary. This
6603 to other project files and can be hand-edited if necessary. This
6493 also means that tagging creates a new commit. The file
6604 also means that tagging creates a new commit. The file
6494 ".hg/localtags" is used for local tags (not shared among
6605 ".hg/localtags" is used for local tags (not shared among
6495 repositories).
6606 repositories).
6496
6607
6497 Tag commits are usually made at the head of a branch. If the parent
6608 Tag commits are usually made at the head of a branch. If the parent
6498 of the working directory is not a branch head, :hg:`tag` aborts; use
6609 of the working directory is not a branch head, :hg:`tag` aborts; use
6499 -f/--force to force the tag commit to be based on a non-head
6610 -f/--force to force the tag commit to be based on a non-head
6500 changeset.
6611 changeset.
6501
6612
6502 See :hg:`help dates` for a list of formats valid for -d/--date.
6613 See :hg:`help dates` for a list of formats valid for -d/--date.
6503
6614
6504 Since tag names have priority over branch names during revision
6615 Since tag names have priority over branch names during revision
6505 lookup, using an existing branch name as a tag name is discouraged.
6616 lookup, using an existing branch name as a tag name is discouraged.
6506
6617
6507 Returns 0 on success.
6618 Returns 0 on success.
6508 """
6619 """
6509 wlock = lock = None
6620 wlock = lock = None
6510 try:
6621 try:
6511 wlock = repo.wlock()
6622 wlock = repo.wlock()
6512 lock = repo.lock()
6623 lock = repo.lock()
6513 rev_ = "."
6624 rev_ = "."
6514 names = [t.strip() for t in (name1,) + names]
6625 names = [t.strip() for t in (name1,) + names]
6515 if len(names) != len(set(names)):
6626 if len(names) != len(set(names)):
6516 raise error.Abort(_('tag names must be unique'))
6627 raise error.Abort(_('tag names must be unique'))
6517 for n in names:
6628 for n in names:
6518 scmutil.checknewlabel(repo, n, 'tag')
6629 scmutil.checknewlabel(repo, n, 'tag')
6519 if not n:
6630 if not n:
6520 raise error.Abort(_('tag names cannot consist entirely of '
6631 raise error.Abort(_('tag names cannot consist entirely of '
6521 'whitespace'))
6632 'whitespace'))
6522 if opts.get('rev') and opts.get('remove'):
6633 if opts.get('rev') and opts.get('remove'):
6523 raise error.Abort(_("--rev and --remove are incompatible"))
6634 raise error.Abort(_("--rev and --remove are incompatible"))
6524 if opts.get('rev'):
6635 if opts.get('rev'):
6525 rev_ = opts['rev']
6636 rev_ = opts['rev']
6526 message = opts.get('message')
6637 message = opts.get('message')
6527 if opts.get('remove'):
6638 if opts.get('remove'):
6528 if opts.get('local'):
6639 if opts.get('local'):
6529 expectedtype = 'local'
6640 expectedtype = 'local'
6530 else:
6641 else:
6531 expectedtype = 'global'
6642 expectedtype = 'global'
6532
6643
6533 for n in names:
6644 for n in names:
6534 if not repo.tagtype(n):
6645 if not repo.tagtype(n):
6535 raise error.Abort(_("tag '%s' does not exist") % n)
6646 raise error.Abort(_("tag '%s' does not exist") % n)
6536 if repo.tagtype(n) != expectedtype:
6647 if repo.tagtype(n) != expectedtype:
6537 if expectedtype == 'global':
6648 if expectedtype == 'global':
6538 raise error.Abort(_("tag '%s' is not a global tag") % n)
6649 raise error.Abort(_("tag '%s' is not a global tag") % n)
6539 else:
6650 else:
6540 raise error.Abort(_("tag '%s' is not a local tag") % n)
6651 raise error.Abort(_("tag '%s' is not a local tag") % n)
6541 rev_ = 'null'
6652 rev_ = 'null'
6542 if not message:
6653 if not message:
6543 # we don't translate commit messages
6654 # we don't translate commit messages
6544 message = 'Removed tag %s' % ', '.join(names)
6655 message = 'Removed tag %s' % ', '.join(names)
6545 elif not opts.get('force'):
6656 elif not opts.get('force'):
6546 for n in names:
6657 for n in names:
6547 if n in repo.tags():
6658 if n in repo.tags():
6548 raise error.Abort(_("tag '%s' already exists "
6659 raise error.Abort(_("tag '%s' already exists "
6549 "(use -f to force)") % n)
6660 "(use -f to force)") % n)
6550 if not opts.get('local'):
6661 if not opts.get('local'):
6551 p1, p2 = repo.dirstate.parents()
6662 p1, p2 = repo.dirstate.parents()
6552 if p2 != nullid:
6663 if p2 != nullid:
6553 raise error.Abort(_('uncommitted merge'))
6664 raise error.Abort(_('uncommitted merge'))
6554 bheads = repo.branchheads()
6665 bheads = repo.branchheads()
6555 if not opts.get('force') and bheads and p1 not in bheads:
6666 if not opts.get('force') and bheads and p1 not in bheads:
6556 raise error.Abort(_('not at a branch head (use -f to force)'))
6667 raise error.Abort(_('not at a branch head (use -f to force)'))
6557 r = scmutil.revsingle(repo, rev_).node()
6668 r = scmutil.revsingle(repo, rev_).node()
6558
6669
6559 if not message:
6670 if not message:
6560 # we don't translate commit messages
6671 # we don't translate commit messages
6561 message = ('Added tag %s for changeset %s' %
6672 message = ('Added tag %s for changeset %s' %
6562 (', '.join(names), short(r)))
6673 (', '.join(names), short(r)))
6563
6674
6564 date = opts.get('date')
6675 date = opts.get('date')
6565 if date:
6676 if date:
6566 date = util.parsedate(date)
6677 date = util.parsedate(date)
6567
6678
6568 if opts.get('remove'):
6679 if opts.get('remove'):
6569 editform = 'tag.remove'
6680 editform = 'tag.remove'
6570 else:
6681 else:
6571 editform = 'tag.add'
6682 editform = 'tag.add'
6572 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6683 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6573
6684
6574 # don't allow tagging the null rev
6685 # don't allow tagging the null rev
6575 if (not opts.get('remove') and
6686 if (not opts.get('remove') and
6576 scmutil.revsingle(repo, rev_).rev() == nullrev):
6687 scmutil.revsingle(repo, rev_).rev() == nullrev):
6577 raise error.Abort(_("cannot tag null revision"))
6688 raise error.Abort(_("cannot tag null revision"))
6578
6689
6579 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6690 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6580 editor=editor)
6691 editor=editor)
6581 finally:
6692 finally:
6582 release(lock, wlock)
6693 release(lock, wlock)
6583
6694
6584 @command('tags', formatteropts, '')
6695 @command('tags', formatteropts, '')
6585 def tags(ui, repo, **opts):
6696 def tags(ui, repo, **opts):
6586 """list repository tags
6697 """list repository tags
6587
6698
6588 This lists both regular and local tags. When the -v/--verbose
6699 This lists both regular and local tags. When the -v/--verbose
6589 switch is used, a third column "local" is printed for local tags.
6700 switch is used, a third column "local" is printed for local tags.
6590
6701
6591 Returns 0 on success.
6702 Returns 0 on success.
6592 """
6703 """
6593
6704
6594 fm = ui.formatter('tags', opts)
6705 fm = ui.formatter('tags', opts)
6595 hexfunc = fm.hexfunc
6706 hexfunc = fm.hexfunc
6596 tagtype = ""
6707 tagtype = ""
6597
6708
6598 for t, n in reversed(repo.tagslist()):
6709 for t, n in reversed(repo.tagslist()):
6599 hn = hexfunc(n)
6710 hn = hexfunc(n)
6600 label = 'tags.normal'
6711 label = 'tags.normal'
6601 tagtype = ''
6712 tagtype = ''
6602 if repo.tagtype(t) == 'local':
6713 if repo.tagtype(t) == 'local':
6603 label = 'tags.local'
6714 label = 'tags.local'
6604 tagtype = 'local'
6715 tagtype = 'local'
6605
6716
6606 fm.startitem()
6717 fm.startitem()
6607 fm.write('tag', '%s', t, label=label)
6718 fm.write('tag', '%s', t, label=label)
6608 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6719 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6609 fm.condwrite(not ui.quiet, 'rev node', fmt,
6720 fm.condwrite(not ui.quiet, 'rev node', fmt,
6610 repo.changelog.rev(n), hn, label=label)
6721 repo.changelog.rev(n), hn, label=label)
6611 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6722 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6612 tagtype, label=label)
6723 tagtype, label=label)
6613 fm.plain('\n')
6724 fm.plain('\n')
6614 fm.end()
6725 fm.end()
6615
6726
6616 @command('tip',
6727 @command('tip',
6617 [('p', 'patch', None, _('show patch')),
6728 [('p', 'patch', None, _('show patch')),
6618 ('g', 'git', None, _('use git extended diff format')),
6729 ('g', 'git', None, _('use git extended diff format')),
6619 ] + templateopts,
6730 ] + templateopts,
6620 _('[-p] [-g]'))
6731 _('[-p] [-g]'))
6621 def tip(ui, repo, **opts):
6732 def tip(ui, repo, **opts):
6622 """show the tip revision (DEPRECATED)
6733 """show the tip revision (DEPRECATED)
6623
6734
6624 The tip revision (usually just called the tip) is the changeset
6735 The tip revision (usually just called the tip) is the changeset
6625 most recently added to the repository (and therefore the most
6736 most recently added to the repository (and therefore the most
6626 recently changed head).
6737 recently changed head).
6627
6738
6628 If you have just made a commit, that commit will be the tip. If
6739 If you have just made a commit, that commit will be the tip. If
6629 you have just pulled changes from another repository, the tip of
6740 you have just pulled changes from another repository, the tip of
6630 that repository becomes the current tip. The "tip" tag is special
6741 that repository becomes the current tip. The "tip" tag is special
6631 and cannot be renamed or assigned to a different changeset.
6742 and cannot be renamed or assigned to a different changeset.
6632
6743
6633 This command is deprecated, please use :hg:`heads` instead.
6744 This command is deprecated, please use :hg:`heads` instead.
6634
6745
6635 Returns 0 on success.
6746 Returns 0 on success.
6636 """
6747 """
6637 displayer = cmdutil.show_changeset(ui, repo, opts)
6748 displayer = cmdutil.show_changeset(ui, repo, opts)
6638 displayer.show(repo['tip'])
6749 displayer.show(repo['tip'])
6639 displayer.close()
6750 displayer.close()
6640
6751
6641 @command('unbundle',
6752 @command('unbundle',
6642 [('u', 'update', None,
6753 [('u', 'update', None,
6643 _('update to new branch head if changesets were unbundled'))],
6754 _('update to new branch head if changesets were unbundled'))],
6644 _('[-u] FILE...'))
6755 _('[-u] FILE...'))
6645 def unbundle(ui, repo, fname1, *fnames, **opts):
6756 def unbundle(ui, repo, fname1, *fnames, **opts):
6646 """apply one or more changegroup files
6757 """apply one or more changegroup files
6647
6758
6648 Apply one or more compressed changegroup files generated by the
6759 Apply one or more compressed changegroup files generated by the
6649 bundle command.
6760 bundle command.
6650
6761
6651 Returns 0 on success, 1 if an update has unresolved files.
6762 Returns 0 on success, 1 if an update has unresolved files.
6652 """
6763 """
6653 fnames = (fname1,) + fnames
6764 fnames = (fname1,) + fnames
6654
6765
6655 lock = repo.lock()
6766 lock = repo.lock()
6656 try:
6767 try:
6657 for fname in fnames:
6768 for fname in fnames:
6658 f = hg.openpath(ui, fname)
6769 f = hg.openpath(ui, fname)
6659 gen = exchange.readbundle(ui, f, fname)
6770 gen = exchange.readbundle(ui, f, fname)
6660 if isinstance(gen, bundle2.unbundle20):
6771 if isinstance(gen, bundle2.unbundle20):
6661 tr = repo.transaction('unbundle')
6772 tr = repo.transaction('unbundle')
6662 try:
6773 try:
6663 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
6774 op = bundle2.applybundle(repo, gen, tr, source='unbundle',
6664 url='bundle:' + fname)
6775 url='bundle:' + fname)
6665 tr.close()
6776 tr.close()
6666 except error.BundleUnknownFeatureError as exc:
6777 except error.BundleUnknownFeatureError as exc:
6667 raise error.Abort(_('%s: unknown bundle feature, %s')
6778 raise error.Abort(_('%s: unknown bundle feature, %s')
6668 % (fname, exc),
6779 % (fname, exc),
6669 hint=_("see https://mercurial-scm.org/"
6780 hint=_("see https://mercurial-scm.org/"
6670 "wiki/BundleFeature for more "
6781 "wiki/BundleFeature for more "
6671 "information"))
6782 "information"))
6672 finally:
6783 finally:
6673 if tr:
6784 if tr:
6674 tr.release()
6785 tr.release()
6675 changes = [r.get('return', 0)
6786 changes = [r.get('return', 0)
6676 for r in op.records['changegroup']]
6787 for r in op.records['changegroup']]
6677 modheads = changegroup.combineresults(changes)
6788 modheads = changegroup.combineresults(changes)
6678 elif isinstance(gen, streamclone.streamcloneapplier):
6789 elif isinstance(gen, streamclone.streamcloneapplier):
6679 raise error.Abort(
6790 raise error.Abort(
6680 _('packed bundles cannot be applied with '
6791 _('packed bundles cannot be applied with '
6681 '"hg unbundle"'),
6792 '"hg unbundle"'),
6682 hint=_('use "hg debugapplystreamclonebundle"'))
6793 hint=_('use "hg debugapplystreamclonebundle"'))
6683 else:
6794 else:
6684 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6795 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6685 finally:
6796 finally:
6686 lock.release()
6797 lock.release()
6687
6798
6688 return postincoming(ui, repo, modheads, opts.get('update'), None)
6799 return postincoming(ui, repo, modheads, opts.get('update'), None)
6689
6800
6690 @command('^update|up|checkout|co',
6801 @command('^update|up|checkout|co',
6691 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6802 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6692 ('c', 'check', None,
6803 ('c', 'check', None,
6693 _('update across branches if no uncommitted changes')),
6804 _('update across branches if no uncommitted changes')),
6694 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6805 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6695 ('r', 'rev', '', _('revision'), _('REV'))
6806 ('r', 'rev', '', _('revision'), _('REV'))
6696 ] + mergetoolopts,
6807 ] + mergetoolopts,
6697 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6808 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6698 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6809 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6699 tool=None):
6810 tool=None):
6700 """update working directory (or switch revisions)
6811 """update working directory (or switch revisions)
6701
6812
6702 Update the repository's working directory to the specified
6813 Update the repository's working directory to the specified
6703 changeset. If no changeset is specified, update to the tip of the
6814 changeset. If no changeset is specified, update to the tip of the
6704 current named branch and move the active bookmark (see :hg:`help
6815 current named branch and move the active bookmark (see :hg:`help
6705 bookmarks`).
6816 bookmarks`).
6706
6817
6707 Update sets the working directory's parent revision to the specified
6818 Update sets the working directory's parent revision to the specified
6708 changeset (see :hg:`help parents`).
6819 changeset (see :hg:`help parents`).
6709
6820
6710 If the changeset is not a descendant or ancestor of the working
6821 If the changeset is not a descendant or ancestor of the working
6711 directory's parent, the update is aborted. With the -c/--check
6822 directory's parent, the update is aborted. With the -c/--check
6712 option, the working directory is checked for uncommitted changes; if
6823 option, the working directory is checked for uncommitted changes; if
6713 none are found, the working directory is updated to the specified
6824 none are found, the working directory is updated to the specified
6714 changeset.
6825 changeset.
6715
6826
6716 .. container:: verbose
6827 .. container:: verbose
6717
6828
6718 The following rules apply when the working directory contains
6829 The following rules apply when the working directory contains
6719 uncommitted changes:
6830 uncommitted changes:
6720
6831
6721 1. If neither -c/--check nor -C/--clean is specified, and if
6832 1. If neither -c/--check nor -C/--clean is specified, and if
6722 the requested changeset is an ancestor or descendant of
6833 the requested changeset is an ancestor or descendant of
6723 the working directory's parent, the uncommitted changes
6834 the working directory's parent, the uncommitted changes
6724 are merged into the requested changeset and the merged
6835 are merged into the requested changeset and the merged
6725 result is left uncommitted. If the requested changeset is
6836 result is left uncommitted. If the requested changeset is
6726 not an ancestor or descendant (that is, it is on another
6837 not an ancestor or descendant (that is, it is on another
6727 branch), the update is aborted and the uncommitted changes
6838 branch), the update is aborted and the uncommitted changes
6728 are preserved.
6839 are preserved.
6729
6840
6730 2. With the -c/--check option, the update is aborted and the
6841 2. With the -c/--check option, the update is aborted and the
6731 uncommitted changes are preserved.
6842 uncommitted changes are preserved.
6732
6843
6733 3. With the -C/--clean option, uncommitted changes are discarded and
6844 3. With the -C/--clean option, uncommitted changes are discarded and
6734 the working directory is updated to the requested changeset.
6845 the working directory is updated to the requested changeset.
6735
6846
6736 To cancel an uncommitted merge (and lose your changes), use
6847 To cancel an uncommitted merge (and lose your changes), use
6737 :hg:`update --clean .`.
6848 :hg:`update --clean .`.
6738
6849
6739 Use null as the changeset to remove the working directory (like
6850 Use null as the changeset to remove the working directory (like
6740 :hg:`clone -U`).
6851 :hg:`clone -U`).
6741
6852
6742 If you want to revert just one file to an older revision, use
6853 If you want to revert just one file to an older revision, use
6743 :hg:`revert [-r REV] NAME`.
6854 :hg:`revert [-r REV] NAME`.
6744
6855
6745 See :hg:`help dates` for a list of formats valid for -d/--date.
6856 See :hg:`help dates` for a list of formats valid for -d/--date.
6746
6857
6747 Returns 0 on success, 1 if there are unresolved files.
6858 Returns 0 on success, 1 if there are unresolved files.
6748 """
6859 """
6749 movemarkfrom = None
6860 movemarkfrom = None
6750 if rev and node:
6861 if rev and node:
6751 raise error.Abort(_("please specify just one revision"))
6862 raise error.Abort(_("please specify just one revision"))
6752
6863
6753 if rev is None or rev == '':
6864 if rev is None or rev == '':
6754 rev = node
6865 rev = node
6755
6866
6756 wlock = repo.wlock()
6867 wlock = repo.wlock()
6757 try:
6868 try:
6758 cmdutil.clearunfinished(repo)
6869 cmdutil.clearunfinished(repo)
6759
6870
6760 if date:
6871 if date:
6761 if rev is not None:
6872 if rev is not None:
6762 raise error.Abort(_("you can't specify a revision and a date"))
6873 raise error.Abort(_("you can't specify a revision and a date"))
6763 rev = cmdutil.finddate(ui, repo, date)
6874 rev = cmdutil.finddate(ui, repo, date)
6764
6875
6765 # if we defined a bookmark, we have to remember the original name
6876 # if we defined a bookmark, we have to remember the original name
6766 brev = rev
6877 brev = rev
6767 rev = scmutil.revsingle(repo, rev, rev).rev()
6878 rev = scmutil.revsingle(repo, rev, rev).rev()
6768
6879
6769 if check and clean:
6880 if check and clean:
6770 raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
6881 raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
6771 )
6882 )
6772
6883
6773 if check:
6884 if check:
6774 cmdutil.bailifchanged(repo, merge=False)
6885 cmdutil.bailifchanged(repo, merge=False)
6775 if rev is None:
6886 if rev is None:
6776 updata = destutil.destupdate(repo, clean=clean, check=check)
6887 updata = destutil.destupdate(repo, clean=clean, check=check)
6777 rev, movemarkfrom, brev = updata
6888 rev, movemarkfrom, brev = updata
6778
6889
6779 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6890 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6780
6891
6781 if clean:
6892 if clean:
6782 ret = hg.clean(repo, rev)
6893 ret = hg.clean(repo, rev)
6783 else:
6894 else:
6784 ret = hg.update(repo, rev)
6895 ret = hg.update(repo, rev)
6785
6896
6786 if not ret and movemarkfrom:
6897 if not ret and movemarkfrom:
6787 if movemarkfrom == repo['.'].node():
6898 if movemarkfrom == repo['.'].node():
6788 pass # no-op update
6899 pass # no-op update
6789 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6900 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6790 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6901 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6791 else:
6902 else:
6792 # this can happen with a non-linear update
6903 # this can happen with a non-linear update
6793 ui.status(_("(leaving bookmark %s)\n") %
6904 ui.status(_("(leaving bookmark %s)\n") %
6794 repo._activebookmark)
6905 repo._activebookmark)
6795 bookmarks.deactivate(repo)
6906 bookmarks.deactivate(repo)
6796 elif brev in repo._bookmarks:
6907 elif brev in repo._bookmarks:
6797 bookmarks.activate(repo, brev)
6908 bookmarks.activate(repo, brev)
6798 ui.status(_("(activating bookmark %s)\n") % brev)
6909 ui.status(_("(activating bookmark %s)\n") % brev)
6799 elif brev:
6910 elif brev:
6800 if repo._activebookmark:
6911 if repo._activebookmark:
6801 ui.status(_("(leaving bookmark %s)\n") %
6912 ui.status(_("(leaving bookmark %s)\n") %
6802 repo._activebookmark)
6913 repo._activebookmark)
6803 bookmarks.deactivate(repo)
6914 bookmarks.deactivate(repo)
6804 finally:
6915 finally:
6805 wlock.release()
6916 wlock.release()
6806
6917
6807 return ret
6918 return ret
6808
6919
6809 @command('verify', [])
6920 @command('verify', [])
6810 def verify(ui, repo):
6921 def verify(ui, repo):
6811 """verify the integrity of the repository
6922 """verify the integrity of the repository
6812
6923
6813 Verify the integrity of the current repository.
6924 Verify the integrity of the current repository.
6814
6925
6815 This will perform an extensive check of the repository's
6926 This will perform an extensive check of the repository's
6816 integrity, validating the hashes and checksums of each entry in
6927 integrity, validating the hashes and checksums of each entry in
6817 the changelog, manifest, and tracked files, as well as the
6928 the changelog, manifest, and tracked files, as well as the
6818 integrity of their crosslinks and indices.
6929 integrity of their crosslinks and indices.
6819
6930
6820 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6931 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6821 for more information about recovery from corruption of the
6932 for more information about recovery from corruption of the
6822 repository.
6933 repository.
6823
6934
6824 Returns 0 on success, 1 if errors are encountered.
6935 Returns 0 on success, 1 if errors are encountered.
6825 """
6936 """
6826 return hg.verify(repo)
6937 return hg.verify(repo)
6827
6938
6828 @command('version', [], norepo=True)
6939 @command('version', [], norepo=True)
6829 def version_(ui):
6940 def version_(ui):
6830 """output version and copyright information"""
6941 """output version and copyright information"""
6831 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6942 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6832 % util.version())
6943 % util.version())
6833 ui.status(_(
6944 ui.status(_(
6834 "(see https://mercurial-scm.org for more information)\n"
6945 "(see https://mercurial-scm.org for more information)\n"
6835 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6946 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6836 "This is free software; see the source for copying conditions. "
6947 "This is free software; see the source for copying conditions. "
6837 "There is NO\nwarranty; "
6948 "There is NO\nwarranty; "
6838 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6949 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6839 ))
6950 ))
6840
6951
6841 ui.note(_("\nEnabled extensions:\n\n"))
6952 ui.note(_("\nEnabled extensions:\n\n"))
6842 if ui.verbose:
6953 if ui.verbose:
6843 # format names and versions into columns
6954 # format names and versions into columns
6844 names = []
6955 names = []
6845 vers = []
6956 vers = []
6846 for name, module in extensions.extensions():
6957 for name, module in extensions.extensions():
6847 names.append(name)
6958 names.append(name)
6848 vers.append(extensions.moduleversion(module))
6959 vers.append(extensions.moduleversion(module))
6849 if names:
6960 if names:
6850 maxnamelen = max(len(n) for n in names)
6961 maxnamelen = max(len(n) for n in names)
6851 for i, name in enumerate(names):
6962 for i, name in enumerate(names):
6852 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
6963 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
@@ -1,348 +1,350 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 add
3 add
4 addremove
4 addremove
5 annotate
5 annotate
6 archive
6 archive
7 backout
7 backout
8 bisect
8 bisect
9 bookmarks
9 bookmarks
10 branch
10 branch
11 branches
11 branches
12 bundle
12 bundle
13 cat
13 cat
14 clone
14 clone
15 commit
15 commit
16 config
16 config
17 copy
17 copy
18 diff
18 diff
19 export
19 export
20 files
20 files
21 forget
21 forget
22 graft
22 graft
23 grep
23 grep
24 heads
24 heads
25 help
25 help
26 identify
26 identify
27 import
27 import
28 incoming
28 incoming
29 init
29 init
30 locate
30 locate
31 log
31 log
32 manifest
32 manifest
33 merge
33 merge
34 outgoing
34 outgoing
35 parents
35 parents
36 paths
36 paths
37 phase
37 phase
38 pull
38 pull
39 push
39 push
40 recover
40 recover
41 remove
41 remove
42 rename
42 rename
43 resolve
43 resolve
44 revert
44 revert
45 rollback
45 rollback
46 root
46 root
47 serve
47 serve
48 status
48 status
49 summary
49 summary
50 tag
50 tag
51 tags
51 tags
52 tip
52 tip
53 unbundle
53 unbundle
54 update
54 update
55 verify
55 verify
56 version
56 version
57
57
58 Show all commands that start with "a"
58 Show all commands that start with "a"
59 $ hg debugcomplete a
59 $ hg debugcomplete a
60 add
60 add
61 addremove
61 addremove
62 annotate
62 annotate
63 archive
63 archive
64
64
65 Do not show debug commands if there are other candidates
65 Do not show debug commands if there are other candidates
66 $ hg debugcomplete d
66 $ hg debugcomplete d
67 diff
67 diff
68
68
69 Show debug commands if there are no other candidates
69 Show debug commands if there are no other candidates
70 $ hg debugcomplete debug
70 $ hg debugcomplete debug
71 debugancestor
71 debugancestor
72 debugapplystreamclonebundle
72 debugapplystreamclonebundle
73 debugbuilddag
73 debugbuilddag
74 debugbundle
74 debugbundle
75 debugcheckstate
75 debugcheckstate
76 debugcommands
76 debugcommands
77 debugcomplete
77 debugcomplete
78 debugconfig
78 debugconfig
79 debugcreatestreamclonebundle
79 debugcreatestreamclonebundle
80 debugdag
80 debugdag
81 debugdata
81 debugdata
82 debugdate
82 debugdate
83 debugdeltachain
83 debugdirstate
84 debugdirstate
84 debugdiscovery
85 debugdiscovery
85 debugextensions
86 debugextensions
86 debugfileset
87 debugfileset
87 debugfsinfo
88 debugfsinfo
88 debuggetbundle
89 debuggetbundle
89 debugignore
90 debugignore
90 debugindex
91 debugindex
91 debugindexdot
92 debugindexdot
92 debuginstall
93 debuginstall
93 debugknown
94 debugknown
94 debuglabelcomplete
95 debuglabelcomplete
95 debuglocks
96 debuglocks
96 debugmergestate
97 debugmergestate
97 debugnamecomplete
98 debugnamecomplete
98 debugobsolete
99 debugobsolete
99 debugpathcomplete
100 debugpathcomplete
100 debugpushkey
101 debugpushkey
101 debugpvec
102 debugpvec
102 debugrebuilddirstate
103 debugrebuilddirstate
103 debugrebuildfncache
104 debugrebuildfncache
104 debugrename
105 debugrename
105 debugrevlog
106 debugrevlog
106 debugrevspec
107 debugrevspec
107 debugsetparents
108 debugsetparents
108 debugsub
109 debugsub
109 debugsuccessorssets
110 debugsuccessorssets
110 debugwalk
111 debugwalk
111 debugwireargs
112 debugwireargs
112
113
113 Do not show the alias of a debug command if there are other candidates
114 Do not show the alias of a debug command if there are other candidates
114 (this should hide rawcommit)
115 (this should hide rawcommit)
115 $ hg debugcomplete r
116 $ hg debugcomplete r
116 recover
117 recover
117 remove
118 remove
118 rename
119 rename
119 resolve
120 resolve
120 revert
121 revert
121 rollback
122 rollback
122 root
123 root
123 Show the alias of a debug command if there are no other candidates
124 Show the alias of a debug command if there are no other candidates
124 $ hg debugcomplete rawc
125 $ hg debugcomplete rawc
125
126
126
127
127 Show the global options
128 Show the global options
128 $ hg debugcomplete --options | sort
129 $ hg debugcomplete --options | sort
129 --config
130 --config
130 --cwd
131 --cwd
131 --debug
132 --debug
132 --debugger
133 --debugger
133 --encoding
134 --encoding
134 --encodingmode
135 --encodingmode
135 --help
136 --help
136 --hidden
137 --hidden
137 --noninteractive
138 --noninteractive
138 --profile
139 --profile
139 --quiet
140 --quiet
140 --repository
141 --repository
141 --time
142 --time
142 --traceback
143 --traceback
143 --verbose
144 --verbose
144 --version
145 --version
145 -R
146 -R
146 -h
147 -h
147 -q
148 -q
148 -v
149 -v
149 -y
150 -y
150
151
151 Show the options for the "serve" command
152 Show the options for the "serve" command
152 $ hg debugcomplete --options serve | sort
153 $ hg debugcomplete --options serve | sort
153 --accesslog
154 --accesslog
154 --address
155 --address
155 --certificate
156 --certificate
156 --cmdserver
157 --cmdserver
157 --config
158 --config
158 --cwd
159 --cwd
159 --daemon
160 --daemon
160 --daemon-pipefds
161 --daemon-pipefds
161 --debug
162 --debug
162 --debugger
163 --debugger
163 --encoding
164 --encoding
164 --encodingmode
165 --encodingmode
165 --errorlog
166 --errorlog
166 --help
167 --help
167 --hidden
168 --hidden
168 --ipv6
169 --ipv6
169 --name
170 --name
170 --noninteractive
171 --noninteractive
171 --pid-file
172 --pid-file
172 --port
173 --port
173 --prefix
174 --prefix
174 --profile
175 --profile
175 --quiet
176 --quiet
176 --repository
177 --repository
177 --stdio
178 --stdio
178 --style
179 --style
179 --templates
180 --templates
180 --time
181 --time
181 --traceback
182 --traceback
182 --verbose
183 --verbose
183 --version
184 --version
184 --web-conf
185 --web-conf
185 -6
186 -6
186 -A
187 -A
187 -E
188 -E
188 -R
189 -R
189 -a
190 -a
190 -d
191 -d
191 -h
192 -h
192 -n
193 -n
193 -p
194 -p
194 -q
195 -q
195 -t
196 -t
196 -v
197 -v
197 -y
198 -y
198
199
199 Show an error if we use --options with an ambiguous abbreviation
200 Show an error if we use --options with an ambiguous abbreviation
200 $ hg debugcomplete --options s
201 $ hg debugcomplete --options s
201 hg: command 's' is ambiguous:
202 hg: command 's' is ambiguous:
202 serve showconfig status summary
203 serve showconfig status summary
203 [255]
204 [255]
204
205
205 Show all commands + options
206 Show all commands + options
206 $ hg debugcommands
207 $ hg debugcommands
207 add: include, exclude, subrepos, dry-run
208 add: include, exclude, subrepos, dry-run
208 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
209 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
209 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
210 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
210 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
211 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
211 diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos
212 diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos
212 export: output, switch-parent, rev, text, git, nodates
213 export: output, switch-parent, rev, text, git, nodates
213 forget: include, exclude
214 forget: include, exclude
214 init: ssh, remotecmd, insecure
215 init: ssh, remotecmd, insecure
215 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
216 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
216 merge: force, rev, preview, tool
217 merge: force, rev, preview, tool
217 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
218 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
218 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
219 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
219 remove: after, force, subrepos, include, exclude
220 remove: after, force, subrepos, include, exclude
220 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
221 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
221 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
222 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
222 summary: remote
223 summary: remote
223 update: clean, check, date, rev, tool
224 update: clean, check, date, rev, tool
224 addremove: similarity, subrepos, include, exclude, dry-run
225 addremove: similarity, subrepos, include, exclude, dry-run
225 archive: no-decode, prefix, rev, type, subrepos, include, exclude
226 archive: no-decode, prefix, rev, type, subrepos, include, exclude
226 backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
227 backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
227 bisect: reset, good, bad, skip, extend, command, noupdate
228 bisect: reset, good, bad, skip, extend, command, noupdate
228 bookmarks: force, rev, delete, rename, inactive, template
229 bookmarks: force, rev, delete, rename, inactive, template
229 branch: force, clean
230 branch: force, clean
230 branches: active, closed, template
231 branches: active, closed, template
231 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
232 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
232 cat: output, rev, decode, include, exclude
233 cat: output, rev, decode, include, exclude
233 config: untrusted, edit, local, global
234 config: untrusted, edit, local, global
234 copy: after, force, include, exclude, dry-run
235 copy: after, force, include, exclude, dry-run
235 debugancestor:
236 debugancestor:
236 debugapplystreamclonebundle:
237 debugapplystreamclonebundle:
237 debugbuilddag: mergeable-file, overwritten-file, new-file
238 debugbuilddag: mergeable-file, overwritten-file, new-file
238 debugbundle: all
239 debugbundle: all
239 debugcheckstate:
240 debugcheckstate:
240 debugcommands:
241 debugcommands:
241 debugcomplete: options
242 debugcomplete: options
242 debugcreatestreamclonebundle:
243 debugcreatestreamclonebundle:
243 debugdag: tags, branches, dots, spaces
244 debugdag: tags, branches, dots, spaces
244 debugdata: changelog, manifest, dir
245 debugdata: changelog, manifest, dir
245 debugdate: extended
246 debugdate: extended
247 debugdeltachain: changelog, manifest, dir, template
246 debugdirstate: nodates, datesort
248 debugdirstate: nodates, datesort
247 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
249 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
248 debugextensions: template
250 debugextensions: template
249 debugfileset: rev
251 debugfileset: rev
250 debugfsinfo:
252 debugfsinfo:
251 debuggetbundle: head, common, type
253 debuggetbundle: head, common, type
252 debugignore:
254 debugignore:
253 debugindex: changelog, manifest, dir, format
255 debugindex: changelog, manifest, dir, format
254 debugindexdot: changelog, manifest, dir
256 debugindexdot: changelog, manifest, dir
255 debuginstall:
257 debuginstall:
256 debugknown:
258 debugknown:
257 debuglabelcomplete:
259 debuglabelcomplete:
258 debuglocks: force-lock, force-wlock
260 debuglocks: force-lock, force-wlock
259 debugmergestate:
261 debugmergestate:
260 debugnamecomplete:
262 debugnamecomplete:
261 debugobsolete: flags, record-parents, rev, date, user
263 debugobsolete: flags, record-parents, rev, date, user
262 debugpathcomplete: full, normal, added, removed
264 debugpathcomplete: full, normal, added, removed
263 debugpushkey:
265 debugpushkey:
264 debugpvec:
266 debugpvec:
265 debugrebuilddirstate: rev, minimal
267 debugrebuilddirstate: rev, minimal
266 debugrebuildfncache:
268 debugrebuildfncache:
267 debugrename: rev
269 debugrename: rev
268 debugrevlog: changelog, manifest, dir, dump
270 debugrevlog: changelog, manifest, dir, dump
269 debugrevspec: optimize
271 debugrevspec: optimize
270 debugsetparents:
272 debugsetparents:
271 debugsub: rev
273 debugsub: rev
272 debugsuccessorssets:
274 debugsuccessorssets:
273 debugwalk: include, exclude
275 debugwalk: include, exclude
274 debugwireargs: three, four, five, ssh, remotecmd, insecure
276 debugwireargs: three, four, five, ssh, remotecmd, insecure
275 files: rev, print0, include, exclude, template, subrepos
277 files: rev, print0, include, exclude, template, subrepos
276 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
278 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
277 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
279 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
278 heads: rev, topo, active, closed, style, template
280 heads: rev, topo, active, closed, style, template
279 help: extension, command, keyword
281 help: extension, command, keyword
280 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
282 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
281 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
283 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
282 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
284 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
283 locate: rev, print0, fullpath, include, exclude
285 locate: rev, print0, fullpath, include, exclude
284 manifest: rev, all, template
286 manifest: rev, all, template
285 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
287 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
286 parents: rev, style, template
288 parents: rev, style, template
287 paths:
289 paths:
288 phase: public, draft, secret, force, rev
290 phase: public, draft, secret, force, rev
289 recover:
291 recover:
290 rename: after, force, include, exclude, dry-run
292 rename: after, force, include, exclude, dry-run
291 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
293 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
292 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
294 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
293 rollback: dry-run, force
295 rollback: dry-run, force
294 root:
296 root:
295 tag: force, local, rev, remove, edit, message, date, user
297 tag: force, local, rev, remove, edit, message, date, user
296 tags: template
298 tags: template
297 tip: patch, git, style, template
299 tip: patch, git, style, template
298 unbundle: update
300 unbundle: update
299 verify:
301 verify:
300 version:
302 version:
301
303
302 $ hg init a
304 $ hg init a
303 $ cd a
305 $ cd a
304 $ echo fee > fee
306 $ echo fee > fee
305 $ hg ci -q -Amfee
307 $ hg ci -q -Amfee
306 $ hg tag fee
308 $ hg tag fee
307 $ mkdir fie
309 $ mkdir fie
308 $ echo dead > fie/dead
310 $ echo dead > fie/dead
309 $ echo live > fie/live
311 $ echo live > fie/live
310 $ hg bookmark fo
312 $ hg bookmark fo
311 $ hg branch -q fie
313 $ hg branch -q fie
312 $ hg ci -q -Amfie
314 $ hg ci -q -Amfie
313 $ echo fo > fo
315 $ echo fo > fo
314 $ hg branch -qf default
316 $ hg branch -qf default
315 $ hg ci -q -Amfo
317 $ hg ci -q -Amfo
316 $ echo Fum > Fum
318 $ echo Fum > Fum
317 $ hg ci -q -AmFum
319 $ hg ci -q -AmFum
318 $ hg bookmark Fum
320 $ hg bookmark Fum
319
321
320 Test debugpathcomplete
322 Test debugpathcomplete
321
323
322 $ hg debugpathcomplete f
324 $ hg debugpathcomplete f
323 fee
325 fee
324 fie
326 fie
325 fo
327 fo
326 $ hg debugpathcomplete -f f
328 $ hg debugpathcomplete -f f
327 fee
329 fee
328 fie/dead
330 fie/dead
329 fie/live
331 fie/live
330 fo
332 fo
331
333
332 $ hg rm Fum
334 $ hg rm Fum
333 $ hg debugpathcomplete -r F
335 $ hg debugpathcomplete -r F
334 Fum
336 Fum
335
337
336 Test debugnamecomplete
338 Test debugnamecomplete
337
339
338 $ hg debugnamecomplete
340 $ hg debugnamecomplete
339 Fum
341 Fum
340 default
342 default
341 fee
343 fee
342 fie
344 fie
343 fo
345 fo
344 tip
346 tip
345 $ hg debugnamecomplete f
347 $ hg debugnamecomplete f
346 fee
348 fee
347 fie
349 fie
348 fo
350 fo
@@ -1,102 +1,128 b''
1 $ cat << EOF >> $HGRCPATH
1 $ cat << EOF >> $HGRCPATH
2 > [format]
2 > [format]
3 > usegeneraldelta=yes
3 > usegeneraldelta=yes
4 > EOF
4 > EOF
5
5
6 $ hg init debugrevlog
6 $ hg init debugrevlog
7 $ cd debugrevlog
7 $ cd debugrevlog
8 $ echo a > a
8 $ echo a > a
9 $ hg ci -Am adda
9 $ hg ci -Am adda
10 adding a
10 adding a
11 $ hg debugrevlog -m
11 $ hg debugrevlog -m
12 format : 1
12 format : 1
13 flags : inline, generaldelta
13 flags : inline, generaldelta
14
14
15 revisions : 1
15 revisions : 1
16 merges : 0 ( 0.00%)
16 merges : 0 ( 0.00%)
17 normal : 1 (100.00%)
17 normal : 1 (100.00%)
18 revisions : 1
18 revisions : 1
19 full : 1 (100.00%)
19 full : 1 (100.00%)
20 deltas : 0 ( 0.00%)
20 deltas : 0 ( 0.00%)
21 revision size : 44
21 revision size : 44
22 full : 44 (100.00%)
22 full : 44 (100.00%)
23 deltas : 0 ( 0.00%)
23 deltas : 0 ( 0.00%)
24
24
25 avg chain length : 0
25 avg chain length : 0
26 max chain length : 0
26 max chain length : 0
27 compression ratio : 0
27 compression ratio : 0
28
28
29 uncompressed data size (min/max/avg) : 43 / 43 / 43
29 uncompressed data size (min/max/avg) : 43 / 43 / 43
30 full revision size (min/max/avg) : 44 / 44 / 44
30 full revision size (min/max/avg) : 44 / 44 / 44
31 delta size (min/max/avg) : 0 / 0 / 0
31 delta size (min/max/avg) : 0 / 0 / 0
32
32
33 Test debugindex, with and without the --debug flag
33 Test debugindex, with and without the --debug flag
34 $ hg debugindex a
34 $ hg debugindex a
35 rev offset length ..... linkrev nodeid p1 p2 (re)
35 rev offset length ..... linkrev nodeid p1 p2 (re)
36 0 0 3 .... 0 b789fdd96dc2 000000000000 000000000000 (re)
36 0 0 3 .... 0 b789fdd96dc2 000000000000 000000000000 (re)
37 $ hg --debug debugindex a
37 $ hg --debug debugindex a
38 rev offset length ..... linkrev nodeid p1 p2 (re)
38 rev offset length ..... linkrev nodeid p1 p2 (re)
39 0 0 3 .... 0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 (re)
39 0 0 3 .... 0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 (re)
40 $ hg debugindex -f 1 a
40 $ hg debugindex -f 1 a
41 rev flag offset length size ..... link p1 p2 nodeid (re)
41 rev flag offset length size ..... link p1 p2 nodeid (re)
42 0 0000 0 3 2 .... 0 -1 -1 b789fdd96dc2 (re)
42 0 0000 0 3 2 .... 0 -1 -1 b789fdd96dc2 (re)
43 $ hg --debug debugindex -f 1 a
43 $ hg --debug debugindex -f 1 a
44 rev flag offset length size ..... link p1 p2 nodeid (re)
44 rev flag offset length size ..... link p1 p2 nodeid (re)
45 0 0000 0 3 2 .... 0 -1 -1 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 (re)
45 0 0000 0 3 2 .... 0 -1 -1 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 (re)
46
46
47 debugdelta chain basic output
48
49 $ hg debugdeltachain -m
50 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
51 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000
52
53 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen}\n'
54 0 1 1
55
56 $ hg debugdeltachain -m -Tjson
57 [
58 {
59 "chainid": 1,
60 "chainlen": 1,
61 "chainratio": 1.02325581395,
62 "chainsize": 44,
63 "compsize": 44,
64 "deltatype": "base",
65 "extradist": 0,
66 "extraratio": 0.0,
67 "lindist": 44,
68 "prevrev": -1,
69 "rev": 0,
70 "uncompsize": 43
71 }
72 ]
47
73
48 Test max chain len
74 Test max chain len
49 $ cat >> $HGRCPATH << EOF
75 $ cat >> $HGRCPATH << EOF
50 > [format]
76 > [format]
51 > maxchainlen=4
77 > maxchainlen=4
52 > EOF
78 > EOF
53
79
54 $ printf "This test checks if maxchainlen config value is respected also it can serve as basic test for debugrevlog -d <file>.\n" >> a
80 $ printf "This test checks if maxchainlen config value is respected also it can serve as basic test for debugrevlog -d <file>.\n" >> a
55 $ hg ci -m a
81 $ hg ci -m a
56 $ printf "b\n" >> a
82 $ printf "b\n" >> a
57 $ hg ci -m a
83 $ hg ci -m a
58 $ printf "c\n" >> a
84 $ printf "c\n" >> a
59 $ hg ci -m a
85 $ hg ci -m a
60 $ printf "d\n" >> a
86 $ printf "d\n" >> a
61 $ hg ci -m a
87 $ hg ci -m a
62 $ printf "e\n" >> a
88 $ printf "e\n" >> a
63 $ hg ci -m a
89 $ hg ci -m a
64 $ printf "f\n" >> a
90 $ printf "f\n" >> a
65 $ hg ci -m a
91 $ hg ci -m a
66 $ printf 'g\n' >> a
92 $ printf 'g\n' >> a
67 $ hg ci -m a
93 $ hg ci -m a
68 $ printf 'h\n' >> a
94 $ printf 'h\n' >> a
69 $ hg ci -m a
95 $ hg ci -m a
70 $ hg debugrevlog -d a
96 $ hg debugrevlog -d a
71 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
97 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
72 0 -1 -1 0 ??? 0 0 0 0 ??? ???? ? 1 0 (glob)
98 0 -1 -1 0 ??? 0 0 0 0 ??? ???? ? 1 0 (glob)
73 1 0 -1 ??? ??? 0 0 0 0 ??? ???? ? 1 1 (glob)
99 1 0 -1 ??? ??? 0 0 0 0 ??? ???? ? 1 1 (glob)
74 2 1 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
100 2 1 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
75 3 2 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
101 3 2 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
76 4 3 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 4 (glob)
102 4 3 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 4 (glob)
77 5 4 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 0 (glob)
103 5 4 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 0 (glob)
78 6 5 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 1 (glob)
104 6 5 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 1 (glob)
79 7 6 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
105 7 6 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
80 8 7 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
106 8 7 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
81 $ cd ..
107 $ cd ..
82
108
83 Test internal debugstacktrace command
109 Test internal debugstacktrace command
84
110
85 $ cat > debugstacktrace.py << EOF
111 $ cat > debugstacktrace.py << EOF
86 > from mercurial.util import debugstacktrace, dst, sys
112 > from mercurial.util import debugstacktrace, dst, sys
87 > def f():
113 > def f():
88 > dst('hello world')
114 > dst('hello world')
89 > def g():
115 > def g():
90 > f()
116 > f()
91 > debugstacktrace(skip=-5, f=sys.stdout)
117 > debugstacktrace(skip=-5, f=sys.stdout)
92 > g()
118 > g()
93 > EOF
119 > EOF
94 $ python debugstacktrace.py
120 $ python debugstacktrace.py
95 hello world at:
121 hello world at:
96 debugstacktrace.py:7 in * (glob)
122 debugstacktrace.py:7 in * (glob)
97 debugstacktrace.py:5 in g
123 debugstacktrace.py:5 in g
98 debugstacktrace.py:3 in f
124 debugstacktrace.py:3 in f
99 stacktrace at:
125 stacktrace at:
100 debugstacktrace.py:7 *in * (glob)
126 debugstacktrace.py:7 *in * (glob)
101 debugstacktrace.py:6 *in g (glob)
127 debugstacktrace.py:6 *in g (glob)
102 */util.py:* in debugstacktrace (glob)
128 */util.py:* in debugstacktrace (glob)
@@ -1,2413 +1,2415 b''
1 Short help:
1 Short help:
2
2
3 $ hg
3 $ hg
4 Mercurial Distributed SCM
4 Mercurial Distributed SCM
5
5
6 basic commands:
6 basic commands:
7
7
8 add add the specified files on the next commit
8 add add the specified files on the next commit
9 annotate show changeset information by line for each file
9 annotate show changeset information by line for each file
10 clone make a copy of an existing repository
10 clone make a copy of an existing repository
11 commit commit the specified files or all outstanding changes
11 commit commit the specified files or all outstanding changes
12 diff diff repository (or selected files)
12 diff diff repository (or selected files)
13 export dump the header and diffs for one or more changesets
13 export dump the header and diffs for one or more changesets
14 forget forget the specified files on the next commit
14 forget forget the specified files on the next commit
15 init create a new repository in the given directory
15 init create a new repository in the given directory
16 log show revision history of entire repository or files
16 log show revision history of entire repository or files
17 merge merge another revision into working directory
17 merge merge another revision into working directory
18 pull pull changes from the specified source
18 pull pull changes from the specified source
19 push push changes to the specified destination
19 push push changes to the specified destination
20 remove remove the specified files on the next commit
20 remove remove the specified files on the next commit
21 serve start stand-alone webserver
21 serve start stand-alone webserver
22 status show changed files in the working directory
22 status show changed files in the working directory
23 summary summarize working directory state
23 summary summarize working directory state
24 update update working directory (or switch revisions)
24 update update working directory (or switch revisions)
25
25
26 (use "hg help" for the full list of commands or "hg -v" for details)
26 (use "hg help" for the full list of commands or "hg -v" for details)
27
27
28 $ hg -q
28 $ hg -q
29 add add the specified files on the next commit
29 add add the specified files on the next commit
30 annotate show changeset information by line for each file
30 annotate show changeset information by line for each file
31 clone make a copy of an existing repository
31 clone make a copy of an existing repository
32 commit commit the specified files or all outstanding changes
32 commit commit the specified files or all outstanding changes
33 diff diff repository (or selected files)
33 diff diff repository (or selected files)
34 export dump the header and diffs for one or more changesets
34 export dump the header and diffs for one or more changesets
35 forget forget the specified files on the next commit
35 forget forget the specified files on the next commit
36 init create a new repository in the given directory
36 init create a new repository in the given directory
37 log show revision history of entire repository or files
37 log show revision history of entire repository or files
38 merge merge another revision into working directory
38 merge merge another revision into working directory
39 pull pull changes from the specified source
39 pull pull changes from the specified source
40 push push changes to the specified destination
40 push push changes to the specified destination
41 remove remove the specified files on the next commit
41 remove remove the specified files on the next commit
42 serve start stand-alone webserver
42 serve start stand-alone webserver
43 status show changed files in the working directory
43 status show changed files in the working directory
44 summary summarize working directory state
44 summary summarize working directory state
45 update update working directory (or switch revisions)
45 update update working directory (or switch revisions)
46
46
47 $ hg help
47 $ hg help
48 Mercurial Distributed SCM
48 Mercurial Distributed SCM
49
49
50 list of commands:
50 list of commands:
51
51
52 add add the specified files on the next commit
52 add add the specified files on the next commit
53 addremove add all new files, delete all missing files
53 addremove add all new files, delete all missing files
54 annotate show changeset information by line for each file
54 annotate show changeset information by line for each file
55 archive create an unversioned archive of a repository revision
55 archive create an unversioned archive of a repository revision
56 backout reverse effect of earlier changeset
56 backout reverse effect of earlier changeset
57 bisect subdivision search of changesets
57 bisect subdivision search of changesets
58 bookmarks create a new bookmark or list existing bookmarks
58 bookmarks create a new bookmark or list existing bookmarks
59 branch set or show the current branch name
59 branch set or show the current branch name
60 branches list repository named branches
60 branches list repository named branches
61 bundle create a changegroup file
61 bundle create a changegroup file
62 cat output the current or given revision of files
62 cat output the current or given revision of files
63 clone make a copy of an existing repository
63 clone make a copy of an existing repository
64 commit commit the specified files or all outstanding changes
64 commit commit the specified files or all outstanding changes
65 config show combined config settings from all hgrc files
65 config show combined config settings from all hgrc files
66 copy mark files as copied for the next commit
66 copy mark files as copied for the next commit
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 files list tracked files
70 forget forget the specified files on the next commit
70 forget forget the specified files on the next commit
71 graft copy changes from other branches onto the current branch
71 graft copy changes from other branches onto the current branch
72 grep search for a pattern in specified files and revisions
72 grep search for a pattern in specified files and revisions
73 heads show branch heads
73 heads show branch heads
74 help show help for a given topic or a help overview
74 help show help for a given topic or a help overview
75 identify identify the working directory or specified revision
75 identify identify the working directory or specified revision
76 import import an ordered set of patches
76 import import an ordered set of patches
77 incoming show new changesets found in source
77 incoming show new changesets found in source
78 init create a new repository in the given directory
78 init create a new repository in the given directory
79 log show revision history of entire repository or files
79 log show revision history of entire repository or files
80 manifest output the current or given revision of the project manifest
80 manifest output the current or given revision of the project manifest
81 merge merge another revision into working directory
81 merge merge another revision into working directory
82 outgoing show changesets not found in the destination
82 outgoing show changesets not found in the destination
83 paths show aliases for remote repositories
83 paths show aliases for remote repositories
84 phase set or show the current phase name
84 phase set or show the current phase name
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 recover roll back an interrupted transaction
87 recover roll back an interrupted transaction
88 remove remove the specified files on the next commit
88 remove remove the specified files on the next commit
89 rename rename files; equivalent of copy + remove
89 rename rename files; equivalent of copy + remove
90 resolve redo merges or set/view the merge status of files
90 resolve redo merges or set/view the merge status of files
91 revert restore files to their checkout state
91 revert restore files to their checkout state
92 root print the root (top) of the current working directory
92 root print the root (top) of the current working directory
93 serve start stand-alone webserver
93 serve start stand-alone webserver
94 status show changed files in the working directory
94 status show changed files in the working directory
95 summary summarize working directory state
95 summary summarize working directory state
96 tag add one or more tags for the current or given revision
96 tag add one or more tags for the current or given revision
97 tags list repository tags
97 tags list repository tags
98 unbundle apply one or more changegroup files
98 unbundle apply one or more changegroup files
99 update update working directory (or switch revisions)
99 update update working directory (or switch revisions)
100 verify verify the integrity of the repository
100 verify verify the integrity of the repository
101 version output version and copyright information
101 version output version and copyright information
102
102
103 additional help topics:
103 additional help topics:
104
104
105 config Configuration Files
105 config Configuration Files
106 dates Date Formats
106 dates Date Formats
107 diffs Diff Formats
107 diffs Diff Formats
108 environment Environment Variables
108 environment Environment Variables
109 extensions Using Additional Features
109 extensions Using Additional Features
110 filesets Specifying File Sets
110 filesets Specifying File Sets
111 glossary Glossary
111 glossary Glossary
112 hgignore Syntax for Mercurial Ignore Files
112 hgignore Syntax for Mercurial Ignore Files
113 hgweb Configuring hgweb
113 hgweb Configuring hgweb
114 merge-tools Merge Tools
114 merge-tools Merge Tools
115 multirevs Specifying Multiple Revisions
115 multirevs Specifying Multiple Revisions
116 patterns File Name Patterns
116 patterns File Name Patterns
117 phases Working with Phases
117 phases Working with Phases
118 revisions Specifying Single Revisions
118 revisions Specifying Single Revisions
119 revsets Specifying Revision Sets
119 revsets Specifying Revision Sets
120 scripting Using Mercurial from scripts and automation
120 scripting Using Mercurial from scripts and automation
121 subrepos Subrepositories
121 subrepos Subrepositories
122 templating Template Usage
122 templating Template Usage
123 urls URL Paths
123 urls URL Paths
124
124
125 (use "hg help -v" to show built-in aliases and global options)
125 (use "hg help -v" to show built-in aliases and global options)
126
126
127 $ hg -q help
127 $ hg -q help
128 add add the specified files on the next commit
128 add add the specified files on the next commit
129 addremove add all new files, delete all missing files
129 addremove add all new files, delete all missing files
130 annotate show changeset information by line for each file
130 annotate show changeset information by line for each file
131 archive create an unversioned archive of a repository revision
131 archive create an unversioned archive of a repository revision
132 backout reverse effect of earlier changeset
132 backout reverse effect of earlier changeset
133 bisect subdivision search of changesets
133 bisect subdivision search of changesets
134 bookmarks create a new bookmark or list existing bookmarks
134 bookmarks create a new bookmark or list existing bookmarks
135 branch set or show the current branch name
135 branch set or show the current branch name
136 branches list repository named branches
136 branches list repository named branches
137 bundle create a changegroup file
137 bundle create a changegroup file
138 cat output the current or given revision of files
138 cat output the current or given revision of files
139 clone make a copy of an existing repository
139 clone make a copy of an existing repository
140 commit commit the specified files or all outstanding changes
140 commit commit the specified files or all outstanding changes
141 config show combined config settings from all hgrc files
141 config show combined config settings from all hgrc files
142 copy mark files as copied for the next commit
142 copy mark files as copied for the next commit
143 diff diff repository (or selected files)
143 diff diff repository (or selected files)
144 export dump the header and diffs for one or more changesets
144 export dump the header and diffs for one or more changesets
145 files list tracked files
145 files list tracked files
146 forget forget the specified files on the next commit
146 forget forget the specified files on the next commit
147 graft copy changes from other branches onto the current branch
147 graft copy changes from other branches onto the current branch
148 grep search for a pattern in specified files and revisions
148 grep search for a pattern in specified files and revisions
149 heads show branch heads
149 heads show branch heads
150 help show help for a given topic or a help overview
150 help show help for a given topic or a help overview
151 identify identify the working directory or specified revision
151 identify identify the working directory or specified revision
152 import import an ordered set of patches
152 import import an ordered set of patches
153 incoming show new changesets found in source
153 incoming show new changesets found in source
154 init create a new repository in the given directory
154 init create a new repository in the given directory
155 log show revision history of entire repository or files
155 log show revision history of entire repository or files
156 manifest output the current or given revision of the project manifest
156 manifest output the current or given revision of the project manifest
157 merge merge another revision into working directory
157 merge merge another revision into working directory
158 outgoing show changesets not found in the destination
158 outgoing show changesets not found in the destination
159 paths show aliases for remote repositories
159 paths show aliases for remote repositories
160 phase set or show the current phase name
160 phase set or show the current phase name
161 pull pull changes from the specified source
161 pull pull changes from the specified source
162 push push changes to the specified destination
162 push push changes to the specified destination
163 recover roll back an interrupted transaction
163 recover roll back an interrupted transaction
164 remove remove the specified files on the next commit
164 remove remove the specified files on the next commit
165 rename rename files; equivalent of copy + remove
165 rename rename files; equivalent of copy + remove
166 resolve redo merges or set/view the merge status of files
166 resolve redo merges or set/view the merge status of files
167 revert restore files to their checkout state
167 revert restore files to their checkout state
168 root print the root (top) of the current working directory
168 root print the root (top) of the current working directory
169 serve start stand-alone webserver
169 serve start stand-alone webserver
170 status show changed files in the working directory
170 status show changed files in the working directory
171 summary summarize working directory state
171 summary summarize working directory state
172 tag add one or more tags for the current or given revision
172 tag add one or more tags for the current or given revision
173 tags list repository tags
173 tags list repository tags
174 unbundle apply one or more changegroup files
174 unbundle apply one or more changegroup files
175 update update working directory (or switch revisions)
175 update update working directory (or switch revisions)
176 verify verify the integrity of the repository
176 verify verify the integrity of the repository
177 version output version and copyright information
177 version output version and copyright information
178
178
179 additional help topics:
179 additional help topics:
180
180
181 config Configuration Files
181 config Configuration Files
182 dates Date Formats
182 dates Date Formats
183 diffs Diff Formats
183 diffs Diff Formats
184 environment Environment Variables
184 environment Environment Variables
185 extensions Using Additional Features
185 extensions Using Additional Features
186 filesets Specifying File Sets
186 filesets Specifying File Sets
187 glossary Glossary
187 glossary Glossary
188 hgignore Syntax for Mercurial Ignore Files
188 hgignore Syntax for Mercurial Ignore Files
189 hgweb Configuring hgweb
189 hgweb Configuring hgweb
190 merge-tools Merge Tools
190 merge-tools Merge Tools
191 multirevs Specifying Multiple Revisions
191 multirevs Specifying Multiple Revisions
192 patterns File Name Patterns
192 patterns File Name Patterns
193 phases Working with Phases
193 phases Working with Phases
194 revisions Specifying Single Revisions
194 revisions Specifying Single Revisions
195 revsets Specifying Revision Sets
195 revsets Specifying Revision Sets
196 scripting Using Mercurial from scripts and automation
196 scripting Using Mercurial from scripts and automation
197 subrepos Subrepositories
197 subrepos Subrepositories
198 templating Template Usage
198 templating Template Usage
199 urls URL Paths
199 urls URL Paths
200
200
201 Test extension help:
201 Test extension help:
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
202 $ hg help extensions --config extensions.rebase= --config extensions.children=
203 Using Additional Features
203 Using Additional Features
204 """""""""""""""""""""""""
204 """""""""""""""""""""""""
205
205
206 Mercurial has the ability to add new features through the use of
206 Mercurial has the ability to add new features through the use of
207 extensions. Extensions may add new commands, add options to existing
207 extensions. Extensions may add new commands, add options to existing
208 commands, change the default behavior of commands, or implement hooks.
208 commands, change the default behavior of commands, or implement hooks.
209
209
210 To enable the "foo" extension, either shipped with Mercurial or in the
210 To enable the "foo" extension, either shipped with Mercurial or in the
211 Python search path, create an entry for it in your configuration file,
211 Python search path, create an entry for it in your configuration file,
212 like this:
212 like this:
213
213
214 [extensions]
214 [extensions]
215 foo =
215 foo =
216
216
217 You may also specify the full path to an extension:
217 You may also specify the full path to an extension:
218
218
219 [extensions]
219 [extensions]
220 myfeature = ~/.hgext/myfeature.py
220 myfeature = ~/.hgext/myfeature.py
221
221
222 See "hg help config" for more information on configuration files.
222 See "hg help config" for more information on configuration files.
223
223
224 Extensions are not loaded by default for a variety of reasons: they can
224 Extensions are not loaded by default for a variety of reasons: they can
225 increase startup overhead; they may be meant for advanced usage only; they
225 increase startup overhead; they may be meant for advanced usage only; they
226 may provide potentially dangerous abilities (such as letting you destroy
226 may provide potentially dangerous abilities (such as letting you destroy
227 or modify history); they might not be ready for prime time; or they may
227 or modify history); they might not be ready for prime time; or they may
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
228 alter some usual behaviors of stock Mercurial. It is thus up to the user
229 to activate extensions as needed.
229 to activate extensions as needed.
230
230
231 To explicitly disable an extension enabled in a configuration file of
231 To explicitly disable an extension enabled in a configuration file of
232 broader scope, prepend its path with !:
232 broader scope, prepend its path with !:
233
233
234 [extensions]
234 [extensions]
235 # disabling extension bar residing in /path/to/extension/bar.py
235 # disabling extension bar residing in /path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
236 bar = !/path/to/extension/bar.py
237 # ditto, but no path was supplied for extension baz
237 # ditto, but no path was supplied for extension baz
238 baz = !
238 baz = !
239
239
240 enabled extensions:
240 enabled extensions:
241
241
242 children command to display child changesets (DEPRECATED)
242 children command to display child changesets (DEPRECATED)
243 rebase command to move sets of revisions to a different ancestor
243 rebase command to move sets of revisions to a different ancestor
244
244
245 disabled extensions:
245 disabled extensions:
246
246
247 acl hooks for controlling repository access
247 acl hooks for controlling repository access
248 blackbox log repository events to a blackbox for debugging
248 blackbox log repository events to a blackbox for debugging
249 bugzilla hooks for integrating with the Bugzilla bug tracker
249 bugzilla hooks for integrating with the Bugzilla bug tracker
250 censor erase file content at a given revision
250 censor erase file content at a given revision
251 churn command to display statistics about repository history
251 churn command to display statistics about repository history
252 clonebundles advertise pre-generated bundles to seed clones
252 clonebundles advertise pre-generated bundles to seed clones
253 (experimental)
253 (experimental)
254 color colorize output from some commands
254 color colorize output from some commands
255 convert import revisions from foreign VCS repositories into
255 convert import revisions from foreign VCS repositories into
256 Mercurial
256 Mercurial
257 eol automatically manage newlines in repository files
257 eol automatically manage newlines in repository files
258 extdiff command to allow external programs to compare revisions
258 extdiff command to allow external programs to compare revisions
259 factotum http authentication with factotum
259 factotum http authentication with factotum
260 gpg commands to sign and verify changesets
260 gpg commands to sign and verify changesets
261 hgcia hooks for integrating with the CIA.vc notification service
261 hgcia hooks for integrating with the CIA.vc notification service
262 hgk browse the repository in a graphical way
262 hgk browse the repository in a graphical way
263 highlight syntax highlighting for hgweb (requires Pygments)
263 highlight syntax highlighting for hgweb (requires Pygments)
264 histedit interactive history editing
264 histedit interactive history editing
265 keyword expand keywords in tracked files
265 keyword expand keywords in tracked files
266 largefiles track large binary files
266 largefiles track large binary files
267 mq manage a stack of patches
267 mq manage a stack of patches
268 notify hooks for sending email push notifications
268 notify hooks for sending email push notifications
269 pager browse command output with an external pager
269 pager browse command output with an external pager
270 patchbomb command to send changesets as (a series of) patch emails
270 patchbomb command to send changesets as (a series of) patch emails
271 purge command to delete untracked files from the working
271 purge command to delete untracked files from the working
272 directory
272 directory
273 record commands to interactively select changes for
273 record commands to interactively select changes for
274 commit/qrefresh
274 commit/qrefresh
275 relink recreates hardlinks between repository clones
275 relink recreates hardlinks between repository clones
276 schemes extend schemes with shortcuts to repository swarms
276 schemes extend schemes with shortcuts to repository swarms
277 share share a common history between several working directories
277 share share a common history between several working directories
278 shelve save and restore changes to the working directory
278 shelve save and restore changes to the working directory
279 strip strip changesets and their descendants from history
279 strip strip changesets and their descendants from history
280 transplant command to transplant changesets from another branch
280 transplant command to transplant changesets from another branch
281 win32mbcs allow the use of MBCS paths with problematic encodings
281 win32mbcs allow the use of MBCS paths with problematic encodings
282 zeroconf discover and advertise repositories on the local network
282 zeroconf discover and advertise repositories on the local network
283
283
284 Verify that extension keywords appear in help templates
284 Verify that extension keywords appear in help templates
285
285
286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
287
287
288 Test short command list with verbose option
288 Test short command list with verbose option
289
289
290 $ hg -v help shortlist
290 $ hg -v help shortlist
291 Mercurial Distributed SCM
291 Mercurial Distributed SCM
292
292
293 basic commands:
293 basic commands:
294
294
295 add add the specified files on the next commit
295 add add the specified files on the next commit
296 annotate, blame
296 annotate, blame
297 show changeset information by line for each file
297 show changeset information by line for each file
298 clone make a copy of an existing repository
298 clone make a copy of an existing repository
299 commit, ci commit the specified files or all outstanding changes
299 commit, ci commit the specified files or all outstanding changes
300 diff diff repository (or selected files)
300 diff diff repository (or selected files)
301 export dump the header and diffs for one or more changesets
301 export dump the header and diffs for one or more changesets
302 forget forget the specified files on the next commit
302 forget forget the specified files on the next commit
303 init create a new repository in the given directory
303 init create a new repository in the given directory
304 log, history show revision history of entire repository or files
304 log, history show revision history of entire repository or files
305 merge merge another revision into working directory
305 merge merge another revision into working directory
306 pull pull changes from the specified source
306 pull pull changes from the specified source
307 push push changes to the specified destination
307 push push changes to the specified destination
308 remove, rm remove the specified files on the next commit
308 remove, rm remove the specified files on the next commit
309 serve start stand-alone webserver
309 serve start stand-alone webserver
310 status, st show changed files in the working directory
310 status, st show changed files in the working directory
311 summary, sum summarize working directory state
311 summary, sum summarize working directory state
312 update, up, checkout, co
312 update, up, checkout, co
313 update working directory (or switch revisions)
313 update working directory (or switch revisions)
314
314
315 global options ([+] can be repeated):
315 global options ([+] can be repeated):
316
316
317 -R --repository REPO repository root directory or name of overlay bundle
317 -R --repository REPO repository root directory or name of overlay bundle
318 file
318 file
319 --cwd DIR change working directory
319 --cwd DIR change working directory
320 -y --noninteractive do not prompt, automatically pick the first choice for
320 -y --noninteractive do not prompt, automatically pick the first choice for
321 all prompts
321 all prompts
322 -q --quiet suppress output
322 -q --quiet suppress output
323 -v --verbose enable additional output
323 -v --verbose enable additional output
324 --config CONFIG [+] set/override config option (use 'section.name=value')
324 --config CONFIG [+] set/override config option (use 'section.name=value')
325 --debug enable debugging output
325 --debug enable debugging output
326 --debugger start debugger
326 --debugger start debugger
327 --encoding ENCODE set the charset encoding (default: ascii)
327 --encoding ENCODE set the charset encoding (default: ascii)
328 --encodingmode MODE set the charset encoding mode (default: strict)
328 --encodingmode MODE set the charset encoding mode (default: strict)
329 --traceback always print a traceback on exception
329 --traceback always print a traceback on exception
330 --time time how long the command takes
330 --time time how long the command takes
331 --profile print command execution profile
331 --profile print command execution profile
332 --version output version information and exit
332 --version output version information and exit
333 -h --help display help and exit
333 -h --help display help and exit
334 --hidden consider hidden changesets
334 --hidden consider hidden changesets
335
335
336 (use "hg help" for the full list of commands)
336 (use "hg help" for the full list of commands)
337
337
338 $ hg add -h
338 $ hg add -h
339 hg add [OPTION]... [FILE]...
339 hg add [OPTION]... [FILE]...
340
340
341 add the specified files on the next commit
341 add the specified files on the next commit
342
342
343 Schedule files to be version controlled and added to the repository.
343 Schedule files to be version controlled and added to the repository.
344
344
345 The files will be added to the repository at the next commit. To undo an
345 The files will be added to the repository at the next commit. To undo an
346 add before that, see "hg forget".
346 add before that, see "hg forget".
347
347
348 If no names are given, add all files to the repository.
348 If no names are given, add all files to the repository.
349
349
350 Returns 0 if all files are successfully added.
350 Returns 0 if all files are successfully added.
351
351
352 options ([+] can be repeated):
352 options ([+] can be repeated):
353
353
354 -I --include PATTERN [+] include names matching the given patterns
354 -I --include PATTERN [+] include names matching the given patterns
355 -X --exclude PATTERN [+] exclude names matching the given patterns
355 -X --exclude PATTERN [+] exclude names matching the given patterns
356 -S --subrepos recurse into subrepositories
356 -S --subrepos recurse into subrepositories
357 -n --dry-run do not perform actions, just print output
357 -n --dry-run do not perform actions, just print output
358
358
359 (some details hidden, use --verbose to show complete help)
359 (some details hidden, use --verbose to show complete help)
360
360
361 Verbose help for add
361 Verbose help for add
362
362
363 $ hg add -hv
363 $ hg add -hv
364 hg add [OPTION]... [FILE]...
364 hg add [OPTION]... [FILE]...
365
365
366 add the specified files on the next commit
366 add the specified files on the next commit
367
367
368 Schedule files to be version controlled and added to the repository.
368 Schedule files to be version controlled and added to the repository.
369
369
370 The files will be added to the repository at the next commit. To undo an
370 The files will be added to the repository at the next commit. To undo an
371 add before that, see "hg forget".
371 add before that, see "hg forget".
372
372
373 If no names are given, add all files to the repository.
373 If no names are given, add all files to the repository.
374
374
375 Examples:
375 Examples:
376
376
377 - New (unknown) files are added automatically by "hg add":
377 - New (unknown) files are added automatically by "hg add":
378
378
379 $ ls
379 $ ls
380 foo.c
380 foo.c
381 $ hg status
381 $ hg status
382 ? foo.c
382 ? foo.c
383 $ hg add
383 $ hg add
384 adding foo.c
384 adding foo.c
385 $ hg status
385 $ hg status
386 A foo.c
386 A foo.c
387
387
388 - Specific files to be added can be specified:
388 - Specific files to be added can be specified:
389
389
390 $ ls
390 $ ls
391 bar.c foo.c
391 bar.c foo.c
392 $ hg status
392 $ hg status
393 ? bar.c
393 ? bar.c
394 ? foo.c
394 ? foo.c
395 $ hg add bar.c
395 $ hg add bar.c
396 $ hg status
396 $ hg status
397 A bar.c
397 A bar.c
398 ? foo.c
398 ? foo.c
399
399
400 Returns 0 if all files are successfully added.
400 Returns 0 if all files are successfully added.
401
401
402 options ([+] can be repeated):
402 options ([+] can be repeated):
403
403
404 -I --include PATTERN [+] include names matching the given patterns
404 -I --include PATTERN [+] include names matching the given patterns
405 -X --exclude PATTERN [+] exclude names matching the given patterns
405 -X --exclude PATTERN [+] exclude names matching the given patterns
406 -S --subrepos recurse into subrepositories
406 -S --subrepos recurse into subrepositories
407 -n --dry-run do not perform actions, just print output
407 -n --dry-run do not perform actions, just print output
408
408
409 global options ([+] can be repeated):
409 global options ([+] can be repeated):
410
410
411 -R --repository REPO repository root directory or name of overlay bundle
411 -R --repository REPO repository root directory or name of overlay bundle
412 file
412 file
413 --cwd DIR change working directory
413 --cwd DIR change working directory
414 -y --noninteractive do not prompt, automatically pick the first choice for
414 -y --noninteractive do not prompt, automatically pick the first choice for
415 all prompts
415 all prompts
416 -q --quiet suppress output
416 -q --quiet suppress output
417 -v --verbose enable additional output
417 -v --verbose enable additional output
418 --config CONFIG [+] set/override config option (use 'section.name=value')
418 --config CONFIG [+] set/override config option (use 'section.name=value')
419 --debug enable debugging output
419 --debug enable debugging output
420 --debugger start debugger
420 --debugger start debugger
421 --encoding ENCODE set the charset encoding (default: ascii)
421 --encoding ENCODE set the charset encoding (default: ascii)
422 --encodingmode MODE set the charset encoding mode (default: strict)
422 --encodingmode MODE set the charset encoding mode (default: strict)
423 --traceback always print a traceback on exception
423 --traceback always print a traceback on exception
424 --time time how long the command takes
424 --time time how long the command takes
425 --profile print command execution profile
425 --profile print command execution profile
426 --version output version information and exit
426 --version output version information and exit
427 -h --help display help and exit
427 -h --help display help and exit
428 --hidden consider hidden changesets
428 --hidden consider hidden changesets
429
429
430 Test help option with version option
430 Test help option with version option
431
431
432 $ hg add -h --version
432 $ hg add -h --version
433 Mercurial Distributed SCM (version *) (glob)
433 Mercurial Distributed SCM (version *) (glob)
434 (see https://mercurial-scm.org for more information)
434 (see https://mercurial-scm.org for more information)
435
435
436 Copyright (C) 2005-2015 Matt Mackall and others
436 Copyright (C) 2005-2015 Matt Mackall and others
437 This is free software; see the source for copying conditions. There is NO
437 This is free software; see the source for copying conditions. There is NO
438 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
438 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
439
439
440 $ hg add --skjdfks
440 $ hg add --skjdfks
441 hg add: option --skjdfks not recognized
441 hg add: option --skjdfks not recognized
442 hg add [OPTION]... [FILE]...
442 hg add [OPTION]... [FILE]...
443
443
444 add the specified files on the next commit
444 add the specified files on the next commit
445
445
446 options ([+] can be repeated):
446 options ([+] can be repeated):
447
447
448 -I --include PATTERN [+] include names matching the given patterns
448 -I --include PATTERN [+] include names matching the given patterns
449 -X --exclude PATTERN [+] exclude names matching the given patterns
449 -X --exclude PATTERN [+] exclude names matching the given patterns
450 -S --subrepos recurse into subrepositories
450 -S --subrepos recurse into subrepositories
451 -n --dry-run do not perform actions, just print output
451 -n --dry-run do not perform actions, just print output
452
452
453 (use "hg add -h" to show more help)
453 (use "hg add -h" to show more help)
454 [255]
454 [255]
455
455
456 Test ambiguous command help
456 Test ambiguous command help
457
457
458 $ hg help ad
458 $ hg help ad
459 list of commands:
459 list of commands:
460
460
461 add add the specified files on the next commit
461 add add the specified files on the next commit
462 addremove add all new files, delete all missing files
462 addremove add all new files, delete all missing files
463
463
464 (use "hg help -v ad" to show built-in aliases and global options)
464 (use "hg help -v ad" to show built-in aliases and global options)
465
465
466 Test command without options
466 Test command without options
467
467
468 $ hg help verify
468 $ hg help verify
469 hg verify
469 hg verify
470
470
471 verify the integrity of the repository
471 verify the integrity of the repository
472
472
473 Verify the integrity of the current repository.
473 Verify the integrity of the current repository.
474
474
475 This will perform an extensive check of the repository's integrity,
475 This will perform an extensive check of the repository's integrity,
476 validating the hashes and checksums of each entry in the changelog,
476 validating the hashes and checksums of each entry in the changelog,
477 manifest, and tracked files, as well as the integrity of their crosslinks
477 manifest, and tracked files, as well as the integrity of their crosslinks
478 and indices.
478 and indices.
479
479
480 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
480 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
481 information about recovery from corruption of the repository.
481 information about recovery from corruption of the repository.
482
482
483 Returns 0 on success, 1 if errors are encountered.
483 Returns 0 on success, 1 if errors are encountered.
484
484
485 (some details hidden, use --verbose to show complete help)
485 (some details hidden, use --verbose to show complete help)
486
486
487 $ hg help diff
487 $ hg help diff
488 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
488 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
489
489
490 diff repository (or selected files)
490 diff repository (or selected files)
491
491
492 Show differences between revisions for the specified files.
492 Show differences between revisions for the specified files.
493
493
494 Differences between files are shown using the unified diff format.
494 Differences between files are shown using the unified diff format.
495
495
496 Note:
496 Note:
497 diff may generate unexpected results for merges, as it will default to
497 diff may generate unexpected results for merges, as it will default to
498 comparing against the working directory's first parent changeset if no
498 comparing against the working directory's first parent changeset if no
499 revisions are specified.
499 revisions are specified.
500
500
501 When two revision arguments are given, then changes are shown between
501 When two revision arguments are given, then changes are shown between
502 those revisions. If only one revision is specified then that revision is
502 those revisions. If only one revision is specified then that revision is
503 compared to the working directory, and, when no revisions are specified,
503 compared to the working directory, and, when no revisions are specified,
504 the working directory files are compared to its parent.
504 the working directory files are compared to its parent.
505
505
506 Alternatively you can specify -c/--change with a revision to see the
506 Alternatively you can specify -c/--change with a revision to see the
507 changes in that changeset relative to its first parent.
507 changes in that changeset relative to its first parent.
508
508
509 Without the -a/--text option, diff will avoid generating diffs of files it
509 Without the -a/--text option, diff will avoid generating diffs of files it
510 detects as binary. With -a, diff will generate a diff anyway, probably
510 detects as binary. With -a, diff will generate a diff anyway, probably
511 with undesirable results.
511 with undesirable results.
512
512
513 Use the -g/--git option to generate diffs in the git extended diff format.
513 Use the -g/--git option to generate diffs in the git extended diff format.
514 For more information, read "hg help diffs".
514 For more information, read "hg help diffs".
515
515
516 Returns 0 on success.
516 Returns 0 on success.
517
517
518 options ([+] can be repeated):
518 options ([+] can be repeated):
519
519
520 -r --rev REV [+] revision
520 -r --rev REV [+] revision
521 -c --change REV change made by revision
521 -c --change REV change made by revision
522 -a --text treat all files as text
522 -a --text treat all files as text
523 -g --git use git extended diff format
523 -g --git use git extended diff format
524 --nodates omit dates from diff headers
524 --nodates omit dates from diff headers
525 --noprefix omit a/ and b/ prefixes from filenames
525 --noprefix omit a/ and b/ prefixes from filenames
526 -p --show-function show which function each change is in
526 -p --show-function show which function each change is in
527 --reverse produce a diff that undoes the changes
527 --reverse produce a diff that undoes the changes
528 -w --ignore-all-space ignore white space when comparing lines
528 -w --ignore-all-space ignore white space when comparing lines
529 -b --ignore-space-change ignore changes in the amount of white space
529 -b --ignore-space-change ignore changes in the amount of white space
530 -B --ignore-blank-lines ignore changes whose lines are all blank
530 -B --ignore-blank-lines ignore changes whose lines are all blank
531 -U --unified NUM number of lines of context to show
531 -U --unified NUM number of lines of context to show
532 --stat output diffstat-style summary of changes
532 --stat output diffstat-style summary of changes
533 --root DIR produce diffs relative to subdirectory
533 --root DIR produce diffs relative to subdirectory
534 -I --include PATTERN [+] include names matching the given patterns
534 -I --include PATTERN [+] include names matching the given patterns
535 -X --exclude PATTERN [+] exclude names matching the given patterns
535 -X --exclude PATTERN [+] exclude names matching the given patterns
536 -S --subrepos recurse into subrepositories
536 -S --subrepos recurse into subrepositories
537
537
538 (some details hidden, use --verbose to show complete help)
538 (some details hidden, use --verbose to show complete help)
539
539
540 $ hg help status
540 $ hg help status
541 hg status [OPTION]... [FILE]...
541 hg status [OPTION]... [FILE]...
542
542
543 aliases: st
543 aliases: st
544
544
545 show changed files in the working directory
545 show changed files in the working directory
546
546
547 Show status of files in the repository. If names are given, only files
547 Show status of files in the repository. If names are given, only files
548 that match are shown. Files that are clean or ignored or the source of a
548 that match are shown. Files that are clean or ignored or the source of a
549 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
549 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
550 -C/--copies or -A/--all are given. Unless options described with "show
550 -C/--copies or -A/--all are given. Unless options described with "show
551 only ..." are given, the options -mardu are used.
551 only ..." are given, the options -mardu are used.
552
552
553 Option -q/--quiet hides untracked (unknown and ignored) files unless
553 Option -q/--quiet hides untracked (unknown and ignored) files unless
554 explicitly requested with -u/--unknown or -i/--ignored.
554 explicitly requested with -u/--unknown or -i/--ignored.
555
555
556 Note:
556 Note:
557 status may appear to disagree with diff if permissions have changed or
557 status may appear to disagree with diff if permissions have changed or
558 a merge has occurred. The standard diff format does not report
558 a merge has occurred. The standard diff format does not report
559 permission changes and diff only reports changes relative to one merge
559 permission changes and diff only reports changes relative to one merge
560 parent.
560 parent.
561
561
562 If one revision is given, it is used as the base revision. If two
562 If one revision is given, it is used as the base revision. If two
563 revisions are given, the differences between them are shown. The --change
563 revisions are given, the differences between them are shown. The --change
564 option can also be used as a shortcut to list the changed files of a
564 option can also be used as a shortcut to list the changed files of a
565 revision from its first parent.
565 revision from its first parent.
566
566
567 The codes used to show the status of files are:
567 The codes used to show the status of files are:
568
568
569 M = modified
569 M = modified
570 A = added
570 A = added
571 R = removed
571 R = removed
572 C = clean
572 C = clean
573 ! = missing (deleted by non-hg command, but still tracked)
573 ! = missing (deleted by non-hg command, but still tracked)
574 ? = not tracked
574 ? = not tracked
575 I = ignored
575 I = ignored
576 = origin of the previous file (with --copies)
576 = origin of the previous file (with --copies)
577
577
578 Returns 0 on success.
578 Returns 0 on success.
579
579
580 options ([+] can be repeated):
580 options ([+] can be repeated):
581
581
582 -A --all show status of all files
582 -A --all show status of all files
583 -m --modified show only modified files
583 -m --modified show only modified files
584 -a --added show only added files
584 -a --added show only added files
585 -r --removed show only removed files
585 -r --removed show only removed files
586 -d --deleted show only deleted (but tracked) files
586 -d --deleted show only deleted (but tracked) files
587 -c --clean show only files without changes
587 -c --clean show only files without changes
588 -u --unknown show only unknown (not tracked) files
588 -u --unknown show only unknown (not tracked) files
589 -i --ignored show only ignored files
589 -i --ignored show only ignored files
590 -n --no-status hide status prefix
590 -n --no-status hide status prefix
591 -C --copies show source of copied files
591 -C --copies show source of copied files
592 -0 --print0 end filenames with NUL, for use with xargs
592 -0 --print0 end filenames with NUL, for use with xargs
593 --rev REV [+] show difference from revision
593 --rev REV [+] show difference from revision
594 --change REV list the changed files of a revision
594 --change REV list the changed files of a revision
595 -I --include PATTERN [+] include names matching the given patterns
595 -I --include PATTERN [+] include names matching the given patterns
596 -X --exclude PATTERN [+] exclude names matching the given patterns
596 -X --exclude PATTERN [+] exclude names matching the given patterns
597 -S --subrepos recurse into subrepositories
597 -S --subrepos recurse into subrepositories
598
598
599 (some details hidden, use --verbose to show complete help)
599 (some details hidden, use --verbose to show complete help)
600
600
601 $ hg -q help status
601 $ hg -q help status
602 hg status [OPTION]... [FILE]...
602 hg status [OPTION]... [FILE]...
603
603
604 show changed files in the working directory
604 show changed files in the working directory
605
605
606 $ hg help foo
606 $ hg help foo
607 abort: no such help topic: foo
607 abort: no such help topic: foo
608 (try "hg help --keyword foo")
608 (try "hg help --keyword foo")
609 [255]
609 [255]
610
610
611 $ hg skjdfks
611 $ hg skjdfks
612 hg: unknown command 'skjdfks'
612 hg: unknown command 'skjdfks'
613 Mercurial Distributed SCM
613 Mercurial Distributed SCM
614
614
615 basic commands:
615 basic commands:
616
616
617 add add the specified files on the next commit
617 add add the specified files on the next commit
618 annotate show changeset information by line for each file
618 annotate show changeset information by line for each file
619 clone make a copy of an existing repository
619 clone make a copy of an existing repository
620 commit commit the specified files or all outstanding changes
620 commit commit the specified files or all outstanding changes
621 diff diff repository (or selected files)
621 diff diff repository (or selected files)
622 export dump the header and diffs for one or more changesets
622 export dump the header and diffs for one or more changesets
623 forget forget the specified files on the next commit
623 forget forget the specified files on the next commit
624 init create a new repository in the given directory
624 init create a new repository in the given directory
625 log show revision history of entire repository or files
625 log show revision history of entire repository or files
626 merge merge another revision into working directory
626 merge merge another revision into working directory
627 pull pull changes from the specified source
627 pull pull changes from the specified source
628 push push changes to the specified destination
628 push push changes to the specified destination
629 remove remove the specified files on the next commit
629 remove remove the specified files on the next commit
630 serve start stand-alone webserver
630 serve start stand-alone webserver
631 status show changed files in the working directory
631 status show changed files in the working directory
632 summary summarize working directory state
632 summary summarize working directory state
633 update update working directory (or switch revisions)
633 update update working directory (or switch revisions)
634
634
635 (use "hg help" for the full list of commands or "hg -v" for details)
635 (use "hg help" for the full list of commands or "hg -v" for details)
636 [255]
636 [255]
637
637
638
638
639 Make sure that we don't run afoul of the help system thinking that
639 Make sure that we don't run afoul of the help system thinking that
640 this is a section and erroring out weirdly.
640 this is a section and erroring out weirdly.
641
641
642 $ hg .log
642 $ hg .log
643 hg: unknown command '.log'
643 hg: unknown command '.log'
644 (did you mean one of log?)
644 (did you mean one of log?)
645 [255]
645 [255]
646
646
647 $ hg log.
647 $ hg log.
648 hg: unknown command 'log.'
648 hg: unknown command 'log.'
649 (did you mean one of log?)
649 (did you mean one of log?)
650 [255]
650 [255]
651 $ hg pu.lh
651 $ hg pu.lh
652 hg: unknown command 'pu.lh'
652 hg: unknown command 'pu.lh'
653 (did you mean one of pull, push?)
653 (did you mean one of pull, push?)
654 [255]
654 [255]
655
655
656 $ cat > helpext.py <<EOF
656 $ cat > helpext.py <<EOF
657 > import os
657 > import os
658 > from mercurial import cmdutil, commands
658 > from mercurial import cmdutil, commands
659 >
659 >
660 > cmdtable = {}
660 > cmdtable = {}
661 > command = cmdutil.command(cmdtable)
661 > command = cmdutil.command(cmdtable)
662 >
662 >
663 > @command('nohelp',
663 > @command('nohelp',
664 > [('', 'longdesc', 3, 'x'*90),
664 > [('', 'longdesc', 3, 'x'*90),
665 > ('n', '', None, 'normal desc'),
665 > ('n', '', None, 'normal desc'),
666 > ('', 'newline', '', 'line1\nline2')],
666 > ('', 'newline', '', 'line1\nline2')],
667 > 'hg nohelp',
667 > 'hg nohelp',
668 > norepo=True)
668 > norepo=True)
669 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
669 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
670 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
670 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
671 > def nohelp(ui, *args, **kwargs):
671 > def nohelp(ui, *args, **kwargs):
672 > pass
672 > pass
673 >
673 >
674 > EOF
674 > EOF
675 $ echo '[extensions]' >> $HGRCPATH
675 $ echo '[extensions]' >> $HGRCPATH
676 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
676 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
677
677
678 Test command with no help text
678 Test command with no help text
679
679
680 $ hg help nohelp
680 $ hg help nohelp
681 hg nohelp
681 hg nohelp
682
682
683 (no help text available)
683 (no help text available)
684
684
685 options:
685 options:
686
686
687 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
687 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
688 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
688 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
689 -n -- normal desc
689 -n -- normal desc
690 --newline VALUE line1 line2
690 --newline VALUE line1 line2
691
691
692 (some details hidden, use --verbose to show complete help)
692 (some details hidden, use --verbose to show complete help)
693
693
694 $ hg help -k nohelp
694 $ hg help -k nohelp
695 Commands:
695 Commands:
696
696
697 nohelp hg nohelp
697 nohelp hg nohelp
698
698
699 Extension Commands:
699 Extension Commands:
700
700
701 nohelp (no help text available)
701 nohelp (no help text available)
702
702
703 Test that default list of commands omits extension commands
703 Test that default list of commands omits extension commands
704
704
705 $ hg help
705 $ hg help
706 Mercurial Distributed SCM
706 Mercurial Distributed SCM
707
707
708 list of commands:
708 list of commands:
709
709
710 add add the specified files on the next commit
710 add add the specified files on the next commit
711 addremove add all new files, delete all missing files
711 addremove add all new files, delete all missing files
712 annotate show changeset information by line for each file
712 annotate show changeset information by line for each file
713 archive create an unversioned archive of a repository revision
713 archive create an unversioned archive of a repository revision
714 backout reverse effect of earlier changeset
714 backout reverse effect of earlier changeset
715 bisect subdivision search of changesets
715 bisect subdivision search of changesets
716 bookmarks create a new bookmark or list existing bookmarks
716 bookmarks create a new bookmark or list existing bookmarks
717 branch set or show the current branch name
717 branch set or show the current branch name
718 branches list repository named branches
718 branches list repository named branches
719 bundle create a changegroup file
719 bundle create a changegroup file
720 cat output the current or given revision of files
720 cat output the current or given revision of files
721 clone make a copy of an existing repository
721 clone make a copy of an existing repository
722 commit commit the specified files or all outstanding changes
722 commit commit the specified files or all outstanding changes
723 config show combined config settings from all hgrc files
723 config show combined config settings from all hgrc files
724 copy mark files as copied for the next commit
724 copy mark files as copied for the next commit
725 diff diff repository (or selected files)
725 diff diff repository (or selected files)
726 export dump the header and diffs for one or more changesets
726 export dump the header and diffs for one or more changesets
727 files list tracked files
727 files list tracked files
728 forget forget the specified files on the next commit
728 forget forget the specified files on the next commit
729 graft copy changes from other branches onto the current branch
729 graft copy changes from other branches onto the current branch
730 grep search for a pattern in specified files and revisions
730 grep search for a pattern in specified files and revisions
731 heads show branch heads
731 heads show branch heads
732 help show help for a given topic or a help overview
732 help show help for a given topic or a help overview
733 identify identify the working directory or specified revision
733 identify identify the working directory or specified revision
734 import import an ordered set of patches
734 import import an ordered set of patches
735 incoming show new changesets found in source
735 incoming show new changesets found in source
736 init create a new repository in the given directory
736 init create a new repository in the given directory
737 log show revision history of entire repository or files
737 log show revision history of entire repository or files
738 manifest output the current or given revision of the project manifest
738 manifest output the current or given revision of the project manifest
739 merge merge another revision into working directory
739 merge merge another revision into working directory
740 outgoing show changesets not found in the destination
740 outgoing show changesets not found in the destination
741 paths show aliases for remote repositories
741 paths show aliases for remote repositories
742 phase set or show the current phase name
742 phase set or show the current phase name
743 pull pull changes from the specified source
743 pull pull changes from the specified source
744 push push changes to the specified destination
744 push push changes to the specified destination
745 recover roll back an interrupted transaction
745 recover roll back an interrupted transaction
746 remove remove the specified files on the next commit
746 remove remove the specified files on the next commit
747 rename rename files; equivalent of copy + remove
747 rename rename files; equivalent of copy + remove
748 resolve redo merges or set/view the merge status of files
748 resolve redo merges or set/view the merge status of files
749 revert restore files to their checkout state
749 revert restore files to their checkout state
750 root print the root (top) of the current working directory
750 root print the root (top) of the current working directory
751 serve start stand-alone webserver
751 serve start stand-alone webserver
752 status show changed files in the working directory
752 status show changed files in the working directory
753 summary summarize working directory state
753 summary summarize working directory state
754 tag add one or more tags for the current or given revision
754 tag add one or more tags for the current or given revision
755 tags list repository tags
755 tags list repository tags
756 unbundle apply one or more changegroup files
756 unbundle apply one or more changegroup files
757 update update working directory (or switch revisions)
757 update update working directory (or switch revisions)
758 verify verify the integrity of the repository
758 verify verify the integrity of the repository
759 version output version and copyright information
759 version output version and copyright information
760
760
761 enabled extensions:
761 enabled extensions:
762
762
763 helpext (no help text available)
763 helpext (no help text available)
764
764
765 additional help topics:
765 additional help topics:
766
766
767 config Configuration Files
767 config Configuration Files
768 dates Date Formats
768 dates Date Formats
769 diffs Diff Formats
769 diffs Diff Formats
770 environment Environment Variables
770 environment Environment Variables
771 extensions Using Additional Features
771 extensions Using Additional Features
772 filesets Specifying File Sets
772 filesets Specifying File Sets
773 glossary Glossary
773 glossary Glossary
774 hgignore Syntax for Mercurial Ignore Files
774 hgignore Syntax for Mercurial Ignore Files
775 hgweb Configuring hgweb
775 hgweb Configuring hgweb
776 merge-tools Merge Tools
776 merge-tools Merge Tools
777 multirevs Specifying Multiple Revisions
777 multirevs Specifying Multiple Revisions
778 patterns File Name Patterns
778 patterns File Name Patterns
779 phases Working with Phases
779 phases Working with Phases
780 revisions Specifying Single Revisions
780 revisions Specifying Single Revisions
781 revsets Specifying Revision Sets
781 revsets Specifying Revision Sets
782 scripting Using Mercurial from scripts and automation
782 scripting Using Mercurial from scripts and automation
783 subrepos Subrepositories
783 subrepos Subrepositories
784 templating Template Usage
784 templating Template Usage
785 urls URL Paths
785 urls URL Paths
786
786
787 (use "hg help -v" to show built-in aliases and global options)
787 (use "hg help -v" to show built-in aliases and global options)
788
788
789
789
790 Test list of internal help commands
790 Test list of internal help commands
791
791
792 $ hg help debug
792 $ hg help debug
793 debug commands (internal and unsupported):
793 debug commands (internal and unsupported):
794
794
795 debugancestor
795 debugancestor
796 find the ancestor revision of two revisions in a given index
796 find the ancestor revision of two revisions in a given index
797 debugapplystreamclonebundle
797 debugapplystreamclonebundle
798 apply a stream clone bundle file
798 apply a stream clone bundle file
799 debugbuilddag
799 debugbuilddag
800 builds a repo with a given DAG from scratch in the current
800 builds a repo with a given DAG from scratch in the current
801 empty repo
801 empty repo
802 debugbundle lists the contents of a bundle
802 debugbundle lists the contents of a bundle
803 debugcheckstate
803 debugcheckstate
804 validate the correctness of the current dirstate
804 validate the correctness of the current dirstate
805 debugcommands
805 debugcommands
806 list all available commands and options
806 list all available commands and options
807 debugcomplete
807 debugcomplete
808 returns the completion list associated with the given command
808 returns the completion list associated with the given command
809 debugcreatestreamclonebundle
809 debugcreatestreamclonebundle
810 create a stream clone bundle file
810 create a stream clone bundle file
811 debugdag format the changelog or an index DAG as a concise textual
811 debugdag format the changelog or an index DAG as a concise textual
812 description
812 description
813 debugdata dump the contents of a data file revision
813 debugdata dump the contents of a data file revision
814 debugdate parse and display a date
814 debugdate parse and display a date
815 debugdeltachain
816 dump information about delta chains in a revlog
815 debugdirstate
817 debugdirstate
816 show the contents of the current dirstate
818 show the contents of the current dirstate
817 debugdiscovery
819 debugdiscovery
818 runs the changeset discovery protocol in isolation
820 runs the changeset discovery protocol in isolation
819 debugextensions
821 debugextensions
820 show information about active extensions
822 show information about active extensions
821 debugfileset parse and apply a fileset specification
823 debugfileset parse and apply a fileset specification
822 debugfsinfo show information detected about current filesystem
824 debugfsinfo show information detected about current filesystem
823 debuggetbundle
825 debuggetbundle
824 retrieves a bundle from a repo
826 retrieves a bundle from a repo
825 debugignore display the combined ignore pattern
827 debugignore display the combined ignore pattern
826 debugindex dump the contents of an index file
828 debugindex dump the contents of an index file
827 debugindexdot
829 debugindexdot
828 dump an index DAG as a graphviz dot file
830 dump an index DAG as a graphviz dot file
829 debuginstall test Mercurial installation
831 debuginstall test Mercurial installation
830 debugknown test whether node ids are known to a repo
832 debugknown test whether node ids are known to a repo
831 debuglocks show or modify state of locks
833 debuglocks show or modify state of locks
832 debugmergestate
834 debugmergestate
833 print merge state
835 print merge state
834 debugnamecomplete
836 debugnamecomplete
835 complete "names" - tags, open branch names, bookmark names
837 complete "names" - tags, open branch names, bookmark names
836 debugobsolete
838 debugobsolete
837 create arbitrary obsolete marker
839 create arbitrary obsolete marker
838 debugoptDEP (no help text available)
840 debugoptDEP (no help text available)
839 debugoptEXP (no help text available)
841 debugoptEXP (no help text available)
840 debugpathcomplete
842 debugpathcomplete
841 complete part or all of a tracked path
843 complete part or all of a tracked path
842 debugpushkey access the pushkey key/value protocol
844 debugpushkey access the pushkey key/value protocol
843 debugpvec (no help text available)
845 debugpvec (no help text available)
844 debugrebuilddirstate
846 debugrebuilddirstate
845 rebuild the dirstate as it would look like for the given
847 rebuild the dirstate as it would look like for the given
846 revision
848 revision
847 debugrebuildfncache
849 debugrebuildfncache
848 rebuild the fncache file
850 rebuild the fncache file
849 debugrename dump rename information
851 debugrename dump rename information
850 debugrevlog show data and statistics about a revlog
852 debugrevlog show data and statistics about a revlog
851 debugrevspec parse and apply a revision specification
853 debugrevspec parse and apply a revision specification
852 debugsetparents
854 debugsetparents
853 manually set the parents of the current working directory
855 manually set the parents of the current working directory
854 debugsub (no help text available)
856 debugsub (no help text available)
855 debugsuccessorssets
857 debugsuccessorssets
856 show set of successors for revision
858 show set of successors for revision
857 debugwalk show how files match on given patterns
859 debugwalk show how files match on given patterns
858 debugwireargs
860 debugwireargs
859 (no help text available)
861 (no help text available)
860
862
861 (use "hg help -v debug" to show built-in aliases and global options)
863 (use "hg help -v debug" to show built-in aliases and global options)
862
864
863
865
864 Test list of commands with command with no help text
866 Test list of commands with command with no help text
865
867
866 $ hg help helpext
868 $ hg help helpext
867 helpext extension - no help text available
869 helpext extension - no help text available
868
870
869 list of commands:
871 list of commands:
870
872
871 nohelp (no help text available)
873 nohelp (no help text available)
872
874
873 (use "hg help -v helpext" to show built-in aliases and global options)
875 (use "hg help -v helpext" to show built-in aliases and global options)
874
876
875
877
876 test deprecated and experimental options are hidden in command help
878 test deprecated and experimental options are hidden in command help
877 $ hg help debugoptDEP
879 $ hg help debugoptDEP
878 hg debugoptDEP
880 hg debugoptDEP
879
881
880 (no help text available)
882 (no help text available)
881
883
882 options:
884 options:
883
885
884 (some details hidden, use --verbose to show complete help)
886 (some details hidden, use --verbose to show complete help)
885
887
886 $ hg help debugoptEXP
888 $ hg help debugoptEXP
887 hg debugoptEXP
889 hg debugoptEXP
888
890
889 (no help text available)
891 (no help text available)
890
892
891 options:
893 options:
892
894
893 (some details hidden, use --verbose to show complete help)
895 (some details hidden, use --verbose to show complete help)
894
896
895 test deprecated and experimental options is shown with -v
897 test deprecated and experimental options is shown with -v
896 $ hg help -v debugoptDEP | grep dopt
898 $ hg help -v debugoptDEP | grep dopt
897 --dopt option is (DEPRECATED)
899 --dopt option is (DEPRECATED)
898 $ hg help -v debugoptEXP | grep eopt
900 $ hg help -v debugoptEXP | grep eopt
899 --eopt option is (EXPERIMENTAL)
901 --eopt option is (EXPERIMENTAL)
900
902
901 #if gettext
903 #if gettext
902 test deprecated option is hidden with translation with untranslated description
904 test deprecated option is hidden with translation with untranslated description
903 (use many globy for not failing on changed transaction)
905 (use many globy for not failing on changed transaction)
904 $ LANGUAGE=sv hg help debugoptDEP
906 $ LANGUAGE=sv hg help debugoptDEP
905 hg debugoptDEP
907 hg debugoptDEP
906
908
907 (*) (glob)
909 (*) (glob)
908
910
909 options:
911 options:
910
912
911 (some details hidden, use --verbose to show complete help)
913 (some details hidden, use --verbose to show complete help)
912 #endif
914 #endif
913
915
914 Test commands that collide with topics (issue4240)
916 Test commands that collide with topics (issue4240)
915
917
916 $ hg config -hq
918 $ hg config -hq
917 hg config [-u] [NAME]...
919 hg config [-u] [NAME]...
918
920
919 show combined config settings from all hgrc files
921 show combined config settings from all hgrc files
920 $ hg showconfig -hq
922 $ hg showconfig -hq
921 hg config [-u] [NAME]...
923 hg config [-u] [NAME]...
922
924
923 show combined config settings from all hgrc files
925 show combined config settings from all hgrc files
924
926
925 Test a help topic
927 Test a help topic
926
928
927 $ hg help revs
929 $ hg help revs
928 Specifying Single Revisions
930 Specifying Single Revisions
929 """""""""""""""""""""""""""
931 """""""""""""""""""""""""""
930
932
931 Mercurial supports several ways to specify individual revisions.
933 Mercurial supports several ways to specify individual revisions.
932
934
933 A plain integer is treated as a revision number. Negative integers are
935 A plain integer is treated as a revision number. Negative integers are
934 treated as sequential offsets from the tip, with -1 denoting the tip, -2
936 treated as sequential offsets from the tip, with -1 denoting the tip, -2
935 denoting the revision prior to the tip, and so forth.
937 denoting the revision prior to the tip, and so forth.
936
938
937 A 40-digit hexadecimal string is treated as a unique revision identifier.
939 A 40-digit hexadecimal string is treated as a unique revision identifier.
938
940
939 A hexadecimal string less than 40 characters long is treated as a unique
941 A hexadecimal string less than 40 characters long is treated as a unique
940 revision identifier and is referred to as a short-form identifier. A
942 revision identifier and is referred to as a short-form identifier. A
941 short-form identifier is only valid if it is the prefix of exactly one
943 short-form identifier is only valid if it is the prefix of exactly one
942 full-length identifier.
944 full-length identifier.
943
945
944 Any other string is treated as a bookmark, tag, or branch name. A bookmark
946 Any other string is treated as a bookmark, tag, or branch name. A bookmark
945 is a movable pointer to a revision. A tag is a permanent name associated
947 is a movable pointer to a revision. A tag is a permanent name associated
946 with a revision. A branch name denotes the tipmost open branch head of
948 with a revision. A branch name denotes the tipmost open branch head of
947 that branch - or if they are all closed, the tipmost closed head of the
949 that branch - or if they are all closed, the tipmost closed head of the
948 branch. Bookmark, tag, and branch names must not contain the ":"
950 branch. Bookmark, tag, and branch names must not contain the ":"
949 character.
951 character.
950
952
951 The reserved name "tip" always identifies the most recent revision.
953 The reserved name "tip" always identifies the most recent revision.
952
954
953 The reserved name "null" indicates the null revision. This is the revision
955 The reserved name "null" indicates the null revision. This is the revision
954 of an empty repository, and the parent of revision 0.
956 of an empty repository, and the parent of revision 0.
955
957
956 The reserved name "." indicates the working directory parent. If no
958 The reserved name "." indicates the working directory parent. If no
957 working directory is checked out, it is equivalent to null. If an
959 working directory is checked out, it is equivalent to null. If an
958 uncommitted merge is in progress, "." is the revision of the first parent.
960 uncommitted merge is in progress, "." is the revision of the first parent.
959
961
960 Test repeated config section name
962 Test repeated config section name
961
963
962 $ hg help config.host
964 $ hg help config.host
963 "http_proxy.host"
965 "http_proxy.host"
964 Host name and (optional) port of the proxy server, for example
966 Host name and (optional) port of the proxy server, for example
965 "myproxy:8000".
967 "myproxy:8000".
966
968
967 "smtp.host"
969 "smtp.host"
968 Host name of mail server, e.g. "mail.example.com".
970 Host name of mail server, e.g. "mail.example.com".
969
971
970 Unrelated trailing paragraphs shouldn't be included
972 Unrelated trailing paragraphs shouldn't be included
971
973
972 $ hg help config.extramsg | grep '^$'
974 $ hg help config.extramsg | grep '^$'
973
975
974
976
975 Test capitalized section name
977 Test capitalized section name
976
978
977 $ hg help scripting.HGPLAIN > /dev/null
979 $ hg help scripting.HGPLAIN > /dev/null
978
980
979 Help subsection:
981 Help subsection:
980
982
981 $ hg help config.charsets |grep "Email example:" > /dev/null
983 $ hg help config.charsets |grep "Email example:" > /dev/null
982 [1]
984 [1]
983
985
984 Show nested definitions
986 Show nested definitions
985 ("profiling.type"[break]"ls"[break]"stat"[break])
987 ("profiling.type"[break]"ls"[break]"stat"[break])
986
988
987 $ hg help config.type | egrep '^$'|wc -l
989 $ hg help config.type | egrep '^$'|wc -l
988 \s*3 (re)
990 \s*3 (re)
989
991
990 Last item in help config.*:
992 Last item in help config.*:
991
993
992 $ hg help config.`hg help config|grep '^ "'| \
994 $ hg help config.`hg help config|grep '^ "'| \
993 > tail -1|sed 's![ "]*!!g'`| \
995 > tail -1|sed 's![ "]*!!g'`| \
994 > grep "hg help -c config" > /dev/null
996 > grep "hg help -c config" > /dev/null
995 [1]
997 [1]
996
998
997 note to use help -c for general hg help config:
999 note to use help -c for general hg help config:
998
1000
999 $ hg help config |grep "hg help -c config" > /dev/null
1001 $ hg help config |grep "hg help -c config" > /dev/null
1000
1002
1001 Test templating help
1003 Test templating help
1002
1004
1003 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1005 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1004 desc String. The text of the changeset description.
1006 desc String. The text of the changeset description.
1005 diffstat String. Statistics of changes with the following format:
1007 diffstat String. Statistics of changes with the following format:
1006 firstline Any text. Returns the first line of text.
1008 firstline Any text. Returns the first line of text.
1007 nonempty Any text. Returns '(none)' if the string is empty.
1009 nonempty Any text. Returns '(none)' if the string is empty.
1008
1010
1009 Test deprecated items
1011 Test deprecated items
1010
1012
1011 $ hg help -v templating | grep currentbookmark
1013 $ hg help -v templating | grep currentbookmark
1012 currentbookmark
1014 currentbookmark
1013 $ hg help templating | (grep currentbookmark || true)
1015 $ hg help templating | (grep currentbookmark || true)
1014
1016
1015 Test help hooks
1017 Test help hooks
1016
1018
1017 $ cat > helphook1.py <<EOF
1019 $ cat > helphook1.py <<EOF
1018 > from mercurial import help
1020 > from mercurial import help
1019 >
1021 >
1020 > def rewrite(ui, topic, doc):
1022 > def rewrite(ui, topic, doc):
1021 > return doc + '\nhelphook1\n'
1023 > return doc + '\nhelphook1\n'
1022 >
1024 >
1023 > def extsetup(ui):
1025 > def extsetup(ui):
1024 > help.addtopichook('revsets', rewrite)
1026 > help.addtopichook('revsets', rewrite)
1025 > EOF
1027 > EOF
1026 $ cat > helphook2.py <<EOF
1028 $ cat > helphook2.py <<EOF
1027 > from mercurial import help
1029 > from mercurial import help
1028 >
1030 >
1029 > def rewrite(ui, topic, doc):
1031 > def rewrite(ui, topic, doc):
1030 > return doc + '\nhelphook2\n'
1032 > return doc + '\nhelphook2\n'
1031 >
1033 >
1032 > def extsetup(ui):
1034 > def extsetup(ui):
1033 > help.addtopichook('revsets', rewrite)
1035 > help.addtopichook('revsets', rewrite)
1034 > EOF
1036 > EOF
1035 $ echo '[extensions]' >> $HGRCPATH
1037 $ echo '[extensions]' >> $HGRCPATH
1036 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1038 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1037 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1039 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1038 $ hg help revsets | grep helphook
1040 $ hg help revsets | grep helphook
1039 helphook1
1041 helphook1
1040 helphook2
1042 helphook2
1041
1043
1042 Test -e / -c / -k combinations
1044 Test -e / -c / -k combinations
1043
1045
1044 $ hg help -c schemes
1046 $ hg help -c schemes
1045 abort: no such help topic: schemes
1047 abort: no such help topic: schemes
1046 (try "hg help --keyword schemes")
1048 (try "hg help --keyword schemes")
1047 [255]
1049 [255]
1048 $ hg help -e schemes |head -1
1050 $ hg help -e schemes |head -1
1049 schemes extension - extend schemes with shortcuts to repository swarms
1051 schemes extension - extend schemes with shortcuts to repository swarms
1050 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1052 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1051 Commands:
1053 Commands:
1052 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1054 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1053 Extensions:
1055 Extensions:
1054 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1056 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1055 Extensions:
1057 Extensions:
1056 Commands:
1058 Commands:
1057 $ hg help -c commit > /dev/null
1059 $ hg help -c commit > /dev/null
1058 $ hg help -e -c commit > /dev/null
1060 $ hg help -e -c commit > /dev/null
1059 $ hg help -e commit > /dev/null
1061 $ hg help -e commit > /dev/null
1060 abort: no such help topic: commit
1062 abort: no such help topic: commit
1061 (try "hg help --keyword commit")
1063 (try "hg help --keyword commit")
1062 [255]
1064 [255]
1063
1065
1064 Test keyword search help
1066 Test keyword search help
1065
1067
1066 $ cat > prefixedname.py <<EOF
1068 $ cat > prefixedname.py <<EOF
1067 > '''matched against word "clone"
1069 > '''matched against word "clone"
1068 > '''
1070 > '''
1069 > EOF
1071 > EOF
1070 $ echo '[extensions]' >> $HGRCPATH
1072 $ echo '[extensions]' >> $HGRCPATH
1071 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1073 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1072 $ hg help -k clone
1074 $ hg help -k clone
1073 Topics:
1075 Topics:
1074
1076
1075 config Configuration Files
1077 config Configuration Files
1076 extensions Using Additional Features
1078 extensions Using Additional Features
1077 glossary Glossary
1079 glossary Glossary
1078 phases Working with Phases
1080 phases Working with Phases
1079 subrepos Subrepositories
1081 subrepos Subrepositories
1080 urls URL Paths
1082 urls URL Paths
1081
1083
1082 Commands:
1084 Commands:
1083
1085
1084 bookmarks create a new bookmark or list existing bookmarks
1086 bookmarks create a new bookmark or list existing bookmarks
1085 clone make a copy of an existing repository
1087 clone make a copy of an existing repository
1086 debugapplystreamclonebundle apply a stream clone bundle file
1088 debugapplystreamclonebundle apply a stream clone bundle file
1087 debugcreatestreamclonebundle create a stream clone bundle file
1089 debugcreatestreamclonebundle create a stream clone bundle file
1088 paths show aliases for remote repositories
1090 paths show aliases for remote repositories
1089 update update working directory (or switch revisions)
1091 update update working directory (or switch revisions)
1090
1092
1091 Extensions:
1093 Extensions:
1092
1094
1093 clonebundles advertise pre-generated bundles to seed clones (experimental)
1095 clonebundles advertise pre-generated bundles to seed clones (experimental)
1094 prefixedname matched against word "clone"
1096 prefixedname matched against word "clone"
1095 relink recreates hardlinks between repository clones
1097 relink recreates hardlinks between repository clones
1096
1098
1097 Extension Commands:
1099 Extension Commands:
1098
1100
1099 qclone clone main and patch repository at same time
1101 qclone clone main and patch repository at same time
1100
1102
1101 Test unfound topic
1103 Test unfound topic
1102
1104
1103 $ hg help nonexistingtopicthatwillneverexisteverever
1105 $ hg help nonexistingtopicthatwillneverexisteverever
1104 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1106 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1105 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1107 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1106 [255]
1108 [255]
1107
1109
1108 Test unfound keyword
1110 Test unfound keyword
1109
1111
1110 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1112 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1111 abort: no matches
1113 abort: no matches
1112 (try "hg help" for a list of topics)
1114 (try "hg help" for a list of topics)
1113 [255]
1115 [255]
1114
1116
1115 Test omit indicating for help
1117 Test omit indicating for help
1116
1118
1117 $ cat > addverboseitems.py <<EOF
1119 $ cat > addverboseitems.py <<EOF
1118 > '''extension to test omit indicating.
1120 > '''extension to test omit indicating.
1119 >
1121 >
1120 > This paragraph is never omitted (for extension)
1122 > This paragraph is never omitted (for extension)
1121 >
1123 >
1122 > .. container:: verbose
1124 > .. container:: verbose
1123 >
1125 >
1124 > This paragraph is omitted,
1126 > This paragraph is omitted,
1125 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1127 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1126 >
1128 >
1127 > This paragraph is never omitted, too (for extension)
1129 > This paragraph is never omitted, too (for extension)
1128 > '''
1130 > '''
1129 >
1131 >
1130 > from mercurial import help, commands
1132 > from mercurial import help, commands
1131 > testtopic = """This paragraph is never omitted (for topic).
1133 > testtopic = """This paragraph is never omitted (for topic).
1132 >
1134 >
1133 > .. container:: verbose
1135 > .. container:: verbose
1134 >
1136 >
1135 > This paragraph is omitted,
1137 > This paragraph is omitted,
1136 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1138 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1137 >
1139 >
1138 > This paragraph is never omitted, too (for topic)
1140 > This paragraph is never omitted, too (for topic)
1139 > """
1141 > """
1140 > def extsetup(ui):
1142 > def extsetup(ui):
1141 > help.helptable.append((["topic-containing-verbose"],
1143 > help.helptable.append((["topic-containing-verbose"],
1142 > "This is the topic to test omit indicating.",
1144 > "This is the topic to test omit indicating.",
1143 > lambda ui: testtopic))
1145 > lambda ui: testtopic))
1144 > EOF
1146 > EOF
1145 $ echo '[extensions]' >> $HGRCPATH
1147 $ echo '[extensions]' >> $HGRCPATH
1146 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1148 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1147 $ hg help addverboseitems
1149 $ hg help addverboseitems
1148 addverboseitems extension - extension to test omit indicating.
1150 addverboseitems extension - extension to test omit indicating.
1149
1151
1150 This paragraph is never omitted (for extension)
1152 This paragraph is never omitted (for extension)
1151
1153
1152 This paragraph is never omitted, too (for extension)
1154 This paragraph is never omitted, too (for extension)
1153
1155
1154 (some details hidden, use --verbose to show complete help)
1156 (some details hidden, use --verbose to show complete help)
1155
1157
1156 no commands defined
1158 no commands defined
1157 $ hg help -v addverboseitems
1159 $ hg help -v addverboseitems
1158 addverboseitems extension - extension to test omit indicating.
1160 addverboseitems extension - extension to test omit indicating.
1159
1161
1160 This paragraph is never omitted (for extension)
1162 This paragraph is never omitted (for extension)
1161
1163
1162 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1164 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1163 extension)
1165 extension)
1164
1166
1165 This paragraph is never omitted, too (for extension)
1167 This paragraph is never omitted, too (for extension)
1166
1168
1167 no commands defined
1169 no commands defined
1168 $ hg help topic-containing-verbose
1170 $ hg help topic-containing-verbose
1169 This is the topic to test omit indicating.
1171 This is the topic to test omit indicating.
1170 """"""""""""""""""""""""""""""""""""""""""
1172 """"""""""""""""""""""""""""""""""""""""""
1171
1173
1172 This paragraph is never omitted (for topic).
1174 This paragraph is never omitted (for topic).
1173
1175
1174 This paragraph is never omitted, too (for topic)
1176 This paragraph is never omitted, too (for topic)
1175
1177
1176 (some details hidden, use --verbose to show complete help)
1178 (some details hidden, use --verbose to show complete help)
1177 $ hg help -v topic-containing-verbose
1179 $ hg help -v topic-containing-verbose
1178 This is the topic to test omit indicating.
1180 This is the topic to test omit indicating.
1179 """"""""""""""""""""""""""""""""""""""""""
1181 """"""""""""""""""""""""""""""""""""""""""
1180
1182
1181 This paragraph is never omitted (for topic).
1183 This paragraph is never omitted (for topic).
1182
1184
1183 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1185 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1184 topic)
1186 topic)
1185
1187
1186 This paragraph is never omitted, too (for topic)
1188 This paragraph is never omitted, too (for topic)
1187
1189
1188 Test section lookup
1190 Test section lookup
1189
1191
1190 $ hg help revset.merge
1192 $ hg help revset.merge
1191 "merge()"
1193 "merge()"
1192 Changeset is a merge changeset.
1194 Changeset is a merge changeset.
1193
1195
1194 $ hg help glossary.dag
1196 $ hg help glossary.dag
1195 DAG
1197 DAG
1196 The repository of changesets of a distributed version control system
1198 The repository of changesets of a distributed version control system
1197 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1199 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1198 of nodes and edges, where nodes correspond to changesets and edges
1200 of nodes and edges, where nodes correspond to changesets and edges
1199 imply a parent -> child relation. This graph can be visualized by
1201 imply a parent -> child relation. This graph can be visualized by
1200 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1202 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1201 limited by the requirement for children to have at most two parents.
1203 limited by the requirement for children to have at most two parents.
1202
1204
1203
1205
1204 $ hg help hgrc.paths
1206 $ hg help hgrc.paths
1205 "paths"
1207 "paths"
1206 -------
1208 -------
1207
1209
1208 Assigns symbolic names to repositories. The left side is the symbolic
1210 Assigns symbolic names to repositories. The left side is the symbolic
1209 name, and the right gives the directory or URL that is the location of the
1211 name, and the right gives the directory or URL that is the location of the
1210 repository. Default paths can be declared by setting the following
1212 repository. Default paths can be declared by setting the following
1211 entries.
1213 entries.
1212
1214
1213 "default"
1215 "default"
1214 Directory or URL to use when pulling if no source is specified.
1216 Directory or URL to use when pulling if no source is specified.
1215 (default: repository from which the current repository was cloned)
1217 (default: repository from which the current repository was cloned)
1216
1218
1217 "default-push"
1219 "default-push"
1218 Optional. Directory or URL to use when pushing if no destination is
1220 Optional. Directory or URL to use when pushing if no destination is
1219 specified.
1221 specified.
1220
1222
1221 Custom paths can be defined by assigning the path to a name that later can
1223 Custom paths can be defined by assigning the path to a name that later can
1222 be used from the command line. Example:
1224 be used from the command line. Example:
1223
1225
1224 [paths]
1226 [paths]
1225 my_path = http://example.com/path
1227 my_path = http://example.com/path
1226
1228
1227 To push to the path defined in "my_path" run the command:
1229 To push to the path defined in "my_path" run the command:
1228
1230
1229 hg push my_path
1231 hg push my_path
1230
1232
1231 $ hg help glossary.mcguffin
1233 $ hg help glossary.mcguffin
1232 abort: help section not found
1234 abort: help section not found
1233 [255]
1235 [255]
1234
1236
1235 $ hg help glossary.mc.guffin
1237 $ hg help glossary.mc.guffin
1236 abort: help section not found
1238 abort: help section not found
1237 [255]
1239 [255]
1238
1240
1239 $ hg help template.files
1241 $ hg help template.files
1240 files List of strings. All files modified, added, or removed by
1242 files List of strings. All files modified, added, or removed by
1241 this changeset.
1243 this changeset.
1242
1244
1243 Test dynamic list of merge tools only shows up once
1245 Test dynamic list of merge tools only shows up once
1244 $ hg help merge-tools
1246 $ hg help merge-tools
1245 Merge Tools
1247 Merge Tools
1246 """""""""""
1248 """""""""""
1247
1249
1248 To merge files Mercurial uses merge tools.
1250 To merge files Mercurial uses merge tools.
1249
1251
1250 A merge tool combines two different versions of a file into a merged file.
1252 A merge tool combines two different versions of a file into a merged file.
1251 Merge tools are given the two files and the greatest common ancestor of
1253 Merge tools are given the two files and the greatest common ancestor of
1252 the two file versions, so they can determine the changes made on both
1254 the two file versions, so they can determine the changes made on both
1253 branches.
1255 branches.
1254
1256
1255 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1257 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1256 backout" and in several extensions.
1258 backout" and in several extensions.
1257
1259
1258 Usually, the merge tool tries to automatically reconcile the files by
1260 Usually, the merge tool tries to automatically reconcile the files by
1259 combining all non-overlapping changes that occurred separately in the two
1261 combining all non-overlapping changes that occurred separately in the two
1260 different evolutions of the same initial base file. Furthermore, some
1262 different evolutions of the same initial base file. Furthermore, some
1261 interactive merge programs make it easier to manually resolve conflicting
1263 interactive merge programs make it easier to manually resolve conflicting
1262 merges, either in a graphical way, or by inserting some conflict markers.
1264 merges, either in a graphical way, or by inserting some conflict markers.
1263 Mercurial does not include any interactive merge programs but relies on
1265 Mercurial does not include any interactive merge programs but relies on
1264 external tools for that.
1266 external tools for that.
1265
1267
1266 Available merge tools
1268 Available merge tools
1267 =====================
1269 =====================
1268
1270
1269 External merge tools and their properties are configured in the merge-
1271 External merge tools and their properties are configured in the merge-
1270 tools configuration section - see hgrc(5) - but they can often just be
1272 tools configuration section - see hgrc(5) - but they can often just be
1271 named by their executable.
1273 named by their executable.
1272
1274
1273 A merge tool is generally usable if its executable can be found on the
1275 A merge tool is generally usable if its executable can be found on the
1274 system and if it can handle the merge. The executable is found if it is an
1276 system and if it can handle the merge. The executable is found if it is an
1275 absolute or relative executable path or the name of an application in the
1277 absolute or relative executable path or the name of an application in the
1276 executable search path. The tool is assumed to be able to handle the merge
1278 executable search path. The tool is assumed to be able to handle the merge
1277 if it can handle symlinks if the file is a symlink, if it can handle
1279 if it can handle symlinks if the file is a symlink, if it can handle
1278 binary files if the file is binary, and if a GUI is available if the tool
1280 binary files if the file is binary, and if a GUI is available if the tool
1279 requires a GUI.
1281 requires a GUI.
1280
1282
1281 There are some internal merge tools which can be used. The internal merge
1283 There are some internal merge tools which can be used. The internal merge
1282 tools are:
1284 tools are:
1283
1285
1284 ":dump"
1286 ":dump"
1285 Creates three versions of the files to merge, containing the contents of
1287 Creates three versions of the files to merge, containing the contents of
1286 local, other and base. These files can then be used to perform a merge
1288 local, other and base. These files can then be used to perform a merge
1287 manually. If the file to be merged is named "a.txt", these files will
1289 manually. If the file to be merged is named "a.txt", these files will
1288 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1290 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1289 they will be placed in the same directory as "a.txt".
1291 they will be placed in the same directory as "a.txt".
1290
1292
1291 ":fail"
1293 ":fail"
1292 Rather than attempting to merge files that were modified on both
1294 Rather than attempting to merge files that were modified on both
1293 branches, it marks them as unresolved. The resolve command must be used
1295 branches, it marks them as unresolved. The resolve command must be used
1294 to resolve these conflicts.
1296 to resolve these conflicts.
1295
1297
1296 ":local"
1298 ":local"
1297 Uses the local version of files as the merged version.
1299 Uses the local version of files as the merged version.
1298
1300
1299 ":merge"
1301 ":merge"
1300 Uses the internal non-interactive simple merge algorithm for merging
1302 Uses the internal non-interactive simple merge algorithm for merging
1301 files. It will fail if there are any conflicts and leave markers in the
1303 files. It will fail if there are any conflicts and leave markers in the
1302 partially merged file. Markers will have two sections, one for each side
1304 partially merged file. Markers will have two sections, one for each side
1303 of merge.
1305 of merge.
1304
1306
1305 ":merge-local"
1307 ":merge-local"
1306 Like :merge, but resolve all conflicts non-interactively in favor of the
1308 Like :merge, but resolve all conflicts non-interactively in favor of the
1307 local changes.
1309 local changes.
1308
1310
1309 ":merge-other"
1311 ":merge-other"
1310 Like :merge, but resolve all conflicts non-interactively in favor of the
1312 Like :merge, but resolve all conflicts non-interactively in favor of the
1311 other changes.
1313 other changes.
1312
1314
1313 ":merge3"
1315 ":merge3"
1314 Uses the internal non-interactive simple merge algorithm for merging
1316 Uses the internal non-interactive simple merge algorithm for merging
1315 files. It will fail if there are any conflicts and leave markers in the
1317 files. It will fail if there are any conflicts and leave markers in the
1316 partially merged file. Marker will have three sections, one from each
1318 partially merged file. Marker will have three sections, one from each
1317 side of the merge and one for the base content.
1319 side of the merge and one for the base content.
1318
1320
1319 ":other"
1321 ":other"
1320 Uses the other version of files as the merged version.
1322 Uses the other version of files as the merged version.
1321
1323
1322 ":prompt"
1324 ":prompt"
1323 Asks the user which of the local or the other version to keep as the
1325 Asks the user which of the local or the other version to keep as the
1324 merged version.
1326 merged version.
1325
1327
1326 ":tagmerge"
1328 ":tagmerge"
1327 Uses the internal tag merge algorithm (experimental).
1329 Uses the internal tag merge algorithm (experimental).
1328
1330
1329 ":union"
1331 ":union"
1330 Uses the internal non-interactive simple merge algorithm for merging
1332 Uses the internal non-interactive simple merge algorithm for merging
1331 files. It will use both left and right sides for conflict regions. No
1333 files. It will use both left and right sides for conflict regions. No
1332 markers are inserted.
1334 markers are inserted.
1333
1335
1334 Internal tools are always available and do not require a GUI but will by
1336 Internal tools are always available and do not require a GUI but will by
1335 default not handle symlinks or binary files.
1337 default not handle symlinks or binary files.
1336
1338
1337 Choosing a merge tool
1339 Choosing a merge tool
1338 =====================
1340 =====================
1339
1341
1340 Mercurial uses these rules when deciding which merge tool to use:
1342 Mercurial uses these rules when deciding which merge tool to use:
1341
1343
1342 1. If a tool has been specified with the --tool option to merge or
1344 1. If a tool has been specified with the --tool option to merge or
1343 resolve, it is used. If it is the name of a tool in the merge-tools
1345 resolve, it is used. If it is the name of a tool in the merge-tools
1344 configuration, its configuration is used. Otherwise the specified tool
1346 configuration, its configuration is used. Otherwise the specified tool
1345 must be executable by the shell.
1347 must be executable by the shell.
1346 2. If the "HGMERGE" environment variable is present, its value is used and
1348 2. If the "HGMERGE" environment variable is present, its value is used and
1347 must be executable by the shell.
1349 must be executable by the shell.
1348 3. If the filename of the file to be merged matches any of the patterns in
1350 3. If the filename of the file to be merged matches any of the patterns in
1349 the merge-patterns configuration section, the first usable merge tool
1351 the merge-patterns configuration section, the first usable merge tool
1350 corresponding to a matching pattern is used. Here, binary capabilities
1352 corresponding to a matching pattern is used. Here, binary capabilities
1351 of the merge tool are not considered.
1353 of the merge tool are not considered.
1352 4. If ui.merge is set it will be considered next. If the value is not the
1354 4. If ui.merge is set it will be considered next. If the value is not the
1353 name of a configured tool, the specified value is used and must be
1355 name of a configured tool, the specified value is used and must be
1354 executable by the shell. Otherwise the named tool is used if it is
1356 executable by the shell. Otherwise the named tool is used if it is
1355 usable.
1357 usable.
1356 5. If any usable merge tools are present in the merge-tools configuration
1358 5. If any usable merge tools are present in the merge-tools configuration
1357 section, the one with the highest priority is used.
1359 section, the one with the highest priority is used.
1358 6. If a program named "hgmerge" can be found on the system, it is used -
1360 6. If a program named "hgmerge" can be found on the system, it is used -
1359 but it will by default not be used for symlinks and binary files.
1361 but it will by default not be used for symlinks and binary files.
1360 7. If the file to be merged is not binary and is not a symlink, then
1362 7. If the file to be merged is not binary and is not a symlink, then
1361 internal ":merge" is used.
1363 internal ":merge" is used.
1362 8. The merge of the file fails and must be resolved before commit.
1364 8. The merge of the file fails and must be resolved before commit.
1363
1365
1364 Note:
1366 Note:
1365 After selecting a merge program, Mercurial will by default attempt to
1367 After selecting a merge program, Mercurial will by default attempt to
1366 merge the files using a simple merge algorithm first. Only if it
1368 merge the files using a simple merge algorithm first. Only if it
1367 doesn't succeed because of conflicting changes Mercurial will actually
1369 doesn't succeed because of conflicting changes Mercurial will actually
1368 execute the merge program. Whether to use the simple merge algorithm
1370 execute the merge program. Whether to use the simple merge algorithm
1369 first can be controlled by the premerge setting of the merge tool.
1371 first can be controlled by the premerge setting of the merge tool.
1370 Premerge is enabled by default unless the file is binary or a symlink.
1372 Premerge is enabled by default unless the file is binary or a symlink.
1371
1373
1372 See the merge-tools and ui sections of hgrc(5) for details on the
1374 See the merge-tools and ui sections of hgrc(5) for details on the
1373 configuration of merge tools.
1375 configuration of merge tools.
1374
1376
1375 Test usage of section marks in help documents
1377 Test usage of section marks in help documents
1376
1378
1377 $ cd "$TESTDIR"/../doc
1379 $ cd "$TESTDIR"/../doc
1378 $ python check-seclevel.py
1380 $ python check-seclevel.py
1379 $ cd $TESTTMP
1381 $ cd $TESTTMP
1380
1382
1381 #if serve
1383 #if serve
1382
1384
1383 Test the help pages in hgweb.
1385 Test the help pages in hgweb.
1384
1386
1385 Dish up an empty repo; serve it cold.
1387 Dish up an empty repo; serve it cold.
1386
1388
1387 $ hg init "$TESTTMP/test"
1389 $ hg init "$TESTTMP/test"
1388 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1390 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1389 $ cat hg.pid >> $DAEMON_PIDS
1391 $ cat hg.pid >> $DAEMON_PIDS
1390
1392
1391 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1393 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1392 200 Script output follows
1394 200 Script output follows
1393
1395
1394 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1396 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1395 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1397 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1396 <head>
1398 <head>
1397 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1399 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1398 <meta name="robots" content="index, nofollow" />
1400 <meta name="robots" content="index, nofollow" />
1399 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1401 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1400 <script type="text/javascript" src="/static/mercurial.js"></script>
1402 <script type="text/javascript" src="/static/mercurial.js"></script>
1401
1403
1402 <title>Help: Index</title>
1404 <title>Help: Index</title>
1403 </head>
1405 </head>
1404 <body>
1406 <body>
1405
1407
1406 <div class="container">
1408 <div class="container">
1407 <div class="menu">
1409 <div class="menu">
1408 <div class="logo">
1410 <div class="logo">
1409 <a href="https://mercurial-scm.org/">
1411 <a href="https://mercurial-scm.org/">
1410 <img src="/static/hglogo.png" alt="mercurial" /></a>
1412 <img src="/static/hglogo.png" alt="mercurial" /></a>
1411 </div>
1413 </div>
1412 <ul>
1414 <ul>
1413 <li><a href="/shortlog">log</a></li>
1415 <li><a href="/shortlog">log</a></li>
1414 <li><a href="/graph">graph</a></li>
1416 <li><a href="/graph">graph</a></li>
1415 <li><a href="/tags">tags</a></li>
1417 <li><a href="/tags">tags</a></li>
1416 <li><a href="/bookmarks">bookmarks</a></li>
1418 <li><a href="/bookmarks">bookmarks</a></li>
1417 <li><a href="/branches">branches</a></li>
1419 <li><a href="/branches">branches</a></li>
1418 </ul>
1420 </ul>
1419 <ul>
1421 <ul>
1420 <li class="active">help</li>
1422 <li class="active">help</li>
1421 </ul>
1423 </ul>
1422 </div>
1424 </div>
1423
1425
1424 <div class="main">
1426 <div class="main">
1425 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1427 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1426 <form class="search" action="/log">
1428 <form class="search" action="/log">
1427
1429
1428 <p><input name="rev" id="search1" type="text" size="30" /></p>
1430 <p><input name="rev" id="search1" type="text" size="30" /></p>
1429 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1431 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1430 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1432 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1431 </form>
1433 </form>
1432 <table class="bigtable">
1434 <table class="bigtable">
1433 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1435 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1434
1436
1435 <tr><td>
1437 <tr><td>
1436 <a href="/help/config">
1438 <a href="/help/config">
1437 config
1439 config
1438 </a>
1440 </a>
1439 </td><td>
1441 </td><td>
1440 Configuration Files
1442 Configuration Files
1441 </td></tr>
1443 </td></tr>
1442 <tr><td>
1444 <tr><td>
1443 <a href="/help/dates">
1445 <a href="/help/dates">
1444 dates
1446 dates
1445 </a>
1447 </a>
1446 </td><td>
1448 </td><td>
1447 Date Formats
1449 Date Formats
1448 </td></tr>
1450 </td></tr>
1449 <tr><td>
1451 <tr><td>
1450 <a href="/help/diffs">
1452 <a href="/help/diffs">
1451 diffs
1453 diffs
1452 </a>
1454 </a>
1453 </td><td>
1455 </td><td>
1454 Diff Formats
1456 Diff Formats
1455 </td></tr>
1457 </td></tr>
1456 <tr><td>
1458 <tr><td>
1457 <a href="/help/environment">
1459 <a href="/help/environment">
1458 environment
1460 environment
1459 </a>
1461 </a>
1460 </td><td>
1462 </td><td>
1461 Environment Variables
1463 Environment Variables
1462 </td></tr>
1464 </td></tr>
1463 <tr><td>
1465 <tr><td>
1464 <a href="/help/extensions">
1466 <a href="/help/extensions">
1465 extensions
1467 extensions
1466 </a>
1468 </a>
1467 </td><td>
1469 </td><td>
1468 Using Additional Features
1470 Using Additional Features
1469 </td></tr>
1471 </td></tr>
1470 <tr><td>
1472 <tr><td>
1471 <a href="/help/filesets">
1473 <a href="/help/filesets">
1472 filesets
1474 filesets
1473 </a>
1475 </a>
1474 </td><td>
1476 </td><td>
1475 Specifying File Sets
1477 Specifying File Sets
1476 </td></tr>
1478 </td></tr>
1477 <tr><td>
1479 <tr><td>
1478 <a href="/help/glossary">
1480 <a href="/help/glossary">
1479 glossary
1481 glossary
1480 </a>
1482 </a>
1481 </td><td>
1483 </td><td>
1482 Glossary
1484 Glossary
1483 </td></tr>
1485 </td></tr>
1484 <tr><td>
1486 <tr><td>
1485 <a href="/help/hgignore">
1487 <a href="/help/hgignore">
1486 hgignore
1488 hgignore
1487 </a>
1489 </a>
1488 </td><td>
1490 </td><td>
1489 Syntax for Mercurial Ignore Files
1491 Syntax for Mercurial Ignore Files
1490 </td></tr>
1492 </td></tr>
1491 <tr><td>
1493 <tr><td>
1492 <a href="/help/hgweb">
1494 <a href="/help/hgweb">
1493 hgweb
1495 hgweb
1494 </a>
1496 </a>
1495 </td><td>
1497 </td><td>
1496 Configuring hgweb
1498 Configuring hgweb
1497 </td></tr>
1499 </td></tr>
1498 <tr><td>
1500 <tr><td>
1499 <a href="/help/merge-tools">
1501 <a href="/help/merge-tools">
1500 merge-tools
1502 merge-tools
1501 </a>
1503 </a>
1502 </td><td>
1504 </td><td>
1503 Merge Tools
1505 Merge Tools
1504 </td></tr>
1506 </td></tr>
1505 <tr><td>
1507 <tr><td>
1506 <a href="/help/multirevs">
1508 <a href="/help/multirevs">
1507 multirevs
1509 multirevs
1508 </a>
1510 </a>
1509 </td><td>
1511 </td><td>
1510 Specifying Multiple Revisions
1512 Specifying Multiple Revisions
1511 </td></tr>
1513 </td></tr>
1512 <tr><td>
1514 <tr><td>
1513 <a href="/help/patterns">
1515 <a href="/help/patterns">
1514 patterns
1516 patterns
1515 </a>
1517 </a>
1516 </td><td>
1518 </td><td>
1517 File Name Patterns
1519 File Name Patterns
1518 </td></tr>
1520 </td></tr>
1519 <tr><td>
1521 <tr><td>
1520 <a href="/help/phases">
1522 <a href="/help/phases">
1521 phases
1523 phases
1522 </a>
1524 </a>
1523 </td><td>
1525 </td><td>
1524 Working with Phases
1526 Working with Phases
1525 </td></tr>
1527 </td></tr>
1526 <tr><td>
1528 <tr><td>
1527 <a href="/help/revisions">
1529 <a href="/help/revisions">
1528 revisions
1530 revisions
1529 </a>
1531 </a>
1530 </td><td>
1532 </td><td>
1531 Specifying Single Revisions
1533 Specifying Single Revisions
1532 </td></tr>
1534 </td></tr>
1533 <tr><td>
1535 <tr><td>
1534 <a href="/help/revsets">
1536 <a href="/help/revsets">
1535 revsets
1537 revsets
1536 </a>
1538 </a>
1537 </td><td>
1539 </td><td>
1538 Specifying Revision Sets
1540 Specifying Revision Sets
1539 </td></tr>
1541 </td></tr>
1540 <tr><td>
1542 <tr><td>
1541 <a href="/help/scripting">
1543 <a href="/help/scripting">
1542 scripting
1544 scripting
1543 </a>
1545 </a>
1544 </td><td>
1546 </td><td>
1545 Using Mercurial from scripts and automation
1547 Using Mercurial from scripts and automation
1546 </td></tr>
1548 </td></tr>
1547 <tr><td>
1549 <tr><td>
1548 <a href="/help/subrepos">
1550 <a href="/help/subrepos">
1549 subrepos
1551 subrepos
1550 </a>
1552 </a>
1551 </td><td>
1553 </td><td>
1552 Subrepositories
1554 Subrepositories
1553 </td></tr>
1555 </td></tr>
1554 <tr><td>
1556 <tr><td>
1555 <a href="/help/templating">
1557 <a href="/help/templating">
1556 templating
1558 templating
1557 </a>
1559 </a>
1558 </td><td>
1560 </td><td>
1559 Template Usage
1561 Template Usage
1560 </td></tr>
1562 </td></tr>
1561 <tr><td>
1563 <tr><td>
1562 <a href="/help/urls">
1564 <a href="/help/urls">
1563 urls
1565 urls
1564 </a>
1566 </a>
1565 </td><td>
1567 </td><td>
1566 URL Paths
1568 URL Paths
1567 </td></tr>
1569 </td></tr>
1568 <tr><td>
1570 <tr><td>
1569 <a href="/help/topic-containing-verbose">
1571 <a href="/help/topic-containing-verbose">
1570 topic-containing-verbose
1572 topic-containing-verbose
1571 </a>
1573 </a>
1572 </td><td>
1574 </td><td>
1573 This is the topic to test omit indicating.
1575 This is the topic to test omit indicating.
1574 </td></tr>
1576 </td></tr>
1575
1577
1576 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1578 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1577
1579
1578 <tr><td>
1580 <tr><td>
1579 <a href="/help/add">
1581 <a href="/help/add">
1580 add
1582 add
1581 </a>
1583 </a>
1582 </td><td>
1584 </td><td>
1583 add the specified files on the next commit
1585 add the specified files on the next commit
1584 </td></tr>
1586 </td></tr>
1585 <tr><td>
1587 <tr><td>
1586 <a href="/help/annotate">
1588 <a href="/help/annotate">
1587 annotate
1589 annotate
1588 </a>
1590 </a>
1589 </td><td>
1591 </td><td>
1590 show changeset information by line for each file
1592 show changeset information by line for each file
1591 </td></tr>
1593 </td></tr>
1592 <tr><td>
1594 <tr><td>
1593 <a href="/help/clone">
1595 <a href="/help/clone">
1594 clone
1596 clone
1595 </a>
1597 </a>
1596 </td><td>
1598 </td><td>
1597 make a copy of an existing repository
1599 make a copy of an existing repository
1598 </td></tr>
1600 </td></tr>
1599 <tr><td>
1601 <tr><td>
1600 <a href="/help/commit">
1602 <a href="/help/commit">
1601 commit
1603 commit
1602 </a>
1604 </a>
1603 </td><td>
1605 </td><td>
1604 commit the specified files or all outstanding changes
1606 commit the specified files or all outstanding changes
1605 </td></tr>
1607 </td></tr>
1606 <tr><td>
1608 <tr><td>
1607 <a href="/help/diff">
1609 <a href="/help/diff">
1608 diff
1610 diff
1609 </a>
1611 </a>
1610 </td><td>
1612 </td><td>
1611 diff repository (or selected files)
1613 diff repository (or selected files)
1612 </td></tr>
1614 </td></tr>
1613 <tr><td>
1615 <tr><td>
1614 <a href="/help/export">
1616 <a href="/help/export">
1615 export
1617 export
1616 </a>
1618 </a>
1617 </td><td>
1619 </td><td>
1618 dump the header and diffs for one or more changesets
1620 dump the header and diffs for one or more changesets
1619 </td></tr>
1621 </td></tr>
1620 <tr><td>
1622 <tr><td>
1621 <a href="/help/forget">
1623 <a href="/help/forget">
1622 forget
1624 forget
1623 </a>
1625 </a>
1624 </td><td>
1626 </td><td>
1625 forget the specified files on the next commit
1627 forget the specified files on the next commit
1626 </td></tr>
1628 </td></tr>
1627 <tr><td>
1629 <tr><td>
1628 <a href="/help/init">
1630 <a href="/help/init">
1629 init
1631 init
1630 </a>
1632 </a>
1631 </td><td>
1633 </td><td>
1632 create a new repository in the given directory
1634 create a new repository in the given directory
1633 </td></tr>
1635 </td></tr>
1634 <tr><td>
1636 <tr><td>
1635 <a href="/help/log">
1637 <a href="/help/log">
1636 log
1638 log
1637 </a>
1639 </a>
1638 </td><td>
1640 </td><td>
1639 show revision history of entire repository or files
1641 show revision history of entire repository or files
1640 </td></tr>
1642 </td></tr>
1641 <tr><td>
1643 <tr><td>
1642 <a href="/help/merge">
1644 <a href="/help/merge">
1643 merge
1645 merge
1644 </a>
1646 </a>
1645 </td><td>
1647 </td><td>
1646 merge another revision into working directory
1648 merge another revision into working directory
1647 </td></tr>
1649 </td></tr>
1648 <tr><td>
1650 <tr><td>
1649 <a href="/help/pull">
1651 <a href="/help/pull">
1650 pull
1652 pull
1651 </a>
1653 </a>
1652 </td><td>
1654 </td><td>
1653 pull changes from the specified source
1655 pull changes from the specified source
1654 </td></tr>
1656 </td></tr>
1655 <tr><td>
1657 <tr><td>
1656 <a href="/help/push">
1658 <a href="/help/push">
1657 push
1659 push
1658 </a>
1660 </a>
1659 </td><td>
1661 </td><td>
1660 push changes to the specified destination
1662 push changes to the specified destination
1661 </td></tr>
1663 </td></tr>
1662 <tr><td>
1664 <tr><td>
1663 <a href="/help/remove">
1665 <a href="/help/remove">
1664 remove
1666 remove
1665 </a>
1667 </a>
1666 </td><td>
1668 </td><td>
1667 remove the specified files on the next commit
1669 remove the specified files on the next commit
1668 </td></tr>
1670 </td></tr>
1669 <tr><td>
1671 <tr><td>
1670 <a href="/help/serve">
1672 <a href="/help/serve">
1671 serve
1673 serve
1672 </a>
1674 </a>
1673 </td><td>
1675 </td><td>
1674 start stand-alone webserver
1676 start stand-alone webserver
1675 </td></tr>
1677 </td></tr>
1676 <tr><td>
1678 <tr><td>
1677 <a href="/help/status">
1679 <a href="/help/status">
1678 status
1680 status
1679 </a>
1681 </a>
1680 </td><td>
1682 </td><td>
1681 show changed files in the working directory
1683 show changed files in the working directory
1682 </td></tr>
1684 </td></tr>
1683 <tr><td>
1685 <tr><td>
1684 <a href="/help/summary">
1686 <a href="/help/summary">
1685 summary
1687 summary
1686 </a>
1688 </a>
1687 </td><td>
1689 </td><td>
1688 summarize working directory state
1690 summarize working directory state
1689 </td></tr>
1691 </td></tr>
1690 <tr><td>
1692 <tr><td>
1691 <a href="/help/update">
1693 <a href="/help/update">
1692 update
1694 update
1693 </a>
1695 </a>
1694 </td><td>
1696 </td><td>
1695 update working directory (or switch revisions)
1697 update working directory (or switch revisions)
1696 </td></tr>
1698 </td></tr>
1697
1699
1698 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1700 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1699
1701
1700 <tr><td>
1702 <tr><td>
1701 <a href="/help/addremove">
1703 <a href="/help/addremove">
1702 addremove
1704 addremove
1703 </a>
1705 </a>
1704 </td><td>
1706 </td><td>
1705 add all new files, delete all missing files
1707 add all new files, delete all missing files
1706 </td></tr>
1708 </td></tr>
1707 <tr><td>
1709 <tr><td>
1708 <a href="/help/archive">
1710 <a href="/help/archive">
1709 archive
1711 archive
1710 </a>
1712 </a>
1711 </td><td>
1713 </td><td>
1712 create an unversioned archive of a repository revision
1714 create an unversioned archive of a repository revision
1713 </td></tr>
1715 </td></tr>
1714 <tr><td>
1716 <tr><td>
1715 <a href="/help/backout">
1717 <a href="/help/backout">
1716 backout
1718 backout
1717 </a>
1719 </a>
1718 </td><td>
1720 </td><td>
1719 reverse effect of earlier changeset
1721 reverse effect of earlier changeset
1720 </td></tr>
1722 </td></tr>
1721 <tr><td>
1723 <tr><td>
1722 <a href="/help/bisect">
1724 <a href="/help/bisect">
1723 bisect
1725 bisect
1724 </a>
1726 </a>
1725 </td><td>
1727 </td><td>
1726 subdivision search of changesets
1728 subdivision search of changesets
1727 </td></tr>
1729 </td></tr>
1728 <tr><td>
1730 <tr><td>
1729 <a href="/help/bookmarks">
1731 <a href="/help/bookmarks">
1730 bookmarks
1732 bookmarks
1731 </a>
1733 </a>
1732 </td><td>
1734 </td><td>
1733 create a new bookmark or list existing bookmarks
1735 create a new bookmark or list existing bookmarks
1734 </td></tr>
1736 </td></tr>
1735 <tr><td>
1737 <tr><td>
1736 <a href="/help/branch">
1738 <a href="/help/branch">
1737 branch
1739 branch
1738 </a>
1740 </a>
1739 </td><td>
1741 </td><td>
1740 set or show the current branch name
1742 set or show the current branch name
1741 </td></tr>
1743 </td></tr>
1742 <tr><td>
1744 <tr><td>
1743 <a href="/help/branches">
1745 <a href="/help/branches">
1744 branches
1746 branches
1745 </a>
1747 </a>
1746 </td><td>
1748 </td><td>
1747 list repository named branches
1749 list repository named branches
1748 </td></tr>
1750 </td></tr>
1749 <tr><td>
1751 <tr><td>
1750 <a href="/help/bundle">
1752 <a href="/help/bundle">
1751 bundle
1753 bundle
1752 </a>
1754 </a>
1753 </td><td>
1755 </td><td>
1754 create a changegroup file
1756 create a changegroup file
1755 </td></tr>
1757 </td></tr>
1756 <tr><td>
1758 <tr><td>
1757 <a href="/help/cat">
1759 <a href="/help/cat">
1758 cat
1760 cat
1759 </a>
1761 </a>
1760 </td><td>
1762 </td><td>
1761 output the current or given revision of files
1763 output the current or given revision of files
1762 </td></tr>
1764 </td></tr>
1763 <tr><td>
1765 <tr><td>
1764 <a href="/help/config">
1766 <a href="/help/config">
1765 config
1767 config
1766 </a>
1768 </a>
1767 </td><td>
1769 </td><td>
1768 show combined config settings from all hgrc files
1770 show combined config settings from all hgrc files
1769 </td></tr>
1771 </td></tr>
1770 <tr><td>
1772 <tr><td>
1771 <a href="/help/copy">
1773 <a href="/help/copy">
1772 copy
1774 copy
1773 </a>
1775 </a>
1774 </td><td>
1776 </td><td>
1775 mark files as copied for the next commit
1777 mark files as copied for the next commit
1776 </td></tr>
1778 </td></tr>
1777 <tr><td>
1779 <tr><td>
1778 <a href="/help/files">
1780 <a href="/help/files">
1779 files
1781 files
1780 </a>
1782 </a>
1781 </td><td>
1783 </td><td>
1782 list tracked files
1784 list tracked files
1783 </td></tr>
1785 </td></tr>
1784 <tr><td>
1786 <tr><td>
1785 <a href="/help/graft">
1787 <a href="/help/graft">
1786 graft
1788 graft
1787 </a>
1789 </a>
1788 </td><td>
1790 </td><td>
1789 copy changes from other branches onto the current branch
1791 copy changes from other branches onto the current branch
1790 </td></tr>
1792 </td></tr>
1791 <tr><td>
1793 <tr><td>
1792 <a href="/help/grep">
1794 <a href="/help/grep">
1793 grep
1795 grep
1794 </a>
1796 </a>
1795 </td><td>
1797 </td><td>
1796 search for a pattern in specified files and revisions
1798 search for a pattern in specified files and revisions
1797 </td></tr>
1799 </td></tr>
1798 <tr><td>
1800 <tr><td>
1799 <a href="/help/heads">
1801 <a href="/help/heads">
1800 heads
1802 heads
1801 </a>
1803 </a>
1802 </td><td>
1804 </td><td>
1803 show branch heads
1805 show branch heads
1804 </td></tr>
1806 </td></tr>
1805 <tr><td>
1807 <tr><td>
1806 <a href="/help/help">
1808 <a href="/help/help">
1807 help
1809 help
1808 </a>
1810 </a>
1809 </td><td>
1811 </td><td>
1810 show help for a given topic or a help overview
1812 show help for a given topic or a help overview
1811 </td></tr>
1813 </td></tr>
1812 <tr><td>
1814 <tr><td>
1813 <a href="/help/identify">
1815 <a href="/help/identify">
1814 identify
1816 identify
1815 </a>
1817 </a>
1816 </td><td>
1818 </td><td>
1817 identify the working directory or specified revision
1819 identify the working directory or specified revision
1818 </td></tr>
1820 </td></tr>
1819 <tr><td>
1821 <tr><td>
1820 <a href="/help/import">
1822 <a href="/help/import">
1821 import
1823 import
1822 </a>
1824 </a>
1823 </td><td>
1825 </td><td>
1824 import an ordered set of patches
1826 import an ordered set of patches
1825 </td></tr>
1827 </td></tr>
1826 <tr><td>
1828 <tr><td>
1827 <a href="/help/incoming">
1829 <a href="/help/incoming">
1828 incoming
1830 incoming
1829 </a>
1831 </a>
1830 </td><td>
1832 </td><td>
1831 show new changesets found in source
1833 show new changesets found in source
1832 </td></tr>
1834 </td></tr>
1833 <tr><td>
1835 <tr><td>
1834 <a href="/help/manifest">
1836 <a href="/help/manifest">
1835 manifest
1837 manifest
1836 </a>
1838 </a>
1837 </td><td>
1839 </td><td>
1838 output the current or given revision of the project manifest
1840 output the current or given revision of the project manifest
1839 </td></tr>
1841 </td></tr>
1840 <tr><td>
1842 <tr><td>
1841 <a href="/help/nohelp">
1843 <a href="/help/nohelp">
1842 nohelp
1844 nohelp
1843 </a>
1845 </a>
1844 </td><td>
1846 </td><td>
1845 (no help text available)
1847 (no help text available)
1846 </td></tr>
1848 </td></tr>
1847 <tr><td>
1849 <tr><td>
1848 <a href="/help/outgoing">
1850 <a href="/help/outgoing">
1849 outgoing
1851 outgoing
1850 </a>
1852 </a>
1851 </td><td>
1853 </td><td>
1852 show changesets not found in the destination
1854 show changesets not found in the destination
1853 </td></tr>
1855 </td></tr>
1854 <tr><td>
1856 <tr><td>
1855 <a href="/help/paths">
1857 <a href="/help/paths">
1856 paths
1858 paths
1857 </a>
1859 </a>
1858 </td><td>
1860 </td><td>
1859 show aliases for remote repositories
1861 show aliases for remote repositories
1860 </td></tr>
1862 </td></tr>
1861 <tr><td>
1863 <tr><td>
1862 <a href="/help/phase">
1864 <a href="/help/phase">
1863 phase
1865 phase
1864 </a>
1866 </a>
1865 </td><td>
1867 </td><td>
1866 set or show the current phase name
1868 set or show the current phase name
1867 </td></tr>
1869 </td></tr>
1868 <tr><td>
1870 <tr><td>
1869 <a href="/help/recover">
1871 <a href="/help/recover">
1870 recover
1872 recover
1871 </a>
1873 </a>
1872 </td><td>
1874 </td><td>
1873 roll back an interrupted transaction
1875 roll back an interrupted transaction
1874 </td></tr>
1876 </td></tr>
1875 <tr><td>
1877 <tr><td>
1876 <a href="/help/rename">
1878 <a href="/help/rename">
1877 rename
1879 rename
1878 </a>
1880 </a>
1879 </td><td>
1881 </td><td>
1880 rename files; equivalent of copy + remove
1882 rename files; equivalent of copy + remove
1881 </td></tr>
1883 </td></tr>
1882 <tr><td>
1884 <tr><td>
1883 <a href="/help/resolve">
1885 <a href="/help/resolve">
1884 resolve
1886 resolve
1885 </a>
1887 </a>
1886 </td><td>
1888 </td><td>
1887 redo merges or set/view the merge status of files
1889 redo merges or set/view the merge status of files
1888 </td></tr>
1890 </td></tr>
1889 <tr><td>
1891 <tr><td>
1890 <a href="/help/revert">
1892 <a href="/help/revert">
1891 revert
1893 revert
1892 </a>
1894 </a>
1893 </td><td>
1895 </td><td>
1894 restore files to their checkout state
1896 restore files to their checkout state
1895 </td></tr>
1897 </td></tr>
1896 <tr><td>
1898 <tr><td>
1897 <a href="/help/root">
1899 <a href="/help/root">
1898 root
1900 root
1899 </a>
1901 </a>
1900 </td><td>
1902 </td><td>
1901 print the root (top) of the current working directory
1903 print the root (top) of the current working directory
1902 </td></tr>
1904 </td></tr>
1903 <tr><td>
1905 <tr><td>
1904 <a href="/help/tag">
1906 <a href="/help/tag">
1905 tag
1907 tag
1906 </a>
1908 </a>
1907 </td><td>
1909 </td><td>
1908 add one or more tags for the current or given revision
1910 add one or more tags for the current or given revision
1909 </td></tr>
1911 </td></tr>
1910 <tr><td>
1912 <tr><td>
1911 <a href="/help/tags">
1913 <a href="/help/tags">
1912 tags
1914 tags
1913 </a>
1915 </a>
1914 </td><td>
1916 </td><td>
1915 list repository tags
1917 list repository tags
1916 </td></tr>
1918 </td></tr>
1917 <tr><td>
1919 <tr><td>
1918 <a href="/help/unbundle">
1920 <a href="/help/unbundle">
1919 unbundle
1921 unbundle
1920 </a>
1922 </a>
1921 </td><td>
1923 </td><td>
1922 apply one or more changegroup files
1924 apply one or more changegroup files
1923 </td></tr>
1925 </td></tr>
1924 <tr><td>
1926 <tr><td>
1925 <a href="/help/verify">
1927 <a href="/help/verify">
1926 verify
1928 verify
1927 </a>
1929 </a>
1928 </td><td>
1930 </td><td>
1929 verify the integrity of the repository
1931 verify the integrity of the repository
1930 </td></tr>
1932 </td></tr>
1931 <tr><td>
1933 <tr><td>
1932 <a href="/help/version">
1934 <a href="/help/version">
1933 version
1935 version
1934 </a>
1936 </a>
1935 </td><td>
1937 </td><td>
1936 output version and copyright information
1938 output version and copyright information
1937 </td></tr>
1939 </td></tr>
1938 </table>
1940 </table>
1939 </div>
1941 </div>
1940 </div>
1942 </div>
1941
1943
1942 <script type="text/javascript">process_dates()</script>
1944 <script type="text/javascript">process_dates()</script>
1943
1945
1944
1946
1945 </body>
1947 </body>
1946 </html>
1948 </html>
1947
1949
1948
1950
1949 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1951 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1950 200 Script output follows
1952 200 Script output follows
1951
1953
1952 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1954 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1953 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1955 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1954 <head>
1956 <head>
1955 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1957 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1956 <meta name="robots" content="index, nofollow" />
1958 <meta name="robots" content="index, nofollow" />
1957 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1959 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1958 <script type="text/javascript" src="/static/mercurial.js"></script>
1960 <script type="text/javascript" src="/static/mercurial.js"></script>
1959
1961
1960 <title>Help: add</title>
1962 <title>Help: add</title>
1961 </head>
1963 </head>
1962 <body>
1964 <body>
1963
1965
1964 <div class="container">
1966 <div class="container">
1965 <div class="menu">
1967 <div class="menu">
1966 <div class="logo">
1968 <div class="logo">
1967 <a href="https://mercurial-scm.org/">
1969 <a href="https://mercurial-scm.org/">
1968 <img src="/static/hglogo.png" alt="mercurial" /></a>
1970 <img src="/static/hglogo.png" alt="mercurial" /></a>
1969 </div>
1971 </div>
1970 <ul>
1972 <ul>
1971 <li><a href="/shortlog">log</a></li>
1973 <li><a href="/shortlog">log</a></li>
1972 <li><a href="/graph">graph</a></li>
1974 <li><a href="/graph">graph</a></li>
1973 <li><a href="/tags">tags</a></li>
1975 <li><a href="/tags">tags</a></li>
1974 <li><a href="/bookmarks">bookmarks</a></li>
1976 <li><a href="/bookmarks">bookmarks</a></li>
1975 <li><a href="/branches">branches</a></li>
1977 <li><a href="/branches">branches</a></li>
1976 </ul>
1978 </ul>
1977 <ul>
1979 <ul>
1978 <li class="active"><a href="/help">help</a></li>
1980 <li class="active"><a href="/help">help</a></li>
1979 </ul>
1981 </ul>
1980 </div>
1982 </div>
1981
1983
1982 <div class="main">
1984 <div class="main">
1983 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1985 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1984 <h3>Help: add</h3>
1986 <h3>Help: add</h3>
1985
1987
1986 <form class="search" action="/log">
1988 <form class="search" action="/log">
1987
1989
1988 <p><input name="rev" id="search1" type="text" size="30" /></p>
1990 <p><input name="rev" id="search1" type="text" size="30" /></p>
1989 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1991 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1990 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1992 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1991 </form>
1993 </form>
1992 <div id="doc">
1994 <div id="doc">
1993 <p>
1995 <p>
1994 hg add [OPTION]... [FILE]...
1996 hg add [OPTION]... [FILE]...
1995 </p>
1997 </p>
1996 <p>
1998 <p>
1997 add the specified files on the next commit
1999 add the specified files on the next commit
1998 </p>
2000 </p>
1999 <p>
2001 <p>
2000 Schedule files to be version controlled and added to the
2002 Schedule files to be version controlled and added to the
2001 repository.
2003 repository.
2002 </p>
2004 </p>
2003 <p>
2005 <p>
2004 The files will be added to the repository at the next commit. To
2006 The files will be added to the repository at the next commit. To
2005 undo an add before that, see &quot;hg forget&quot;.
2007 undo an add before that, see &quot;hg forget&quot;.
2006 </p>
2008 </p>
2007 <p>
2009 <p>
2008 If no names are given, add all files to the repository.
2010 If no names are given, add all files to the repository.
2009 </p>
2011 </p>
2010 <p>
2012 <p>
2011 Examples:
2013 Examples:
2012 </p>
2014 </p>
2013 <ul>
2015 <ul>
2014 <li> New (unknown) files are added automatically by &quot;hg add&quot;:
2016 <li> New (unknown) files are added automatically by &quot;hg add&quot;:
2015 <pre>
2017 <pre>
2016 \$ ls (re)
2018 \$ ls (re)
2017 foo.c
2019 foo.c
2018 \$ hg status (re)
2020 \$ hg status (re)
2019 ? foo.c
2021 ? foo.c
2020 \$ hg add (re)
2022 \$ hg add (re)
2021 adding foo.c
2023 adding foo.c
2022 \$ hg status (re)
2024 \$ hg status (re)
2023 A foo.c
2025 A foo.c
2024 </pre>
2026 </pre>
2025 <li> Specific files to be added can be specified:
2027 <li> Specific files to be added can be specified:
2026 <pre>
2028 <pre>
2027 \$ ls (re)
2029 \$ ls (re)
2028 bar.c foo.c
2030 bar.c foo.c
2029 \$ hg status (re)
2031 \$ hg status (re)
2030 ? bar.c
2032 ? bar.c
2031 ? foo.c
2033 ? foo.c
2032 \$ hg add bar.c (re)
2034 \$ hg add bar.c (re)
2033 \$ hg status (re)
2035 \$ hg status (re)
2034 A bar.c
2036 A bar.c
2035 ? foo.c
2037 ? foo.c
2036 </pre>
2038 </pre>
2037 </ul>
2039 </ul>
2038 <p>
2040 <p>
2039 Returns 0 if all files are successfully added.
2041 Returns 0 if all files are successfully added.
2040 </p>
2042 </p>
2041 <p>
2043 <p>
2042 options ([+] can be repeated):
2044 options ([+] can be repeated):
2043 </p>
2045 </p>
2044 <table>
2046 <table>
2045 <tr><td>-I</td>
2047 <tr><td>-I</td>
2046 <td>--include PATTERN [+]</td>
2048 <td>--include PATTERN [+]</td>
2047 <td>include names matching the given patterns</td></tr>
2049 <td>include names matching the given patterns</td></tr>
2048 <tr><td>-X</td>
2050 <tr><td>-X</td>
2049 <td>--exclude PATTERN [+]</td>
2051 <td>--exclude PATTERN [+]</td>
2050 <td>exclude names matching the given patterns</td></tr>
2052 <td>exclude names matching the given patterns</td></tr>
2051 <tr><td>-S</td>
2053 <tr><td>-S</td>
2052 <td>--subrepos</td>
2054 <td>--subrepos</td>
2053 <td>recurse into subrepositories</td></tr>
2055 <td>recurse into subrepositories</td></tr>
2054 <tr><td>-n</td>
2056 <tr><td>-n</td>
2055 <td>--dry-run</td>
2057 <td>--dry-run</td>
2056 <td>do not perform actions, just print output</td></tr>
2058 <td>do not perform actions, just print output</td></tr>
2057 </table>
2059 </table>
2058 <p>
2060 <p>
2059 global options ([+] can be repeated):
2061 global options ([+] can be repeated):
2060 </p>
2062 </p>
2061 <table>
2063 <table>
2062 <tr><td>-R</td>
2064 <tr><td>-R</td>
2063 <td>--repository REPO</td>
2065 <td>--repository REPO</td>
2064 <td>repository root directory or name of overlay bundle file</td></tr>
2066 <td>repository root directory or name of overlay bundle file</td></tr>
2065 <tr><td></td>
2067 <tr><td></td>
2066 <td>--cwd DIR</td>
2068 <td>--cwd DIR</td>
2067 <td>change working directory</td></tr>
2069 <td>change working directory</td></tr>
2068 <tr><td>-y</td>
2070 <tr><td>-y</td>
2069 <td>--noninteractive</td>
2071 <td>--noninteractive</td>
2070 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2072 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2071 <tr><td>-q</td>
2073 <tr><td>-q</td>
2072 <td>--quiet</td>
2074 <td>--quiet</td>
2073 <td>suppress output</td></tr>
2075 <td>suppress output</td></tr>
2074 <tr><td>-v</td>
2076 <tr><td>-v</td>
2075 <td>--verbose</td>
2077 <td>--verbose</td>
2076 <td>enable additional output</td></tr>
2078 <td>enable additional output</td></tr>
2077 <tr><td></td>
2079 <tr><td></td>
2078 <td>--config CONFIG [+]</td>
2080 <td>--config CONFIG [+]</td>
2079 <td>set/override config option (use 'section.name=value')</td></tr>
2081 <td>set/override config option (use 'section.name=value')</td></tr>
2080 <tr><td></td>
2082 <tr><td></td>
2081 <td>--debug</td>
2083 <td>--debug</td>
2082 <td>enable debugging output</td></tr>
2084 <td>enable debugging output</td></tr>
2083 <tr><td></td>
2085 <tr><td></td>
2084 <td>--debugger</td>
2086 <td>--debugger</td>
2085 <td>start debugger</td></tr>
2087 <td>start debugger</td></tr>
2086 <tr><td></td>
2088 <tr><td></td>
2087 <td>--encoding ENCODE</td>
2089 <td>--encoding ENCODE</td>
2088 <td>set the charset encoding (default: ascii)</td></tr>
2090 <td>set the charset encoding (default: ascii)</td></tr>
2089 <tr><td></td>
2091 <tr><td></td>
2090 <td>--encodingmode MODE</td>
2092 <td>--encodingmode MODE</td>
2091 <td>set the charset encoding mode (default: strict)</td></tr>
2093 <td>set the charset encoding mode (default: strict)</td></tr>
2092 <tr><td></td>
2094 <tr><td></td>
2093 <td>--traceback</td>
2095 <td>--traceback</td>
2094 <td>always print a traceback on exception</td></tr>
2096 <td>always print a traceback on exception</td></tr>
2095 <tr><td></td>
2097 <tr><td></td>
2096 <td>--time</td>
2098 <td>--time</td>
2097 <td>time how long the command takes</td></tr>
2099 <td>time how long the command takes</td></tr>
2098 <tr><td></td>
2100 <tr><td></td>
2099 <td>--profile</td>
2101 <td>--profile</td>
2100 <td>print command execution profile</td></tr>
2102 <td>print command execution profile</td></tr>
2101 <tr><td></td>
2103 <tr><td></td>
2102 <td>--version</td>
2104 <td>--version</td>
2103 <td>output version information and exit</td></tr>
2105 <td>output version information and exit</td></tr>
2104 <tr><td>-h</td>
2106 <tr><td>-h</td>
2105 <td>--help</td>
2107 <td>--help</td>
2106 <td>display help and exit</td></tr>
2108 <td>display help and exit</td></tr>
2107 <tr><td></td>
2109 <tr><td></td>
2108 <td>--hidden</td>
2110 <td>--hidden</td>
2109 <td>consider hidden changesets</td></tr>
2111 <td>consider hidden changesets</td></tr>
2110 </table>
2112 </table>
2111
2113
2112 </div>
2114 </div>
2113 </div>
2115 </div>
2114 </div>
2116 </div>
2115
2117
2116 <script type="text/javascript">process_dates()</script>
2118 <script type="text/javascript">process_dates()</script>
2117
2119
2118
2120
2119 </body>
2121 </body>
2120 </html>
2122 </html>
2121
2123
2122
2124
2123 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2125 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2124 200 Script output follows
2126 200 Script output follows
2125
2127
2126 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2128 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2127 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2129 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2128 <head>
2130 <head>
2129 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2131 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2130 <meta name="robots" content="index, nofollow" />
2132 <meta name="robots" content="index, nofollow" />
2131 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2133 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2132 <script type="text/javascript" src="/static/mercurial.js"></script>
2134 <script type="text/javascript" src="/static/mercurial.js"></script>
2133
2135
2134 <title>Help: remove</title>
2136 <title>Help: remove</title>
2135 </head>
2137 </head>
2136 <body>
2138 <body>
2137
2139
2138 <div class="container">
2140 <div class="container">
2139 <div class="menu">
2141 <div class="menu">
2140 <div class="logo">
2142 <div class="logo">
2141 <a href="https://mercurial-scm.org/">
2143 <a href="https://mercurial-scm.org/">
2142 <img src="/static/hglogo.png" alt="mercurial" /></a>
2144 <img src="/static/hglogo.png" alt="mercurial" /></a>
2143 </div>
2145 </div>
2144 <ul>
2146 <ul>
2145 <li><a href="/shortlog">log</a></li>
2147 <li><a href="/shortlog">log</a></li>
2146 <li><a href="/graph">graph</a></li>
2148 <li><a href="/graph">graph</a></li>
2147 <li><a href="/tags">tags</a></li>
2149 <li><a href="/tags">tags</a></li>
2148 <li><a href="/bookmarks">bookmarks</a></li>
2150 <li><a href="/bookmarks">bookmarks</a></li>
2149 <li><a href="/branches">branches</a></li>
2151 <li><a href="/branches">branches</a></li>
2150 </ul>
2152 </ul>
2151 <ul>
2153 <ul>
2152 <li class="active"><a href="/help">help</a></li>
2154 <li class="active"><a href="/help">help</a></li>
2153 </ul>
2155 </ul>
2154 </div>
2156 </div>
2155
2157
2156 <div class="main">
2158 <div class="main">
2157 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2159 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2158 <h3>Help: remove</h3>
2160 <h3>Help: remove</h3>
2159
2161
2160 <form class="search" action="/log">
2162 <form class="search" action="/log">
2161
2163
2162 <p><input name="rev" id="search1" type="text" size="30" /></p>
2164 <p><input name="rev" id="search1" type="text" size="30" /></p>
2163 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2165 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2164 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2166 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2165 </form>
2167 </form>
2166 <div id="doc">
2168 <div id="doc">
2167 <p>
2169 <p>
2168 hg remove [OPTION]... FILE...
2170 hg remove [OPTION]... FILE...
2169 </p>
2171 </p>
2170 <p>
2172 <p>
2171 aliases: rm
2173 aliases: rm
2172 </p>
2174 </p>
2173 <p>
2175 <p>
2174 remove the specified files on the next commit
2176 remove the specified files on the next commit
2175 </p>
2177 </p>
2176 <p>
2178 <p>
2177 Schedule the indicated files for removal from the current branch.
2179 Schedule the indicated files for removal from the current branch.
2178 </p>
2180 </p>
2179 <p>
2181 <p>
2180 This command schedules the files to be removed at the next commit.
2182 This command schedules the files to be removed at the next commit.
2181 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2183 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2182 files, see &quot;hg forget&quot;.
2184 files, see &quot;hg forget&quot;.
2183 </p>
2185 </p>
2184 <p>
2186 <p>
2185 -A/--after can be used to remove only files that have already
2187 -A/--after can be used to remove only files that have already
2186 been deleted, -f/--force can be used to force deletion, and -Af
2188 been deleted, -f/--force can be used to force deletion, and -Af
2187 can be used to remove files from the next revision without
2189 can be used to remove files from the next revision without
2188 deleting them from the working directory.
2190 deleting them from the working directory.
2189 </p>
2191 </p>
2190 <p>
2192 <p>
2191 The following table details the behavior of remove for different
2193 The following table details the behavior of remove for different
2192 file states (columns) and option combinations (rows). The file
2194 file states (columns) and option combinations (rows). The file
2193 states are Added [A], Clean [C], Modified [M] and Missing [!]
2195 states are Added [A], Clean [C], Modified [M] and Missing [!]
2194 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2196 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2195 (from branch) and Delete (from disk):
2197 (from branch) and Delete (from disk):
2196 </p>
2198 </p>
2197 <table>
2199 <table>
2198 <tr><td>opt/state</td>
2200 <tr><td>opt/state</td>
2199 <td>A</td>
2201 <td>A</td>
2200 <td>C</td>
2202 <td>C</td>
2201 <td>M</td>
2203 <td>M</td>
2202 <td>!</td></tr>
2204 <td>!</td></tr>
2203 <tr><td>none</td>
2205 <tr><td>none</td>
2204 <td>W</td>
2206 <td>W</td>
2205 <td>RD</td>
2207 <td>RD</td>
2206 <td>W</td>
2208 <td>W</td>
2207 <td>R</td></tr>
2209 <td>R</td></tr>
2208 <tr><td>-f</td>
2210 <tr><td>-f</td>
2209 <td>R</td>
2211 <td>R</td>
2210 <td>RD</td>
2212 <td>RD</td>
2211 <td>RD</td>
2213 <td>RD</td>
2212 <td>R</td></tr>
2214 <td>R</td></tr>
2213 <tr><td>-A</td>
2215 <tr><td>-A</td>
2214 <td>W</td>
2216 <td>W</td>
2215 <td>W</td>
2217 <td>W</td>
2216 <td>W</td>
2218 <td>W</td>
2217 <td>R</td></tr>
2219 <td>R</td></tr>
2218 <tr><td>-Af</td>
2220 <tr><td>-Af</td>
2219 <td>R</td>
2221 <td>R</td>
2220 <td>R</td>
2222 <td>R</td>
2221 <td>R</td>
2223 <td>R</td>
2222 <td>R</td></tr>
2224 <td>R</td></tr>
2223 </table>
2225 </table>
2224 <p>
2226 <p>
2225 Note that remove never deletes files in Added [A] state from the
2227 Note that remove never deletes files in Added [A] state from the
2226 working directory, not even if option --force is specified.
2228 working directory, not even if option --force is specified.
2227 </p>
2229 </p>
2228 <p>
2230 <p>
2229 Returns 0 on success, 1 if any warnings encountered.
2231 Returns 0 on success, 1 if any warnings encountered.
2230 </p>
2232 </p>
2231 <p>
2233 <p>
2232 options ([+] can be repeated):
2234 options ([+] can be repeated):
2233 </p>
2235 </p>
2234 <table>
2236 <table>
2235 <tr><td>-A</td>
2237 <tr><td>-A</td>
2236 <td>--after</td>
2238 <td>--after</td>
2237 <td>record delete for missing files</td></tr>
2239 <td>record delete for missing files</td></tr>
2238 <tr><td>-f</td>
2240 <tr><td>-f</td>
2239 <td>--force</td>
2241 <td>--force</td>
2240 <td>remove (and delete) file even if added or modified</td></tr>
2242 <td>remove (and delete) file even if added or modified</td></tr>
2241 <tr><td>-S</td>
2243 <tr><td>-S</td>
2242 <td>--subrepos</td>
2244 <td>--subrepos</td>
2243 <td>recurse into subrepositories</td></tr>
2245 <td>recurse into subrepositories</td></tr>
2244 <tr><td>-I</td>
2246 <tr><td>-I</td>
2245 <td>--include PATTERN [+]</td>
2247 <td>--include PATTERN [+]</td>
2246 <td>include names matching the given patterns</td></tr>
2248 <td>include names matching the given patterns</td></tr>
2247 <tr><td>-X</td>
2249 <tr><td>-X</td>
2248 <td>--exclude PATTERN [+]</td>
2250 <td>--exclude PATTERN [+]</td>
2249 <td>exclude names matching the given patterns</td></tr>
2251 <td>exclude names matching the given patterns</td></tr>
2250 </table>
2252 </table>
2251 <p>
2253 <p>
2252 global options ([+] can be repeated):
2254 global options ([+] can be repeated):
2253 </p>
2255 </p>
2254 <table>
2256 <table>
2255 <tr><td>-R</td>
2257 <tr><td>-R</td>
2256 <td>--repository REPO</td>
2258 <td>--repository REPO</td>
2257 <td>repository root directory or name of overlay bundle file</td></tr>
2259 <td>repository root directory or name of overlay bundle file</td></tr>
2258 <tr><td></td>
2260 <tr><td></td>
2259 <td>--cwd DIR</td>
2261 <td>--cwd DIR</td>
2260 <td>change working directory</td></tr>
2262 <td>change working directory</td></tr>
2261 <tr><td>-y</td>
2263 <tr><td>-y</td>
2262 <td>--noninteractive</td>
2264 <td>--noninteractive</td>
2263 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2265 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2264 <tr><td>-q</td>
2266 <tr><td>-q</td>
2265 <td>--quiet</td>
2267 <td>--quiet</td>
2266 <td>suppress output</td></tr>
2268 <td>suppress output</td></tr>
2267 <tr><td>-v</td>
2269 <tr><td>-v</td>
2268 <td>--verbose</td>
2270 <td>--verbose</td>
2269 <td>enable additional output</td></tr>
2271 <td>enable additional output</td></tr>
2270 <tr><td></td>
2272 <tr><td></td>
2271 <td>--config CONFIG [+]</td>
2273 <td>--config CONFIG [+]</td>
2272 <td>set/override config option (use 'section.name=value')</td></tr>
2274 <td>set/override config option (use 'section.name=value')</td></tr>
2273 <tr><td></td>
2275 <tr><td></td>
2274 <td>--debug</td>
2276 <td>--debug</td>
2275 <td>enable debugging output</td></tr>
2277 <td>enable debugging output</td></tr>
2276 <tr><td></td>
2278 <tr><td></td>
2277 <td>--debugger</td>
2279 <td>--debugger</td>
2278 <td>start debugger</td></tr>
2280 <td>start debugger</td></tr>
2279 <tr><td></td>
2281 <tr><td></td>
2280 <td>--encoding ENCODE</td>
2282 <td>--encoding ENCODE</td>
2281 <td>set the charset encoding (default: ascii)</td></tr>
2283 <td>set the charset encoding (default: ascii)</td></tr>
2282 <tr><td></td>
2284 <tr><td></td>
2283 <td>--encodingmode MODE</td>
2285 <td>--encodingmode MODE</td>
2284 <td>set the charset encoding mode (default: strict)</td></tr>
2286 <td>set the charset encoding mode (default: strict)</td></tr>
2285 <tr><td></td>
2287 <tr><td></td>
2286 <td>--traceback</td>
2288 <td>--traceback</td>
2287 <td>always print a traceback on exception</td></tr>
2289 <td>always print a traceback on exception</td></tr>
2288 <tr><td></td>
2290 <tr><td></td>
2289 <td>--time</td>
2291 <td>--time</td>
2290 <td>time how long the command takes</td></tr>
2292 <td>time how long the command takes</td></tr>
2291 <tr><td></td>
2293 <tr><td></td>
2292 <td>--profile</td>
2294 <td>--profile</td>
2293 <td>print command execution profile</td></tr>
2295 <td>print command execution profile</td></tr>
2294 <tr><td></td>
2296 <tr><td></td>
2295 <td>--version</td>
2297 <td>--version</td>
2296 <td>output version information and exit</td></tr>
2298 <td>output version information and exit</td></tr>
2297 <tr><td>-h</td>
2299 <tr><td>-h</td>
2298 <td>--help</td>
2300 <td>--help</td>
2299 <td>display help and exit</td></tr>
2301 <td>display help and exit</td></tr>
2300 <tr><td></td>
2302 <tr><td></td>
2301 <td>--hidden</td>
2303 <td>--hidden</td>
2302 <td>consider hidden changesets</td></tr>
2304 <td>consider hidden changesets</td></tr>
2303 </table>
2305 </table>
2304
2306
2305 </div>
2307 </div>
2306 </div>
2308 </div>
2307 </div>
2309 </div>
2308
2310
2309 <script type="text/javascript">process_dates()</script>
2311 <script type="text/javascript">process_dates()</script>
2310
2312
2311
2313
2312 </body>
2314 </body>
2313 </html>
2315 </html>
2314
2316
2315
2317
2316 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2318 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2317 200 Script output follows
2319 200 Script output follows
2318
2320
2319 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2321 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2320 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2322 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2321 <head>
2323 <head>
2322 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2324 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2323 <meta name="robots" content="index, nofollow" />
2325 <meta name="robots" content="index, nofollow" />
2324 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2326 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2325 <script type="text/javascript" src="/static/mercurial.js"></script>
2327 <script type="text/javascript" src="/static/mercurial.js"></script>
2326
2328
2327 <title>Help: revisions</title>
2329 <title>Help: revisions</title>
2328 </head>
2330 </head>
2329 <body>
2331 <body>
2330
2332
2331 <div class="container">
2333 <div class="container">
2332 <div class="menu">
2334 <div class="menu">
2333 <div class="logo">
2335 <div class="logo">
2334 <a href="https://mercurial-scm.org/">
2336 <a href="https://mercurial-scm.org/">
2335 <img src="/static/hglogo.png" alt="mercurial" /></a>
2337 <img src="/static/hglogo.png" alt="mercurial" /></a>
2336 </div>
2338 </div>
2337 <ul>
2339 <ul>
2338 <li><a href="/shortlog">log</a></li>
2340 <li><a href="/shortlog">log</a></li>
2339 <li><a href="/graph">graph</a></li>
2341 <li><a href="/graph">graph</a></li>
2340 <li><a href="/tags">tags</a></li>
2342 <li><a href="/tags">tags</a></li>
2341 <li><a href="/bookmarks">bookmarks</a></li>
2343 <li><a href="/bookmarks">bookmarks</a></li>
2342 <li><a href="/branches">branches</a></li>
2344 <li><a href="/branches">branches</a></li>
2343 </ul>
2345 </ul>
2344 <ul>
2346 <ul>
2345 <li class="active"><a href="/help">help</a></li>
2347 <li class="active"><a href="/help">help</a></li>
2346 </ul>
2348 </ul>
2347 </div>
2349 </div>
2348
2350
2349 <div class="main">
2351 <div class="main">
2350 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2352 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2351 <h3>Help: revisions</h3>
2353 <h3>Help: revisions</h3>
2352
2354
2353 <form class="search" action="/log">
2355 <form class="search" action="/log">
2354
2356
2355 <p><input name="rev" id="search1" type="text" size="30" /></p>
2357 <p><input name="rev" id="search1" type="text" size="30" /></p>
2356 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2358 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2357 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2359 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2358 </form>
2360 </form>
2359 <div id="doc">
2361 <div id="doc">
2360 <h1>Specifying Single Revisions</h1>
2362 <h1>Specifying Single Revisions</h1>
2361 <p>
2363 <p>
2362 Mercurial supports several ways to specify individual revisions.
2364 Mercurial supports several ways to specify individual revisions.
2363 </p>
2365 </p>
2364 <p>
2366 <p>
2365 A plain integer is treated as a revision number. Negative integers are
2367 A plain integer is treated as a revision number. Negative integers are
2366 treated as sequential offsets from the tip, with -1 denoting the tip,
2368 treated as sequential offsets from the tip, with -1 denoting the tip,
2367 -2 denoting the revision prior to the tip, and so forth.
2369 -2 denoting the revision prior to the tip, and so forth.
2368 </p>
2370 </p>
2369 <p>
2371 <p>
2370 A 40-digit hexadecimal string is treated as a unique revision
2372 A 40-digit hexadecimal string is treated as a unique revision
2371 identifier.
2373 identifier.
2372 </p>
2374 </p>
2373 <p>
2375 <p>
2374 A hexadecimal string less than 40 characters long is treated as a
2376 A hexadecimal string less than 40 characters long is treated as a
2375 unique revision identifier and is referred to as a short-form
2377 unique revision identifier and is referred to as a short-form
2376 identifier. A short-form identifier is only valid if it is the prefix
2378 identifier. A short-form identifier is only valid if it is the prefix
2377 of exactly one full-length identifier.
2379 of exactly one full-length identifier.
2378 </p>
2380 </p>
2379 <p>
2381 <p>
2380 Any other string is treated as a bookmark, tag, or branch name. A
2382 Any other string is treated as a bookmark, tag, or branch name. A
2381 bookmark is a movable pointer to a revision. A tag is a permanent name
2383 bookmark is a movable pointer to a revision. A tag is a permanent name
2382 associated with a revision. A branch name denotes the tipmost open branch head
2384 associated with a revision. A branch name denotes the tipmost open branch head
2383 of that branch - or if they are all closed, the tipmost closed head of the
2385 of that branch - or if they are all closed, the tipmost closed head of the
2384 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2386 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2385 </p>
2387 </p>
2386 <p>
2388 <p>
2387 The reserved name &quot;tip&quot; always identifies the most recent revision.
2389 The reserved name &quot;tip&quot; always identifies the most recent revision.
2388 </p>
2390 </p>
2389 <p>
2391 <p>
2390 The reserved name &quot;null&quot; indicates the null revision. This is the
2392 The reserved name &quot;null&quot; indicates the null revision. This is the
2391 revision of an empty repository, and the parent of revision 0.
2393 revision of an empty repository, and the parent of revision 0.
2392 </p>
2394 </p>
2393 <p>
2395 <p>
2394 The reserved name &quot;.&quot; indicates the working directory parent. If no
2396 The reserved name &quot;.&quot; indicates the working directory parent. If no
2395 working directory is checked out, it is equivalent to null. If an
2397 working directory is checked out, it is equivalent to null. If an
2396 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2398 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2397 parent.
2399 parent.
2398 </p>
2400 </p>
2399
2401
2400 </div>
2402 </div>
2401 </div>
2403 </div>
2402 </div>
2404 </div>
2403
2405
2404 <script type="text/javascript">process_dates()</script>
2406 <script type="text/javascript">process_dates()</script>
2405
2407
2406
2408
2407 </body>
2409 </body>
2408 </html>
2410 </html>
2409
2411
2410
2412
2411 $ killdaemons.py
2413 $ killdaemons.py
2412
2414
2413 #endif
2415 #endif
General Comments 0
You need to be logged in to leave comments. Login now