##// END OF EJS Templates
unbundle: properly read head modification result from bundle2...
Pierre-Yves David -
r26539:1956026e default
parent child Browse files
Show More
@@ -1,6649 +1,6649 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, nullid, nullrev, short
8 from node import hex, bin, 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 from hgweb import server as hgweb_server
18 from hgweb import server as hgweb_server
19 import merge as mergemod
19 import merge as mergemod
20 import minirst, revset, fileset
20 import minirst, revset, fileset
21 import dagparser, context, simplemerge, graphmod, copies
21 import dagparser, context, simplemerge, graphmod, copies
22 import random, operator
22 import random, operator
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
23 import setdiscovery, treediscovery, dagutil, pvec, localrepo
24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
25 import ui as uimod
25 import ui as uimod
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 # Commands start here, listed alphabetically
174 # Commands start here, listed alphabetically
175
175
176 @command('^add',
176 @command('^add',
177 walkopts + subrepoopts + dryrunopts,
177 walkopts + subrepoopts + dryrunopts,
178 _('[OPTION]... [FILE]...'),
178 _('[OPTION]... [FILE]...'),
179 inferrepo=True)
179 inferrepo=True)
180 def add(ui, repo, *pats, **opts):
180 def add(ui, repo, *pats, **opts):
181 """add the specified files on the next commit
181 """add the specified files on the next commit
182
182
183 Schedule files to be version controlled and added to the
183 Schedule files to be version controlled and added to the
184 repository.
184 repository.
185
185
186 The files will be added to the repository at the next commit. To
186 The files will be added to the repository at the next commit. To
187 undo an add before that, see :hg:`forget`.
187 undo an add before that, see :hg:`forget`.
188
188
189 If no names are given, add all files to the repository.
189 If no names are given, add all files to the repository.
190
190
191 .. container:: verbose
191 .. container:: verbose
192
192
193 An example showing how new (unknown) files are added
193 An example showing how new (unknown) files are added
194 automatically by :hg:`add`::
194 automatically by :hg:`add`::
195
195
196 $ ls
196 $ ls
197 foo.c
197 foo.c
198 $ hg status
198 $ hg status
199 ? foo.c
199 ? foo.c
200 $ hg add
200 $ hg add
201 adding foo.c
201 adding foo.c
202 $ hg status
202 $ hg status
203 A foo.c
203 A foo.c
204
204
205 Returns 0 if all files are successfully added.
205 Returns 0 if all files are successfully added.
206 """
206 """
207
207
208 m = scmutil.match(repo[None], pats, opts)
208 m = scmutil.match(repo[None], pats, opts)
209 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
209 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
210 return rejected and 1 or 0
210 return rejected and 1 or 0
211
211
212 @command('addremove',
212 @command('addremove',
213 similarityopts + subrepoopts + walkopts + dryrunopts,
213 similarityopts + subrepoopts + walkopts + dryrunopts,
214 _('[OPTION]... [FILE]...'),
214 _('[OPTION]... [FILE]...'),
215 inferrepo=True)
215 inferrepo=True)
216 def addremove(ui, repo, *pats, **opts):
216 def addremove(ui, repo, *pats, **opts):
217 """add all new files, delete all missing files
217 """add all new files, delete all missing files
218
218
219 Add all new files and remove all missing files from the
219 Add all new files and remove all missing files from the
220 repository.
220 repository.
221
221
222 New files are ignored if they match any of the patterns in
222 New files are ignored if they match any of the patterns in
223 ``.hgignore``. As with add, these changes take effect at the next
223 ``.hgignore``. As with add, these changes take effect at the next
224 commit.
224 commit.
225
225
226 Use the -s/--similarity option to detect renamed files. This
226 Use the -s/--similarity option to detect renamed files. This
227 option takes a percentage between 0 (disabled) and 100 (files must
227 option takes a percentage between 0 (disabled) and 100 (files must
228 be identical) as its parameter. With a parameter greater than 0,
228 be identical) as its parameter. With a parameter greater than 0,
229 this compares every removed file with every added file and records
229 this compares every removed file with every added file and records
230 those similar enough as renames. Detecting renamed files this way
230 those similar enough as renames. Detecting renamed files this way
231 can be expensive. After using this option, :hg:`status -C` can be
231 can be expensive. After using this option, :hg:`status -C` can be
232 used to check which files were identified as moved or renamed. If
232 used to check which files were identified as moved or renamed. If
233 not specified, -s/--similarity defaults to 100 and only renames of
233 not specified, -s/--similarity defaults to 100 and only renames of
234 identical files are detected.
234 identical files are detected.
235
235
236 Returns 0 if all files are successfully added.
236 Returns 0 if all files are successfully added.
237 """
237 """
238 try:
238 try:
239 sim = float(opts.get('similarity') or 100)
239 sim = float(opts.get('similarity') or 100)
240 except ValueError:
240 except ValueError:
241 raise util.Abort(_('similarity must be a number'))
241 raise util.Abort(_('similarity must be a number'))
242 if sim < 0 or sim > 100:
242 if sim < 0 or sim > 100:
243 raise util.Abort(_('similarity must be between 0 and 100'))
243 raise util.Abort(_('similarity must be between 0 and 100'))
244 matcher = scmutil.match(repo[None], pats, opts)
244 matcher = scmutil.match(repo[None], pats, opts)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
245 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
246
246
247 @command('^annotate|blame',
247 @command('^annotate|blame',
248 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
248 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
249 ('', 'follow', None,
249 ('', 'follow', None,
250 _('follow copies/renames and list the filename (DEPRECATED)')),
250 _('follow copies/renames and list the filename (DEPRECATED)')),
251 ('', 'no-follow', None, _("don't follow copies and renames")),
251 ('', 'no-follow', None, _("don't follow copies and renames")),
252 ('a', 'text', None, _('treat all files as text')),
252 ('a', 'text', None, _('treat all files as text')),
253 ('u', 'user', None, _('list the author (long with -v)')),
253 ('u', 'user', None, _('list the author (long with -v)')),
254 ('f', 'file', None, _('list the filename')),
254 ('f', 'file', None, _('list the filename')),
255 ('d', 'date', None, _('list the date (short with -q)')),
255 ('d', 'date', None, _('list the date (short with -q)')),
256 ('n', 'number', None, _('list the revision number (default)')),
256 ('n', 'number', None, _('list the revision number (default)')),
257 ('c', 'changeset', None, _('list the changeset')),
257 ('c', 'changeset', None, _('list the changeset')),
258 ('l', 'line-number', None, _('show line number at the first appearance'))
258 ('l', 'line-number', None, _('show line number at the first appearance'))
259 ] + diffwsopts + walkopts + formatteropts,
259 ] + diffwsopts + walkopts + formatteropts,
260 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
260 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
261 inferrepo=True)
261 inferrepo=True)
262 def annotate(ui, repo, *pats, **opts):
262 def annotate(ui, repo, *pats, **opts):
263 """show changeset information by line for each file
263 """show changeset information by line for each file
264
264
265 List changes in files, showing the revision id responsible for
265 List changes in files, showing the revision id responsible for
266 each line
266 each line
267
267
268 This command is useful for discovering when a change was made and
268 This command is useful for discovering when a change was made and
269 by whom.
269 by whom.
270
270
271 Without the -a/--text option, annotate will avoid processing files
271 Without the -a/--text option, annotate will avoid processing files
272 it detects as binary. With -a, annotate will annotate the file
272 it detects as binary. With -a, annotate will annotate the file
273 anyway, although the results will probably be neither useful
273 anyway, although the results will probably be neither useful
274 nor desirable.
274 nor desirable.
275
275
276 Returns 0 on success.
276 Returns 0 on success.
277 """
277 """
278 if not pats:
278 if not pats:
279 raise util.Abort(_('at least one filename or pattern is required'))
279 raise util.Abort(_('at least one filename or pattern is required'))
280
280
281 if opts.get('follow'):
281 if opts.get('follow'):
282 # --follow is deprecated and now just an alias for -f/--file
282 # --follow is deprecated and now just an alias for -f/--file
283 # to mimic the behavior of Mercurial before version 1.5
283 # to mimic the behavior of Mercurial before version 1.5
284 opts['file'] = True
284 opts['file'] = True
285
285
286 ctx = scmutil.revsingle(repo, opts.get('rev'))
286 ctx = scmutil.revsingle(repo, opts.get('rev'))
287
287
288 fm = ui.formatter('annotate', opts)
288 fm = ui.formatter('annotate', opts)
289 if ui.quiet:
289 if ui.quiet:
290 datefunc = util.shortdate
290 datefunc = util.shortdate
291 else:
291 else:
292 datefunc = util.datestr
292 datefunc = util.datestr
293 if ctx.rev() is None:
293 if ctx.rev() is None:
294 def hexfn(node):
294 def hexfn(node):
295 if node is None:
295 if node is None:
296 return None
296 return None
297 else:
297 else:
298 return fm.hexfunc(node)
298 return fm.hexfunc(node)
299 if opts.get('changeset'):
299 if opts.get('changeset'):
300 # omit "+" suffix which is appended to node hex
300 # omit "+" suffix which is appended to node hex
301 def formatrev(rev):
301 def formatrev(rev):
302 if rev is None:
302 if rev is None:
303 return '%d' % ctx.p1().rev()
303 return '%d' % ctx.p1().rev()
304 else:
304 else:
305 return '%d' % rev
305 return '%d' % rev
306 else:
306 else:
307 def formatrev(rev):
307 def formatrev(rev):
308 if rev is None:
308 if rev is None:
309 return '%d+' % ctx.p1().rev()
309 return '%d+' % ctx.p1().rev()
310 else:
310 else:
311 return '%d ' % rev
311 return '%d ' % rev
312 def formathex(hex):
312 def formathex(hex):
313 if hex is None:
313 if hex is None:
314 return '%s+' % fm.hexfunc(ctx.p1().node())
314 return '%s+' % fm.hexfunc(ctx.p1().node())
315 else:
315 else:
316 return '%s ' % hex
316 return '%s ' % hex
317 else:
317 else:
318 hexfn = fm.hexfunc
318 hexfn = fm.hexfunc
319 formatrev = formathex = str
319 formatrev = formathex = str
320
320
321 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
321 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
322 ('number', ' ', lambda x: x[0].rev(), formatrev),
322 ('number', ' ', lambda x: x[0].rev(), formatrev),
323 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
323 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
324 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
324 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
325 ('file', ' ', lambda x: x[0].path(), str),
325 ('file', ' ', lambda x: x[0].path(), str),
326 ('line_number', ':', lambda x: x[1], str),
326 ('line_number', ':', lambda x: x[1], str),
327 ]
327 ]
328 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
328 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
329
329
330 if (not opts.get('user') and not opts.get('changeset')
330 if (not opts.get('user') and not opts.get('changeset')
331 and not opts.get('date') and not opts.get('file')):
331 and not opts.get('date') and not opts.get('file')):
332 opts['number'] = True
332 opts['number'] = True
333
333
334 linenumber = opts.get('line_number') is not None
334 linenumber = opts.get('line_number') is not None
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
335 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
336 raise util.Abort(_('at least one of -n/-c is required for -l'))
336 raise util.Abort(_('at least one of -n/-c is required for -l'))
337
337
338 if fm:
338 if fm:
339 def makefunc(get, fmt):
339 def makefunc(get, fmt):
340 return get
340 return get
341 else:
341 else:
342 def makefunc(get, fmt):
342 def makefunc(get, fmt):
343 return lambda x: fmt(get(x))
343 return lambda x: fmt(get(x))
344 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
344 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
345 if opts.get(op)]
345 if opts.get(op)]
346 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
346 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
347 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
347 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
348 if opts.get(op))
348 if opts.get(op))
349
349
350 def bad(x, y):
350 def bad(x, y):
351 raise util.Abort("%s: %s" % (x, y))
351 raise util.Abort("%s: %s" % (x, y))
352
352
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
353 m = scmutil.match(ctx, pats, opts, badfn=bad)
354
354
355 follow = not opts.get('no_follow')
355 follow = not opts.get('no_follow')
356 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
356 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
357 whitespace=True)
357 whitespace=True)
358 for abs in ctx.walk(m):
358 for abs in ctx.walk(m):
359 fctx = ctx[abs]
359 fctx = ctx[abs]
360 if not opts.get('text') and util.binary(fctx.data()):
360 if not opts.get('text') and util.binary(fctx.data()):
361 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
361 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
362 continue
362 continue
363
363
364 lines = fctx.annotate(follow=follow, linenumber=linenumber,
364 lines = fctx.annotate(follow=follow, linenumber=linenumber,
365 diffopts=diffopts)
365 diffopts=diffopts)
366 formats = []
366 formats = []
367 pieces = []
367 pieces = []
368
368
369 for f, sep in funcmap:
369 for f, sep in funcmap:
370 l = [f(n) for n, dummy in lines]
370 l = [f(n) for n, dummy in lines]
371 if l:
371 if l:
372 if fm:
372 if fm:
373 formats.append(['%s' for x in l])
373 formats.append(['%s' for x in l])
374 else:
374 else:
375 sizes = [encoding.colwidth(x) for x in l]
375 sizes = [encoding.colwidth(x) for x in l]
376 ml = max(sizes)
376 ml = max(sizes)
377 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
377 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
378 pieces.append(l)
378 pieces.append(l)
379
379
380 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
380 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
381 fm.startitem()
381 fm.startitem()
382 fm.write(fields, "".join(f), *p)
382 fm.write(fields, "".join(f), *p)
383 fm.write('line', ": %s", l[1])
383 fm.write('line', ": %s", l[1])
384
384
385 if lines and not lines[-1][1].endswith('\n'):
385 if lines and not lines[-1][1].endswith('\n'):
386 fm.plain('\n')
386 fm.plain('\n')
387
387
388 fm.end()
388 fm.end()
389
389
390 @command('archive',
390 @command('archive',
391 [('', 'no-decode', None, _('do not pass files through decoders')),
391 [('', 'no-decode', None, _('do not pass files through decoders')),
392 ('p', 'prefix', '', _('directory prefix for files in archive'),
392 ('p', 'prefix', '', _('directory prefix for files in archive'),
393 _('PREFIX')),
393 _('PREFIX')),
394 ('r', 'rev', '', _('revision to distribute'), _('REV')),
394 ('r', 'rev', '', _('revision to distribute'), _('REV')),
395 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
395 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
396 ] + subrepoopts + walkopts,
396 ] + subrepoopts + walkopts,
397 _('[OPTION]... DEST'))
397 _('[OPTION]... DEST'))
398 def archive(ui, repo, dest, **opts):
398 def archive(ui, repo, dest, **opts):
399 '''create an unversioned archive of a repository revision
399 '''create an unversioned archive of a repository revision
400
400
401 By default, the revision used is the parent of the working
401 By default, the revision used is the parent of the working
402 directory; use -r/--rev to specify a different revision.
402 directory; use -r/--rev to specify a different revision.
403
403
404 The archive type is automatically detected based on file
404 The archive type is automatically detected based on file
405 extension (or override using -t/--type).
405 extension (or override using -t/--type).
406
406
407 .. container:: verbose
407 .. container:: verbose
408
408
409 Examples:
409 Examples:
410
410
411 - create a zip file containing the 1.0 release::
411 - create a zip file containing the 1.0 release::
412
412
413 hg archive -r 1.0 project-1.0.zip
413 hg archive -r 1.0 project-1.0.zip
414
414
415 - create a tarball excluding .hg files::
415 - create a tarball excluding .hg files::
416
416
417 hg archive project.tar.gz -X ".hg*"
417 hg archive project.tar.gz -X ".hg*"
418
418
419 Valid types are:
419 Valid types are:
420
420
421 :``files``: a directory full of files (default)
421 :``files``: a directory full of files (default)
422 :``tar``: tar archive, uncompressed
422 :``tar``: tar archive, uncompressed
423 :``tbz2``: tar archive, compressed using bzip2
423 :``tbz2``: tar archive, compressed using bzip2
424 :``tgz``: tar archive, compressed using gzip
424 :``tgz``: tar archive, compressed using gzip
425 :``uzip``: zip archive, uncompressed
425 :``uzip``: zip archive, uncompressed
426 :``zip``: zip archive, compressed using deflate
426 :``zip``: zip archive, compressed using deflate
427
427
428 The exact name of the destination archive or directory is given
428 The exact name of the destination archive or directory is given
429 using a format string; see :hg:`help export` for details.
429 using a format string; see :hg:`help export` for details.
430
430
431 Each member added to an archive file has a directory prefix
431 Each member added to an archive file has a directory prefix
432 prepended. Use -p/--prefix to specify a format string for the
432 prepended. Use -p/--prefix to specify a format string for the
433 prefix. The default is the basename of the archive, with suffixes
433 prefix. The default is the basename of the archive, with suffixes
434 removed.
434 removed.
435
435
436 Returns 0 on success.
436 Returns 0 on success.
437 '''
437 '''
438
438
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
439 ctx = scmutil.revsingle(repo, opts.get('rev'))
440 if not ctx:
440 if not ctx:
441 raise util.Abort(_('no working directory: please specify a revision'))
441 raise util.Abort(_('no working directory: please specify a revision'))
442 node = ctx.node()
442 node = ctx.node()
443 dest = cmdutil.makefilename(repo, dest, node)
443 dest = cmdutil.makefilename(repo, dest, node)
444 if os.path.realpath(dest) == repo.root:
444 if os.path.realpath(dest) == repo.root:
445 raise util.Abort(_('repository root cannot be destination'))
445 raise util.Abort(_('repository root cannot be destination'))
446
446
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
447 kind = opts.get('type') or archival.guesskind(dest) or 'files'
448 prefix = opts.get('prefix')
448 prefix = opts.get('prefix')
449
449
450 if dest == '-':
450 if dest == '-':
451 if kind == 'files':
451 if kind == 'files':
452 raise util.Abort(_('cannot archive plain files to stdout'))
452 raise util.Abort(_('cannot archive plain files to stdout'))
453 dest = cmdutil.makefileobj(repo, dest)
453 dest = cmdutil.makefileobj(repo, dest)
454 if not prefix:
454 if not prefix:
455 prefix = os.path.basename(repo.root) + '-%h'
455 prefix = os.path.basename(repo.root) + '-%h'
456
456
457 prefix = cmdutil.makefilename(repo, prefix, node)
457 prefix = cmdutil.makefilename(repo, prefix, node)
458 matchfn = scmutil.match(ctx, [], opts)
458 matchfn = scmutil.match(ctx, [], opts)
459 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
459 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
460 matchfn, prefix, subrepos=opts.get('subrepos'))
460 matchfn, prefix, subrepos=opts.get('subrepos'))
461
461
462 @command('backout',
462 @command('backout',
463 [('', 'merge', None, _('merge with old dirstate parent after backout')),
463 [('', 'merge', None, _('merge with old dirstate parent after backout')),
464 ('', 'commit', None, _('commit if no conflicts were encountered')),
464 ('', 'commit', None, _('commit if no conflicts were encountered')),
465 ('', 'parent', '',
465 ('', 'parent', '',
466 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
466 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
467 ('r', 'rev', '', _('revision to backout'), _('REV')),
467 ('r', 'rev', '', _('revision to backout'), _('REV')),
468 ('e', 'edit', False, _('invoke editor on commit messages')),
468 ('e', 'edit', False, _('invoke editor on commit messages')),
469 ] + mergetoolopts + walkopts + commitopts + commitopts2,
469 ] + mergetoolopts + walkopts + commitopts + commitopts2,
470 _('[OPTION]... [-r] REV'))
470 _('[OPTION]... [-r] REV'))
471 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
471 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
472 '''reverse effect of earlier changeset
472 '''reverse effect of earlier changeset
473
473
474 Prepare a new changeset with the effect of REV undone in the
474 Prepare a new changeset with the effect of REV undone in the
475 current working directory.
475 current working directory.
476
476
477 If REV is the parent of the working directory, then this new changeset
477 If REV is the parent of the working directory, then this new changeset
478 is committed automatically. Otherwise, hg needs to merge the
478 is committed automatically. Otherwise, hg needs to merge the
479 changes and the merged result is left uncommitted.
479 changes and the merged result is left uncommitted.
480
480
481 .. note::
481 .. note::
482
482
483 backout cannot be used to fix either an unwanted or
483 backout cannot be used to fix either an unwanted or
484 incorrect merge.
484 incorrect merge.
485
485
486 .. container:: verbose
486 .. container:: verbose
487
487
488 By default, the pending changeset will have one parent,
488 By default, the pending changeset will have one parent,
489 maintaining a linear history. With --merge, the pending
489 maintaining a linear history. With --merge, the pending
490 changeset will instead have two parents: the old parent of the
490 changeset will instead have two parents: the old parent of the
491 working directory and a new child of REV that simply undoes REV.
491 working directory and a new child of REV that simply undoes REV.
492
492
493 Before version 1.7, the behavior without --merge was equivalent
493 Before version 1.7, the behavior without --merge was equivalent
494 to specifying --merge followed by :hg:`update --clean .` to
494 to specifying --merge followed by :hg:`update --clean .` to
495 cancel the merge and leave the child of REV as a head to be
495 cancel the merge and leave the child of REV as a head to be
496 merged separately.
496 merged separately.
497
497
498 See :hg:`help dates` for a list of formats valid for -d/--date.
498 See :hg:`help dates` for a list of formats valid for -d/--date.
499
499
500 See :hg:`help revert` for a way to restore files to the state
500 See :hg:`help revert` for a way to restore files to the state
501 of another revision.
501 of another revision.
502
502
503 Returns 0 on success, 1 if nothing to backout or there are unresolved
503 Returns 0 on success, 1 if nothing to backout or there are unresolved
504 files.
504 files.
505 '''
505 '''
506 if rev and node:
506 if rev and node:
507 raise util.Abort(_("please specify just one revision"))
507 raise util.Abort(_("please specify just one revision"))
508
508
509 if not rev:
509 if not rev:
510 rev = node
510 rev = node
511
511
512 if not rev:
512 if not rev:
513 raise util.Abort(_("please specify a revision to backout"))
513 raise util.Abort(_("please specify a revision to backout"))
514
514
515 date = opts.get('date')
515 date = opts.get('date')
516 if date:
516 if date:
517 opts['date'] = util.parsedate(date)
517 opts['date'] = util.parsedate(date)
518
518
519 cmdutil.checkunfinished(repo)
519 cmdutil.checkunfinished(repo)
520 cmdutil.bailifchanged(repo)
520 cmdutil.bailifchanged(repo)
521 node = scmutil.revsingle(repo, rev).node()
521 node = scmutil.revsingle(repo, rev).node()
522
522
523 op1, op2 = repo.dirstate.parents()
523 op1, op2 = repo.dirstate.parents()
524 if not repo.changelog.isancestor(node, op1):
524 if not repo.changelog.isancestor(node, op1):
525 raise util.Abort(_('cannot backout change that is not an ancestor'))
525 raise util.Abort(_('cannot backout change that is not an ancestor'))
526
526
527 p1, p2 = repo.changelog.parents(node)
527 p1, p2 = repo.changelog.parents(node)
528 if p1 == nullid:
528 if p1 == nullid:
529 raise util.Abort(_('cannot backout a change with no parents'))
529 raise util.Abort(_('cannot backout a change with no parents'))
530 if p2 != nullid:
530 if p2 != nullid:
531 if not opts.get('parent'):
531 if not opts.get('parent'):
532 raise util.Abort(_('cannot backout a merge changeset'))
532 raise util.Abort(_('cannot backout a merge changeset'))
533 p = repo.lookup(opts['parent'])
533 p = repo.lookup(opts['parent'])
534 if p not in (p1, p2):
534 if p not in (p1, p2):
535 raise util.Abort(_('%s is not a parent of %s') %
535 raise util.Abort(_('%s is not a parent of %s') %
536 (short(p), short(node)))
536 (short(p), short(node)))
537 parent = p
537 parent = p
538 else:
538 else:
539 if opts.get('parent'):
539 if opts.get('parent'):
540 raise util.Abort(_('cannot use --parent on non-merge changeset'))
540 raise util.Abort(_('cannot use --parent on non-merge changeset'))
541 parent = p1
541 parent = p1
542
542
543 # the backout should appear on the same branch
543 # the backout should appear on the same branch
544 wlock = repo.wlock()
544 wlock = repo.wlock()
545 try:
545 try:
546 branch = repo.dirstate.branch()
546 branch = repo.dirstate.branch()
547 bheads = repo.branchheads(branch)
547 bheads = repo.branchheads(branch)
548 rctx = scmutil.revsingle(repo, hex(parent))
548 rctx = scmutil.revsingle(repo, hex(parent))
549 if not opts.get('merge') and op1 != node:
549 if not opts.get('merge') and op1 != node:
550 try:
550 try:
551 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
551 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
552 'backout')
552 'backout')
553 repo.dirstate.beginparentchange()
553 repo.dirstate.beginparentchange()
554 stats = mergemod.update(repo, parent, True, True, False,
554 stats = mergemod.update(repo, parent, True, True, False,
555 node, False)
555 node, False)
556 repo.setparents(op1, op2)
556 repo.setparents(op1, op2)
557 repo.dirstate.endparentchange()
557 repo.dirstate.endparentchange()
558 hg._showstats(repo, stats)
558 hg._showstats(repo, stats)
559 if stats[3]:
559 if stats[3]:
560 repo.ui.status(_("use 'hg resolve' to retry unresolved "
560 repo.ui.status(_("use 'hg resolve' to retry unresolved "
561 "file merges\n"))
561 "file merges\n"))
562 return 1
562 return 1
563 elif not commit:
563 elif not commit:
564 msg = _("changeset %s backed out, "
564 msg = _("changeset %s backed out, "
565 "don't forget to commit.\n")
565 "don't forget to commit.\n")
566 ui.status(msg % short(node))
566 ui.status(msg % short(node))
567 return 0
567 return 0
568 finally:
568 finally:
569 ui.setconfig('ui', 'forcemerge', '', '')
569 ui.setconfig('ui', 'forcemerge', '', '')
570 else:
570 else:
571 hg.clean(repo, node, show_stats=False)
571 hg.clean(repo, node, show_stats=False)
572 repo.dirstate.setbranch(branch)
572 repo.dirstate.setbranch(branch)
573 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
573 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
574
574
575
575
576 def commitfunc(ui, repo, message, match, opts):
576 def commitfunc(ui, repo, message, match, opts):
577 editform = 'backout'
577 editform = 'backout'
578 e = cmdutil.getcommiteditor(editform=editform, **opts)
578 e = cmdutil.getcommiteditor(editform=editform, **opts)
579 if not message:
579 if not message:
580 # we don't translate commit messages
580 # we don't translate commit messages
581 message = "Backed out changeset %s" % short(node)
581 message = "Backed out changeset %s" % short(node)
582 e = cmdutil.getcommiteditor(edit=True, editform=editform)
582 e = cmdutil.getcommiteditor(edit=True, editform=editform)
583 return repo.commit(message, opts.get('user'), opts.get('date'),
583 return repo.commit(message, opts.get('user'), opts.get('date'),
584 match, editor=e)
584 match, editor=e)
585 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
585 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
586 if not newnode:
586 if not newnode:
587 ui.status(_("nothing changed\n"))
587 ui.status(_("nothing changed\n"))
588 return 1
588 return 1
589 cmdutil.commitstatus(repo, newnode, branch, bheads)
589 cmdutil.commitstatus(repo, newnode, branch, bheads)
590
590
591 def nice(node):
591 def nice(node):
592 return '%d:%s' % (repo.changelog.rev(node), short(node))
592 return '%d:%s' % (repo.changelog.rev(node), short(node))
593 ui.status(_('changeset %s backs out changeset %s\n') %
593 ui.status(_('changeset %s backs out changeset %s\n') %
594 (nice(repo.changelog.tip()), nice(node)))
594 (nice(repo.changelog.tip()), nice(node)))
595 if opts.get('merge') and op1 != node:
595 if opts.get('merge') and op1 != node:
596 hg.clean(repo, op1, show_stats=False)
596 hg.clean(repo, op1, show_stats=False)
597 ui.status(_('merging with changeset %s\n')
597 ui.status(_('merging with changeset %s\n')
598 % nice(repo.changelog.tip()))
598 % nice(repo.changelog.tip()))
599 try:
599 try:
600 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
600 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
601 'backout')
601 'backout')
602 return hg.merge(repo, hex(repo.changelog.tip()))
602 return hg.merge(repo, hex(repo.changelog.tip()))
603 finally:
603 finally:
604 ui.setconfig('ui', 'forcemerge', '', '')
604 ui.setconfig('ui', 'forcemerge', '', '')
605 finally:
605 finally:
606 wlock.release()
606 wlock.release()
607 return 0
607 return 0
608
608
609 @command('bisect',
609 @command('bisect',
610 [('r', 'reset', False, _('reset bisect state')),
610 [('r', 'reset', False, _('reset bisect state')),
611 ('g', 'good', False, _('mark changeset good')),
611 ('g', 'good', False, _('mark changeset good')),
612 ('b', 'bad', False, _('mark changeset bad')),
612 ('b', 'bad', False, _('mark changeset bad')),
613 ('s', 'skip', False, _('skip testing changeset')),
613 ('s', 'skip', False, _('skip testing changeset')),
614 ('e', 'extend', False, _('extend the bisect range')),
614 ('e', 'extend', False, _('extend the bisect range')),
615 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
615 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
616 ('U', 'noupdate', False, _('do not update to target'))],
616 ('U', 'noupdate', False, _('do not update to target'))],
617 _("[-gbsr] [-U] [-c CMD] [REV]"))
617 _("[-gbsr] [-U] [-c CMD] [REV]"))
618 def bisect(ui, repo, rev=None, extra=None, command=None,
618 def bisect(ui, repo, rev=None, extra=None, command=None,
619 reset=None, good=None, bad=None, skip=None, extend=None,
619 reset=None, good=None, bad=None, skip=None, extend=None,
620 noupdate=None):
620 noupdate=None):
621 """subdivision search of changesets
621 """subdivision search of changesets
622
622
623 This command helps to find changesets which introduce problems. To
623 This command helps to find changesets which introduce problems. To
624 use, mark the earliest changeset you know exhibits the problem as
624 use, mark the earliest changeset you know exhibits the problem as
625 bad, then mark the latest changeset which is free from the problem
625 bad, then mark the latest changeset which is free from the problem
626 as good. Bisect will update your working directory to a revision
626 as good. Bisect will update your working directory to a revision
627 for testing (unless the -U/--noupdate option is specified). Once
627 for testing (unless the -U/--noupdate option is specified). Once
628 you have performed tests, mark the working directory as good or
628 you have performed tests, mark the working directory as good or
629 bad, and bisect will either update to another candidate changeset
629 bad, and bisect will either update to another candidate changeset
630 or announce that it has found the bad revision.
630 or announce that it has found the bad revision.
631
631
632 As a shortcut, you can also use the revision argument to mark a
632 As a shortcut, you can also use the revision argument to mark a
633 revision as good or bad without checking it out first.
633 revision as good or bad without checking it out first.
634
634
635 If you supply a command, it will be used for automatic bisection.
635 If you supply a command, it will be used for automatic bisection.
636 The environment variable HG_NODE will contain the ID of the
636 The environment variable HG_NODE will contain the ID of the
637 changeset being tested. The exit status of the command will be
637 changeset being tested. The exit status of the command will be
638 used to mark revisions as good or bad: status 0 means good, 125
638 used to mark revisions as good or bad: status 0 means good, 125
639 means to skip the revision, 127 (command not found) will abort the
639 means to skip the revision, 127 (command not found) will abort the
640 bisection, and any other non-zero exit status means the revision
640 bisection, and any other non-zero exit status means the revision
641 is bad.
641 is bad.
642
642
643 .. container:: verbose
643 .. container:: verbose
644
644
645 Some examples:
645 Some examples:
646
646
647 - start a bisection with known bad revision 34, and good revision 12::
647 - start a bisection with known bad revision 34, and good revision 12::
648
648
649 hg bisect --bad 34
649 hg bisect --bad 34
650 hg bisect --good 12
650 hg bisect --good 12
651
651
652 - advance the current bisection by marking current revision as good or
652 - advance the current bisection by marking current revision as good or
653 bad::
653 bad::
654
654
655 hg bisect --good
655 hg bisect --good
656 hg bisect --bad
656 hg bisect --bad
657
657
658 - mark the current revision, or a known revision, to be skipped (e.g. if
658 - mark the current revision, or a known revision, to be skipped (e.g. if
659 that revision is not usable because of another issue)::
659 that revision is not usable because of another issue)::
660
660
661 hg bisect --skip
661 hg bisect --skip
662 hg bisect --skip 23
662 hg bisect --skip 23
663
663
664 - skip all revisions that do not touch directories ``foo`` or ``bar``::
664 - skip all revisions that do not touch directories ``foo`` or ``bar``::
665
665
666 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
666 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
667
667
668 - forget the current bisection::
668 - forget the current bisection::
669
669
670 hg bisect --reset
670 hg bisect --reset
671
671
672 - use 'make && make tests' to automatically find the first broken
672 - use 'make && make tests' to automatically find the first broken
673 revision::
673 revision::
674
674
675 hg bisect --reset
675 hg bisect --reset
676 hg bisect --bad 34
676 hg bisect --bad 34
677 hg bisect --good 12
677 hg bisect --good 12
678 hg bisect --command "make && make tests"
678 hg bisect --command "make && make tests"
679
679
680 - see all changesets whose states are already known in the current
680 - see all changesets whose states are already known in the current
681 bisection::
681 bisection::
682
682
683 hg log -r "bisect(pruned)"
683 hg log -r "bisect(pruned)"
684
684
685 - see the changeset currently being bisected (especially useful
685 - see the changeset currently being bisected (especially useful
686 if running with -U/--noupdate)::
686 if running with -U/--noupdate)::
687
687
688 hg log -r "bisect(current)"
688 hg log -r "bisect(current)"
689
689
690 - see all changesets that took part in the current bisection::
690 - see all changesets that took part in the current bisection::
691
691
692 hg log -r "bisect(range)"
692 hg log -r "bisect(range)"
693
693
694 - you can even get a nice graph::
694 - you can even get a nice graph::
695
695
696 hg log --graph -r "bisect(range)"
696 hg log --graph -r "bisect(range)"
697
697
698 See :hg:`help revsets` for more about the `bisect()` keyword.
698 See :hg:`help revsets` for more about the `bisect()` keyword.
699
699
700 Returns 0 on success.
700 Returns 0 on success.
701 """
701 """
702 def extendbisectrange(nodes, good):
702 def extendbisectrange(nodes, good):
703 # bisect is incomplete when it ends on a merge node and
703 # bisect is incomplete when it ends on a merge node and
704 # one of the parent was not checked.
704 # one of the parent was not checked.
705 parents = repo[nodes[0]].parents()
705 parents = repo[nodes[0]].parents()
706 if len(parents) > 1:
706 if len(parents) > 1:
707 if good:
707 if good:
708 side = state['bad']
708 side = state['bad']
709 else:
709 else:
710 side = state['good']
710 side = state['good']
711 num = len(set(i.node() for i in parents) & set(side))
711 num = len(set(i.node() for i in parents) & set(side))
712 if num == 1:
712 if num == 1:
713 return parents[0].ancestor(parents[1])
713 return parents[0].ancestor(parents[1])
714 return None
714 return None
715
715
716 def print_result(nodes, good):
716 def print_result(nodes, good):
717 displayer = cmdutil.show_changeset(ui, repo, {})
717 displayer = cmdutil.show_changeset(ui, repo, {})
718 if len(nodes) == 1:
718 if len(nodes) == 1:
719 # narrowed it down to a single revision
719 # narrowed it down to a single revision
720 if good:
720 if good:
721 ui.write(_("The first good revision is:\n"))
721 ui.write(_("The first good revision is:\n"))
722 else:
722 else:
723 ui.write(_("The first bad revision is:\n"))
723 ui.write(_("The first bad revision is:\n"))
724 displayer.show(repo[nodes[0]])
724 displayer.show(repo[nodes[0]])
725 extendnode = extendbisectrange(nodes, good)
725 extendnode = extendbisectrange(nodes, good)
726 if extendnode is not None:
726 if extendnode is not None:
727 ui.write(_('Not all ancestors of this changeset have been'
727 ui.write(_('Not all ancestors of this changeset have been'
728 ' checked.\nUse bisect --extend to continue the '
728 ' checked.\nUse bisect --extend to continue the '
729 'bisection from\nthe common ancestor, %s.\n')
729 'bisection from\nthe common ancestor, %s.\n')
730 % extendnode)
730 % extendnode)
731 else:
731 else:
732 # multiple possible revisions
732 # multiple possible revisions
733 if good:
733 if good:
734 ui.write(_("Due to skipped revisions, the first "
734 ui.write(_("Due to skipped revisions, the first "
735 "good revision could be any of:\n"))
735 "good revision could be any of:\n"))
736 else:
736 else:
737 ui.write(_("Due to skipped revisions, the first "
737 ui.write(_("Due to skipped revisions, the first "
738 "bad revision could be any of:\n"))
738 "bad revision could be any of:\n"))
739 for n in nodes:
739 for n in nodes:
740 displayer.show(repo[n])
740 displayer.show(repo[n])
741 displayer.close()
741 displayer.close()
742
742
743 def check_state(state, interactive=True):
743 def check_state(state, interactive=True):
744 if not state['good'] or not state['bad']:
744 if not state['good'] or not state['bad']:
745 if (good or bad or skip or reset) and interactive:
745 if (good or bad or skip or reset) and interactive:
746 return
746 return
747 if not state['good']:
747 if not state['good']:
748 raise util.Abort(_('cannot bisect (no known good revisions)'))
748 raise util.Abort(_('cannot bisect (no known good revisions)'))
749 else:
749 else:
750 raise util.Abort(_('cannot bisect (no known bad revisions)'))
750 raise util.Abort(_('cannot bisect (no known bad revisions)'))
751 return True
751 return True
752
752
753 # backward compatibility
753 # backward compatibility
754 if rev in "good bad reset init".split():
754 if rev in "good bad reset init".split():
755 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
755 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
756 cmd, rev, extra = rev, extra, None
756 cmd, rev, extra = rev, extra, None
757 if cmd == "good":
757 if cmd == "good":
758 good = True
758 good = True
759 elif cmd == "bad":
759 elif cmd == "bad":
760 bad = True
760 bad = True
761 else:
761 else:
762 reset = True
762 reset = True
763 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
763 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
764 raise util.Abort(_('incompatible arguments'))
764 raise util.Abort(_('incompatible arguments'))
765
765
766 cmdutil.checkunfinished(repo)
766 cmdutil.checkunfinished(repo)
767
767
768 if reset:
768 if reset:
769 p = repo.join("bisect.state")
769 p = repo.join("bisect.state")
770 if os.path.exists(p):
770 if os.path.exists(p):
771 os.unlink(p)
771 os.unlink(p)
772 return
772 return
773
773
774 state = hbisect.load_state(repo)
774 state = hbisect.load_state(repo)
775
775
776 if command:
776 if command:
777 changesets = 1
777 changesets = 1
778 if noupdate:
778 if noupdate:
779 try:
779 try:
780 node = state['current'][0]
780 node = state['current'][0]
781 except LookupError:
781 except LookupError:
782 raise util.Abort(_('current bisect revision is unknown - '
782 raise util.Abort(_('current bisect revision is unknown - '
783 'start a new bisect to fix'))
783 'start a new bisect to fix'))
784 else:
784 else:
785 node, p2 = repo.dirstate.parents()
785 node, p2 = repo.dirstate.parents()
786 if p2 != nullid:
786 if p2 != nullid:
787 raise util.Abort(_('current bisect revision is a merge'))
787 raise util.Abort(_('current bisect revision is a merge'))
788 try:
788 try:
789 while changesets:
789 while changesets:
790 # update state
790 # update state
791 state['current'] = [node]
791 state['current'] = [node]
792 hbisect.save_state(repo, state)
792 hbisect.save_state(repo, state)
793 status = ui.system(command, environ={'HG_NODE': hex(node)})
793 status = ui.system(command, environ={'HG_NODE': hex(node)})
794 if status == 125:
794 if status == 125:
795 transition = "skip"
795 transition = "skip"
796 elif status == 0:
796 elif status == 0:
797 transition = "good"
797 transition = "good"
798 # status < 0 means process was killed
798 # status < 0 means process was killed
799 elif status == 127:
799 elif status == 127:
800 raise util.Abort(_("failed to execute %s") % command)
800 raise util.Abort(_("failed to execute %s") % command)
801 elif status < 0:
801 elif status < 0:
802 raise util.Abort(_("%s killed") % command)
802 raise util.Abort(_("%s killed") % command)
803 else:
803 else:
804 transition = "bad"
804 transition = "bad"
805 ctx = scmutil.revsingle(repo, rev, node)
805 ctx = scmutil.revsingle(repo, rev, node)
806 rev = None # clear for future iterations
806 rev = None # clear for future iterations
807 state[transition].append(ctx.node())
807 state[transition].append(ctx.node())
808 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
808 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
809 check_state(state, interactive=False)
809 check_state(state, interactive=False)
810 # bisect
810 # bisect
811 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
811 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
812 # update to next check
812 # update to next check
813 node = nodes[0]
813 node = nodes[0]
814 if not noupdate:
814 if not noupdate:
815 cmdutil.bailifchanged(repo)
815 cmdutil.bailifchanged(repo)
816 hg.clean(repo, node, show_stats=False)
816 hg.clean(repo, node, show_stats=False)
817 finally:
817 finally:
818 state['current'] = [node]
818 state['current'] = [node]
819 hbisect.save_state(repo, state)
819 hbisect.save_state(repo, state)
820 print_result(nodes, bgood)
820 print_result(nodes, bgood)
821 return
821 return
822
822
823 # update state
823 # update state
824
824
825 if rev:
825 if rev:
826 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
826 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
827 else:
827 else:
828 nodes = [repo.lookup('.')]
828 nodes = [repo.lookup('.')]
829
829
830 if good or bad or skip:
830 if good or bad or skip:
831 if good:
831 if good:
832 state['good'] += nodes
832 state['good'] += nodes
833 elif bad:
833 elif bad:
834 state['bad'] += nodes
834 state['bad'] += nodes
835 elif skip:
835 elif skip:
836 state['skip'] += nodes
836 state['skip'] += nodes
837 hbisect.save_state(repo, state)
837 hbisect.save_state(repo, state)
838
838
839 if not check_state(state):
839 if not check_state(state):
840 return
840 return
841
841
842 # actually bisect
842 # actually bisect
843 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
843 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
844 if extend:
844 if extend:
845 if not changesets:
845 if not changesets:
846 extendnode = extendbisectrange(nodes, good)
846 extendnode = extendbisectrange(nodes, good)
847 if extendnode is not None:
847 if extendnode is not None:
848 ui.write(_("Extending search to changeset %d:%s\n")
848 ui.write(_("Extending search to changeset %d:%s\n")
849 % (extendnode.rev(), extendnode))
849 % (extendnode.rev(), extendnode))
850 state['current'] = [extendnode.node()]
850 state['current'] = [extendnode.node()]
851 hbisect.save_state(repo, state)
851 hbisect.save_state(repo, state)
852 if noupdate:
852 if noupdate:
853 return
853 return
854 cmdutil.bailifchanged(repo)
854 cmdutil.bailifchanged(repo)
855 return hg.clean(repo, extendnode.node())
855 return hg.clean(repo, extendnode.node())
856 raise util.Abort(_("nothing to extend"))
856 raise util.Abort(_("nothing to extend"))
857
857
858 if changesets == 0:
858 if changesets == 0:
859 print_result(nodes, good)
859 print_result(nodes, good)
860 else:
860 else:
861 assert len(nodes) == 1 # only a single node can be tested next
861 assert len(nodes) == 1 # only a single node can be tested next
862 node = nodes[0]
862 node = nodes[0]
863 # compute the approximate number of remaining tests
863 # compute the approximate number of remaining tests
864 tests, size = 0, 2
864 tests, size = 0, 2
865 while size <= changesets:
865 while size <= changesets:
866 tests, size = tests + 1, size * 2
866 tests, size = tests + 1, size * 2
867 rev = repo.changelog.rev(node)
867 rev = repo.changelog.rev(node)
868 ui.write(_("Testing changeset %d:%s "
868 ui.write(_("Testing changeset %d:%s "
869 "(%d changesets remaining, ~%d tests)\n")
869 "(%d changesets remaining, ~%d tests)\n")
870 % (rev, short(node), changesets, tests))
870 % (rev, short(node), changesets, tests))
871 state['current'] = [node]
871 state['current'] = [node]
872 hbisect.save_state(repo, state)
872 hbisect.save_state(repo, state)
873 if not noupdate:
873 if not noupdate:
874 cmdutil.bailifchanged(repo)
874 cmdutil.bailifchanged(repo)
875 return hg.clean(repo, node)
875 return hg.clean(repo, node)
876
876
877 @command('bookmarks|bookmark',
877 @command('bookmarks|bookmark',
878 [('f', 'force', False, _('force')),
878 [('f', 'force', False, _('force')),
879 ('r', 'rev', '', _('revision'), _('REV')),
879 ('r', 'rev', '', _('revision'), _('REV')),
880 ('d', 'delete', False, _('delete a given bookmark')),
880 ('d', 'delete', False, _('delete a given bookmark')),
881 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
881 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
882 ('i', 'inactive', False, _('mark a bookmark inactive')),
882 ('i', 'inactive', False, _('mark a bookmark inactive')),
883 ] + formatteropts,
883 ] + formatteropts,
884 _('hg bookmarks [OPTIONS]... [NAME]...'))
884 _('hg bookmarks [OPTIONS]... [NAME]...'))
885 def bookmark(ui, repo, *names, **opts):
885 def bookmark(ui, repo, *names, **opts):
886 '''create a new bookmark or list existing bookmarks
886 '''create a new bookmark or list existing bookmarks
887
887
888 Bookmarks are labels on changesets to help track lines of development.
888 Bookmarks are labels on changesets to help track lines of development.
889 Bookmarks are unversioned and can be moved, renamed and deleted.
889 Bookmarks are unversioned and can be moved, renamed and deleted.
890 Deleting or moving a bookmark has no effect on the associated changesets.
890 Deleting or moving a bookmark has no effect on the associated changesets.
891
891
892 Creating or updating to a bookmark causes it to be marked as 'active'.
892 Creating or updating to a bookmark causes it to be marked as 'active'.
893 The active bookmark is indicated with a '*'.
893 The active bookmark is indicated with a '*'.
894 When a commit is made, the active bookmark will advance to the new commit.
894 When a commit is made, the active bookmark will advance to the new commit.
895 A plain :hg:`update` will also advance an active bookmark, if possible.
895 A plain :hg:`update` will also advance an active bookmark, if possible.
896 Updating away from a bookmark will cause it to be deactivated.
896 Updating away from a bookmark will cause it to be deactivated.
897
897
898 Bookmarks can be pushed and pulled between repositories (see
898 Bookmarks can be pushed and pulled between repositories (see
899 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
899 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
900 diverged, a new 'divergent bookmark' of the form 'name@path' will
900 diverged, a new 'divergent bookmark' of the form 'name@path' will
901 be created. Using :hg:`merge` will resolve the divergence.
901 be created. Using :hg:`merge` will resolve the divergence.
902
902
903 A bookmark named '@' has the special property that :hg:`clone` will
903 A bookmark named '@' has the special property that :hg:`clone` will
904 check it out by default if it exists.
904 check it out by default if it exists.
905
905
906 .. container:: verbose
906 .. container:: verbose
907
907
908 Examples:
908 Examples:
909
909
910 - create an active bookmark for a new line of development::
910 - create an active bookmark for a new line of development::
911
911
912 hg book new-feature
912 hg book new-feature
913
913
914 - create an inactive bookmark as a place marker::
914 - create an inactive bookmark as a place marker::
915
915
916 hg book -i reviewed
916 hg book -i reviewed
917
917
918 - create an inactive bookmark on another changeset::
918 - create an inactive bookmark on another changeset::
919
919
920 hg book -r .^ tested
920 hg book -r .^ tested
921
921
922 - rename bookmark turkey to dinner::
922 - rename bookmark turkey to dinner::
923
923
924 hg book -m turkey dinner
924 hg book -m turkey dinner
925
925
926 - move the '@' bookmark from another branch::
926 - move the '@' bookmark from another branch::
927
927
928 hg book -f @
928 hg book -f @
929 '''
929 '''
930 force = opts.get('force')
930 force = opts.get('force')
931 rev = opts.get('rev')
931 rev = opts.get('rev')
932 delete = opts.get('delete')
932 delete = opts.get('delete')
933 rename = opts.get('rename')
933 rename = opts.get('rename')
934 inactive = opts.get('inactive')
934 inactive = opts.get('inactive')
935
935
936 def checkformat(mark):
936 def checkformat(mark):
937 mark = mark.strip()
937 mark = mark.strip()
938 if not mark:
938 if not mark:
939 raise util.Abort(_("bookmark names cannot consist entirely of "
939 raise util.Abort(_("bookmark names cannot consist entirely of "
940 "whitespace"))
940 "whitespace"))
941 scmutil.checknewlabel(repo, mark, 'bookmark')
941 scmutil.checknewlabel(repo, mark, 'bookmark')
942 return mark
942 return mark
943
943
944 def checkconflict(repo, mark, cur, force=False, target=None):
944 def checkconflict(repo, mark, cur, force=False, target=None):
945 if mark in marks and not force:
945 if mark in marks and not force:
946 if target:
946 if target:
947 if marks[mark] == target and target == cur:
947 if marks[mark] == target and target == cur:
948 # re-activating a bookmark
948 # re-activating a bookmark
949 return
949 return
950 anc = repo.changelog.ancestors([repo[target].rev()])
950 anc = repo.changelog.ancestors([repo[target].rev()])
951 bmctx = repo[marks[mark]]
951 bmctx = repo[marks[mark]]
952 divs = [repo[b].node() for b in marks
952 divs = [repo[b].node() for b in marks
953 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
953 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
954
954
955 # allow resolving a single divergent bookmark even if moving
955 # allow resolving a single divergent bookmark even if moving
956 # the bookmark across branches when a revision is specified
956 # the bookmark across branches when a revision is specified
957 # that contains a divergent bookmark
957 # that contains a divergent bookmark
958 if bmctx.rev() not in anc and target in divs:
958 if bmctx.rev() not in anc and target in divs:
959 bookmarks.deletedivergent(repo, [target], mark)
959 bookmarks.deletedivergent(repo, [target], mark)
960 return
960 return
961
961
962 deletefrom = [b for b in divs
962 deletefrom = [b for b in divs
963 if repo[b].rev() in anc or b == target]
963 if repo[b].rev() in anc or b == target]
964 bookmarks.deletedivergent(repo, deletefrom, mark)
964 bookmarks.deletedivergent(repo, deletefrom, mark)
965 if bookmarks.validdest(repo, bmctx, repo[target]):
965 if bookmarks.validdest(repo, bmctx, repo[target]):
966 ui.status(_("moving bookmark '%s' forward from %s\n") %
966 ui.status(_("moving bookmark '%s' forward from %s\n") %
967 (mark, short(bmctx.node())))
967 (mark, short(bmctx.node())))
968 return
968 return
969 raise util.Abort(_("bookmark '%s' already exists "
969 raise util.Abort(_("bookmark '%s' already exists "
970 "(use -f to force)") % mark)
970 "(use -f to force)") % mark)
971 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
971 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
972 and not force):
972 and not force):
973 raise util.Abort(
973 raise util.Abort(
974 _("a bookmark cannot have the name of an existing branch"))
974 _("a bookmark cannot have the name of an existing branch"))
975
975
976 if delete and rename:
976 if delete and rename:
977 raise util.Abort(_("--delete and --rename are incompatible"))
977 raise util.Abort(_("--delete and --rename are incompatible"))
978 if delete and rev:
978 if delete and rev:
979 raise util.Abort(_("--rev is incompatible with --delete"))
979 raise util.Abort(_("--rev is incompatible with --delete"))
980 if rename and rev:
980 if rename and rev:
981 raise util.Abort(_("--rev is incompatible with --rename"))
981 raise util.Abort(_("--rev is incompatible with --rename"))
982 if not names and (delete or rev):
982 if not names and (delete or rev):
983 raise util.Abort(_("bookmark name required"))
983 raise util.Abort(_("bookmark name required"))
984
984
985 if delete or rename or names or inactive:
985 if delete or rename or names or inactive:
986 wlock = lock = tr = None
986 wlock = lock = tr = None
987 try:
987 try:
988 wlock = repo.wlock()
988 wlock = repo.wlock()
989 lock = repo.lock()
989 lock = repo.lock()
990 cur = repo.changectx('.').node()
990 cur = repo.changectx('.').node()
991 marks = repo._bookmarks
991 marks = repo._bookmarks
992 if delete:
992 if delete:
993 tr = repo.transaction('bookmark')
993 tr = repo.transaction('bookmark')
994 for mark in names:
994 for mark in names:
995 if mark not in marks:
995 if mark not in marks:
996 raise util.Abort(_("bookmark '%s' does not exist") %
996 raise util.Abort(_("bookmark '%s' does not exist") %
997 mark)
997 mark)
998 if mark == repo._activebookmark:
998 if mark == repo._activebookmark:
999 bookmarks.deactivate(repo)
999 bookmarks.deactivate(repo)
1000 del marks[mark]
1000 del marks[mark]
1001
1001
1002 elif rename:
1002 elif rename:
1003 tr = repo.transaction('bookmark')
1003 tr = repo.transaction('bookmark')
1004 if not names:
1004 if not names:
1005 raise util.Abort(_("new bookmark name required"))
1005 raise util.Abort(_("new bookmark name required"))
1006 elif len(names) > 1:
1006 elif len(names) > 1:
1007 raise util.Abort(_("only one new bookmark name allowed"))
1007 raise util.Abort(_("only one new bookmark name allowed"))
1008 mark = checkformat(names[0])
1008 mark = checkformat(names[0])
1009 if rename not in marks:
1009 if rename not in marks:
1010 raise util.Abort(_("bookmark '%s' does not exist") % rename)
1010 raise util.Abort(_("bookmark '%s' does not exist") % rename)
1011 checkconflict(repo, mark, cur, force)
1011 checkconflict(repo, mark, cur, force)
1012 marks[mark] = marks[rename]
1012 marks[mark] = marks[rename]
1013 if repo._activebookmark == rename and not inactive:
1013 if repo._activebookmark == rename and not inactive:
1014 bookmarks.activate(repo, mark)
1014 bookmarks.activate(repo, mark)
1015 del marks[rename]
1015 del marks[rename]
1016 elif names:
1016 elif names:
1017 tr = repo.transaction('bookmark')
1017 tr = repo.transaction('bookmark')
1018 newact = None
1018 newact = None
1019 for mark in names:
1019 for mark in names:
1020 mark = checkformat(mark)
1020 mark = checkformat(mark)
1021 if newact is None:
1021 if newact is None:
1022 newact = mark
1022 newact = mark
1023 if inactive and mark == repo._activebookmark:
1023 if inactive and mark == repo._activebookmark:
1024 bookmarks.deactivate(repo)
1024 bookmarks.deactivate(repo)
1025 return
1025 return
1026 tgt = cur
1026 tgt = cur
1027 if rev:
1027 if rev:
1028 tgt = scmutil.revsingle(repo, rev).node()
1028 tgt = scmutil.revsingle(repo, rev).node()
1029 checkconflict(repo, mark, cur, force, tgt)
1029 checkconflict(repo, mark, cur, force, tgt)
1030 marks[mark] = tgt
1030 marks[mark] = tgt
1031 if not inactive and cur == marks[newact] and not rev:
1031 if not inactive and cur == marks[newact] and not rev:
1032 bookmarks.activate(repo, newact)
1032 bookmarks.activate(repo, newact)
1033 elif cur != tgt and newact == repo._activebookmark:
1033 elif cur != tgt and newact == repo._activebookmark:
1034 bookmarks.deactivate(repo)
1034 bookmarks.deactivate(repo)
1035 elif inactive:
1035 elif inactive:
1036 if len(marks) == 0:
1036 if len(marks) == 0:
1037 ui.status(_("no bookmarks set\n"))
1037 ui.status(_("no bookmarks set\n"))
1038 elif not repo._activebookmark:
1038 elif not repo._activebookmark:
1039 ui.status(_("no active bookmark\n"))
1039 ui.status(_("no active bookmark\n"))
1040 else:
1040 else:
1041 bookmarks.deactivate(repo)
1041 bookmarks.deactivate(repo)
1042 if tr is not None:
1042 if tr is not None:
1043 marks.recordchange(tr)
1043 marks.recordchange(tr)
1044 tr.close()
1044 tr.close()
1045 finally:
1045 finally:
1046 lockmod.release(tr, lock, wlock)
1046 lockmod.release(tr, lock, wlock)
1047 else: # show bookmarks
1047 else: # show bookmarks
1048 fm = ui.formatter('bookmarks', opts)
1048 fm = ui.formatter('bookmarks', opts)
1049 hexfn = fm.hexfunc
1049 hexfn = fm.hexfunc
1050 marks = repo._bookmarks
1050 marks = repo._bookmarks
1051 if len(marks) == 0 and not fm:
1051 if len(marks) == 0 and not fm:
1052 ui.status(_("no bookmarks set\n"))
1052 ui.status(_("no bookmarks set\n"))
1053 for bmark, n in sorted(marks.iteritems()):
1053 for bmark, n in sorted(marks.iteritems()):
1054 active = repo._activebookmark
1054 active = repo._activebookmark
1055 if bmark == active:
1055 if bmark == active:
1056 prefix, label = '*', activebookmarklabel
1056 prefix, label = '*', activebookmarklabel
1057 else:
1057 else:
1058 prefix, label = ' ', ''
1058 prefix, label = ' ', ''
1059
1059
1060 fm.startitem()
1060 fm.startitem()
1061 if not ui.quiet:
1061 if not ui.quiet:
1062 fm.plain(' %s ' % prefix, label=label)
1062 fm.plain(' %s ' % prefix, label=label)
1063 fm.write('bookmark', '%s', bmark, label=label)
1063 fm.write('bookmark', '%s', bmark, label=label)
1064 pad = " " * (25 - encoding.colwidth(bmark))
1064 pad = " " * (25 - encoding.colwidth(bmark))
1065 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1065 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1066 repo.changelog.rev(n), hexfn(n), label=label)
1066 repo.changelog.rev(n), hexfn(n), label=label)
1067 fm.data(active=(bmark == active))
1067 fm.data(active=(bmark == active))
1068 fm.plain('\n')
1068 fm.plain('\n')
1069 fm.end()
1069 fm.end()
1070
1070
1071 @command('branch',
1071 @command('branch',
1072 [('f', 'force', None,
1072 [('f', 'force', None,
1073 _('set branch name even if it shadows an existing branch')),
1073 _('set branch name even if it shadows an existing branch')),
1074 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1074 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1075 _('[-fC] [NAME]'))
1075 _('[-fC] [NAME]'))
1076 def branch(ui, repo, label=None, **opts):
1076 def branch(ui, repo, label=None, **opts):
1077 """set or show the current branch name
1077 """set or show the current branch name
1078
1078
1079 .. note::
1079 .. note::
1080
1080
1081 Branch names are permanent and global. Use :hg:`bookmark` to create a
1081 Branch names are permanent and global. Use :hg:`bookmark` to create a
1082 light-weight bookmark instead. See :hg:`help glossary` for more
1082 light-weight bookmark instead. See :hg:`help glossary` for more
1083 information about named branches and bookmarks.
1083 information about named branches and bookmarks.
1084
1084
1085 With no argument, show the current branch name. With one argument,
1085 With no argument, show the current branch name. With one argument,
1086 set the working directory branch name (the branch will not exist
1086 set the working directory branch name (the branch will not exist
1087 in the repository until the next commit). Standard practice
1087 in the repository until the next commit). Standard practice
1088 recommends that primary development take place on the 'default'
1088 recommends that primary development take place on the 'default'
1089 branch.
1089 branch.
1090
1090
1091 Unless -f/--force is specified, branch will not let you set a
1091 Unless -f/--force is specified, branch will not let you set a
1092 branch name that already exists.
1092 branch name that already exists.
1093
1093
1094 Use -C/--clean to reset the working directory branch to that of
1094 Use -C/--clean to reset the working directory branch to that of
1095 the parent of the working directory, negating a previous branch
1095 the parent of the working directory, negating a previous branch
1096 change.
1096 change.
1097
1097
1098 Use the command :hg:`update` to switch to an existing branch. Use
1098 Use the command :hg:`update` to switch to an existing branch. Use
1099 :hg:`commit --close-branch` to mark this branch head as closed.
1099 :hg:`commit --close-branch` to mark this branch head as closed.
1100 When all heads of the branch are closed, the branch will be
1100 When all heads of the branch are closed, the branch will be
1101 considered closed.
1101 considered closed.
1102
1102
1103 Returns 0 on success.
1103 Returns 0 on success.
1104 """
1104 """
1105 if label:
1105 if label:
1106 label = label.strip()
1106 label = label.strip()
1107
1107
1108 if not opts.get('clean') and not label:
1108 if not opts.get('clean') and not label:
1109 ui.write("%s\n" % repo.dirstate.branch())
1109 ui.write("%s\n" % repo.dirstate.branch())
1110 return
1110 return
1111
1111
1112 wlock = repo.wlock()
1112 wlock = repo.wlock()
1113 try:
1113 try:
1114 if opts.get('clean'):
1114 if opts.get('clean'):
1115 label = repo[None].p1().branch()
1115 label = repo[None].p1().branch()
1116 repo.dirstate.setbranch(label)
1116 repo.dirstate.setbranch(label)
1117 ui.status(_('reset working directory to branch %s\n') % label)
1117 ui.status(_('reset working directory to branch %s\n') % label)
1118 elif label:
1118 elif label:
1119 if not opts.get('force') and label in repo.branchmap():
1119 if not opts.get('force') and label in repo.branchmap():
1120 if label not in [p.branch() for p in repo.parents()]:
1120 if label not in [p.branch() for p in repo.parents()]:
1121 raise util.Abort(_('a branch of the same name already'
1121 raise util.Abort(_('a branch of the same name already'
1122 ' exists'),
1122 ' exists'),
1123 # i18n: "it" refers to an existing branch
1123 # i18n: "it" refers to an existing branch
1124 hint=_("use 'hg update' to switch to it"))
1124 hint=_("use 'hg update' to switch to it"))
1125 scmutil.checknewlabel(repo, label, 'branch')
1125 scmutil.checknewlabel(repo, label, 'branch')
1126 repo.dirstate.setbranch(label)
1126 repo.dirstate.setbranch(label)
1127 ui.status(_('marked working directory as branch %s\n') % label)
1127 ui.status(_('marked working directory as branch %s\n') % label)
1128
1128
1129 # find any open named branches aside from default
1129 # find any open named branches aside from default
1130 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1130 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1131 if n != "default" and not c]
1131 if n != "default" and not c]
1132 if not others:
1132 if not others:
1133 ui.status(_('(branches are permanent and global, '
1133 ui.status(_('(branches are permanent and global, '
1134 'did you want a bookmark?)\n'))
1134 'did you want a bookmark?)\n'))
1135 finally:
1135 finally:
1136 wlock.release()
1136 wlock.release()
1137
1137
1138 @command('branches',
1138 @command('branches',
1139 [('a', 'active', False,
1139 [('a', 'active', False,
1140 _('show only branches that have unmerged heads (DEPRECATED)')),
1140 _('show only branches that have unmerged heads (DEPRECATED)')),
1141 ('c', 'closed', False, _('show normal and closed branches')),
1141 ('c', 'closed', False, _('show normal and closed branches')),
1142 ] + formatteropts,
1142 ] + formatteropts,
1143 _('[-ac]'))
1143 _('[-ac]'))
1144 def branches(ui, repo, active=False, closed=False, **opts):
1144 def branches(ui, repo, active=False, closed=False, **opts):
1145 """list repository named branches
1145 """list repository named branches
1146
1146
1147 List the repository's named branches, indicating which ones are
1147 List the repository's named branches, indicating which ones are
1148 inactive. If -c/--closed is specified, also list branches which have
1148 inactive. If -c/--closed is specified, also list branches which have
1149 been marked closed (see :hg:`commit --close-branch`).
1149 been marked closed (see :hg:`commit --close-branch`).
1150
1150
1151 Use the command :hg:`update` to switch to an existing branch.
1151 Use the command :hg:`update` to switch to an existing branch.
1152
1152
1153 Returns 0.
1153 Returns 0.
1154 """
1154 """
1155
1155
1156 fm = ui.formatter('branches', opts)
1156 fm = ui.formatter('branches', opts)
1157 hexfunc = fm.hexfunc
1157 hexfunc = fm.hexfunc
1158
1158
1159 allheads = set(repo.heads())
1159 allheads = set(repo.heads())
1160 branches = []
1160 branches = []
1161 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1161 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1162 isactive = not isclosed and bool(set(heads) & allheads)
1162 isactive = not isclosed and bool(set(heads) & allheads)
1163 branches.append((tag, repo[tip], isactive, not isclosed))
1163 branches.append((tag, repo[tip], isactive, not isclosed))
1164 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1164 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1165 reverse=True)
1165 reverse=True)
1166
1166
1167 for tag, ctx, isactive, isopen in branches:
1167 for tag, ctx, isactive, isopen in branches:
1168 if active and not isactive:
1168 if active and not isactive:
1169 continue
1169 continue
1170 if isactive:
1170 if isactive:
1171 label = 'branches.active'
1171 label = 'branches.active'
1172 notice = ''
1172 notice = ''
1173 elif not isopen:
1173 elif not isopen:
1174 if not closed:
1174 if not closed:
1175 continue
1175 continue
1176 label = 'branches.closed'
1176 label = 'branches.closed'
1177 notice = _(' (closed)')
1177 notice = _(' (closed)')
1178 else:
1178 else:
1179 label = 'branches.inactive'
1179 label = 'branches.inactive'
1180 notice = _(' (inactive)')
1180 notice = _(' (inactive)')
1181 current = (tag == repo.dirstate.branch())
1181 current = (tag == repo.dirstate.branch())
1182 if current:
1182 if current:
1183 label = 'branches.current'
1183 label = 'branches.current'
1184
1184
1185 fm.startitem()
1185 fm.startitem()
1186 fm.write('branch', '%s', tag, label=label)
1186 fm.write('branch', '%s', tag, label=label)
1187 rev = ctx.rev()
1187 rev = ctx.rev()
1188 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1188 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1189 fmt = ' ' * padsize + ' %d:%s'
1189 fmt = ' ' * padsize + ' %d:%s'
1190 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1190 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1191 label='log.changeset changeset.%s' % ctx.phasestr())
1191 label='log.changeset changeset.%s' % ctx.phasestr())
1192 fm.data(active=isactive, closed=not isopen, current=current)
1192 fm.data(active=isactive, closed=not isopen, current=current)
1193 if not ui.quiet:
1193 if not ui.quiet:
1194 fm.plain(notice)
1194 fm.plain(notice)
1195 fm.plain('\n')
1195 fm.plain('\n')
1196 fm.end()
1196 fm.end()
1197
1197
1198 @command('bundle',
1198 @command('bundle',
1199 [('f', 'force', None, _('run even when the destination is unrelated')),
1199 [('f', 'force', None, _('run even when the destination is unrelated')),
1200 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1200 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1201 _('REV')),
1201 _('REV')),
1202 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1202 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1203 _('BRANCH')),
1203 _('BRANCH')),
1204 ('', 'base', [],
1204 ('', 'base', [],
1205 _('a base changeset assumed to be available at the destination'),
1205 _('a base changeset assumed to be available at the destination'),
1206 _('REV')),
1206 _('REV')),
1207 ('a', 'all', None, _('bundle all changesets in the repository')),
1207 ('a', 'all', None, _('bundle all changesets in the repository')),
1208 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1208 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1209 ] + remoteopts,
1209 ] + remoteopts,
1210 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1210 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1211 def bundle(ui, repo, fname, dest=None, **opts):
1211 def bundle(ui, repo, fname, dest=None, **opts):
1212 """create a changegroup file
1212 """create a changegroup file
1213
1213
1214 Generate a compressed changegroup file collecting changesets not
1214 Generate a compressed changegroup file collecting changesets not
1215 known to be in another repository.
1215 known to be in another repository.
1216
1216
1217 If you omit the destination repository, then hg assumes the
1217 If you omit the destination repository, then hg assumes the
1218 destination will have all the nodes you specify with --base
1218 destination will have all the nodes you specify with --base
1219 parameters. To create a bundle containing all changesets, use
1219 parameters. To create a bundle containing all changesets, use
1220 -a/--all (or --base null).
1220 -a/--all (or --base null).
1221
1221
1222 You can change bundle format with the -t/--type option. You can
1222 You can change bundle format with the -t/--type option. You can
1223 specify a compression, a bundle version or both using a dash
1223 specify a compression, a bundle version or both using a dash
1224 (comp-version). The available compression methods are: none, bzip2,
1224 (comp-version). The available compression methods are: none, bzip2,
1225 and gzip (by default, bundles are compressed using bzip2). The
1225 and gzip (by default, bundles are compressed using bzip2). The
1226 available format are: v1, v2 (default to most suitable).
1226 available format are: v1, v2 (default to most suitable).
1227
1227
1228 The bundle file can then be transferred using conventional means
1228 The bundle file can then be transferred using conventional means
1229 and applied to another repository with the unbundle or pull
1229 and applied to another repository with the unbundle or pull
1230 command. This is useful when direct push and pull are not
1230 command. This is useful when direct push and pull are not
1231 available or when exporting an entire repository is undesirable.
1231 available or when exporting an entire repository is undesirable.
1232
1232
1233 Applying bundles preserves all changeset contents including
1233 Applying bundles preserves all changeset contents including
1234 permissions, copy/rename information, and revision history.
1234 permissions, copy/rename information, and revision history.
1235
1235
1236 Returns 0 on success, 1 if no changes found.
1236 Returns 0 on success, 1 if no changes found.
1237 """
1237 """
1238 revs = None
1238 revs = None
1239 if 'rev' in opts:
1239 if 'rev' in opts:
1240 revs = scmutil.revrange(repo, opts['rev'])
1240 revs = scmutil.revrange(repo, opts['rev'])
1241
1241
1242 bundletype = opts.get('type', 'bzip2').lower()
1242 bundletype = opts.get('type', 'bzip2').lower()
1243 cgversion, bcompression = cmdutil.parsebundletype(repo, bundletype)
1243 cgversion, bcompression = cmdutil.parsebundletype(repo, bundletype)
1244
1244
1245 if opts.get('all'):
1245 if opts.get('all'):
1246 base = ['null']
1246 base = ['null']
1247 else:
1247 else:
1248 base = scmutil.revrange(repo, opts.get('base'))
1248 base = scmutil.revrange(repo, opts.get('base'))
1249 # TODO: get desired bundlecaps from command line.
1249 # TODO: get desired bundlecaps from command line.
1250 bundlecaps = None
1250 bundlecaps = None
1251 if base:
1251 if base:
1252 if dest:
1252 if dest:
1253 raise util.Abort(_("--base is incompatible with specifying "
1253 raise util.Abort(_("--base is incompatible with specifying "
1254 "a destination"))
1254 "a destination"))
1255 common = [repo.lookup(rev) for rev in base]
1255 common = [repo.lookup(rev) for rev in base]
1256 heads = revs and map(repo.lookup, revs) or revs
1256 heads = revs and map(repo.lookup, revs) or revs
1257 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1257 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1258 common=common, bundlecaps=bundlecaps,
1258 common=common, bundlecaps=bundlecaps,
1259 version=cgversion)
1259 version=cgversion)
1260 outgoing = None
1260 outgoing = None
1261 else:
1261 else:
1262 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1262 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1263 dest, branches = hg.parseurl(dest, opts.get('branch'))
1263 dest, branches = hg.parseurl(dest, opts.get('branch'))
1264 other = hg.peer(repo, opts, dest)
1264 other = hg.peer(repo, opts, dest)
1265 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1265 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1266 heads = revs and map(repo.lookup, revs) or revs
1266 heads = revs and map(repo.lookup, revs) or revs
1267 outgoing = discovery.findcommonoutgoing(repo, other,
1267 outgoing = discovery.findcommonoutgoing(repo, other,
1268 onlyheads=heads,
1268 onlyheads=heads,
1269 force=opts.get('force'),
1269 force=opts.get('force'),
1270 portable=True)
1270 portable=True)
1271 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1271 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1272 bundlecaps, version=cgversion)
1272 bundlecaps, version=cgversion)
1273 if not cg:
1273 if not cg:
1274 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1274 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1275 return 1
1275 return 1
1276
1276
1277 if cgversion == '01': #bundle1
1277 if cgversion == '01': #bundle1
1278 if bcompression is None:
1278 if bcompression is None:
1279 bcompression = 'UN'
1279 bcompression = 'UN'
1280 bversion = 'HG10' + bcompression
1280 bversion = 'HG10' + bcompression
1281 bcompression = None
1281 bcompression = None
1282 else:
1282 else:
1283 assert cgversion == '02'
1283 assert cgversion == '02'
1284 bversion = 'HG20'
1284 bversion = 'HG20'
1285
1285
1286
1286
1287 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1287 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1288
1288
1289 @command('cat',
1289 @command('cat',
1290 [('o', 'output', '',
1290 [('o', 'output', '',
1291 _('print output to file with formatted name'), _('FORMAT')),
1291 _('print output to file with formatted name'), _('FORMAT')),
1292 ('r', 'rev', '', _('print the given revision'), _('REV')),
1292 ('r', 'rev', '', _('print the given revision'), _('REV')),
1293 ('', 'decode', None, _('apply any matching decode filter')),
1293 ('', 'decode', None, _('apply any matching decode filter')),
1294 ] + walkopts,
1294 ] + walkopts,
1295 _('[OPTION]... FILE...'),
1295 _('[OPTION]... FILE...'),
1296 inferrepo=True)
1296 inferrepo=True)
1297 def cat(ui, repo, file1, *pats, **opts):
1297 def cat(ui, repo, file1, *pats, **opts):
1298 """output the current or given revision of files
1298 """output the current or given revision of files
1299
1299
1300 Print the specified files as they were at the given revision. If
1300 Print the specified files as they were at the given revision. If
1301 no revision is given, the parent of the working directory is used.
1301 no revision is given, the parent of the working directory is used.
1302
1302
1303 Output may be to a file, in which case the name of the file is
1303 Output may be to a file, in which case the name of the file is
1304 given using a format string. The formatting rules as follows:
1304 given using a format string. The formatting rules as follows:
1305
1305
1306 :``%%``: literal "%" character
1306 :``%%``: literal "%" character
1307 :``%s``: basename of file being printed
1307 :``%s``: basename of file being printed
1308 :``%d``: dirname of file being printed, or '.' if in repository root
1308 :``%d``: dirname of file being printed, or '.' if in repository root
1309 :``%p``: root-relative path name of file being printed
1309 :``%p``: root-relative path name of file being printed
1310 :``%H``: changeset hash (40 hexadecimal digits)
1310 :``%H``: changeset hash (40 hexadecimal digits)
1311 :``%R``: changeset revision number
1311 :``%R``: changeset revision number
1312 :``%h``: short-form changeset hash (12 hexadecimal digits)
1312 :``%h``: short-form changeset hash (12 hexadecimal digits)
1313 :``%r``: zero-padded changeset revision number
1313 :``%r``: zero-padded changeset revision number
1314 :``%b``: basename of the exporting repository
1314 :``%b``: basename of the exporting repository
1315
1315
1316 Returns 0 on success.
1316 Returns 0 on success.
1317 """
1317 """
1318 ctx = scmutil.revsingle(repo, opts.get('rev'))
1318 ctx = scmutil.revsingle(repo, opts.get('rev'))
1319 m = scmutil.match(ctx, (file1,) + pats, opts)
1319 m = scmutil.match(ctx, (file1,) + pats, opts)
1320
1320
1321 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1321 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1322
1322
1323 @command('^clone',
1323 @command('^clone',
1324 [('U', 'noupdate', None, _('the clone will include an empty working '
1324 [('U', 'noupdate', None, _('the clone will include an empty working '
1325 'directory (only a repository)')),
1325 'directory (only a repository)')),
1326 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1326 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1327 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1327 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1328 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1328 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1329 ('', 'pull', None, _('use pull protocol to copy metadata')),
1329 ('', 'pull', None, _('use pull protocol to copy metadata')),
1330 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1330 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1331 ] + remoteopts,
1331 ] + remoteopts,
1332 _('[OPTION]... SOURCE [DEST]'),
1332 _('[OPTION]... SOURCE [DEST]'),
1333 norepo=True)
1333 norepo=True)
1334 def clone(ui, source, dest=None, **opts):
1334 def clone(ui, source, dest=None, **opts):
1335 """make a copy of an existing repository
1335 """make a copy of an existing repository
1336
1336
1337 Create a copy of an existing repository in a new directory.
1337 Create a copy of an existing repository in a new directory.
1338
1338
1339 If no destination directory name is specified, it defaults to the
1339 If no destination directory name is specified, it defaults to the
1340 basename of the source.
1340 basename of the source.
1341
1341
1342 The location of the source is added to the new repository's
1342 The location of the source is added to the new repository's
1343 ``.hg/hgrc`` file, as the default to be used for future pulls.
1343 ``.hg/hgrc`` file, as the default to be used for future pulls.
1344
1344
1345 Only local paths and ``ssh://`` URLs are supported as
1345 Only local paths and ``ssh://`` URLs are supported as
1346 destinations. For ``ssh://`` destinations, no working directory or
1346 destinations. For ``ssh://`` destinations, no working directory or
1347 ``.hg/hgrc`` will be created on the remote side.
1347 ``.hg/hgrc`` will be created on the remote side.
1348
1348
1349 To pull only a subset of changesets, specify one or more revisions
1349 To pull only a subset of changesets, specify one or more revisions
1350 identifiers with -r/--rev or branches with -b/--branch. The
1350 identifiers with -r/--rev or branches with -b/--branch. The
1351 resulting clone will contain only the specified changesets and
1351 resulting clone will contain only the specified changesets and
1352 their ancestors. These options (or 'clone src#rev dest') imply
1352 their ancestors. These options (or 'clone src#rev dest') imply
1353 --pull, even for local source repositories. Note that specifying a
1353 --pull, even for local source repositories. Note that specifying a
1354 tag will include the tagged changeset but not the changeset
1354 tag will include the tagged changeset but not the changeset
1355 containing the tag.
1355 containing the tag.
1356
1356
1357 If the source repository has a bookmark called '@' set, that
1357 If the source repository has a bookmark called '@' set, that
1358 revision will be checked out in the new repository by default.
1358 revision will be checked out in the new repository by default.
1359
1359
1360 To check out a particular version, use -u/--update, or
1360 To check out a particular version, use -u/--update, or
1361 -U/--noupdate to create a clone with no working directory.
1361 -U/--noupdate to create a clone with no working directory.
1362
1362
1363 .. container:: verbose
1363 .. container:: verbose
1364
1364
1365 For efficiency, hardlinks are used for cloning whenever the
1365 For efficiency, hardlinks are used for cloning whenever the
1366 source and destination are on the same filesystem (note this
1366 source and destination are on the same filesystem (note this
1367 applies only to the repository data, not to the working
1367 applies only to the repository data, not to the working
1368 directory). Some filesystems, such as AFS, implement hardlinking
1368 directory). Some filesystems, such as AFS, implement hardlinking
1369 incorrectly, but do not report errors. In these cases, use the
1369 incorrectly, but do not report errors. In these cases, use the
1370 --pull option to avoid hardlinking.
1370 --pull option to avoid hardlinking.
1371
1371
1372 In some cases, you can clone repositories and the working
1372 In some cases, you can clone repositories and the working
1373 directory using full hardlinks with ::
1373 directory using full hardlinks with ::
1374
1374
1375 $ cp -al REPO REPOCLONE
1375 $ cp -al REPO REPOCLONE
1376
1376
1377 This is the fastest way to clone, but it is not always safe. The
1377 This is the fastest way to clone, but it is not always safe. The
1378 operation is not atomic (making sure REPO is not modified during
1378 operation is not atomic (making sure REPO is not modified during
1379 the operation is up to you) and you have to make sure your
1379 the operation is up to you) and you have to make sure your
1380 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1380 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1381 so). Also, this is not compatible with certain extensions that
1381 so). Also, this is not compatible with certain extensions that
1382 place their metadata under the .hg directory, such as mq.
1382 place their metadata under the .hg directory, such as mq.
1383
1383
1384 Mercurial will update the working directory to the first applicable
1384 Mercurial will update the working directory to the first applicable
1385 revision from this list:
1385 revision from this list:
1386
1386
1387 a) null if -U or the source repository has no changesets
1387 a) null if -U or the source repository has no changesets
1388 b) if -u . and the source repository is local, the first parent of
1388 b) if -u . and the source repository is local, the first parent of
1389 the source repository's working directory
1389 the source repository's working directory
1390 c) the changeset specified with -u (if a branch name, this means the
1390 c) the changeset specified with -u (if a branch name, this means the
1391 latest head of that branch)
1391 latest head of that branch)
1392 d) the changeset specified with -r
1392 d) the changeset specified with -r
1393 e) the tipmost head specified with -b
1393 e) the tipmost head specified with -b
1394 f) the tipmost head specified with the url#branch source syntax
1394 f) the tipmost head specified with the url#branch source syntax
1395 g) the revision marked with the '@' bookmark, if present
1395 g) the revision marked with the '@' bookmark, if present
1396 h) the tipmost head of the default branch
1396 h) the tipmost head of the default branch
1397 i) tip
1397 i) tip
1398
1398
1399 Examples:
1399 Examples:
1400
1400
1401 - clone a remote repository to a new directory named hg/::
1401 - clone a remote repository to a new directory named hg/::
1402
1402
1403 hg clone http://selenic.com/hg
1403 hg clone http://selenic.com/hg
1404
1404
1405 - create a lightweight local clone::
1405 - create a lightweight local clone::
1406
1406
1407 hg clone project/ project-feature/
1407 hg clone project/ project-feature/
1408
1408
1409 - clone from an absolute path on an ssh server (note double-slash)::
1409 - clone from an absolute path on an ssh server (note double-slash)::
1410
1410
1411 hg clone ssh://user@server//home/projects/alpha/
1411 hg clone ssh://user@server//home/projects/alpha/
1412
1412
1413 - do a high-speed clone over a LAN while checking out a
1413 - do a high-speed clone over a LAN while checking out a
1414 specified version::
1414 specified version::
1415
1415
1416 hg clone --uncompressed http://server/repo -u 1.5
1416 hg clone --uncompressed http://server/repo -u 1.5
1417
1417
1418 - create a repository without changesets after a particular revision::
1418 - create a repository without changesets after a particular revision::
1419
1419
1420 hg clone -r 04e544 experimental/ good/
1420 hg clone -r 04e544 experimental/ good/
1421
1421
1422 - clone (and track) a particular named branch::
1422 - clone (and track) a particular named branch::
1423
1423
1424 hg clone http://selenic.com/hg#stable
1424 hg clone http://selenic.com/hg#stable
1425
1425
1426 See :hg:`help urls` for details on specifying URLs.
1426 See :hg:`help urls` for details on specifying URLs.
1427
1427
1428 Returns 0 on success.
1428 Returns 0 on success.
1429 """
1429 """
1430 if opts.get('noupdate') and opts.get('updaterev'):
1430 if opts.get('noupdate') and opts.get('updaterev'):
1431 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1431 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1432
1432
1433 r = hg.clone(ui, opts, source, dest,
1433 r = hg.clone(ui, opts, source, dest,
1434 pull=opts.get('pull'),
1434 pull=opts.get('pull'),
1435 stream=opts.get('uncompressed'),
1435 stream=opts.get('uncompressed'),
1436 rev=opts.get('rev'),
1436 rev=opts.get('rev'),
1437 update=opts.get('updaterev') or not opts.get('noupdate'),
1437 update=opts.get('updaterev') or not opts.get('noupdate'),
1438 branch=opts.get('branch'),
1438 branch=opts.get('branch'),
1439 shareopts=opts.get('shareopts'))
1439 shareopts=opts.get('shareopts'))
1440
1440
1441 return r is None
1441 return r is None
1442
1442
1443 @command('^commit|ci',
1443 @command('^commit|ci',
1444 [('A', 'addremove', None,
1444 [('A', 'addremove', None,
1445 _('mark new/missing files as added/removed before committing')),
1445 _('mark new/missing files as added/removed before committing')),
1446 ('', 'close-branch', None,
1446 ('', 'close-branch', None,
1447 _('mark a branch head as closed')),
1447 _('mark a branch head as closed')),
1448 ('', 'amend', None, _('amend the parent of the working directory')),
1448 ('', 'amend', None, _('amend the parent of the working directory')),
1449 ('s', 'secret', None, _('use the secret phase for committing')),
1449 ('s', 'secret', None, _('use the secret phase for committing')),
1450 ('e', 'edit', None, _('invoke editor on commit messages')),
1450 ('e', 'edit', None, _('invoke editor on commit messages')),
1451 ('i', 'interactive', None, _('use interactive mode')),
1451 ('i', 'interactive', None, _('use interactive mode')),
1452 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1452 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1453 _('[OPTION]... [FILE]...'),
1453 _('[OPTION]... [FILE]...'),
1454 inferrepo=True)
1454 inferrepo=True)
1455 def commit(ui, repo, *pats, **opts):
1455 def commit(ui, repo, *pats, **opts):
1456 """commit the specified files or all outstanding changes
1456 """commit the specified files or all outstanding changes
1457
1457
1458 Commit changes to the given files into the repository. Unlike a
1458 Commit changes to the given files into the repository. Unlike a
1459 centralized SCM, this operation is a local operation. See
1459 centralized SCM, this operation is a local operation. See
1460 :hg:`push` for a way to actively distribute your changes.
1460 :hg:`push` for a way to actively distribute your changes.
1461
1461
1462 If a list of files is omitted, all changes reported by :hg:`status`
1462 If a list of files is omitted, all changes reported by :hg:`status`
1463 will be committed.
1463 will be committed.
1464
1464
1465 If you are committing the result of a merge, do not provide any
1465 If you are committing the result of a merge, do not provide any
1466 filenames or -I/-X filters.
1466 filenames or -I/-X filters.
1467
1467
1468 If no commit message is specified, Mercurial starts your
1468 If no commit message is specified, Mercurial starts your
1469 configured editor where you can enter a message. In case your
1469 configured editor where you can enter a message. In case your
1470 commit fails, you will find a backup of your message in
1470 commit fails, you will find a backup of your message in
1471 ``.hg/last-message.txt``.
1471 ``.hg/last-message.txt``.
1472
1472
1473 The --close-branch flag can be used to mark the current branch
1473 The --close-branch flag can be used to mark the current branch
1474 head closed. When all heads of a branch are closed, the branch
1474 head closed. When all heads of a branch are closed, the branch
1475 will be considered closed and no longer listed.
1475 will be considered closed and no longer listed.
1476
1476
1477 The --amend flag can be used to amend the parent of the
1477 The --amend flag can be used to amend the parent of the
1478 working directory with a new commit that contains the changes
1478 working directory with a new commit that contains the changes
1479 in the parent in addition to those currently reported by :hg:`status`,
1479 in the parent in addition to those currently reported by :hg:`status`,
1480 if there are any. The old commit is stored in a backup bundle in
1480 if there are any. The old commit is stored in a backup bundle in
1481 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1481 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1482 on how to restore it).
1482 on how to restore it).
1483
1483
1484 Message, user and date are taken from the amended commit unless
1484 Message, user and date are taken from the amended commit unless
1485 specified. When a message isn't specified on the command line,
1485 specified. When a message isn't specified on the command line,
1486 the editor will open with the message of the amended commit.
1486 the editor will open with the message of the amended commit.
1487
1487
1488 It is not possible to amend public changesets (see :hg:`help phases`)
1488 It is not possible to amend public changesets (see :hg:`help phases`)
1489 or changesets that have children.
1489 or changesets that have children.
1490
1490
1491 See :hg:`help dates` for a list of formats valid for -d/--date.
1491 See :hg:`help dates` for a list of formats valid for -d/--date.
1492
1492
1493 Returns 0 on success, 1 if nothing changed.
1493 Returns 0 on success, 1 if nothing changed.
1494 """
1494 """
1495 if opts.get('interactive'):
1495 if opts.get('interactive'):
1496 opts.pop('interactive')
1496 opts.pop('interactive')
1497 cmdutil.dorecord(ui, repo, commit, None, False,
1497 cmdutil.dorecord(ui, repo, commit, None, False,
1498 cmdutil.recordfilter, *pats, **opts)
1498 cmdutil.recordfilter, *pats, **opts)
1499 return
1499 return
1500
1500
1501 if opts.get('subrepos'):
1501 if opts.get('subrepos'):
1502 if opts.get('amend'):
1502 if opts.get('amend'):
1503 raise util.Abort(_('cannot amend with --subrepos'))
1503 raise util.Abort(_('cannot amend with --subrepos'))
1504 # Let --subrepos on the command line override config setting.
1504 # Let --subrepos on the command line override config setting.
1505 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1505 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1506
1506
1507 cmdutil.checkunfinished(repo, commit=True)
1507 cmdutil.checkunfinished(repo, commit=True)
1508
1508
1509 branch = repo[None].branch()
1509 branch = repo[None].branch()
1510 bheads = repo.branchheads(branch)
1510 bheads = repo.branchheads(branch)
1511
1511
1512 extra = {}
1512 extra = {}
1513 if opts.get('close_branch'):
1513 if opts.get('close_branch'):
1514 extra['close'] = 1
1514 extra['close'] = 1
1515
1515
1516 if not bheads:
1516 if not bheads:
1517 raise util.Abort(_('can only close branch heads'))
1517 raise util.Abort(_('can only close branch heads'))
1518 elif opts.get('amend'):
1518 elif opts.get('amend'):
1519 if repo.parents()[0].p1().branch() != branch and \
1519 if repo.parents()[0].p1().branch() != branch and \
1520 repo.parents()[0].p2().branch() != branch:
1520 repo.parents()[0].p2().branch() != branch:
1521 raise util.Abort(_('can only close branch heads'))
1521 raise util.Abort(_('can only close branch heads'))
1522
1522
1523 if opts.get('amend'):
1523 if opts.get('amend'):
1524 if ui.configbool('ui', 'commitsubrepos'):
1524 if ui.configbool('ui', 'commitsubrepos'):
1525 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1525 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1526
1526
1527 old = repo['.']
1527 old = repo['.']
1528 if not old.mutable():
1528 if not old.mutable():
1529 raise util.Abort(_('cannot amend public changesets'))
1529 raise util.Abort(_('cannot amend public changesets'))
1530 if len(repo[None].parents()) > 1:
1530 if len(repo[None].parents()) > 1:
1531 raise util.Abort(_('cannot amend while merging'))
1531 raise util.Abort(_('cannot amend while merging'))
1532 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1532 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1533 if not allowunstable and old.children():
1533 if not allowunstable and old.children():
1534 raise util.Abort(_('cannot amend changeset with children'))
1534 raise util.Abort(_('cannot amend changeset with children'))
1535
1535
1536 # commitfunc is used only for temporary amend commit by cmdutil.amend
1536 # commitfunc is used only for temporary amend commit by cmdutil.amend
1537 def commitfunc(ui, repo, message, match, opts):
1537 def commitfunc(ui, repo, message, match, opts):
1538 return repo.commit(message,
1538 return repo.commit(message,
1539 opts.get('user') or old.user(),
1539 opts.get('user') or old.user(),
1540 opts.get('date') or old.date(),
1540 opts.get('date') or old.date(),
1541 match,
1541 match,
1542 extra=extra)
1542 extra=extra)
1543
1543
1544 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1544 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1545 if node == old.node():
1545 if node == old.node():
1546 ui.status(_("nothing changed\n"))
1546 ui.status(_("nothing changed\n"))
1547 return 1
1547 return 1
1548 else:
1548 else:
1549 def commitfunc(ui, repo, message, match, opts):
1549 def commitfunc(ui, repo, message, match, opts):
1550 backup = ui.backupconfig('phases', 'new-commit')
1550 backup = ui.backupconfig('phases', 'new-commit')
1551 baseui = repo.baseui
1551 baseui = repo.baseui
1552 basebackup = baseui.backupconfig('phases', 'new-commit')
1552 basebackup = baseui.backupconfig('phases', 'new-commit')
1553 try:
1553 try:
1554 if opts.get('secret'):
1554 if opts.get('secret'):
1555 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1555 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1556 # Propagate to subrepos
1556 # Propagate to subrepos
1557 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1557 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1558
1558
1559 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1559 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1560 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1560 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1561 return repo.commit(message, opts.get('user'), opts.get('date'),
1561 return repo.commit(message, opts.get('user'), opts.get('date'),
1562 match,
1562 match,
1563 editor=editor,
1563 editor=editor,
1564 extra=extra)
1564 extra=extra)
1565 finally:
1565 finally:
1566 ui.restoreconfig(backup)
1566 ui.restoreconfig(backup)
1567 repo.baseui.restoreconfig(basebackup)
1567 repo.baseui.restoreconfig(basebackup)
1568
1568
1569
1569
1570 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1570 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1571
1571
1572 if not node:
1572 if not node:
1573 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1573 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1574 if stat[3]:
1574 if stat[3]:
1575 ui.status(_("nothing changed (%d missing files, see "
1575 ui.status(_("nothing changed (%d missing files, see "
1576 "'hg status')\n") % len(stat[3]))
1576 "'hg status')\n") % len(stat[3]))
1577 else:
1577 else:
1578 ui.status(_("nothing changed\n"))
1578 ui.status(_("nothing changed\n"))
1579 return 1
1579 return 1
1580
1580
1581 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1581 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1582
1582
1583 @command('config|showconfig|debugconfig',
1583 @command('config|showconfig|debugconfig',
1584 [('u', 'untrusted', None, _('show untrusted configuration options')),
1584 [('u', 'untrusted', None, _('show untrusted configuration options')),
1585 ('e', 'edit', None, _('edit user config')),
1585 ('e', 'edit', None, _('edit user config')),
1586 ('l', 'local', None, _('edit repository config')),
1586 ('l', 'local', None, _('edit repository config')),
1587 ('g', 'global', None, _('edit global config'))],
1587 ('g', 'global', None, _('edit global config'))],
1588 _('[-u] [NAME]...'),
1588 _('[-u] [NAME]...'),
1589 optionalrepo=True)
1589 optionalrepo=True)
1590 def config(ui, repo, *values, **opts):
1590 def config(ui, repo, *values, **opts):
1591 """show combined config settings from all hgrc files
1591 """show combined config settings from all hgrc files
1592
1592
1593 With no arguments, print names and values of all config items.
1593 With no arguments, print names and values of all config items.
1594
1594
1595 With one argument of the form section.name, print just the value
1595 With one argument of the form section.name, print just the value
1596 of that config item.
1596 of that config item.
1597
1597
1598 With multiple arguments, print names and values of all config
1598 With multiple arguments, print names and values of all config
1599 items with matching section names.
1599 items with matching section names.
1600
1600
1601 With --edit, start an editor on the user-level config file. With
1601 With --edit, start an editor on the user-level config file. With
1602 --global, edit the system-wide config file. With --local, edit the
1602 --global, edit the system-wide config file. With --local, edit the
1603 repository-level config file.
1603 repository-level config file.
1604
1604
1605 With --debug, the source (filename and line number) is printed
1605 With --debug, the source (filename and line number) is printed
1606 for each config item.
1606 for each config item.
1607
1607
1608 See :hg:`help config` for more information about config files.
1608 See :hg:`help config` for more information about config files.
1609
1609
1610 Returns 0 on success, 1 if NAME does not exist.
1610 Returns 0 on success, 1 if NAME does not exist.
1611
1611
1612 """
1612 """
1613
1613
1614 if opts.get('edit') or opts.get('local') or opts.get('global'):
1614 if opts.get('edit') or opts.get('local') or opts.get('global'):
1615 if opts.get('local') and opts.get('global'):
1615 if opts.get('local') and opts.get('global'):
1616 raise util.Abort(_("can't use --local and --global together"))
1616 raise util.Abort(_("can't use --local and --global together"))
1617
1617
1618 if opts.get('local'):
1618 if opts.get('local'):
1619 if not repo:
1619 if not repo:
1620 raise util.Abort(_("can't use --local outside a repository"))
1620 raise util.Abort(_("can't use --local outside a repository"))
1621 paths = [repo.join('hgrc')]
1621 paths = [repo.join('hgrc')]
1622 elif opts.get('global'):
1622 elif opts.get('global'):
1623 paths = scmutil.systemrcpath()
1623 paths = scmutil.systemrcpath()
1624 else:
1624 else:
1625 paths = scmutil.userrcpath()
1625 paths = scmutil.userrcpath()
1626
1626
1627 for f in paths:
1627 for f in paths:
1628 if os.path.exists(f):
1628 if os.path.exists(f):
1629 break
1629 break
1630 else:
1630 else:
1631 if opts.get('global'):
1631 if opts.get('global'):
1632 samplehgrc = uimod.samplehgrcs['global']
1632 samplehgrc = uimod.samplehgrcs['global']
1633 elif opts.get('local'):
1633 elif opts.get('local'):
1634 samplehgrc = uimod.samplehgrcs['local']
1634 samplehgrc = uimod.samplehgrcs['local']
1635 else:
1635 else:
1636 samplehgrc = uimod.samplehgrcs['user']
1636 samplehgrc = uimod.samplehgrcs['user']
1637
1637
1638 f = paths[0]
1638 f = paths[0]
1639 fp = open(f, "w")
1639 fp = open(f, "w")
1640 fp.write(samplehgrc)
1640 fp.write(samplehgrc)
1641 fp.close()
1641 fp.close()
1642
1642
1643 editor = ui.geteditor()
1643 editor = ui.geteditor()
1644 ui.system("%s \"%s\"" % (editor, f),
1644 ui.system("%s \"%s\"" % (editor, f),
1645 onerr=util.Abort, errprefix=_("edit failed"))
1645 onerr=util.Abort, errprefix=_("edit failed"))
1646 return
1646 return
1647
1647
1648 for f in scmutil.rcpath():
1648 for f in scmutil.rcpath():
1649 ui.debug('read config from: %s\n' % f)
1649 ui.debug('read config from: %s\n' % f)
1650 untrusted = bool(opts.get('untrusted'))
1650 untrusted = bool(opts.get('untrusted'))
1651 if values:
1651 if values:
1652 sections = [v for v in values if '.' not in v]
1652 sections = [v for v in values if '.' not in v]
1653 items = [v for v in values if '.' in v]
1653 items = [v for v in values if '.' in v]
1654 if len(items) > 1 or items and sections:
1654 if len(items) > 1 or items and sections:
1655 raise util.Abort(_('only one config item permitted'))
1655 raise util.Abort(_('only one config item permitted'))
1656 matched = False
1656 matched = False
1657 for section, name, value in ui.walkconfig(untrusted=untrusted):
1657 for section, name, value in ui.walkconfig(untrusted=untrusted):
1658 value = str(value).replace('\n', '\\n')
1658 value = str(value).replace('\n', '\\n')
1659 sectname = section + '.' + name
1659 sectname = section + '.' + name
1660 if values:
1660 if values:
1661 for v in values:
1661 for v in values:
1662 if v == section:
1662 if v == section:
1663 ui.debug('%s: ' %
1663 ui.debug('%s: ' %
1664 ui.configsource(section, name, untrusted))
1664 ui.configsource(section, name, untrusted))
1665 ui.write('%s=%s\n' % (sectname, value))
1665 ui.write('%s=%s\n' % (sectname, value))
1666 matched = True
1666 matched = True
1667 elif v == sectname:
1667 elif v == sectname:
1668 ui.debug('%s: ' %
1668 ui.debug('%s: ' %
1669 ui.configsource(section, name, untrusted))
1669 ui.configsource(section, name, untrusted))
1670 ui.write(value, '\n')
1670 ui.write(value, '\n')
1671 matched = True
1671 matched = True
1672 else:
1672 else:
1673 ui.debug('%s: ' %
1673 ui.debug('%s: ' %
1674 ui.configsource(section, name, untrusted))
1674 ui.configsource(section, name, untrusted))
1675 ui.write('%s=%s\n' % (sectname, value))
1675 ui.write('%s=%s\n' % (sectname, value))
1676 matched = True
1676 matched = True
1677 if matched:
1677 if matched:
1678 return 0
1678 return 0
1679 return 1
1679 return 1
1680
1680
1681 @command('copy|cp',
1681 @command('copy|cp',
1682 [('A', 'after', None, _('record a copy that has already occurred')),
1682 [('A', 'after', None, _('record a copy that has already occurred')),
1683 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1683 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1684 ] + walkopts + dryrunopts,
1684 ] + walkopts + dryrunopts,
1685 _('[OPTION]... [SOURCE]... DEST'))
1685 _('[OPTION]... [SOURCE]... DEST'))
1686 def copy(ui, repo, *pats, **opts):
1686 def copy(ui, repo, *pats, **opts):
1687 """mark files as copied for the next commit
1687 """mark files as copied for the next commit
1688
1688
1689 Mark dest as having copies of source files. If dest is a
1689 Mark dest as having copies of source files. If dest is a
1690 directory, copies are put in that directory. If dest is a file,
1690 directory, copies are put in that directory. If dest is a file,
1691 the source must be a single file.
1691 the source must be a single file.
1692
1692
1693 By default, this command copies the contents of files as they
1693 By default, this command copies the contents of files as they
1694 exist in the working directory. If invoked with -A/--after, the
1694 exist in the working directory. If invoked with -A/--after, the
1695 operation is recorded, but no copying is performed.
1695 operation is recorded, but no copying is performed.
1696
1696
1697 This command takes effect with the next commit. To undo a copy
1697 This command takes effect with the next commit. To undo a copy
1698 before that, see :hg:`revert`.
1698 before that, see :hg:`revert`.
1699
1699
1700 Returns 0 on success, 1 if errors are encountered.
1700 Returns 0 on success, 1 if errors are encountered.
1701 """
1701 """
1702 wlock = repo.wlock(False)
1702 wlock = repo.wlock(False)
1703 try:
1703 try:
1704 return cmdutil.copy(ui, repo, pats, opts)
1704 return cmdutil.copy(ui, repo, pats, opts)
1705 finally:
1705 finally:
1706 wlock.release()
1706 wlock.release()
1707
1707
1708 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1708 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1709 def debugancestor(ui, repo, *args):
1709 def debugancestor(ui, repo, *args):
1710 """find the ancestor revision of two revisions in a given index"""
1710 """find the ancestor revision of two revisions in a given index"""
1711 if len(args) == 3:
1711 if len(args) == 3:
1712 index, rev1, rev2 = args
1712 index, rev1, rev2 = args
1713 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1713 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1714 lookup = r.lookup
1714 lookup = r.lookup
1715 elif len(args) == 2:
1715 elif len(args) == 2:
1716 if not repo:
1716 if not repo:
1717 raise util.Abort(_("there is no Mercurial repository here "
1717 raise util.Abort(_("there is no Mercurial repository here "
1718 "(.hg not found)"))
1718 "(.hg not found)"))
1719 rev1, rev2 = args
1719 rev1, rev2 = args
1720 r = repo.changelog
1720 r = repo.changelog
1721 lookup = repo.lookup
1721 lookup = repo.lookup
1722 else:
1722 else:
1723 raise util.Abort(_('either two or three arguments required'))
1723 raise util.Abort(_('either two or three arguments required'))
1724 a = r.ancestor(lookup(rev1), lookup(rev2))
1724 a = r.ancestor(lookup(rev1), lookup(rev2))
1725 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1725 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1726
1726
1727 @command('debugbuilddag',
1727 @command('debugbuilddag',
1728 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1728 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1729 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1729 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1730 ('n', 'new-file', None, _('add new file at each rev'))],
1730 ('n', 'new-file', None, _('add new file at each rev'))],
1731 _('[OPTION]... [TEXT]'))
1731 _('[OPTION]... [TEXT]'))
1732 def debugbuilddag(ui, repo, text=None,
1732 def debugbuilddag(ui, repo, text=None,
1733 mergeable_file=False,
1733 mergeable_file=False,
1734 overwritten_file=False,
1734 overwritten_file=False,
1735 new_file=False):
1735 new_file=False):
1736 """builds a repo with a given DAG from scratch in the current empty repo
1736 """builds a repo with a given DAG from scratch in the current empty repo
1737
1737
1738 The description of the DAG is read from stdin if not given on the
1738 The description of the DAG is read from stdin if not given on the
1739 command line.
1739 command line.
1740
1740
1741 Elements:
1741 Elements:
1742
1742
1743 - "+n" is a linear run of n nodes based on the current default parent
1743 - "+n" is a linear run of n nodes based on the current default parent
1744 - "." is a single node based on the current default parent
1744 - "." is a single node based on the current default parent
1745 - "$" resets the default parent to null (implied at the start);
1745 - "$" resets the default parent to null (implied at the start);
1746 otherwise the default parent is always the last node created
1746 otherwise the default parent is always the last node created
1747 - "<p" sets the default parent to the backref p
1747 - "<p" sets the default parent to the backref p
1748 - "*p" is a fork at parent p, which is a backref
1748 - "*p" is a fork at parent p, which is a backref
1749 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1749 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1750 - "/p2" is a merge of the preceding node and p2
1750 - "/p2" is a merge of the preceding node and p2
1751 - ":tag" defines a local tag for the preceding node
1751 - ":tag" defines a local tag for the preceding node
1752 - "@branch" sets the named branch for subsequent nodes
1752 - "@branch" sets the named branch for subsequent nodes
1753 - "#...\\n" is a comment up to the end of the line
1753 - "#...\\n" is a comment up to the end of the line
1754
1754
1755 Whitespace between the above elements is ignored.
1755 Whitespace between the above elements is ignored.
1756
1756
1757 A backref is either
1757 A backref is either
1758
1758
1759 - a number n, which references the node curr-n, where curr is the current
1759 - a number n, which references the node curr-n, where curr is the current
1760 node, or
1760 node, or
1761 - the name of a local tag you placed earlier using ":tag", or
1761 - the name of a local tag you placed earlier using ":tag", or
1762 - empty to denote the default parent.
1762 - empty to denote the default parent.
1763
1763
1764 All string valued-elements are either strictly alphanumeric, or must
1764 All string valued-elements are either strictly alphanumeric, or must
1765 be enclosed in double quotes ("..."), with "\\" as escape character.
1765 be enclosed in double quotes ("..."), with "\\" as escape character.
1766 """
1766 """
1767
1767
1768 if text is None:
1768 if text is None:
1769 ui.status(_("reading DAG from stdin\n"))
1769 ui.status(_("reading DAG from stdin\n"))
1770 text = ui.fin.read()
1770 text = ui.fin.read()
1771
1771
1772 cl = repo.changelog
1772 cl = repo.changelog
1773 if len(cl) > 0:
1773 if len(cl) > 0:
1774 raise util.Abort(_('repository is not empty'))
1774 raise util.Abort(_('repository is not empty'))
1775
1775
1776 # determine number of revs in DAG
1776 # determine number of revs in DAG
1777 total = 0
1777 total = 0
1778 for type, data in dagparser.parsedag(text):
1778 for type, data in dagparser.parsedag(text):
1779 if type == 'n':
1779 if type == 'n':
1780 total += 1
1780 total += 1
1781
1781
1782 if mergeable_file:
1782 if mergeable_file:
1783 linesperrev = 2
1783 linesperrev = 2
1784 # make a file with k lines per rev
1784 # make a file with k lines per rev
1785 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1785 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1786 initialmergedlines.append("")
1786 initialmergedlines.append("")
1787
1787
1788 tags = []
1788 tags = []
1789
1789
1790 lock = tr = None
1790 lock = tr = None
1791 try:
1791 try:
1792 lock = repo.lock()
1792 lock = repo.lock()
1793 tr = repo.transaction("builddag")
1793 tr = repo.transaction("builddag")
1794
1794
1795 at = -1
1795 at = -1
1796 atbranch = 'default'
1796 atbranch = 'default'
1797 nodeids = []
1797 nodeids = []
1798 id = 0
1798 id = 0
1799 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1799 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1800 for type, data in dagparser.parsedag(text):
1800 for type, data in dagparser.parsedag(text):
1801 if type == 'n':
1801 if type == 'n':
1802 ui.note(('node %s\n' % str(data)))
1802 ui.note(('node %s\n' % str(data)))
1803 id, ps = data
1803 id, ps = data
1804
1804
1805 files = []
1805 files = []
1806 fctxs = {}
1806 fctxs = {}
1807
1807
1808 p2 = None
1808 p2 = None
1809 if mergeable_file:
1809 if mergeable_file:
1810 fn = "mf"
1810 fn = "mf"
1811 p1 = repo[ps[0]]
1811 p1 = repo[ps[0]]
1812 if len(ps) > 1:
1812 if len(ps) > 1:
1813 p2 = repo[ps[1]]
1813 p2 = repo[ps[1]]
1814 pa = p1.ancestor(p2)
1814 pa = p1.ancestor(p2)
1815 base, local, other = [x[fn].data() for x in (pa, p1,
1815 base, local, other = [x[fn].data() for x in (pa, p1,
1816 p2)]
1816 p2)]
1817 m3 = simplemerge.Merge3Text(base, local, other)
1817 m3 = simplemerge.Merge3Text(base, local, other)
1818 ml = [l.strip() for l in m3.merge_lines()]
1818 ml = [l.strip() for l in m3.merge_lines()]
1819 ml.append("")
1819 ml.append("")
1820 elif at > 0:
1820 elif at > 0:
1821 ml = p1[fn].data().split("\n")
1821 ml = p1[fn].data().split("\n")
1822 else:
1822 else:
1823 ml = initialmergedlines
1823 ml = initialmergedlines
1824 ml[id * linesperrev] += " r%i" % id
1824 ml[id * linesperrev] += " r%i" % id
1825 mergedtext = "\n".join(ml)
1825 mergedtext = "\n".join(ml)
1826 files.append(fn)
1826 files.append(fn)
1827 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1827 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1828
1828
1829 if overwritten_file:
1829 if overwritten_file:
1830 fn = "of"
1830 fn = "of"
1831 files.append(fn)
1831 files.append(fn)
1832 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1832 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1833
1833
1834 if new_file:
1834 if new_file:
1835 fn = "nf%i" % id
1835 fn = "nf%i" % id
1836 files.append(fn)
1836 files.append(fn)
1837 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1837 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1838 if len(ps) > 1:
1838 if len(ps) > 1:
1839 if not p2:
1839 if not p2:
1840 p2 = repo[ps[1]]
1840 p2 = repo[ps[1]]
1841 for fn in p2:
1841 for fn in p2:
1842 if fn.startswith("nf"):
1842 if fn.startswith("nf"):
1843 files.append(fn)
1843 files.append(fn)
1844 fctxs[fn] = p2[fn]
1844 fctxs[fn] = p2[fn]
1845
1845
1846 def fctxfn(repo, cx, path):
1846 def fctxfn(repo, cx, path):
1847 return fctxs.get(path)
1847 return fctxs.get(path)
1848
1848
1849 if len(ps) == 0 or ps[0] < 0:
1849 if len(ps) == 0 or ps[0] < 0:
1850 pars = [None, None]
1850 pars = [None, None]
1851 elif len(ps) == 1:
1851 elif len(ps) == 1:
1852 pars = [nodeids[ps[0]], None]
1852 pars = [nodeids[ps[0]], None]
1853 else:
1853 else:
1854 pars = [nodeids[p] for p in ps]
1854 pars = [nodeids[p] for p in ps]
1855 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1855 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1856 date=(id, 0),
1856 date=(id, 0),
1857 user="debugbuilddag",
1857 user="debugbuilddag",
1858 extra={'branch': atbranch})
1858 extra={'branch': atbranch})
1859 nodeid = repo.commitctx(cx)
1859 nodeid = repo.commitctx(cx)
1860 nodeids.append(nodeid)
1860 nodeids.append(nodeid)
1861 at = id
1861 at = id
1862 elif type == 'l':
1862 elif type == 'l':
1863 id, name = data
1863 id, name = data
1864 ui.note(('tag %s\n' % name))
1864 ui.note(('tag %s\n' % name))
1865 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1865 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1866 elif type == 'a':
1866 elif type == 'a':
1867 ui.note(('branch %s\n' % data))
1867 ui.note(('branch %s\n' % data))
1868 atbranch = data
1868 atbranch = data
1869 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1869 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1870 tr.close()
1870 tr.close()
1871
1871
1872 if tags:
1872 if tags:
1873 repo.vfs.write("localtags", "".join(tags))
1873 repo.vfs.write("localtags", "".join(tags))
1874 finally:
1874 finally:
1875 ui.progress(_('building'), None)
1875 ui.progress(_('building'), None)
1876 release(tr, lock)
1876 release(tr, lock)
1877
1877
1878 @command('debugbundle',
1878 @command('debugbundle',
1879 [('a', 'all', None, _('show all details'))],
1879 [('a', 'all', None, _('show all details'))],
1880 _('FILE'),
1880 _('FILE'),
1881 norepo=True)
1881 norepo=True)
1882 def debugbundle(ui, bundlepath, all=None, **opts):
1882 def debugbundle(ui, bundlepath, all=None, **opts):
1883 """lists the contents of a bundle"""
1883 """lists the contents of a bundle"""
1884 f = hg.openpath(ui, bundlepath)
1884 f = hg.openpath(ui, bundlepath)
1885 try:
1885 try:
1886 gen = exchange.readbundle(ui, f, bundlepath)
1886 gen = exchange.readbundle(ui, f, bundlepath)
1887 if isinstance(gen, bundle2.unbundle20):
1887 if isinstance(gen, bundle2.unbundle20):
1888 return _debugbundle2(ui, gen, all=all, **opts)
1888 return _debugbundle2(ui, gen, all=all, **opts)
1889 if all:
1889 if all:
1890 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1890 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1891
1891
1892 def showchunks(named):
1892 def showchunks(named):
1893 ui.write("\n%s\n" % named)
1893 ui.write("\n%s\n" % named)
1894 chain = None
1894 chain = None
1895 while True:
1895 while True:
1896 chunkdata = gen.deltachunk(chain)
1896 chunkdata = gen.deltachunk(chain)
1897 if not chunkdata:
1897 if not chunkdata:
1898 break
1898 break
1899 node = chunkdata['node']
1899 node = chunkdata['node']
1900 p1 = chunkdata['p1']
1900 p1 = chunkdata['p1']
1901 p2 = chunkdata['p2']
1901 p2 = chunkdata['p2']
1902 cs = chunkdata['cs']
1902 cs = chunkdata['cs']
1903 deltabase = chunkdata['deltabase']
1903 deltabase = chunkdata['deltabase']
1904 delta = chunkdata['delta']
1904 delta = chunkdata['delta']
1905 ui.write("%s %s %s %s %s %s\n" %
1905 ui.write("%s %s %s %s %s %s\n" %
1906 (hex(node), hex(p1), hex(p2),
1906 (hex(node), hex(p1), hex(p2),
1907 hex(cs), hex(deltabase), len(delta)))
1907 hex(cs), hex(deltabase), len(delta)))
1908 chain = node
1908 chain = node
1909
1909
1910 chunkdata = gen.changelogheader()
1910 chunkdata = gen.changelogheader()
1911 showchunks("changelog")
1911 showchunks("changelog")
1912 chunkdata = gen.manifestheader()
1912 chunkdata = gen.manifestheader()
1913 showchunks("manifest")
1913 showchunks("manifest")
1914 while True:
1914 while True:
1915 chunkdata = gen.filelogheader()
1915 chunkdata = gen.filelogheader()
1916 if not chunkdata:
1916 if not chunkdata:
1917 break
1917 break
1918 fname = chunkdata['filename']
1918 fname = chunkdata['filename']
1919 showchunks(fname)
1919 showchunks(fname)
1920 else:
1920 else:
1921 if isinstance(gen, bundle2.unbundle20):
1921 if isinstance(gen, bundle2.unbundle20):
1922 raise util.Abort(_('use debugbundle2 for this file'))
1922 raise util.Abort(_('use debugbundle2 for this file'))
1923 chunkdata = gen.changelogheader()
1923 chunkdata = gen.changelogheader()
1924 chain = None
1924 chain = None
1925 while True:
1925 while True:
1926 chunkdata = gen.deltachunk(chain)
1926 chunkdata = gen.deltachunk(chain)
1927 if not chunkdata:
1927 if not chunkdata:
1928 break
1928 break
1929 node = chunkdata['node']
1929 node = chunkdata['node']
1930 ui.write("%s\n" % hex(node))
1930 ui.write("%s\n" % hex(node))
1931 chain = node
1931 chain = node
1932 finally:
1932 finally:
1933 f.close()
1933 f.close()
1934
1934
1935 def _debugbundle2(ui, gen, **opts):
1935 def _debugbundle2(ui, gen, **opts):
1936 """lists the contents of a bundle2"""
1936 """lists the contents of a bundle2"""
1937 if not isinstance(gen, bundle2.unbundle20):
1937 if not isinstance(gen, bundle2.unbundle20):
1938 raise util.Abort(_('not a bundle2 file'))
1938 raise util.Abort(_('not a bundle2 file'))
1939 ui.write(('Stream params: %s\n' % repr(gen.params)))
1939 ui.write(('Stream params: %s\n' % repr(gen.params)))
1940 for part in gen.iterparts():
1940 for part in gen.iterparts():
1941 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1941 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1942 if part.type == 'changegroup':
1942 if part.type == 'changegroup':
1943 version = part.params.get('version', '01')
1943 version = part.params.get('version', '01')
1944 cg = changegroup.packermap[version][1](part, 'UN')
1944 cg = changegroup.packermap[version][1](part, 'UN')
1945 chunkdata = cg.changelogheader()
1945 chunkdata = cg.changelogheader()
1946 chain = None
1946 chain = None
1947 while True:
1947 while True:
1948 chunkdata = cg.deltachunk(chain)
1948 chunkdata = cg.deltachunk(chain)
1949 if not chunkdata:
1949 if not chunkdata:
1950 break
1950 break
1951 node = chunkdata['node']
1951 node = chunkdata['node']
1952 ui.write(" %s\n" % hex(node))
1952 ui.write(" %s\n" % hex(node))
1953 chain = node
1953 chain = node
1954
1954
1955 @command('debugcheckstate', [], '')
1955 @command('debugcheckstate', [], '')
1956 def debugcheckstate(ui, repo):
1956 def debugcheckstate(ui, repo):
1957 """validate the correctness of the current dirstate"""
1957 """validate the correctness of the current dirstate"""
1958 parent1, parent2 = repo.dirstate.parents()
1958 parent1, parent2 = repo.dirstate.parents()
1959 m1 = repo[parent1].manifest()
1959 m1 = repo[parent1].manifest()
1960 m2 = repo[parent2].manifest()
1960 m2 = repo[parent2].manifest()
1961 errors = 0
1961 errors = 0
1962 for f in repo.dirstate:
1962 for f in repo.dirstate:
1963 state = repo.dirstate[f]
1963 state = repo.dirstate[f]
1964 if state in "nr" and f not in m1:
1964 if state in "nr" and f not in m1:
1965 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1965 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1966 errors += 1
1966 errors += 1
1967 if state in "a" and f in m1:
1967 if state in "a" and f in m1:
1968 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1968 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1969 errors += 1
1969 errors += 1
1970 if state in "m" and f not in m1 and f not in m2:
1970 if state in "m" and f not in m1 and f not in m2:
1971 ui.warn(_("%s in state %s, but not in either manifest\n") %
1971 ui.warn(_("%s in state %s, but not in either manifest\n") %
1972 (f, state))
1972 (f, state))
1973 errors += 1
1973 errors += 1
1974 for f in m1:
1974 for f in m1:
1975 state = repo.dirstate[f]
1975 state = repo.dirstate[f]
1976 if state not in "nrm":
1976 if state not in "nrm":
1977 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1977 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1978 errors += 1
1978 errors += 1
1979 if errors:
1979 if errors:
1980 error = _(".hg/dirstate inconsistent with current parent's manifest")
1980 error = _(".hg/dirstate inconsistent with current parent's manifest")
1981 raise util.Abort(error)
1981 raise util.Abort(error)
1982
1982
1983 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1983 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1984 def debugcommands(ui, cmd='', *args):
1984 def debugcommands(ui, cmd='', *args):
1985 """list all available commands and options"""
1985 """list all available commands and options"""
1986 for cmd, vals in sorted(table.iteritems()):
1986 for cmd, vals in sorted(table.iteritems()):
1987 cmd = cmd.split('|')[0].strip('^')
1987 cmd = cmd.split('|')[0].strip('^')
1988 opts = ', '.join([i[1] for i in vals[1]])
1988 opts = ', '.join([i[1] for i in vals[1]])
1989 ui.write('%s: %s\n' % (cmd, opts))
1989 ui.write('%s: %s\n' % (cmd, opts))
1990
1990
1991 @command('debugcomplete',
1991 @command('debugcomplete',
1992 [('o', 'options', None, _('show the command options'))],
1992 [('o', 'options', None, _('show the command options'))],
1993 _('[-o] CMD'),
1993 _('[-o] CMD'),
1994 norepo=True)
1994 norepo=True)
1995 def debugcomplete(ui, cmd='', **opts):
1995 def debugcomplete(ui, cmd='', **opts):
1996 """returns the completion list associated with the given command"""
1996 """returns the completion list associated with the given command"""
1997
1997
1998 if opts.get('options'):
1998 if opts.get('options'):
1999 options = []
1999 options = []
2000 otables = [globalopts]
2000 otables = [globalopts]
2001 if cmd:
2001 if cmd:
2002 aliases, entry = cmdutil.findcmd(cmd, table, False)
2002 aliases, entry = cmdutil.findcmd(cmd, table, False)
2003 otables.append(entry[1])
2003 otables.append(entry[1])
2004 for t in otables:
2004 for t in otables:
2005 for o in t:
2005 for o in t:
2006 if "(DEPRECATED)" in o[3]:
2006 if "(DEPRECATED)" in o[3]:
2007 continue
2007 continue
2008 if o[0]:
2008 if o[0]:
2009 options.append('-%s' % o[0])
2009 options.append('-%s' % o[0])
2010 options.append('--%s' % o[1])
2010 options.append('--%s' % o[1])
2011 ui.write("%s\n" % "\n".join(options))
2011 ui.write("%s\n" % "\n".join(options))
2012 return
2012 return
2013
2013
2014 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2014 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2015 if ui.verbose:
2015 if ui.verbose:
2016 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2016 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2017 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2017 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2018
2018
2019 @command('debugdag',
2019 @command('debugdag',
2020 [('t', 'tags', None, _('use tags as labels')),
2020 [('t', 'tags', None, _('use tags as labels')),
2021 ('b', 'branches', None, _('annotate with branch names')),
2021 ('b', 'branches', None, _('annotate with branch names')),
2022 ('', 'dots', None, _('use dots for runs')),
2022 ('', 'dots', None, _('use dots for runs')),
2023 ('s', 'spaces', None, _('separate elements by spaces'))],
2023 ('s', 'spaces', None, _('separate elements by spaces'))],
2024 _('[OPTION]... [FILE [REV]...]'),
2024 _('[OPTION]... [FILE [REV]...]'),
2025 optionalrepo=True)
2025 optionalrepo=True)
2026 def debugdag(ui, repo, file_=None, *revs, **opts):
2026 def debugdag(ui, repo, file_=None, *revs, **opts):
2027 """format the changelog or an index DAG as a concise textual description
2027 """format the changelog or an index DAG as a concise textual description
2028
2028
2029 If you pass a revlog index, the revlog's DAG is emitted. If you list
2029 If you pass a revlog index, the revlog's DAG is emitted. If you list
2030 revision numbers, they get labeled in the output as rN.
2030 revision numbers, they get labeled in the output as rN.
2031
2031
2032 Otherwise, the changelog DAG of the current repo is emitted.
2032 Otherwise, the changelog DAG of the current repo is emitted.
2033 """
2033 """
2034 spaces = opts.get('spaces')
2034 spaces = opts.get('spaces')
2035 dots = opts.get('dots')
2035 dots = opts.get('dots')
2036 if file_:
2036 if file_:
2037 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2037 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2038 revs = set((int(r) for r in revs))
2038 revs = set((int(r) for r in revs))
2039 def events():
2039 def events():
2040 for r in rlog:
2040 for r in rlog:
2041 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2041 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2042 if p != -1))
2042 if p != -1))
2043 if r in revs:
2043 if r in revs:
2044 yield 'l', (r, "r%i" % r)
2044 yield 'l', (r, "r%i" % r)
2045 elif repo:
2045 elif repo:
2046 cl = repo.changelog
2046 cl = repo.changelog
2047 tags = opts.get('tags')
2047 tags = opts.get('tags')
2048 branches = opts.get('branches')
2048 branches = opts.get('branches')
2049 if tags:
2049 if tags:
2050 labels = {}
2050 labels = {}
2051 for l, n in repo.tags().items():
2051 for l, n in repo.tags().items():
2052 labels.setdefault(cl.rev(n), []).append(l)
2052 labels.setdefault(cl.rev(n), []).append(l)
2053 def events():
2053 def events():
2054 b = "default"
2054 b = "default"
2055 for r in cl:
2055 for r in cl:
2056 if branches:
2056 if branches:
2057 newb = cl.read(cl.node(r))[5]['branch']
2057 newb = cl.read(cl.node(r))[5]['branch']
2058 if newb != b:
2058 if newb != b:
2059 yield 'a', newb
2059 yield 'a', newb
2060 b = newb
2060 b = newb
2061 yield 'n', (r, list(p for p in cl.parentrevs(r)
2061 yield 'n', (r, list(p for p in cl.parentrevs(r)
2062 if p != -1))
2062 if p != -1))
2063 if tags:
2063 if tags:
2064 ls = labels.get(r)
2064 ls = labels.get(r)
2065 if ls:
2065 if ls:
2066 for l in ls:
2066 for l in ls:
2067 yield 'l', (r, l)
2067 yield 'l', (r, l)
2068 else:
2068 else:
2069 raise util.Abort(_('need repo for changelog dag'))
2069 raise util.Abort(_('need repo for changelog dag'))
2070
2070
2071 for line in dagparser.dagtextlines(events(),
2071 for line in dagparser.dagtextlines(events(),
2072 addspaces=spaces,
2072 addspaces=spaces,
2073 wraplabels=True,
2073 wraplabels=True,
2074 wrapannotations=True,
2074 wrapannotations=True,
2075 wrapnonlinear=dots,
2075 wrapnonlinear=dots,
2076 usedots=dots,
2076 usedots=dots,
2077 maxlinewidth=70):
2077 maxlinewidth=70):
2078 ui.write(line)
2078 ui.write(line)
2079 ui.write("\n")
2079 ui.write("\n")
2080
2080
2081 @command('debugdata',
2081 @command('debugdata',
2082 [('c', 'changelog', False, _('open changelog')),
2082 [('c', 'changelog', False, _('open changelog')),
2083 ('m', 'manifest', False, _('open manifest')),
2083 ('m', 'manifest', False, _('open manifest')),
2084 ('', 'dir', False, _('open directory manifest'))],
2084 ('', 'dir', False, _('open directory manifest'))],
2085 _('-c|-m|FILE REV'))
2085 _('-c|-m|FILE REV'))
2086 def debugdata(ui, repo, file_, rev=None, **opts):
2086 def debugdata(ui, repo, file_, rev=None, **opts):
2087 """dump the contents of a data file revision"""
2087 """dump the contents of a data file revision"""
2088 if opts.get('changelog') or opts.get('manifest'):
2088 if opts.get('changelog') or opts.get('manifest'):
2089 file_, rev = None, file_
2089 file_, rev = None, file_
2090 elif rev is None:
2090 elif rev is None:
2091 raise error.CommandError('debugdata', _('invalid arguments'))
2091 raise error.CommandError('debugdata', _('invalid arguments'))
2092 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2092 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2093 try:
2093 try:
2094 ui.write(r.revision(r.lookup(rev)))
2094 ui.write(r.revision(r.lookup(rev)))
2095 except KeyError:
2095 except KeyError:
2096 raise util.Abort(_('invalid revision identifier %s') % rev)
2096 raise util.Abort(_('invalid revision identifier %s') % rev)
2097
2097
2098 @command('debugdate',
2098 @command('debugdate',
2099 [('e', 'extended', None, _('try extended date formats'))],
2099 [('e', 'extended', None, _('try extended date formats'))],
2100 _('[-e] DATE [RANGE]'),
2100 _('[-e] DATE [RANGE]'),
2101 norepo=True, optionalrepo=True)
2101 norepo=True, optionalrepo=True)
2102 def debugdate(ui, date, range=None, **opts):
2102 def debugdate(ui, date, range=None, **opts):
2103 """parse and display a date"""
2103 """parse and display a date"""
2104 if opts["extended"]:
2104 if opts["extended"]:
2105 d = util.parsedate(date, util.extendeddateformats)
2105 d = util.parsedate(date, util.extendeddateformats)
2106 else:
2106 else:
2107 d = util.parsedate(date)
2107 d = util.parsedate(date)
2108 ui.write(("internal: %s %s\n") % d)
2108 ui.write(("internal: %s %s\n") % d)
2109 ui.write(("standard: %s\n") % util.datestr(d))
2109 ui.write(("standard: %s\n") % util.datestr(d))
2110 if range:
2110 if range:
2111 m = util.matchdate(range)
2111 m = util.matchdate(range)
2112 ui.write(("match: %s\n") % m(d[0]))
2112 ui.write(("match: %s\n") % m(d[0]))
2113
2113
2114 @command('debugdiscovery',
2114 @command('debugdiscovery',
2115 [('', 'old', None, _('use old-style discovery')),
2115 [('', 'old', None, _('use old-style discovery')),
2116 ('', 'nonheads', None,
2116 ('', 'nonheads', None,
2117 _('use old-style discovery with non-heads included')),
2117 _('use old-style discovery with non-heads included')),
2118 ] + remoteopts,
2118 ] + remoteopts,
2119 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2119 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2120 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2120 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2121 """runs the changeset discovery protocol in isolation"""
2121 """runs the changeset discovery protocol in isolation"""
2122 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2122 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2123 opts.get('branch'))
2123 opts.get('branch'))
2124 remote = hg.peer(repo, opts, remoteurl)
2124 remote = hg.peer(repo, opts, remoteurl)
2125 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2125 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2126
2126
2127 # make sure tests are repeatable
2127 # make sure tests are repeatable
2128 random.seed(12323)
2128 random.seed(12323)
2129
2129
2130 def doit(localheads, remoteheads, remote=remote):
2130 def doit(localheads, remoteheads, remote=remote):
2131 if opts.get('old'):
2131 if opts.get('old'):
2132 if localheads:
2132 if localheads:
2133 raise util.Abort('cannot use localheads with old style '
2133 raise util.Abort('cannot use localheads with old style '
2134 'discovery')
2134 'discovery')
2135 if not util.safehasattr(remote, 'branches'):
2135 if not util.safehasattr(remote, 'branches'):
2136 # enable in-client legacy support
2136 # enable in-client legacy support
2137 remote = localrepo.locallegacypeer(remote.local())
2137 remote = localrepo.locallegacypeer(remote.local())
2138 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2138 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2139 force=True)
2139 force=True)
2140 common = set(common)
2140 common = set(common)
2141 if not opts.get('nonheads'):
2141 if not opts.get('nonheads'):
2142 ui.write(("unpruned common: %s\n") %
2142 ui.write(("unpruned common: %s\n") %
2143 " ".join(sorted(short(n) for n in common)))
2143 " ".join(sorted(short(n) for n in common)))
2144 dag = dagutil.revlogdag(repo.changelog)
2144 dag = dagutil.revlogdag(repo.changelog)
2145 all = dag.ancestorset(dag.internalizeall(common))
2145 all = dag.ancestorset(dag.internalizeall(common))
2146 common = dag.externalizeall(dag.headsetofconnecteds(all))
2146 common = dag.externalizeall(dag.headsetofconnecteds(all))
2147 else:
2147 else:
2148 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2148 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2149 common = set(common)
2149 common = set(common)
2150 rheads = set(hds)
2150 rheads = set(hds)
2151 lheads = set(repo.heads())
2151 lheads = set(repo.heads())
2152 ui.write(("common heads: %s\n") %
2152 ui.write(("common heads: %s\n") %
2153 " ".join(sorted(short(n) for n in common)))
2153 " ".join(sorted(short(n) for n in common)))
2154 if lheads <= common:
2154 if lheads <= common:
2155 ui.write(("local is subset\n"))
2155 ui.write(("local is subset\n"))
2156 elif rheads <= common:
2156 elif rheads <= common:
2157 ui.write(("remote is subset\n"))
2157 ui.write(("remote is subset\n"))
2158
2158
2159 serverlogs = opts.get('serverlog')
2159 serverlogs = opts.get('serverlog')
2160 if serverlogs:
2160 if serverlogs:
2161 for filename in serverlogs:
2161 for filename in serverlogs:
2162 logfile = open(filename, 'r')
2162 logfile = open(filename, 'r')
2163 try:
2163 try:
2164 line = logfile.readline()
2164 line = logfile.readline()
2165 while line:
2165 while line:
2166 parts = line.strip().split(';')
2166 parts = line.strip().split(';')
2167 op = parts[1]
2167 op = parts[1]
2168 if op == 'cg':
2168 if op == 'cg':
2169 pass
2169 pass
2170 elif op == 'cgss':
2170 elif op == 'cgss':
2171 doit(parts[2].split(' '), parts[3].split(' '))
2171 doit(parts[2].split(' '), parts[3].split(' '))
2172 elif op == 'unb':
2172 elif op == 'unb':
2173 doit(parts[3].split(' '), parts[2].split(' '))
2173 doit(parts[3].split(' '), parts[2].split(' '))
2174 line = logfile.readline()
2174 line = logfile.readline()
2175 finally:
2175 finally:
2176 logfile.close()
2176 logfile.close()
2177
2177
2178 else:
2178 else:
2179 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2179 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2180 opts.get('remote_head'))
2180 opts.get('remote_head'))
2181 localrevs = opts.get('local_head')
2181 localrevs = opts.get('local_head')
2182 doit(localrevs, remoterevs)
2182 doit(localrevs, remoterevs)
2183
2183
2184 @command('debugextensions', formatteropts, [], norepo=True)
2184 @command('debugextensions', formatteropts, [], norepo=True)
2185 def debugextensions(ui, **opts):
2185 def debugextensions(ui, **opts):
2186 '''show information about active extensions'''
2186 '''show information about active extensions'''
2187 exts = extensions.extensions(ui)
2187 exts = extensions.extensions(ui)
2188 fm = ui.formatter('debugextensions', opts)
2188 fm = ui.formatter('debugextensions', opts)
2189 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2189 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2190 extsource = extmod.__file__
2190 extsource = extmod.__file__
2191 exttestedwith = getattr(extmod, 'testedwith', None)
2191 exttestedwith = getattr(extmod, 'testedwith', None)
2192 if exttestedwith is not None:
2192 if exttestedwith is not None:
2193 exttestedwith = exttestedwith.split()
2193 exttestedwith = exttestedwith.split()
2194 extbuglink = getattr(extmod, 'buglink', None)
2194 extbuglink = getattr(extmod, 'buglink', None)
2195
2195
2196 fm.startitem()
2196 fm.startitem()
2197
2197
2198 if ui.quiet or ui.verbose:
2198 if ui.quiet or ui.verbose:
2199 fm.write('name', '%s\n', extname)
2199 fm.write('name', '%s\n', extname)
2200 else:
2200 else:
2201 fm.write('name', '%s', extname)
2201 fm.write('name', '%s', extname)
2202 if not exttestedwith:
2202 if not exttestedwith:
2203 fm.plain(_(' (untested!)\n'))
2203 fm.plain(_(' (untested!)\n'))
2204 else:
2204 else:
2205 if exttestedwith == ['internal'] or \
2205 if exttestedwith == ['internal'] or \
2206 util.version() in exttestedwith:
2206 util.version() in exttestedwith:
2207 fm.plain('\n')
2207 fm.plain('\n')
2208 else:
2208 else:
2209 lasttestedversion = exttestedwith[-1]
2209 lasttestedversion = exttestedwith[-1]
2210 fm.plain(' (%s!)\n' % lasttestedversion)
2210 fm.plain(' (%s!)\n' % lasttestedversion)
2211
2211
2212 fm.condwrite(ui.verbose and extsource, 'source',
2212 fm.condwrite(ui.verbose and extsource, 'source',
2213 _(' location: %s\n'), extsource or "")
2213 _(' location: %s\n'), extsource or "")
2214
2214
2215 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2215 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2216 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2216 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2217
2217
2218 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2218 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2219 _(' bug reporting: %s\n'), extbuglink or "")
2219 _(' bug reporting: %s\n'), extbuglink or "")
2220
2220
2221 fm.end()
2221 fm.end()
2222
2222
2223 @command('debugfileset',
2223 @command('debugfileset',
2224 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2224 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2225 _('[-r REV] FILESPEC'))
2225 _('[-r REV] FILESPEC'))
2226 def debugfileset(ui, repo, expr, **opts):
2226 def debugfileset(ui, repo, expr, **opts):
2227 '''parse and apply a fileset specification'''
2227 '''parse and apply a fileset specification'''
2228 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2228 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2229 if ui.verbose:
2229 if ui.verbose:
2230 tree = fileset.parse(expr)
2230 tree = fileset.parse(expr)
2231 ui.note(fileset.prettyformat(tree), "\n")
2231 ui.note(fileset.prettyformat(tree), "\n")
2232
2232
2233 for f in ctx.getfileset(expr):
2233 for f in ctx.getfileset(expr):
2234 ui.write("%s\n" % f)
2234 ui.write("%s\n" % f)
2235
2235
2236 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2236 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2237 def debugfsinfo(ui, path="."):
2237 def debugfsinfo(ui, path="."):
2238 """show information detected about current filesystem"""
2238 """show information detected about current filesystem"""
2239 util.writefile('.debugfsinfo', '')
2239 util.writefile('.debugfsinfo', '')
2240 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2240 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2241 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2241 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2242 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2242 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2243 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2243 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2244 and 'yes' or 'no'))
2244 and 'yes' or 'no'))
2245 os.unlink('.debugfsinfo')
2245 os.unlink('.debugfsinfo')
2246
2246
2247 @command('debuggetbundle',
2247 @command('debuggetbundle',
2248 [('H', 'head', [], _('id of head node'), _('ID')),
2248 [('H', 'head', [], _('id of head node'), _('ID')),
2249 ('C', 'common', [], _('id of common node'), _('ID')),
2249 ('C', 'common', [], _('id of common node'), _('ID')),
2250 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2250 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2251 _('REPO FILE [-H|-C ID]...'),
2251 _('REPO FILE [-H|-C ID]...'),
2252 norepo=True)
2252 norepo=True)
2253 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2253 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2254 """retrieves a bundle from a repo
2254 """retrieves a bundle from a repo
2255
2255
2256 Every ID must be a full-length hex node id string. Saves the bundle to the
2256 Every ID must be a full-length hex node id string. Saves the bundle to the
2257 given file.
2257 given file.
2258 """
2258 """
2259 repo = hg.peer(ui, opts, repopath)
2259 repo = hg.peer(ui, opts, repopath)
2260 if not repo.capable('getbundle'):
2260 if not repo.capable('getbundle'):
2261 raise util.Abort("getbundle() not supported by target repository")
2261 raise util.Abort("getbundle() not supported by target repository")
2262 args = {}
2262 args = {}
2263 if common:
2263 if common:
2264 args['common'] = [bin(s) for s in common]
2264 args['common'] = [bin(s) for s in common]
2265 if head:
2265 if head:
2266 args['heads'] = [bin(s) for s in head]
2266 args['heads'] = [bin(s) for s in head]
2267 # TODO: get desired bundlecaps from command line.
2267 # TODO: get desired bundlecaps from command line.
2268 args['bundlecaps'] = None
2268 args['bundlecaps'] = None
2269 bundle = repo.getbundle('debug', **args)
2269 bundle = repo.getbundle('debug', **args)
2270
2270
2271 bundletype = opts.get('type', 'bzip2').lower()
2271 bundletype = opts.get('type', 'bzip2').lower()
2272 btypes = {'none': 'HG10UN',
2272 btypes = {'none': 'HG10UN',
2273 'bzip2': 'HG10BZ',
2273 'bzip2': 'HG10BZ',
2274 'gzip': 'HG10GZ',
2274 'gzip': 'HG10GZ',
2275 'bundle2': 'HG20'}
2275 'bundle2': 'HG20'}
2276 bundletype = btypes.get(bundletype)
2276 bundletype = btypes.get(bundletype)
2277 if bundletype not in changegroup.bundletypes:
2277 if bundletype not in changegroup.bundletypes:
2278 raise util.Abort(_('unknown bundle type specified with --type'))
2278 raise util.Abort(_('unknown bundle type specified with --type'))
2279 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2279 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2280
2280
2281 @command('debugignore', [], '')
2281 @command('debugignore', [], '')
2282 def debugignore(ui, repo, *values, **opts):
2282 def debugignore(ui, repo, *values, **opts):
2283 """display the combined ignore pattern"""
2283 """display the combined ignore pattern"""
2284 ignore = repo.dirstate._ignore
2284 ignore = repo.dirstate._ignore
2285 includepat = getattr(ignore, 'includepat', None)
2285 includepat = getattr(ignore, 'includepat', None)
2286 if includepat is not None:
2286 if includepat is not None:
2287 ui.write("%s\n" % includepat)
2287 ui.write("%s\n" % includepat)
2288 else:
2288 else:
2289 raise util.Abort(_("no ignore patterns found"))
2289 raise util.Abort(_("no ignore patterns found"))
2290
2290
2291 @command('debugindex',
2291 @command('debugindex',
2292 [('c', 'changelog', False, _('open changelog')),
2292 [('c', 'changelog', False, _('open changelog')),
2293 ('m', 'manifest', False, _('open manifest')),
2293 ('m', 'manifest', False, _('open manifest')),
2294 ('', 'dir', False, _('open directory manifest')),
2294 ('', 'dir', False, _('open directory manifest')),
2295 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2295 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2296 _('[-f FORMAT] -c|-m|FILE'),
2296 _('[-f FORMAT] -c|-m|FILE'),
2297 optionalrepo=True)
2297 optionalrepo=True)
2298 def debugindex(ui, repo, file_=None, **opts):
2298 def debugindex(ui, repo, file_=None, **opts):
2299 """dump the contents of an index file"""
2299 """dump the contents of an index file"""
2300 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2300 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2301 format = opts.get('format', 0)
2301 format = opts.get('format', 0)
2302 if format not in (0, 1):
2302 if format not in (0, 1):
2303 raise util.Abort(_("unknown format %d") % format)
2303 raise util.Abort(_("unknown format %d") % format)
2304
2304
2305 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2305 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2306 if generaldelta:
2306 if generaldelta:
2307 basehdr = ' delta'
2307 basehdr = ' delta'
2308 else:
2308 else:
2309 basehdr = ' base'
2309 basehdr = ' base'
2310
2310
2311 if ui.debugflag:
2311 if ui.debugflag:
2312 shortfn = hex
2312 shortfn = hex
2313 else:
2313 else:
2314 shortfn = short
2314 shortfn = short
2315
2315
2316 # There might not be anything in r, so have a sane default
2316 # There might not be anything in r, so have a sane default
2317 idlen = 12
2317 idlen = 12
2318 for i in r:
2318 for i in r:
2319 idlen = len(shortfn(r.node(i)))
2319 idlen = len(shortfn(r.node(i)))
2320 break
2320 break
2321
2321
2322 if format == 0:
2322 if format == 0:
2323 ui.write(" rev offset length " + basehdr + " linkrev"
2323 ui.write(" rev offset length " + basehdr + " linkrev"
2324 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2324 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2325 elif format == 1:
2325 elif format == 1:
2326 ui.write(" rev flag offset length"
2326 ui.write(" rev flag offset length"
2327 " size " + basehdr + " link p1 p2"
2327 " size " + basehdr + " link p1 p2"
2328 " %s\n" % "nodeid".rjust(idlen))
2328 " %s\n" % "nodeid".rjust(idlen))
2329
2329
2330 for i in r:
2330 for i in r:
2331 node = r.node(i)
2331 node = r.node(i)
2332 if generaldelta:
2332 if generaldelta:
2333 base = r.deltaparent(i)
2333 base = r.deltaparent(i)
2334 else:
2334 else:
2335 base = r.chainbase(i)
2335 base = r.chainbase(i)
2336 if format == 0:
2336 if format == 0:
2337 try:
2337 try:
2338 pp = r.parents(node)
2338 pp = r.parents(node)
2339 except Exception:
2339 except Exception:
2340 pp = [nullid, nullid]
2340 pp = [nullid, nullid]
2341 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2341 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2342 i, r.start(i), r.length(i), base, r.linkrev(i),
2342 i, r.start(i), r.length(i), base, r.linkrev(i),
2343 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2343 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2344 elif format == 1:
2344 elif format == 1:
2345 pr = r.parentrevs(i)
2345 pr = r.parentrevs(i)
2346 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2346 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2347 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2347 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2348 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2348 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2349
2349
2350 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2350 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2351 def debugindexdot(ui, repo, file_):
2351 def debugindexdot(ui, repo, file_):
2352 """dump an index DAG as a graphviz dot file"""
2352 """dump an index DAG as a graphviz dot file"""
2353 r = None
2353 r = None
2354 if repo:
2354 if repo:
2355 filelog = repo.file(file_)
2355 filelog = repo.file(file_)
2356 if len(filelog):
2356 if len(filelog):
2357 r = filelog
2357 r = filelog
2358 if not r:
2358 if not r:
2359 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2359 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2360 ui.write(("digraph G {\n"))
2360 ui.write(("digraph G {\n"))
2361 for i in r:
2361 for i in r:
2362 node = r.node(i)
2362 node = r.node(i)
2363 pp = r.parents(node)
2363 pp = r.parents(node)
2364 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2364 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2365 if pp[1] != nullid:
2365 if pp[1] != nullid:
2366 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2366 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2367 ui.write("}\n")
2367 ui.write("}\n")
2368
2368
2369 @command('debuginstall', [], '', norepo=True)
2369 @command('debuginstall', [], '', norepo=True)
2370 def debuginstall(ui):
2370 def debuginstall(ui):
2371 '''test Mercurial installation
2371 '''test Mercurial installation
2372
2372
2373 Returns 0 on success.
2373 Returns 0 on success.
2374 '''
2374 '''
2375
2375
2376 def writetemp(contents):
2376 def writetemp(contents):
2377 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2377 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2378 f = os.fdopen(fd, "wb")
2378 f = os.fdopen(fd, "wb")
2379 f.write(contents)
2379 f.write(contents)
2380 f.close()
2380 f.close()
2381 return name
2381 return name
2382
2382
2383 problems = 0
2383 problems = 0
2384
2384
2385 # encoding
2385 # encoding
2386 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2386 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2387 try:
2387 try:
2388 encoding.fromlocal("test")
2388 encoding.fromlocal("test")
2389 except util.Abort as inst:
2389 except util.Abort as inst:
2390 ui.write(" %s\n" % inst)
2390 ui.write(" %s\n" % inst)
2391 ui.write(_(" (check that your locale is properly set)\n"))
2391 ui.write(_(" (check that your locale is properly set)\n"))
2392 problems += 1
2392 problems += 1
2393
2393
2394 # Python
2394 # Python
2395 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2395 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2396 ui.status(_("checking Python version (%s)\n")
2396 ui.status(_("checking Python version (%s)\n")
2397 % ("%s.%s.%s" % sys.version_info[:3]))
2397 % ("%s.%s.%s" % sys.version_info[:3]))
2398 ui.status(_("checking Python lib (%s)...\n")
2398 ui.status(_("checking Python lib (%s)...\n")
2399 % os.path.dirname(os.__file__))
2399 % os.path.dirname(os.__file__))
2400
2400
2401 # compiled modules
2401 # compiled modules
2402 ui.status(_("checking installed modules (%s)...\n")
2402 ui.status(_("checking installed modules (%s)...\n")
2403 % os.path.dirname(__file__))
2403 % os.path.dirname(__file__))
2404 try:
2404 try:
2405 import bdiff, mpatch, base85, osutil
2405 import bdiff, mpatch, base85, osutil
2406 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2406 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2407 except Exception as inst:
2407 except Exception as inst:
2408 ui.write(" %s\n" % inst)
2408 ui.write(" %s\n" % inst)
2409 ui.write(_(" One or more extensions could not be found"))
2409 ui.write(_(" One or more extensions could not be found"))
2410 ui.write(_(" (check that you compiled the extensions)\n"))
2410 ui.write(_(" (check that you compiled the extensions)\n"))
2411 problems += 1
2411 problems += 1
2412
2412
2413 # templates
2413 # templates
2414 import templater
2414 import templater
2415 p = templater.templatepaths()
2415 p = templater.templatepaths()
2416 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2416 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2417 if p:
2417 if p:
2418 m = templater.templatepath("map-cmdline.default")
2418 m = templater.templatepath("map-cmdline.default")
2419 if m:
2419 if m:
2420 # template found, check if it is working
2420 # template found, check if it is working
2421 try:
2421 try:
2422 templater.templater(m)
2422 templater.templater(m)
2423 except Exception as inst:
2423 except Exception as inst:
2424 ui.write(" %s\n" % inst)
2424 ui.write(" %s\n" % inst)
2425 p = None
2425 p = None
2426 else:
2426 else:
2427 ui.write(_(" template 'default' not found\n"))
2427 ui.write(_(" template 'default' not found\n"))
2428 p = None
2428 p = None
2429 else:
2429 else:
2430 ui.write(_(" no template directories found\n"))
2430 ui.write(_(" no template directories found\n"))
2431 if not p:
2431 if not p:
2432 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2432 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2433 problems += 1
2433 problems += 1
2434
2434
2435 # editor
2435 # editor
2436 ui.status(_("checking commit editor...\n"))
2436 ui.status(_("checking commit editor...\n"))
2437 editor = ui.geteditor()
2437 editor = ui.geteditor()
2438 editor = util.expandpath(editor)
2438 editor = util.expandpath(editor)
2439 cmdpath = util.findexe(shlex.split(editor)[0])
2439 cmdpath = util.findexe(shlex.split(editor)[0])
2440 if not cmdpath:
2440 if not cmdpath:
2441 if editor == 'vi':
2441 if editor == 'vi':
2442 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2442 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2443 ui.write(_(" (specify a commit editor in your configuration"
2443 ui.write(_(" (specify a commit editor in your configuration"
2444 " file)\n"))
2444 " file)\n"))
2445 else:
2445 else:
2446 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2446 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2447 ui.write(_(" (specify a commit editor in your configuration"
2447 ui.write(_(" (specify a commit editor in your configuration"
2448 " file)\n"))
2448 " file)\n"))
2449 problems += 1
2449 problems += 1
2450
2450
2451 # check username
2451 # check username
2452 ui.status(_("checking username...\n"))
2452 ui.status(_("checking username...\n"))
2453 try:
2453 try:
2454 ui.username()
2454 ui.username()
2455 except util.Abort as e:
2455 except util.Abort as e:
2456 ui.write(" %s\n" % e)
2456 ui.write(" %s\n" % e)
2457 ui.write(_(" (specify a username in your configuration file)\n"))
2457 ui.write(_(" (specify a username in your configuration file)\n"))
2458 problems += 1
2458 problems += 1
2459
2459
2460 if not problems:
2460 if not problems:
2461 ui.status(_("no problems detected\n"))
2461 ui.status(_("no problems detected\n"))
2462 else:
2462 else:
2463 ui.write(_("%s problems detected,"
2463 ui.write(_("%s problems detected,"
2464 " please check your install!\n") % problems)
2464 " please check your install!\n") % problems)
2465
2465
2466 return problems
2466 return problems
2467
2467
2468 @command('debugknown', [], _('REPO ID...'), norepo=True)
2468 @command('debugknown', [], _('REPO ID...'), norepo=True)
2469 def debugknown(ui, repopath, *ids, **opts):
2469 def debugknown(ui, repopath, *ids, **opts):
2470 """test whether node ids are known to a repo
2470 """test whether node ids are known to a repo
2471
2471
2472 Every ID must be a full-length hex node id string. Returns a list of 0s
2472 Every ID must be a full-length hex node id string. Returns a list of 0s
2473 and 1s indicating unknown/known.
2473 and 1s indicating unknown/known.
2474 """
2474 """
2475 repo = hg.peer(ui, opts, repopath)
2475 repo = hg.peer(ui, opts, repopath)
2476 if not repo.capable('known'):
2476 if not repo.capable('known'):
2477 raise util.Abort("known() not supported by target repository")
2477 raise util.Abort("known() not supported by target repository")
2478 flags = repo.known([bin(s) for s in ids])
2478 flags = repo.known([bin(s) for s in ids])
2479 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2479 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2480
2480
2481 @command('debuglabelcomplete', [], _('LABEL...'))
2481 @command('debuglabelcomplete', [], _('LABEL...'))
2482 def debuglabelcomplete(ui, repo, *args):
2482 def debuglabelcomplete(ui, repo, *args):
2483 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2483 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2484 debugnamecomplete(ui, repo, *args)
2484 debugnamecomplete(ui, repo, *args)
2485
2485
2486 @command('debugmergestate', [], '')
2486 @command('debugmergestate', [], '')
2487 def debugmergestate(ui, repo, *args):
2487 def debugmergestate(ui, repo, *args):
2488 """print merge state
2488 """print merge state
2489
2489
2490 Use --verbose to print out information about whether v1 or v2 merge state
2490 Use --verbose to print out information about whether v1 or v2 merge state
2491 was chosen."""
2491 was chosen."""
2492 def printrecords(version):
2492 def printrecords(version):
2493 ui.write(('* version %s records\n') % version)
2493 ui.write(('* version %s records\n') % version)
2494 if version == 1:
2494 if version == 1:
2495 records = v1records
2495 records = v1records
2496 else:
2496 else:
2497 records = v2records
2497 records = v2records
2498
2498
2499 for rtype, record in records:
2499 for rtype, record in records:
2500 # pretty print some record types
2500 # pretty print some record types
2501 if rtype == 'L':
2501 if rtype == 'L':
2502 ui.write(('local: %s\n') % record)
2502 ui.write(('local: %s\n') % record)
2503 elif rtype == 'O':
2503 elif rtype == 'O':
2504 ui.write(('other: %s\n') % record)
2504 ui.write(('other: %s\n') % record)
2505 elif rtype == 'F':
2505 elif rtype == 'F':
2506 r = record.split('\0')
2506 r = record.split('\0')
2507 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2507 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2508 if version == 1:
2508 if version == 1:
2509 onode = 'not stored in v1 format'
2509 onode = 'not stored in v1 format'
2510 flags = r[7]
2510 flags = r[7]
2511 else:
2511 else:
2512 onode, flags = r[7:9]
2512 onode, flags = r[7:9]
2513 ui.write(('file: %s (state "%s", hash %s)\n')
2513 ui.write(('file: %s (state "%s", hash %s)\n')
2514 % (f, state, hash))
2514 % (f, state, hash))
2515 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2515 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2516 ui.write((' ancestor path: %s (node %s)\n') % (afile, anode))
2516 ui.write((' ancestor path: %s (node %s)\n') % (afile, anode))
2517 ui.write((' other path: %s (node %s)\n') % (ofile, onode))
2517 ui.write((' other path: %s (node %s)\n') % (ofile, onode))
2518 else:
2518 else:
2519 ui.write(('unrecognized entry: %s\t%s\n')
2519 ui.write(('unrecognized entry: %s\t%s\n')
2520 % (rtype, record.replace('\0', '\t')))
2520 % (rtype, record.replace('\0', '\t')))
2521
2521
2522 ms = mergemod.mergestate(repo)
2522 ms = mergemod.mergestate(repo)
2523
2523
2524 # sort so that reasonable information is on top
2524 # sort so that reasonable information is on top
2525 v1records = ms._readrecordsv1()
2525 v1records = ms._readrecordsv1()
2526 v2records = ms._readrecordsv2()
2526 v2records = ms._readrecordsv2()
2527 order = 'LO'
2527 order = 'LO'
2528 def key(r):
2528 def key(r):
2529 idx = order.find(r[0])
2529 idx = order.find(r[0])
2530 if idx == -1:
2530 if idx == -1:
2531 return (1, r[1])
2531 return (1, r[1])
2532 else:
2532 else:
2533 return (0, idx)
2533 return (0, idx)
2534 v1records.sort(key=key)
2534 v1records.sort(key=key)
2535 v2records.sort(key=key)
2535 v2records.sort(key=key)
2536
2536
2537 if not v1records and not v2records:
2537 if not v1records and not v2records:
2538 ui.write(('no merge state found\n'))
2538 ui.write(('no merge state found\n'))
2539 elif not v2records:
2539 elif not v2records:
2540 ui.note(('no version 2 merge state\n'))
2540 ui.note(('no version 2 merge state\n'))
2541 printrecords(1)
2541 printrecords(1)
2542 elif ms._v1v2match(v1records, v2records):
2542 elif ms._v1v2match(v1records, v2records):
2543 ui.note(('v1 and v2 states match: using v2\n'))
2543 ui.note(('v1 and v2 states match: using v2\n'))
2544 printrecords(2)
2544 printrecords(2)
2545 else:
2545 else:
2546 ui.note(('v1 and v2 states mismatch: using v1\n'))
2546 ui.note(('v1 and v2 states mismatch: using v1\n'))
2547 printrecords(1)
2547 printrecords(1)
2548 if ui.verbose:
2548 if ui.verbose:
2549 printrecords(2)
2549 printrecords(2)
2550
2550
2551 @command('debugnamecomplete', [], _('NAME...'))
2551 @command('debugnamecomplete', [], _('NAME...'))
2552 def debugnamecomplete(ui, repo, *args):
2552 def debugnamecomplete(ui, repo, *args):
2553 '''complete "names" - tags, open branch names, bookmark names'''
2553 '''complete "names" - tags, open branch names, bookmark names'''
2554
2554
2555 names = set()
2555 names = set()
2556 # since we previously only listed open branches, we will handle that
2556 # since we previously only listed open branches, we will handle that
2557 # specially (after this for loop)
2557 # specially (after this for loop)
2558 for name, ns in repo.names.iteritems():
2558 for name, ns in repo.names.iteritems():
2559 if name != 'branches':
2559 if name != 'branches':
2560 names.update(ns.listnames(repo))
2560 names.update(ns.listnames(repo))
2561 names.update(tag for (tag, heads, tip, closed)
2561 names.update(tag for (tag, heads, tip, closed)
2562 in repo.branchmap().iterbranches() if not closed)
2562 in repo.branchmap().iterbranches() if not closed)
2563 completions = set()
2563 completions = set()
2564 if not args:
2564 if not args:
2565 args = ['']
2565 args = ['']
2566 for a in args:
2566 for a in args:
2567 completions.update(n for n in names if n.startswith(a))
2567 completions.update(n for n in names if n.startswith(a))
2568 ui.write('\n'.join(sorted(completions)))
2568 ui.write('\n'.join(sorted(completions)))
2569 ui.write('\n')
2569 ui.write('\n')
2570
2570
2571 @command('debuglocks',
2571 @command('debuglocks',
2572 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2572 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2573 ('W', 'force-wlock', None,
2573 ('W', 'force-wlock', None,
2574 _('free the working state lock (DANGEROUS)'))],
2574 _('free the working state lock (DANGEROUS)'))],
2575 _('[OPTION]...'))
2575 _('[OPTION]...'))
2576 def debuglocks(ui, repo, **opts):
2576 def debuglocks(ui, repo, **opts):
2577 """show or modify state of locks
2577 """show or modify state of locks
2578
2578
2579 By default, this command will show which locks are held. This
2579 By default, this command will show which locks are held. This
2580 includes the user and process holding the lock, the amount of time
2580 includes the user and process holding the lock, the amount of time
2581 the lock has been held, and the machine name where the process is
2581 the lock has been held, and the machine name where the process is
2582 running if it's not local.
2582 running if it's not local.
2583
2583
2584 Locks protect the integrity of Mercurial's data, so should be
2584 Locks protect the integrity of Mercurial's data, so should be
2585 treated with care. System crashes or other interruptions may cause
2585 treated with care. System crashes or other interruptions may cause
2586 locks to not be properly released, though Mercurial will usually
2586 locks to not be properly released, though Mercurial will usually
2587 detect and remove such stale locks automatically.
2587 detect and remove such stale locks automatically.
2588
2588
2589 However, detecting stale locks may not always be possible (for
2589 However, detecting stale locks may not always be possible (for
2590 instance, on a shared filesystem). Removing locks may also be
2590 instance, on a shared filesystem). Removing locks may also be
2591 blocked by filesystem permissions.
2591 blocked by filesystem permissions.
2592
2592
2593 Returns 0 if no locks are held.
2593 Returns 0 if no locks are held.
2594
2594
2595 """
2595 """
2596
2596
2597 if opts.get('force_lock'):
2597 if opts.get('force_lock'):
2598 repo.svfs.unlink('lock')
2598 repo.svfs.unlink('lock')
2599 if opts.get('force_wlock'):
2599 if opts.get('force_wlock'):
2600 repo.vfs.unlink('wlock')
2600 repo.vfs.unlink('wlock')
2601 if opts.get('force_lock') or opts.get('force_lock'):
2601 if opts.get('force_lock') or opts.get('force_lock'):
2602 return 0
2602 return 0
2603
2603
2604 now = time.time()
2604 now = time.time()
2605 held = 0
2605 held = 0
2606
2606
2607 def report(vfs, name, method):
2607 def report(vfs, name, method):
2608 # this causes stale locks to get reaped for more accurate reporting
2608 # this causes stale locks to get reaped for more accurate reporting
2609 try:
2609 try:
2610 l = method(False)
2610 l = method(False)
2611 except error.LockHeld:
2611 except error.LockHeld:
2612 l = None
2612 l = None
2613
2613
2614 if l:
2614 if l:
2615 l.release()
2615 l.release()
2616 else:
2616 else:
2617 try:
2617 try:
2618 stat = vfs.lstat(name)
2618 stat = vfs.lstat(name)
2619 age = now - stat.st_mtime
2619 age = now - stat.st_mtime
2620 user = util.username(stat.st_uid)
2620 user = util.username(stat.st_uid)
2621 locker = vfs.readlock(name)
2621 locker = vfs.readlock(name)
2622 if ":" in locker:
2622 if ":" in locker:
2623 host, pid = locker.split(':')
2623 host, pid = locker.split(':')
2624 if host == socket.gethostname():
2624 if host == socket.gethostname():
2625 locker = 'user %s, process %s' % (user, pid)
2625 locker = 'user %s, process %s' % (user, pid)
2626 else:
2626 else:
2627 locker = 'user %s, process %s, host %s' \
2627 locker = 'user %s, process %s, host %s' \
2628 % (user, pid, host)
2628 % (user, pid, host)
2629 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2629 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2630 return 1
2630 return 1
2631 except OSError as e:
2631 except OSError as e:
2632 if e.errno != errno.ENOENT:
2632 if e.errno != errno.ENOENT:
2633 raise
2633 raise
2634
2634
2635 ui.write("%-6s free\n" % (name + ":"))
2635 ui.write("%-6s free\n" % (name + ":"))
2636 return 0
2636 return 0
2637
2637
2638 held += report(repo.svfs, "lock", repo.lock)
2638 held += report(repo.svfs, "lock", repo.lock)
2639 held += report(repo.vfs, "wlock", repo.wlock)
2639 held += report(repo.vfs, "wlock", repo.wlock)
2640
2640
2641 return held
2641 return held
2642
2642
2643 @command('debugobsolete',
2643 @command('debugobsolete',
2644 [('', 'flags', 0, _('markers flag')),
2644 [('', 'flags', 0, _('markers flag')),
2645 ('', 'record-parents', False,
2645 ('', 'record-parents', False,
2646 _('record parent information for the precursor')),
2646 _('record parent information for the precursor')),
2647 ('r', 'rev', [], _('display markers relevant to REV')),
2647 ('r', 'rev', [], _('display markers relevant to REV')),
2648 ] + commitopts2,
2648 ] + commitopts2,
2649 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2649 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2650 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2650 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2651 """create arbitrary obsolete marker
2651 """create arbitrary obsolete marker
2652
2652
2653 With no arguments, displays the list of obsolescence markers."""
2653 With no arguments, displays the list of obsolescence markers."""
2654
2654
2655 def parsenodeid(s):
2655 def parsenodeid(s):
2656 try:
2656 try:
2657 # We do not use revsingle/revrange functions here to accept
2657 # We do not use revsingle/revrange functions here to accept
2658 # arbitrary node identifiers, possibly not present in the
2658 # arbitrary node identifiers, possibly not present in the
2659 # local repository.
2659 # local repository.
2660 n = bin(s)
2660 n = bin(s)
2661 if len(n) != len(nullid):
2661 if len(n) != len(nullid):
2662 raise TypeError()
2662 raise TypeError()
2663 return n
2663 return n
2664 except TypeError:
2664 except TypeError:
2665 raise util.Abort('changeset references must be full hexadecimal '
2665 raise util.Abort('changeset references must be full hexadecimal '
2666 'node identifiers')
2666 'node identifiers')
2667
2667
2668 if precursor is not None:
2668 if precursor is not None:
2669 if opts['rev']:
2669 if opts['rev']:
2670 raise util.Abort('cannot select revision when creating marker')
2670 raise util.Abort('cannot select revision when creating marker')
2671 metadata = {}
2671 metadata = {}
2672 metadata['user'] = opts['user'] or ui.username()
2672 metadata['user'] = opts['user'] or ui.username()
2673 succs = tuple(parsenodeid(succ) for succ in successors)
2673 succs = tuple(parsenodeid(succ) for succ in successors)
2674 l = repo.lock()
2674 l = repo.lock()
2675 try:
2675 try:
2676 tr = repo.transaction('debugobsolete')
2676 tr = repo.transaction('debugobsolete')
2677 try:
2677 try:
2678 date = opts.get('date')
2678 date = opts.get('date')
2679 if date:
2679 if date:
2680 date = util.parsedate(date)
2680 date = util.parsedate(date)
2681 else:
2681 else:
2682 date = None
2682 date = None
2683 prec = parsenodeid(precursor)
2683 prec = parsenodeid(precursor)
2684 parents = None
2684 parents = None
2685 if opts['record_parents']:
2685 if opts['record_parents']:
2686 if prec not in repo.unfiltered():
2686 if prec not in repo.unfiltered():
2687 raise util.Abort('cannot used --record-parents on '
2687 raise util.Abort('cannot used --record-parents on '
2688 'unknown changesets')
2688 'unknown changesets')
2689 parents = repo.unfiltered()[prec].parents()
2689 parents = repo.unfiltered()[prec].parents()
2690 parents = tuple(p.node() for p in parents)
2690 parents = tuple(p.node() for p in parents)
2691 repo.obsstore.create(tr, prec, succs, opts['flags'],
2691 repo.obsstore.create(tr, prec, succs, opts['flags'],
2692 parents=parents, date=date,
2692 parents=parents, date=date,
2693 metadata=metadata)
2693 metadata=metadata)
2694 tr.close()
2694 tr.close()
2695 except ValueError as exc:
2695 except ValueError as exc:
2696 raise util.Abort(_('bad obsmarker input: %s') % exc)
2696 raise util.Abort(_('bad obsmarker input: %s') % exc)
2697 finally:
2697 finally:
2698 tr.release()
2698 tr.release()
2699 finally:
2699 finally:
2700 l.release()
2700 l.release()
2701 else:
2701 else:
2702 if opts['rev']:
2702 if opts['rev']:
2703 revs = scmutil.revrange(repo, opts['rev'])
2703 revs = scmutil.revrange(repo, opts['rev'])
2704 nodes = [repo[r].node() for r in revs]
2704 nodes = [repo[r].node() for r in revs]
2705 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2705 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2706 markers.sort(key=lambda x: x._data)
2706 markers.sort(key=lambda x: x._data)
2707 else:
2707 else:
2708 markers = obsolete.getmarkers(repo)
2708 markers = obsolete.getmarkers(repo)
2709
2709
2710 for m in markers:
2710 for m in markers:
2711 cmdutil.showmarker(ui, m)
2711 cmdutil.showmarker(ui, m)
2712
2712
2713 @command('debugpathcomplete',
2713 @command('debugpathcomplete',
2714 [('f', 'full', None, _('complete an entire path')),
2714 [('f', 'full', None, _('complete an entire path')),
2715 ('n', 'normal', None, _('show only normal files')),
2715 ('n', 'normal', None, _('show only normal files')),
2716 ('a', 'added', None, _('show only added files')),
2716 ('a', 'added', None, _('show only added files')),
2717 ('r', 'removed', None, _('show only removed files'))],
2717 ('r', 'removed', None, _('show only removed files'))],
2718 _('FILESPEC...'))
2718 _('FILESPEC...'))
2719 def debugpathcomplete(ui, repo, *specs, **opts):
2719 def debugpathcomplete(ui, repo, *specs, **opts):
2720 '''complete part or all of a tracked path
2720 '''complete part or all of a tracked path
2721
2721
2722 This command supports shells that offer path name completion. It
2722 This command supports shells that offer path name completion. It
2723 currently completes only files already known to the dirstate.
2723 currently completes only files already known to the dirstate.
2724
2724
2725 Completion extends only to the next path segment unless
2725 Completion extends only to the next path segment unless
2726 --full is specified, in which case entire paths are used.'''
2726 --full is specified, in which case entire paths are used.'''
2727
2727
2728 def complete(path, acceptable):
2728 def complete(path, acceptable):
2729 dirstate = repo.dirstate
2729 dirstate = repo.dirstate
2730 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2730 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2731 rootdir = repo.root + os.sep
2731 rootdir = repo.root + os.sep
2732 if spec != repo.root and not spec.startswith(rootdir):
2732 if spec != repo.root and not spec.startswith(rootdir):
2733 return [], []
2733 return [], []
2734 if os.path.isdir(spec):
2734 if os.path.isdir(spec):
2735 spec += '/'
2735 spec += '/'
2736 spec = spec[len(rootdir):]
2736 spec = spec[len(rootdir):]
2737 fixpaths = os.sep != '/'
2737 fixpaths = os.sep != '/'
2738 if fixpaths:
2738 if fixpaths:
2739 spec = spec.replace(os.sep, '/')
2739 spec = spec.replace(os.sep, '/')
2740 speclen = len(spec)
2740 speclen = len(spec)
2741 fullpaths = opts['full']
2741 fullpaths = opts['full']
2742 files, dirs = set(), set()
2742 files, dirs = set(), set()
2743 adddir, addfile = dirs.add, files.add
2743 adddir, addfile = dirs.add, files.add
2744 for f, st in dirstate.iteritems():
2744 for f, st in dirstate.iteritems():
2745 if f.startswith(spec) and st[0] in acceptable:
2745 if f.startswith(spec) and st[0] in acceptable:
2746 if fixpaths:
2746 if fixpaths:
2747 f = f.replace('/', os.sep)
2747 f = f.replace('/', os.sep)
2748 if fullpaths:
2748 if fullpaths:
2749 addfile(f)
2749 addfile(f)
2750 continue
2750 continue
2751 s = f.find(os.sep, speclen)
2751 s = f.find(os.sep, speclen)
2752 if s >= 0:
2752 if s >= 0:
2753 adddir(f[:s])
2753 adddir(f[:s])
2754 else:
2754 else:
2755 addfile(f)
2755 addfile(f)
2756 return files, dirs
2756 return files, dirs
2757
2757
2758 acceptable = ''
2758 acceptable = ''
2759 if opts['normal']:
2759 if opts['normal']:
2760 acceptable += 'nm'
2760 acceptable += 'nm'
2761 if opts['added']:
2761 if opts['added']:
2762 acceptable += 'a'
2762 acceptable += 'a'
2763 if opts['removed']:
2763 if opts['removed']:
2764 acceptable += 'r'
2764 acceptable += 'r'
2765 cwd = repo.getcwd()
2765 cwd = repo.getcwd()
2766 if not specs:
2766 if not specs:
2767 specs = ['.']
2767 specs = ['.']
2768
2768
2769 files, dirs = set(), set()
2769 files, dirs = set(), set()
2770 for spec in specs:
2770 for spec in specs:
2771 f, d = complete(spec, acceptable or 'nmar')
2771 f, d = complete(spec, acceptable or 'nmar')
2772 files.update(f)
2772 files.update(f)
2773 dirs.update(d)
2773 dirs.update(d)
2774 files.update(dirs)
2774 files.update(dirs)
2775 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2775 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2776 ui.write('\n')
2776 ui.write('\n')
2777
2777
2778 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2778 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2779 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2779 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2780 '''access the pushkey key/value protocol
2780 '''access the pushkey key/value protocol
2781
2781
2782 With two args, list the keys in the given namespace.
2782 With two args, list the keys in the given namespace.
2783
2783
2784 With five args, set a key to new if it currently is set to old.
2784 With five args, set a key to new if it currently is set to old.
2785 Reports success or failure.
2785 Reports success or failure.
2786 '''
2786 '''
2787
2787
2788 target = hg.peer(ui, {}, repopath)
2788 target = hg.peer(ui, {}, repopath)
2789 if keyinfo:
2789 if keyinfo:
2790 key, old, new = keyinfo
2790 key, old, new = keyinfo
2791 r = target.pushkey(namespace, key, old, new)
2791 r = target.pushkey(namespace, key, old, new)
2792 ui.status(str(r) + '\n')
2792 ui.status(str(r) + '\n')
2793 return not r
2793 return not r
2794 else:
2794 else:
2795 for k, v in sorted(target.listkeys(namespace).iteritems()):
2795 for k, v in sorted(target.listkeys(namespace).iteritems()):
2796 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2796 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2797 v.encode('string-escape')))
2797 v.encode('string-escape')))
2798
2798
2799 @command('debugpvec', [], _('A B'))
2799 @command('debugpvec', [], _('A B'))
2800 def debugpvec(ui, repo, a, b=None):
2800 def debugpvec(ui, repo, a, b=None):
2801 ca = scmutil.revsingle(repo, a)
2801 ca = scmutil.revsingle(repo, a)
2802 cb = scmutil.revsingle(repo, b)
2802 cb = scmutil.revsingle(repo, b)
2803 pa = pvec.ctxpvec(ca)
2803 pa = pvec.ctxpvec(ca)
2804 pb = pvec.ctxpvec(cb)
2804 pb = pvec.ctxpvec(cb)
2805 if pa == pb:
2805 if pa == pb:
2806 rel = "="
2806 rel = "="
2807 elif pa > pb:
2807 elif pa > pb:
2808 rel = ">"
2808 rel = ">"
2809 elif pa < pb:
2809 elif pa < pb:
2810 rel = "<"
2810 rel = "<"
2811 elif pa | pb:
2811 elif pa | pb:
2812 rel = "|"
2812 rel = "|"
2813 ui.write(_("a: %s\n") % pa)
2813 ui.write(_("a: %s\n") % pa)
2814 ui.write(_("b: %s\n") % pb)
2814 ui.write(_("b: %s\n") % pb)
2815 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2815 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2816 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2816 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2817 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2817 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2818 pa.distance(pb), rel))
2818 pa.distance(pb), rel))
2819
2819
2820 @command('debugrebuilddirstate|debugrebuildstate',
2820 @command('debugrebuilddirstate|debugrebuildstate',
2821 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2821 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2822 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2822 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2823 'the working copy parent')),
2823 'the working copy parent')),
2824 ],
2824 ],
2825 _('[-r REV]'))
2825 _('[-r REV]'))
2826 def debugrebuilddirstate(ui, repo, rev, **opts):
2826 def debugrebuilddirstate(ui, repo, rev, **opts):
2827 """rebuild the dirstate as it would look like for the given revision
2827 """rebuild the dirstate as it would look like for the given revision
2828
2828
2829 If no revision is specified the first current parent will be used.
2829 If no revision is specified the first current parent will be used.
2830
2830
2831 The dirstate will be set to the files of the given revision.
2831 The dirstate will be set to the files of the given revision.
2832 The actual working directory content or existing dirstate
2832 The actual working directory content or existing dirstate
2833 information such as adds or removes is not considered.
2833 information such as adds or removes is not considered.
2834
2834
2835 ``minimal`` will only rebuild the dirstate status for files that claim to be
2835 ``minimal`` will only rebuild the dirstate status for files that claim to be
2836 tracked but are not in the parent manifest, or that exist in the parent
2836 tracked but are not in the parent manifest, or that exist in the parent
2837 manifest but are not in the dirstate. It will not change adds, removes, or
2837 manifest but are not in the dirstate. It will not change adds, removes, or
2838 modified files that are in the working copy parent.
2838 modified files that are in the working copy parent.
2839
2839
2840 One use of this command is to make the next :hg:`status` invocation
2840 One use of this command is to make the next :hg:`status` invocation
2841 check the actual file content.
2841 check the actual file content.
2842 """
2842 """
2843 ctx = scmutil.revsingle(repo, rev)
2843 ctx = scmutil.revsingle(repo, rev)
2844 wlock = repo.wlock()
2844 wlock = repo.wlock()
2845 try:
2845 try:
2846 dirstate = repo.dirstate
2846 dirstate = repo.dirstate
2847
2847
2848 # See command doc for what minimal does.
2848 # See command doc for what minimal does.
2849 if opts.get('minimal'):
2849 if opts.get('minimal'):
2850 dirstatefiles = set(dirstate)
2850 dirstatefiles = set(dirstate)
2851 ctxfiles = set(ctx.manifest().keys())
2851 ctxfiles = set(ctx.manifest().keys())
2852 for file in (dirstatefiles | ctxfiles):
2852 for file in (dirstatefiles | ctxfiles):
2853 indirstate = file in dirstatefiles
2853 indirstate = file in dirstatefiles
2854 inctx = file in ctxfiles
2854 inctx = file in ctxfiles
2855
2855
2856 if indirstate and not inctx and dirstate[file] != 'a':
2856 if indirstate and not inctx and dirstate[file] != 'a':
2857 dirstate.drop(file)
2857 dirstate.drop(file)
2858 elif inctx and not indirstate:
2858 elif inctx and not indirstate:
2859 dirstate.normallookup(file)
2859 dirstate.normallookup(file)
2860 else:
2860 else:
2861 dirstate.rebuild(ctx.node(), ctx.manifest())
2861 dirstate.rebuild(ctx.node(), ctx.manifest())
2862 finally:
2862 finally:
2863 wlock.release()
2863 wlock.release()
2864
2864
2865 @command('debugrebuildfncache', [], '')
2865 @command('debugrebuildfncache', [], '')
2866 def debugrebuildfncache(ui, repo):
2866 def debugrebuildfncache(ui, repo):
2867 """rebuild the fncache file"""
2867 """rebuild the fncache file"""
2868 repair.rebuildfncache(ui, repo)
2868 repair.rebuildfncache(ui, repo)
2869
2869
2870 @command('debugrename',
2870 @command('debugrename',
2871 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2871 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2872 _('[-r REV] FILE'))
2872 _('[-r REV] FILE'))
2873 def debugrename(ui, repo, file1, *pats, **opts):
2873 def debugrename(ui, repo, file1, *pats, **opts):
2874 """dump rename information"""
2874 """dump rename information"""
2875
2875
2876 ctx = scmutil.revsingle(repo, opts.get('rev'))
2876 ctx = scmutil.revsingle(repo, opts.get('rev'))
2877 m = scmutil.match(ctx, (file1,) + pats, opts)
2877 m = scmutil.match(ctx, (file1,) + pats, opts)
2878 for abs in ctx.walk(m):
2878 for abs in ctx.walk(m):
2879 fctx = ctx[abs]
2879 fctx = ctx[abs]
2880 o = fctx.filelog().renamed(fctx.filenode())
2880 o = fctx.filelog().renamed(fctx.filenode())
2881 rel = m.rel(abs)
2881 rel = m.rel(abs)
2882 if o:
2882 if o:
2883 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2883 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2884 else:
2884 else:
2885 ui.write(_("%s not renamed\n") % rel)
2885 ui.write(_("%s not renamed\n") % rel)
2886
2886
2887 @command('debugrevlog',
2887 @command('debugrevlog',
2888 [('c', 'changelog', False, _('open changelog')),
2888 [('c', 'changelog', False, _('open changelog')),
2889 ('m', 'manifest', False, _('open manifest')),
2889 ('m', 'manifest', False, _('open manifest')),
2890 ('', 'dir', False, _('open directory manifest')),
2890 ('', 'dir', False, _('open directory manifest')),
2891 ('d', 'dump', False, _('dump index data'))],
2891 ('d', 'dump', False, _('dump index data'))],
2892 _('-c|-m|FILE'),
2892 _('-c|-m|FILE'),
2893 optionalrepo=True)
2893 optionalrepo=True)
2894 def debugrevlog(ui, repo, file_=None, **opts):
2894 def debugrevlog(ui, repo, file_=None, **opts):
2895 """show data and statistics about a revlog"""
2895 """show data and statistics about a revlog"""
2896 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2896 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2897
2897
2898 if opts.get("dump"):
2898 if opts.get("dump"):
2899 numrevs = len(r)
2899 numrevs = len(r)
2900 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2900 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2901 " rawsize totalsize compression heads chainlen\n")
2901 " rawsize totalsize compression heads chainlen\n")
2902 ts = 0
2902 ts = 0
2903 heads = set()
2903 heads = set()
2904
2904
2905 for rev in xrange(numrevs):
2905 for rev in xrange(numrevs):
2906 dbase = r.deltaparent(rev)
2906 dbase = r.deltaparent(rev)
2907 if dbase == -1:
2907 if dbase == -1:
2908 dbase = rev
2908 dbase = rev
2909 cbase = r.chainbase(rev)
2909 cbase = r.chainbase(rev)
2910 clen = r.chainlen(rev)
2910 clen = r.chainlen(rev)
2911 p1, p2 = r.parentrevs(rev)
2911 p1, p2 = r.parentrevs(rev)
2912 rs = r.rawsize(rev)
2912 rs = r.rawsize(rev)
2913 ts = ts + rs
2913 ts = ts + rs
2914 heads -= set(r.parentrevs(rev))
2914 heads -= set(r.parentrevs(rev))
2915 heads.add(rev)
2915 heads.add(rev)
2916 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2916 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2917 "%11d %5d %8d\n" %
2917 "%11d %5d %8d\n" %
2918 (rev, p1, p2, r.start(rev), r.end(rev),
2918 (rev, p1, p2, r.start(rev), r.end(rev),
2919 r.start(dbase), r.start(cbase),
2919 r.start(dbase), r.start(cbase),
2920 r.start(p1), r.start(p2),
2920 r.start(p1), r.start(p2),
2921 rs, ts, ts / r.end(rev), len(heads), clen))
2921 rs, ts, ts / r.end(rev), len(heads), clen))
2922 return 0
2922 return 0
2923
2923
2924 v = r.version
2924 v = r.version
2925 format = v & 0xFFFF
2925 format = v & 0xFFFF
2926 flags = []
2926 flags = []
2927 gdelta = False
2927 gdelta = False
2928 if v & revlog.REVLOGNGINLINEDATA:
2928 if v & revlog.REVLOGNGINLINEDATA:
2929 flags.append('inline')
2929 flags.append('inline')
2930 if v & revlog.REVLOGGENERALDELTA:
2930 if v & revlog.REVLOGGENERALDELTA:
2931 gdelta = True
2931 gdelta = True
2932 flags.append('generaldelta')
2932 flags.append('generaldelta')
2933 if not flags:
2933 if not flags:
2934 flags = ['(none)']
2934 flags = ['(none)']
2935
2935
2936 nummerges = 0
2936 nummerges = 0
2937 numfull = 0
2937 numfull = 0
2938 numprev = 0
2938 numprev = 0
2939 nump1 = 0
2939 nump1 = 0
2940 nump2 = 0
2940 nump2 = 0
2941 numother = 0
2941 numother = 0
2942 nump1prev = 0
2942 nump1prev = 0
2943 nump2prev = 0
2943 nump2prev = 0
2944 chainlengths = []
2944 chainlengths = []
2945
2945
2946 datasize = [None, 0, 0L]
2946 datasize = [None, 0, 0L]
2947 fullsize = [None, 0, 0L]
2947 fullsize = [None, 0, 0L]
2948 deltasize = [None, 0, 0L]
2948 deltasize = [None, 0, 0L]
2949
2949
2950 def addsize(size, l):
2950 def addsize(size, l):
2951 if l[0] is None or size < l[0]:
2951 if l[0] is None or size < l[0]:
2952 l[0] = size
2952 l[0] = size
2953 if size > l[1]:
2953 if size > l[1]:
2954 l[1] = size
2954 l[1] = size
2955 l[2] += size
2955 l[2] += size
2956
2956
2957 numrevs = len(r)
2957 numrevs = len(r)
2958 for rev in xrange(numrevs):
2958 for rev in xrange(numrevs):
2959 p1, p2 = r.parentrevs(rev)
2959 p1, p2 = r.parentrevs(rev)
2960 delta = r.deltaparent(rev)
2960 delta = r.deltaparent(rev)
2961 if format > 0:
2961 if format > 0:
2962 addsize(r.rawsize(rev), datasize)
2962 addsize(r.rawsize(rev), datasize)
2963 if p2 != nullrev:
2963 if p2 != nullrev:
2964 nummerges += 1
2964 nummerges += 1
2965 size = r.length(rev)
2965 size = r.length(rev)
2966 if delta == nullrev:
2966 if delta == nullrev:
2967 chainlengths.append(0)
2967 chainlengths.append(0)
2968 numfull += 1
2968 numfull += 1
2969 addsize(size, fullsize)
2969 addsize(size, fullsize)
2970 else:
2970 else:
2971 chainlengths.append(chainlengths[delta] + 1)
2971 chainlengths.append(chainlengths[delta] + 1)
2972 addsize(size, deltasize)
2972 addsize(size, deltasize)
2973 if delta == rev - 1:
2973 if delta == rev - 1:
2974 numprev += 1
2974 numprev += 1
2975 if delta == p1:
2975 if delta == p1:
2976 nump1prev += 1
2976 nump1prev += 1
2977 elif delta == p2:
2977 elif delta == p2:
2978 nump2prev += 1
2978 nump2prev += 1
2979 elif delta == p1:
2979 elif delta == p1:
2980 nump1 += 1
2980 nump1 += 1
2981 elif delta == p2:
2981 elif delta == p2:
2982 nump2 += 1
2982 nump2 += 1
2983 elif delta != nullrev:
2983 elif delta != nullrev:
2984 numother += 1
2984 numother += 1
2985
2985
2986 # Adjust size min value for empty cases
2986 # Adjust size min value for empty cases
2987 for size in (datasize, fullsize, deltasize):
2987 for size in (datasize, fullsize, deltasize):
2988 if size[0] is None:
2988 if size[0] is None:
2989 size[0] = 0
2989 size[0] = 0
2990
2990
2991 numdeltas = numrevs - numfull
2991 numdeltas = numrevs - numfull
2992 numoprev = numprev - nump1prev - nump2prev
2992 numoprev = numprev - nump1prev - nump2prev
2993 totalrawsize = datasize[2]
2993 totalrawsize = datasize[2]
2994 datasize[2] /= numrevs
2994 datasize[2] /= numrevs
2995 fulltotal = fullsize[2]
2995 fulltotal = fullsize[2]
2996 fullsize[2] /= numfull
2996 fullsize[2] /= numfull
2997 deltatotal = deltasize[2]
2997 deltatotal = deltasize[2]
2998 if numrevs - numfull > 0:
2998 if numrevs - numfull > 0:
2999 deltasize[2] /= numrevs - numfull
2999 deltasize[2] /= numrevs - numfull
3000 totalsize = fulltotal + deltatotal
3000 totalsize = fulltotal + deltatotal
3001 avgchainlen = sum(chainlengths) / numrevs
3001 avgchainlen = sum(chainlengths) / numrevs
3002 maxchainlen = max(chainlengths)
3002 maxchainlen = max(chainlengths)
3003 compratio = totalrawsize / totalsize
3003 compratio = totalrawsize / totalsize
3004
3004
3005 basedfmtstr = '%%%dd\n'
3005 basedfmtstr = '%%%dd\n'
3006 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3006 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3007
3007
3008 def dfmtstr(max):
3008 def dfmtstr(max):
3009 return basedfmtstr % len(str(max))
3009 return basedfmtstr % len(str(max))
3010 def pcfmtstr(max, padding=0):
3010 def pcfmtstr(max, padding=0):
3011 return basepcfmtstr % (len(str(max)), ' ' * padding)
3011 return basepcfmtstr % (len(str(max)), ' ' * padding)
3012
3012
3013 def pcfmt(value, total):
3013 def pcfmt(value, total):
3014 return (value, 100 * float(value) / total)
3014 return (value, 100 * float(value) / total)
3015
3015
3016 ui.write(('format : %d\n') % format)
3016 ui.write(('format : %d\n') % format)
3017 ui.write(('flags : %s\n') % ', '.join(flags))
3017 ui.write(('flags : %s\n') % ', '.join(flags))
3018
3018
3019 ui.write('\n')
3019 ui.write('\n')
3020 fmt = pcfmtstr(totalsize)
3020 fmt = pcfmtstr(totalsize)
3021 fmt2 = dfmtstr(totalsize)
3021 fmt2 = dfmtstr(totalsize)
3022 ui.write(('revisions : ') + fmt2 % numrevs)
3022 ui.write(('revisions : ') + fmt2 % numrevs)
3023 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3023 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3024 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3024 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3025 ui.write(('revisions : ') + fmt2 % numrevs)
3025 ui.write(('revisions : ') + fmt2 % numrevs)
3026 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3026 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3027 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3027 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3028 ui.write(('revision size : ') + fmt2 % totalsize)
3028 ui.write(('revision size : ') + fmt2 % totalsize)
3029 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3029 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3030 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3030 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3031
3031
3032 ui.write('\n')
3032 ui.write('\n')
3033 fmt = dfmtstr(max(avgchainlen, compratio))
3033 fmt = dfmtstr(max(avgchainlen, compratio))
3034 ui.write(('avg chain length : ') + fmt % avgchainlen)
3034 ui.write(('avg chain length : ') + fmt % avgchainlen)
3035 ui.write(('max chain length : ') + fmt % maxchainlen)
3035 ui.write(('max chain length : ') + fmt % maxchainlen)
3036 ui.write(('compression ratio : ') + fmt % compratio)
3036 ui.write(('compression ratio : ') + fmt % compratio)
3037
3037
3038 if format > 0:
3038 if format > 0:
3039 ui.write('\n')
3039 ui.write('\n')
3040 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3040 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3041 % tuple(datasize))
3041 % tuple(datasize))
3042 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3042 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3043 % tuple(fullsize))
3043 % tuple(fullsize))
3044 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3044 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3045 % tuple(deltasize))
3045 % tuple(deltasize))
3046
3046
3047 if numdeltas > 0:
3047 if numdeltas > 0:
3048 ui.write('\n')
3048 ui.write('\n')
3049 fmt = pcfmtstr(numdeltas)
3049 fmt = pcfmtstr(numdeltas)
3050 fmt2 = pcfmtstr(numdeltas, 4)
3050 fmt2 = pcfmtstr(numdeltas, 4)
3051 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3051 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3052 if numprev > 0:
3052 if numprev > 0:
3053 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3053 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3054 numprev))
3054 numprev))
3055 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3055 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3056 numprev))
3056 numprev))
3057 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3057 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3058 numprev))
3058 numprev))
3059 if gdelta:
3059 if gdelta:
3060 ui.write(('deltas against p1 : ')
3060 ui.write(('deltas against p1 : ')
3061 + fmt % pcfmt(nump1, numdeltas))
3061 + fmt % pcfmt(nump1, numdeltas))
3062 ui.write(('deltas against p2 : ')
3062 ui.write(('deltas against p2 : ')
3063 + fmt % pcfmt(nump2, numdeltas))
3063 + fmt % pcfmt(nump2, numdeltas))
3064 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3064 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3065 numdeltas))
3065 numdeltas))
3066
3066
3067 @command('debugrevspec',
3067 @command('debugrevspec',
3068 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3068 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3069 ('REVSPEC'))
3069 ('REVSPEC'))
3070 def debugrevspec(ui, repo, expr, **opts):
3070 def debugrevspec(ui, repo, expr, **opts):
3071 """parse and apply a revision specification
3071 """parse and apply a revision specification
3072
3072
3073 Use --verbose to print the parsed tree before and after aliases
3073 Use --verbose to print the parsed tree before and after aliases
3074 expansion.
3074 expansion.
3075 """
3075 """
3076 if ui.verbose:
3076 if ui.verbose:
3077 tree = revset.parse(expr, lookup=repo.__contains__)
3077 tree = revset.parse(expr, lookup=repo.__contains__)
3078 ui.note(revset.prettyformat(tree), "\n")
3078 ui.note(revset.prettyformat(tree), "\n")
3079 newtree = revset.findaliases(ui, tree)
3079 newtree = revset.findaliases(ui, tree)
3080 if newtree != tree:
3080 if newtree != tree:
3081 ui.note(revset.prettyformat(newtree), "\n")
3081 ui.note(revset.prettyformat(newtree), "\n")
3082 tree = newtree
3082 tree = newtree
3083 newtree = revset.foldconcat(tree)
3083 newtree = revset.foldconcat(tree)
3084 if newtree != tree:
3084 if newtree != tree:
3085 ui.note(revset.prettyformat(newtree), "\n")
3085 ui.note(revset.prettyformat(newtree), "\n")
3086 if opts["optimize"]:
3086 if opts["optimize"]:
3087 weight, optimizedtree = revset.optimize(newtree, True)
3087 weight, optimizedtree = revset.optimize(newtree, True)
3088 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3088 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3089 func = revset.match(ui, expr, repo)
3089 func = revset.match(ui, expr, repo)
3090 revs = func(repo)
3090 revs = func(repo)
3091 if ui.verbose:
3091 if ui.verbose:
3092 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3092 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3093 for c in revs:
3093 for c in revs:
3094 ui.write("%s\n" % c)
3094 ui.write("%s\n" % c)
3095
3095
3096 @command('debugsetparents', [], _('REV1 [REV2]'))
3096 @command('debugsetparents', [], _('REV1 [REV2]'))
3097 def debugsetparents(ui, repo, rev1, rev2=None):
3097 def debugsetparents(ui, repo, rev1, rev2=None):
3098 """manually set the parents of the current working directory
3098 """manually set the parents of the current working directory
3099
3099
3100 This is useful for writing repository conversion tools, but should
3100 This is useful for writing repository conversion tools, but should
3101 be used with care. For example, neither the working directory nor the
3101 be used with care. For example, neither the working directory nor the
3102 dirstate is updated, so file status may be incorrect after running this
3102 dirstate is updated, so file status may be incorrect after running this
3103 command.
3103 command.
3104
3104
3105 Returns 0 on success.
3105 Returns 0 on success.
3106 """
3106 """
3107
3107
3108 r1 = scmutil.revsingle(repo, rev1).node()
3108 r1 = scmutil.revsingle(repo, rev1).node()
3109 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3109 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3110
3110
3111 wlock = repo.wlock()
3111 wlock = repo.wlock()
3112 try:
3112 try:
3113 repo.dirstate.beginparentchange()
3113 repo.dirstate.beginparentchange()
3114 repo.setparents(r1, r2)
3114 repo.setparents(r1, r2)
3115 repo.dirstate.endparentchange()
3115 repo.dirstate.endparentchange()
3116 finally:
3116 finally:
3117 wlock.release()
3117 wlock.release()
3118
3118
3119 @command('debugdirstate|debugstate',
3119 @command('debugdirstate|debugstate',
3120 [('', 'nodates', None, _('do not display the saved mtime')),
3120 [('', 'nodates', None, _('do not display the saved mtime')),
3121 ('', 'datesort', None, _('sort by saved mtime'))],
3121 ('', 'datesort', None, _('sort by saved mtime'))],
3122 _('[OPTION]...'))
3122 _('[OPTION]...'))
3123 def debugstate(ui, repo, nodates=None, datesort=None):
3123 def debugstate(ui, repo, nodates=None, datesort=None):
3124 """show the contents of the current dirstate"""
3124 """show the contents of the current dirstate"""
3125 timestr = ""
3125 timestr = ""
3126 if datesort:
3126 if datesort:
3127 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3127 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3128 else:
3128 else:
3129 keyfunc = None # sort by filename
3129 keyfunc = None # sort by filename
3130 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3130 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3131 if ent[3] == -1:
3131 if ent[3] == -1:
3132 timestr = 'unset '
3132 timestr = 'unset '
3133 elif nodates:
3133 elif nodates:
3134 timestr = 'set '
3134 timestr = 'set '
3135 else:
3135 else:
3136 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3136 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3137 time.localtime(ent[3]))
3137 time.localtime(ent[3]))
3138 if ent[1] & 0o20000:
3138 if ent[1] & 0o20000:
3139 mode = 'lnk'
3139 mode = 'lnk'
3140 else:
3140 else:
3141 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3141 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3142 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3142 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3143 for f in repo.dirstate.copies():
3143 for f in repo.dirstate.copies():
3144 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3144 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3145
3145
3146 @command('debugsub',
3146 @command('debugsub',
3147 [('r', 'rev', '',
3147 [('r', 'rev', '',
3148 _('revision to check'), _('REV'))],
3148 _('revision to check'), _('REV'))],
3149 _('[-r REV] [REV]'))
3149 _('[-r REV] [REV]'))
3150 def debugsub(ui, repo, rev=None):
3150 def debugsub(ui, repo, rev=None):
3151 ctx = scmutil.revsingle(repo, rev, None)
3151 ctx = scmutil.revsingle(repo, rev, None)
3152 for k, v in sorted(ctx.substate.items()):
3152 for k, v in sorted(ctx.substate.items()):
3153 ui.write(('path %s\n') % k)
3153 ui.write(('path %s\n') % k)
3154 ui.write((' source %s\n') % v[0])
3154 ui.write((' source %s\n') % v[0])
3155 ui.write((' revision %s\n') % v[1])
3155 ui.write((' revision %s\n') % v[1])
3156
3156
3157 @command('debugsuccessorssets',
3157 @command('debugsuccessorssets',
3158 [],
3158 [],
3159 _('[REV]'))
3159 _('[REV]'))
3160 def debugsuccessorssets(ui, repo, *revs):
3160 def debugsuccessorssets(ui, repo, *revs):
3161 """show set of successors for revision
3161 """show set of successors for revision
3162
3162
3163 A successors set of changeset A is a consistent group of revisions that
3163 A successors set of changeset A is a consistent group of revisions that
3164 succeed A. It contains non-obsolete changesets only.
3164 succeed A. It contains non-obsolete changesets only.
3165
3165
3166 In most cases a changeset A has a single successors set containing a single
3166 In most cases a changeset A has a single successors set containing a single
3167 successor (changeset A replaced by A').
3167 successor (changeset A replaced by A').
3168
3168
3169 A changeset that is made obsolete with no successors are called "pruned".
3169 A changeset that is made obsolete with no successors are called "pruned".
3170 Such changesets have no successors sets at all.
3170 Such changesets have no successors sets at all.
3171
3171
3172 A changeset that has been "split" will have a successors set containing
3172 A changeset that has been "split" will have a successors set containing
3173 more than one successor.
3173 more than one successor.
3174
3174
3175 A changeset that has been rewritten in multiple different ways is called
3175 A changeset that has been rewritten in multiple different ways is called
3176 "divergent". Such changesets have multiple successor sets (each of which
3176 "divergent". Such changesets have multiple successor sets (each of which
3177 may also be split, i.e. have multiple successors).
3177 may also be split, i.e. have multiple successors).
3178
3178
3179 Results are displayed as follows::
3179 Results are displayed as follows::
3180
3180
3181 <rev1>
3181 <rev1>
3182 <successors-1A>
3182 <successors-1A>
3183 <rev2>
3183 <rev2>
3184 <successors-2A>
3184 <successors-2A>
3185 <successors-2B1> <successors-2B2> <successors-2B3>
3185 <successors-2B1> <successors-2B2> <successors-2B3>
3186
3186
3187 Here rev2 has two possible (i.e. divergent) successors sets. The first
3187 Here rev2 has two possible (i.e. divergent) successors sets. The first
3188 holds one element, whereas the second holds three (i.e. the changeset has
3188 holds one element, whereas the second holds three (i.e. the changeset has
3189 been split).
3189 been split).
3190 """
3190 """
3191 # passed to successorssets caching computation from one call to another
3191 # passed to successorssets caching computation from one call to another
3192 cache = {}
3192 cache = {}
3193 ctx2str = str
3193 ctx2str = str
3194 node2str = short
3194 node2str = short
3195 if ui.debug():
3195 if ui.debug():
3196 def ctx2str(ctx):
3196 def ctx2str(ctx):
3197 return ctx.hex()
3197 return ctx.hex()
3198 node2str = hex
3198 node2str = hex
3199 for rev in scmutil.revrange(repo, revs):
3199 for rev in scmutil.revrange(repo, revs):
3200 ctx = repo[rev]
3200 ctx = repo[rev]
3201 ui.write('%s\n'% ctx2str(ctx))
3201 ui.write('%s\n'% ctx2str(ctx))
3202 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3202 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3203 if succsset:
3203 if succsset:
3204 ui.write(' ')
3204 ui.write(' ')
3205 ui.write(node2str(succsset[0]))
3205 ui.write(node2str(succsset[0]))
3206 for node in succsset[1:]:
3206 for node in succsset[1:]:
3207 ui.write(' ')
3207 ui.write(' ')
3208 ui.write(node2str(node))
3208 ui.write(node2str(node))
3209 ui.write('\n')
3209 ui.write('\n')
3210
3210
3211 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3211 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3212 def debugwalk(ui, repo, *pats, **opts):
3212 def debugwalk(ui, repo, *pats, **opts):
3213 """show how files match on given patterns"""
3213 """show how files match on given patterns"""
3214 m = scmutil.match(repo[None], pats, opts)
3214 m = scmutil.match(repo[None], pats, opts)
3215 items = list(repo.walk(m))
3215 items = list(repo.walk(m))
3216 if not items:
3216 if not items:
3217 return
3217 return
3218 f = lambda fn: fn
3218 f = lambda fn: fn
3219 if ui.configbool('ui', 'slash') and os.sep != '/':
3219 if ui.configbool('ui', 'slash') and os.sep != '/':
3220 f = lambda fn: util.normpath(fn)
3220 f = lambda fn: util.normpath(fn)
3221 fmt = 'f %%-%ds %%-%ds %%s' % (
3221 fmt = 'f %%-%ds %%-%ds %%s' % (
3222 max([len(abs) for abs in items]),
3222 max([len(abs) for abs in items]),
3223 max([len(m.rel(abs)) for abs in items]))
3223 max([len(m.rel(abs)) for abs in items]))
3224 for abs in items:
3224 for abs in items:
3225 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3225 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3226 ui.write("%s\n" % line.rstrip())
3226 ui.write("%s\n" % line.rstrip())
3227
3227
3228 @command('debugwireargs',
3228 @command('debugwireargs',
3229 [('', 'three', '', 'three'),
3229 [('', 'three', '', 'three'),
3230 ('', 'four', '', 'four'),
3230 ('', 'four', '', 'four'),
3231 ('', 'five', '', 'five'),
3231 ('', 'five', '', 'five'),
3232 ] + remoteopts,
3232 ] + remoteopts,
3233 _('REPO [OPTIONS]... [ONE [TWO]]'),
3233 _('REPO [OPTIONS]... [ONE [TWO]]'),
3234 norepo=True)
3234 norepo=True)
3235 def debugwireargs(ui, repopath, *vals, **opts):
3235 def debugwireargs(ui, repopath, *vals, **opts):
3236 repo = hg.peer(ui, opts, repopath)
3236 repo = hg.peer(ui, opts, repopath)
3237 for opt in remoteopts:
3237 for opt in remoteopts:
3238 del opts[opt[1]]
3238 del opts[opt[1]]
3239 args = {}
3239 args = {}
3240 for k, v in opts.iteritems():
3240 for k, v in opts.iteritems():
3241 if v:
3241 if v:
3242 args[k] = v
3242 args[k] = v
3243 # run twice to check that we don't mess up the stream for the next command
3243 # run twice to check that we don't mess up the stream for the next command
3244 res1 = repo.debugwireargs(*vals, **args)
3244 res1 = repo.debugwireargs(*vals, **args)
3245 res2 = repo.debugwireargs(*vals, **args)
3245 res2 = repo.debugwireargs(*vals, **args)
3246 ui.write("%s\n" % res1)
3246 ui.write("%s\n" % res1)
3247 if res1 != res2:
3247 if res1 != res2:
3248 ui.warn("%s\n" % res2)
3248 ui.warn("%s\n" % res2)
3249
3249
3250 @command('^diff',
3250 @command('^diff',
3251 [('r', 'rev', [], _('revision'), _('REV')),
3251 [('r', 'rev', [], _('revision'), _('REV')),
3252 ('c', 'change', '', _('change made by revision'), _('REV'))
3252 ('c', 'change', '', _('change made by revision'), _('REV'))
3253 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3253 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3254 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3254 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3255 inferrepo=True)
3255 inferrepo=True)
3256 def diff(ui, repo, *pats, **opts):
3256 def diff(ui, repo, *pats, **opts):
3257 """diff repository (or selected files)
3257 """diff repository (or selected files)
3258
3258
3259 Show differences between revisions for the specified files.
3259 Show differences between revisions for the specified files.
3260
3260
3261 Differences between files are shown using the unified diff format.
3261 Differences between files are shown using the unified diff format.
3262
3262
3263 .. note::
3263 .. note::
3264
3264
3265 diff may generate unexpected results for merges, as it will
3265 diff may generate unexpected results for merges, as it will
3266 default to comparing against the working directory's first
3266 default to comparing against the working directory's first
3267 parent changeset if no revisions are specified.
3267 parent changeset if no revisions are specified.
3268
3268
3269 When two revision arguments are given, then changes are shown
3269 When two revision arguments are given, then changes are shown
3270 between those revisions. If only one revision is specified then
3270 between those revisions. If only one revision is specified then
3271 that revision is compared to the working directory, and, when no
3271 that revision is compared to the working directory, and, when no
3272 revisions are specified, the working directory files are compared
3272 revisions are specified, the working directory files are compared
3273 to its parent.
3273 to its parent.
3274
3274
3275 Alternatively you can specify -c/--change with a revision to see
3275 Alternatively you can specify -c/--change with a revision to see
3276 the changes in that changeset relative to its first parent.
3276 the changes in that changeset relative to its first parent.
3277
3277
3278 Without the -a/--text option, diff will avoid generating diffs of
3278 Without the -a/--text option, diff will avoid generating diffs of
3279 files it detects as binary. With -a, diff will generate a diff
3279 files it detects as binary. With -a, diff will generate a diff
3280 anyway, probably with undesirable results.
3280 anyway, probably with undesirable results.
3281
3281
3282 Use the -g/--git option to generate diffs in the git extended diff
3282 Use the -g/--git option to generate diffs in the git extended diff
3283 format. For more information, read :hg:`help diffs`.
3283 format. For more information, read :hg:`help diffs`.
3284
3284
3285 .. container:: verbose
3285 .. container:: verbose
3286
3286
3287 Examples:
3287 Examples:
3288
3288
3289 - compare a file in the current working directory to its parent::
3289 - compare a file in the current working directory to its parent::
3290
3290
3291 hg diff foo.c
3291 hg diff foo.c
3292
3292
3293 - compare two historical versions of a directory, with rename info::
3293 - compare two historical versions of a directory, with rename info::
3294
3294
3295 hg diff --git -r 1.0:1.2 lib/
3295 hg diff --git -r 1.0:1.2 lib/
3296
3296
3297 - get change stats relative to the last change on some date::
3297 - get change stats relative to the last change on some date::
3298
3298
3299 hg diff --stat -r "date('may 2')"
3299 hg diff --stat -r "date('may 2')"
3300
3300
3301 - diff all newly-added files that contain a keyword::
3301 - diff all newly-added files that contain a keyword::
3302
3302
3303 hg diff "set:added() and grep(GNU)"
3303 hg diff "set:added() and grep(GNU)"
3304
3304
3305 - compare a revision and its parents::
3305 - compare a revision and its parents::
3306
3306
3307 hg diff -c 9353 # compare against first parent
3307 hg diff -c 9353 # compare against first parent
3308 hg diff -r 9353^:9353 # same using revset syntax
3308 hg diff -r 9353^:9353 # same using revset syntax
3309 hg diff -r 9353^2:9353 # compare against the second parent
3309 hg diff -r 9353^2:9353 # compare against the second parent
3310
3310
3311 Returns 0 on success.
3311 Returns 0 on success.
3312 """
3312 """
3313
3313
3314 revs = opts.get('rev')
3314 revs = opts.get('rev')
3315 change = opts.get('change')
3315 change = opts.get('change')
3316 stat = opts.get('stat')
3316 stat = opts.get('stat')
3317 reverse = opts.get('reverse')
3317 reverse = opts.get('reverse')
3318
3318
3319 if revs and change:
3319 if revs and change:
3320 msg = _('cannot specify --rev and --change at the same time')
3320 msg = _('cannot specify --rev and --change at the same time')
3321 raise util.Abort(msg)
3321 raise util.Abort(msg)
3322 elif change:
3322 elif change:
3323 node2 = scmutil.revsingle(repo, change, None).node()
3323 node2 = scmutil.revsingle(repo, change, None).node()
3324 node1 = repo[node2].p1().node()
3324 node1 = repo[node2].p1().node()
3325 else:
3325 else:
3326 node1, node2 = scmutil.revpair(repo, revs)
3326 node1, node2 = scmutil.revpair(repo, revs)
3327
3327
3328 if reverse:
3328 if reverse:
3329 node1, node2 = node2, node1
3329 node1, node2 = node2, node1
3330
3330
3331 diffopts = patch.diffallopts(ui, opts)
3331 diffopts = patch.diffallopts(ui, opts)
3332 m = scmutil.match(repo[node2], pats, opts)
3332 m = scmutil.match(repo[node2], pats, opts)
3333 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3333 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3334 listsubrepos=opts.get('subrepos'),
3334 listsubrepos=opts.get('subrepos'),
3335 root=opts.get('root'))
3335 root=opts.get('root'))
3336
3336
3337 @command('^export',
3337 @command('^export',
3338 [('o', 'output', '',
3338 [('o', 'output', '',
3339 _('print output to file with formatted name'), _('FORMAT')),
3339 _('print output to file with formatted name'), _('FORMAT')),
3340 ('', 'switch-parent', None, _('diff against the second parent')),
3340 ('', 'switch-parent', None, _('diff against the second parent')),
3341 ('r', 'rev', [], _('revisions to export'), _('REV')),
3341 ('r', 'rev', [], _('revisions to export'), _('REV')),
3342 ] + diffopts,
3342 ] + diffopts,
3343 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3343 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3344 def export(ui, repo, *changesets, **opts):
3344 def export(ui, repo, *changesets, **opts):
3345 """dump the header and diffs for one or more changesets
3345 """dump the header and diffs for one or more changesets
3346
3346
3347 Print the changeset header and diffs for one or more revisions.
3347 Print the changeset header and diffs for one or more revisions.
3348 If no revision is given, the parent of the working directory is used.
3348 If no revision is given, the parent of the working directory is used.
3349
3349
3350 The information shown in the changeset header is: author, date,
3350 The information shown in the changeset header is: author, date,
3351 branch name (if non-default), changeset hash, parent(s) and commit
3351 branch name (if non-default), changeset hash, parent(s) and commit
3352 comment.
3352 comment.
3353
3353
3354 .. note::
3354 .. note::
3355
3355
3356 export may generate unexpected diff output for merge
3356 export may generate unexpected diff output for merge
3357 changesets, as it will compare the merge changeset against its
3357 changesets, as it will compare the merge changeset against its
3358 first parent only.
3358 first parent only.
3359
3359
3360 Output may be to a file, in which case the name of the file is
3360 Output may be to a file, in which case the name of the file is
3361 given using a format string. The formatting rules are as follows:
3361 given using a format string. The formatting rules are as follows:
3362
3362
3363 :``%%``: literal "%" character
3363 :``%%``: literal "%" character
3364 :``%H``: changeset hash (40 hexadecimal digits)
3364 :``%H``: changeset hash (40 hexadecimal digits)
3365 :``%N``: number of patches being generated
3365 :``%N``: number of patches being generated
3366 :``%R``: changeset revision number
3366 :``%R``: changeset revision number
3367 :``%b``: basename of the exporting repository
3367 :``%b``: basename of the exporting repository
3368 :``%h``: short-form changeset hash (12 hexadecimal digits)
3368 :``%h``: short-form changeset hash (12 hexadecimal digits)
3369 :``%m``: first line of the commit message (only alphanumeric characters)
3369 :``%m``: first line of the commit message (only alphanumeric characters)
3370 :``%n``: zero-padded sequence number, starting at 1
3370 :``%n``: zero-padded sequence number, starting at 1
3371 :``%r``: zero-padded changeset revision number
3371 :``%r``: zero-padded changeset revision number
3372
3372
3373 Without the -a/--text option, export will avoid generating diffs
3373 Without the -a/--text option, export will avoid generating diffs
3374 of files it detects as binary. With -a, export will generate a
3374 of files it detects as binary. With -a, export will generate a
3375 diff anyway, probably with undesirable results.
3375 diff anyway, probably with undesirable results.
3376
3376
3377 Use the -g/--git option to generate diffs in the git extended diff
3377 Use the -g/--git option to generate diffs in the git extended diff
3378 format. See :hg:`help diffs` for more information.
3378 format. See :hg:`help diffs` for more information.
3379
3379
3380 With the --switch-parent option, the diff will be against the
3380 With the --switch-parent option, the diff will be against the
3381 second parent. It can be useful to review a merge.
3381 second parent. It can be useful to review a merge.
3382
3382
3383 .. container:: verbose
3383 .. container:: verbose
3384
3384
3385 Examples:
3385 Examples:
3386
3386
3387 - use export and import to transplant a bugfix to the current
3387 - use export and import to transplant a bugfix to the current
3388 branch::
3388 branch::
3389
3389
3390 hg export -r 9353 | hg import -
3390 hg export -r 9353 | hg import -
3391
3391
3392 - export all the changesets between two revisions to a file with
3392 - export all the changesets between two revisions to a file with
3393 rename information::
3393 rename information::
3394
3394
3395 hg export --git -r 123:150 > changes.txt
3395 hg export --git -r 123:150 > changes.txt
3396
3396
3397 - split outgoing changes into a series of patches with
3397 - split outgoing changes into a series of patches with
3398 descriptive names::
3398 descriptive names::
3399
3399
3400 hg export -r "outgoing()" -o "%n-%m.patch"
3400 hg export -r "outgoing()" -o "%n-%m.patch"
3401
3401
3402 Returns 0 on success.
3402 Returns 0 on success.
3403 """
3403 """
3404 changesets += tuple(opts.get('rev', []))
3404 changesets += tuple(opts.get('rev', []))
3405 if not changesets:
3405 if not changesets:
3406 changesets = ['.']
3406 changesets = ['.']
3407 revs = scmutil.revrange(repo, changesets)
3407 revs = scmutil.revrange(repo, changesets)
3408 if not revs:
3408 if not revs:
3409 raise util.Abort(_("export requires at least one changeset"))
3409 raise util.Abort(_("export requires at least one changeset"))
3410 if len(revs) > 1:
3410 if len(revs) > 1:
3411 ui.note(_('exporting patches:\n'))
3411 ui.note(_('exporting patches:\n'))
3412 else:
3412 else:
3413 ui.note(_('exporting patch:\n'))
3413 ui.note(_('exporting patch:\n'))
3414 cmdutil.export(repo, revs, template=opts.get('output'),
3414 cmdutil.export(repo, revs, template=opts.get('output'),
3415 switch_parent=opts.get('switch_parent'),
3415 switch_parent=opts.get('switch_parent'),
3416 opts=patch.diffallopts(ui, opts))
3416 opts=patch.diffallopts(ui, opts))
3417
3417
3418 @command('files',
3418 @command('files',
3419 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3419 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3420 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3420 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3421 ] + walkopts + formatteropts + subrepoopts,
3421 ] + walkopts + formatteropts + subrepoopts,
3422 _('[OPTION]... [PATTERN]...'))
3422 _('[OPTION]... [PATTERN]...'))
3423 def files(ui, repo, *pats, **opts):
3423 def files(ui, repo, *pats, **opts):
3424 """list tracked files
3424 """list tracked files
3425
3425
3426 Print files under Mercurial control in the working directory or
3426 Print files under Mercurial control in the working directory or
3427 specified revision whose names match the given patterns (excluding
3427 specified revision whose names match the given patterns (excluding
3428 removed files).
3428 removed files).
3429
3429
3430 If no patterns are given to match, this command prints the names
3430 If no patterns are given to match, this command prints the names
3431 of all files under Mercurial control in the working directory.
3431 of all files under Mercurial control in the working directory.
3432
3432
3433 .. container:: verbose
3433 .. container:: verbose
3434
3434
3435 Examples:
3435 Examples:
3436
3436
3437 - list all files under the current directory::
3437 - list all files under the current directory::
3438
3438
3439 hg files .
3439 hg files .
3440
3440
3441 - shows sizes and flags for current revision::
3441 - shows sizes and flags for current revision::
3442
3442
3443 hg files -vr .
3443 hg files -vr .
3444
3444
3445 - list all files named README::
3445 - list all files named README::
3446
3446
3447 hg files -I "**/README"
3447 hg files -I "**/README"
3448
3448
3449 - list all binary files::
3449 - list all binary files::
3450
3450
3451 hg files "set:binary()"
3451 hg files "set:binary()"
3452
3452
3453 - find files containing a regular expression::
3453 - find files containing a regular expression::
3454
3454
3455 hg files "set:grep('bob')"
3455 hg files "set:grep('bob')"
3456
3456
3457 - search tracked file contents with xargs and grep::
3457 - search tracked file contents with xargs and grep::
3458
3458
3459 hg files -0 | xargs -0 grep foo
3459 hg files -0 | xargs -0 grep foo
3460
3460
3461 See :hg:`help patterns` and :hg:`help filesets` for more information
3461 See :hg:`help patterns` and :hg:`help filesets` for more information
3462 on specifying file patterns.
3462 on specifying file patterns.
3463
3463
3464 Returns 0 if a match is found, 1 otherwise.
3464 Returns 0 if a match is found, 1 otherwise.
3465
3465
3466 """
3466 """
3467 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3467 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3468
3468
3469 end = '\n'
3469 end = '\n'
3470 if opts.get('print0'):
3470 if opts.get('print0'):
3471 end = '\0'
3471 end = '\0'
3472 fm = ui.formatter('files', opts)
3472 fm = ui.formatter('files', opts)
3473 fmt = '%s' + end
3473 fmt = '%s' + end
3474
3474
3475 m = scmutil.match(ctx, pats, opts)
3475 m = scmutil.match(ctx, pats, opts)
3476 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3476 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3477
3477
3478 fm.end()
3478 fm.end()
3479
3479
3480 return ret
3480 return ret
3481
3481
3482 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3482 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3483 def forget(ui, repo, *pats, **opts):
3483 def forget(ui, repo, *pats, **opts):
3484 """forget the specified files on the next commit
3484 """forget the specified files on the next commit
3485
3485
3486 Mark the specified files so they will no longer be tracked
3486 Mark the specified files so they will no longer be tracked
3487 after the next commit.
3487 after the next commit.
3488
3488
3489 This only removes files from the current branch, not from the
3489 This only removes files from the current branch, not from the
3490 entire project history, and it does not delete them from the
3490 entire project history, and it does not delete them from the
3491 working directory.
3491 working directory.
3492
3492
3493 To delete the file from the working directory, see :hg:`remove`.
3493 To delete the file from the working directory, see :hg:`remove`.
3494
3494
3495 To undo a forget before the next commit, see :hg:`add`.
3495 To undo a forget before the next commit, see :hg:`add`.
3496
3496
3497 .. container:: verbose
3497 .. container:: verbose
3498
3498
3499 Examples:
3499 Examples:
3500
3500
3501 - forget newly-added binary files::
3501 - forget newly-added binary files::
3502
3502
3503 hg forget "set:added() and binary()"
3503 hg forget "set:added() and binary()"
3504
3504
3505 - forget files that would be excluded by .hgignore::
3505 - forget files that would be excluded by .hgignore::
3506
3506
3507 hg forget "set:hgignore()"
3507 hg forget "set:hgignore()"
3508
3508
3509 Returns 0 on success.
3509 Returns 0 on success.
3510 """
3510 """
3511
3511
3512 if not pats:
3512 if not pats:
3513 raise util.Abort(_('no files specified'))
3513 raise util.Abort(_('no files specified'))
3514
3514
3515 m = scmutil.match(repo[None], pats, opts)
3515 m = scmutil.match(repo[None], pats, opts)
3516 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3516 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3517 return rejected and 1 or 0
3517 return rejected and 1 or 0
3518
3518
3519 @command(
3519 @command(
3520 'graft',
3520 'graft',
3521 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3521 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3522 ('c', 'continue', False, _('resume interrupted graft')),
3522 ('c', 'continue', False, _('resume interrupted graft')),
3523 ('e', 'edit', False, _('invoke editor on commit messages')),
3523 ('e', 'edit', False, _('invoke editor on commit messages')),
3524 ('', 'log', None, _('append graft info to log message')),
3524 ('', 'log', None, _('append graft info to log message')),
3525 ('f', 'force', False, _('force graft')),
3525 ('f', 'force', False, _('force graft')),
3526 ('D', 'currentdate', False,
3526 ('D', 'currentdate', False,
3527 _('record the current date as commit date')),
3527 _('record the current date as commit date')),
3528 ('U', 'currentuser', False,
3528 ('U', 'currentuser', False,
3529 _('record the current user as committer'), _('DATE'))]
3529 _('record the current user as committer'), _('DATE'))]
3530 + commitopts2 + mergetoolopts + dryrunopts,
3530 + commitopts2 + mergetoolopts + dryrunopts,
3531 _('[OPTION]... [-r] REV...'))
3531 _('[OPTION]... [-r] REV...'))
3532 def graft(ui, repo, *revs, **opts):
3532 def graft(ui, repo, *revs, **opts):
3533 '''copy changes from other branches onto the current branch
3533 '''copy changes from other branches onto the current branch
3534
3534
3535 This command uses Mercurial's merge logic to copy individual
3535 This command uses Mercurial's merge logic to copy individual
3536 changes from other branches without merging branches in the
3536 changes from other branches without merging branches in the
3537 history graph. This is sometimes known as 'backporting' or
3537 history graph. This is sometimes known as 'backporting' or
3538 'cherry-picking'. By default, graft will copy user, date, and
3538 'cherry-picking'. By default, graft will copy user, date, and
3539 description from the source changesets.
3539 description from the source changesets.
3540
3540
3541 Changesets that are ancestors of the current revision, that have
3541 Changesets that are ancestors of the current revision, that have
3542 already been grafted, or that are merges will be skipped.
3542 already been grafted, or that are merges will be skipped.
3543
3543
3544 If --log is specified, log messages will have a comment appended
3544 If --log is specified, log messages will have a comment appended
3545 of the form::
3545 of the form::
3546
3546
3547 (grafted from CHANGESETHASH)
3547 (grafted from CHANGESETHASH)
3548
3548
3549 If --force is specified, revisions will be grafted even if they
3549 If --force is specified, revisions will be grafted even if they
3550 are already ancestors of or have been grafted to the destination.
3550 are already ancestors of or have been grafted to the destination.
3551 This is useful when the revisions have since been backed out.
3551 This is useful when the revisions have since been backed out.
3552
3552
3553 If a graft merge results in conflicts, the graft process is
3553 If a graft merge results in conflicts, the graft process is
3554 interrupted so that the current merge can be manually resolved.
3554 interrupted so that the current merge can be manually resolved.
3555 Once all conflicts are addressed, the graft process can be
3555 Once all conflicts are addressed, the graft process can be
3556 continued with the -c/--continue option.
3556 continued with the -c/--continue option.
3557
3557
3558 .. note::
3558 .. note::
3559
3559
3560 The -c/--continue option does not reapply earlier options, except
3560 The -c/--continue option does not reapply earlier options, except
3561 for --force.
3561 for --force.
3562
3562
3563 .. container:: verbose
3563 .. container:: verbose
3564
3564
3565 Examples:
3565 Examples:
3566
3566
3567 - copy a single change to the stable branch and edit its description::
3567 - copy a single change to the stable branch and edit its description::
3568
3568
3569 hg update stable
3569 hg update stable
3570 hg graft --edit 9393
3570 hg graft --edit 9393
3571
3571
3572 - graft a range of changesets with one exception, updating dates::
3572 - graft a range of changesets with one exception, updating dates::
3573
3573
3574 hg graft -D "2085::2093 and not 2091"
3574 hg graft -D "2085::2093 and not 2091"
3575
3575
3576 - continue a graft after resolving conflicts::
3576 - continue a graft after resolving conflicts::
3577
3577
3578 hg graft -c
3578 hg graft -c
3579
3579
3580 - show the source of a grafted changeset::
3580 - show the source of a grafted changeset::
3581
3581
3582 hg log --debug -r .
3582 hg log --debug -r .
3583
3583
3584 See :hg:`help revisions` and :hg:`help revsets` for more about
3584 See :hg:`help revisions` and :hg:`help revsets` for more about
3585 specifying revisions.
3585 specifying revisions.
3586
3586
3587 Returns 0 on successful completion.
3587 Returns 0 on successful completion.
3588 '''
3588 '''
3589
3589
3590 revs = list(revs)
3590 revs = list(revs)
3591 revs.extend(opts['rev'])
3591 revs.extend(opts['rev'])
3592
3592
3593 if not opts.get('user') and opts.get('currentuser'):
3593 if not opts.get('user') and opts.get('currentuser'):
3594 opts['user'] = ui.username()
3594 opts['user'] = ui.username()
3595 if not opts.get('date') and opts.get('currentdate'):
3595 if not opts.get('date') and opts.get('currentdate'):
3596 opts['date'] = "%d %d" % util.makedate()
3596 opts['date'] = "%d %d" % util.makedate()
3597
3597
3598 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3598 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3599
3599
3600 cont = False
3600 cont = False
3601 if opts['continue']:
3601 if opts['continue']:
3602 cont = True
3602 cont = True
3603 if revs:
3603 if revs:
3604 raise util.Abort(_("can't specify --continue and revisions"))
3604 raise util.Abort(_("can't specify --continue and revisions"))
3605 # read in unfinished revisions
3605 # read in unfinished revisions
3606 try:
3606 try:
3607 nodes = repo.vfs.read('graftstate').splitlines()
3607 nodes = repo.vfs.read('graftstate').splitlines()
3608 revs = [repo[node].rev() for node in nodes]
3608 revs = [repo[node].rev() for node in nodes]
3609 except IOError as inst:
3609 except IOError as inst:
3610 if inst.errno != errno.ENOENT:
3610 if inst.errno != errno.ENOENT:
3611 raise
3611 raise
3612 raise util.Abort(_("no graft state found, can't continue"))
3612 raise util.Abort(_("no graft state found, can't continue"))
3613 else:
3613 else:
3614 cmdutil.checkunfinished(repo)
3614 cmdutil.checkunfinished(repo)
3615 cmdutil.bailifchanged(repo)
3615 cmdutil.bailifchanged(repo)
3616 if not revs:
3616 if not revs:
3617 raise util.Abort(_('no revisions specified'))
3617 raise util.Abort(_('no revisions specified'))
3618 revs = scmutil.revrange(repo, revs)
3618 revs = scmutil.revrange(repo, revs)
3619
3619
3620 skipped = set()
3620 skipped = set()
3621 # check for merges
3621 # check for merges
3622 for rev in repo.revs('%ld and merge()', revs):
3622 for rev in repo.revs('%ld and merge()', revs):
3623 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3623 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3624 skipped.add(rev)
3624 skipped.add(rev)
3625 revs = [r for r in revs if r not in skipped]
3625 revs = [r for r in revs if r not in skipped]
3626 if not revs:
3626 if not revs:
3627 return -1
3627 return -1
3628
3628
3629 # Don't check in the --continue case, in effect retaining --force across
3629 # Don't check in the --continue case, in effect retaining --force across
3630 # --continues. That's because without --force, any revisions we decided to
3630 # --continues. That's because without --force, any revisions we decided to
3631 # skip would have been filtered out here, so they wouldn't have made their
3631 # skip would have been filtered out here, so they wouldn't have made their
3632 # way to the graftstate. With --force, any revisions we would have otherwise
3632 # way to the graftstate. With --force, any revisions we would have otherwise
3633 # skipped would not have been filtered out, and if they hadn't been applied
3633 # skipped would not have been filtered out, and if they hadn't been applied
3634 # already, they'd have been in the graftstate.
3634 # already, they'd have been in the graftstate.
3635 if not (cont or opts.get('force')):
3635 if not (cont or opts.get('force')):
3636 # check for ancestors of dest branch
3636 # check for ancestors of dest branch
3637 crev = repo['.'].rev()
3637 crev = repo['.'].rev()
3638 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3638 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3639 # Cannot use x.remove(y) on smart set, this has to be a list.
3639 # Cannot use x.remove(y) on smart set, this has to be a list.
3640 # XXX make this lazy in the future
3640 # XXX make this lazy in the future
3641 revs = list(revs)
3641 revs = list(revs)
3642 # don't mutate while iterating, create a copy
3642 # don't mutate while iterating, create a copy
3643 for rev in list(revs):
3643 for rev in list(revs):
3644 if rev in ancestors:
3644 if rev in ancestors:
3645 ui.warn(_('skipping ancestor revision %d:%s\n') %
3645 ui.warn(_('skipping ancestor revision %d:%s\n') %
3646 (rev, repo[rev]))
3646 (rev, repo[rev]))
3647 # XXX remove on list is slow
3647 # XXX remove on list is slow
3648 revs.remove(rev)
3648 revs.remove(rev)
3649 if not revs:
3649 if not revs:
3650 return -1
3650 return -1
3651
3651
3652 # analyze revs for earlier grafts
3652 # analyze revs for earlier grafts
3653 ids = {}
3653 ids = {}
3654 for ctx in repo.set("%ld", revs):
3654 for ctx in repo.set("%ld", revs):
3655 ids[ctx.hex()] = ctx.rev()
3655 ids[ctx.hex()] = ctx.rev()
3656 n = ctx.extra().get('source')
3656 n = ctx.extra().get('source')
3657 if n:
3657 if n:
3658 ids[n] = ctx.rev()
3658 ids[n] = ctx.rev()
3659
3659
3660 # check ancestors for earlier grafts
3660 # check ancestors for earlier grafts
3661 ui.debug('scanning for duplicate grafts\n')
3661 ui.debug('scanning for duplicate grafts\n')
3662
3662
3663 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3663 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3664 ctx = repo[rev]
3664 ctx = repo[rev]
3665 n = ctx.extra().get('source')
3665 n = ctx.extra().get('source')
3666 if n in ids:
3666 if n in ids:
3667 try:
3667 try:
3668 r = repo[n].rev()
3668 r = repo[n].rev()
3669 except error.RepoLookupError:
3669 except error.RepoLookupError:
3670 r = None
3670 r = None
3671 if r in revs:
3671 if r in revs:
3672 ui.warn(_('skipping revision %d:%s '
3672 ui.warn(_('skipping revision %d:%s '
3673 '(already grafted to %d:%s)\n')
3673 '(already grafted to %d:%s)\n')
3674 % (r, repo[r], rev, ctx))
3674 % (r, repo[r], rev, ctx))
3675 revs.remove(r)
3675 revs.remove(r)
3676 elif ids[n] in revs:
3676 elif ids[n] in revs:
3677 if r is None:
3677 if r is None:
3678 ui.warn(_('skipping already grafted revision %d:%s '
3678 ui.warn(_('skipping already grafted revision %d:%s '
3679 '(%d:%s also has unknown origin %s)\n')
3679 '(%d:%s also has unknown origin %s)\n')
3680 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3680 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3681 else:
3681 else:
3682 ui.warn(_('skipping already grafted revision %d:%s '
3682 ui.warn(_('skipping already grafted revision %d:%s '
3683 '(%d:%s also has origin %d:%s)\n')
3683 '(%d:%s also has origin %d:%s)\n')
3684 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3684 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3685 revs.remove(ids[n])
3685 revs.remove(ids[n])
3686 elif ctx.hex() in ids:
3686 elif ctx.hex() in ids:
3687 r = ids[ctx.hex()]
3687 r = ids[ctx.hex()]
3688 ui.warn(_('skipping already grafted revision %d:%s '
3688 ui.warn(_('skipping already grafted revision %d:%s '
3689 '(was grafted from %d:%s)\n') %
3689 '(was grafted from %d:%s)\n') %
3690 (r, repo[r], rev, ctx))
3690 (r, repo[r], rev, ctx))
3691 revs.remove(r)
3691 revs.remove(r)
3692 if not revs:
3692 if not revs:
3693 return -1
3693 return -1
3694
3694
3695 wlock = repo.wlock()
3695 wlock = repo.wlock()
3696 try:
3696 try:
3697 for pos, ctx in enumerate(repo.set("%ld", revs)):
3697 for pos, ctx in enumerate(repo.set("%ld", revs)):
3698 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3698 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3699 ctx.description().split('\n', 1)[0])
3699 ctx.description().split('\n', 1)[0])
3700 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3700 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3701 if names:
3701 if names:
3702 desc += ' (%s)' % ' '.join(names)
3702 desc += ' (%s)' % ' '.join(names)
3703 ui.status(_('grafting %s\n') % desc)
3703 ui.status(_('grafting %s\n') % desc)
3704 if opts.get('dry_run'):
3704 if opts.get('dry_run'):
3705 continue
3705 continue
3706
3706
3707 source = ctx.extra().get('source')
3707 source = ctx.extra().get('source')
3708 extra = {}
3708 extra = {}
3709 if source:
3709 if source:
3710 extra['source'] = source
3710 extra['source'] = source
3711 extra['intermediate-source'] = ctx.hex()
3711 extra['intermediate-source'] = ctx.hex()
3712 else:
3712 else:
3713 extra['source'] = ctx.hex()
3713 extra['source'] = ctx.hex()
3714 user = ctx.user()
3714 user = ctx.user()
3715 if opts.get('user'):
3715 if opts.get('user'):
3716 user = opts['user']
3716 user = opts['user']
3717 date = ctx.date()
3717 date = ctx.date()
3718 if opts.get('date'):
3718 if opts.get('date'):
3719 date = opts['date']
3719 date = opts['date']
3720 message = ctx.description()
3720 message = ctx.description()
3721 if opts.get('log'):
3721 if opts.get('log'):
3722 message += '\n(grafted from %s)' % ctx.hex()
3722 message += '\n(grafted from %s)' % ctx.hex()
3723
3723
3724 # we don't merge the first commit when continuing
3724 # we don't merge the first commit when continuing
3725 if not cont:
3725 if not cont:
3726 # perform the graft merge with p1(rev) as 'ancestor'
3726 # perform the graft merge with p1(rev) as 'ancestor'
3727 try:
3727 try:
3728 # ui.forcemerge is an internal variable, do not document
3728 # ui.forcemerge is an internal variable, do not document
3729 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3729 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3730 'graft')
3730 'graft')
3731 stats = mergemod.graft(repo, ctx, ctx.p1(),
3731 stats = mergemod.graft(repo, ctx, ctx.p1(),
3732 ['local', 'graft'])
3732 ['local', 'graft'])
3733 finally:
3733 finally:
3734 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3734 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3735 # report any conflicts
3735 # report any conflicts
3736 if stats and stats[3] > 0:
3736 if stats and stats[3] > 0:
3737 # write out state for --continue
3737 # write out state for --continue
3738 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3738 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3739 repo.vfs.write('graftstate', ''.join(nodelines))
3739 repo.vfs.write('graftstate', ''.join(nodelines))
3740 raise util.Abort(
3740 raise util.Abort(
3741 _("unresolved conflicts, can't continue"),
3741 _("unresolved conflicts, can't continue"),
3742 hint=_('use hg resolve and hg graft --continue'))
3742 hint=_('use hg resolve and hg graft --continue'))
3743 else:
3743 else:
3744 cont = False
3744 cont = False
3745
3745
3746 # commit
3746 # commit
3747 node = repo.commit(text=message, user=user,
3747 node = repo.commit(text=message, user=user,
3748 date=date, extra=extra, editor=editor)
3748 date=date, extra=extra, editor=editor)
3749 if node is None:
3749 if node is None:
3750 ui.warn(
3750 ui.warn(
3751 _('note: graft of %d:%s created no changes to commit\n') %
3751 _('note: graft of %d:%s created no changes to commit\n') %
3752 (ctx.rev(), ctx))
3752 (ctx.rev(), ctx))
3753 finally:
3753 finally:
3754 wlock.release()
3754 wlock.release()
3755
3755
3756 # remove state when we complete successfully
3756 # remove state when we complete successfully
3757 if not opts.get('dry_run'):
3757 if not opts.get('dry_run'):
3758 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3758 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3759
3759
3760 return 0
3760 return 0
3761
3761
3762 @command('grep',
3762 @command('grep',
3763 [('0', 'print0', None, _('end fields with NUL')),
3763 [('0', 'print0', None, _('end fields with NUL')),
3764 ('', 'all', None, _('print all revisions that match')),
3764 ('', 'all', None, _('print all revisions that match')),
3765 ('a', 'text', None, _('treat all files as text')),
3765 ('a', 'text', None, _('treat all files as text')),
3766 ('f', 'follow', None,
3766 ('f', 'follow', None,
3767 _('follow changeset history,'
3767 _('follow changeset history,'
3768 ' or file history across copies and renames')),
3768 ' or file history across copies and renames')),
3769 ('i', 'ignore-case', None, _('ignore case when matching')),
3769 ('i', 'ignore-case', None, _('ignore case when matching')),
3770 ('l', 'files-with-matches', None,
3770 ('l', 'files-with-matches', None,
3771 _('print only filenames and revisions that match')),
3771 _('print only filenames and revisions that match')),
3772 ('n', 'line-number', None, _('print matching line numbers')),
3772 ('n', 'line-number', None, _('print matching line numbers')),
3773 ('r', 'rev', [],
3773 ('r', 'rev', [],
3774 _('only search files changed within revision range'), _('REV')),
3774 _('only search files changed within revision range'), _('REV')),
3775 ('u', 'user', None, _('list the author (long with -v)')),
3775 ('u', 'user', None, _('list the author (long with -v)')),
3776 ('d', 'date', None, _('list the date (short with -q)')),
3776 ('d', 'date', None, _('list the date (short with -q)')),
3777 ] + walkopts,
3777 ] + walkopts,
3778 _('[OPTION]... PATTERN [FILE]...'),
3778 _('[OPTION]... PATTERN [FILE]...'),
3779 inferrepo=True)
3779 inferrepo=True)
3780 def grep(ui, repo, pattern, *pats, **opts):
3780 def grep(ui, repo, pattern, *pats, **opts):
3781 """search for a pattern in specified files and revisions
3781 """search for a pattern in specified files and revisions
3782
3782
3783 Search revisions of files for a regular expression.
3783 Search revisions of files for a regular expression.
3784
3784
3785 This command behaves differently than Unix grep. It only accepts
3785 This command behaves differently than Unix grep. It only accepts
3786 Python/Perl regexps. It searches repository history, not the
3786 Python/Perl regexps. It searches repository history, not the
3787 working directory. It always prints the revision number in which a
3787 working directory. It always prints the revision number in which a
3788 match appears.
3788 match appears.
3789
3789
3790 By default, grep only prints output for the first revision of a
3790 By default, grep only prints output for the first revision of a
3791 file in which it finds a match. To get it to print every revision
3791 file in which it finds a match. To get it to print every revision
3792 that contains a change in match status ("-" for a match that
3792 that contains a change in match status ("-" for a match that
3793 becomes a non-match, or "+" for a non-match that becomes a match),
3793 becomes a non-match, or "+" for a non-match that becomes a match),
3794 use the --all flag.
3794 use the --all flag.
3795
3795
3796 Returns 0 if a match is found, 1 otherwise.
3796 Returns 0 if a match is found, 1 otherwise.
3797 """
3797 """
3798 reflags = re.M
3798 reflags = re.M
3799 if opts.get('ignore_case'):
3799 if opts.get('ignore_case'):
3800 reflags |= re.I
3800 reflags |= re.I
3801 try:
3801 try:
3802 regexp = util.re.compile(pattern, reflags)
3802 regexp = util.re.compile(pattern, reflags)
3803 except re.error as inst:
3803 except re.error as inst:
3804 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3804 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3805 return 1
3805 return 1
3806 sep, eol = ':', '\n'
3806 sep, eol = ':', '\n'
3807 if opts.get('print0'):
3807 if opts.get('print0'):
3808 sep = eol = '\0'
3808 sep = eol = '\0'
3809
3809
3810 getfile = util.lrucachefunc(repo.file)
3810 getfile = util.lrucachefunc(repo.file)
3811
3811
3812 def matchlines(body):
3812 def matchlines(body):
3813 begin = 0
3813 begin = 0
3814 linenum = 0
3814 linenum = 0
3815 while begin < len(body):
3815 while begin < len(body):
3816 match = regexp.search(body, begin)
3816 match = regexp.search(body, begin)
3817 if not match:
3817 if not match:
3818 break
3818 break
3819 mstart, mend = match.span()
3819 mstart, mend = match.span()
3820 linenum += body.count('\n', begin, mstart) + 1
3820 linenum += body.count('\n', begin, mstart) + 1
3821 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3821 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3822 begin = body.find('\n', mend) + 1 or len(body) + 1
3822 begin = body.find('\n', mend) + 1 or len(body) + 1
3823 lend = begin - 1
3823 lend = begin - 1
3824 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3824 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3825
3825
3826 class linestate(object):
3826 class linestate(object):
3827 def __init__(self, line, linenum, colstart, colend):
3827 def __init__(self, line, linenum, colstart, colend):
3828 self.line = line
3828 self.line = line
3829 self.linenum = linenum
3829 self.linenum = linenum
3830 self.colstart = colstart
3830 self.colstart = colstart
3831 self.colend = colend
3831 self.colend = colend
3832
3832
3833 def __hash__(self):
3833 def __hash__(self):
3834 return hash((self.linenum, self.line))
3834 return hash((self.linenum, self.line))
3835
3835
3836 def __eq__(self, other):
3836 def __eq__(self, other):
3837 return self.line == other.line
3837 return self.line == other.line
3838
3838
3839 def __iter__(self):
3839 def __iter__(self):
3840 yield (self.line[:self.colstart], '')
3840 yield (self.line[:self.colstart], '')
3841 yield (self.line[self.colstart:self.colend], 'grep.match')
3841 yield (self.line[self.colstart:self.colend], 'grep.match')
3842 rest = self.line[self.colend:]
3842 rest = self.line[self.colend:]
3843 while rest != '':
3843 while rest != '':
3844 match = regexp.search(rest)
3844 match = regexp.search(rest)
3845 if not match:
3845 if not match:
3846 yield (rest, '')
3846 yield (rest, '')
3847 break
3847 break
3848 mstart, mend = match.span()
3848 mstart, mend = match.span()
3849 yield (rest[:mstart], '')
3849 yield (rest[:mstart], '')
3850 yield (rest[mstart:mend], 'grep.match')
3850 yield (rest[mstart:mend], 'grep.match')
3851 rest = rest[mend:]
3851 rest = rest[mend:]
3852
3852
3853 matches = {}
3853 matches = {}
3854 copies = {}
3854 copies = {}
3855 def grepbody(fn, rev, body):
3855 def grepbody(fn, rev, body):
3856 matches[rev].setdefault(fn, [])
3856 matches[rev].setdefault(fn, [])
3857 m = matches[rev][fn]
3857 m = matches[rev][fn]
3858 for lnum, cstart, cend, line in matchlines(body):
3858 for lnum, cstart, cend, line in matchlines(body):
3859 s = linestate(line, lnum, cstart, cend)
3859 s = linestate(line, lnum, cstart, cend)
3860 m.append(s)
3860 m.append(s)
3861
3861
3862 def difflinestates(a, b):
3862 def difflinestates(a, b):
3863 sm = difflib.SequenceMatcher(None, a, b)
3863 sm = difflib.SequenceMatcher(None, a, b)
3864 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3864 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3865 if tag == 'insert':
3865 if tag == 'insert':
3866 for i in xrange(blo, bhi):
3866 for i in xrange(blo, bhi):
3867 yield ('+', b[i])
3867 yield ('+', b[i])
3868 elif tag == 'delete':
3868 elif tag == 'delete':
3869 for i in xrange(alo, ahi):
3869 for i in xrange(alo, ahi):
3870 yield ('-', a[i])
3870 yield ('-', a[i])
3871 elif tag == 'replace':
3871 elif tag == 'replace':
3872 for i in xrange(alo, ahi):
3872 for i in xrange(alo, ahi):
3873 yield ('-', a[i])
3873 yield ('-', a[i])
3874 for i in xrange(blo, bhi):
3874 for i in xrange(blo, bhi):
3875 yield ('+', b[i])
3875 yield ('+', b[i])
3876
3876
3877 def display(fn, ctx, pstates, states):
3877 def display(fn, ctx, pstates, states):
3878 rev = ctx.rev()
3878 rev = ctx.rev()
3879 if ui.quiet:
3879 if ui.quiet:
3880 datefunc = util.shortdate
3880 datefunc = util.shortdate
3881 else:
3881 else:
3882 datefunc = util.datestr
3882 datefunc = util.datestr
3883 found = False
3883 found = False
3884 @util.cachefunc
3884 @util.cachefunc
3885 def binary():
3885 def binary():
3886 flog = getfile(fn)
3886 flog = getfile(fn)
3887 return util.binary(flog.read(ctx.filenode(fn)))
3887 return util.binary(flog.read(ctx.filenode(fn)))
3888
3888
3889 if opts.get('all'):
3889 if opts.get('all'):
3890 iter = difflinestates(pstates, states)
3890 iter = difflinestates(pstates, states)
3891 else:
3891 else:
3892 iter = [('', l) for l in states]
3892 iter = [('', l) for l in states]
3893 for change, l in iter:
3893 for change, l in iter:
3894 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3894 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3895
3895
3896 if opts.get('line_number'):
3896 if opts.get('line_number'):
3897 cols.append((str(l.linenum), 'grep.linenumber'))
3897 cols.append((str(l.linenum), 'grep.linenumber'))
3898 if opts.get('all'):
3898 if opts.get('all'):
3899 cols.append((change, 'grep.change'))
3899 cols.append((change, 'grep.change'))
3900 if opts.get('user'):
3900 if opts.get('user'):
3901 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3901 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3902 if opts.get('date'):
3902 if opts.get('date'):
3903 cols.append((datefunc(ctx.date()), 'grep.date'))
3903 cols.append((datefunc(ctx.date()), 'grep.date'))
3904 for col, label in cols[:-1]:
3904 for col, label in cols[:-1]:
3905 ui.write(col, label=label)
3905 ui.write(col, label=label)
3906 ui.write(sep, label='grep.sep')
3906 ui.write(sep, label='grep.sep')
3907 ui.write(cols[-1][0], label=cols[-1][1])
3907 ui.write(cols[-1][0], label=cols[-1][1])
3908 if not opts.get('files_with_matches'):
3908 if not opts.get('files_with_matches'):
3909 ui.write(sep, label='grep.sep')
3909 ui.write(sep, label='grep.sep')
3910 if not opts.get('text') and binary():
3910 if not opts.get('text') and binary():
3911 ui.write(" Binary file matches")
3911 ui.write(" Binary file matches")
3912 else:
3912 else:
3913 for s, label in l:
3913 for s, label in l:
3914 ui.write(s, label=label)
3914 ui.write(s, label=label)
3915 ui.write(eol)
3915 ui.write(eol)
3916 found = True
3916 found = True
3917 if opts.get('files_with_matches'):
3917 if opts.get('files_with_matches'):
3918 break
3918 break
3919 return found
3919 return found
3920
3920
3921 skip = {}
3921 skip = {}
3922 revfiles = {}
3922 revfiles = {}
3923 matchfn = scmutil.match(repo[None], pats, opts)
3923 matchfn = scmutil.match(repo[None], pats, opts)
3924 found = False
3924 found = False
3925 follow = opts.get('follow')
3925 follow = opts.get('follow')
3926
3926
3927 def prep(ctx, fns):
3927 def prep(ctx, fns):
3928 rev = ctx.rev()
3928 rev = ctx.rev()
3929 pctx = ctx.p1()
3929 pctx = ctx.p1()
3930 parent = pctx.rev()
3930 parent = pctx.rev()
3931 matches.setdefault(rev, {})
3931 matches.setdefault(rev, {})
3932 matches.setdefault(parent, {})
3932 matches.setdefault(parent, {})
3933 files = revfiles.setdefault(rev, [])
3933 files = revfiles.setdefault(rev, [])
3934 for fn in fns:
3934 for fn in fns:
3935 flog = getfile(fn)
3935 flog = getfile(fn)
3936 try:
3936 try:
3937 fnode = ctx.filenode(fn)
3937 fnode = ctx.filenode(fn)
3938 except error.LookupError:
3938 except error.LookupError:
3939 continue
3939 continue
3940
3940
3941 copied = flog.renamed(fnode)
3941 copied = flog.renamed(fnode)
3942 copy = follow and copied and copied[0]
3942 copy = follow and copied and copied[0]
3943 if copy:
3943 if copy:
3944 copies.setdefault(rev, {})[fn] = copy
3944 copies.setdefault(rev, {})[fn] = copy
3945 if fn in skip:
3945 if fn in skip:
3946 if copy:
3946 if copy:
3947 skip[copy] = True
3947 skip[copy] = True
3948 continue
3948 continue
3949 files.append(fn)
3949 files.append(fn)
3950
3950
3951 if fn not in matches[rev]:
3951 if fn not in matches[rev]:
3952 grepbody(fn, rev, flog.read(fnode))
3952 grepbody(fn, rev, flog.read(fnode))
3953
3953
3954 pfn = copy or fn
3954 pfn = copy or fn
3955 if pfn not in matches[parent]:
3955 if pfn not in matches[parent]:
3956 try:
3956 try:
3957 fnode = pctx.filenode(pfn)
3957 fnode = pctx.filenode(pfn)
3958 grepbody(pfn, parent, flog.read(fnode))
3958 grepbody(pfn, parent, flog.read(fnode))
3959 except error.LookupError:
3959 except error.LookupError:
3960 pass
3960 pass
3961
3961
3962 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3962 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3963 rev = ctx.rev()
3963 rev = ctx.rev()
3964 parent = ctx.p1().rev()
3964 parent = ctx.p1().rev()
3965 for fn in sorted(revfiles.get(rev, [])):
3965 for fn in sorted(revfiles.get(rev, [])):
3966 states = matches[rev][fn]
3966 states = matches[rev][fn]
3967 copy = copies.get(rev, {}).get(fn)
3967 copy = copies.get(rev, {}).get(fn)
3968 if fn in skip:
3968 if fn in skip:
3969 if copy:
3969 if copy:
3970 skip[copy] = True
3970 skip[copy] = True
3971 continue
3971 continue
3972 pstates = matches.get(parent, {}).get(copy or fn, [])
3972 pstates = matches.get(parent, {}).get(copy or fn, [])
3973 if pstates or states:
3973 if pstates or states:
3974 r = display(fn, ctx, pstates, states)
3974 r = display(fn, ctx, pstates, states)
3975 found = found or r
3975 found = found or r
3976 if r and not opts.get('all'):
3976 if r and not opts.get('all'):
3977 skip[fn] = True
3977 skip[fn] = True
3978 if copy:
3978 if copy:
3979 skip[copy] = True
3979 skip[copy] = True
3980 del matches[rev]
3980 del matches[rev]
3981 del revfiles[rev]
3981 del revfiles[rev]
3982
3982
3983 return not found
3983 return not found
3984
3984
3985 @command('heads',
3985 @command('heads',
3986 [('r', 'rev', '',
3986 [('r', 'rev', '',
3987 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3987 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3988 ('t', 'topo', False, _('show topological heads only')),
3988 ('t', 'topo', False, _('show topological heads only')),
3989 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3989 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3990 ('c', 'closed', False, _('show normal and closed branch heads')),
3990 ('c', 'closed', False, _('show normal and closed branch heads')),
3991 ] + templateopts,
3991 ] + templateopts,
3992 _('[-ct] [-r STARTREV] [REV]...'))
3992 _('[-ct] [-r STARTREV] [REV]...'))
3993 def heads(ui, repo, *branchrevs, **opts):
3993 def heads(ui, repo, *branchrevs, **opts):
3994 """show branch heads
3994 """show branch heads
3995
3995
3996 With no arguments, show all open branch heads in the repository.
3996 With no arguments, show all open branch heads in the repository.
3997 Branch heads are changesets that have no descendants on the
3997 Branch heads are changesets that have no descendants on the
3998 same branch. They are where development generally takes place and
3998 same branch. They are where development generally takes place and
3999 are the usual targets for update and merge operations.
3999 are the usual targets for update and merge operations.
4000
4000
4001 If one or more REVs are given, only open branch heads on the
4001 If one or more REVs are given, only open branch heads on the
4002 branches associated with the specified changesets are shown. This
4002 branches associated with the specified changesets are shown. This
4003 means that you can use :hg:`heads .` to see the heads on the
4003 means that you can use :hg:`heads .` to see the heads on the
4004 currently checked-out branch.
4004 currently checked-out branch.
4005
4005
4006 If -c/--closed is specified, also show branch heads marked closed
4006 If -c/--closed is specified, also show branch heads marked closed
4007 (see :hg:`commit --close-branch`).
4007 (see :hg:`commit --close-branch`).
4008
4008
4009 If STARTREV is specified, only those heads that are descendants of
4009 If STARTREV is specified, only those heads that are descendants of
4010 STARTREV will be displayed.
4010 STARTREV will be displayed.
4011
4011
4012 If -t/--topo is specified, named branch mechanics will be ignored and only
4012 If -t/--topo is specified, named branch mechanics will be ignored and only
4013 topological heads (changesets with no children) will be shown.
4013 topological heads (changesets with no children) will be shown.
4014
4014
4015 Returns 0 if matching heads are found, 1 if not.
4015 Returns 0 if matching heads are found, 1 if not.
4016 """
4016 """
4017
4017
4018 start = None
4018 start = None
4019 if 'rev' in opts:
4019 if 'rev' in opts:
4020 start = scmutil.revsingle(repo, opts['rev'], None).node()
4020 start = scmutil.revsingle(repo, opts['rev'], None).node()
4021
4021
4022 if opts.get('topo'):
4022 if opts.get('topo'):
4023 heads = [repo[h] for h in repo.heads(start)]
4023 heads = [repo[h] for h in repo.heads(start)]
4024 else:
4024 else:
4025 heads = []
4025 heads = []
4026 for branch in repo.branchmap():
4026 for branch in repo.branchmap():
4027 heads += repo.branchheads(branch, start, opts.get('closed'))
4027 heads += repo.branchheads(branch, start, opts.get('closed'))
4028 heads = [repo[h] for h in heads]
4028 heads = [repo[h] for h in heads]
4029
4029
4030 if branchrevs:
4030 if branchrevs:
4031 branches = set(repo[br].branch() for br in branchrevs)
4031 branches = set(repo[br].branch() for br in branchrevs)
4032 heads = [h for h in heads if h.branch() in branches]
4032 heads = [h for h in heads if h.branch() in branches]
4033
4033
4034 if opts.get('active') and branchrevs:
4034 if opts.get('active') and branchrevs:
4035 dagheads = repo.heads(start)
4035 dagheads = repo.heads(start)
4036 heads = [h for h in heads if h.node() in dagheads]
4036 heads = [h for h in heads if h.node() in dagheads]
4037
4037
4038 if branchrevs:
4038 if branchrevs:
4039 haveheads = set(h.branch() for h in heads)
4039 haveheads = set(h.branch() for h in heads)
4040 if branches - haveheads:
4040 if branches - haveheads:
4041 headless = ', '.join(b for b in branches - haveheads)
4041 headless = ', '.join(b for b in branches - haveheads)
4042 msg = _('no open branch heads found on branches %s')
4042 msg = _('no open branch heads found on branches %s')
4043 if opts.get('rev'):
4043 if opts.get('rev'):
4044 msg += _(' (started at %s)') % opts['rev']
4044 msg += _(' (started at %s)') % opts['rev']
4045 ui.warn((msg + '\n') % headless)
4045 ui.warn((msg + '\n') % headless)
4046
4046
4047 if not heads:
4047 if not heads:
4048 return 1
4048 return 1
4049
4049
4050 heads = sorted(heads, key=lambda x: -x.rev())
4050 heads = sorted(heads, key=lambda x: -x.rev())
4051 displayer = cmdutil.show_changeset(ui, repo, opts)
4051 displayer = cmdutil.show_changeset(ui, repo, opts)
4052 for ctx in heads:
4052 for ctx in heads:
4053 displayer.show(ctx)
4053 displayer.show(ctx)
4054 displayer.close()
4054 displayer.close()
4055
4055
4056 @command('help',
4056 @command('help',
4057 [('e', 'extension', None, _('show only help for extensions')),
4057 [('e', 'extension', None, _('show only help for extensions')),
4058 ('c', 'command', None, _('show only help for commands')),
4058 ('c', 'command', None, _('show only help for commands')),
4059 ('k', 'keyword', None, _('show topics matching keyword')),
4059 ('k', 'keyword', None, _('show topics matching keyword')),
4060 ],
4060 ],
4061 _('[-eck] [TOPIC]'),
4061 _('[-eck] [TOPIC]'),
4062 norepo=True)
4062 norepo=True)
4063 def help_(ui, name=None, **opts):
4063 def help_(ui, name=None, **opts):
4064 """show help for a given topic or a help overview
4064 """show help for a given topic or a help overview
4065
4065
4066 With no arguments, print a list of commands with short help messages.
4066 With no arguments, print a list of commands with short help messages.
4067
4067
4068 Given a topic, extension, or command name, print help for that
4068 Given a topic, extension, or command name, print help for that
4069 topic.
4069 topic.
4070
4070
4071 Returns 0 if successful.
4071 Returns 0 if successful.
4072 """
4072 """
4073
4073
4074 textwidth = min(ui.termwidth(), 80) - 2
4074 textwidth = min(ui.termwidth(), 80) - 2
4075
4075
4076 keep = []
4076 keep = []
4077 if ui.verbose:
4077 if ui.verbose:
4078 keep.append('verbose')
4078 keep.append('verbose')
4079 if sys.platform.startswith('win'):
4079 if sys.platform.startswith('win'):
4080 keep.append('windows')
4080 keep.append('windows')
4081 elif sys.platform == 'OpenVMS':
4081 elif sys.platform == 'OpenVMS':
4082 keep.append('vms')
4082 keep.append('vms')
4083 elif sys.platform == 'plan9':
4083 elif sys.platform == 'plan9':
4084 keep.append('plan9')
4084 keep.append('plan9')
4085 else:
4085 else:
4086 keep.append('unix')
4086 keep.append('unix')
4087 keep.append(sys.platform.lower())
4087 keep.append(sys.platform.lower())
4088
4088
4089 section = None
4089 section = None
4090 if name and '.' in name:
4090 if name and '.' in name:
4091 name, section = name.split('.', 1)
4091 name, section = name.split('.', 1)
4092 section = section.lower()
4092 section = section.lower()
4093
4093
4094 text = help.help_(ui, name, **opts)
4094 text = help.help_(ui, name, **opts)
4095
4095
4096 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4096 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4097 section=section)
4097 section=section)
4098
4098
4099 # We could have been given a weird ".foo" section without a name
4099 # We could have been given a weird ".foo" section without a name
4100 # to look for, or we could have simply failed to found "foo.bar"
4100 # to look for, or we could have simply failed to found "foo.bar"
4101 # because bar isn't a section of foo
4101 # because bar isn't a section of foo
4102 if section and not (formatted and name):
4102 if section and not (formatted and name):
4103 raise util.Abort(_("help section not found"))
4103 raise util.Abort(_("help section not found"))
4104
4104
4105 if 'verbose' in pruned:
4105 if 'verbose' in pruned:
4106 keep.append('omitted')
4106 keep.append('omitted')
4107 else:
4107 else:
4108 keep.append('notomitted')
4108 keep.append('notomitted')
4109 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4109 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4110 section=section)
4110 section=section)
4111 ui.write(formatted)
4111 ui.write(formatted)
4112
4112
4113
4113
4114 @command('identify|id',
4114 @command('identify|id',
4115 [('r', 'rev', '',
4115 [('r', 'rev', '',
4116 _('identify the specified revision'), _('REV')),
4116 _('identify the specified revision'), _('REV')),
4117 ('n', 'num', None, _('show local revision number')),
4117 ('n', 'num', None, _('show local revision number')),
4118 ('i', 'id', None, _('show global revision id')),
4118 ('i', 'id', None, _('show global revision id')),
4119 ('b', 'branch', None, _('show branch')),
4119 ('b', 'branch', None, _('show branch')),
4120 ('t', 'tags', None, _('show tags')),
4120 ('t', 'tags', None, _('show tags')),
4121 ('B', 'bookmarks', None, _('show bookmarks')),
4121 ('B', 'bookmarks', None, _('show bookmarks')),
4122 ] + remoteopts,
4122 ] + remoteopts,
4123 _('[-nibtB] [-r REV] [SOURCE]'),
4123 _('[-nibtB] [-r REV] [SOURCE]'),
4124 optionalrepo=True)
4124 optionalrepo=True)
4125 def identify(ui, repo, source=None, rev=None,
4125 def identify(ui, repo, source=None, rev=None,
4126 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4126 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4127 """identify the working directory or specified revision
4127 """identify the working directory or specified revision
4128
4128
4129 Print a summary identifying the repository state at REV using one or
4129 Print a summary identifying the repository state at REV using one or
4130 two parent hash identifiers, followed by a "+" if the working
4130 two parent hash identifiers, followed by a "+" if the working
4131 directory has uncommitted changes, the branch name (if not default),
4131 directory has uncommitted changes, the branch name (if not default),
4132 a list of tags, and a list of bookmarks.
4132 a list of tags, and a list of bookmarks.
4133
4133
4134 When REV is not given, print a summary of the current state of the
4134 When REV is not given, print a summary of the current state of the
4135 repository.
4135 repository.
4136
4136
4137 Specifying a path to a repository root or Mercurial bundle will
4137 Specifying a path to a repository root or Mercurial bundle will
4138 cause lookup to operate on that repository/bundle.
4138 cause lookup to operate on that repository/bundle.
4139
4139
4140 .. container:: verbose
4140 .. container:: verbose
4141
4141
4142 Examples:
4142 Examples:
4143
4143
4144 - generate a build identifier for the working directory::
4144 - generate a build identifier for the working directory::
4145
4145
4146 hg id --id > build-id.dat
4146 hg id --id > build-id.dat
4147
4147
4148 - find the revision corresponding to a tag::
4148 - find the revision corresponding to a tag::
4149
4149
4150 hg id -n -r 1.3
4150 hg id -n -r 1.3
4151
4151
4152 - check the most recent revision of a remote repository::
4152 - check the most recent revision of a remote repository::
4153
4153
4154 hg id -r tip http://selenic.com/hg/
4154 hg id -r tip http://selenic.com/hg/
4155
4155
4156 Returns 0 if successful.
4156 Returns 0 if successful.
4157 """
4157 """
4158
4158
4159 if not repo and not source:
4159 if not repo and not source:
4160 raise util.Abort(_("there is no Mercurial repository here "
4160 raise util.Abort(_("there is no Mercurial repository here "
4161 "(.hg not found)"))
4161 "(.hg not found)"))
4162
4162
4163 if ui.debugflag:
4163 if ui.debugflag:
4164 hexfunc = hex
4164 hexfunc = hex
4165 else:
4165 else:
4166 hexfunc = short
4166 hexfunc = short
4167 default = not (num or id or branch or tags or bookmarks)
4167 default = not (num or id or branch or tags or bookmarks)
4168 output = []
4168 output = []
4169 revs = []
4169 revs = []
4170
4170
4171 if source:
4171 if source:
4172 source, branches = hg.parseurl(ui.expandpath(source))
4172 source, branches = hg.parseurl(ui.expandpath(source))
4173 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4173 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4174 repo = peer.local()
4174 repo = peer.local()
4175 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4175 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4176
4176
4177 if not repo:
4177 if not repo:
4178 if num or branch or tags:
4178 if num or branch or tags:
4179 raise util.Abort(
4179 raise util.Abort(
4180 _("can't query remote revision number, branch, or tags"))
4180 _("can't query remote revision number, branch, or tags"))
4181 if not rev and revs:
4181 if not rev and revs:
4182 rev = revs[0]
4182 rev = revs[0]
4183 if not rev:
4183 if not rev:
4184 rev = "tip"
4184 rev = "tip"
4185
4185
4186 remoterev = peer.lookup(rev)
4186 remoterev = peer.lookup(rev)
4187 if default or id:
4187 if default or id:
4188 output = [hexfunc(remoterev)]
4188 output = [hexfunc(remoterev)]
4189
4189
4190 def getbms():
4190 def getbms():
4191 bms = []
4191 bms = []
4192
4192
4193 if 'bookmarks' in peer.listkeys('namespaces'):
4193 if 'bookmarks' in peer.listkeys('namespaces'):
4194 hexremoterev = hex(remoterev)
4194 hexremoterev = hex(remoterev)
4195 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4195 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4196 if bmr == hexremoterev]
4196 if bmr == hexremoterev]
4197
4197
4198 return sorted(bms)
4198 return sorted(bms)
4199
4199
4200 if bookmarks:
4200 if bookmarks:
4201 output.extend(getbms())
4201 output.extend(getbms())
4202 elif default and not ui.quiet:
4202 elif default and not ui.quiet:
4203 # multiple bookmarks for a single parent separated by '/'
4203 # multiple bookmarks for a single parent separated by '/'
4204 bm = '/'.join(getbms())
4204 bm = '/'.join(getbms())
4205 if bm:
4205 if bm:
4206 output.append(bm)
4206 output.append(bm)
4207 else:
4207 else:
4208 ctx = scmutil.revsingle(repo, rev, None)
4208 ctx = scmutil.revsingle(repo, rev, None)
4209
4209
4210 if ctx.rev() is None:
4210 if ctx.rev() is None:
4211 ctx = repo[None]
4211 ctx = repo[None]
4212 parents = ctx.parents()
4212 parents = ctx.parents()
4213 taglist = []
4213 taglist = []
4214 for p in parents:
4214 for p in parents:
4215 taglist.extend(p.tags())
4215 taglist.extend(p.tags())
4216
4216
4217 changed = ""
4217 changed = ""
4218 if default or id or num:
4218 if default or id or num:
4219 if (any(repo.status())
4219 if (any(repo.status())
4220 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4220 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4221 changed = '+'
4221 changed = '+'
4222 if default or id:
4222 if default or id:
4223 output = ["%s%s" %
4223 output = ["%s%s" %
4224 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4224 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4225 if num:
4225 if num:
4226 output.append("%s%s" %
4226 output.append("%s%s" %
4227 ('+'.join([str(p.rev()) for p in parents]), changed))
4227 ('+'.join([str(p.rev()) for p in parents]), changed))
4228 else:
4228 else:
4229 if default or id:
4229 if default or id:
4230 output = [hexfunc(ctx.node())]
4230 output = [hexfunc(ctx.node())]
4231 if num:
4231 if num:
4232 output.append(str(ctx.rev()))
4232 output.append(str(ctx.rev()))
4233 taglist = ctx.tags()
4233 taglist = ctx.tags()
4234
4234
4235 if default and not ui.quiet:
4235 if default and not ui.quiet:
4236 b = ctx.branch()
4236 b = ctx.branch()
4237 if b != 'default':
4237 if b != 'default':
4238 output.append("(%s)" % b)
4238 output.append("(%s)" % b)
4239
4239
4240 # multiple tags for a single parent separated by '/'
4240 # multiple tags for a single parent separated by '/'
4241 t = '/'.join(taglist)
4241 t = '/'.join(taglist)
4242 if t:
4242 if t:
4243 output.append(t)
4243 output.append(t)
4244
4244
4245 # multiple bookmarks for a single parent separated by '/'
4245 # multiple bookmarks for a single parent separated by '/'
4246 bm = '/'.join(ctx.bookmarks())
4246 bm = '/'.join(ctx.bookmarks())
4247 if bm:
4247 if bm:
4248 output.append(bm)
4248 output.append(bm)
4249 else:
4249 else:
4250 if branch:
4250 if branch:
4251 output.append(ctx.branch())
4251 output.append(ctx.branch())
4252
4252
4253 if tags:
4253 if tags:
4254 output.extend(taglist)
4254 output.extend(taglist)
4255
4255
4256 if bookmarks:
4256 if bookmarks:
4257 output.extend(ctx.bookmarks())
4257 output.extend(ctx.bookmarks())
4258
4258
4259 ui.write("%s\n" % ' '.join(output))
4259 ui.write("%s\n" % ' '.join(output))
4260
4260
4261 @command('import|patch',
4261 @command('import|patch',
4262 [('p', 'strip', 1,
4262 [('p', 'strip', 1,
4263 _('directory strip option for patch. This has the same '
4263 _('directory strip option for patch. This has the same '
4264 'meaning as the corresponding patch option'), _('NUM')),
4264 'meaning as the corresponding patch option'), _('NUM')),
4265 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4265 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4266 ('e', 'edit', False, _('invoke editor on commit messages')),
4266 ('e', 'edit', False, _('invoke editor on commit messages')),
4267 ('f', 'force', None,
4267 ('f', 'force', None,
4268 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4268 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4269 ('', 'no-commit', None,
4269 ('', 'no-commit', None,
4270 _("don't commit, just update the working directory")),
4270 _("don't commit, just update the working directory")),
4271 ('', 'bypass', None,
4271 ('', 'bypass', None,
4272 _("apply patch without touching the working directory")),
4272 _("apply patch without touching the working directory")),
4273 ('', 'partial', None,
4273 ('', 'partial', None,
4274 _('commit even if some hunks fail')),
4274 _('commit even if some hunks fail')),
4275 ('', 'exact', None,
4275 ('', 'exact', None,
4276 _('apply patch to the nodes from which it was generated')),
4276 _('apply patch to the nodes from which it was generated')),
4277 ('', 'prefix', '',
4277 ('', 'prefix', '',
4278 _('apply patch to subdirectory'), _('DIR')),
4278 _('apply patch to subdirectory'), _('DIR')),
4279 ('', 'import-branch', None,
4279 ('', 'import-branch', None,
4280 _('use any branch information in patch (implied by --exact)'))] +
4280 _('use any branch information in patch (implied by --exact)'))] +
4281 commitopts + commitopts2 + similarityopts,
4281 commitopts + commitopts2 + similarityopts,
4282 _('[OPTION]... PATCH...'))
4282 _('[OPTION]... PATCH...'))
4283 def import_(ui, repo, patch1=None, *patches, **opts):
4283 def import_(ui, repo, patch1=None, *patches, **opts):
4284 """import an ordered set of patches
4284 """import an ordered set of patches
4285
4285
4286 Import a list of patches and commit them individually (unless
4286 Import a list of patches and commit them individually (unless
4287 --no-commit is specified).
4287 --no-commit is specified).
4288
4288
4289 Because import first applies changes to the working directory,
4289 Because import first applies changes to the working directory,
4290 import will abort if there are outstanding changes.
4290 import will abort if there are outstanding changes.
4291
4291
4292 You can import a patch straight from a mail message. Even patches
4292 You can import a patch straight from a mail message. Even patches
4293 as attachments work (to use the body part, it must have type
4293 as attachments work (to use the body part, it must have type
4294 text/plain or text/x-patch). From and Subject headers of email
4294 text/plain or text/x-patch). From and Subject headers of email
4295 message are used as default committer and commit message. All
4295 message are used as default committer and commit message. All
4296 text/plain body parts before first diff are added to commit
4296 text/plain body parts before first diff are added to commit
4297 message.
4297 message.
4298
4298
4299 If the imported patch was generated by :hg:`export`, user and
4299 If the imported patch was generated by :hg:`export`, user and
4300 description from patch override values from message headers and
4300 description from patch override values from message headers and
4301 body. Values given on command line with -m/--message and -u/--user
4301 body. Values given on command line with -m/--message and -u/--user
4302 override these.
4302 override these.
4303
4303
4304 If --exact is specified, import will set the working directory to
4304 If --exact is specified, import will set the working directory to
4305 the parent of each patch before applying it, and will abort if the
4305 the parent of each patch before applying it, and will abort if the
4306 resulting changeset has a different ID than the one recorded in
4306 resulting changeset has a different ID than the one recorded in
4307 the patch. This may happen due to character set problems or other
4307 the patch. This may happen due to character set problems or other
4308 deficiencies in the text patch format.
4308 deficiencies in the text patch format.
4309
4309
4310 Use --bypass to apply and commit patches directly to the
4310 Use --bypass to apply and commit patches directly to the
4311 repository, not touching the working directory. Without --exact,
4311 repository, not touching the working directory. Without --exact,
4312 patches will be applied on top of the working directory parent
4312 patches will be applied on top of the working directory parent
4313 revision.
4313 revision.
4314
4314
4315 With -s/--similarity, hg will attempt to discover renames and
4315 With -s/--similarity, hg will attempt to discover renames and
4316 copies in the patch in the same way as :hg:`addremove`.
4316 copies in the patch in the same way as :hg:`addremove`.
4317
4317
4318 Use --partial to ensure a changeset will be created from the patch
4318 Use --partial to ensure a changeset will be created from the patch
4319 even if some hunks fail to apply. Hunks that fail to apply will be
4319 even if some hunks fail to apply. Hunks that fail to apply will be
4320 written to a <target-file>.rej file. Conflicts can then be resolved
4320 written to a <target-file>.rej file. Conflicts can then be resolved
4321 by hand before :hg:`commit --amend` is run to update the created
4321 by hand before :hg:`commit --amend` is run to update the created
4322 changeset. This flag exists to let people import patches that
4322 changeset. This flag exists to let people import patches that
4323 partially apply without losing the associated metadata (author,
4323 partially apply without losing the associated metadata (author,
4324 date, description, ...). Note that when none of the hunk applies
4324 date, description, ...). Note that when none of the hunk applies
4325 cleanly, :hg:`import --partial` will create an empty changeset,
4325 cleanly, :hg:`import --partial` will create an empty changeset,
4326 importing only the patch metadata.
4326 importing only the patch metadata.
4327
4327
4328 It is possible to use external patch programs to perform the patch
4328 It is possible to use external patch programs to perform the patch
4329 by setting the ``ui.patch`` configuration option. For the default
4329 by setting the ``ui.patch`` configuration option. For the default
4330 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4330 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4331 See :hg:`help config` for more information about configuration
4331 See :hg:`help config` for more information about configuration
4332 files and how to use these options.
4332 files and how to use these options.
4333
4333
4334 To read a patch from standard input, use "-" as the patch name. If
4334 To read a patch from standard input, use "-" as the patch name. If
4335 a URL is specified, the patch will be downloaded from it.
4335 a URL is specified, the patch will be downloaded from it.
4336 See :hg:`help dates` for a list of formats valid for -d/--date.
4336 See :hg:`help dates` for a list of formats valid for -d/--date.
4337
4337
4338 .. container:: verbose
4338 .. container:: verbose
4339
4339
4340 Examples:
4340 Examples:
4341
4341
4342 - import a traditional patch from a website and detect renames::
4342 - import a traditional patch from a website and detect renames::
4343
4343
4344 hg import -s 80 http://example.com/bugfix.patch
4344 hg import -s 80 http://example.com/bugfix.patch
4345
4345
4346 - import a changeset from an hgweb server::
4346 - import a changeset from an hgweb server::
4347
4347
4348 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4348 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4349
4349
4350 - import all the patches in an Unix-style mbox::
4350 - import all the patches in an Unix-style mbox::
4351
4351
4352 hg import incoming-patches.mbox
4352 hg import incoming-patches.mbox
4353
4353
4354 - attempt to exactly restore an exported changeset (not always
4354 - attempt to exactly restore an exported changeset (not always
4355 possible)::
4355 possible)::
4356
4356
4357 hg import --exact proposed-fix.patch
4357 hg import --exact proposed-fix.patch
4358
4358
4359 - use an external tool to apply a patch which is too fuzzy for
4359 - use an external tool to apply a patch which is too fuzzy for
4360 the default internal tool.
4360 the default internal tool.
4361
4361
4362 hg import --config ui.patch="patch --merge" fuzzy.patch
4362 hg import --config ui.patch="patch --merge" fuzzy.patch
4363
4363
4364 - change the default fuzzing from 2 to a less strict 7
4364 - change the default fuzzing from 2 to a less strict 7
4365
4365
4366 hg import --config ui.fuzz=7 fuzz.patch
4366 hg import --config ui.fuzz=7 fuzz.patch
4367
4367
4368 Returns 0 on success, 1 on partial success (see --partial).
4368 Returns 0 on success, 1 on partial success (see --partial).
4369 """
4369 """
4370
4370
4371 if not patch1:
4371 if not patch1:
4372 raise util.Abort(_('need at least one patch to import'))
4372 raise util.Abort(_('need at least one patch to import'))
4373
4373
4374 patches = (patch1,) + patches
4374 patches = (patch1,) + patches
4375
4375
4376 date = opts.get('date')
4376 date = opts.get('date')
4377 if date:
4377 if date:
4378 opts['date'] = util.parsedate(date)
4378 opts['date'] = util.parsedate(date)
4379
4379
4380 update = not opts.get('bypass')
4380 update = not opts.get('bypass')
4381 if not update and opts.get('no_commit'):
4381 if not update and opts.get('no_commit'):
4382 raise util.Abort(_('cannot use --no-commit with --bypass'))
4382 raise util.Abort(_('cannot use --no-commit with --bypass'))
4383 try:
4383 try:
4384 sim = float(opts.get('similarity') or 0)
4384 sim = float(opts.get('similarity') or 0)
4385 except ValueError:
4385 except ValueError:
4386 raise util.Abort(_('similarity must be a number'))
4386 raise util.Abort(_('similarity must be a number'))
4387 if sim < 0 or sim > 100:
4387 if sim < 0 or sim > 100:
4388 raise util.Abort(_('similarity must be between 0 and 100'))
4388 raise util.Abort(_('similarity must be between 0 and 100'))
4389 if sim and not update:
4389 if sim and not update:
4390 raise util.Abort(_('cannot use --similarity with --bypass'))
4390 raise util.Abort(_('cannot use --similarity with --bypass'))
4391 if opts.get('exact') and opts.get('edit'):
4391 if opts.get('exact') and opts.get('edit'):
4392 raise util.Abort(_('cannot use --exact with --edit'))
4392 raise util.Abort(_('cannot use --exact with --edit'))
4393 if opts.get('exact') and opts.get('prefix'):
4393 if opts.get('exact') and opts.get('prefix'):
4394 raise util.Abort(_('cannot use --exact with --prefix'))
4394 raise util.Abort(_('cannot use --exact with --prefix'))
4395
4395
4396 if update:
4396 if update:
4397 cmdutil.checkunfinished(repo)
4397 cmdutil.checkunfinished(repo)
4398 if (opts.get('exact') or not opts.get('force')) and update:
4398 if (opts.get('exact') or not opts.get('force')) and update:
4399 cmdutil.bailifchanged(repo)
4399 cmdutil.bailifchanged(repo)
4400
4400
4401 base = opts["base"]
4401 base = opts["base"]
4402 wlock = dsguard = lock = tr = None
4402 wlock = dsguard = lock = tr = None
4403 msgs = []
4403 msgs = []
4404 ret = 0
4404 ret = 0
4405
4405
4406
4406
4407 try:
4407 try:
4408 try:
4408 try:
4409 wlock = repo.wlock()
4409 wlock = repo.wlock()
4410 dsguard = cmdutil.dirstateguard(repo, 'import')
4410 dsguard = cmdutil.dirstateguard(repo, 'import')
4411 if not opts.get('no_commit'):
4411 if not opts.get('no_commit'):
4412 lock = repo.lock()
4412 lock = repo.lock()
4413 tr = repo.transaction('import')
4413 tr = repo.transaction('import')
4414 parents = repo.parents()
4414 parents = repo.parents()
4415 for patchurl in patches:
4415 for patchurl in patches:
4416 if patchurl == '-':
4416 if patchurl == '-':
4417 ui.status(_('applying patch from stdin\n'))
4417 ui.status(_('applying patch from stdin\n'))
4418 patchfile = ui.fin
4418 patchfile = ui.fin
4419 patchurl = 'stdin' # for error message
4419 patchurl = 'stdin' # for error message
4420 else:
4420 else:
4421 patchurl = os.path.join(base, patchurl)
4421 patchurl = os.path.join(base, patchurl)
4422 ui.status(_('applying %s\n') % patchurl)
4422 ui.status(_('applying %s\n') % patchurl)
4423 patchfile = hg.openpath(ui, patchurl)
4423 patchfile = hg.openpath(ui, patchurl)
4424
4424
4425 haspatch = False
4425 haspatch = False
4426 for hunk in patch.split(patchfile):
4426 for hunk in patch.split(patchfile):
4427 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4427 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4428 parents, opts,
4428 parents, opts,
4429 msgs, hg.clean)
4429 msgs, hg.clean)
4430 if msg:
4430 if msg:
4431 haspatch = True
4431 haspatch = True
4432 ui.note(msg + '\n')
4432 ui.note(msg + '\n')
4433 if update or opts.get('exact'):
4433 if update or opts.get('exact'):
4434 parents = repo.parents()
4434 parents = repo.parents()
4435 else:
4435 else:
4436 parents = [repo[node]]
4436 parents = [repo[node]]
4437 if rej:
4437 if rej:
4438 ui.write_err(_("patch applied partially\n"))
4438 ui.write_err(_("patch applied partially\n"))
4439 ui.write_err(_("(fix the .rej files and run "
4439 ui.write_err(_("(fix the .rej files and run "
4440 "`hg commit --amend`)\n"))
4440 "`hg commit --amend`)\n"))
4441 ret = 1
4441 ret = 1
4442 break
4442 break
4443
4443
4444 if not haspatch:
4444 if not haspatch:
4445 raise util.Abort(_('%s: no diffs found') % patchurl)
4445 raise util.Abort(_('%s: no diffs found') % patchurl)
4446
4446
4447 if tr:
4447 if tr:
4448 tr.close()
4448 tr.close()
4449 if msgs:
4449 if msgs:
4450 repo.savecommitmessage('\n* * *\n'.join(msgs))
4450 repo.savecommitmessage('\n* * *\n'.join(msgs))
4451 dsguard.close()
4451 dsguard.close()
4452 return ret
4452 return ret
4453 finally:
4453 finally:
4454 # TODO: get rid of this meaningless try/finally enclosing.
4454 # TODO: get rid of this meaningless try/finally enclosing.
4455 # this is kept only to reduce changes in a patch.
4455 # this is kept only to reduce changes in a patch.
4456 pass
4456 pass
4457 finally:
4457 finally:
4458 if tr:
4458 if tr:
4459 tr.release()
4459 tr.release()
4460 release(lock, dsguard, wlock)
4460 release(lock, dsguard, wlock)
4461
4461
4462 @command('incoming|in',
4462 @command('incoming|in',
4463 [('f', 'force', None,
4463 [('f', 'force', None,
4464 _('run even if remote repository is unrelated')),
4464 _('run even if remote repository is unrelated')),
4465 ('n', 'newest-first', None, _('show newest record first')),
4465 ('n', 'newest-first', None, _('show newest record first')),
4466 ('', 'bundle', '',
4466 ('', 'bundle', '',
4467 _('file to store the bundles into'), _('FILE')),
4467 _('file to store the bundles into'), _('FILE')),
4468 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4468 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4469 ('B', 'bookmarks', False, _("compare bookmarks")),
4469 ('B', 'bookmarks', False, _("compare bookmarks")),
4470 ('b', 'branch', [],
4470 ('b', 'branch', [],
4471 _('a specific branch you would like to pull'), _('BRANCH')),
4471 _('a specific branch you would like to pull'), _('BRANCH')),
4472 ] + logopts + remoteopts + subrepoopts,
4472 ] + logopts + remoteopts + subrepoopts,
4473 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4473 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4474 def incoming(ui, repo, source="default", **opts):
4474 def incoming(ui, repo, source="default", **opts):
4475 """show new changesets found in source
4475 """show new changesets found in source
4476
4476
4477 Show new changesets found in the specified path/URL or the default
4477 Show new changesets found in the specified path/URL or the default
4478 pull location. These are the changesets that would have been pulled
4478 pull location. These are the changesets that would have been pulled
4479 if a pull at the time you issued this command.
4479 if a pull at the time you issued this command.
4480
4480
4481 See pull for valid source format details.
4481 See pull for valid source format details.
4482
4482
4483 .. container:: verbose
4483 .. container:: verbose
4484
4484
4485 With -B/--bookmarks, the result of bookmark comparison between
4485 With -B/--bookmarks, the result of bookmark comparison between
4486 local and remote repositories is displayed. With -v/--verbose,
4486 local and remote repositories is displayed. With -v/--verbose,
4487 status is also displayed for each bookmark like below::
4487 status is also displayed for each bookmark like below::
4488
4488
4489 BM1 01234567890a added
4489 BM1 01234567890a added
4490 BM2 1234567890ab advanced
4490 BM2 1234567890ab advanced
4491 BM3 234567890abc diverged
4491 BM3 234567890abc diverged
4492 BM4 34567890abcd changed
4492 BM4 34567890abcd changed
4493
4493
4494 The action taken locally when pulling depends on the
4494 The action taken locally when pulling depends on the
4495 status of each bookmark:
4495 status of each bookmark:
4496
4496
4497 :``added``: pull will create it
4497 :``added``: pull will create it
4498 :``advanced``: pull will update it
4498 :``advanced``: pull will update it
4499 :``diverged``: pull will create a divergent bookmark
4499 :``diverged``: pull will create a divergent bookmark
4500 :``changed``: result depends on remote changesets
4500 :``changed``: result depends on remote changesets
4501
4501
4502 From the point of view of pulling behavior, bookmark
4502 From the point of view of pulling behavior, bookmark
4503 existing only in the remote repository are treated as ``added``,
4503 existing only in the remote repository are treated as ``added``,
4504 even if it is in fact locally deleted.
4504 even if it is in fact locally deleted.
4505
4505
4506 .. container:: verbose
4506 .. container:: verbose
4507
4507
4508 For remote repository, using --bundle avoids downloading the
4508 For remote repository, using --bundle avoids downloading the
4509 changesets twice if the incoming is followed by a pull.
4509 changesets twice if the incoming is followed by a pull.
4510
4510
4511 Examples:
4511 Examples:
4512
4512
4513 - show incoming changes with patches and full description::
4513 - show incoming changes with patches and full description::
4514
4514
4515 hg incoming -vp
4515 hg incoming -vp
4516
4516
4517 - show incoming changes excluding merges, store a bundle::
4517 - show incoming changes excluding merges, store a bundle::
4518
4518
4519 hg in -vpM --bundle incoming.hg
4519 hg in -vpM --bundle incoming.hg
4520 hg pull incoming.hg
4520 hg pull incoming.hg
4521
4521
4522 - briefly list changes inside a bundle::
4522 - briefly list changes inside a bundle::
4523
4523
4524 hg in changes.hg -T "{desc|firstline}\\n"
4524 hg in changes.hg -T "{desc|firstline}\\n"
4525
4525
4526 Returns 0 if there are incoming changes, 1 otherwise.
4526 Returns 0 if there are incoming changes, 1 otherwise.
4527 """
4527 """
4528 if opts.get('graph'):
4528 if opts.get('graph'):
4529 cmdutil.checkunsupportedgraphflags([], opts)
4529 cmdutil.checkunsupportedgraphflags([], opts)
4530 def display(other, chlist, displayer):
4530 def display(other, chlist, displayer):
4531 revdag = cmdutil.graphrevs(other, chlist, opts)
4531 revdag = cmdutil.graphrevs(other, chlist, opts)
4532 showparents = [ctx.node() for ctx in repo[None].parents()]
4532 showparents = [ctx.node() for ctx in repo[None].parents()]
4533 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4533 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4534 graphmod.asciiedges)
4534 graphmod.asciiedges)
4535
4535
4536 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4536 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4537 return 0
4537 return 0
4538
4538
4539 if opts.get('bundle') and opts.get('subrepos'):
4539 if opts.get('bundle') and opts.get('subrepos'):
4540 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4540 raise util.Abort(_('cannot combine --bundle and --subrepos'))
4541
4541
4542 if opts.get('bookmarks'):
4542 if opts.get('bookmarks'):
4543 source, branches = hg.parseurl(ui.expandpath(source),
4543 source, branches = hg.parseurl(ui.expandpath(source),
4544 opts.get('branch'))
4544 opts.get('branch'))
4545 other = hg.peer(repo, opts, source)
4545 other = hg.peer(repo, opts, source)
4546 if 'bookmarks' not in other.listkeys('namespaces'):
4546 if 'bookmarks' not in other.listkeys('namespaces'):
4547 ui.warn(_("remote doesn't support bookmarks\n"))
4547 ui.warn(_("remote doesn't support bookmarks\n"))
4548 return 0
4548 return 0
4549 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4549 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4550 return bookmarks.incoming(ui, repo, other)
4550 return bookmarks.incoming(ui, repo, other)
4551
4551
4552 repo._subtoppath = ui.expandpath(source)
4552 repo._subtoppath = ui.expandpath(source)
4553 try:
4553 try:
4554 return hg.incoming(ui, repo, source, opts)
4554 return hg.incoming(ui, repo, source, opts)
4555 finally:
4555 finally:
4556 del repo._subtoppath
4556 del repo._subtoppath
4557
4557
4558
4558
4559 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4559 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4560 norepo=True)
4560 norepo=True)
4561 def init(ui, dest=".", **opts):
4561 def init(ui, dest=".", **opts):
4562 """create a new repository in the given directory
4562 """create a new repository in the given directory
4563
4563
4564 Initialize a new repository in the given directory. If the given
4564 Initialize a new repository in the given directory. If the given
4565 directory does not exist, it will be created.
4565 directory does not exist, it will be created.
4566
4566
4567 If no directory is given, the current directory is used.
4567 If no directory is given, the current directory is used.
4568
4568
4569 It is possible to specify an ``ssh://`` URL as the destination.
4569 It is possible to specify an ``ssh://`` URL as the destination.
4570 See :hg:`help urls` for more information.
4570 See :hg:`help urls` for more information.
4571
4571
4572 Returns 0 on success.
4572 Returns 0 on success.
4573 """
4573 """
4574 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4574 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4575
4575
4576 @command('locate',
4576 @command('locate',
4577 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4577 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4578 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4578 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4579 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4579 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4580 ] + walkopts,
4580 ] + walkopts,
4581 _('[OPTION]... [PATTERN]...'))
4581 _('[OPTION]... [PATTERN]...'))
4582 def locate(ui, repo, *pats, **opts):
4582 def locate(ui, repo, *pats, **opts):
4583 """locate files matching specific patterns (DEPRECATED)
4583 """locate files matching specific patterns (DEPRECATED)
4584
4584
4585 Print files under Mercurial control in the working directory whose
4585 Print files under Mercurial control in the working directory whose
4586 names match the given patterns.
4586 names match the given patterns.
4587
4587
4588 By default, this command searches all directories in the working
4588 By default, this command searches all directories in the working
4589 directory. To search just the current directory and its
4589 directory. To search just the current directory and its
4590 subdirectories, use "--include .".
4590 subdirectories, use "--include .".
4591
4591
4592 If no patterns are given to match, this command prints the names
4592 If no patterns are given to match, this command prints the names
4593 of all files under Mercurial control in the working directory.
4593 of all files under Mercurial control in the working directory.
4594
4594
4595 If you want to feed the output of this command into the "xargs"
4595 If you want to feed the output of this command into the "xargs"
4596 command, use the -0 option to both this command and "xargs". This
4596 command, use the -0 option to both this command and "xargs". This
4597 will avoid the problem of "xargs" treating single filenames that
4597 will avoid the problem of "xargs" treating single filenames that
4598 contain whitespace as multiple filenames.
4598 contain whitespace as multiple filenames.
4599
4599
4600 See :hg:`help files` for a more versatile command.
4600 See :hg:`help files` for a more versatile command.
4601
4601
4602 Returns 0 if a match is found, 1 otherwise.
4602 Returns 0 if a match is found, 1 otherwise.
4603 """
4603 """
4604 if opts.get('print0'):
4604 if opts.get('print0'):
4605 end = '\0'
4605 end = '\0'
4606 else:
4606 else:
4607 end = '\n'
4607 end = '\n'
4608 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4608 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4609
4609
4610 ret = 1
4610 ret = 1
4611 ctx = repo[rev]
4611 ctx = repo[rev]
4612 m = scmutil.match(ctx, pats, opts, default='relglob',
4612 m = scmutil.match(ctx, pats, opts, default='relglob',
4613 badfn=lambda x, y: False)
4613 badfn=lambda x, y: False)
4614
4614
4615 for abs in ctx.matches(m):
4615 for abs in ctx.matches(m):
4616 if opts.get('fullpath'):
4616 if opts.get('fullpath'):
4617 ui.write(repo.wjoin(abs), end)
4617 ui.write(repo.wjoin(abs), end)
4618 else:
4618 else:
4619 ui.write(((pats and m.rel(abs)) or abs), end)
4619 ui.write(((pats and m.rel(abs)) or abs), end)
4620 ret = 0
4620 ret = 0
4621
4621
4622 return ret
4622 return ret
4623
4623
4624 @command('^log|history',
4624 @command('^log|history',
4625 [('f', 'follow', None,
4625 [('f', 'follow', None,
4626 _('follow changeset history, or file history across copies and renames')),
4626 _('follow changeset history, or file history across copies and renames')),
4627 ('', 'follow-first', None,
4627 ('', 'follow-first', None,
4628 _('only follow the first parent of merge changesets (DEPRECATED)')),
4628 _('only follow the first parent of merge changesets (DEPRECATED)')),
4629 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4629 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4630 ('C', 'copies', None, _('show copied files')),
4630 ('C', 'copies', None, _('show copied files')),
4631 ('k', 'keyword', [],
4631 ('k', 'keyword', [],
4632 _('do case-insensitive search for a given text'), _('TEXT')),
4632 _('do case-insensitive search for a given text'), _('TEXT')),
4633 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4633 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4634 ('', 'removed', None, _('include revisions where files were removed')),
4634 ('', 'removed', None, _('include revisions where files were removed')),
4635 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4635 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4636 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4636 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4637 ('', 'only-branch', [],
4637 ('', 'only-branch', [],
4638 _('show only changesets within the given named branch (DEPRECATED)'),
4638 _('show only changesets within the given named branch (DEPRECATED)'),
4639 _('BRANCH')),
4639 _('BRANCH')),
4640 ('b', 'branch', [],
4640 ('b', 'branch', [],
4641 _('show changesets within the given named branch'), _('BRANCH')),
4641 _('show changesets within the given named branch'), _('BRANCH')),
4642 ('P', 'prune', [],
4642 ('P', 'prune', [],
4643 _('do not display revision or any of its ancestors'), _('REV')),
4643 _('do not display revision or any of its ancestors'), _('REV')),
4644 ] + logopts + walkopts,
4644 ] + logopts + walkopts,
4645 _('[OPTION]... [FILE]'),
4645 _('[OPTION]... [FILE]'),
4646 inferrepo=True)
4646 inferrepo=True)
4647 def log(ui, repo, *pats, **opts):
4647 def log(ui, repo, *pats, **opts):
4648 """show revision history of entire repository or files
4648 """show revision history of entire repository or files
4649
4649
4650 Print the revision history of the specified files or the entire
4650 Print the revision history of the specified files or the entire
4651 project.
4651 project.
4652
4652
4653 If no revision range is specified, the default is ``tip:0`` unless
4653 If no revision range is specified, the default is ``tip:0`` unless
4654 --follow is set, in which case the working directory parent is
4654 --follow is set, in which case the working directory parent is
4655 used as the starting revision.
4655 used as the starting revision.
4656
4656
4657 File history is shown without following rename or copy history of
4657 File history is shown without following rename or copy history of
4658 files. Use -f/--follow with a filename to follow history across
4658 files. Use -f/--follow with a filename to follow history across
4659 renames and copies. --follow without a filename will only show
4659 renames and copies. --follow without a filename will only show
4660 ancestors or descendants of the starting revision.
4660 ancestors or descendants of the starting revision.
4661
4661
4662 By default this command prints revision number and changeset id,
4662 By default this command prints revision number and changeset id,
4663 tags, non-trivial parents, user, date and time, and a summary for
4663 tags, non-trivial parents, user, date and time, and a summary for
4664 each commit. When the -v/--verbose switch is used, the list of
4664 each commit. When the -v/--verbose switch is used, the list of
4665 changed files and full commit message are shown.
4665 changed files and full commit message are shown.
4666
4666
4667 With --graph the revisions are shown as an ASCII art DAG with the most
4667 With --graph the revisions are shown as an ASCII art DAG with the most
4668 recent changeset at the top.
4668 recent changeset at the top.
4669 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4669 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4670 and '+' represents a fork where the changeset from the lines below is a
4670 and '+' represents a fork where the changeset from the lines below is a
4671 parent of the 'o' merge on the same line.
4671 parent of the 'o' merge on the same line.
4672
4672
4673 .. note::
4673 .. note::
4674
4674
4675 log -p/--patch may generate unexpected diff output for merge
4675 log -p/--patch may generate unexpected diff output for merge
4676 changesets, as it will only compare the merge changeset against
4676 changesets, as it will only compare the merge changeset against
4677 its first parent. Also, only files different from BOTH parents
4677 its first parent. Also, only files different from BOTH parents
4678 will appear in files:.
4678 will appear in files:.
4679
4679
4680 .. note::
4680 .. note::
4681
4681
4682 for performance reasons, log FILE may omit duplicate changes
4682 for performance reasons, log FILE may omit duplicate changes
4683 made on branches and will not show removals or mode changes. To
4683 made on branches and will not show removals or mode changes. To
4684 see all such changes, use the --removed switch.
4684 see all such changes, use the --removed switch.
4685
4685
4686 .. container:: verbose
4686 .. container:: verbose
4687
4687
4688 Some examples:
4688 Some examples:
4689
4689
4690 - changesets with full descriptions and file lists::
4690 - changesets with full descriptions and file lists::
4691
4691
4692 hg log -v
4692 hg log -v
4693
4693
4694 - changesets ancestral to the working directory::
4694 - changesets ancestral to the working directory::
4695
4695
4696 hg log -f
4696 hg log -f
4697
4697
4698 - last 10 commits on the current branch::
4698 - last 10 commits on the current branch::
4699
4699
4700 hg log -l 10 -b .
4700 hg log -l 10 -b .
4701
4701
4702 - changesets showing all modifications of a file, including removals::
4702 - changesets showing all modifications of a file, including removals::
4703
4703
4704 hg log --removed file.c
4704 hg log --removed file.c
4705
4705
4706 - all changesets that touch a directory, with diffs, excluding merges::
4706 - all changesets that touch a directory, with diffs, excluding merges::
4707
4707
4708 hg log -Mp lib/
4708 hg log -Mp lib/
4709
4709
4710 - all revision numbers that match a keyword::
4710 - all revision numbers that match a keyword::
4711
4711
4712 hg log -k bug --template "{rev}\\n"
4712 hg log -k bug --template "{rev}\\n"
4713
4713
4714 - list available log templates::
4714 - list available log templates::
4715
4715
4716 hg log -T list
4716 hg log -T list
4717
4717
4718 - check if a given changeset is included in a tagged release::
4718 - check if a given changeset is included in a tagged release::
4719
4719
4720 hg log -r "a21ccf and ancestor(1.9)"
4720 hg log -r "a21ccf and ancestor(1.9)"
4721
4721
4722 - find all changesets by some user in a date range::
4722 - find all changesets by some user in a date range::
4723
4723
4724 hg log -k alice -d "may 2008 to jul 2008"
4724 hg log -k alice -d "may 2008 to jul 2008"
4725
4725
4726 - summary of all changesets after the last tag::
4726 - summary of all changesets after the last tag::
4727
4727
4728 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4728 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4729
4729
4730 See :hg:`help dates` for a list of formats valid for -d/--date.
4730 See :hg:`help dates` for a list of formats valid for -d/--date.
4731
4731
4732 See :hg:`help revisions` and :hg:`help revsets` for more about
4732 See :hg:`help revisions` and :hg:`help revsets` for more about
4733 specifying revisions.
4733 specifying revisions.
4734
4734
4735 See :hg:`help templates` for more about pre-packaged styles and
4735 See :hg:`help templates` for more about pre-packaged styles and
4736 specifying custom templates.
4736 specifying custom templates.
4737
4737
4738 Returns 0 on success.
4738 Returns 0 on success.
4739
4739
4740 """
4740 """
4741 if opts.get('follow') and opts.get('rev'):
4741 if opts.get('follow') and opts.get('rev'):
4742 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4742 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4743 del opts['follow']
4743 del opts['follow']
4744
4744
4745 if opts.get('graph'):
4745 if opts.get('graph'):
4746 return cmdutil.graphlog(ui, repo, *pats, **opts)
4746 return cmdutil.graphlog(ui, repo, *pats, **opts)
4747
4747
4748 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4748 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4749 limit = cmdutil.loglimit(opts)
4749 limit = cmdutil.loglimit(opts)
4750 count = 0
4750 count = 0
4751
4751
4752 getrenamed = None
4752 getrenamed = None
4753 if opts.get('copies'):
4753 if opts.get('copies'):
4754 endrev = None
4754 endrev = None
4755 if opts.get('rev'):
4755 if opts.get('rev'):
4756 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4756 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4757 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4757 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4758
4758
4759 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4759 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4760 for rev in revs:
4760 for rev in revs:
4761 if count == limit:
4761 if count == limit:
4762 break
4762 break
4763 ctx = repo[rev]
4763 ctx = repo[rev]
4764 copies = None
4764 copies = None
4765 if getrenamed is not None and rev:
4765 if getrenamed is not None and rev:
4766 copies = []
4766 copies = []
4767 for fn in ctx.files():
4767 for fn in ctx.files():
4768 rename = getrenamed(fn, rev)
4768 rename = getrenamed(fn, rev)
4769 if rename:
4769 if rename:
4770 copies.append((fn, rename[0]))
4770 copies.append((fn, rename[0]))
4771 if filematcher:
4771 if filematcher:
4772 revmatchfn = filematcher(ctx.rev())
4772 revmatchfn = filematcher(ctx.rev())
4773 else:
4773 else:
4774 revmatchfn = None
4774 revmatchfn = None
4775 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4775 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4776 if displayer.flush(ctx):
4776 if displayer.flush(ctx):
4777 count += 1
4777 count += 1
4778
4778
4779 displayer.close()
4779 displayer.close()
4780
4780
4781 @command('manifest',
4781 @command('manifest',
4782 [('r', 'rev', '', _('revision to display'), _('REV')),
4782 [('r', 'rev', '', _('revision to display'), _('REV')),
4783 ('', 'all', False, _("list files from all revisions"))]
4783 ('', 'all', False, _("list files from all revisions"))]
4784 + formatteropts,
4784 + formatteropts,
4785 _('[-r REV]'))
4785 _('[-r REV]'))
4786 def manifest(ui, repo, node=None, rev=None, **opts):
4786 def manifest(ui, repo, node=None, rev=None, **opts):
4787 """output the current or given revision of the project manifest
4787 """output the current or given revision of the project manifest
4788
4788
4789 Print a list of version controlled files for the given revision.
4789 Print a list of version controlled files for the given revision.
4790 If no revision is given, the first parent of the working directory
4790 If no revision is given, the first parent of the working directory
4791 is used, or the null revision if no revision is checked out.
4791 is used, or the null revision if no revision is checked out.
4792
4792
4793 With -v, print file permissions, symlink and executable bits.
4793 With -v, print file permissions, symlink and executable bits.
4794 With --debug, print file revision hashes.
4794 With --debug, print file revision hashes.
4795
4795
4796 If option --all is specified, the list of all files from all revisions
4796 If option --all is specified, the list of all files from all revisions
4797 is printed. This includes deleted and renamed files.
4797 is printed. This includes deleted and renamed files.
4798
4798
4799 Returns 0 on success.
4799 Returns 0 on success.
4800 """
4800 """
4801
4801
4802 fm = ui.formatter('manifest', opts)
4802 fm = ui.formatter('manifest', opts)
4803
4803
4804 if opts.get('all'):
4804 if opts.get('all'):
4805 if rev or node:
4805 if rev or node:
4806 raise util.Abort(_("can't specify a revision with --all"))
4806 raise util.Abort(_("can't specify a revision with --all"))
4807
4807
4808 res = []
4808 res = []
4809 prefix = "data/"
4809 prefix = "data/"
4810 suffix = ".i"
4810 suffix = ".i"
4811 plen = len(prefix)
4811 plen = len(prefix)
4812 slen = len(suffix)
4812 slen = len(suffix)
4813 lock = repo.lock()
4813 lock = repo.lock()
4814 try:
4814 try:
4815 for fn, b, size in repo.store.datafiles():
4815 for fn, b, size in repo.store.datafiles():
4816 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4816 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4817 res.append(fn[plen:-slen])
4817 res.append(fn[plen:-slen])
4818 finally:
4818 finally:
4819 lock.release()
4819 lock.release()
4820 for f in res:
4820 for f in res:
4821 fm.startitem()
4821 fm.startitem()
4822 fm.write("path", '%s\n', f)
4822 fm.write("path", '%s\n', f)
4823 fm.end()
4823 fm.end()
4824 return
4824 return
4825
4825
4826 if rev and node:
4826 if rev and node:
4827 raise util.Abort(_("please specify just one revision"))
4827 raise util.Abort(_("please specify just one revision"))
4828
4828
4829 if not node:
4829 if not node:
4830 node = rev
4830 node = rev
4831
4831
4832 char = {'l': '@', 'x': '*', '': ''}
4832 char = {'l': '@', 'x': '*', '': ''}
4833 mode = {'l': '644', 'x': '755', '': '644'}
4833 mode = {'l': '644', 'x': '755', '': '644'}
4834 ctx = scmutil.revsingle(repo, node)
4834 ctx = scmutil.revsingle(repo, node)
4835 mf = ctx.manifest()
4835 mf = ctx.manifest()
4836 for f in ctx:
4836 for f in ctx:
4837 fm.startitem()
4837 fm.startitem()
4838 fl = ctx[f].flags()
4838 fl = ctx[f].flags()
4839 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4839 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4840 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4840 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4841 fm.write('path', '%s\n', f)
4841 fm.write('path', '%s\n', f)
4842 fm.end()
4842 fm.end()
4843
4843
4844 @command('^merge',
4844 @command('^merge',
4845 [('f', 'force', None,
4845 [('f', 'force', None,
4846 _('force a merge including outstanding changes (DEPRECATED)')),
4846 _('force a merge including outstanding changes (DEPRECATED)')),
4847 ('r', 'rev', '', _('revision to merge'), _('REV')),
4847 ('r', 'rev', '', _('revision to merge'), _('REV')),
4848 ('P', 'preview', None,
4848 ('P', 'preview', None,
4849 _('review revisions to merge (no merge is performed)'))
4849 _('review revisions to merge (no merge is performed)'))
4850 ] + mergetoolopts,
4850 ] + mergetoolopts,
4851 _('[-P] [-f] [[-r] REV]'))
4851 _('[-P] [-f] [[-r] REV]'))
4852 def merge(ui, repo, node=None, **opts):
4852 def merge(ui, repo, node=None, **opts):
4853 """merge another revision into working directory
4853 """merge another revision into working directory
4854
4854
4855 The current working directory is updated with all changes made in
4855 The current working directory is updated with all changes made in
4856 the requested revision since the last common predecessor revision.
4856 the requested revision since the last common predecessor revision.
4857
4857
4858 Files that changed between either parent are marked as changed for
4858 Files that changed between either parent are marked as changed for
4859 the next commit and a commit must be performed before any further
4859 the next commit and a commit must be performed before any further
4860 updates to the repository are allowed. The next commit will have
4860 updates to the repository are allowed. The next commit will have
4861 two parents.
4861 two parents.
4862
4862
4863 ``--tool`` can be used to specify the merge tool used for file
4863 ``--tool`` can be used to specify the merge tool used for file
4864 merges. It overrides the HGMERGE environment variable and your
4864 merges. It overrides the HGMERGE environment variable and your
4865 configuration files. See :hg:`help merge-tools` for options.
4865 configuration files. See :hg:`help merge-tools` for options.
4866
4866
4867 If no revision is specified, the working directory's parent is a
4867 If no revision is specified, the working directory's parent is a
4868 head revision, and the current branch contains exactly one other
4868 head revision, and the current branch contains exactly one other
4869 head, the other head is merged with by default. Otherwise, an
4869 head, the other head is merged with by default. Otherwise, an
4870 explicit revision with which to merge with must be provided.
4870 explicit revision with which to merge with must be provided.
4871
4871
4872 :hg:`resolve` must be used to resolve unresolved files.
4872 :hg:`resolve` must be used to resolve unresolved files.
4873
4873
4874 To undo an uncommitted merge, use :hg:`update --clean .` which
4874 To undo an uncommitted merge, use :hg:`update --clean .` which
4875 will check out a clean copy of the original merge parent, losing
4875 will check out a clean copy of the original merge parent, losing
4876 all changes.
4876 all changes.
4877
4877
4878 Returns 0 on success, 1 if there are unresolved files.
4878 Returns 0 on success, 1 if there are unresolved files.
4879 """
4879 """
4880
4880
4881 if opts.get('rev') and node:
4881 if opts.get('rev') and node:
4882 raise util.Abort(_("please specify just one revision"))
4882 raise util.Abort(_("please specify just one revision"))
4883 if not node:
4883 if not node:
4884 node = opts.get('rev')
4884 node = opts.get('rev')
4885
4885
4886 if node:
4886 if node:
4887 node = scmutil.revsingle(repo, node).node()
4887 node = scmutil.revsingle(repo, node).node()
4888
4888
4889 if not node:
4889 if not node:
4890 node = scmutil.revsingle(repo, '_mergedefaultdest()').node()
4890 node = scmutil.revsingle(repo, '_mergedefaultdest()').node()
4891
4891
4892 if opts.get('preview'):
4892 if opts.get('preview'):
4893 # find nodes that are ancestors of p2 but not of p1
4893 # find nodes that are ancestors of p2 but not of p1
4894 p1 = repo.lookup('.')
4894 p1 = repo.lookup('.')
4895 p2 = repo.lookup(node)
4895 p2 = repo.lookup(node)
4896 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4896 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4897
4897
4898 displayer = cmdutil.show_changeset(ui, repo, opts)
4898 displayer = cmdutil.show_changeset(ui, repo, opts)
4899 for node in nodes:
4899 for node in nodes:
4900 displayer.show(repo[node])
4900 displayer.show(repo[node])
4901 displayer.close()
4901 displayer.close()
4902 return 0
4902 return 0
4903
4903
4904 try:
4904 try:
4905 # ui.forcemerge is an internal variable, do not document
4905 # ui.forcemerge is an internal variable, do not document
4906 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4906 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4907 return hg.merge(repo, node, force=opts.get('force'))
4907 return hg.merge(repo, node, force=opts.get('force'))
4908 finally:
4908 finally:
4909 ui.setconfig('ui', 'forcemerge', '', 'merge')
4909 ui.setconfig('ui', 'forcemerge', '', 'merge')
4910
4910
4911 @command('outgoing|out',
4911 @command('outgoing|out',
4912 [('f', 'force', None, _('run even when the destination is unrelated')),
4912 [('f', 'force', None, _('run even when the destination is unrelated')),
4913 ('r', 'rev', [],
4913 ('r', 'rev', [],
4914 _('a changeset intended to be included in the destination'), _('REV')),
4914 _('a changeset intended to be included in the destination'), _('REV')),
4915 ('n', 'newest-first', None, _('show newest record first')),
4915 ('n', 'newest-first', None, _('show newest record first')),
4916 ('B', 'bookmarks', False, _('compare bookmarks')),
4916 ('B', 'bookmarks', False, _('compare bookmarks')),
4917 ('b', 'branch', [], _('a specific branch you would like to push'),
4917 ('b', 'branch', [], _('a specific branch you would like to push'),
4918 _('BRANCH')),
4918 _('BRANCH')),
4919 ] + logopts + remoteopts + subrepoopts,
4919 ] + logopts + remoteopts + subrepoopts,
4920 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4920 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4921 def outgoing(ui, repo, dest=None, **opts):
4921 def outgoing(ui, repo, dest=None, **opts):
4922 """show changesets not found in the destination
4922 """show changesets not found in the destination
4923
4923
4924 Show changesets not found in the specified destination repository
4924 Show changesets not found in the specified destination repository
4925 or the default push location. These are the changesets that would
4925 or the default push location. These are the changesets that would
4926 be pushed if a push was requested.
4926 be pushed if a push was requested.
4927
4927
4928 See pull for details of valid destination formats.
4928 See pull for details of valid destination formats.
4929
4929
4930 .. container:: verbose
4930 .. container:: verbose
4931
4931
4932 With -B/--bookmarks, the result of bookmark comparison between
4932 With -B/--bookmarks, the result of bookmark comparison between
4933 local and remote repositories is displayed. With -v/--verbose,
4933 local and remote repositories is displayed. With -v/--verbose,
4934 status is also displayed for each bookmark like below::
4934 status is also displayed for each bookmark like below::
4935
4935
4936 BM1 01234567890a added
4936 BM1 01234567890a added
4937 BM2 deleted
4937 BM2 deleted
4938 BM3 234567890abc advanced
4938 BM3 234567890abc advanced
4939 BM4 34567890abcd diverged
4939 BM4 34567890abcd diverged
4940 BM5 4567890abcde changed
4940 BM5 4567890abcde changed
4941
4941
4942 The action taken when pushing depends on the
4942 The action taken when pushing depends on the
4943 status of each bookmark:
4943 status of each bookmark:
4944
4944
4945 :``added``: push with ``-B`` will create it
4945 :``added``: push with ``-B`` will create it
4946 :``deleted``: push with ``-B`` will delete it
4946 :``deleted``: push with ``-B`` will delete it
4947 :``advanced``: push will update it
4947 :``advanced``: push will update it
4948 :``diverged``: push with ``-B`` will update it
4948 :``diverged``: push with ``-B`` will update it
4949 :``changed``: push with ``-B`` will update it
4949 :``changed``: push with ``-B`` will update it
4950
4950
4951 From the point of view of pushing behavior, bookmarks
4951 From the point of view of pushing behavior, bookmarks
4952 existing only in the remote repository are treated as
4952 existing only in the remote repository are treated as
4953 ``deleted``, even if it is in fact added remotely.
4953 ``deleted``, even if it is in fact added remotely.
4954
4954
4955 Returns 0 if there are outgoing changes, 1 otherwise.
4955 Returns 0 if there are outgoing changes, 1 otherwise.
4956 """
4956 """
4957 if opts.get('graph'):
4957 if opts.get('graph'):
4958 cmdutil.checkunsupportedgraphflags([], opts)
4958 cmdutil.checkunsupportedgraphflags([], opts)
4959 o, other = hg._outgoing(ui, repo, dest, opts)
4959 o, other = hg._outgoing(ui, repo, dest, opts)
4960 if not o:
4960 if not o:
4961 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4961 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4962 return
4962 return
4963
4963
4964 revdag = cmdutil.graphrevs(repo, o, opts)
4964 revdag = cmdutil.graphrevs(repo, o, opts)
4965 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4965 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4966 showparents = [ctx.node() for ctx in repo[None].parents()]
4966 showparents = [ctx.node() for ctx in repo[None].parents()]
4967 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4967 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4968 graphmod.asciiedges)
4968 graphmod.asciiedges)
4969 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4969 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4970 return 0
4970 return 0
4971
4971
4972 if opts.get('bookmarks'):
4972 if opts.get('bookmarks'):
4973 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4973 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4974 dest, branches = hg.parseurl(dest, opts.get('branch'))
4974 dest, branches = hg.parseurl(dest, opts.get('branch'))
4975 other = hg.peer(repo, opts, dest)
4975 other = hg.peer(repo, opts, dest)
4976 if 'bookmarks' not in other.listkeys('namespaces'):
4976 if 'bookmarks' not in other.listkeys('namespaces'):
4977 ui.warn(_("remote doesn't support bookmarks\n"))
4977 ui.warn(_("remote doesn't support bookmarks\n"))
4978 return 0
4978 return 0
4979 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4979 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4980 return bookmarks.outgoing(ui, repo, other)
4980 return bookmarks.outgoing(ui, repo, other)
4981
4981
4982 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4982 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4983 try:
4983 try:
4984 return hg.outgoing(ui, repo, dest, opts)
4984 return hg.outgoing(ui, repo, dest, opts)
4985 finally:
4985 finally:
4986 del repo._subtoppath
4986 del repo._subtoppath
4987
4987
4988 @command('parents',
4988 @command('parents',
4989 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4989 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4990 ] + templateopts,
4990 ] + templateopts,
4991 _('[-r REV] [FILE]'),
4991 _('[-r REV] [FILE]'),
4992 inferrepo=True)
4992 inferrepo=True)
4993 def parents(ui, repo, file_=None, **opts):
4993 def parents(ui, repo, file_=None, **opts):
4994 """show the parents of the working directory or revision (DEPRECATED)
4994 """show the parents of the working directory or revision (DEPRECATED)
4995
4995
4996 Print the working directory's parent revisions. If a revision is
4996 Print the working directory's parent revisions. If a revision is
4997 given via -r/--rev, the parent of that revision will be printed.
4997 given via -r/--rev, the parent of that revision will be printed.
4998 If a file argument is given, the revision in which the file was
4998 If a file argument is given, the revision in which the file was
4999 last changed (before the working directory revision or the
4999 last changed (before the working directory revision or the
5000 argument to --rev if given) is printed.
5000 argument to --rev if given) is printed.
5001
5001
5002 See :hg:`summary` and :hg:`help revsets` for related information.
5002 See :hg:`summary` and :hg:`help revsets` for related information.
5003
5003
5004 Returns 0 on success.
5004 Returns 0 on success.
5005 """
5005 """
5006
5006
5007 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5007 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5008
5008
5009 if file_:
5009 if file_:
5010 m = scmutil.match(ctx, (file_,), opts)
5010 m = scmutil.match(ctx, (file_,), opts)
5011 if m.anypats() or len(m.files()) != 1:
5011 if m.anypats() or len(m.files()) != 1:
5012 raise util.Abort(_('can only specify an explicit filename'))
5012 raise util.Abort(_('can only specify an explicit filename'))
5013 file_ = m.files()[0]
5013 file_ = m.files()[0]
5014 filenodes = []
5014 filenodes = []
5015 for cp in ctx.parents():
5015 for cp in ctx.parents():
5016 if not cp:
5016 if not cp:
5017 continue
5017 continue
5018 try:
5018 try:
5019 filenodes.append(cp.filenode(file_))
5019 filenodes.append(cp.filenode(file_))
5020 except error.LookupError:
5020 except error.LookupError:
5021 pass
5021 pass
5022 if not filenodes:
5022 if not filenodes:
5023 raise util.Abort(_("'%s' not found in manifest!") % file_)
5023 raise util.Abort(_("'%s' not found in manifest!") % file_)
5024 p = []
5024 p = []
5025 for fn in filenodes:
5025 for fn in filenodes:
5026 fctx = repo.filectx(file_, fileid=fn)
5026 fctx = repo.filectx(file_, fileid=fn)
5027 p.append(fctx.node())
5027 p.append(fctx.node())
5028 else:
5028 else:
5029 p = [cp.node() for cp in ctx.parents()]
5029 p = [cp.node() for cp in ctx.parents()]
5030
5030
5031 displayer = cmdutil.show_changeset(ui, repo, opts)
5031 displayer = cmdutil.show_changeset(ui, repo, opts)
5032 for n in p:
5032 for n in p:
5033 if n != nullid:
5033 if n != nullid:
5034 displayer.show(repo[n])
5034 displayer.show(repo[n])
5035 displayer.close()
5035 displayer.close()
5036
5036
5037 @command('paths', [], _('[NAME]'), optionalrepo=True)
5037 @command('paths', [], _('[NAME]'), optionalrepo=True)
5038 def paths(ui, repo, search=None):
5038 def paths(ui, repo, search=None):
5039 """show aliases for remote repositories
5039 """show aliases for remote repositories
5040
5040
5041 Show definition of symbolic path name NAME. If no name is given,
5041 Show definition of symbolic path name NAME. If no name is given,
5042 show definition of all available names.
5042 show definition of all available names.
5043
5043
5044 Option -q/--quiet suppresses all output when searching for NAME
5044 Option -q/--quiet suppresses all output when searching for NAME
5045 and shows only the path names when listing all definitions.
5045 and shows only the path names when listing all definitions.
5046
5046
5047 Path names are defined in the [paths] section of your
5047 Path names are defined in the [paths] section of your
5048 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5048 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5049 repository, ``.hg/hgrc`` is used, too.
5049 repository, ``.hg/hgrc`` is used, too.
5050
5050
5051 The path names ``default`` and ``default-push`` have a special
5051 The path names ``default`` and ``default-push`` have a special
5052 meaning. When performing a push or pull operation, they are used
5052 meaning. When performing a push or pull operation, they are used
5053 as fallbacks if no location is specified on the command-line.
5053 as fallbacks if no location is specified on the command-line.
5054 When ``default-push`` is set, it will be used for push and
5054 When ``default-push`` is set, it will be used for push and
5055 ``default`` will be used for pull; otherwise ``default`` is used
5055 ``default`` will be used for pull; otherwise ``default`` is used
5056 as the fallback for both. When cloning a repository, the clone
5056 as the fallback for both. When cloning a repository, the clone
5057 source is written as ``default`` in ``.hg/hgrc``. Note that
5057 source is written as ``default`` in ``.hg/hgrc``. Note that
5058 ``default`` and ``default-push`` apply to all inbound (e.g.
5058 ``default`` and ``default-push`` apply to all inbound (e.g.
5059 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5059 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5060 :hg:`bundle`) operations.
5060 :hg:`bundle`) operations.
5061
5061
5062 See :hg:`help urls` for more information.
5062 See :hg:`help urls` for more information.
5063
5063
5064 Returns 0 on success.
5064 Returns 0 on success.
5065 """
5065 """
5066 if search:
5066 if search:
5067 for name, path in sorted(ui.paths.iteritems()):
5067 for name, path in sorted(ui.paths.iteritems()):
5068 if name == search:
5068 if name == search:
5069 ui.status("%s\n" % util.hidepassword(path.loc))
5069 ui.status("%s\n" % util.hidepassword(path.loc))
5070 return
5070 return
5071 if not ui.quiet:
5071 if not ui.quiet:
5072 ui.warn(_("not found!\n"))
5072 ui.warn(_("not found!\n"))
5073 return 1
5073 return 1
5074 else:
5074 else:
5075 for name, path in sorted(ui.paths.iteritems()):
5075 for name, path in sorted(ui.paths.iteritems()):
5076 if ui.quiet:
5076 if ui.quiet:
5077 ui.write("%s\n" % name)
5077 ui.write("%s\n" % name)
5078 else:
5078 else:
5079 ui.write("%s = %s\n" % (name,
5079 ui.write("%s = %s\n" % (name,
5080 util.hidepassword(path.loc)))
5080 util.hidepassword(path.loc)))
5081
5081
5082 @command('phase',
5082 @command('phase',
5083 [('p', 'public', False, _('set changeset phase to public')),
5083 [('p', 'public', False, _('set changeset phase to public')),
5084 ('d', 'draft', False, _('set changeset phase to draft')),
5084 ('d', 'draft', False, _('set changeset phase to draft')),
5085 ('s', 'secret', False, _('set changeset phase to secret')),
5085 ('s', 'secret', False, _('set changeset phase to secret')),
5086 ('f', 'force', False, _('allow to move boundary backward')),
5086 ('f', 'force', False, _('allow to move boundary backward')),
5087 ('r', 'rev', [], _('target revision'), _('REV')),
5087 ('r', 'rev', [], _('target revision'), _('REV')),
5088 ],
5088 ],
5089 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5089 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5090 def phase(ui, repo, *revs, **opts):
5090 def phase(ui, repo, *revs, **opts):
5091 """set or show the current phase name
5091 """set or show the current phase name
5092
5092
5093 With no argument, show the phase name of the current revision(s).
5093 With no argument, show the phase name of the current revision(s).
5094
5094
5095 With one of -p/--public, -d/--draft or -s/--secret, change the
5095 With one of -p/--public, -d/--draft or -s/--secret, change the
5096 phase value of the specified revisions.
5096 phase value of the specified revisions.
5097
5097
5098 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5098 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5099 lower phase to an higher phase. Phases are ordered as follows::
5099 lower phase to an higher phase. Phases are ordered as follows::
5100
5100
5101 public < draft < secret
5101 public < draft < secret
5102
5102
5103 Returns 0 on success, 1 if some phases could not be changed.
5103 Returns 0 on success, 1 if some phases could not be changed.
5104
5104
5105 (For more information about the phases concept, see :hg:`help phases`.)
5105 (For more information about the phases concept, see :hg:`help phases`.)
5106 """
5106 """
5107 # search for a unique phase argument
5107 # search for a unique phase argument
5108 targetphase = None
5108 targetphase = None
5109 for idx, name in enumerate(phases.phasenames):
5109 for idx, name in enumerate(phases.phasenames):
5110 if opts[name]:
5110 if opts[name]:
5111 if targetphase is not None:
5111 if targetphase is not None:
5112 raise util.Abort(_('only one phase can be specified'))
5112 raise util.Abort(_('only one phase can be specified'))
5113 targetphase = idx
5113 targetphase = idx
5114
5114
5115 # look for specified revision
5115 # look for specified revision
5116 revs = list(revs)
5116 revs = list(revs)
5117 revs.extend(opts['rev'])
5117 revs.extend(opts['rev'])
5118 if not revs:
5118 if not revs:
5119 # display both parents as the second parent phase can influence
5119 # display both parents as the second parent phase can influence
5120 # the phase of a merge commit
5120 # the phase of a merge commit
5121 revs = [c.rev() for c in repo[None].parents()]
5121 revs = [c.rev() for c in repo[None].parents()]
5122
5122
5123 revs = scmutil.revrange(repo, revs)
5123 revs = scmutil.revrange(repo, revs)
5124
5124
5125 lock = None
5125 lock = None
5126 ret = 0
5126 ret = 0
5127 if targetphase is None:
5127 if targetphase is None:
5128 # display
5128 # display
5129 for r in revs:
5129 for r in revs:
5130 ctx = repo[r]
5130 ctx = repo[r]
5131 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5131 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5132 else:
5132 else:
5133 tr = None
5133 tr = None
5134 lock = repo.lock()
5134 lock = repo.lock()
5135 try:
5135 try:
5136 tr = repo.transaction("phase")
5136 tr = repo.transaction("phase")
5137 # set phase
5137 # set phase
5138 if not revs:
5138 if not revs:
5139 raise util.Abort(_('empty revision set'))
5139 raise util.Abort(_('empty revision set'))
5140 nodes = [repo[r].node() for r in revs]
5140 nodes = [repo[r].node() for r in revs]
5141 # moving revision from public to draft may hide them
5141 # moving revision from public to draft may hide them
5142 # We have to check result on an unfiltered repository
5142 # We have to check result on an unfiltered repository
5143 unfi = repo.unfiltered()
5143 unfi = repo.unfiltered()
5144 getphase = unfi._phasecache.phase
5144 getphase = unfi._phasecache.phase
5145 olddata = [getphase(unfi, r) for r in unfi]
5145 olddata = [getphase(unfi, r) for r in unfi]
5146 phases.advanceboundary(repo, tr, targetphase, nodes)
5146 phases.advanceboundary(repo, tr, targetphase, nodes)
5147 if opts['force']:
5147 if opts['force']:
5148 phases.retractboundary(repo, tr, targetphase, nodes)
5148 phases.retractboundary(repo, tr, targetphase, nodes)
5149 tr.close()
5149 tr.close()
5150 finally:
5150 finally:
5151 if tr is not None:
5151 if tr is not None:
5152 tr.release()
5152 tr.release()
5153 lock.release()
5153 lock.release()
5154 getphase = unfi._phasecache.phase
5154 getphase = unfi._phasecache.phase
5155 newdata = [getphase(unfi, r) for r in unfi]
5155 newdata = [getphase(unfi, r) for r in unfi]
5156 changes = sum(newdata[r] != olddata[r] for r in unfi)
5156 changes = sum(newdata[r] != olddata[r] for r in unfi)
5157 cl = unfi.changelog
5157 cl = unfi.changelog
5158 rejected = [n for n in nodes
5158 rejected = [n for n in nodes
5159 if newdata[cl.rev(n)] < targetphase]
5159 if newdata[cl.rev(n)] < targetphase]
5160 if rejected:
5160 if rejected:
5161 ui.warn(_('cannot move %i changesets to a higher '
5161 ui.warn(_('cannot move %i changesets to a higher '
5162 'phase, use --force\n') % len(rejected))
5162 'phase, use --force\n') % len(rejected))
5163 ret = 1
5163 ret = 1
5164 if changes:
5164 if changes:
5165 msg = _('phase changed for %i changesets\n') % changes
5165 msg = _('phase changed for %i changesets\n') % changes
5166 if ret:
5166 if ret:
5167 ui.status(msg)
5167 ui.status(msg)
5168 else:
5168 else:
5169 ui.note(msg)
5169 ui.note(msg)
5170 else:
5170 else:
5171 ui.warn(_('no phases changed\n'))
5171 ui.warn(_('no phases changed\n'))
5172 return ret
5172 return ret
5173
5173
5174 def postincoming(ui, repo, modheads, optupdate, checkout):
5174 def postincoming(ui, repo, modheads, optupdate, checkout):
5175 if modheads == 0:
5175 if modheads == 0:
5176 return
5176 return
5177 if optupdate:
5177 if optupdate:
5178 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
5178 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
5179 try:
5179 try:
5180 ret = hg.update(repo, checkout)
5180 ret = hg.update(repo, checkout)
5181 except util.Abort as inst:
5181 except util.Abort as inst:
5182 ui.warn(_("not updating: %s\n") % str(inst))
5182 ui.warn(_("not updating: %s\n") % str(inst))
5183 if inst.hint:
5183 if inst.hint:
5184 ui.warn(_("(%s)\n") % inst.hint)
5184 ui.warn(_("(%s)\n") % inst.hint)
5185 return 0
5185 return 0
5186 if not ret and not checkout:
5186 if not ret and not checkout:
5187 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5187 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5188 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5188 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5189 return ret
5189 return ret
5190 if modheads > 1:
5190 if modheads > 1:
5191 currentbranchheads = len(repo.branchheads())
5191 currentbranchheads = len(repo.branchheads())
5192 if currentbranchheads == modheads:
5192 if currentbranchheads == modheads:
5193 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5193 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5194 elif currentbranchheads > 1:
5194 elif currentbranchheads > 1:
5195 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5195 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5196 "merge)\n"))
5196 "merge)\n"))
5197 else:
5197 else:
5198 ui.status(_("(run 'hg heads' to see heads)\n"))
5198 ui.status(_("(run 'hg heads' to see heads)\n"))
5199 else:
5199 else:
5200 ui.status(_("(run 'hg update' to get a working copy)\n"))
5200 ui.status(_("(run 'hg update' to get a working copy)\n"))
5201
5201
5202 @command('^pull',
5202 @command('^pull',
5203 [('u', 'update', None,
5203 [('u', 'update', None,
5204 _('update to new branch head if changesets were pulled')),
5204 _('update to new branch head if changesets were pulled')),
5205 ('f', 'force', None, _('run even when remote repository is unrelated')),
5205 ('f', 'force', None, _('run even when remote repository is unrelated')),
5206 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5206 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5207 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5207 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5208 ('b', 'branch', [], _('a specific branch you would like to pull'),
5208 ('b', 'branch', [], _('a specific branch you would like to pull'),
5209 _('BRANCH')),
5209 _('BRANCH')),
5210 ] + remoteopts,
5210 ] + remoteopts,
5211 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5211 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5212 def pull(ui, repo, source="default", **opts):
5212 def pull(ui, repo, source="default", **opts):
5213 """pull changes from the specified source
5213 """pull changes from the specified source
5214
5214
5215 Pull changes from a remote repository to a local one.
5215 Pull changes from a remote repository to a local one.
5216
5216
5217 This finds all changes from the repository at the specified path
5217 This finds all changes from the repository at the specified path
5218 or URL and adds them to a local repository (the current one unless
5218 or URL and adds them to a local repository (the current one unless
5219 -R is specified). By default, this does not update the copy of the
5219 -R is specified). By default, this does not update the copy of the
5220 project in the working directory.
5220 project in the working directory.
5221
5221
5222 Use :hg:`incoming` if you want to see what would have been added
5222 Use :hg:`incoming` if you want to see what would have been added
5223 by a pull at the time you issued this command. If you then decide
5223 by a pull at the time you issued this command. If you then decide
5224 to add those changes to the repository, you should use :hg:`pull
5224 to add those changes to the repository, you should use :hg:`pull
5225 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5225 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5226
5226
5227 If SOURCE is omitted, the 'default' path will be used.
5227 If SOURCE is omitted, the 'default' path will be used.
5228 See :hg:`help urls` for more information.
5228 See :hg:`help urls` for more information.
5229
5229
5230 Returns 0 on success, 1 if an update had unresolved files.
5230 Returns 0 on success, 1 if an update had unresolved files.
5231 """
5231 """
5232 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5232 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5233 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5233 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5234 other = hg.peer(repo, opts, source)
5234 other = hg.peer(repo, opts, source)
5235 try:
5235 try:
5236 revs, checkout = hg.addbranchrevs(repo, other, branches,
5236 revs, checkout = hg.addbranchrevs(repo, other, branches,
5237 opts.get('rev'))
5237 opts.get('rev'))
5238
5238
5239
5239
5240 pullopargs = {}
5240 pullopargs = {}
5241 if opts.get('bookmark'):
5241 if opts.get('bookmark'):
5242 if not revs:
5242 if not revs:
5243 revs = []
5243 revs = []
5244 # The list of bookmark used here is not the one used to actually
5244 # The list of bookmark used here is not the one used to actually
5245 # update the bookmark name. This can result in the revision pulled
5245 # update the bookmark name. This can result in the revision pulled
5246 # not ending up with the name of the bookmark because of a race
5246 # not ending up with the name of the bookmark because of a race
5247 # condition on the server. (See issue 4689 for details)
5247 # condition on the server. (See issue 4689 for details)
5248 remotebookmarks = other.listkeys('bookmarks')
5248 remotebookmarks = other.listkeys('bookmarks')
5249 pullopargs['remotebookmarks'] = remotebookmarks
5249 pullopargs['remotebookmarks'] = remotebookmarks
5250 for b in opts['bookmark']:
5250 for b in opts['bookmark']:
5251 if b not in remotebookmarks:
5251 if b not in remotebookmarks:
5252 raise util.Abort(_('remote bookmark %s not found!') % b)
5252 raise util.Abort(_('remote bookmark %s not found!') % b)
5253 revs.append(remotebookmarks[b])
5253 revs.append(remotebookmarks[b])
5254
5254
5255 if revs:
5255 if revs:
5256 try:
5256 try:
5257 # When 'rev' is a bookmark name, we cannot guarantee that it
5257 # When 'rev' is a bookmark name, we cannot guarantee that it
5258 # will be updated with that name because of a race condition
5258 # will be updated with that name because of a race condition
5259 # server side. (See issue 4689 for details)
5259 # server side. (See issue 4689 for details)
5260 oldrevs = revs
5260 oldrevs = revs
5261 revs = [] # actually, nodes
5261 revs = [] # actually, nodes
5262 for r in oldrevs:
5262 for r in oldrevs:
5263 node = other.lookup(r)
5263 node = other.lookup(r)
5264 revs.append(node)
5264 revs.append(node)
5265 if r == checkout:
5265 if r == checkout:
5266 checkout = node
5266 checkout = node
5267 except error.CapabilityError:
5267 except error.CapabilityError:
5268 err = _("other repository doesn't support revision lookup, "
5268 err = _("other repository doesn't support revision lookup, "
5269 "so a rev cannot be specified.")
5269 "so a rev cannot be specified.")
5270 raise util.Abort(err)
5270 raise util.Abort(err)
5271
5271
5272 modheads = exchange.pull(repo, other, heads=revs,
5272 modheads = exchange.pull(repo, other, heads=revs,
5273 force=opts.get('force'),
5273 force=opts.get('force'),
5274 bookmarks=opts.get('bookmark', ()),
5274 bookmarks=opts.get('bookmark', ()),
5275 opargs=pullopargs).cgresult
5275 opargs=pullopargs).cgresult
5276 if checkout:
5276 if checkout:
5277 checkout = str(repo.changelog.rev(checkout))
5277 checkout = str(repo.changelog.rev(checkout))
5278 repo._subtoppath = source
5278 repo._subtoppath = source
5279 try:
5279 try:
5280 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5280 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5281
5281
5282 finally:
5282 finally:
5283 del repo._subtoppath
5283 del repo._subtoppath
5284
5284
5285 finally:
5285 finally:
5286 other.close()
5286 other.close()
5287 return ret
5287 return ret
5288
5288
5289 @command('^push',
5289 @command('^push',
5290 [('f', 'force', None, _('force push')),
5290 [('f', 'force', None, _('force push')),
5291 ('r', 'rev', [],
5291 ('r', 'rev', [],
5292 _('a changeset intended to be included in the destination'),
5292 _('a changeset intended to be included in the destination'),
5293 _('REV')),
5293 _('REV')),
5294 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5294 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5295 ('b', 'branch', [],
5295 ('b', 'branch', [],
5296 _('a specific branch you would like to push'), _('BRANCH')),
5296 _('a specific branch you would like to push'), _('BRANCH')),
5297 ('', 'new-branch', False, _('allow pushing a new branch')),
5297 ('', 'new-branch', False, _('allow pushing a new branch')),
5298 ] + remoteopts,
5298 ] + remoteopts,
5299 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5299 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5300 def push(ui, repo, dest=None, **opts):
5300 def push(ui, repo, dest=None, **opts):
5301 """push changes to the specified destination
5301 """push changes to the specified destination
5302
5302
5303 Push changesets from the local repository to the specified
5303 Push changesets from the local repository to the specified
5304 destination.
5304 destination.
5305
5305
5306 This operation is symmetrical to pull: it is identical to a pull
5306 This operation is symmetrical to pull: it is identical to a pull
5307 in the destination repository from the current one.
5307 in the destination repository from the current one.
5308
5308
5309 By default, push will not allow creation of new heads at the
5309 By default, push will not allow creation of new heads at the
5310 destination, since multiple heads would make it unclear which head
5310 destination, since multiple heads would make it unclear which head
5311 to use. In this situation, it is recommended to pull and merge
5311 to use. In this situation, it is recommended to pull and merge
5312 before pushing.
5312 before pushing.
5313
5313
5314 Use --new-branch if you want to allow push to create a new named
5314 Use --new-branch if you want to allow push to create a new named
5315 branch that is not present at the destination. This allows you to
5315 branch that is not present at the destination. This allows you to
5316 only create a new branch without forcing other changes.
5316 only create a new branch without forcing other changes.
5317
5317
5318 .. note::
5318 .. note::
5319
5319
5320 Extra care should be taken with the -f/--force option,
5320 Extra care should be taken with the -f/--force option,
5321 which will push all new heads on all branches, an action which will
5321 which will push all new heads on all branches, an action which will
5322 almost always cause confusion for collaborators.
5322 almost always cause confusion for collaborators.
5323
5323
5324 If -r/--rev is used, the specified revision and all its ancestors
5324 If -r/--rev is used, the specified revision and all its ancestors
5325 will be pushed to the remote repository.
5325 will be pushed to the remote repository.
5326
5326
5327 If -B/--bookmark is used, the specified bookmarked revision, its
5327 If -B/--bookmark is used, the specified bookmarked revision, its
5328 ancestors, and the bookmark will be pushed to the remote
5328 ancestors, and the bookmark will be pushed to the remote
5329 repository.
5329 repository.
5330
5330
5331 Please see :hg:`help urls` for important details about ``ssh://``
5331 Please see :hg:`help urls` for important details about ``ssh://``
5332 URLs. If DESTINATION is omitted, a default path will be used.
5332 URLs. If DESTINATION is omitted, a default path will be used.
5333
5333
5334 Returns 0 if push was successful, 1 if nothing to push.
5334 Returns 0 if push was successful, 1 if nothing to push.
5335 """
5335 """
5336
5336
5337 if opts.get('bookmark'):
5337 if opts.get('bookmark'):
5338 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5338 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5339 for b in opts['bookmark']:
5339 for b in opts['bookmark']:
5340 # translate -B options to -r so changesets get pushed
5340 # translate -B options to -r so changesets get pushed
5341 if b in repo._bookmarks:
5341 if b in repo._bookmarks:
5342 opts.setdefault('rev', []).append(b)
5342 opts.setdefault('rev', []).append(b)
5343 else:
5343 else:
5344 # if we try to push a deleted bookmark, translate it to null
5344 # if we try to push a deleted bookmark, translate it to null
5345 # this lets simultaneous -r, -b options continue working
5345 # this lets simultaneous -r, -b options continue working
5346 opts.setdefault('rev', []).append("null")
5346 opts.setdefault('rev', []).append("null")
5347
5347
5348 path = ui.paths.getpath(dest, default='default')
5348 path = ui.paths.getpath(dest, default='default')
5349 if not path:
5349 if not path:
5350 raise util.Abort(_('default repository not configured!'),
5350 raise util.Abort(_('default repository not configured!'),
5351 hint=_('see the "path" section in "hg help config"'))
5351 hint=_('see the "path" section in "hg help config"'))
5352 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5352 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5353 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5353 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5354 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5354 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5355 other = hg.peer(repo, opts, dest)
5355 other = hg.peer(repo, opts, dest)
5356
5356
5357 if revs:
5357 if revs:
5358 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5358 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5359 if not revs:
5359 if not revs:
5360 raise util.Abort(_("specified revisions evaluate to an empty set"),
5360 raise util.Abort(_("specified revisions evaluate to an empty set"),
5361 hint=_("use different revision arguments"))
5361 hint=_("use different revision arguments"))
5362
5362
5363 repo._subtoppath = dest
5363 repo._subtoppath = dest
5364 try:
5364 try:
5365 # push subrepos depth-first for coherent ordering
5365 # push subrepos depth-first for coherent ordering
5366 c = repo['']
5366 c = repo['']
5367 subs = c.substate # only repos that are committed
5367 subs = c.substate # only repos that are committed
5368 for s in sorted(subs):
5368 for s in sorted(subs):
5369 result = c.sub(s).push(opts)
5369 result = c.sub(s).push(opts)
5370 if result == 0:
5370 if result == 0:
5371 return not result
5371 return not result
5372 finally:
5372 finally:
5373 del repo._subtoppath
5373 del repo._subtoppath
5374 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5374 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5375 newbranch=opts.get('new_branch'),
5375 newbranch=opts.get('new_branch'),
5376 bookmarks=opts.get('bookmark', ()))
5376 bookmarks=opts.get('bookmark', ()))
5377
5377
5378 result = not pushop.cgresult
5378 result = not pushop.cgresult
5379
5379
5380 if pushop.bkresult is not None:
5380 if pushop.bkresult is not None:
5381 if pushop.bkresult == 2:
5381 if pushop.bkresult == 2:
5382 result = 2
5382 result = 2
5383 elif not result and pushop.bkresult:
5383 elif not result and pushop.bkresult:
5384 result = 2
5384 result = 2
5385
5385
5386 return result
5386 return result
5387
5387
5388 @command('recover', [])
5388 @command('recover', [])
5389 def recover(ui, repo):
5389 def recover(ui, repo):
5390 """roll back an interrupted transaction
5390 """roll back an interrupted transaction
5391
5391
5392 Recover from an interrupted commit or pull.
5392 Recover from an interrupted commit or pull.
5393
5393
5394 This command tries to fix the repository status after an
5394 This command tries to fix the repository status after an
5395 interrupted operation. It should only be necessary when Mercurial
5395 interrupted operation. It should only be necessary when Mercurial
5396 suggests it.
5396 suggests it.
5397
5397
5398 Returns 0 if successful, 1 if nothing to recover or verify fails.
5398 Returns 0 if successful, 1 if nothing to recover or verify fails.
5399 """
5399 """
5400 if repo.recover():
5400 if repo.recover():
5401 return hg.verify(repo)
5401 return hg.verify(repo)
5402 return 1
5402 return 1
5403
5403
5404 @command('^remove|rm',
5404 @command('^remove|rm',
5405 [('A', 'after', None, _('record delete for missing files')),
5405 [('A', 'after', None, _('record delete for missing files')),
5406 ('f', 'force', None,
5406 ('f', 'force', None,
5407 _('remove (and delete) file even if added or modified')),
5407 _('remove (and delete) file even if added or modified')),
5408 ] + subrepoopts + walkopts,
5408 ] + subrepoopts + walkopts,
5409 _('[OPTION]... FILE...'),
5409 _('[OPTION]... FILE...'),
5410 inferrepo=True)
5410 inferrepo=True)
5411 def remove(ui, repo, *pats, **opts):
5411 def remove(ui, repo, *pats, **opts):
5412 """remove the specified files on the next commit
5412 """remove the specified files on the next commit
5413
5413
5414 Schedule the indicated files for removal from the current branch.
5414 Schedule the indicated files for removal from the current branch.
5415
5415
5416 This command schedules the files to be removed at the next commit.
5416 This command schedules the files to be removed at the next commit.
5417 To undo a remove before that, see :hg:`revert`. To undo added
5417 To undo a remove before that, see :hg:`revert`. To undo added
5418 files, see :hg:`forget`.
5418 files, see :hg:`forget`.
5419
5419
5420 .. container:: verbose
5420 .. container:: verbose
5421
5421
5422 -A/--after can be used to remove only files that have already
5422 -A/--after can be used to remove only files that have already
5423 been deleted, -f/--force can be used to force deletion, and -Af
5423 been deleted, -f/--force can be used to force deletion, and -Af
5424 can be used to remove files from the next revision without
5424 can be used to remove files from the next revision without
5425 deleting them from the working directory.
5425 deleting them from the working directory.
5426
5426
5427 The following table details the behavior of remove for different
5427 The following table details the behavior of remove for different
5428 file states (columns) and option combinations (rows). The file
5428 file states (columns) and option combinations (rows). The file
5429 states are Added [A], Clean [C], Modified [M] and Missing [!]
5429 states are Added [A], Clean [C], Modified [M] and Missing [!]
5430 (as reported by :hg:`status`). The actions are Warn, Remove
5430 (as reported by :hg:`status`). The actions are Warn, Remove
5431 (from branch) and Delete (from disk):
5431 (from branch) and Delete (from disk):
5432
5432
5433 ========= == == == ==
5433 ========= == == == ==
5434 opt/state A C M !
5434 opt/state A C M !
5435 ========= == == == ==
5435 ========= == == == ==
5436 none W RD W R
5436 none W RD W R
5437 -f R RD RD R
5437 -f R RD RD R
5438 -A W W W R
5438 -A W W W R
5439 -Af R R R R
5439 -Af R R R R
5440 ========= == == == ==
5440 ========= == == == ==
5441
5441
5442 Note that remove never deletes files in Added [A] state from the
5442 Note that remove never deletes files in Added [A] state from the
5443 working directory, not even if option --force is specified.
5443 working directory, not even if option --force is specified.
5444
5444
5445 Returns 0 on success, 1 if any warnings encountered.
5445 Returns 0 on success, 1 if any warnings encountered.
5446 """
5446 """
5447
5447
5448 after, force = opts.get('after'), opts.get('force')
5448 after, force = opts.get('after'), opts.get('force')
5449 if not pats and not after:
5449 if not pats and not after:
5450 raise util.Abort(_('no files specified'))
5450 raise util.Abort(_('no files specified'))
5451
5451
5452 m = scmutil.match(repo[None], pats, opts)
5452 m = scmutil.match(repo[None], pats, opts)
5453 subrepos = opts.get('subrepos')
5453 subrepos = opts.get('subrepos')
5454 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5454 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5455
5455
5456 @command('rename|move|mv',
5456 @command('rename|move|mv',
5457 [('A', 'after', None, _('record a rename that has already occurred')),
5457 [('A', 'after', None, _('record a rename that has already occurred')),
5458 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5458 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5459 ] + walkopts + dryrunopts,
5459 ] + walkopts + dryrunopts,
5460 _('[OPTION]... SOURCE... DEST'))
5460 _('[OPTION]... SOURCE... DEST'))
5461 def rename(ui, repo, *pats, **opts):
5461 def rename(ui, repo, *pats, **opts):
5462 """rename files; equivalent of copy + remove
5462 """rename files; equivalent of copy + remove
5463
5463
5464 Mark dest as copies of sources; mark sources for deletion. If dest
5464 Mark dest as copies of sources; mark sources for deletion. If dest
5465 is a directory, copies are put in that directory. If dest is a
5465 is a directory, copies are put in that directory. If dest is a
5466 file, there can only be one source.
5466 file, there can only be one source.
5467
5467
5468 By default, this command copies the contents of files as they
5468 By default, this command copies the contents of files as they
5469 exist in the working directory. If invoked with -A/--after, the
5469 exist in the working directory. If invoked with -A/--after, the
5470 operation is recorded, but no copying is performed.
5470 operation is recorded, but no copying is performed.
5471
5471
5472 This command takes effect at the next commit. To undo a rename
5472 This command takes effect at the next commit. To undo a rename
5473 before that, see :hg:`revert`.
5473 before that, see :hg:`revert`.
5474
5474
5475 Returns 0 on success, 1 if errors are encountered.
5475 Returns 0 on success, 1 if errors are encountered.
5476 """
5476 """
5477 wlock = repo.wlock(False)
5477 wlock = repo.wlock(False)
5478 try:
5478 try:
5479 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5479 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5480 finally:
5480 finally:
5481 wlock.release()
5481 wlock.release()
5482
5482
5483 @command('resolve',
5483 @command('resolve',
5484 [('a', 'all', None, _('select all unresolved files')),
5484 [('a', 'all', None, _('select all unresolved files')),
5485 ('l', 'list', None, _('list state of files needing merge')),
5485 ('l', 'list', None, _('list state of files needing merge')),
5486 ('m', 'mark', None, _('mark files as resolved')),
5486 ('m', 'mark', None, _('mark files as resolved')),
5487 ('u', 'unmark', None, _('mark files as unresolved')),
5487 ('u', 'unmark', None, _('mark files as unresolved')),
5488 ('n', 'no-status', None, _('hide status prefix'))]
5488 ('n', 'no-status', None, _('hide status prefix'))]
5489 + mergetoolopts + walkopts + formatteropts,
5489 + mergetoolopts + walkopts + formatteropts,
5490 _('[OPTION]... [FILE]...'),
5490 _('[OPTION]... [FILE]...'),
5491 inferrepo=True)
5491 inferrepo=True)
5492 def resolve(ui, repo, *pats, **opts):
5492 def resolve(ui, repo, *pats, **opts):
5493 """redo merges or set/view the merge status of files
5493 """redo merges or set/view the merge status of files
5494
5494
5495 Merges with unresolved conflicts are often the result of
5495 Merges with unresolved conflicts are often the result of
5496 non-interactive merging using the ``internal:merge`` configuration
5496 non-interactive merging using the ``internal:merge`` configuration
5497 setting, or a command-line merge tool like ``diff3``. The resolve
5497 setting, or a command-line merge tool like ``diff3``. The resolve
5498 command is used to manage the files involved in a merge, after
5498 command is used to manage the files involved in a merge, after
5499 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5499 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5500 working directory must have two parents). See :hg:`help
5500 working directory must have two parents). See :hg:`help
5501 merge-tools` for information on configuring merge tools.
5501 merge-tools` for information on configuring merge tools.
5502
5502
5503 The resolve command can be used in the following ways:
5503 The resolve command can be used in the following ways:
5504
5504
5505 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5505 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5506 files, discarding any previous merge attempts. Re-merging is not
5506 files, discarding any previous merge attempts. Re-merging is not
5507 performed for files already marked as resolved. Use ``--all/-a``
5507 performed for files already marked as resolved. Use ``--all/-a``
5508 to select all unresolved files. ``--tool`` can be used to specify
5508 to select all unresolved files. ``--tool`` can be used to specify
5509 the merge tool used for the given files. It overrides the HGMERGE
5509 the merge tool used for the given files. It overrides the HGMERGE
5510 environment variable and your configuration files. Previous file
5510 environment variable and your configuration files. Previous file
5511 contents are saved with a ``.orig`` suffix.
5511 contents are saved with a ``.orig`` suffix.
5512
5512
5513 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5513 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5514 (e.g. after having manually fixed-up the files). The default is
5514 (e.g. after having manually fixed-up the files). The default is
5515 to mark all unresolved files.
5515 to mark all unresolved files.
5516
5516
5517 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5517 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5518 default is to mark all resolved files.
5518 default is to mark all resolved files.
5519
5519
5520 - :hg:`resolve -l`: list files which had or still have conflicts.
5520 - :hg:`resolve -l`: list files which had or still have conflicts.
5521 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5521 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5522
5522
5523 Note that Mercurial will not let you commit files with unresolved
5523 Note that Mercurial will not let you commit files with unresolved
5524 merge conflicts. You must use :hg:`resolve -m ...` before you can
5524 merge conflicts. You must use :hg:`resolve -m ...` before you can
5525 commit after a conflicting merge.
5525 commit after a conflicting merge.
5526
5526
5527 Returns 0 on success, 1 if any files fail a resolve attempt.
5527 Returns 0 on success, 1 if any files fail a resolve attempt.
5528 """
5528 """
5529
5529
5530 all, mark, unmark, show, nostatus = \
5530 all, mark, unmark, show, nostatus = \
5531 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5531 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5532
5532
5533 if (show and (mark or unmark)) or (mark and unmark):
5533 if (show and (mark or unmark)) or (mark and unmark):
5534 raise util.Abort(_("too many options specified"))
5534 raise util.Abort(_("too many options specified"))
5535 if pats and all:
5535 if pats and all:
5536 raise util.Abort(_("can't specify --all and patterns"))
5536 raise util.Abort(_("can't specify --all and patterns"))
5537 if not (all or pats or show or mark or unmark):
5537 if not (all or pats or show or mark or unmark):
5538 raise util.Abort(_('no files or directories specified'),
5538 raise util.Abort(_('no files or directories specified'),
5539 hint=('use --all to re-merge all unresolved files'))
5539 hint=('use --all to re-merge all unresolved files'))
5540
5540
5541 if show:
5541 if show:
5542 fm = ui.formatter('resolve', opts)
5542 fm = ui.formatter('resolve', opts)
5543 ms = mergemod.mergestate(repo)
5543 ms = mergemod.mergestate(repo)
5544 m = scmutil.match(repo[None], pats, opts)
5544 m = scmutil.match(repo[None], pats, opts)
5545 for f in ms:
5545 for f in ms:
5546 if not m(f):
5546 if not m(f):
5547 continue
5547 continue
5548 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]
5548 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]
5549 fm.startitem()
5549 fm.startitem()
5550 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5550 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5551 fm.write('path', '%s\n', f, label=l)
5551 fm.write('path', '%s\n', f, label=l)
5552 fm.end()
5552 fm.end()
5553 return 0
5553 return 0
5554
5554
5555 wlock = repo.wlock()
5555 wlock = repo.wlock()
5556 try:
5556 try:
5557 ms = mergemod.mergestate(repo)
5557 ms = mergemod.mergestate(repo)
5558
5558
5559 if not (ms.active() or repo.dirstate.p2() != nullid):
5559 if not (ms.active() or repo.dirstate.p2() != nullid):
5560 raise util.Abort(
5560 raise util.Abort(
5561 _('resolve command not applicable when not merging'))
5561 _('resolve command not applicable when not merging'))
5562
5562
5563 m = scmutil.match(repo[None], pats, opts)
5563 m = scmutil.match(repo[None], pats, opts)
5564 ret = 0
5564 ret = 0
5565 didwork = False
5565 didwork = False
5566
5566
5567 for f in ms:
5567 for f in ms:
5568 if not m(f):
5568 if not m(f):
5569 continue
5569 continue
5570
5570
5571 didwork = True
5571 didwork = True
5572
5572
5573 if mark:
5573 if mark:
5574 ms.mark(f, "r")
5574 ms.mark(f, "r")
5575 elif unmark:
5575 elif unmark:
5576 ms.mark(f, "u")
5576 ms.mark(f, "u")
5577 else:
5577 else:
5578 wctx = repo[None]
5578 wctx = repo[None]
5579
5579
5580 # backup pre-resolve (merge uses .orig for its own purposes)
5580 # backup pre-resolve (merge uses .orig for its own purposes)
5581 a = repo.wjoin(f)
5581 a = repo.wjoin(f)
5582 util.copyfile(a, a + ".resolve")
5582 util.copyfile(a, a + ".resolve")
5583
5583
5584 try:
5584 try:
5585 # resolve file
5585 # resolve file
5586 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5586 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5587 'resolve')
5587 'resolve')
5588 if ms.resolve(f, wctx):
5588 if ms.resolve(f, wctx):
5589 ret = 1
5589 ret = 1
5590 finally:
5590 finally:
5591 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5591 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5592 ms.commit()
5592 ms.commit()
5593
5593
5594 # replace filemerge's .orig file with our resolve file
5594 # replace filemerge's .orig file with our resolve file
5595 util.rename(a + ".resolve", a + ".orig")
5595 util.rename(a + ".resolve", a + ".orig")
5596
5596
5597 ms.commit()
5597 ms.commit()
5598
5598
5599 if not didwork and pats:
5599 if not didwork and pats:
5600 ui.warn(_("arguments do not match paths that need resolving\n"))
5600 ui.warn(_("arguments do not match paths that need resolving\n"))
5601
5601
5602 finally:
5602 finally:
5603 wlock.release()
5603 wlock.release()
5604
5604
5605 # Nudge users into finishing an unfinished operation
5605 # Nudge users into finishing an unfinished operation
5606 if not list(ms.unresolved()):
5606 if not list(ms.unresolved()):
5607 ui.status(_('(no more unresolved files)\n'))
5607 ui.status(_('(no more unresolved files)\n'))
5608
5608
5609 return ret
5609 return ret
5610
5610
5611 @command('revert',
5611 @command('revert',
5612 [('a', 'all', None, _('revert all changes when no arguments given')),
5612 [('a', 'all', None, _('revert all changes when no arguments given')),
5613 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5613 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5614 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5614 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5615 ('C', 'no-backup', None, _('do not save backup copies of files')),
5615 ('C', 'no-backup', None, _('do not save backup copies of files')),
5616 ('i', 'interactive', None,
5616 ('i', 'interactive', None,
5617 _('interactively select the changes (EXPERIMENTAL)')),
5617 _('interactively select the changes (EXPERIMENTAL)')),
5618 ] + walkopts + dryrunopts,
5618 ] + walkopts + dryrunopts,
5619 _('[OPTION]... [-r REV] [NAME]...'))
5619 _('[OPTION]... [-r REV] [NAME]...'))
5620 def revert(ui, repo, *pats, **opts):
5620 def revert(ui, repo, *pats, **opts):
5621 """restore files to their checkout state
5621 """restore files to their checkout state
5622
5622
5623 .. note::
5623 .. note::
5624
5624
5625 To check out earlier revisions, you should use :hg:`update REV`.
5625 To check out earlier revisions, you should use :hg:`update REV`.
5626 To cancel an uncommitted merge (and lose your changes),
5626 To cancel an uncommitted merge (and lose your changes),
5627 use :hg:`update --clean .`.
5627 use :hg:`update --clean .`.
5628
5628
5629 With no revision specified, revert the specified files or directories
5629 With no revision specified, revert the specified files or directories
5630 to the contents they had in the parent of the working directory.
5630 to the contents they had in the parent of the working directory.
5631 This restores the contents of files to an unmodified
5631 This restores the contents of files to an unmodified
5632 state and unschedules adds, removes, copies, and renames. If the
5632 state and unschedules adds, removes, copies, and renames. If the
5633 working directory has two parents, you must explicitly specify a
5633 working directory has two parents, you must explicitly specify a
5634 revision.
5634 revision.
5635
5635
5636 Using the -r/--rev or -d/--date options, revert the given files or
5636 Using the -r/--rev or -d/--date options, revert the given files or
5637 directories to their states as of a specific revision. Because
5637 directories to their states as of a specific revision. Because
5638 revert does not change the working directory parents, this will
5638 revert does not change the working directory parents, this will
5639 cause these files to appear modified. This can be helpful to "back
5639 cause these files to appear modified. This can be helpful to "back
5640 out" some or all of an earlier change. See :hg:`backout` for a
5640 out" some or all of an earlier change. See :hg:`backout` for a
5641 related method.
5641 related method.
5642
5642
5643 Modified files are saved with a .orig suffix before reverting.
5643 Modified files are saved with a .orig suffix before reverting.
5644 To disable these backups, use --no-backup.
5644 To disable these backups, use --no-backup.
5645
5645
5646 See :hg:`help dates` for a list of formats valid for -d/--date.
5646 See :hg:`help dates` for a list of formats valid for -d/--date.
5647
5647
5648 See :hg:`help backout` for a way to reverse the effect of an
5648 See :hg:`help backout` for a way to reverse the effect of an
5649 earlier changeset.
5649 earlier changeset.
5650
5650
5651 Returns 0 on success.
5651 Returns 0 on success.
5652 """
5652 """
5653
5653
5654 if opts.get("date"):
5654 if opts.get("date"):
5655 if opts.get("rev"):
5655 if opts.get("rev"):
5656 raise util.Abort(_("you can't specify a revision and a date"))
5656 raise util.Abort(_("you can't specify a revision and a date"))
5657 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5657 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5658
5658
5659 parent, p2 = repo.dirstate.parents()
5659 parent, p2 = repo.dirstate.parents()
5660 if not opts.get('rev') and p2 != nullid:
5660 if not opts.get('rev') and p2 != nullid:
5661 # revert after merge is a trap for new users (issue2915)
5661 # revert after merge is a trap for new users (issue2915)
5662 raise util.Abort(_('uncommitted merge with no revision specified'),
5662 raise util.Abort(_('uncommitted merge with no revision specified'),
5663 hint=_('use "hg update" or see "hg help revert"'))
5663 hint=_('use "hg update" or see "hg help revert"'))
5664
5664
5665 ctx = scmutil.revsingle(repo, opts.get('rev'))
5665 ctx = scmutil.revsingle(repo, opts.get('rev'))
5666
5666
5667 if (not (pats or opts.get('include') or opts.get('exclude') or
5667 if (not (pats or opts.get('include') or opts.get('exclude') or
5668 opts.get('all') or opts.get('interactive'))):
5668 opts.get('all') or opts.get('interactive'))):
5669 msg = _("no files or directories specified")
5669 msg = _("no files or directories specified")
5670 if p2 != nullid:
5670 if p2 != nullid:
5671 hint = _("uncommitted merge, use --all to discard all changes,"
5671 hint = _("uncommitted merge, use --all to discard all changes,"
5672 " or 'hg update -C .' to abort the merge")
5672 " or 'hg update -C .' to abort the merge")
5673 raise util.Abort(msg, hint=hint)
5673 raise util.Abort(msg, hint=hint)
5674 dirty = any(repo.status())
5674 dirty = any(repo.status())
5675 node = ctx.node()
5675 node = ctx.node()
5676 if node != parent:
5676 if node != parent:
5677 if dirty:
5677 if dirty:
5678 hint = _("uncommitted changes, use --all to discard all"
5678 hint = _("uncommitted changes, use --all to discard all"
5679 " changes, or 'hg update %s' to update") % ctx.rev()
5679 " changes, or 'hg update %s' to update") % ctx.rev()
5680 else:
5680 else:
5681 hint = _("use --all to revert all files,"
5681 hint = _("use --all to revert all files,"
5682 " or 'hg update %s' to update") % ctx.rev()
5682 " or 'hg update %s' to update") % ctx.rev()
5683 elif dirty:
5683 elif dirty:
5684 hint = _("uncommitted changes, use --all to discard all changes")
5684 hint = _("uncommitted changes, use --all to discard all changes")
5685 else:
5685 else:
5686 hint = _("use --all to revert all files")
5686 hint = _("use --all to revert all files")
5687 raise util.Abort(msg, hint=hint)
5687 raise util.Abort(msg, hint=hint)
5688
5688
5689 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5689 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5690
5690
5691 @command('rollback', dryrunopts +
5691 @command('rollback', dryrunopts +
5692 [('f', 'force', False, _('ignore safety measures'))])
5692 [('f', 'force', False, _('ignore safety measures'))])
5693 def rollback(ui, repo, **opts):
5693 def rollback(ui, repo, **opts):
5694 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5694 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5695
5695
5696 Please use :hg:`commit --amend` instead of rollback to correct
5696 Please use :hg:`commit --amend` instead of rollback to correct
5697 mistakes in the last commit.
5697 mistakes in the last commit.
5698
5698
5699 This command should be used with care. There is only one level of
5699 This command should be used with care. There is only one level of
5700 rollback, and there is no way to undo a rollback. It will also
5700 rollback, and there is no way to undo a rollback. It will also
5701 restore the dirstate at the time of the last transaction, losing
5701 restore the dirstate at the time of the last transaction, losing
5702 any dirstate changes since that time. This command does not alter
5702 any dirstate changes since that time. This command does not alter
5703 the working directory.
5703 the working directory.
5704
5704
5705 Transactions are used to encapsulate the effects of all commands
5705 Transactions are used to encapsulate the effects of all commands
5706 that create new changesets or propagate existing changesets into a
5706 that create new changesets or propagate existing changesets into a
5707 repository.
5707 repository.
5708
5708
5709 .. container:: verbose
5709 .. container:: verbose
5710
5710
5711 For example, the following commands are transactional, and their
5711 For example, the following commands are transactional, and their
5712 effects can be rolled back:
5712 effects can be rolled back:
5713
5713
5714 - commit
5714 - commit
5715 - import
5715 - import
5716 - pull
5716 - pull
5717 - push (with this repository as the destination)
5717 - push (with this repository as the destination)
5718 - unbundle
5718 - unbundle
5719
5719
5720 To avoid permanent data loss, rollback will refuse to rollback a
5720 To avoid permanent data loss, rollback will refuse to rollback a
5721 commit transaction if it isn't checked out. Use --force to
5721 commit transaction if it isn't checked out. Use --force to
5722 override this protection.
5722 override this protection.
5723
5723
5724 This command is not intended for use on public repositories. Once
5724 This command is not intended for use on public repositories. Once
5725 changes are visible for pull by other users, rolling a transaction
5725 changes are visible for pull by other users, rolling a transaction
5726 back locally is ineffective (someone else may already have pulled
5726 back locally is ineffective (someone else may already have pulled
5727 the changes). Furthermore, a race is possible with readers of the
5727 the changes). Furthermore, a race is possible with readers of the
5728 repository; for example an in-progress pull from the repository
5728 repository; for example an in-progress pull from the repository
5729 may fail if a rollback is performed.
5729 may fail if a rollback is performed.
5730
5730
5731 Returns 0 on success, 1 if no rollback data is available.
5731 Returns 0 on success, 1 if no rollback data is available.
5732 """
5732 """
5733 return repo.rollback(dryrun=opts.get('dry_run'),
5733 return repo.rollback(dryrun=opts.get('dry_run'),
5734 force=opts.get('force'))
5734 force=opts.get('force'))
5735
5735
5736 @command('root', [])
5736 @command('root', [])
5737 def root(ui, repo):
5737 def root(ui, repo):
5738 """print the root (top) of the current working directory
5738 """print the root (top) of the current working directory
5739
5739
5740 Print the root directory of the current repository.
5740 Print the root directory of the current repository.
5741
5741
5742 Returns 0 on success.
5742 Returns 0 on success.
5743 """
5743 """
5744 ui.write(repo.root + "\n")
5744 ui.write(repo.root + "\n")
5745
5745
5746 @command('^serve',
5746 @command('^serve',
5747 [('A', 'accesslog', '', _('name of access log file to write to'),
5747 [('A', 'accesslog', '', _('name of access log file to write to'),
5748 _('FILE')),
5748 _('FILE')),
5749 ('d', 'daemon', None, _('run server in background')),
5749 ('d', 'daemon', None, _('run server in background')),
5750 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5750 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5751 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5751 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5752 # use string type, then we can check if something was passed
5752 # use string type, then we can check if something was passed
5753 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5753 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5754 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5754 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5755 _('ADDR')),
5755 _('ADDR')),
5756 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5756 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5757 _('PREFIX')),
5757 _('PREFIX')),
5758 ('n', 'name', '',
5758 ('n', 'name', '',
5759 _('name to show in web pages (default: working directory)'), _('NAME')),
5759 _('name to show in web pages (default: working directory)'), _('NAME')),
5760 ('', 'web-conf', '',
5760 ('', 'web-conf', '',
5761 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5761 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5762 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5762 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5763 _('FILE')),
5763 _('FILE')),
5764 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5764 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5765 ('', 'stdio', None, _('for remote clients')),
5765 ('', 'stdio', None, _('for remote clients')),
5766 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5766 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5767 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5767 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5768 ('', 'style', '', _('template style to use'), _('STYLE')),
5768 ('', 'style', '', _('template style to use'), _('STYLE')),
5769 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5769 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5770 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5770 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5771 _('[OPTION]...'),
5771 _('[OPTION]...'),
5772 optionalrepo=True)
5772 optionalrepo=True)
5773 def serve(ui, repo, **opts):
5773 def serve(ui, repo, **opts):
5774 """start stand-alone webserver
5774 """start stand-alone webserver
5775
5775
5776 Start a local HTTP repository browser and pull server. You can use
5776 Start a local HTTP repository browser and pull server. You can use
5777 this for ad-hoc sharing and browsing of repositories. It is
5777 this for ad-hoc sharing and browsing of repositories. It is
5778 recommended to use a real web server to serve a repository for
5778 recommended to use a real web server to serve a repository for
5779 longer periods of time.
5779 longer periods of time.
5780
5780
5781 Please note that the server does not implement access control.
5781 Please note that the server does not implement access control.
5782 This means that, by default, anybody can read from the server and
5782 This means that, by default, anybody can read from the server and
5783 nobody can write to it by default. Set the ``web.allow_push``
5783 nobody can write to it by default. Set the ``web.allow_push``
5784 option to ``*`` to allow everybody to push to the server. You
5784 option to ``*`` to allow everybody to push to the server. You
5785 should use a real web server if you need to authenticate users.
5785 should use a real web server if you need to authenticate users.
5786
5786
5787 By default, the server logs accesses to stdout and errors to
5787 By default, the server logs accesses to stdout and errors to
5788 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5788 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5789 files.
5789 files.
5790
5790
5791 To have the server choose a free port number to listen on, specify
5791 To have the server choose a free port number to listen on, specify
5792 a port number of 0; in this case, the server will print the port
5792 a port number of 0; in this case, the server will print the port
5793 number it uses.
5793 number it uses.
5794
5794
5795 Returns 0 on success.
5795 Returns 0 on success.
5796 """
5796 """
5797
5797
5798 if opts["stdio"] and opts["cmdserver"]:
5798 if opts["stdio"] and opts["cmdserver"]:
5799 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5799 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5800
5800
5801 if opts["stdio"]:
5801 if opts["stdio"]:
5802 if repo is None:
5802 if repo is None:
5803 raise error.RepoError(_("there is no Mercurial repository here"
5803 raise error.RepoError(_("there is no Mercurial repository here"
5804 " (.hg not found)"))
5804 " (.hg not found)"))
5805 s = sshserver.sshserver(ui, repo)
5805 s = sshserver.sshserver(ui, repo)
5806 s.serve_forever()
5806 s.serve_forever()
5807
5807
5808 if opts["cmdserver"]:
5808 if opts["cmdserver"]:
5809 import commandserver
5809 import commandserver
5810 service = commandserver.createservice(ui, repo, opts)
5810 service = commandserver.createservice(ui, repo, opts)
5811 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5811 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5812
5812
5813 # this way we can check if something was given in the command-line
5813 # this way we can check if something was given in the command-line
5814 if opts.get('port'):
5814 if opts.get('port'):
5815 opts['port'] = util.getport(opts.get('port'))
5815 opts['port'] = util.getport(opts.get('port'))
5816
5816
5817 if repo:
5817 if repo:
5818 baseui = repo.baseui
5818 baseui = repo.baseui
5819 else:
5819 else:
5820 baseui = ui
5820 baseui = ui
5821 optlist = ("name templates style address port prefix ipv6"
5821 optlist = ("name templates style address port prefix ipv6"
5822 " accesslog errorlog certificate encoding")
5822 " accesslog errorlog certificate encoding")
5823 for o in optlist.split():
5823 for o in optlist.split():
5824 val = opts.get(o, '')
5824 val = opts.get(o, '')
5825 if val in (None, ''): # should check against default options instead
5825 if val in (None, ''): # should check against default options instead
5826 continue
5826 continue
5827 baseui.setconfig("web", o, val, 'serve')
5827 baseui.setconfig("web", o, val, 'serve')
5828 if repo and repo.ui != baseui:
5828 if repo and repo.ui != baseui:
5829 repo.ui.setconfig("web", o, val, 'serve')
5829 repo.ui.setconfig("web", o, val, 'serve')
5830
5830
5831 o = opts.get('web_conf') or opts.get('webdir_conf')
5831 o = opts.get('web_conf') or opts.get('webdir_conf')
5832 if not o:
5832 if not o:
5833 if not repo:
5833 if not repo:
5834 raise error.RepoError(_("there is no Mercurial repository"
5834 raise error.RepoError(_("there is no Mercurial repository"
5835 " here (.hg not found)"))
5835 " here (.hg not found)"))
5836 o = repo
5836 o = repo
5837
5837
5838 app = hgweb.hgweb(o, baseui=baseui)
5838 app = hgweb.hgweb(o, baseui=baseui)
5839 service = httpservice(ui, app, opts)
5839 service = httpservice(ui, app, opts)
5840 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5840 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5841
5841
5842 class httpservice(object):
5842 class httpservice(object):
5843 def __init__(self, ui, app, opts):
5843 def __init__(self, ui, app, opts):
5844 self.ui = ui
5844 self.ui = ui
5845 self.app = app
5845 self.app = app
5846 self.opts = opts
5846 self.opts = opts
5847
5847
5848 def init(self):
5848 def init(self):
5849 util.setsignalhandler()
5849 util.setsignalhandler()
5850 self.httpd = hgweb_server.create_server(self.ui, self.app)
5850 self.httpd = hgweb_server.create_server(self.ui, self.app)
5851
5851
5852 if self.opts['port'] and not self.ui.verbose:
5852 if self.opts['port'] and not self.ui.verbose:
5853 return
5853 return
5854
5854
5855 if self.httpd.prefix:
5855 if self.httpd.prefix:
5856 prefix = self.httpd.prefix.strip('/') + '/'
5856 prefix = self.httpd.prefix.strip('/') + '/'
5857 else:
5857 else:
5858 prefix = ''
5858 prefix = ''
5859
5859
5860 port = ':%d' % self.httpd.port
5860 port = ':%d' % self.httpd.port
5861 if port == ':80':
5861 if port == ':80':
5862 port = ''
5862 port = ''
5863
5863
5864 bindaddr = self.httpd.addr
5864 bindaddr = self.httpd.addr
5865 if bindaddr == '0.0.0.0':
5865 if bindaddr == '0.0.0.0':
5866 bindaddr = '*'
5866 bindaddr = '*'
5867 elif ':' in bindaddr: # IPv6
5867 elif ':' in bindaddr: # IPv6
5868 bindaddr = '[%s]' % bindaddr
5868 bindaddr = '[%s]' % bindaddr
5869
5869
5870 fqaddr = self.httpd.fqaddr
5870 fqaddr = self.httpd.fqaddr
5871 if ':' in fqaddr:
5871 if ':' in fqaddr:
5872 fqaddr = '[%s]' % fqaddr
5872 fqaddr = '[%s]' % fqaddr
5873 if self.opts['port']:
5873 if self.opts['port']:
5874 write = self.ui.status
5874 write = self.ui.status
5875 else:
5875 else:
5876 write = self.ui.write
5876 write = self.ui.write
5877 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5877 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5878 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5878 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5879 self.ui.flush() # avoid buffering of status message
5879 self.ui.flush() # avoid buffering of status message
5880
5880
5881 def run(self):
5881 def run(self):
5882 self.httpd.serve_forever()
5882 self.httpd.serve_forever()
5883
5883
5884
5884
5885 @command('^status|st',
5885 @command('^status|st',
5886 [('A', 'all', None, _('show status of all files')),
5886 [('A', 'all', None, _('show status of all files')),
5887 ('m', 'modified', None, _('show only modified files')),
5887 ('m', 'modified', None, _('show only modified files')),
5888 ('a', 'added', None, _('show only added files')),
5888 ('a', 'added', None, _('show only added files')),
5889 ('r', 'removed', None, _('show only removed files')),
5889 ('r', 'removed', None, _('show only removed files')),
5890 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5890 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5891 ('c', 'clean', None, _('show only files without changes')),
5891 ('c', 'clean', None, _('show only files without changes')),
5892 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5892 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5893 ('i', 'ignored', None, _('show only ignored files')),
5893 ('i', 'ignored', None, _('show only ignored files')),
5894 ('n', 'no-status', None, _('hide status prefix')),
5894 ('n', 'no-status', None, _('hide status prefix')),
5895 ('C', 'copies', None, _('show source of copied files')),
5895 ('C', 'copies', None, _('show source of copied files')),
5896 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5896 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5897 ('', 'rev', [], _('show difference from revision'), _('REV')),
5897 ('', 'rev', [], _('show difference from revision'), _('REV')),
5898 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5898 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5899 ] + walkopts + subrepoopts + formatteropts,
5899 ] + walkopts + subrepoopts + formatteropts,
5900 _('[OPTION]... [FILE]...'),
5900 _('[OPTION]... [FILE]...'),
5901 inferrepo=True)
5901 inferrepo=True)
5902 def status(ui, repo, *pats, **opts):
5902 def status(ui, repo, *pats, **opts):
5903 """show changed files in the working directory
5903 """show changed files in the working directory
5904
5904
5905 Show status of files in the repository. If names are given, only
5905 Show status of files in the repository. If names are given, only
5906 files that match are shown. Files that are clean or ignored or
5906 files that match are shown. Files that are clean or ignored or
5907 the source of a copy/move operation, are not listed unless
5907 the source of a copy/move operation, are not listed unless
5908 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5908 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5909 Unless options described with "show only ..." are given, the
5909 Unless options described with "show only ..." are given, the
5910 options -mardu are used.
5910 options -mardu are used.
5911
5911
5912 Option -q/--quiet hides untracked (unknown and ignored) files
5912 Option -q/--quiet hides untracked (unknown and ignored) files
5913 unless explicitly requested with -u/--unknown or -i/--ignored.
5913 unless explicitly requested with -u/--unknown or -i/--ignored.
5914
5914
5915 .. note::
5915 .. note::
5916
5916
5917 status may appear to disagree with diff if permissions have
5917 status may appear to disagree with diff if permissions have
5918 changed or a merge has occurred. The standard diff format does
5918 changed or a merge has occurred. The standard diff format does
5919 not report permission changes and diff only reports changes
5919 not report permission changes and diff only reports changes
5920 relative to one merge parent.
5920 relative to one merge parent.
5921
5921
5922 If one revision is given, it is used as the base revision.
5922 If one revision is given, it is used as the base revision.
5923 If two revisions are given, the differences between them are
5923 If two revisions are given, the differences between them are
5924 shown. The --change option can also be used as a shortcut to list
5924 shown. The --change option can also be used as a shortcut to list
5925 the changed files of a revision from its first parent.
5925 the changed files of a revision from its first parent.
5926
5926
5927 The codes used to show the status of files are::
5927 The codes used to show the status of files are::
5928
5928
5929 M = modified
5929 M = modified
5930 A = added
5930 A = added
5931 R = removed
5931 R = removed
5932 C = clean
5932 C = clean
5933 ! = missing (deleted by non-hg command, but still tracked)
5933 ! = missing (deleted by non-hg command, but still tracked)
5934 ? = not tracked
5934 ? = not tracked
5935 I = ignored
5935 I = ignored
5936 = origin of the previous file (with --copies)
5936 = origin of the previous file (with --copies)
5937
5937
5938 .. container:: verbose
5938 .. container:: verbose
5939
5939
5940 Examples:
5940 Examples:
5941
5941
5942 - show changes in the working directory relative to a
5942 - show changes in the working directory relative to a
5943 changeset::
5943 changeset::
5944
5944
5945 hg status --rev 9353
5945 hg status --rev 9353
5946
5946
5947 - show changes in the working directory relative to the
5947 - show changes in the working directory relative to the
5948 current directory (see :hg:`help patterns` for more information)::
5948 current directory (see :hg:`help patterns` for more information)::
5949
5949
5950 hg status re:
5950 hg status re:
5951
5951
5952 - show all changes including copies in an existing changeset::
5952 - show all changes including copies in an existing changeset::
5953
5953
5954 hg status --copies --change 9353
5954 hg status --copies --change 9353
5955
5955
5956 - get a NUL separated list of added files, suitable for xargs::
5956 - get a NUL separated list of added files, suitable for xargs::
5957
5957
5958 hg status -an0
5958 hg status -an0
5959
5959
5960 Returns 0 on success.
5960 Returns 0 on success.
5961 """
5961 """
5962
5962
5963 revs = opts.get('rev')
5963 revs = opts.get('rev')
5964 change = opts.get('change')
5964 change = opts.get('change')
5965
5965
5966 if revs and change:
5966 if revs and change:
5967 msg = _('cannot specify --rev and --change at the same time')
5967 msg = _('cannot specify --rev and --change at the same time')
5968 raise util.Abort(msg)
5968 raise util.Abort(msg)
5969 elif change:
5969 elif change:
5970 node2 = scmutil.revsingle(repo, change, None).node()
5970 node2 = scmutil.revsingle(repo, change, None).node()
5971 node1 = repo[node2].p1().node()
5971 node1 = repo[node2].p1().node()
5972 else:
5972 else:
5973 node1, node2 = scmutil.revpair(repo, revs)
5973 node1, node2 = scmutil.revpair(repo, revs)
5974
5974
5975 if pats:
5975 if pats:
5976 cwd = repo.getcwd()
5976 cwd = repo.getcwd()
5977 else:
5977 else:
5978 cwd = ''
5978 cwd = ''
5979
5979
5980 if opts.get('print0'):
5980 if opts.get('print0'):
5981 end = '\0'
5981 end = '\0'
5982 else:
5982 else:
5983 end = '\n'
5983 end = '\n'
5984 copy = {}
5984 copy = {}
5985 states = 'modified added removed deleted unknown ignored clean'.split()
5985 states = 'modified added removed deleted unknown ignored clean'.split()
5986 show = [k for k in states if opts.get(k)]
5986 show = [k for k in states if opts.get(k)]
5987 if opts.get('all'):
5987 if opts.get('all'):
5988 show += ui.quiet and (states[:4] + ['clean']) or states
5988 show += ui.quiet and (states[:4] + ['clean']) or states
5989 if not show:
5989 if not show:
5990 if ui.quiet:
5990 if ui.quiet:
5991 show = states[:4]
5991 show = states[:4]
5992 else:
5992 else:
5993 show = states[:5]
5993 show = states[:5]
5994
5994
5995 m = scmutil.match(repo[node2], pats, opts)
5995 m = scmutil.match(repo[node2], pats, opts)
5996 stat = repo.status(node1, node2, m,
5996 stat = repo.status(node1, node2, m,
5997 'ignored' in show, 'clean' in show, 'unknown' in show,
5997 'ignored' in show, 'clean' in show, 'unknown' in show,
5998 opts.get('subrepos'))
5998 opts.get('subrepos'))
5999 changestates = zip(states, 'MAR!?IC', stat)
5999 changestates = zip(states, 'MAR!?IC', stat)
6000
6000
6001 if (opts.get('all') or opts.get('copies')
6001 if (opts.get('all') or opts.get('copies')
6002 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6002 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6003 copy = copies.pathcopies(repo[node1], repo[node2], m)
6003 copy = copies.pathcopies(repo[node1], repo[node2], m)
6004
6004
6005 fm = ui.formatter('status', opts)
6005 fm = ui.formatter('status', opts)
6006 fmt = '%s' + end
6006 fmt = '%s' + end
6007 showchar = not opts.get('no_status')
6007 showchar = not opts.get('no_status')
6008
6008
6009 for state, char, files in changestates:
6009 for state, char, files in changestates:
6010 if state in show:
6010 if state in show:
6011 label = 'status.' + state
6011 label = 'status.' + state
6012 for f in files:
6012 for f in files:
6013 fm.startitem()
6013 fm.startitem()
6014 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6014 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6015 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6015 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6016 if f in copy:
6016 if f in copy:
6017 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6017 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6018 label='status.copied')
6018 label='status.copied')
6019 fm.end()
6019 fm.end()
6020
6020
6021 @command('^summary|sum',
6021 @command('^summary|sum',
6022 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6022 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6023 def summary(ui, repo, **opts):
6023 def summary(ui, repo, **opts):
6024 """summarize working directory state
6024 """summarize working directory state
6025
6025
6026 This generates a brief summary of the working directory state,
6026 This generates a brief summary of the working directory state,
6027 including parents, branch, commit status, phase and available updates.
6027 including parents, branch, commit status, phase and available updates.
6028
6028
6029 With the --remote option, this will check the default paths for
6029 With the --remote option, this will check the default paths for
6030 incoming and outgoing changes. This can be time-consuming.
6030 incoming and outgoing changes. This can be time-consuming.
6031
6031
6032 Returns 0 on success.
6032 Returns 0 on success.
6033 """
6033 """
6034
6034
6035 ctx = repo[None]
6035 ctx = repo[None]
6036 parents = ctx.parents()
6036 parents = ctx.parents()
6037 pnode = parents[0].node()
6037 pnode = parents[0].node()
6038 marks = []
6038 marks = []
6039
6039
6040 for p in parents:
6040 for p in parents:
6041 # label with log.changeset (instead of log.parent) since this
6041 # label with log.changeset (instead of log.parent) since this
6042 # shows a working directory parent *changeset*:
6042 # shows a working directory parent *changeset*:
6043 # i18n: column positioning for "hg summary"
6043 # i18n: column positioning for "hg summary"
6044 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6044 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6045 label='log.changeset changeset.%s' % p.phasestr())
6045 label='log.changeset changeset.%s' % p.phasestr())
6046 ui.write(' '.join(p.tags()), label='log.tag')
6046 ui.write(' '.join(p.tags()), label='log.tag')
6047 if p.bookmarks():
6047 if p.bookmarks():
6048 marks.extend(p.bookmarks())
6048 marks.extend(p.bookmarks())
6049 if p.rev() == -1:
6049 if p.rev() == -1:
6050 if not len(repo):
6050 if not len(repo):
6051 ui.write(_(' (empty repository)'))
6051 ui.write(_(' (empty repository)'))
6052 else:
6052 else:
6053 ui.write(_(' (no revision checked out)'))
6053 ui.write(_(' (no revision checked out)'))
6054 ui.write('\n')
6054 ui.write('\n')
6055 if p.description():
6055 if p.description():
6056 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6056 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6057 label='log.summary')
6057 label='log.summary')
6058
6058
6059 branch = ctx.branch()
6059 branch = ctx.branch()
6060 bheads = repo.branchheads(branch)
6060 bheads = repo.branchheads(branch)
6061 # i18n: column positioning for "hg summary"
6061 # i18n: column positioning for "hg summary"
6062 m = _('branch: %s\n') % branch
6062 m = _('branch: %s\n') % branch
6063 if branch != 'default':
6063 if branch != 'default':
6064 ui.write(m, label='log.branch')
6064 ui.write(m, label='log.branch')
6065 else:
6065 else:
6066 ui.status(m, label='log.branch')
6066 ui.status(m, label='log.branch')
6067
6067
6068 if marks:
6068 if marks:
6069 active = repo._activebookmark
6069 active = repo._activebookmark
6070 # i18n: column positioning for "hg summary"
6070 # i18n: column positioning for "hg summary"
6071 ui.write(_('bookmarks:'), label='log.bookmark')
6071 ui.write(_('bookmarks:'), label='log.bookmark')
6072 if active is not None:
6072 if active is not None:
6073 if active in marks:
6073 if active in marks:
6074 ui.write(' *' + active, label=activebookmarklabel)
6074 ui.write(' *' + active, label=activebookmarklabel)
6075 marks.remove(active)
6075 marks.remove(active)
6076 else:
6076 else:
6077 ui.write(' [%s]' % active, label=activebookmarklabel)
6077 ui.write(' [%s]' % active, label=activebookmarklabel)
6078 for m in marks:
6078 for m in marks:
6079 ui.write(' ' + m, label='log.bookmark')
6079 ui.write(' ' + m, label='log.bookmark')
6080 ui.write('\n', label='log.bookmark')
6080 ui.write('\n', label='log.bookmark')
6081
6081
6082 status = repo.status(unknown=True)
6082 status = repo.status(unknown=True)
6083
6083
6084 c = repo.dirstate.copies()
6084 c = repo.dirstate.copies()
6085 copied, renamed = [], []
6085 copied, renamed = [], []
6086 for d, s in c.iteritems():
6086 for d, s in c.iteritems():
6087 if s in status.removed:
6087 if s in status.removed:
6088 status.removed.remove(s)
6088 status.removed.remove(s)
6089 renamed.append(d)
6089 renamed.append(d)
6090 else:
6090 else:
6091 copied.append(d)
6091 copied.append(d)
6092 if d in status.added:
6092 if d in status.added:
6093 status.added.remove(d)
6093 status.added.remove(d)
6094
6094
6095 ms = mergemod.mergestate(repo)
6095 ms = mergemod.mergestate(repo)
6096 unresolved = [f for f in ms if ms[f] == 'u']
6096 unresolved = [f for f in ms if ms[f] == 'u']
6097
6097
6098 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6098 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6099
6099
6100 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6100 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6101 (ui.label(_('%d added'), 'status.added'), status.added),
6101 (ui.label(_('%d added'), 'status.added'), status.added),
6102 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6102 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6103 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6103 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6104 (ui.label(_('%d copied'), 'status.copied'), copied),
6104 (ui.label(_('%d copied'), 'status.copied'), copied),
6105 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6105 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6106 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6106 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6107 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6107 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6108 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6108 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6109 t = []
6109 t = []
6110 for l, s in labels:
6110 for l, s in labels:
6111 if s:
6111 if s:
6112 t.append(l % len(s))
6112 t.append(l % len(s))
6113
6113
6114 t = ', '.join(t)
6114 t = ', '.join(t)
6115 cleanworkdir = False
6115 cleanworkdir = False
6116
6116
6117 if repo.vfs.exists('updatestate'):
6117 if repo.vfs.exists('updatestate'):
6118 t += _(' (interrupted update)')
6118 t += _(' (interrupted update)')
6119 elif len(parents) > 1:
6119 elif len(parents) > 1:
6120 t += _(' (merge)')
6120 t += _(' (merge)')
6121 elif branch != parents[0].branch():
6121 elif branch != parents[0].branch():
6122 t += _(' (new branch)')
6122 t += _(' (new branch)')
6123 elif (parents[0].closesbranch() and
6123 elif (parents[0].closesbranch() and
6124 pnode in repo.branchheads(branch, closed=True)):
6124 pnode in repo.branchheads(branch, closed=True)):
6125 t += _(' (head closed)')
6125 t += _(' (head closed)')
6126 elif not (status.modified or status.added or status.removed or renamed or
6126 elif not (status.modified or status.added or status.removed or renamed or
6127 copied or subs):
6127 copied or subs):
6128 t += _(' (clean)')
6128 t += _(' (clean)')
6129 cleanworkdir = True
6129 cleanworkdir = True
6130 elif pnode not in bheads:
6130 elif pnode not in bheads:
6131 t += _(' (new branch head)')
6131 t += _(' (new branch head)')
6132
6132
6133 if parents:
6133 if parents:
6134 pendingphase = max(p.phase() for p in parents)
6134 pendingphase = max(p.phase() for p in parents)
6135 else:
6135 else:
6136 pendingphase = phases.public
6136 pendingphase = phases.public
6137
6137
6138 if pendingphase > phases.newcommitphase(ui):
6138 if pendingphase > phases.newcommitphase(ui):
6139 t += ' (%s)' % phases.phasenames[pendingphase]
6139 t += ' (%s)' % phases.phasenames[pendingphase]
6140
6140
6141 if cleanworkdir:
6141 if cleanworkdir:
6142 # i18n: column positioning for "hg summary"
6142 # i18n: column positioning for "hg summary"
6143 ui.status(_('commit: %s\n') % t.strip())
6143 ui.status(_('commit: %s\n') % t.strip())
6144 else:
6144 else:
6145 # i18n: column positioning for "hg summary"
6145 # i18n: column positioning for "hg summary"
6146 ui.write(_('commit: %s\n') % t.strip())
6146 ui.write(_('commit: %s\n') % t.strip())
6147
6147
6148 # all ancestors of branch heads - all ancestors of parent = new csets
6148 # all ancestors of branch heads - all ancestors of parent = new csets
6149 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6149 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6150 bheads))
6150 bheads))
6151
6151
6152 if new == 0:
6152 if new == 0:
6153 # i18n: column positioning for "hg summary"
6153 # i18n: column positioning for "hg summary"
6154 ui.status(_('update: (current)\n'))
6154 ui.status(_('update: (current)\n'))
6155 elif pnode not in bheads:
6155 elif pnode not in bheads:
6156 # i18n: column positioning for "hg summary"
6156 # i18n: column positioning for "hg summary"
6157 ui.write(_('update: %d new changesets (update)\n') % new)
6157 ui.write(_('update: %d new changesets (update)\n') % new)
6158 else:
6158 else:
6159 # i18n: column positioning for "hg summary"
6159 # i18n: column positioning for "hg summary"
6160 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6160 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6161 (new, len(bheads)))
6161 (new, len(bheads)))
6162
6162
6163 t = []
6163 t = []
6164 draft = len(repo.revs('draft()'))
6164 draft = len(repo.revs('draft()'))
6165 if draft:
6165 if draft:
6166 t.append(_('%d draft') % draft)
6166 t.append(_('%d draft') % draft)
6167 secret = len(repo.revs('secret()'))
6167 secret = len(repo.revs('secret()'))
6168 if secret:
6168 if secret:
6169 t.append(_('%d secret') % secret)
6169 t.append(_('%d secret') % secret)
6170
6170
6171 if draft or secret:
6171 if draft or secret:
6172 ui.status(_('phases: %s\n') % ', '.join(t))
6172 ui.status(_('phases: %s\n') % ', '.join(t))
6173
6173
6174 cmdutil.summaryhooks(ui, repo)
6174 cmdutil.summaryhooks(ui, repo)
6175
6175
6176 if opts.get('remote'):
6176 if opts.get('remote'):
6177 needsincoming, needsoutgoing = True, True
6177 needsincoming, needsoutgoing = True, True
6178 else:
6178 else:
6179 needsincoming, needsoutgoing = False, False
6179 needsincoming, needsoutgoing = False, False
6180 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6180 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6181 if i:
6181 if i:
6182 needsincoming = True
6182 needsincoming = True
6183 if o:
6183 if o:
6184 needsoutgoing = True
6184 needsoutgoing = True
6185 if not needsincoming and not needsoutgoing:
6185 if not needsincoming and not needsoutgoing:
6186 return
6186 return
6187
6187
6188 def getincoming():
6188 def getincoming():
6189 source, branches = hg.parseurl(ui.expandpath('default'))
6189 source, branches = hg.parseurl(ui.expandpath('default'))
6190 sbranch = branches[0]
6190 sbranch = branches[0]
6191 try:
6191 try:
6192 other = hg.peer(repo, {}, source)
6192 other = hg.peer(repo, {}, source)
6193 except error.RepoError:
6193 except error.RepoError:
6194 if opts.get('remote'):
6194 if opts.get('remote'):
6195 raise
6195 raise
6196 return source, sbranch, None, None, None
6196 return source, sbranch, None, None, None
6197 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6197 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6198 if revs:
6198 if revs:
6199 revs = [other.lookup(rev) for rev in revs]
6199 revs = [other.lookup(rev) for rev in revs]
6200 ui.debug('comparing with %s\n' % util.hidepassword(source))
6200 ui.debug('comparing with %s\n' % util.hidepassword(source))
6201 repo.ui.pushbuffer()
6201 repo.ui.pushbuffer()
6202 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6202 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6203 repo.ui.popbuffer()
6203 repo.ui.popbuffer()
6204 return source, sbranch, other, commoninc, commoninc[1]
6204 return source, sbranch, other, commoninc, commoninc[1]
6205
6205
6206 if needsincoming:
6206 if needsincoming:
6207 source, sbranch, sother, commoninc, incoming = getincoming()
6207 source, sbranch, sother, commoninc, incoming = getincoming()
6208 else:
6208 else:
6209 source = sbranch = sother = commoninc = incoming = None
6209 source = sbranch = sother = commoninc = incoming = None
6210
6210
6211 def getoutgoing():
6211 def getoutgoing():
6212 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6212 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6213 dbranch = branches[0]
6213 dbranch = branches[0]
6214 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6214 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6215 if source != dest:
6215 if source != dest:
6216 try:
6216 try:
6217 dother = hg.peer(repo, {}, dest)
6217 dother = hg.peer(repo, {}, dest)
6218 except error.RepoError:
6218 except error.RepoError:
6219 if opts.get('remote'):
6219 if opts.get('remote'):
6220 raise
6220 raise
6221 return dest, dbranch, None, None
6221 return dest, dbranch, None, None
6222 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6222 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6223 elif sother is None:
6223 elif sother is None:
6224 # there is no explicit destination peer, but source one is invalid
6224 # there is no explicit destination peer, but source one is invalid
6225 return dest, dbranch, None, None
6225 return dest, dbranch, None, None
6226 else:
6226 else:
6227 dother = sother
6227 dother = sother
6228 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6228 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6229 common = None
6229 common = None
6230 else:
6230 else:
6231 common = commoninc
6231 common = commoninc
6232 if revs:
6232 if revs:
6233 revs = [repo.lookup(rev) for rev in revs]
6233 revs = [repo.lookup(rev) for rev in revs]
6234 repo.ui.pushbuffer()
6234 repo.ui.pushbuffer()
6235 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6235 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6236 commoninc=common)
6236 commoninc=common)
6237 repo.ui.popbuffer()
6237 repo.ui.popbuffer()
6238 return dest, dbranch, dother, outgoing
6238 return dest, dbranch, dother, outgoing
6239
6239
6240 if needsoutgoing:
6240 if needsoutgoing:
6241 dest, dbranch, dother, outgoing = getoutgoing()
6241 dest, dbranch, dother, outgoing = getoutgoing()
6242 else:
6242 else:
6243 dest = dbranch = dother = outgoing = None
6243 dest = dbranch = dother = outgoing = None
6244
6244
6245 if opts.get('remote'):
6245 if opts.get('remote'):
6246 t = []
6246 t = []
6247 if incoming:
6247 if incoming:
6248 t.append(_('1 or more incoming'))
6248 t.append(_('1 or more incoming'))
6249 o = outgoing.missing
6249 o = outgoing.missing
6250 if o:
6250 if o:
6251 t.append(_('%d outgoing') % len(o))
6251 t.append(_('%d outgoing') % len(o))
6252 other = dother or sother
6252 other = dother or sother
6253 if 'bookmarks' in other.listkeys('namespaces'):
6253 if 'bookmarks' in other.listkeys('namespaces'):
6254 counts = bookmarks.summary(repo, other)
6254 counts = bookmarks.summary(repo, other)
6255 if counts[0] > 0:
6255 if counts[0] > 0:
6256 t.append(_('%d incoming bookmarks') % counts[0])
6256 t.append(_('%d incoming bookmarks') % counts[0])
6257 if counts[1] > 0:
6257 if counts[1] > 0:
6258 t.append(_('%d outgoing bookmarks') % counts[1])
6258 t.append(_('%d outgoing bookmarks') % counts[1])
6259
6259
6260 if t:
6260 if t:
6261 # i18n: column positioning for "hg summary"
6261 # i18n: column positioning for "hg summary"
6262 ui.write(_('remote: %s\n') % (', '.join(t)))
6262 ui.write(_('remote: %s\n') % (', '.join(t)))
6263 else:
6263 else:
6264 # i18n: column positioning for "hg summary"
6264 # i18n: column positioning for "hg summary"
6265 ui.status(_('remote: (synced)\n'))
6265 ui.status(_('remote: (synced)\n'))
6266
6266
6267 cmdutil.summaryremotehooks(ui, repo, opts,
6267 cmdutil.summaryremotehooks(ui, repo, opts,
6268 ((source, sbranch, sother, commoninc),
6268 ((source, sbranch, sother, commoninc),
6269 (dest, dbranch, dother, outgoing)))
6269 (dest, dbranch, dother, outgoing)))
6270
6270
6271 @command('tag',
6271 @command('tag',
6272 [('f', 'force', None, _('force tag')),
6272 [('f', 'force', None, _('force tag')),
6273 ('l', 'local', None, _('make the tag local')),
6273 ('l', 'local', None, _('make the tag local')),
6274 ('r', 'rev', '', _('revision to tag'), _('REV')),
6274 ('r', 'rev', '', _('revision to tag'), _('REV')),
6275 ('', 'remove', None, _('remove a tag')),
6275 ('', 'remove', None, _('remove a tag')),
6276 # -l/--local is already there, commitopts cannot be used
6276 # -l/--local is already there, commitopts cannot be used
6277 ('e', 'edit', None, _('invoke editor on commit messages')),
6277 ('e', 'edit', None, _('invoke editor on commit messages')),
6278 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6278 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6279 ] + commitopts2,
6279 ] + commitopts2,
6280 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6280 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6281 def tag(ui, repo, name1, *names, **opts):
6281 def tag(ui, repo, name1, *names, **opts):
6282 """add one or more tags for the current or given revision
6282 """add one or more tags for the current or given revision
6283
6283
6284 Name a particular revision using <name>.
6284 Name a particular revision using <name>.
6285
6285
6286 Tags are used to name particular revisions of the repository and are
6286 Tags are used to name particular revisions of the repository and are
6287 very useful to compare different revisions, to go back to significant
6287 very useful to compare different revisions, to go back to significant
6288 earlier versions or to mark branch points as releases, etc. Changing
6288 earlier versions or to mark branch points as releases, etc. Changing
6289 an existing tag is normally disallowed; use -f/--force to override.
6289 an existing tag is normally disallowed; use -f/--force to override.
6290
6290
6291 If no revision is given, the parent of the working directory is
6291 If no revision is given, the parent of the working directory is
6292 used.
6292 used.
6293
6293
6294 To facilitate version control, distribution, and merging of tags,
6294 To facilitate version control, distribution, and merging of tags,
6295 they are stored as a file named ".hgtags" which is managed similarly
6295 they are stored as a file named ".hgtags" which is managed similarly
6296 to other project files and can be hand-edited if necessary. This
6296 to other project files and can be hand-edited if necessary. This
6297 also means that tagging creates a new commit. The file
6297 also means that tagging creates a new commit. The file
6298 ".hg/localtags" is used for local tags (not shared among
6298 ".hg/localtags" is used for local tags (not shared among
6299 repositories).
6299 repositories).
6300
6300
6301 Tag commits are usually made at the head of a branch. If the parent
6301 Tag commits are usually made at the head of a branch. If the parent
6302 of the working directory is not a branch head, :hg:`tag` aborts; use
6302 of the working directory is not a branch head, :hg:`tag` aborts; use
6303 -f/--force to force the tag commit to be based on a non-head
6303 -f/--force to force the tag commit to be based on a non-head
6304 changeset.
6304 changeset.
6305
6305
6306 See :hg:`help dates` for a list of formats valid for -d/--date.
6306 See :hg:`help dates` for a list of formats valid for -d/--date.
6307
6307
6308 Since tag names have priority over branch names during revision
6308 Since tag names have priority over branch names during revision
6309 lookup, using an existing branch name as a tag name is discouraged.
6309 lookup, using an existing branch name as a tag name is discouraged.
6310
6310
6311 Returns 0 on success.
6311 Returns 0 on success.
6312 """
6312 """
6313 wlock = lock = None
6313 wlock = lock = None
6314 try:
6314 try:
6315 wlock = repo.wlock()
6315 wlock = repo.wlock()
6316 lock = repo.lock()
6316 lock = repo.lock()
6317 rev_ = "."
6317 rev_ = "."
6318 names = [t.strip() for t in (name1,) + names]
6318 names = [t.strip() for t in (name1,) + names]
6319 if len(names) != len(set(names)):
6319 if len(names) != len(set(names)):
6320 raise util.Abort(_('tag names must be unique'))
6320 raise util.Abort(_('tag names must be unique'))
6321 for n in names:
6321 for n in names:
6322 scmutil.checknewlabel(repo, n, 'tag')
6322 scmutil.checknewlabel(repo, n, 'tag')
6323 if not n:
6323 if not n:
6324 raise util.Abort(_('tag names cannot consist entirely of '
6324 raise util.Abort(_('tag names cannot consist entirely of '
6325 'whitespace'))
6325 'whitespace'))
6326 if opts.get('rev') and opts.get('remove'):
6326 if opts.get('rev') and opts.get('remove'):
6327 raise util.Abort(_("--rev and --remove are incompatible"))
6327 raise util.Abort(_("--rev and --remove are incompatible"))
6328 if opts.get('rev'):
6328 if opts.get('rev'):
6329 rev_ = opts['rev']
6329 rev_ = opts['rev']
6330 message = opts.get('message')
6330 message = opts.get('message')
6331 if opts.get('remove'):
6331 if opts.get('remove'):
6332 if opts.get('local'):
6332 if opts.get('local'):
6333 expectedtype = 'local'
6333 expectedtype = 'local'
6334 else:
6334 else:
6335 expectedtype = 'global'
6335 expectedtype = 'global'
6336
6336
6337 for n in names:
6337 for n in names:
6338 if not repo.tagtype(n):
6338 if not repo.tagtype(n):
6339 raise util.Abort(_("tag '%s' does not exist") % n)
6339 raise util.Abort(_("tag '%s' does not exist") % n)
6340 if repo.tagtype(n) != expectedtype:
6340 if repo.tagtype(n) != expectedtype:
6341 if expectedtype == 'global':
6341 if expectedtype == 'global':
6342 raise util.Abort(_("tag '%s' is not a global tag") % n)
6342 raise util.Abort(_("tag '%s' is not a global tag") % n)
6343 else:
6343 else:
6344 raise util.Abort(_("tag '%s' is not a local tag") % n)
6344 raise util.Abort(_("tag '%s' is not a local tag") % n)
6345 rev_ = 'null'
6345 rev_ = 'null'
6346 if not message:
6346 if not message:
6347 # we don't translate commit messages
6347 # we don't translate commit messages
6348 message = 'Removed tag %s' % ', '.join(names)
6348 message = 'Removed tag %s' % ', '.join(names)
6349 elif not opts.get('force'):
6349 elif not opts.get('force'):
6350 for n in names:
6350 for n in names:
6351 if n in repo.tags():
6351 if n in repo.tags():
6352 raise util.Abort(_("tag '%s' already exists "
6352 raise util.Abort(_("tag '%s' already exists "
6353 "(use -f to force)") % n)
6353 "(use -f to force)") % n)
6354 if not opts.get('local'):
6354 if not opts.get('local'):
6355 p1, p2 = repo.dirstate.parents()
6355 p1, p2 = repo.dirstate.parents()
6356 if p2 != nullid:
6356 if p2 != nullid:
6357 raise util.Abort(_('uncommitted merge'))
6357 raise util.Abort(_('uncommitted merge'))
6358 bheads = repo.branchheads()
6358 bheads = repo.branchheads()
6359 if not opts.get('force') and bheads and p1 not in bheads:
6359 if not opts.get('force') and bheads and p1 not in bheads:
6360 raise util.Abort(_('not at a branch head (use -f to force)'))
6360 raise util.Abort(_('not at a branch head (use -f to force)'))
6361 r = scmutil.revsingle(repo, rev_).node()
6361 r = scmutil.revsingle(repo, rev_).node()
6362
6362
6363 if not message:
6363 if not message:
6364 # we don't translate commit messages
6364 # we don't translate commit messages
6365 message = ('Added tag %s for changeset %s' %
6365 message = ('Added tag %s for changeset %s' %
6366 (', '.join(names), short(r)))
6366 (', '.join(names), short(r)))
6367
6367
6368 date = opts.get('date')
6368 date = opts.get('date')
6369 if date:
6369 if date:
6370 date = util.parsedate(date)
6370 date = util.parsedate(date)
6371
6371
6372 if opts.get('remove'):
6372 if opts.get('remove'):
6373 editform = 'tag.remove'
6373 editform = 'tag.remove'
6374 else:
6374 else:
6375 editform = 'tag.add'
6375 editform = 'tag.add'
6376 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6376 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6377
6377
6378 # don't allow tagging the null rev
6378 # don't allow tagging the null rev
6379 if (not opts.get('remove') and
6379 if (not opts.get('remove') and
6380 scmutil.revsingle(repo, rev_).rev() == nullrev):
6380 scmutil.revsingle(repo, rev_).rev() == nullrev):
6381 raise util.Abort(_("cannot tag null revision"))
6381 raise util.Abort(_("cannot tag null revision"))
6382
6382
6383 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6383 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6384 editor=editor)
6384 editor=editor)
6385 finally:
6385 finally:
6386 release(lock, wlock)
6386 release(lock, wlock)
6387
6387
6388 @command('tags', formatteropts, '')
6388 @command('tags', formatteropts, '')
6389 def tags(ui, repo, **opts):
6389 def tags(ui, repo, **opts):
6390 """list repository tags
6390 """list repository tags
6391
6391
6392 This lists both regular and local tags. When the -v/--verbose
6392 This lists both regular and local tags. When the -v/--verbose
6393 switch is used, a third column "local" is printed for local tags.
6393 switch is used, a third column "local" is printed for local tags.
6394
6394
6395 Returns 0 on success.
6395 Returns 0 on success.
6396 """
6396 """
6397
6397
6398 fm = ui.formatter('tags', opts)
6398 fm = ui.formatter('tags', opts)
6399 hexfunc = fm.hexfunc
6399 hexfunc = fm.hexfunc
6400 tagtype = ""
6400 tagtype = ""
6401
6401
6402 for t, n in reversed(repo.tagslist()):
6402 for t, n in reversed(repo.tagslist()):
6403 hn = hexfunc(n)
6403 hn = hexfunc(n)
6404 label = 'tags.normal'
6404 label = 'tags.normal'
6405 tagtype = ''
6405 tagtype = ''
6406 if repo.tagtype(t) == 'local':
6406 if repo.tagtype(t) == 'local':
6407 label = 'tags.local'
6407 label = 'tags.local'
6408 tagtype = 'local'
6408 tagtype = 'local'
6409
6409
6410 fm.startitem()
6410 fm.startitem()
6411 fm.write('tag', '%s', t, label=label)
6411 fm.write('tag', '%s', t, label=label)
6412 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6412 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6413 fm.condwrite(not ui.quiet, 'rev node', fmt,
6413 fm.condwrite(not ui.quiet, 'rev node', fmt,
6414 repo.changelog.rev(n), hn, label=label)
6414 repo.changelog.rev(n), hn, label=label)
6415 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6415 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6416 tagtype, label=label)
6416 tagtype, label=label)
6417 fm.plain('\n')
6417 fm.plain('\n')
6418 fm.end()
6418 fm.end()
6419
6419
6420 @command('tip',
6420 @command('tip',
6421 [('p', 'patch', None, _('show patch')),
6421 [('p', 'patch', None, _('show patch')),
6422 ('g', 'git', None, _('use git extended diff format')),
6422 ('g', 'git', None, _('use git extended diff format')),
6423 ] + templateopts,
6423 ] + templateopts,
6424 _('[-p] [-g]'))
6424 _('[-p] [-g]'))
6425 def tip(ui, repo, **opts):
6425 def tip(ui, repo, **opts):
6426 """show the tip revision (DEPRECATED)
6426 """show the tip revision (DEPRECATED)
6427
6427
6428 The tip revision (usually just called the tip) is the changeset
6428 The tip revision (usually just called the tip) is the changeset
6429 most recently added to the repository (and therefore the most
6429 most recently added to the repository (and therefore the most
6430 recently changed head).
6430 recently changed head).
6431
6431
6432 If you have just made a commit, that commit will be the tip. If
6432 If you have just made a commit, that commit will be the tip. If
6433 you have just pulled changes from another repository, the tip of
6433 you have just pulled changes from another repository, the tip of
6434 that repository becomes the current tip. The "tip" tag is special
6434 that repository becomes the current tip. The "tip" tag is special
6435 and cannot be renamed or assigned to a different changeset.
6435 and cannot be renamed or assigned to a different changeset.
6436
6436
6437 This command is deprecated, please use :hg:`heads` instead.
6437 This command is deprecated, please use :hg:`heads` instead.
6438
6438
6439 Returns 0 on success.
6439 Returns 0 on success.
6440 """
6440 """
6441 displayer = cmdutil.show_changeset(ui, repo, opts)
6441 displayer = cmdutil.show_changeset(ui, repo, opts)
6442 displayer.show(repo['tip'])
6442 displayer.show(repo['tip'])
6443 displayer.close()
6443 displayer.close()
6444
6444
6445 @command('unbundle',
6445 @command('unbundle',
6446 [('u', 'update', None,
6446 [('u', 'update', None,
6447 _('update to new branch head if changesets were unbundled'))],
6447 _('update to new branch head if changesets were unbundled'))],
6448 _('[-u] FILE...'))
6448 _('[-u] FILE...'))
6449 def unbundle(ui, repo, fname1, *fnames, **opts):
6449 def unbundle(ui, repo, fname1, *fnames, **opts):
6450 """apply one or more changegroup files
6450 """apply one or more changegroup files
6451
6451
6452 Apply one or more compressed changegroup files generated by the
6452 Apply one or more compressed changegroup files generated by the
6453 bundle command.
6453 bundle command.
6454
6454
6455 Returns 0 on success, 1 if an update has unresolved files.
6455 Returns 0 on success, 1 if an update has unresolved files.
6456 """
6456 """
6457 fnames = (fname1,) + fnames
6457 fnames = (fname1,) + fnames
6458
6458
6459 lock = repo.lock()
6459 lock = repo.lock()
6460 try:
6460 try:
6461 for fname in fnames:
6461 for fname in fnames:
6462 f = hg.openpath(ui, fname)
6462 f = hg.openpath(ui, fname)
6463 gen = exchange.readbundle(ui, f, fname)
6463 gen = exchange.readbundle(ui, f, fname)
6464 if isinstance(gen, bundle2.unbundle20):
6464 if isinstance(gen, bundle2.unbundle20):
6465 tr = repo.transaction('unbundle')
6465 tr = repo.transaction('unbundle')
6466 try:
6466 try:
6467 op = bundle2.processbundle(repo, gen, lambda: tr)
6467 op = bundle2.processbundle(repo, gen, lambda: tr)
6468 tr.close()
6468 tr.close()
6469 except error.BundleUnknownFeatureError as exc:
6469 except error.BundleUnknownFeatureError as exc:
6470 raise util.Abort(_('%s: unknown bundle feature, %s')
6470 raise util.Abort(_('%s: unknown bundle feature, %s')
6471 % (fname, exc),
6471 % (fname, exc),
6472 hint=_("see https://mercurial-scm.org/"
6472 hint=_("see https://mercurial-scm.org/"
6473 "wiki/BundleFeature for more "
6473 "wiki/BundleFeature for more "
6474 "information"))
6474 "information"))
6475 finally:
6475 finally:
6476 if tr:
6476 if tr:
6477 tr.release()
6477 tr.release()
6478 changes = [r.get('result', 0)
6478 changes = [r.get('return', 0)
6479 for r in op.records['changegroup']]
6479 for r in op.records['changegroup']]
6480 modheads = changegroup.combineresults(changes)
6480 modheads = changegroup.combineresults(changes)
6481 else:
6481 else:
6482 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
6482 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
6483 'bundle:' + fname)
6483 'bundle:' + fname)
6484 finally:
6484 finally:
6485 lock.release()
6485 lock.release()
6486
6486
6487 return postincoming(ui, repo, modheads, opts.get('update'), None)
6487 return postincoming(ui, repo, modheads, opts.get('update'), None)
6488
6488
6489 @command('^update|up|checkout|co',
6489 @command('^update|up|checkout|co',
6490 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6490 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6491 ('c', 'check', None,
6491 ('c', 'check', None,
6492 _('update across branches if no uncommitted changes')),
6492 _('update across branches if no uncommitted changes')),
6493 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6493 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6494 ('r', 'rev', '', _('revision'), _('REV'))
6494 ('r', 'rev', '', _('revision'), _('REV'))
6495 ] + mergetoolopts,
6495 ] + mergetoolopts,
6496 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6496 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6497 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6497 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6498 tool=None):
6498 tool=None):
6499 """update working directory (or switch revisions)
6499 """update working directory (or switch revisions)
6500
6500
6501 Update the repository's working directory to the specified
6501 Update the repository's working directory to the specified
6502 changeset. If no changeset is specified, update to the tip of the
6502 changeset. If no changeset is specified, update to the tip of the
6503 current named branch and move the active bookmark (see :hg:`help
6503 current named branch and move the active bookmark (see :hg:`help
6504 bookmarks`).
6504 bookmarks`).
6505
6505
6506 Update sets the working directory's parent revision to the specified
6506 Update sets the working directory's parent revision to the specified
6507 changeset (see :hg:`help parents`).
6507 changeset (see :hg:`help parents`).
6508
6508
6509 If the changeset is not a descendant or ancestor of the working
6509 If the changeset is not a descendant or ancestor of the working
6510 directory's parent, the update is aborted. With the -c/--check
6510 directory's parent, the update is aborted. With the -c/--check
6511 option, the working directory is checked for uncommitted changes; if
6511 option, the working directory is checked for uncommitted changes; if
6512 none are found, the working directory is updated to the specified
6512 none are found, the working directory is updated to the specified
6513 changeset.
6513 changeset.
6514
6514
6515 .. container:: verbose
6515 .. container:: verbose
6516
6516
6517 The following rules apply when the working directory contains
6517 The following rules apply when the working directory contains
6518 uncommitted changes:
6518 uncommitted changes:
6519
6519
6520 1. If neither -c/--check nor -C/--clean is specified, and if
6520 1. If neither -c/--check nor -C/--clean is specified, and if
6521 the requested changeset is an ancestor or descendant of
6521 the requested changeset is an ancestor or descendant of
6522 the working directory's parent, the uncommitted changes
6522 the working directory's parent, the uncommitted changes
6523 are merged into the requested changeset and the merged
6523 are merged into the requested changeset and the merged
6524 result is left uncommitted. If the requested changeset is
6524 result is left uncommitted. If the requested changeset is
6525 not an ancestor or descendant (that is, it is on another
6525 not an ancestor or descendant (that is, it is on another
6526 branch), the update is aborted and the uncommitted changes
6526 branch), the update is aborted and the uncommitted changes
6527 are preserved.
6527 are preserved.
6528
6528
6529 2. With the -c/--check option, the update is aborted and the
6529 2. With the -c/--check option, the update is aborted and the
6530 uncommitted changes are preserved.
6530 uncommitted changes are preserved.
6531
6531
6532 3. With the -C/--clean option, uncommitted changes are discarded and
6532 3. With the -C/--clean option, uncommitted changes are discarded and
6533 the working directory is updated to the requested changeset.
6533 the working directory is updated to the requested changeset.
6534
6534
6535 To cancel an uncommitted merge (and lose your changes), use
6535 To cancel an uncommitted merge (and lose your changes), use
6536 :hg:`update --clean .`.
6536 :hg:`update --clean .`.
6537
6537
6538 Use null as the changeset to remove the working directory (like
6538 Use null as the changeset to remove the working directory (like
6539 :hg:`clone -U`).
6539 :hg:`clone -U`).
6540
6540
6541 If you want to revert just one file to an older revision, use
6541 If you want to revert just one file to an older revision, use
6542 :hg:`revert [-r REV] NAME`.
6542 :hg:`revert [-r REV] NAME`.
6543
6543
6544 See :hg:`help dates` for a list of formats valid for -d/--date.
6544 See :hg:`help dates` for a list of formats valid for -d/--date.
6545
6545
6546 Returns 0 on success, 1 if there are unresolved files.
6546 Returns 0 on success, 1 if there are unresolved files.
6547 """
6547 """
6548 if rev and node:
6548 if rev and node:
6549 raise util.Abort(_("please specify just one revision"))
6549 raise util.Abort(_("please specify just one revision"))
6550
6550
6551 if rev is None or rev == '':
6551 if rev is None or rev == '':
6552 rev = node
6552 rev = node
6553
6553
6554 wlock = repo.wlock()
6554 wlock = repo.wlock()
6555 try:
6555 try:
6556 cmdutil.clearunfinished(repo)
6556 cmdutil.clearunfinished(repo)
6557
6557
6558 if date:
6558 if date:
6559 if rev is not None:
6559 if rev is not None:
6560 raise util.Abort(_("you can't specify a revision and a date"))
6560 raise util.Abort(_("you can't specify a revision and a date"))
6561 rev = cmdutil.finddate(ui, repo, date)
6561 rev = cmdutil.finddate(ui, repo, date)
6562
6562
6563 # with no argument, we also move the active bookmark, if any
6563 # with no argument, we also move the active bookmark, if any
6564 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
6564 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
6565
6565
6566 # if we defined a bookmark, we have to remember the original name
6566 # if we defined a bookmark, we have to remember the original name
6567 brev = rev
6567 brev = rev
6568 rev = scmutil.revsingle(repo, rev, rev).rev()
6568 rev = scmutil.revsingle(repo, rev, rev).rev()
6569
6569
6570 if check and clean:
6570 if check and clean:
6571 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6571 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
6572
6572
6573 if check:
6573 if check:
6574 cmdutil.bailifchanged(repo, merge=False)
6574 cmdutil.bailifchanged(repo, merge=False)
6575 if rev is None:
6575 if rev is None:
6576 rev = repo[repo[None].branch()].rev()
6576 rev = repo[repo[None].branch()].rev()
6577
6577
6578 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6578 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6579
6579
6580 if clean:
6580 if clean:
6581 ret = hg.clean(repo, rev)
6581 ret = hg.clean(repo, rev)
6582 else:
6582 else:
6583 ret = hg.update(repo, rev)
6583 ret = hg.update(repo, rev)
6584
6584
6585 if not ret and movemarkfrom:
6585 if not ret and movemarkfrom:
6586 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6586 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6587 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6587 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6588 else:
6588 else:
6589 # this can happen with a non-linear update
6589 # this can happen with a non-linear update
6590 ui.status(_("(leaving bookmark %s)\n") %
6590 ui.status(_("(leaving bookmark %s)\n") %
6591 repo._activebookmark)
6591 repo._activebookmark)
6592 bookmarks.deactivate(repo)
6592 bookmarks.deactivate(repo)
6593 elif brev in repo._bookmarks:
6593 elif brev in repo._bookmarks:
6594 bookmarks.activate(repo, brev)
6594 bookmarks.activate(repo, brev)
6595 ui.status(_("(activating bookmark %s)\n") % brev)
6595 ui.status(_("(activating bookmark %s)\n") % brev)
6596 elif brev:
6596 elif brev:
6597 if repo._activebookmark:
6597 if repo._activebookmark:
6598 ui.status(_("(leaving bookmark %s)\n") %
6598 ui.status(_("(leaving bookmark %s)\n") %
6599 repo._activebookmark)
6599 repo._activebookmark)
6600 bookmarks.deactivate(repo)
6600 bookmarks.deactivate(repo)
6601 finally:
6601 finally:
6602 wlock.release()
6602 wlock.release()
6603
6603
6604 return ret
6604 return ret
6605
6605
6606 @command('verify', [])
6606 @command('verify', [])
6607 def verify(ui, repo):
6607 def verify(ui, repo):
6608 """verify the integrity of the repository
6608 """verify the integrity of the repository
6609
6609
6610 Verify the integrity of the current repository.
6610 Verify the integrity of the current repository.
6611
6611
6612 This will perform an extensive check of the repository's
6612 This will perform an extensive check of the repository's
6613 integrity, validating the hashes and checksums of each entry in
6613 integrity, validating the hashes and checksums of each entry in
6614 the changelog, manifest, and tracked files, as well as the
6614 the changelog, manifest, and tracked files, as well as the
6615 integrity of their crosslinks and indices.
6615 integrity of their crosslinks and indices.
6616
6616
6617 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6617 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6618 for more information about recovery from corruption of the
6618 for more information about recovery from corruption of the
6619 repository.
6619 repository.
6620
6620
6621 Returns 0 on success, 1 if errors are encountered.
6621 Returns 0 on success, 1 if errors are encountered.
6622 """
6622 """
6623 return hg.verify(repo)
6623 return hg.verify(repo)
6624
6624
6625 @command('version', [], norepo=True)
6625 @command('version', [], norepo=True)
6626 def version_(ui):
6626 def version_(ui):
6627 """output version and copyright information"""
6627 """output version and copyright information"""
6628 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6628 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6629 % util.version())
6629 % util.version())
6630 ui.status(_(
6630 ui.status(_(
6631 "(see https://mercurial-scm.org for more information)\n"
6631 "(see https://mercurial-scm.org for more information)\n"
6632 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6632 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6633 "This is free software; see the source for copying conditions. "
6633 "This is free software; see the source for copying conditions. "
6634 "There is NO\nwarranty; "
6634 "There is NO\nwarranty; "
6635 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6635 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6636 ))
6636 ))
6637
6637
6638 ui.note(_("\nEnabled extensions:\n\n"))
6638 ui.note(_("\nEnabled extensions:\n\n"))
6639 if ui.verbose:
6639 if ui.verbose:
6640 # format names and versions into columns
6640 # format names and versions into columns
6641 names = []
6641 names = []
6642 vers = []
6642 vers = []
6643 for name, module in extensions.extensions():
6643 for name, module in extensions.extensions():
6644 names.append(name)
6644 names.append(name)
6645 vers.append(extensions.moduleversion(module))
6645 vers.append(extensions.moduleversion(module))
6646 if names:
6646 if names:
6647 maxnamelen = max(len(n) for n in names)
6647 maxnamelen = max(len(n) for n in names)
6648 for i, name in enumerate(names):
6648 for i, name in enumerate(names):
6649 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
6649 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
@@ -1,1227 +1,1230 b''
1 This test is dedicated to test the bundle2 container format
1 This test is dedicated to test the bundle2 container format
2
2
3 It test multiple existing parts to test different feature of the container. You
3 It test multiple existing parts to test different feature of the container. You
4 probably do not need to touch this test unless you change the binary encoding
4 probably do not need to touch this test unless you change the binary encoding
5 of the bundle2 format itself.
5 of the bundle2 format itself.
6
6
7 Create an extension to test bundle2 API
7 Create an extension to test bundle2 API
8
8
9 $ cat > bundle2.py << EOF
9 $ cat > bundle2.py << EOF
10 > """A small extension to test bundle2 implementation
10 > """A small extension to test bundle2 implementation
11 >
11 >
12 > Current bundle2 implementation is far too limited to be used in any core
12 > Current bundle2 implementation is far too limited to be used in any core
13 > code. We still need to be able to test it while it grow up.
13 > code. We still need to be able to test it while it grow up.
14 > """
14 > """
15 >
15 >
16 > import sys, os
16 > import sys, os
17 > from mercurial import cmdutil
17 > from mercurial import cmdutil
18 > from mercurial import util
18 > from mercurial import util
19 > from mercurial import bundle2
19 > from mercurial import bundle2
20 > from mercurial import scmutil
20 > from mercurial import scmutil
21 > from mercurial import discovery
21 > from mercurial import discovery
22 > from mercurial import changegroup
22 > from mercurial import changegroup
23 > from mercurial import error
23 > from mercurial import error
24 > from mercurial import obsolete
24 > from mercurial import obsolete
25 >
25 >
26 >
26 >
27 > try:
27 > try:
28 > import msvcrt
28 > import msvcrt
29 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
29 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
30 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
30 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
31 > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
31 > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
32 > except ImportError:
32 > except ImportError:
33 > pass
33 > pass
34 >
34 >
35 > cmdtable = {}
35 > cmdtable = {}
36 > command = cmdutil.command(cmdtable)
36 > command = cmdutil.command(cmdtable)
37 >
37 >
38 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
38 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
39 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
39 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
40 > Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko."""
40 > Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko."""
41 > assert len(ELEPHANTSSONG) == 178 # future test say 178 bytes, trust it.
41 > assert len(ELEPHANTSSONG) == 178 # future test say 178 bytes, trust it.
42 >
42 >
43 > @bundle2.parthandler('test:song')
43 > @bundle2.parthandler('test:song')
44 > def songhandler(op, part):
44 > def songhandler(op, part):
45 > """handle a "test:song" bundle2 part, printing the lyrics on stdin"""
45 > """handle a "test:song" bundle2 part, printing the lyrics on stdin"""
46 > op.ui.write('The choir starts singing:\n')
46 > op.ui.write('The choir starts singing:\n')
47 > verses = 0
47 > verses = 0
48 > for line in part.read().split('\n'):
48 > for line in part.read().split('\n'):
49 > op.ui.write(' %s\n' % line)
49 > op.ui.write(' %s\n' % line)
50 > verses += 1
50 > verses += 1
51 > op.records.add('song', {'verses': verses})
51 > op.records.add('song', {'verses': verses})
52 >
52 >
53 > @bundle2.parthandler('test:ping')
53 > @bundle2.parthandler('test:ping')
54 > def pinghandler(op, part):
54 > def pinghandler(op, part):
55 > op.ui.write('received ping request (id %i)\n' % part.id)
55 > op.ui.write('received ping request (id %i)\n' % part.id)
56 > if op.reply is not None and 'ping-pong' in op.reply.capabilities:
56 > if op.reply is not None and 'ping-pong' in op.reply.capabilities:
57 > op.ui.write_err('replying to ping request (id %i)\n' % part.id)
57 > op.ui.write_err('replying to ping request (id %i)\n' % part.id)
58 > op.reply.newpart('test:pong', [('in-reply-to', str(part.id))],
58 > op.reply.newpart('test:pong', [('in-reply-to', str(part.id))],
59 > mandatory=False)
59 > mandatory=False)
60 >
60 >
61 > @bundle2.parthandler('test:debugreply')
61 > @bundle2.parthandler('test:debugreply')
62 > def debugreply(op, part):
62 > def debugreply(op, part):
63 > """print data about the capacity of the bundle reply"""
63 > """print data about the capacity of the bundle reply"""
64 > if op.reply is None:
64 > if op.reply is None:
65 > op.ui.write('debugreply: no reply\n')
65 > op.ui.write('debugreply: no reply\n')
66 > else:
66 > else:
67 > op.ui.write('debugreply: capabilities:\n')
67 > op.ui.write('debugreply: capabilities:\n')
68 > for cap in sorted(op.reply.capabilities):
68 > for cap in sorted(op.reply.capabilities):
69 > op.ui.write('debugreply: %r\n' % cap)
69 > op.ui.write('debugreply: %r\n' % cap)
70 > for val in op.reply.capabilities[cap]:
70 > for val in op.reply.capabilities[cap]:
71 > op.ui.write('debugreply: %r\n' % val)
71 > op.ui.write('debugreply: %r\n' % val)
72 >
72 >
73 > @command('bundle2',
73 > @command('bundle2',
74 > [('', 'param', [], 'stream level parameter'),
74 > [('', 'param', [], 'stream level parameter'),
75 > ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
75 > ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
76 > ('', 'unknownparams', False, 'include an unknown part parameters in the bundle'),
76 > ('', 'unknownparams', False, 'include an unknown part parameters in the bundle'),
77 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),
77 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),
78 > ('', 'reply', False, 'produce a reply bundle'),
78 > ('', 'reply', False, 'produce a reply bundle'),
79 > ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
79 > ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
80 > ('', 'genraise', False, 'includes a part that raise an exception during generation'),
80 > ('', 'genraise', False, 'includes a part that raise an exception during generation'),
81 > ('', 'timeout', False, 'emulate a timeout during bundle generation'),
81 > ('', 'timeout', False, 'emulate a timeout during bundle generation'),
82 > ('r', 'rev', [], 'includes those changeset in the bundle'),
82 > ('r', 'rev', [], 'includes those changeset in the bundle'),
83 > ('', 'compress', '', 'compress the stream'),],
83 > ('', 'compress', '', 'compress the stream'),],
84 > '[OUTPUTFILE]')
84 > '[OUTPUTFILE]')
85 > def cmdbundle2(ui, repo, path=None, **opts):
85 > def cmdbundle2(ui, repo, path=None, **opts):
86 > """write a bundle2 container on standard output"""
86 > """write a bundle2 container on standard output"""
87 > bundler = bundle2.bundle20(ui)
87 > bundler = bundle2.bundle20(ui)
88 > for p in opts['param']:
88 > for p in opts['param']:
89 > p = p.split('=', 1)
89 > p = p.split('=', 1)
90 > try:
90 > try:
91 > bundler.addparam(*p)
91 > bundler.addparam(*p)
92 > except ValueError, exc:
92 > except ValueError, exc:
93 > raise util.Abort('%s' % exc)
93 > raise util.Abort('%s' % exc)
94 >
94 >
95 > if opts['compress']:
95 > if opts['compress']:
96 > bundler.setcompression(opts['compress'])
96 > bundler.setcompression(opts['compress'])
97 >
97 >
98 > if opts['reply']:
98 > if opts['reply']:
99 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
99 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
100 > bundler.newpart('replycaps', data=capsstring)
100 > bundler.newpart('replycaps', data=capsstring)
101 >
101 >
102 > if opts['pushrace']:
102 > if opts['pushrace']:
103 > # also serve to test the assignement of data outside of init
103 > # also serve to test the assignement of data outside of init
104 > part = bundler.newpart('check:heads')
104 > part = bundler.newpart('check:heads')
105 > part.data = '01234567890123456789'
105 > part.data = '01234567890123456789'
106 >
106 >
107 > revs = opts['rev']
107 > revs = opts['rev']
108 > if 'rev' in opts:
108 > if 'rev' in opts:
109 > revs = scmutil.revrange(repo, opts['rev'])
109 > revs = scmutil.revrange(repo, opts['rev'])
110 > if revs:
110 > if revs:
111 > # very crude version of a changegroup part creation
111 > # very crude version of a changegroup part creation
112 > bundled = repo.revs('%ld::%ld', revs, revs)
112 > bundled = repo.revs('%ld::%ld', revs, revs)
113 > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)]
113 > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)]
114 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
114 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
115 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
115 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
116 > cg = changegroup.getlocalchangegroup(repo, 'test:bundle2', outgoing, None)
116 > cg = changegroup.getlocalchangegroup(repo, 'test:bundle2', outgoing, None)
117 > bundler.newpart('changegroup', data=cg.getchunks(),
117 > bundler.newpart('changegroup', data=cg.getchunks(),
118 > mandatory=False)
118 > mandatory=False)
119 >
119 >
120 > if opts['parts']:
120 > if opts['parts']:
121 > bundler.newpart('test:empty', mandatory=False)
121 > bundler.newpart('test:empty', mandatory=False)
122 > # add a second one to make sure we handle multiple parts
122 > # add a second one to make sure we handle multiple parts
123 > bundler.newpart('test:empty', mandatory=False)
123 > bundler.newpart('test:empty', mandatory=False)
124 > bundler.newpart('test:song', data=ELEPHANTSSONG, mandatory=False)
124 > bundler.newpart('test:song', data=ELEPHANTSSONG, mandatory=False)
125 > bundler.newpart('test:debugreply', mandatory=False)
125 > bundler.newpart('test:debugreply', mandatory=False)
126 > mathpart = bundler.newpart('test:math')
126 > mathpart = bundler.newpart('test:math')
127 > mathpart.addparam('pi', '3.14')
127 > mathpart.addparam('pi', '3.14')
128 > mathpart.addparam('e', '2.72')
128 > mathpart.addparam('e', '2.72')
129 > mathpart.addparam('cooking', 'raw', mandatory=False)
129 > mathpart.addparam('cooking', 'raw', mandatory=False)
130 > mathpart.data = '42'
130 > mathpart.data = '42'
131 > mathpart.mandatory = False
131 > mathpart.mandatory = False
132 > # advisory known part with unknown mandatory param
132 > # advisory known part with unknown mandatory param
133 > bundler.newpart('test:song', [('randomparam','')], mandatory=False)
133 > bundler.newpart('test:song', [('randomparam','')], mandatory=False)
134 > if opts['unknown']:
134 > if opts['unknown']:
135 > bundler.newpart('test:unknown', data='some random content')
135 > bundler.newpart('test:unknown', data='some random content')
136 > if opts['unknownparams']:
136 > if opts['unknownparams']:
137 > bundler.newpart('test:song', [('randomparams', '')])
137 > bundler.newpart('test:song', [('randomparams', '')])
138 > if opts['parts']:
138 > if opts['parts']:
139 > bundler.newpart('test:ping', mandatory=False)
139 > bundler.newpart('test:ping', mandatory=False)
140 > if opts['genraise']:
140 > if opts['genraise']:
141 > def genraise():
141 > def genraise():
142 > yield 'first line\n'
142 > yield 'first line\n'
143 > raise RuntimeError('Someone set up us the bomb!')
143 > raise RuntimeError('Someone set up us the bomb!')
144 > bundler.newpart('output', data=genraise(), mandatory=False)
144 > bundler.newpart('output', data=genraise(), mandatory=False)
145 >
145 >
146 > if path is None:
146 > if path is None:
147 > file = sys.stdout
147 > file = sys.stdout
148 > else:
148 > else:
149 > file = open(path, 'wb')
149 > file = open(path, 'wb')
150 >
150 >
151 > if opts['timeout']:
151 > if opts['timeout']:
152 > bundler.newpart('test:song', data=ELEPHANTSSONG, mandatory=False)
152 > bundler.newpart('test:song', data=ELEPHANTSSONG, mandatory=False)
153 > for idx, junk in enumerate(bundler.getchunks()):
153 > for idx, junk in enumerate(bundler.getchunks()):
154 > ui.write('%d chunk\n' % idx)
154 > ui.write('%d chunk\n' % idx)
155 > if idx > 4:
155 > if idx > 4:
156 > # This throws a GeneratorExit inside the generator, which
156 > # This throws a GeneratorExit inside the generator, which
157 > # can cause problems if the exception-recovery code is
157 > # can cause problems if the exception-recovery code is
158 > # too zealous. It's important for this test that the break
158 > # too zealous. It's important for this test that the break
159 > # occur while we're in the middle of a part.
159 > # occur while we're in the middle of a part.
160 > break
160 > break
161 > ui.write('fake timeout complete.\n')
161 > ui.write('fake timeout complete.\n')
162 > return
162 > return
163 > try:
163 > try:
164 > for chunk in bundler.getchunks():
164 > for chunk in bundler.getchunks():
165 > file.write(chunk)
165 > file.write(chunk)
166 > except RuntimeError, exc:
166 > except RuntimeError, exc:
167 > raise util.Abort(exc)
167 > raise util.Abort(exc)
168 >
168 >
169 > @command('unbundle2', [], '')
169 > @command('unbundle2', [], '')
170 > def cmdunbundle2(ui, repo, replypath=None):
170 > def cmdunbundle2(ui, repo, replypath=None):
171 > """process a bundle2 stream from stdin on the current repo"""
171 > """process a bundle2 stream from stdin on the current repo"""
172 > try:
172 > try:
173 > tr = None
173 > tr = None
174 > lock = repo.lock()
174 > lock = repo.lock()
175 > tr = repo.transaction('processbundle')
175 > tr = repo.transaction('processbundle')
176 > try:
176 > try:
177 > unbundler = bundle2.getunbundler(ui, sys.stdin)
177 > unbundler = bundle2.getunbundler(ui, sys.stdin)
178 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
178 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
179 > tr.close()
179 > tr.close()
180 > except error.BundleValueError, exc:
180 > except error.BundleValueError, exc:
181 > raise util.Abort('missing support for %s' % exc)
181 > raise util.Abort('missing support for %s' % exc)
182 > except error.PushRaced, exc:
182 > except error.PushRaced, exc:
183 > raise util.Abort('push race: %s' % exc)
183 > raise util.Abort('push race: %s' % exc)
184 > finally:
184 > finally:
185 > if tr is not None:
185 > if tr is not None:
186 > tr.release()
186 > tr.release()
187 > lock.release()
187 > lock.release()
188 > remains = sys.stdin.read()
188 > remains = sys.stdin.read()
189 > ui.write('%i unread bytes\n' % len(remains))
189 > ui.write('%i unread bytes\n' % len(remains))
190 > if op.records['song']:
190 > if op.records['song']:
191 > totalverses = sum(r['verses'] for r in op.records['song'])
191 > totalverses = sum(r['verses'] for r in op.records['song'])
192 > ui.write('%i total verses sung\n' % totalverses)
192 > ui.write('%i total verses sung\n' % totalverses)
193 > for rec in op.records['changegroup']:
193 > for rec in op.records['changegroup']:
194 > ui.write('addchangegroup return: %i\n' % rec['return'])
194 > ui.write('addchangegroup return: %i\n' % rec['return'])
195 > if op.reply is not None and replypath is not None:
195 > if op.reply is not None and replypath is not None:
196 > file = open(replypath, 'wb')
196 > file = open(replypath, 'wb')
197 > for chunk in op.reply.getchunks():
197 > for chunk in op.reply.getchunks():
198 > file.write(chunk)
198 > file.write(chunk)
199 >
199 >
200 > @command('statbundle2', [], '')
200 > @command('statbundle2', [], '')
201 > def cmdstatbundle2(ui, repo):
201 > def cmdstatbundle2(ui, repo):
202 > """print statistic on the bundle2 container read from stdin"""
202 > """print statistic on the bundle2 container read from stdin"""
203 > unbundler = bundle2.getunbundler(ui, sys.stdin)
203 > unbundler = bundle2.getunbundler(ui, sys.stdin)
204 > try:
204 > try:
205 > params = unbundler.params
205 > params = unbundler.params
206 > except error.BundleValueError, exc:
206 > except error.BundleValueError, exc:
207 > raise util.Abort('unknown parameters: %s' % exc)
207 > raise util.Abort('unknown parameters: %s' % exc)
208 > ui.write('options count: %i\n' % len(params))
208 > ui.write('options count: %i\n' % len(params))
209 > for key in sorted(params):
209 > for key in sorted(params):
210 > ui.write('- %s\n' % key)
210 > ui.write('- %s\n' % key)
211 > value = params[key]
211 > value = params[key]
212 > if value is not None:
212 > if value is not None:
213 > ui.write(' %s\n' % value)
213 > ui.write(' %s\n' % value)
214 > count = 0
214 > count = 0
215 > for p in unbundler.iterparts():
215 > for p in unbundler.iterparts():
216 > count += 1
216 > count += 1
217 > ui.write(' :%s:\n' % p.type)
217 > ui.write(' :%s:\n' % p.type)
218 > ui.write(' mandatory: %i\n' % len(p.mandatoryparams))
218 > ui.write(' mandatory: %i\n' % len(p.mandatoryparams))
219 > ui.write(' advisory: %i\n' % len(p.advisoryparams))
219 > ui.write(' advisory: %i\n' % len(p.advisoryparams))
220 > ui.write(' payload: %i bytes\n' % len(p.read()))
220 > ui.write(' payload: %i bytes\n' % len(p.read()))
221 > ui.write('parts count: %i\n' % count)
221 > ui.write('parts count: %i\n' % count)
222 > EOF
222 > EOF
223 $ cat >> $HGRCPATH << EOF
223 $ cat >> $HGRCPATH << EOF
224 > [extensions]
224 > [extensions]
225 > bundle2=$TESTTMP/bundle2.py
225 > bundle2=$TESTTMP/bundle2.py
226 > [experimental]
226 > [experimental]
227 > bundle2-exp=True
227 > bundle2-exp=True
228 > evolution=createmarkers
228 > evolution=createmarkers
229 > [ui]
229 > [ui]
230 > ssh=python "$TESTDIR/dummyssh"
230 > ssh=python "$TESTDIR/dummyssh"
231 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
231 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
232 > [web]
232 > [web]
233 > push_ssl = false
233 > push_ssl = false
234 > allow_push = *
234 > allow_push = *
235 > [phases]
235 > [phases]
236 > publish=False
236 > publish=False
237 > EOF
237 > EOF
238
238
239 The extension requires a repo (currently unused)
239 The extension requires a repo (currently unused)
240
240
241 $ hg init main
241 $ hg init main
242 $ cd main
242 $ cd main
243 $ touch a
243 $ touch a
244 $ hg add a
244 $ hg add a
245 $ hg commit -m 'a'
245 $ hg commit -m 'a'
246
246
247
247
248 Empty bundle
248 Empty bundle
249 =================
249 =================
250
250
251 - no option
251 - no option
252 - no parts
252 - no parts
253
253
254 Test bundling
254 Test bundling
255
255
256 $ hg bundle2 | f --hexdump
256 $ hg bundle2 | f --hexdump
257
257
258 0000: 48 47 32 30 00 00 00 00 00 00 00 00 |HG20........|
258 0000: 48 47 32 30 00 00 00 00 00 00 00 00 |HG20........|
259
259
260 Test timeouts during bundling
260 Test timeouts during bundling
261 $ hg bundle2 --timeout --debug --config devel.bundle2.debug=yes
261 $ hg bundle2 --timeout --debug --config devel.bundle2.debug=yes
262 bundle2-output-bundle: "HG20", 1 parts total
262 bundle2-output-bundle: "HG20", 1 parts total
263 bundle2-output: start emission of HG20 stream
263 bundle2-output: start emission of HG20 stream
264 0 chunk
264 0 chunk
265 bundle2-output: bundle parameter:
265 bundle2-output: bundle parameter:
266 1 chunk
266 1 chunk
267 bundle2-output: start of parts
267 bundle2-output: start of parts
268 bundle2-output: bundle part: "test:song"
268 bundle2-output: bundle part: "test:song"
269 bundle2-output-part: "test:song" (advisory) 178 bytes payload
269 bundle2-output-part: "test:song" (advisory) 178 bytes payload
270 bundle2-output: part 0: "test:song"
270 bundle2-output: part 0: "test:song"
271 bundle2-output: header chunk size: 16
271 bundle2-output: header chunk size: 16
272 2 chunk
272 2 chunk
273 3 chunk
273 3 chunk
274 bundle2-output: payload chunk size: 178
274 bundle2-output: payload chunk size: 178
275 4 chunk
275 4 chunk
276 5 chunk
276 5 chunk
277 bundle2-generatorexit
277 bundle2-generatorexit
278 fake timeout complete.
278 fake timeout complete.
279
279
280 Test unbundling
280 Test unbundling
281
281
282 $ hg bundle2 | hg statbundle2
282 $ hg bundle2 | hg statbundle2
283 options count: 0
283 options count: 0
284 parts count: 0
284 parts count: 0
285
285
286 Test old style bundle are detected and refused
286 Test old style bundle are detected and refused
287
287
288 $ hg bundle --all ../bundle.hg
288 $ hg bundle --all ../bundle.hg
289 1 changesets found
289 1 changesets found
290 $ hg statbundle2 < ../bundle.hg
290 $ hg statbundle2 < ../bundle.hg
291 abort: unknown bundle version 10
291 abort: unknown bundle version 10
292 [255]
292 [255]
293
293
294 Test parameters
294 Test parameters
295 =================
295 =================
296
296
297 - some options
297 - some options
298 - no parts
298 - no parts
299
299
300 advisory parameters, no value
300 advisory parameters, no value
301 -------------------------------
301 -------------------------------
302
302
303 Simplest possible parameters form
303 Simplest possible parameters form
304
304
305 Test generation simple option
305 Test generation simple option
306
306
307 $ hg bundle2 --param 'caution' | f --hexdump
307 $ hg bundle2 --param 'caution' | f --hexdump
308
308
309 0000: 48 47 32 30 00 00 00 07 63 61 75 74 69 6f 6e 00 |HG20....caution.|
309 0000: 48 47 32 30 00 00 00 07 63 61 75 74 69 6f 6e 00 |HG20....caution.|
310 0010: 00 00 00 |...|
310 0010: 00 00 00 |...|
311
311
312 Test unbundling
312 Test unbundling
313
313
314 $ hg bundle2 --param 'caution' | hg statbundle2
314 $ hg bundle2 --param 'caution' | hg statbundle2
315 options count: 1
315 options count: 1
316 - caution
316 - caution
317 parts count: 0
317 parts count: 0
318
318
319 Test generation multiple option
319 Test generation multiple option
320
320
321 $ hg bundle2 --param 'caution' --param 'meal' | f --hexdump
321 $ hg bundle2 --param 'caution' --param 'meal' | f --hexdump
322
322
323 0000: 48 47 32 30 00 00 00 0c 63 61 75 74 69 6f 6e 20 |HG20....caution |
323 0000: 48 47 32 30 00 00 00 0c 63 61 75 74 69 6f 6e 20 |HG20....caution |
324 0010: 6d 65 61 6c 00 00 00 00 |meal....|
324 0010: 6d 65 61 6c 00 00 00 00 |meal....|
325
325
326 Test unbundling
326 Test unbundling
327
327
328 $ hg bundle2 --param 'caution' --param 'meal' | hg statbundle2
328 $ hg bundle2 --param 'caution' --param 'meal' | hg statbundle2
329 options count: 2
329 options count: 2
330 - caution
330 - caution
331 - meal
331 - meal
332 parts count: 0
332 parts count: 0
333
333
334 advisory parameters, with value
334 advisory parameters, with value
335 -------------------------------
335 -------------------------------
336
336
337 Test generation
337 Test generation
338
338
339 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | f --hexdump
339 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | f --hexdump
340
340
341 0000: 48 47 32 30 00 00 00 1c 63 61 75 74 69 6f 6e 20 |HG20....caution |
341 0000: 48 47 32 30 00 00 00 1c 63 61 75 74 69 6f 6e 20 |HG20....caution |
342 0010: 6d 65 61 6c 3d 76 65 67 61 6e 20 65 6c 65 70 68 |meal=vegan eleph|
342 0010: 6d 65 61 6c 3d 76 65 67 61 6e 20 65 6c 65 70 68 |meal=vegan eleph|
343 0020: 61 6e 74 73 00 00 00 00 |ants....|
343 0020: 61 6e 74 73 00 00 00 00 |ants....|
344
344
345 Test unbundling
345 Test unbundling
346
346
347 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg statbundle2
347 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg statbundle2
348 options count: 3
348 options count: 3
349 - caution
349 - caution
350 - elephants
350 - elephants
351 - meal
351 - meal
352 vegan
352 vegan
353 parts count: 0
353 parts count: 0
354
354
355 parameter with special char in value
355 parameter with special char in value
356 ---------------------------------------------------
356 ---------------------------------------------------
357
357
358 Test generation
358 Test generation
359
359
360 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | f --hexdump
360 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | f --hexdump
361
361
362 0000: 48 47 32 30 00 00 00 29 65 25 37 43 25 32 31 25 |HG20...)e%7C%21%|
362 0000: 48 47 32 30 00 00 00 29 65 25 37 43 25 32 31 25 |HG20...)e%7C%21%|
363 0010: 32 30 37 2f 3d 62 61 62 61 72 25 32 35 25 32 33 |207/=babar%25%23|
363 0010: 32 30 37 2f 3d 62 61 62 61 72 25 32 35 25 32 33 |207/=babar%25%23|
364 0020: 25 33 44 25 33 44 74 75 74 75 20 73 69 6d 70 6c |%3D%3Dtutu simpl|
364 0020: 25 33 44 25 33 44 74 75 74 75 20 73 69 6d 70 6c |%3D%3Dtutu simpl|
365 0030: 65 00 00 00 00 |e....|
365 0030: 65 00 00 00 00 |e....|
366
366
367 Test unbundling
367 Test unbundling
368
368
369 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | hg statbundle2
369 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | hg statbundle2
370 options count: 2
370 options count: 2
371 - e|! 7/
371 - e|! 7/
372 babar%#==tutu
372 babar%#==tutu
373 - simple
373 - simple
374 parts count: 0
374 parts count: 0
375
375
376 Test unknown mandatory option
376 Test unknown mandatory option
377 ---------------------------------------------------
377 ---------------------------------------------------
378
378
379 $ hg bundle2 --param 'Gravity' | hg statbundle2
379 $ hg bundle2 --param 'Gravity' | hg statbundle2
380 abort: unknown parameters: Stream Parameter - Gravity
380 abort: unknown parameters: Stream Parameter - Gravity
381 [255]
381 [255]
382
382
383 Test debug output
383 Test debug output
384 ---------------------------------------------------
384 ---------------------------------------------------
385
385
386 bundling debug
386 bundling debug
387
387
388 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2 --config progress.debug=true --config devel.bundle2.debug=true
388 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2 --config progress.debug=true --config devel.bundle2.debug=true
389 bundle2-output-bundle: "HG20", (2 params) 0 parts total
389 bundle2-output-bundle: "HG20", (2 params) 0 parts total
390 bundle2-output: start emission of HG20 stream
390 bundle2-output: start emission of HG20 stream
391 bundle2-output: bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
391 bundle2-output: bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
392 bundle2-output: start of parts
392 bundle2-output: start of parts
393 bundle2-output: end of bundle
393 bundle2-output: end of bundle
394
394
395 file content is ok
395 file content is ok
396
396
397 $ f --hexdump ../out.hg2
397 $ f --hexdump ../out.hg2
398 ../out.hg2:
398 ../out.hg2:
399 0000: 48 47 32 30 00 00 00 29 65 25 37 43 25 32 31 25 |HG20...)e%7C%21%|
399 0000: 48 47 32 30 00 00 00 29 65 25 37 43 25 32 31 25 |HG20...)e%7C%21%|
400 0010: 32 30 37 2f 3d 62 61 62 61 72 25 32 35 25 32 33 |207/=babar%25%23|
400 0010: 32 30 37 2f 3d 62 61 62 61 72 25 32 35 25 32 33 |207/=babar%25%23|
401 0020: 25 33 44 25 33 44 74 75 74 75 20 73 69 6d 70 6c |%3D%3Dtutu simpl|
401 0020: 25 33 44 25 33 44 74 75 74 75 20 73 69 6d 70 6c |%3D%3Dtutu simpl|
402 0030: 65 00 00 00 00 |e....|
402 0030: 65 00 00 00 00 |e....|
403
403
404 unbundling debug
404 unbundling debug
405
405
406 $ hg statbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../out.hg2
406 $ hg statbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../out.hg2
407 bundle2-input: start processing of HG20 stream
407 bundle2-input: start processing of HG20 stream
408 bundle2-input: reading bundle2 stream parameters
408 bundle2-input: reading bundle2 stream parameters
409 bundle2-input: ignoring unknown parameter 'e|! 7/'
409 bundle2-input: ignoring unknown parameter 'e|! 7/'
410 bundle2-input: ignoring unknown parameter 'simple'
410 bundle2-input: ignoring unknown parameter 'simple'
411 options count: 2
411 options count: 2
412 - e|! 7/
412 - e|! 7/
413 babar%#==tutu
413 babar%#==tutu
414 - simple
414 - simple
415 bundle2-input: start extraction of bundle2 parts
415 bundle2-input: start extraction of bundle2 parts
416 bundle2-input: part header size: 0
416 bundle2-input: part header size: 0
417 bundle2-input: end of bundle2 stream
417 bundle2-input: end of bundle2 stream
418 parts count: 0
418 parts count: 0
419
419
420
420
421 Test buggy input
421 Test buggy input
422 ---------------------------------------------------
422 ---------------------------------------------------
423
423
424 empty parameter name
424 empty parameter name
425
425
426 $ hg bundle2 --param '' --quiet
426 $ hg bundle2 --param '' --quiet
427 abort: empty parameter name
427 abort: empty parameter name
428 [255]
428 [255]
429
429
430 bad parameter name
430 bad parameter name
431
431
432 $ hg bundle2 --param 42babar
432 $ hg bundle2 --param 42babar
433 abort: non letter first character: '42babar'
433 abort: non letter first character: '42babar'
434 [255]
434 [255]
435
435
436
436
437 Test part
437 Test part
438 =================
438 =================
439
439
440 $ hg bundle2 --parts ../parts.hg2 --debug --config progress.debug=true --config devel.bundle2.debug=true
440 $ hg bundle2 --parts ../parts.hg2 --debug --config progress.debug=true --config devel.bundle2.debug=true
441 bundle2-output-bundle: "HG20", 7 parts total
441 bundle2-output-bundle: "HG20", 7 parts total
442 bundle2-output: start emission of HG20 stream
442 bundle2-output: start emission of HG20 stream
443 bundle2-output: bundle parameter:
443 bundle2-output: bundle parameter:
444 bundle2-output: start of parts
444 bundle2-output: start of parts
445 bundle2-output: bundle part: "test:empty"
445 bundle2-output: bundle part: "test:empty"
446 bundle2-output-part: "test:empty" (advisory) empty payload
446 bundle2-output-part: "test:empty" (advisory) empty payload
447 bundle2-output: part 0: "test:empty"
447 bundle2-output: part 0: "test:empty"
448 bundle2-output: header chunk size: 17
448 bundle2-output: header chunk size: 17
449 bundle2-output: closing payload chunk
449 bundle2-output: closing payload chunk
450 bundle2-output: bundle part: "test:empty"
450 bundle2-output: bundle part: "test:empty"
451 bundle2-output-part: "test:empty" (advisory) empty payload
451 bundle2-output-part: "test:empty" (advisory) empty payload
452 bundle2-output: part 1: "test:empty"
452 bundle2-output: part 1: "test:empty"
453 bundle2-output: header chunk size: 17
453 bundle2-output: header chunk size: 17
454 bundle2-output: closing payload chunk
454 bundle2-output: closing payload chunk
455 bundle2-output: bundle part: "test:song"
455 bundle2-output: bundle part: "test:song"
456 bundle2-output-part: "test:song" (advisory) 178 bytes payload
456 bundle2-output-part: "test:song" (advisory) 178 bytes payload
457 bundle2-output: part 2: "test:song"
457 bundle2-output: part 2: "test:song"
458 bundle2-output: header chunk size: 16
458 bundle2-output: header chunk size: 16
459 bundle2-output: payload chunk size: 178
459 bundle2-output: payload chunk size: 178
460 bundle2-output: closing payload chunk
460 bundle2-output: closing payload chunk
461 bundle2-output: bundle part: "test:debugreply"
461 bundle2-output: bundle part: "test:debugreply"
462 bundle2-output-part: "test:debugreply" (advisory) empty payload
462 bundle2-output-part: "test:debugreply" (advisory) empty payload
463 bundle2-output: part 3: "test:debugreply"
463 bundle2-output: part 3: "test:debugreply"
464 bundle2-output: header chunk size: 22
464 bundle2-output: header chunk size: 22
465 bundle2-output: closing payload chunk
465 bundle2-output: closing payload chunk
466 bundle2-output: bundle part: "test:math"
466 bundle2-output: bundle part: "test:math"
467 bundle2-output-part: "test:math" (advisory) (params: 2 mandatory 2 advisory) 2 bytes payload
467 bundle2-output-part: "test:math" (advisory) (params: 2 mandatory 2 advisory) 2 bytes payload
468 bundle2-output: part 4: "test:math"
468 bundle2-output: part 4: "test:math"
469 bundle2-output: header chunk size: 43
469 bundle2-output: header chunk size: 43
470 bundle2-output: payload chunk size: 2
470 bundle2-output: payload chunk size: 2
471 bundle2-output: closing payload chunk
471 bundle2-output: closing payload chunk
472 bundle2-output: bundle part: "test:song"
472 bundle2-output: bundle part: "test:song"
473 bundle2-output-part: "test:song" (advisory) (params: 1 mandatory) empty payload
473 bundle2-output-part: "test:song" (advisory) (params: 1 mandatory) empty payload
474 bundle2-output: part 5: "test:song"
474 bundle2-output: part 5: "test:song"
475 bundle2-output: header chunk size: 29
475 bundle2-output: header chunk size: 29
476 bundle2-output: closing payload chunk
476 bundle2-output: closing payload chunk
477 bundle2-output: bundle part: "test:ping"
477 bundle2-output: bundle part: "test:ping"
478 bundle2-output-part: "test:ping" (advisory) empty payload
478 bundle2-output-part: "test:ping" (advisory) empty payload
479 bundle2-output: part 6: "test:ping"
479 bundle2-output: part 6: "test:ping"
480 bundle2-output: header chunk size: 16
480 bundle2-output: header chunk size: 16
481 bundle2-output: closing payload chunk
481 bundle2-output: closing payload chunk
482 bundle2-output: end of bundle
482 bundle2-output: end of bundle
483
483
484 $ f --hexdump ../parts.hg2
484 $ f --hexdump ../parts.hg2
485 ../parts.hg2:
485 ../parts.hg2:
486 0000: 48 47 32 30 00 00 00 00 00 00 00 11 0a 74 65 73 |HG20.........tes|
486 0000: 48 47 32 30 00 00 00 00 00 00 00 11 0a 74 65 73 |HG20.........tes|
487 0010: 74 3a 65 6d 70 74 79 00 00 00 00 00 00 00 00 00 |t:empty.........|
487 0010: 74 3a 65 6d 70 74 79 00 00 00 00 00 00 00 00 00 |t:empty.........|
488 0020: 00 00 00 00 11 0a 74 65 73 74 3a 65 6d 70 74 79 |......test:empty|
488 0020: 00 00 00 00 11 0a 74 65 73 74 3a 65 6d 70 74 79 |......test:empty|
489 0030: 00 00 00 01 00 00 00 00 00 00 00 00 00 10 09 74 |...............t|
489 0030: 00 00 00 01 00 00 00 00 00 00 00 00 00 10 09 74 |...............t|
490 0040: 65 73 74 3a 73 6f 6e 67 00 00 00 02 00 00 00 00 |est:song........|
490 0040: 65 73 74 3a 73 6f 6e 67 00 00 00 02 00 00 00 00 |est:song........|
491 0050: 00 b2 50 61 74 61 6c 69 20 44 69 72 61 70 61 74 |..Patali Dirapat|
491 0050: 00 b2 50 61 74 61 6c 69 20 44 69 72 61 70 61 74 |..Patali Dirapat|
492 0060: 61 2c 20 43 72 6f 6d 64 61 20 43 72 6f 6d 64 61 |a, Cromda Cromda|
492 0060: 61 2c 20 43 72 6f 6d 64 61 20 43 72 6f 6d 64 61 |a, Cromda Cromda|
493 0070: 20 52 69 70 61 6c 6f 2c 20 50 61 74 61 20 50 61 | Ripalo, Pata Pa|
493 0070: 20 52 69 70 61 6c 6f 2c 20 50 61 74 61 20 50 61 | Ripalo, Pata Pa|
494 0080: 74 61 2c 20 4b 6f 20 4b 6f 20 4b 6f 0a 42 6f 6b |ta, Ko Ko Ko.Bok|
494 0080: 74 61 2c 20 4b 6f 20 4b 6f 20 4b 6f 0a 42 6f 6b |ta, Ko Ko Ko.Bok|
495 0090: 6f 72 6f 20 44 69 70 6f 75 6c 69 74 6f 2c 20 52 |oro Dipoulito, R|
495 0090: 6f 72 6f 20 44 69 70 6f 75 6c 69 74 6f 2c 20 52 |oro Dipoulito, R|
496 00a0: 6f 6e 64 69 20 52 6f 6e 64 69 20 50 65 70 69 6e |ondi Rondi Pepin|
496 00a0: 6f 6e 64 69 20 52 6f 6e 64 69 20 50 65 70 69 6e |ondi Rondi Pepin|
497 00b0: 6f 2c 20 50 61 74 61 20 50 61 74 61 2c 20 4b 6f |o, Pata Pata, Ko|
497 00b0: 6f 2c 20 50 61 74 61 20 50 61 74 61 2c 20 4b 6f |o, Pata Pata, Ko|
498 00c0: 20 4b 6f 20 4b 6f 0a 45 6d 61 6e 61 20 4b 61 72 | Ko Ko.Emana Kar|
498 00c0: 20 4b 6f 20 4b 6f 0a 45 6d 61 6e 61 20 4b 61 72 | Ko Ko.Emana Kar|
499 00d0: 61 73 73 6f 6c 69 2c 20 4c 6f 75 63 72 61 20 4c |assoli, Loucra L|
499 00d0: 61 73 73 6f 6c 69 2c 20 4c 6f 75 63 72 61 20 4c |assoli, Loucra L|
500 00e0: 6f 75 63 72 61 20 50 6f 6e 70 6f 6e 74 6f 2c 20 |oucra Ponponto, |
500 00e0: 6f 75 63 72 61 20 50 6f 6e 70 6f 6e 74 6f 2c 20 |oucra Ponponto, |
501 00f0: 50 61 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f |Pata Pata, Ko Ko|
501 00f0: 50 61 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f |Pata Pata, Ko Ko|
502 0100: 20 4b 6f 2e 00 00 00 00 00 00 00 16 0f 74 65 73 | Ko..........tes|
502 0100: 20 4b 6f 2e 00 00 00 00 00 00 00 16 0f 74 65 73 | Ko..........tes|
503 0110: 74 3a 64 65 62 75 67 72 65 70 6c 79 00 00 00 03 |t:debugreply....|
503 0110: 74 3a 64 65 62 75 67 72 65 70 6c 79 00 00 00 03 |t:debugreply....|
504 0120: 00 00 00 00 00 00 00 00 00 2b 09 74 65 73 74 3a |.........+.test:|
504 0120: 00 00 00 00 00 00 00 00 00 2b 09 74 65 73 74 3a |.........+.test:|
505 0130: 6d 61 74 68 00 00 00 04 02 01 02 04 01 04 07 03 |math............|
505 0130: 6d 61 74 68 00 00 00 04 02 01 02 04 01 04 07 03 |math............|
506 0140: 70 69 33 2e 31 34 65 32 2e 37 32 63 6f 6f 6b 69 |pi3.14e2.72cooki|
506 0140: 70 69 33 2e 31 34 65 32 2e 37 32 63 6f 6f 6b 69 |pi3.14e2.72cooki|
507 0150: 6e 67 72 61 77 00 00 00 02 34 32 00 00 00 00 00 |ngraw....42.....|
507 0150: 6e 67 72 61 77 00 00 00 02 34 32 00 00 00 00 00 |ngraw....42.....|
508 0160: 00 00 1d 09 74 65 73 74 3a 73 6f 6e 67 00 00 00 |....test:song...|
508 0160: 00 00 1d 09 74 65 73 74 3a 73 6f 6e 67 00 00 00 |....test:song...|
509 0170: 05 01 00 0b 00 72 61 6e 64 6f 6d 70 61 72 61 6d |.....randomparam|
509 0170: 05 01 00 0b 00 72 61 6e 64 6f 6d 70 61 72 61 6d |.....randomparam|
510 0180: 00 00 00 00 00 00 00 10 09 74 65 73 74 3a 70 69 |.........test:pi|
510 0180: 00 00 00 00 00 00 00 10 09 74 65 73 74 3a 70 69 |.........test:pi|
511 0190: 6e 67 00 00 00 06 00 00 00 00 00 00 00 00 00 00 |ng..............|
511 0190: 6e 67 00 00 00 06 00 00 00 00 00 00 00 00 00 00 |ng..............|
512
512
513
513
514 $ hg statbundle2 < ../parts.hg2
514 $ hg statbundle2 < ../parts.hg2
515 options count: 0
515 options count: 0
516 :test:empty:
516 :test:empty:
517 mandatory: 0
517 mandatory: 0
518 advisory: 0
518 advisory: 0
519 payload: 0 bytes
519 payload: 0 bytes
520 :test:empty:
520 :test:empty:
521 mandatory: 0
521 mandatory: 0
522 advisory: 0
522 advisory: 0
523 payload: 0 bytes
523 payload: 0 bytes
524 :test:song:
524 :test:song:
525 mandatory: 0
525 mandatory: 0
526 advisory: 0
526 advisory: 0
527 payload: 178 bytes
527 payload: 178 bytes
528 :test:debugreply:
528 :test:debugreply:
529 mandatory: 0
529 mandatory: 0
530 advisory: 0
530 advisory: 0
531 payload: 0 bytes
531 payload: 0 bytes
532 :test:math:
532 :test:math:
533 mandatory: 2
533 mandatory: 2
534 advisory: 1
534 advisory: 1
535 payload: 2 bytes
535 payload: 2 bytes
536 :test:song:
536 :test:song:
537 mandatory: 1
537 mandatory: 1
538 advisory: 0
538 advisory: 0
539 payload: 0 bytes
539 payload: 0 bytes
540 :test:ping:
540 :test:ping:
541 mandatory: 0
541 mandatory: 0
542 advisory: 0
542 advisory: 0
543 payload: 0 bytes
543 payload: 0 bytes
544 parts count: 7
544 parts count: 7
545
545
546 $ hg statbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../parts.hg2
546 $ hg statbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../parts.hg2
547 bundle2-input: start processing of HG20 stream
547 bundle2-input: start processing of HG20 stream
548 bundle2-input: reading bundle2 stream parameters
548 bundle2-input: reading bundle2 stream parameters
549 options count: 0
549 options count: 0
550 bundle2-input: start extraction of bundle2 parts
550 bundle2-input: start extraction of bundle2 parts
551 bundle2-input: part header size: 17
551 bundle2-input: part header size: 17
552 bundle2-input: part type: "test:empty"
552 bundle2-input: part type: "test:empty"
553 bundle2-input: part id: "0"
553 bundle2-input: part id: "0"
554 bundle2-input: part parameters: 0
554 bundle2-input: part parameters: 0
555 :test:empty:
555 :test:empty:
556 mandatory: 0
556 mandatory: 0
557 advisory: 0
557 advisory: 0
558 bundle2-input: payload chunk size: 0
558 bundle2-input: payload chunk size: 0
559 payload: 0 bytes
559 payload: 0 bytes
560 bundle2-input: part header size: 17
560 bundle2-input: part header size: 17
561 bundle2-input: part type: "test:empty"
561 bundle2-input: part type: "test:empty"
562 bundle2-input: part id: "1"
562 bundle2-input: part id: "1"
563 bundle2-input: part parameters: 0
563 bundle2-input: part parameters: 0
564 :test:empty:
564 :test:empty:
565 mandatory: 0
565 mandatory: 0
566 advisory: 0
566 advisory: 0
567 bundle2-input: payload chunk size: 0
567 bundle2-input: payload chunk size: 0
568 payload: 0 bytes
568 payload: 0 bytes
569 bundle2-input: part header size: 16
569 bundle2-input: part header size: 16
570 bundle2-input: part type: "test:song"
570 bundle2-input: part type: "test:song"
571 bundle2-input: part id: "2"
571 bundle2-input: part id: "2"
572 bundle2-input: part parameters: 0
572 bundle2-input: part parameters: 0
573 :test:song:
573 :test:song:
574 mandatory: 0
574 mandatory: 0
575 advisory: 0
575 advisory: 0
576 bundle2-input: payload chunk size: 178
576 bundle2-input: payload chunk size: 178
577 bundle2-input: payload chunk size: 0
577 bundle2-input: payload chunk size: 0
578 bundle2-input-part: total payload size 178
578 bundle2-input-part: total payload size 178
579 payload: 178 bytes
579 payload: 178 bytes
580 bundle2-input: part header size: 22
580 bundle2-input: part header size: 22
581 bundle2-input: part type: "test:debugreply"
581 bundle2-input: part type: "test:debugreply"
582 bundle2-input: part id: "3"
582 bundle2-input: part id: "3"
583 bundle2-input: part parameters: 0
583 bundle2-input: part parameters: 0
584 :test:debugreply:
584 :test:debugreply:
585 mandatory: 0
585 mandatory: 0
586 advisory: 0
586 advisory: 0
587 bundle2-input: payload chunk size: 0
587 bundle2-input: payload chunk size: 0
588 payload: 0 bytes
588 payload: 0 bytes
589 bundle2-input: part header size: 43
589 bundle2-input: part header size: 43
590 bundle2-input: part type: "test:math"
590 bundle2-input: part type: "test:math"
591 bundle2-input: part id: "4"
591 bundle2-input: part id: "4"
592 bundle2-input: part parameters: 3
592 bundle2-input: part parameters: 3
593 :test:math:
593 :test:math:
594 mandatory: 2
594 mandatory: 2
595 advisory: 1
595 advisory: 1
596 bundle2-input: payload chunk size: 2
596 bundle2-input: payload chunk size: 2
597 bundle2-input: payload chunk size: 0
597 bundle2-input: payload chunk size: 0
598 bundle2-input-part: total payload size 2
598 bundle2-input-part: total payload size 2
599 payload: 2 bytes
599 payload: 2 bytes
600 bundle2-input: part header size: 29
600 bundle2-input: part header size: 29
601 bundle2-input: part type: "test:song"
601 bundle2-input: part type: "test:song"
602 bundle2-input: part id: "5"
602 bundle2-input: part id: "5"
603 bundle2-input: part parameters: 1
603 bundle2-input: part parameters: 1
604 :test:song:
604 :test:song:
605 mandatory: 1
605 mandatory: 1
606 advisory: 0
606 advisory: 0
607 bundle2-input: payload chunk size: 0
607 bundle2-input: payload chunk size: 0
608 payload: 0 bytes
608 payload: 0 bytes
609 bundle2-input: part header size: 16
609 bundle2-input: part header size: 16
610 bundle2-input: part type: "test:ping"
610 bundle2-input: part type: "test:ping"
611 bundle2-input: part id: "6"
611 bundle2-input: part id: "6"
612 bundle2-input: part parameters: 0
612 bundle2-input: part parameters: 0
613 :test:ping:
613 :test:ping:
614 mandatory: 0
614 mandatory: 0
615 advisory: 0
615 advisory: 0
616 bundle2-input: payload chunk size: 0
616 bundle2-input: payload chunk size: 0
617 payload: 0 bytes
617 payload: 0 bytes
618 bundle2-input: part header size: 0
618 bundle2-input: part header size: 0
619 bundle2-input: end of bundle2 stream
619 bundle2-input: end of bundle2 stream
620 parts count: 7
620 parts count: 7
621
621
622 Test actual unbundling of test part
622 Test actual unbundling of test part
623 =======================================
623 =======================================
624
624
625 Process the bundle
625 Process the bundle
626
626
627 $ hg unbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../parts.hg2
627 $ hg unbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../parts.hg2
628 bundle2-input: start processing of HG20 stream
628 bundle2-input: start processing of HG20 stream
629 bundle2-input: reading bundle2 stream parameters
629 bundle2-input: reading bundle2 stream parameters
630 bundle2-input-bundle: with-transaction
630 bundle2-input-bundle: with-transaction
631 bundle2-input: start extraction of bundle2 parts
631 bundle2-input: start extraction of bundle2 parts
632 bundle2-input: part header size: 17
632 bundle2-input: part header size: 17
633 bundle2-input: part type: "test:empty"
633 bundle2-input: part type: "test:empty"
634 bundle2-input: part id: "0"
634 bundle2-input: part id: "0"
635 bundle2-input: part parameters: 0
635 bundle2-input: part parameters: 0
636 bundle2-input: ignoring unsupported advisory part test:empty
636 bundle2-input: ignoring unsupported advisory part test:empty
637 bundle2-input-part: "test:empty" (advisory) unsupported-type
637 bundle2-input-part: "test:empty" (advisory) unsupported-type
638 bundle2-input: payload chunk size: 0
638 bundle2-input: payload chunk size: 0
639 bundle2-input: part header size: 17
639 bundle2-input: part header size: 17
640 bundle2-input: part type: "test:empty"
640 bundle2-input: part type: "test:empty"
641 bundle2-input: part id: "1"
641 bundle2-input: part id: "1"
642 bundle2-input: part parameters: 0
642 bundle2-input: part parameters: 0
643 bundle2-input: ignoring unsupported advisory part test:empty
643 bundle2-input: ignoring unsupported advisory part test:empty
644 bundle2-input-part: "test:empty" (advisory) unsupported-type
644 bundle2-input-part: "test:empty" (advisory) unsupported-type
645 bundle2-input: payload chunk size: 0
645 bundle2-input: payload chunk size: 0
646 bundle2-input: part header size: 16
646 bundle2-input: part header size: 16
647 bundle2-input: part type: "test:song"
647 bundle2-input: part type: "test:song"
648 bundle2-input: part id: "2"
648 bundle2-input: part id: "2"
649 bundle2-input: part parameters: 0
649 bundle2-input: part parameters: 0
650 bundle2-input: found a handler for part 'test:song'
650 bundle2-input: found a handler for part 'test:song'
651 bundle2-input-part: "test:song" (advisory) supported
651 bundle2-input-part: "test:song" (advisory) supported
652 The choir starts singing:
652 The choir starts singing:
653 bundle2-input: payload chunk size: 178
653 bundle2-input: payload chunk size: 178
654 bundle2-input: payload chunk size: 0
654 bundle2-input: payload chunk size: 0
655 bundle2-input-part: total payload size 178
655 bundle2-input-part: total payload size 178
656 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
656 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
657 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
657 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
658 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
658 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
659 bundle2-input: part header size: 22
659 bundle2-input: part header size: 22
660 bundle2-input: part type: "test:debugreply"
660 bundle2-input: part type: "test:debugreply"
661 bundle2-input: part id: "3"
661 bundle2-input: part id: "3"
662 bundle2-input: part parameters: 0
662 bundle2-input: part parameters: 0
663 bundle2-input: found a handler for part 'test:debugreply'
663 bundle2-input: found a handler for part 'test:debugreply'
664 bundle2-input-part: "test:debugreply" (advisory) supported
664 bundle2-input-part: "test:debugreply" (advisory) supported
665 debugreply: no reply
665 debugreply: no reply
666 bundle2-input: payload chunk size: 0
666 bundle2-input: payload chunk size: 0
667 bundle2-input: part header size: 43
667 bundle2-input: part header size: 43
668 bundle2-input: part type: "test:math"
668 bundle2-input: part type: "test:math"
669 bundle2-input: part id: "4"
669 bundle2-input: part id: "4"
670 bundle2-input: part parameters: 3
670 bundle2-input: part parameters: 3
671 bundle2-input: ignoring unsupported advisory part test:math
671 bundle2-input: ignoring unsupported advisory part test:math
672 bundle2-input-part: "test:math" (advisory) (params: 2 mandatory 2 advisory) unsupported-type
672 bundle2-input-part: "test:math" (advisory) (params: 2 mandatory 2 advisory) unsupported-type
673 bundle2-input: payload chunk size: 2
673 bundle2-input: payload chunk size: 2
674 bundle2-input: payload chunk size: 0
674 bundle2-input: payload chunk size: 0
675 bundle2-input-part: total payload size 2
675 bundle2-input-part: total payload size 2
676 bundle2-input: part header size: 29
676 bundle2-input: part header size: 29
677 bundle2-input: part type: "test:song"
677 bundle2-input: part type: "test:song"
678 bundle2-input: part id: "5"
678 bundle2-input: part id: "5"
679 bundle2-input: part parameters: 1
679 bundle2-input: part parameters: 1
680 bundle2-input: found a handler for part 'test:song'
680 bundle2-input: found a handler for part 'test:song'
681 bundle2-input: ignoring unsupported advisory part test:song - randomparam
681 bundle2-input: ignoring unsupported advisory part test:song - randomparam
682 bundle2-input-part: "test:song" (advisory) (params: 1 mandatory) unsupported-params (['randomparam'])
682 bundle2-input-part: "test:song" (advisory) (params: 1 mandatory) unsupported-params (['randomparam'])
683 bundle2-input: payload chunk size: 0
683 bundle2-input: payload chunk size: 0
684 bundle2-input: part header size: 16
684 bundle2-input: part header size: 16
685 bundle2-input: part type: "test:ping"
685 bundle2-input: part type: "test:ping"
686 bundle2-input: part id: "6"
686 bundle2-input: part id: "6"
687 bundle2-input: part parameters: 0
687 bundle2-input: part parameters: 0
688 bundle2-input: found a handler for part 'test:ping'
688 bundle2-input: found a handler for part 'test:ping'
689 bundle2-input-part: "test:ping" (advisory) supported
689 bundle2-input-part: "test:ping" (advisory) supported
690 received ping request (id 6)
690 received ping request (id 6)
691 bundle2-input: payload chunk size: 0
691 bundle2-input: payload chunk size: 0
692 bundle2-input: part header size: 0
692 bundle2-input: part header size: 0
693 bundle2-input: end of bundle2 stream
693 bundle2-input: end of bundle2 stream
694 bundle2-input-bundle: 6 parts total
694 bundle2-input-bundle: 6 parts total
695 0 unread bytes
695 0 unread bytes
696 3 total verses sung
696 3 total verses sung
697
697
698 Unbundle with an unknown mandatory part
698 Unbundle with an unknown mandatory part
699 (should abort)
699 (should abort)
700
700
701 $ hg bundle2 --parts --unknown ../unknown.hg2
701 $ hg bundle2 --parts --unknown ../unknown.hg2
702
702
703 $ hg unbundle2 < ../unknown.hg2
703 $ hg unbundle2 < ../unknown.hg2
704 The choir starts singing:
704 The choir starts singing:
705 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
705 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
706 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
706 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
707 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
707 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
708 debugreply: no reply
708 debugreply: no reply
709 0 unread bytes
709 0 unread bytes
710 abort: missing support for test:unknown
710 abort: missing support for test:unknown
711 [255]
711 [255]
712
712
713 Unbundle with an unknown mandatory part parameters
713 Unbundle with an unknown mandatory part parameters
714 (should abort)
714 (should abort)
715
715
716 $ hg bundle2 --unknownparams ../unknown.hg2
716 $ hg bundle2 --unknownparams ../unknown.hg2
717
717
718 $ hg unbundle2 < ../unknown.hg2
718 $ hg unbundle2 < ../unknown.hg2
719 0 unread bytes
719 0 unread bytes
720 abort: missing support for test:song - randomparams
720 abort: missing support for test:song - randomparams
721 [255]
721 [255]
722
722
723 unbundle with a reply
723 unbundle with a reply
724
724
725 $ hg bundle2 --parts --reply ../parts-reply.hg2
725 $ hg bundle2 --parts --reply ../parts-reply.hg2
726 $ hg unbundle2 ../reply.hg2 < ../parts-reply.hg2
726 $ hg unbundle2 ../reply.hg2 < ../parts-reply.hg2
727 0 unread bytes
727 0 unread bytes
728 3 total verses sung
728 3 total verses sung
729
729
730 The reply is a bundle
730 The reply is a bundle
731
731
732 $ f --hexdump ../reply.hg2
732 $ f --hexdump ../reply.hg2
733 ../reply.hg2:
733 ../reply.hg2:
734 0000: 48 47 32 30 00 00 00 00 00 00 00 1b 06 6f 75 74 |HG20.........out|
734 0000: 48 47 32 30 00 00 00 00 00 00 00 1b 06 6f 75 74 |HG20.........out|
735 0010: 70 75 74 00 00 00 00 00 01 0b 01 69 6e 2d 72 65 |put........in-re|
735 0010: 70 75 74 00 00 00 00 00 01 0b 01 69 6e 2d 72 65 |put........in-re|
736 0020: 70 6c 79 2d 74 6f 33 00 00 00 d9 54 68 65 20 63 |ply-to3....The c|
736 0020: 70 6c 79 2d 74 6f 33 00 00 00 d9 54 68 65 20 63 |ply-to3....The c|
737 0030: 68 6f 69 72 20 73 74 61 72 74 73 20 73 69 6e 67 |hoir starts sing|
737 0030: 68 6f 69 72 20 73 74 61 72 74 73 20 73 69 6e 67 |hoir starts sing|
738 0040: 69 6e 67 3a 0a 20 20 20 20 50 61 74 61 6c 69 20 |ing:. Patali |
738 0040: 69 6e 67 3a 0a 20 20 20 20 50 61 74 61 6c 69 20 |ing:. Patali |
739 0050: 44 69 72 61 70 61 74 61 2c 20 43 72 6f 6d 64 61 |Dirapata, Cromda|
739 0050: 44 69 72 61 70 61 74 61 2c 20 43 72 6f 6d 64 61 |Dirapata, Cromda|
740 0060: 20 43 72 6f 6d 64 61 20 52 69 70 61 6c 6f 2c 20 | Cromda Ripalo, |
740 0060: 20 43 72 6f 6d 64 61 20 52 69 70 61 6c 6f 2c 20 | Cromda Ripalo, |
741 0070: 50 61 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f |Pata Pata, Ko Ko|
741 0070: 50 61 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f |Pata Pata, Ko Ko|
742 0080: 20 4b 6f 0a 20 20 20 20 42 6f 6b 6f 72 6f 20 44 | Ko. Bokoro D|
742 0080: 20 4b 6f 0a 20 20 20 20 42 6f 6b 6f 72 6f 20 44 | Ko. Bokoro D|
743 0090: 69 70 6f 75 6c 69 74 6f 2c 20 52 6f 6e 64 69 20 |ipoulito, Rondi |
743 0090: 69 70 6f 75 6c 69 74 6f 2c 20 52 6f 6e 64 69 20 |ipoulito, Rondi |
744 00a0: 52 6f 6e 64 69 20 50 65 70 69 6e 6f 2c 20 50 61 |Rondi Pepino, Pa|
744 00a0: 52 6f 6e 64 69 20 50 65 70 69 6e 6f 2c 20 50 61 |Rondi Pepino, Pa|
745 00b0: 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f 20 4b |ta Pata, Ko Ko K|
745 00b0: 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f 20 4b |ta Pata, Ko Ko K|
746 00c0: 6f 0a 20 20 20 20 45 6d 61 6e 61 20 4b 61 72 61 |o. Emana Kara|
746 00c0: 6f 0a 20 20 20 20 45 6d 61 6e 61 20 4b 61 72 61 |o. Emana Kara|
747 00d0: 73 73 6f 6c 69 2c 20 4c 6f 75 63 72 61 20 4c 6f |ssoli, Loucra Lo|
747 00d0: 73 73 6f 6c 69 2c 20 4c 6f 75 63 72 61 20 4c 6f |ssoli, Loucra Lo|
748 00e0: 75 63 72 61 20 50 6f 6e 70 6f 6e 74 6f 2c 20 50 |ucra Ponponto, P|
748 00e0: 75 63 72 61 20 50 6f 6e 70 6f 6e 74 6f 2c 20 50 |ucra Ponponto, P|
749 00f0: 61 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f 20 |ata Pata, Ko Ko |
749 00f0: 61 74 61 20 50 61 74 61 2c 20 4b 6f 20 4b 6f 20 |ata Pata, Ko Ko |
750 0100: 4b 6f 2e 0a 00 00 00 00 00 00 00 1b 06 6f 75 74 |Ko...........out|
750 0100: 4b 6f 2e 0a 00 00 00 00 00 00 00 1b 06 6f 75 74 |Ko...........out|
751 0110: 70 75 74 00 00 00 01 00 01 0b 01 69 6e 2d 72 65 |put........in-re|
751 0110: 70 75 74 00 00 00 01 00 01 0b 01 69 6e 2d 72 65 |put........in-re|
752 0120: 70 6c 79 2d 74 6f 34 00 00 00 c9 64 65 62 75 67 |ply-to4....debug|
752 0120: 70 6c 79 2d 74 6f 34 00 00 00 c9 64 65 62 75 67 |ply-to4....debug|
753 0130: 72 65 70 6c 79 3a 20 63 61 70 61 62 69 6c 69 74 |reply: capabilit|
753 0130: 72 65 70 6c 79 3a 20 63 61 70 61 62 69 6c 69 74 |reply: capabilit|
754 0140: 69 65 73 3a 0a 64 65 62 75 67 72 65 70 6c 79 3a |ies:.debugreply:|
754 0140: 69 65 73 3a 0a 64 65 62 75 67 72 65 70 6c 79 3a |ies:.debugreply:|
755 0150: 20 20 20 20 20 27 63 69 74 79 3d 21 27 0a 64 65 | 'city=!'.de|
755 0150: 20 20 20 20 20 27 63 69 74 79 3d 21 27 0a 64 65 | 'city=!'.de|
756 0160: 62 75 67 72 65 70 6c 79 3a 20 20 20 20 20 20 20 |bugreply: |
756 0160: 62 75 67 72 65 70 6c 79 3a 20 20 20 20 20 20 20 |bugreply: |
757 0170: 20 20 27 63 65 6c 65 73 74 65 2c 76 69 6c 6c 65 | 'celeste,ville|
757 0170: 20 20 27 63 65 6c 65 73 74 65 2c 76 69 6c 6c 65 | 'celeste,ville|
758 0180: 27 0a 64 65 62 75 67 72 65 70 6c 79 3a 20 20 20 |'.debugreply: |
758 0180: 27 0a 64 65 62 75 67 72 65 70 6c 79 3a 20 20 20 |'.debugreply: |
759 0190: 20 20 27 65 6c 65 70 68 61 6e 74 73 27 0a 64 65 | 'elephants'.de|
759 0190: 20 20 27 65 6c 65 70 68 61 6e 74 73 27 0a 64 65 | 'elephants'.de|
760 01a0: 62 75 67 72 65 70 6c 79 3a 20 20 20 20 20 20 20 |bugreply: |
760 01a0: 62 75 67 72 65 70 6c 79 3a 20 20 20 20 20 20 20 |bugreply: |
761 01b0: 20 20 27 62 61 62 61 72 27 0a 64 65 62 75 67 72 | 'babar'.debugr|
761 01b0: 20 20 27 62 61 62 61 72 27 0a 64 65 62 75 67 72 | 'babar'.debugr|
762 01c0: 65 70 6c 79 3a 20 20 20 20 20 20 20 20 20 27 63 |eply: 'c|
762 01c0: 65 70 6c 79 3a 20 20 20 20 20 20 20 20 20 27 63 |eply: 'c|
763 01d0: 65 6c 65 73 74 65 27 0a 64 65 62 75 67 72 65 70 |eleste'.debugrep|
763 01d0: 65 6c 65 73 74 65 27 0a 64 65 62 75 67 72 65 70 |eleste'.debugrep|
764 01e0: 6c 79 3a 20 20 20 20 20 27 70 69 6e 67 2d 70 6f |ly: 'ping-po|
764 01e0: 6c 79 3a 20 20 20 20 20 27 70 69 6e 67 2d 70 6f |ly: 'ping-po|
765 01f0: 6e 67 27 0a 00 00 00 00 00 00 00 1e 09 74 65 73 |ng'..........tes|
765 01f0: 6e 67 27 0a 00 00 00 00 00 00 00 1e 09 74 65 73 |ng'..........tes|
766 0200: 74 3a 70 6f 6e 67 00 00 00 02 01 00 0b 01 69 6e |t:pong........in|
766 0200: 74 3a 70 6f 6e 67 00 00 00 02 01 00 0b 01 69 6e |t:pong........in|
767 0210: 2d 72 65 70 6c 79 2d 74 6f 37 00 00 00 00 00 00 |-reply-to7......|
767 0210: 2d 72 65 70 6c 79 2d 74 6f 37 00 00 00 00 00 00 |-reply-to7......|
768 0220: 00 1b 06 6f 75 74 70 75 74 00 00 00 03 00 01 0b |...output.......|
768 0220: 00 1b 06 6f 75 74 70 75 74 00 00 00 03 00 01 0b |...output.......|
769 0230: 01 69 6e 2d 72 65 70 6c 79 2d 74 6f 37 00 00 00 |.in-reply-to7...|
769 0230: 01 69 6e 2d 72 65 70 6c 79 2d 74 6f 37 00 00 00 |.in-reply-to7...|
770 0240: 3d 72 65 63 65 69 76 65 64 20 70 69 6e 67 20 72 |=received ping r|
770 0240: 3d 72 65 63 65 69 76 65 64 20 70 69 6e 67 20 72 |=received ping r|
771 0250: 65 71 75 65 73 74 20 28 69 64 20 37 29 0a 72 65 |equest (id 7).re|
771 0250: 65 71 75 65 73 74 20 28 69 64 20 37 29 0a 72 65 |equest (id 7).re|
772 0260: 70 6c 79 69 6e 67 20 74 6f 20 70 69 6e 67 20 72 |plying to ping r|
772 0260: 70 6c 79 69 6e 67 20 74 6f 20 70 69 6e 67 20 72 |plying to ping r|
773 0270: 65 71 75 65 73 74 20 28 69 64 20 37 29 0a 00 00 |equest (id 7)...|
773 0270: 65 71 75 65 73 74 20 28 69 64 20 37 29 0a 00 00 |equest (id 7)...|
774 0280: 00 00 00 00 00 00 |......|
774 0280: 00 00 00 00 00 00 |......|
775
775
776 The reply is valid
776 The reply is valid
777
777
778 $ hg statbundle2 < ../reply.hg2
778 $ hg statbundle2 < ../reply.hg2
779 options count: 0
779 options count: 0
780 :output:
780 :output:
781 mandatory: 0
781 mandatory: 0
782 advisory: 1
782 advisory: 1
783 payload: 217 bytes
783 payload: 217 bytes
784 :output:
784 :output:
785 mandatory: 0
785 mandatory: 0
786 advisory: 1
786 advisory: 1
787 payload: 201 bytes
787 payload: 201 bytes
788 :test:pong:
788 :test:pong:
789 mandatory: 1
789 mandatory: 1
790 advisory: 0
790 advisory: 0
791 payload: 0 bytes
791 payload: 0 bytes
792 :output:
792 :output:
793 mandatory: 0
793 mandatory: 0
794 advisory: 1
794 advisory: 1
795 payload: 61 bytes
795 payload: 61 bytes
796 parts count: 4
796 parts count: 4
797
797
798 Unbundle the reply to get the output:
798 Unbundle the reply to get the output:
799
799
800 $ hg unbundle2 < ../reply.hg2
800 $ hg unbundle2 < ../reply.hg2
801 remote: The choir starts singing:
801 remote: The choir starts singing:
802 remote: Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
802 remote: Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
803 remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
803 remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
804 remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
804 remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
805 remote: debugreply: capabilities:
805 remote: debugreply: capabilities:
806 remote: debugreply: 'city=!'
806 remote: debugreply: 'city=!'
807 remote: debugreply: 'celeste,ville'
807 remote: debugreply: 'celeste,ville'
808 remote: debugreply: 'elephants'
808 remote: debugreply: 'elephants'
809 remote: debugreply: 'babar'
809 remote: debugreply: 'babar'
810 remote: debugreply: 'celeste'
810 remote: debugreply: 'celeste'
811 remote: debugreply: 'ping-pong'
811 remote: debugreply: 'ping-pong'
812 remote: received ping request (id 7)
812 remote: received ping request (id 7)
813 remote: replying to ping request (id 7)
813 remote: replying to ping request (id 7)
814 0 unread bytes
814 0 unread bytes
815
815
816 Test push race detection
816 Test push race detection
817
817
818 $ hg bundle2 --pushrace ../part-race.hg2
818 $ hg bundle2 --pushrace ../part-race.hg2
819
819
820 $ hg unbundle2 < ../part-race.hg2
820 $ hg unbundle2 < ../part-race.hg2
821 0 unread bytes
821 0 unread bytes
822 abort: push race: repository changed while pushing - please try again
822 abort: push race: repository changed while pushing - please try again
823 [255]
823 [255]
824
824
825 Support for changegroup
825 Support for changegroup
826 ===================================
826 ===================================
827
827
828 $ hg unbundle $TESTDIR/bundles/rebase.hg
828 $ hg unbundle $TESTDIR/bundles/rebase.hg
829 adding changesets
829 adding changesets
830 adding manifests
830 adding manifests
831 adding file changes
831 adding file changes
832 added 8 changesets with 7 changes to 7 files (+3 heads)
832 added 8 changesets with 7 changes to 7 files (+3 heads)
833 (run 'hg heads' to see heads, 'hg merge' to merge)
833 (run 'hg heads' to see heads, 'hg merge' to merge)
834
834
835 $ hg log -G
835 $ hg log -G
836 o 8:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> H
836 o 8:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> H
837 |
837 |
838 | o 7:eea13746799a draft Nicolas Dumazet <nicdumz.commits@gmail.com> G
838 | o 7:eea13746799a draft Nicolas Dumazet <nicdumz.commits@gmail.com> G
839 |/|
839 |/|
840 o | 6:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
840 o | 6:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
841 | |
841 | |
842 | o 5:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
842 | o 5:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
843 |/
843 |/
844 | o 4:32af7686d403 draft Nicolas Dumazet <nicdumz.commits@gmail.com> D
844 | o 4:32af7686d403 draft Nicolas Dumazet <nicdumz.commits@gmail.com> D
845 | |
845 | |
846 | o 3:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> C
846 | o 3:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> C
847 | |
847 | |
848 | o 2:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> B
848 | o 2:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> B
849 |/
849 |/
850 o 1:cd010b8cd998 draft Nicolas Dumazet <nicdumz.commits@gmail.com> A
850 o 1:cd010b8cd998 draft Nicolas Dumazet <nicdumz.commits@gmail.com> A
851
851
852 @ 0:3903775176ed draft test a
852 @ 0:3903775176ed draft test a
853
853
854
854
855 $ hg bundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true --rev '8+7+5+4' ../rev.hg2
855 $ hg bundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true --rev '8+7+5+4' ../rev.hg2
856 4 changesets found
856 4 changesets found
857 list of changesets:
857 list of changesets:
858 32af7686d403cf45b5d95f2d70cebea587ac806a
858 32af7686d403cf45b5d95f2d70cebea587ac806a
859 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
859 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
860 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
860 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
861 02de42196ebee42ef284b6780a87cdc96e8eaab6
861 02de42196ebee42ef284b6780a87cdc96e8eaab6
862 bundle2-output-bundle: "HG20", 1 parts total
862 bundle2-output-bundle: "HG20", 1 parts total
863 bundle2-output: start emission of HG20 stream
863 bundle2-output: start emission of HG20 stream
864 bundle2-output: bundle parameter:
864 bundle2-output: bundle parameter:
865 bundle2-output: start of parts
865 bundle2-output: start of parts
866 bundle2-output: bundle part: "changegroup"
866 bundle2-output: bundle part: "changegroup"
867 bundle2-output-part: "changegroup" (advisory) streamed payload
867 bundle2-output-part: "changegroup" (advisory) streamed payload
868 bundle2-output: part 0: "changegroup"
868 bundle2-output: part 0: "changegroup"
869 bundle2-output: header chunk size: 18
869 bundle2-output: header chunk size: 18
870 bundling: 1/4 changesets (25.00%)
870 bundling: 1/4 changesets (25.00%)
871 bundling: 2/4 changesets (50.00%)
871 bundling: 2/4 changesets (50.00%)
872 bundling: 3/4 changesets (75.00%)
872 bundling: 3/4 changesets (75.00%)
873 bundling: 4/4 changesets (100.00%)
873 bundling: 4/4 changesets (100.00%)
874 bundling: 1/4 manifests (25.00%)
874 bundling: 1/4 manifests (25.00%)
875 bundling: 2/4 manifests (50.00%)
875 bundling: 2/4 manifests (50.00%)
876 bundling: 3/4 manifests (75.00%)
876 bundling: 3/4 manifests (75.00%)
877 bundling: 4/4 manifests (100.00%)
877 bundling: 4/4 manifests (100.00%)
878 bundling: D 1/3 files (33.33%)
878 bundling: D 1/3 files (33.33%)
879 bundling: E 2/3 files (66.67%)
879 bundling: E 2/3 files (66.67%)
880 bundling: H 3/3 files (100.00%)
880 bundling: H 3/3 files (100.00%)
881 bundle2-output: payload chunk size: 1555
881 bundle2-output: payload chunk size: 1555
882 bundle2-output: closing payload chunk
882 bundle2-output: closing payload chunk
883 bundle2-output: end of bundle
883 bundle2-output: end of bundle
884
884
885 $ f --hexdump ../rev.hg2
885 $ f --hexdump ../rev.hg2
886 ../rev.hg2:
886 ../rev.hg2:
887 0000: 48 47 32 30 00 00 00 00 00 00 00 12 0b 63 68 61 |HG20.........cha|
887 0000: 48 47 32 30 00 00 00 00 00 00 00 12 0b 63 68 61 |HG20.........cha|
888 0010: 6e 67 65 67 72 6f 75 70 00 00 00 00 00 00 00 00 |ngegroup........|
888 0010: 6e 67 65 67 72 6f 75 70 00 00 00 00 00 00 00 00 |ngegroup........|
889 0020: 06 13 00 00 00 a4 32 af 76 86 d4 03 cf 45 b5 d9 |......2.v....E..|
889 0020: 06 13 00 00 00 a4 32 af 76 86 d4 03 cf 45 b5 d9 |......2.v....E..|
890 0030: 5f 2d 70 ce be a5 87 ac 80 6a 5f dd d9 89 57 c8 |_-p......j_...W.|
890 0030: 5f 2d 70 ce be a5 87 ac 80 6a 5f dd d9 89 57 c8 |_-p......j_...W.|
891 0040: a5 4a 4d 43 6d fe 1d a9 d8 7f 21 a1 b9 7b 00 00 |.JMCm.....!..{..|
891 0040: a5 4a 4d 43 6d fe 1d a9 d8 7f 21 a1 b9 7b 00 00 |.JMCm.....!..{..|
892 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
892 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
893 0060: 00 00 32 af 76 86 d4 03 cf 45 b5 d9 5f 2d 70 ce |..2.v....E.._-p.|
893 0060: 00 00 32 af 76 86 d4 03 cf 45 b5 d9 5f 2d 70 ce |..2.v....E.._-p.|
894 0070: be a5 87 ac 80 6a 00 00 00 00 00 00 00 29 00 00 |.....j.......)..|
894 0070: be a5 87 ac 80 6a 00 00 00 00 00 00 00 29 00 00 |.....j.......)..|
895 0080: 00 29 36 65 31 66 34 63 34 37 65 63 62 35 33 33 |.)6e1f4c47ecb533|
895 0080: 00 29 36 65 31 66 34 63 34 37 65 63 62 35 33 33 |.)6e1f4c47ecb533|
896 0090: 66 66 64 30 63 38 65 35 32 63 64 63 38 38 61 66 |ffd0c8e52cdc88af|
896 0090: 66 66 64 30 63 38 65 35 32 63 64 63 38 38 61 66 |ffd0c8e52cdc88af|
897 00a0: 62 36 63 64 33 39 65 32 30 63 0a 00 00 00 66 00 |b6cd39e20c....f.|
897 00a0: 62 36 63 64 33 39 65 32 30 63 0a 00 00 00 66 00 |b6cd39e20c....f.|
898 00b0: 00 00 68 00 00 00 02 44 0a 00 00 00 69 00 00 00 |..h....D....i...|
898 00b0: 00 00 68 00 00 00 02 44 0a 00 00 00 69 00 00 00 |..h....D....i...|
899 00c0: 6a 00 00 00 01 44 00 00 00 a4 95 20 ee a7 81 bc |j....D..... ....|
899 00c0: 6a 00 00 00 01 44 00 00 00 a4 95 20 ee a7 81 bc |j....D..... ....|
900 00d0: ca 16 c1 e1 5a cc 0b a1 43 35 a0 e8 e5 ba cd 01 |....Z...C5......|
900 00d0: ca 16 c1 e1 5a cc 0b a1 43 35 a0 e8 e5 ba cd 01 |....Z...C5......|
901 00e0: 0b 8c d9 98 f3 98 1a 5a 81 15 f9 4f 8d a4 ab 50 |.......Z...O...P|
901 00e0: 0b 8c d9 98 f3 98 1a 5a 81 15 f9 4f 8d a4 ab 50 |.......Z...O...P|
902 00f0: 60 89 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |`...............|
902 00f0: 60 89 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |`...............|
903 0100: 00 00 00 00 00 00 95 20 ee a7 81 bc ca 16 c1 e1 |....... ........|
903 0100: 00 00 00 00 00 00 95 20 ee a7 81 bc ca 16 c1 e1 |....... ........|
904 0110: 5a cc 0b a1 43 35 a0 e8 e5 ba 00 00 00 00 00 00 |Z...C5..........|
904 0110: 5a cc 0b a1 43 35 a0 e8 e5 ba 00 00 00 00 00 00 |Z...C5..........|
905 0120: 00 29 00 00 00 29 34 64 65 63 65 39 63 38 32 36 |.)...)4dece9c826|
905 0120: 00 29 00 00 00 29 34 64 65 63 65 39 63 38 32 36 |.)...)4dece9c826|
906 0130: 66 36 39 34 39 30 35 30 37 62 39 38 63 36 33 38 |f69490507b98c638|
906 0130: 66 36 39 34 39 30 35 30 37 62 39 38 63 36 33 38 |f69490507b98c638|
907 0140: 33 61 33 30 30 39 62 32 39 35 38 33 37 64 0a 00 |3a3009b295837d..|
907 0140: 33 61 33 30 30 39 62 32 39 35 38 33 37 64 0a 00 |3a3009b295837d..|
908 0150: 00 00 66 00 00 00 68 00 00 00 02 45 0a 00 00 00 |..f...h....E....|
908 0150: 00 00 66 00 00 00 68 00 00 00 02 45 0a 00 00 00 |..f...h....E....|
909 0160: 69 00 00 00 6a 00 00 00 01 45 00 00 00 a2 ee a1 |i...j....E......|
909 0160: 69 00 00 00 6a 00 00 00 01 45 00 00 00 a2 ee a1 |i...j....E......|
910 0170: 37 46 79 9a 9e 0b fd 88 f2 9d 3c 2e 9d c9 38 9f |7Fy.......<...8.|
910 0170: 37 46 79 9a 9e 0b fd 88 f2 9d 3c 2e 9d c9 38 9f |7Fy.......<...8.|
911 0180: 52 4f 24 b6 38 7c 8c 8c ae 37 17 88 80 f3 fa 95 |RO$.8|...7......|
911 0180: 52 4f 24 b6 38 7c 8c 8c ae 37 17 88 80 f3 fa 95 |RO$.8|...7......|
912 0190: de d3 cb 1c f7 85 95 20 ee a7 81 bc ca 16 c1 e1 |....... ........|
912 0190: de d3 cb 1c f7 85 95 20 ee a7 81 bc ca 16 c1 e1 |....... ........|
913 01a0: 5a cc 0b a1 43 35 a0 e8 e5 ba ee a1 37 46 79 9a |Z...C5......7Fy.|
913 01a0: 5a cc 0b a1 43 35 a0 e8 e5 ba ee a1 37 46 79 9a |Z...C5......7Fy.|
914 01b0: 9e 0b fd 88 f2 9d 3c 2e 9d c9 38 9f 52 4f 00 00 |......<...8.RO..|
914 01b0: 9e 0b fd 88 f2 9d 3c 2e 9d c9 38 9f 52 4f 00 00 |......<...8.RO..|
915 01c0: 00 00 00 00 00 29 00 00 00 29 33 36 35 62 39 33 |.....)...)365b93|
915 01c0: 00 00 00 00 00 29 00 00 00 29 33 36 35 62 39 33 |.....)...)365b93|
916 01d0: 64 35 37 66 64 66 34 38 31 34 65 32 62 35 39 31 |d57fdf4814e2b591|
916 01d0: 64 35 37 66 64 66 34 38 31 34 65 32 62 35 39 31 |d57fdf4814e2b591|
917 01e0: 31 64 36 62 61 63 66 66 32 62 31 32 30 31 34 34 |1d6bacff2b120144|
917 01e0: 31 64 36 62 61 63 66 66 32 62 31 32 30 31 34 34 |1d6bacff2b120144|
918 01f0: 34 31 0a 00 00 00 66 00 00 00 68 00 00 00 00 00 |41....f...h.....|
918 01f0: 34 31 0a 00 00 00 66 00 00 00 68 00 00 00 00 00 |41....f...h.....|
919 0200: 00 00 69 00 00 00 6a 00 00 00 01 47 00 00 00 a4 |..i...j....G....|
919 0200: 00 00 69 00 00 00 6a 00 00 00 01 47 00 00 00 a4 |..i...j....G....|
920 0210: 02 de 42 19 6e be e4 2e f2 84 b6 78 0a 87 cd c9 |..B.n......x....|
920 0210: 02 de 42 19 6e be e4 2e f2 84 b6 78 0a 87 cd c9 |..B.n......x....|
921 0220: 6e 8e aa b6 24 b6 38 7c 8c 8c ae 37 17 88 80 f3 |n...$.8|...7....|
921 0220: 6e 8e aa b6 24 b6 38 7c 8c 8c ae 37 17 88 80 f3 |n...$.8|...7....|
922 0230: fa 95 de d3 cb 1c f7 85 00 00 00 00 00 00 00 00 |................|
922 0230: fa 95 de d3 cb 1c f7 85 00 00 00 00 00 00 00 00 |................|
923 0240: 00 00 00 00 00 00 00 00 00 00 00 00 02 de 42 19 |..............B.|
923 0240: 00 00 00 00 00 00 00 00 00 00 00 00 02 de 42 19 |..............B.|
924 0250: 6e be e4 2e f2 84 b6 78 0a 87 cd c9 6e 8e aa b6 |n......x....n...|
924 0250: 6e be e4 2e f2 84 b6 78 0a 87 cd c9 6e 8e aa b6 |n......x....n...|
925 0260: 00 00 00 00 00 00 00 29 00 00 00 29 38 62 65 65 |.......)...)8bee|
925 0260: 00 00 00 00 00 00 00 29 00 00 00 29 38 62 65 65 |.......)...)8bee|
926 0270: 34 38 65 64 63 37 33 31 38 35 34 31 66 63 30 30 |48edc7318541fc00|
926 0270: 34 38 65 64 63 37 33 31 38 35 34 31 66 63 30 30 |48edc7318541fc00|
927 0280: 31 33 65 65 34 31 62 30 38 39 32 37 36 61 38 63 |13ee41b089276a8c|
927 0280: 31 33 65 65 34 31 62 30 38 39 32 37 36 61 38 63 |13ee41b089276a8c|
928 0290: 32 34 62 66 0a 00 00 00 66 00 00 00 66 00 00 00 |24bf....f...f...|
928 0290: 32 34 62 66 0a 00 00 00 66 00 00 00 66 00 00 00 |24bf....f...f...|
929 02a0: 02 48 0a 00 00 00 67 00 00 00 68 00 00 00 01 48 |.H....g...h....H|
929 02a0: 02 48 0a 00 00 00 67 00 00 00 68 00 00 00 01 48 |.H....g...h....H|
930 02b0: 00 00 00 00 00 00 00 8b 6e 1f 4c 47 ec b5 33 ff |........n.LG..3.|
930 02b0: 00 00 00 00 00 00 00 8b 6e 1f 4c 47 ec b5 33 ff |........n.LG..3.|
931 02c0: d0 c8 e5 2c dc 88 af b6 cd 39 e2 0c 66 a5 a0 18 |...,.....9..f...|
931 02c0: d0 c8 e5 2c dc 88 af b6 cd 39 e2 0c 66 a5 a0 18 |...,.....9..f...|
932 02d0: 17 fd f5 23 9c 27 38 02 b5 b7 61 8d 05 1c 89 e4 |...#.'8...a.....|
932 02d0: 17 fd f5 23 9c 27 38 02 b5 b7 61 8d 05 1c 89 e4 |...#.'8...a.....|
933 02e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
933 02e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
934 02f0: 00 00 00 00 32 af 76 86 d4 03 cf 45 b5 d9 5f 2d |....2.v....E.._-|
934 02f0: 00 00 00 00 32 af 76 86 d4 03 cf 45 b5 d9 5f 2d |....2.v....E.._-|
935 0300: 70 ce be a5 87 ac 80 6a 00 00 00 81 00 00 00 81 |p......j........|
935 0300: 70 ce be a5 87 ac 80 6a 00 00 00 81 00 00 00 81 |p......j........|
936 0310: 00 00 00 2b 44 00 63 33 66 31 63 61 32 39 32 34 |...+D.c3f1ca2924|
936 0310: 00 00 00 2b 44 00 63 33 66 31 63 61 32 39 32 34 |...+D.c3f1ca2924|
937 0320: 63 31 36 61 31 39 62 30 36 35 36 61 38 34 39 30 |c16a19b0656a8490|
937 0320: 63 31 36 61 31 39 62 30 36 35 36 61 38 34 39 30 |c16a19b0656a8490|
938 0330: 30 65 35 30 34 65 35 62 30 61 65 63 32 64 0a 00 |0e504e5b0aec2d..|
938 0330: 30 65 35 30 34 65 35 62 30 61 65 63 32 64 0a 00 |0e504e5b0aec2d..|
939 0340: 00 00 8b 4d ec e9 c8 26 f6 94 90 50 7b 98 c6 38 |...M...&...P{..8|
939 0340: 00 00 8b 4d ec e9 c8 26 f6 94 90 50 7b 98 c6 38 |...M...&...P{..8|
940 0350: 3a 30 09 b2 95 83 7d 00 7d 8c 9d 88 84 13 25 f5 |:0....}.}.....%.|
940 0350: 3a 30 09 b2 95 83 7d 00 7d 8c 9d 88 84 13 25 f5 |:0....}.}.....%.|
941 0360: c6 b0 63 71 b3 5b 4e 8a 2b 1a 83 00 00 00 00 00 |..cq.[N.+.......|
941 0360: c6 b0 63 71 b3 5b 4e 8a 2b 1a 83 00 00 00 00 00 |..cq.[N.+.......|
942 0370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 95 |................|
942 0370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 95 |................|
943 0380: 20 ee a7 81 bc ca 16 c1 e1 5a cc 0b a1 43 35 a0 | ........Z...C5.|
943 0380: 20 ee a7 81 bc ca 16 c1 e1 5a cc 0b a1 43 35 a0 | ........Z...C5.|
944 0390: e8 e5 ba 00 00 00 2b 00 00 00 ac 00 00 00 2b 45 |......+.......+E|
944 0390: e8 e5 ba 00 00 00 2b 00 00 00 ac 00 00 00 2b 45 |......+.......+E|
945 03a0: 00 39 63 36 66 64 30 33 35 30 61 36 63 30 64 30 |.9c6fd0350a6c0d0|
945 03a0: 00 39 63 36 66 64 30 33 35 30 61 36 63 30 64 30 |.9c6fd0350a6c0d0|
946 03b0: 63 34 39 64 34 61 39 63 35 30 31 37 63 66 30 37 |c49d4a9c5017cf07|
946 03b0: 63 34 39 64 34 61 39 63 35 30 31 37 63 66 30 37 |c49d4a9c5017cf07|
947 03c0: 30 34 33 66 35 34 65 35 38 0a 00 00 00 8b 36 5b |043f54e58.....6[|
947 03c0: 30 34 33 66 35 34 65 35 38 0a 00 00 00 8b 36 5b |043f54e58.....6[|
948 03d0: 93 d5 7f df 48 14 e2 b5 91 1d 6b ac ff 2b 12 01 |....H.....k..+..|
948 03d0: 93 d5 7f df 48 14 e2 b5 91 1d 6b ac ff 2b 12 01 |....H.....k..+..|
949 03e0: 44 41 28 a5 84 c6 5e f1 21 f8 9e b6 6a b7 d0 bc |DA(...^.!...j...|
949 03e0: 44 41 28 a5 84 c6 5e f1 21 f8 9e b6 6a b7 d0 bc |DA(...^.!...j...|
950 03f0: 15 3d 80 99 e7 ce 4d ec e9 c8 26 f6 94 90 50 7b |.=....M...&...P{|
950 03f0: 15 3d 80 99 e7 ce 4d ec e9 c8 26 f6 94 90 50 7b |.=....M...&...P{|
951 0400: 98 c6 38 3a 30 09 b2 95 83 7d ee a1 37 46 79 9a |..8:0....}..7Fy.|
951 0400: 98 c6 38 3a 30 09 b2 95 83 7d ee a1 37 46 79 9a |..8:0....}..7Fy.|
952 0410: 9e 0b fd 88 f2 9d 3c 2e 9d c9 38 9f 52 4f 00 00 |......<...8.RO..|
952 0410: 9e 0b fd 88 f2 9d 3c 2e 9d c9 38 9f 52 4f 00 00 |......<...8.RO..|
953 0420: 00 56 00 00 00 56 00 00 00 2b 46 00 32 32 62 66 |.V...V...+F.22bf|
953 0420: 00 56 00 00 00 56 00 00 00 2b 46 00 32 32 62 66 |.V...V...+F.22bf|
954 0430: 63 66 64 36 32 61 32 31 61 33 32 38 37 65 64 62 |cfd62a21a3287edb|
954 0430: 63 66 64 36 32 61 32 31 61 33 32 38 37 65 64 62 |cfd62a21a3287edb|
955 0440: 64 34 64 36 35 36 32 31 38 64 30 66 35 32 35 65 |d4d656218d0f525e|
955 0440: 64 34 64 36 35 36 32 31 38 64 30 66 35 32 35 65 |d4d656218d0f525e|
956 0450: 64 37 36 61 0a 00 00 00 97 8b ee 48 ed c7 31 85 |d76a.......H..1.|
956 0450: 64 37 36 61 0a 00 00 00 97 8b ee 48 ed c7 31 85 |d76a.......H..1.|
957 0460: 41 fc 00 13 ee 41 b0 89 27 6a 8c 24 bf 28 a5 84 |A....A..'j.$.(..|
957 0460: 41 fc 00 13 ee 41 b0 89 27 6a 8c 24 bf 28 a5 84 |A....A..'j.$.(..|
958 0470: c6 5e f1 21 f8 9e b6 6a b7 d0 bc 15 3d 80 99 e7 |.^.!...j....=...|
958 0470: c6 5e f1 21 f8 9e b6 6a b7 d0 bc 15 3d 80 99 e7 |.^.!...j....=...|
959 0480: ce 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
959 0480: ce 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
960 0490: 00 00 00 00 00 02 de 42 19 6e be e4 2e f2 84 b6 |.......B.n......|
960 0490: 00 00 00 00 00 02 de 42 19 6e be e4 2e f2 84 b6 |.......B.n......|
961 04a0: 78 0a 87 cd c9 6e 8e aa b6 00 00 00 2b 00 00 00 |x....n......+...|
961 04a0: 78 0a 87 cd c9 6e 8e aa b6 00 00 00 2b 00 00 00 |x....n......+...|
962 04b0: 56 00 00 00 00 00 00 00 81 00 00 00 81 00 00 00 |V...............|
962 04b0: 56 00 00 00 00 00 00 00 81 00 00 00 81 00 00 00 |V...............|
963 04c0: 2b 48 00 38 35 30 30 31 38 39 65 37 34 61 39 65 |+H.8500189e74a9e|
963 04c0: 2b 48 00 38 35 30 30 31 38 39 65 37 34 61 39 65 |+H.8500189e74a9e|
964 04d0: 30 34 37 35 65 38 32 32 30 39 33 62 63 37 64 62 |0475e822093bc7db|
964 04d0: 30 34 37 35 65 38 32 32 30 39 33 62 63 37 64 62 |0475e822093bc7db|
965 04e0: 30 64 36 33 31 61 65 62 30 62 34 0a 00 00 00 00 |0d631aeb0b4.....|
965 04e0: 30 64 36 33 31 61 65 62 30 62 34 0a 00 00 00 00 |0d631aeb0b4.....|
966 04f0: 00 00 00 05 44 00 00 00 62 c3 f1 ca 29 24 c1 6a |....D...b...)$.j|
966 04f0: 00 00 00 05 44 00 00 00 62 c3 f1 ca 29 24 c1 6a |....D...b...)$.j|
967 0500: 19 b0 65 6a 84 90 0e 50 4e 5b 0a ec 2d 00 00 00 |..ej...PN[..-...|
967 0500: 19 b0 65 6a 84 90 0e 50 4e 5b 0a ec 2d 00 00 00 |..ej...PN[..-...|
968 0510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
968 0510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
969 0520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
969 0520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
970 0530: 00 00 00 00 00 32 af 76 86 d4 03 cf 45 b5 d9 5f |.....2.v....E.._|
970 0530: 00 00 00 00 00 32 af 76 86 d4 03 cf 45 b5 d9 5f |.....2.v....E.._|
971 0540: 2d 70 ce be a5 87 ac 80 6a 00 00 00 00 00 00 00 |-p......j.......|
971 0540: 2d 70 ce be a5 87 ac 80 6a 00 00 00 00 00 00 00 |-p......j.......|
972 0550: 00 00 00 00 02 44 0a 00 00 00 00 00 00 00 05 45 |.....D.........E|
972 0550: 00 00 00 00 02 44 0a 00 00 00 00 00 00 00 05 45 |.....D.........E|
973 0560: 00 00 00 62 9c 6f d0 35 0a 6c 0d 0c 49 d4 a9 c5 |...b.o.5.l..I...|
973 0560: 00 00 00 62 9c 6f d0 35 0a 6c 0d 0c 49 d4 a9 c5 |...b.o.5.l..I...|
974 0570: 01 7c f0 70 43 f5 4e 58 00 00 00 00 00 00 00 00 |.|.pC.NX........|
974 0570: 01 7c f0 70 43 f5 4e 58 00 00 00 00 00 00 00 00 |.|.pC.NX........|
975 0580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
975 0580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
976 0590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
976 0590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
977 05a0: 95 20 ee a7 81 bc ca 16 c1 e1 5a cc 0b a1 43 35 |. ........Z...C5|
977 05a0: 95 20 ee a7 81 bc ca 16 c1 e1 5a cc 0b a1 43 35 |. ........Z...C5|
978 05b0: a0 e8 e5 ba 00 00 00 00 00 00 00 00 00 00 00 02 |................|
978 05b0: a0 e8 e5 ba 00 00 00 00 00 00 00 00 00 00 00 02 |................|
979 05c0: 45 0a 00 00 00 00 00 00 00 05 48 00 00 00 62 85 |E.........H...b.|
979 05c0: 45 0a 00 00 00 00 00 00 00 05 48 00 00 00 62 85 |E.........H...b.|
980 05d0: 00 18 9e 74 a9 e0 47 5e 82 20 93 bc 7d b0 d6 31 |...t..G^. ..}..1|
980 05d0: 00 18 9e 74 a9 e0 47 5e 82 20 93 bc 7d b0 d6 31 |...t..G^. ..}..1|
981 05e0: ae b0 b4 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
981 05e0: ae b0 b4 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
982 05f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
982 05f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
983 0600: 00 00 00 00 00 00 00 00 00 00 00 02 de 42 19 6e |.............B.n|
983 0600: 00 00 00 00 00 00 00 00 00 00 00 02 de 42 19 6e |.............B.n|
984 0610: be e4 2e f2 84 b6 78 0a 87 cd c9 6e 8e aa b6 00 |......x....n....|
984 0610: be e4 2e f2 84 b6 78 0a 87 cd c9 6e 8e aa b6 00 |......x....n....|
985 0620: 00 00 00 00 00 00 00 00 00 00 02 48 0a 00 00 00 |...........H....|
985 0620: 00 00 00 00 00 00 00 00 00 00 02 48 0a 00 00 00 |...........H....|
986 0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 |.............|
986 0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 |.............|
987
987
988 $ hg debugbundle ../rev.hg2
988 $ hg debugbundle ../rev.hg2
989 Stream params: {}
989 Stream params: {}
990 changegroup -- '{}'
990 changegroup -- '{}'
991 32af7686d403cf45b5d95f2d70cebea587ac806a
991 32af7686d403cf45b5d95f2d70cebea587ac806a
992 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
992 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
993 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
993 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
994 02de42196ebee42ef284b6780a87cdc96e8eaab6
994 02de42196ebee42ef284b6780a87cdc96e8eaab6
995 $ hg unbundle ../rev.hg2
995 $ hg unbundle ../rev.hg2
996 adding changesets
996 adding changesets
997 adding manifests
997 adding manifests
998 adding file changes
998 adding file changes
999 added 0 changesets with 0 changes to 3 files
999 added 0 changesets with 0 changes to 3 files
1000 (run 'hg update' to get a working copy)
1000
1001
1001 with reply
1002 with reply
1002
1003
1003 $ hg bundle2 --rev '8+7+5+4' --reply ../rev-rr.hg2
1004 $ hg bundle2 --rev '8+7+5+4' --reply ../rev-rr.hg2
1004 $ hg unbundle2 ../rev-reply.hg2 < ../rev-rr.hg2
1005 $ hg unbundle2 ../rev-reply.hg2 < ../rev-rr.hg2
1005 0 unread bytes
1006 0 unread bytes
1006 addchangegroup return: 1
1007 addchangegroup return: 1
1007
1008
1008 $ f --hexdump ../rev-reply.hg2
1009 $ f --hexdump ../rev-reply.hg2
1009 ../rev-reply.hg2:
1010 ../rev-reply.hg2:
1010 0000: 48 47 32 30 00 00 00 00 00 00 00 2f 11 72 65 70 |HG20......./.rep|
1011 0000: 48 47 32 30 00 00 00 00 00 00 00 2f 11 72 65 70 |HG20......./.rep|
1011 0010: 6c 79 3a 63 68 61 6e 67 65 67 72 6f 75 70 00 00 |ly:changegroup..|
1012 0010: 6c 79 3a 63 68 61 6e 67 65 67 72 6f 75 70 00 00 |ly:changegroup..|
1012 0020: 00 00 00 02 0b 01 06 01 69 6e 2d 72 65 70 6c 79 |........in-reply|
1013 0020: 00 00 00 02 0b 01 06 01 69 6e 2d 72 65 70 6c 79 |........in-reply|
1013 0030: 2d 74 6f 31 72 65 74 75 72 6e 31 00 00 00 00 00 |-to1return1.....|
1014 0030: 2d 74 6f 31 72 65 74 75 72 6e 31 00 00 00 00 00 |-to1return1.....|
1014 0040: 00 00 1b 06 6f 75 74 70 75 74 00 00 00 01 00 01 |....output......|
1015 0040: 00 00 1b 06 6f 75 74 70 75 74 00 00 00 01 00 01 |....output......|
1015 0050: 0b 01 69 6e 2d 72 65 70 6c 79 2d 74 6f 31 00 00 |..in-reply-to1..|
1016 0050: 0b 01 69 6e 2d 72 65 70 6c 79 2d 74 6f 31 00 00 |..in-reply-to1..|
1016 0060: 00 64 61 64 64 69 6e 67 20 63 68 61 6e 67 65 73 |.dadding changes|
1017 0060: 00 64 61 64 64 69 6e 67 20 63 68 61 6e 67 65 73 |.dadding changes|
1017 0070: 65 74 73 0a 61 64 64 69 6e 67 20 6d 61 6e 69 66 |ets.adding manif|
1018 0070: 65 74 73 0a 61 64 64 69 6e 67 20 6d 61 6e 69 66 |ets.adding manif|
1018 0080: 65 73 74 73 0a 61 64 64 69 6e 67 20 66 69 6c 65 |ests.adding file|
1019 0080: 65 73 74 73 0a 61 64 64 69 6e 67 20 66 69 6c 65 |ests.adding file|
1019 0090: 20 63 68 61 6e 67 65 73 0a 61 64 64 65 64 20 30 | changes.added 0|
1020 0090: 20 63 68 61 6e 67 65 73 0a 61 64 64 65 64 20 30 | changes.added 0|
1020 00a0: 20 63 68 61 6e 67 65 73 65 74 73 20 77 69 74 68 | changesets with|
1021 00a0: 20 63 68 61 6e 67 65 73 65 74 73 20 77 69 74 68 | changesets with|
1021 00b0: 20 30 20 63 68 61 6e 67 65 73 20 74 6f 20 33 20 | 0 changes to 3 |
1022 00b0: 20 30 20 63 68 61 6e 67 65 73 20 74 6f 20 33 20 | 0 changes to 3 |
1022 00c0: 66 69 6c 65 73 0a 00 00 00 00 00 00 00 00 |files.........|
1023 00c0: 66 69 6c 65 73 0a 00 00 00 00 00 00 00 00 |files.........|
1023
1024
1024 Check handling of exception during generation.
1025 Check handling of exception during generation.
1025 ----------------------------------------------
1026 ----------------------------------------------
1026
1027
1027 $ hg bundle2 --genraise > ../genfailed.hg2
1028 $ hg bundle2 --genraise > ../genfailed.hg2
1028 abort: Someone set up us the bomb!
1029 abort: Someone set up us the bomb!
1029 [255]
1030 [255]
1030
1031
1031 Should still be a valid bundle
1032 Should still be a valid bundle
1032
1033
1033 $ f --hexdump ../genfailed.hg2
1034 $ f --hexdump ../genfailed.hg2
1034 ../genfailed.hg2:
1035 ../genfailed.hg2:
1035 0000: 48 47 32 30 00 00 00 00 00 00 00 0d 06 6f 75 74 |HG20.........out|
1036 0000: 48 47 32 30 00 00 00 00 00 00 00 0d 06 6f 75 74 |HG20.........out|
1036 0010: 70 75 74 00 00 00 00 00 00 ff ff ff ff 00 00 00 |put.............|
1037 0010: 70 75 74 00 00 00 00 00 00 ff ff ff ff 00 00 00 |put.............|
1037 0020: 48 0b 65 72 72 6f 72 3a 61 62 6f 72 74 00 00 00 |H.error:abort...|
1038 0020: 48 0b 65 72 72 6f 72 3a 61 62 6f 72 74 00 00 00 |H.error:abort...|
1038 0030: 00 01 00 07 2d 6d 65 73 73 61 67 65 75 6e 65 78 |....-messageunex|
1039 0030: 00 01 00 07 2d 6d 65 73 73 61 67 65 75 6e 65 78 |....-messageunex|
1039 0040: 70 65 63 74 65 64 20 65 72 72 6f 72 3a 20 53 6f |pected error: So|
1040 0040: 70 65 63 74 65 64 20 65 72 72 6f 72 3a 20 53 6f |pected error: So|
1040 0050: 6d 65 6f 6e 65 20 73 65 74 20 75 70 20 75 73 20 |meone set up us |
1041 0050: 6d 65 6f 6e 65 20 73 65 74 20 75 70 20 75 73 20 |meone set up us |
1041 0060: 74 68 65 20 62 6f 6d 62 21 00 00 00 00 00 00 00 |the bomb!.......|
1042 0060: 74 68 65 20 62 6f 6d 62 21 00 00 00 00 00 00 00 |the bomb!.......|
1042 0070: 00 |.|
1043 0070: 00 |.|
1043
1044
1044 And its handling on the other size raise a clean exception
1045 And its handling on the other size raise a clean exception
1045
1046
1046 $ cat ../genfailed.hg2 | hg unbundle2
1047 $ cat ../genfailed.hg2 | hg unbundle2
1047 0 unread bytes
1048 0 unread bytes
1048 abort: unexpected error: Someone set up us the bomb!
1049 abort: unexpected error: Someone set up us the bomb!
1049 [255]
1050 [255]
1050
1051
1051 Test compression
1052 Test compression
1052 ================
1053 ================
1053
1054
1054 Simple case where it just work: GZ
1055 Simple case where it just work: GZ
1055 ----------------------------------
1056 ----------------------------------
1056
1057
1057 $ hg bundle2 --compress GZ --rev '8+7+5+4' ../rev.hg2.bz
1058 $ hg bundle2 --compress GZ --rev '8+7+5+4' ../rev.hg2.bz
1058 $ f --hexdump ../rev.hg2.bz
1059 $ f --hexdump ../rev.hg2.bz
1059 ../rev.hg2.bz:
1060 ../rev.hg2.bz:
1060 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress|
1061 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress|
1061 0010: 69 6f 6e 3d 47 5a 78 9c 95 94 7d 68 95 55 1c c7 |ion=GZx...}h.U..|
1062 0010: 69 6f 6e 3d 47 5a 78 9c 95 94 7d 68 95 55 1c c7 |ion=GZx...}h.U..|
1062 0020: 9f 3b 31 e8 ce fa c3 65 be a0 a4 b4 52 b9 29 e7 |.;1....e....R.).|
1063 0020: 9f 3b 31 e8 ce fa c3 65 be a0 a4 b4 52 b9 29 e7 |.;1....e....R.).|
1063 0030: f5 79 ce 89 fa 63 ed 5e 77 8b 9c c3 3f 2a 1c 68 |.y...c.^w...?*.h|
1064 0030: f5 79 ce 89 fa 63 ed 5e 77 8b 9c c3 3f 2a 1c 68 |.y...c.^w...?*.h|
1064 0040: cf 79 9b dd 6a ae b0 28 74 b8 e5 96 5b bb 86 61 |.y..j..(t...[..a|
1065 0040: cf 79 9b dd 6a ae b0 28 74 b8 e5 96 5b bb 86 61 |.y..j..(t...[..a|
1065 0050: a3 15 6e 3a 71 c8 6a e8 a5 da 95 64 28 22 ce 69 |..n:q.j....d(".i|
1066 0050: a3 15 6e 3a 71 c8 6a e8 a5 da 95 64 28 22 ce 69 |..n:q.j....d(".i|
1066 0060: cd 06 59 34 28 2b 51 2a 58 c3 17 56 2a 9a 9d 67 |..Y4(+Q*X..V*..g|
1067 0060: cd 06 59 34 28 2b 51 2a 58 c3 17 56 2a 9a 9d 67 |..Y4(+Q*X..V*..g|
1067 0070: dc c6 35 9e c4 1d f8 9e 87 f3 9c f3 3b bf 0f bf |..5.........;...|
1068 0070: dc c6 35 9e c4 1d f8 9e 87 f3 9c f3 3b bf 0f bf |..5.........;...|
1068 0080: 97 e3 38 ce f4 42 b9 d6 af ae d2 55 af ae 7b ad |..8..B.....U..{.|
1069 0080: 97 e3 38 ce f4 42 b9 d6 af ae d2 55 af ae 7b ad |..8..B.....U..{.|
1069 0090: c6 c9 8d bb 8a ec b4 07 ed 7f fd ed d3 53 be 4e |.............S.N|
1070 0090: c6 c9 8d bb 8a ec b4 07 ed 7f fd ed d3 53 be 4e |.............S.N|
1070 00a0: f4 0e af 59 52 73 ea 50 d7 96 9e ba d4 9a 1f 87 |...YRs.P........|
1071 00a0: f4 0e af 59 52 73 ea 50 d7 96 9e ba d4 9a 1f 87 |...YRs.P........|
1071 00b0: 9b 9f 1d e8 7a 6a 79 e9 cb 7f cf eb fe 7e d3 82 |....zjy......~..|
1072 00b0: 9b 9f 1d e8 7a 6a 79 e9 cb 7f cf eb fe 7e d3 82 |....zjy......~..|
1072 00c0: ce 2f 36 38 21 23 cc 36 b7 b5 38 90 ab a1 21 92 |./68!#.6..8...!.|
1073 00c0: ce 2f 36 38 21 23 cc 36 b7 b5 38 90 ab a1 21 92 |./68!#.6..8...!.|
1073 00d0: 78 5a 0a 8a b1 31 0a 48 a6 29 92 4a 32 e6 1b e1 |xZ...1.H.).J2...|
1074 00d0: 78 5a 0a 8a b1 31 0a 48 a6 29 92 4a 32 e6 1b e1 |xZ...1.H.).J2...|
1074 00e0: 4a 85 b9 46 40 46 ed 61 63 b5 d6 aa 20 1e ac 5e |J..F@F.ac... ..^|
1075 00e0: 4a 85 b9 46 40 46 ed 61 63 b5 d6 aa 20 1e ac 5e |J..F@F.ac... ..^|
1075 00f0: b0 0a ae 8a c4 03 c6 d6 f9 a3 7b eb fb 4e de 7f |..........{..N..|
1076 00f0: b0 0a ae 8a c4 03 c6 d6 f9 a3 7b eb fb 4e de 7f |..........{..N..|
1076 0100: e4 97 55 5f 15 76 96 d2 5d bf 9d 3f 38 18 29 4c |..U_.v..]..?8.)L|
1077 0100: e4 97 55 5f 15 76 96 d2 5d bf 9d 3f 38 18 29 4c |..U_.v..]..?8.)L|
1077 0110: 0f b7 5d 6e 9b b3 aa 7e c6 d5 15 5b f7 7c 52 f1 |..]n...~...[.|R.|
1078 0110: 0f b7 5d 6e 9b b3 aa 7e c6 d5 15 5b f7 7c 52 f1 |..]n...~...[.|R.|
1078 0120: 7c 73 18 63 98 6d 3e 23 51 5a 6a 2e 19 72 8d cb ||s.c.m>#QZj..r..|
1079 0120: 7c 73 18 63 98 6d 3e 23 51 5a 6a 2e 19 72 8d cb ||s.c.m>#QZj..r..|
1079 0130: 09 07 14 78 82 33 e9 62 86 7d 0c 00 17 88 53 86 |...x.3.b.}....S.|
1080 0130: 09 07 14 78 82 33 e9 62 86 7d 0c 00 17 88 53 86 |...x.3.b.}....S.|
1080 0140: 3d 75 0b 63 e2 16 c6 84 9d 76 8f 76 7a cb de fc |=u.c.....v.vz...|
1081 0140: 3d 75 0b 63 e2 16 c6 84 9d 76 8f 76 7a cb de fc |=u.c.....v.vz...|
1081 0150: a8 a3 f0 46 d3 a5 f6 c7 96 b6 9f 60 3b 57 ae 28 |...F.......`;W.(|
1082 0150: a8 a3 f0 46 d3 a5 f6 c7 96 b6 9f 60 3b 57 ae 28 |...F.......`;W.(|
1082 0160: ce b2 8d e9 f4 3e 6f 66 53 dd e5 6b ad 67 be f9 |.....>ofS..k.g..|
1083 0160: ce b2 8d e9 f4 3e 6f 66 53 dd e5 6b ad 67 be f9 |.....>ofS..k.g..|
1083 0170: 72 ee 5f 8d 61 3c 61 b6 f9 8c d8 a5 82 63 45 3d |r._.a<a......cE=|
1084 0170: 72 ee 5f 8d 61 3c 61 b6 f9 8c d8 a5 82 63 45 3d |r._.a<a......cE=|
1084 0180: a3 0c 61 90 68 24 28 87 50 b9 c2 97 c6 20 01 11 |..a.h$(.P.... ..|
1085 0180: a3 0c 61 90 68 24 28 87 50 b9 c2 97 c6 20 01 11 |..a.h$(.P.... ..|
1085 0190: 80 84 10 98 cf e8 e4 13 96 05 51 2c 38 f3 c4 ec |..........Q,8...|
1086 0190: 80 84 10 98 cf e8 e4 13 96 05 51 2c 38 f3 c4 ec |..........Q,8...|
1086 01a0: ea 43 e7 96 5e 6a c8 be 11 dd 32 78 a2 fa dd 8f |.C..^j....2x....|
1087 01a0: ea 43 e7 96 5e 6a c8 be 11 dd 32 78 a2 fa dd 8f |.C..^j....2x....|
1087 01b0: b3 61 84 61 51 0c b3 cd 27 64 42 6b c2 b4 92 1e |.a.aQ...'dBk....|
1088 01b0: b3 61 84 61 51 0c b3 cd 27 64 42 6b c2 b4 92 1e |.a.aQ...'dBk....|
1088 01c0: 86 8c 12 68 24 00 10 db 7f 50 00 c6 91 e7 fa 4c |...h$....P.....L|
1089 01c0: 86 8c 12 68 24 00 10 db 7f 50 00 c6 91 e7 fa 4c |...h$....P.....L|
1089 01d0: 22 22 cc bf 84 81 0a 92 c1 aa 2a c7 1b 49 e6 ee |""........*..I..|
1090 01d0: 22 22 cc bf 84 81 0a 92 c1 aa 2a c7 1b 49 e6 ee |""........*..I..|
1090 01e0: 6b a9 7e e0 e9 b2 91 5e 7c 73 68 e0 fc 23 3f 34 |k.~....^|sh..#?4|
1091 01e0: 6b a9 7e e0 e9 b2 91 5e 7c 73 68 e0 fc 23 3f 34 |k.~....^|sh..#?4|
1091 01f0: ed cf 0e f2 b3 d3 4c d7 ae 59 33 6f 8c 3d b8 63 |......L..Y3o.=.c|
1092 01f0: ed cf 0e f2 b3 d3 4c d7 ae 59 33 6f 8c 3d b8 63 |......L..Y3o.=.c|
1092 0200: 21 2b e8 3d e0 6f 9d 3a b7 f9 dc 24 2a b2 3e a7 |!+.=.o.:...$*.>.|
1093 0200: 21 2b e8 3d e0 6f 9d 3a b7 f9 dc 24 2a b2 3e a7 |!+.=.o.:...$*.>.|
1093 0210: 58 dc 91 d8 40 e9 23 8e 88 84 ae 0f b9 00 2e b5 |X...@.#.........|
1094 0210: 58 dc 91 d8 40 e9 23 8e 88 84 ae 0f b9 00 2e b5 |X...@.#.........|
1094 0220: 74 36 f3 40 53 40 34 15 c0 d7 12 8d e7 bb 65 f9 |t6.@S@4.......e.|
1095 0220: 74 36 f3 40 53 40 34 15 c0 d7 12 8d e7 bb 65 f9 |t6.@S@4.......e.|
1095 0230: c8 ef 03 0f ff f9 fe b6 8a 0d 6d fd ec 51 70 f7 |..........m..Qp.|
1096 0230: c8 ef 03 0f ff f9 fe b6 8a 0d 6d fd ec 51 70 f7 |..........m..Qp.|
1096 0240: a7 ad 9b 6b 9d da 74 7b 53 43 d1 43 63 fd 19 f9 |...k..t{SC.Cc...|
1097 0240: a7 ad 9b 6b 9d da 74 7b 53 43 d1 43 63 fd 19 f9 |...k..t{SC.Cc...|
1097 0250: ca 67 95 e5 ef c4 e6 6c 9e 44 e1 c5 ac 7a 82 6f |.g.....l.D...z.o|
1098 0250: ca 67 95 e5 ef c4 e6 6c 9e 44 e1 c5 ac 7a 82 6f |.g.....l.D...z.o|
1098 0260: c2 e1 d2 b5 2d 81 29 f0 5d 09 6c 6f 10 ae 88 cf |....-.).].lo....|
1099 0260: c2 e1 d2 b5 2d 81 29 f0 5d 09 6c 6f 10 ae 88 cf |....-.).].lo....|
1099 0270: 25 05 d0 93 06 78 80 60 43 2d 10 1b 47 71 2b b7 |%....x.`C-..Gq+.|
1100 0270: 25 05 d0 93 06 78 80 60 43 2d 10 1b 47 71 2b b7 |%....x.`C-..Gq+.|
1100 0280: 7f bb e9 a7 e4 7d 67 7b df 9b f7 62 cf cd d8 f4 |.....}g{...b....|
1101 0280: 7f bb e9 a7 e4 7d 67 7b df 9b f7 62 cf cd d8 f4 |.....}g{...b....|
1101 0290: 48 bc 64 51 57 43 ff ea 8b 0b ae 74 64 53 07 86 |H.dQWC.....tdS..|
1102 0290: 48 bc 64 51 57 43 ff ea 8b 0b ae 74 64 53 07 86 |H.dQWC.....tdS..|
1102 02a0: fa 66 3c 5e f7 e1 af a7 c2 90 ff a7 be 9e c9 29 |.f<^...........)|
1103 02a0: fa 66 3c 5e f7 e1 af a7 c2 90 ff a7 be 9e c9 29 |.f<^...........)|
1103 02b0: b6 cc 41 48 18 69 94 8b 7c 04 7d 8c 98 a7 95 50 |..AH.i..|.}....P|
1104 02b0: b6 cc 41 48 18 69 94 8b 7c 04 7d 8c 98 a7 95 50 |..AH.i..|.}....P|
1104 02c0: 44 d9 d0 20 c8 14 30 14 51 ad 6c 16 03 94 0f 5a |D.. ..0.Q.l....Z|
1105 02c0: 44 d9 d0 20 c8 14 30 14 51 ad 6c 16 03 94 0f 5a |D.. ..0.Q.l....Z|
1105 02d0: 46 93 7f 1c 87 8d 25 d7 9d a2 d1 92 4c f3 c2 54 |F.....%.....L..T|
1106 02d0: 46 93 7f 1c 87 8d 25 d7 9d a2 d1 92 4c f3 c2 54 |F.....%.....L..T|
1106 02e0: ba f8 70 18 ca 24 0a 29 96 43 71 f2 93 95 74 18 |..p..$.).Cq...t.|
1107 02e0: ba f8 70 18 ca 24 0a 29 96 43 71 f2 93 95 74 18 |..p..$.).Cq...t.|
1107 02f0: b5 65 c4 b8 f6 6c 5c 34 20 1e d5 0c 21 c0 b1 90 |.e...l\4 ...!...|
1108 02f0: b5 65 c4 b8 f6 6c 5c 34 20 1e d5 0c 21 c0 b1 90 |.e...l\4 ...!...|
1108 0300: 9e 12 40 b9 18 fa 5a 00 41 a2 39 d3 a9 c1 73 21 |..@...Z.A.9...s!|
1109 0300: 9e 12 40 b9 18 fa 5a 00 41 a2 39 d3 a9 c1 73 21 |..@...Z.A.9...s!|
1109 0310: 8e 5e 3c b9 b8 f8 48 6a 76 46 a7 1a b6 dd 5b 51 |.^<...HjvF....[Q|
1110 0310: 8e 5e 3c b9 b8 f8 48 6a 76 46 a7 1a b6 dd 5b 51 |.^<...HjvF....[Q|
1110 0320: 5e 19 1d 59 12 c6 32 89 02 9a c0 8f 4f b8 0a ba |^..Y..2.....O...|
1111 0320: 5e 19 1d 59 12 c6 32 89 02 9a c0 8f 4f b8 0a ba |^..Y..2.....O...|
1111 0330: 5e ec 58 37 44 a3 2f dd 33 ed c9 d3 dd c7 22 1b |^.X7D./.3.....".|
1112 0330: 5e ec 58 37 44 a3 2f dd 33 ed c9 d3 dd c7 22 1b |^.X7D./.3.....".|
1112 0340: 2f d4 94 8e 95 3f 77 a7 ae 6e f3 32 8d bb 4a 4c |/....?w..n.2..JL|
1113 0340: 2f d4 94 8e 95 3f 77 a7 ae 6e f3 32 8d bb 4a 4c |/....?w..n.2..JL|
1113 0350: b8 0a 5a 43 34 3a b3 3a d6 77 ff 5c b6 fa ad f9 |..ZC4:.:.w.\....|
1114 0350: b8 0a 5a 43 34 3a b3 3a d6 77 ff 5c b6 fa ad f9 |..ZC4:.:.w.\....|
1114 0360: db fb 6a 33 df c1 7d 99 cf ef d4 d5 6d da 77 7c |..j3..}.....m.w||
1115 0360: db fb 6a 33 df c1 7d 99 cf ef d4 d5 6d da 77 7c |..j3..}.....m.w||
1115 0370: 3b 19 fd af c5 3f f1 60 c3 17 |;....?.`..|
1116 0370: 3b 19 fd af c5 3f f1 60 c3 17 |;....?.`..|
1116 $ hg debugbundle ../rev.hg2.bz
1117 $ hg debugbundle ../rev.hg2.bz
1117 Stream params: {'Compression': 'GZ'}
1118 Stream params: {'Compression': 'GZ'}
1118 changegroup -- '{}'
1119 changegroup -- '{}'
1119 32af7686d403cf45b5d95f2d70cebea587ac806a
1120 32af7686d403cf45b5d95f2d70cebea587ac806a
1120 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
1121 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
1121 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
1122 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
1122 02de42196ebee42ef284b6780a87cdc96e8eaab6
1123 02de42196ebee42ef284b6780a87cdc96e8eaab6
1123 $ hg unbundle ../rev.hg2.bz
1124 $ hg unbundle ../rev.hg2.bz
1124 adding changesets
1125 adding changesets
1125 adding manifests
1126 adding manifests
1126 adding file changes
1127 adding file changes
1127 added 0 changesets with 0 changes to 3 files
1128 added 0 changesets with 0 changes to 3 files
1129 (run 'hg update' to get a working copy)
1128 Simple case where it just work: BZ
1130 Simple case where it just work: BZ
1129 ----------------------------------
1131 ----------------------------------
1130
1132
1131 $ hg bundle2 --compress BZ --rev '8+7+5+4' ../rev.hg2.bz
1133 $ hg bundle2 --compress BZ --rev '8+7+5+4' ../rev.hg2.bz
1132 $ f --hexdump ../rev.hg2.bz
1134 $ f --hexdump ../rev.hg2.bz
1133 ../rev.hg2.bz:
1135 ../rev.hg2.bz:
1134 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress|
1136 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress|
1135 0010: 69 6f 6e 3d 42 5a 42 5a 68 39 31 41 59 26 53 59 |ion=BZBZh91AY&SY|
1137 0010: 69 6f 6e 3d 42 5a 42 5a 68 39 31 41 59 26 53 59 |ion=BZBZh91AY&SY|
1136 0020: a3 4b 18 3d 00 00 1a 7f ff ff bf 5f f6 ef ef 7f |.K.=......._....|
1138 0020: a3 4b 18 3d 00 00 1a 7f ff ff bf 5f f6 ef ef 7f |.K.=......._....|
1137 0030: f6 3f f7 d1 d9 ff ff f7 6e ff ff 6e f7 f6 bd df |.?......n..n....|
1139 0030: f6 3f f7 d1 d9 ff ff f7 6e ff ff 6e f7 f6 bd df |.?......n..n....|
1138 0040: b5 ab ff cf 67 f6 e7 7b f7 c0 02 d7 33 82 8b 51 |....g..{....3..Q|
1140 0040: b5 ab ff cf 67 f6 e7 7b f7 c0 02 d7 33 82 8b 51 |....g..{....3..Q|
1139 0050: 04 a5 53 d5 3d 27 a0 99 18 4d 0d 34 00 d1 a1 e8 |..S.='...M.4....|
1141 0050: 04 a5 53 d5 3d 27 a0 99 18 4d 0d 34 00 d1 a1 e8 |..S.='...M.4....|
1140 0060: 80 c8 7a 87 a9 a3 43 6a 3d 46 86 26 80 34 3d 40 |..z...Cj=F.&.4=@|
1142 0060: 80 c8 7a 87 a9 a3 43 6a 3d 46 86 26 80 34 3d 40 |..z...Cj=F.&.4=@|
1141 0070: c8 c9 b5 34 f4 8f 48 0f 51 ea 34 34 fd 4d aa 19 |...4..H.Q.44.M..|
1143 0070: c8 c9 b5 34 f4 8f 48 0f 51 ea 34 34 fd 4d aa 19 |...4..H.Q.44.M..|
1142 0080: 03 40 0c 08 da 86 43 d4 f5 0f 42 1e a0 f3 54 33 |.@....C...B...T3|
1144 0080: 03 40 0c 08 da 86 43 d4 f5 0f 42 1e a0 f3 54 33 |.@....C...B...T3|
1143 0090: 54 d3 13 4d 03 40 32 00 00 32 03 26 80 0d 00 0d |T..M.@2..2.&....|
1145 0090: 54 d3 13 4d 03 40 32 00 00 32 03 26 80 0d 00 0d |T..M.@2..2.&....|
1144 00a0: 00 68 c8 c8 03 20 32 30 98 8c 80 00 00 03 4d 00 |.h... 20......M.|
1146 00a0: 00 68 c8 c8 03 20 32 30 98 8c 80 00 00 03 4d 00 |.h... 20......M.|
1145 00b0: c8 00 00 0d 00 00 22 99 a1 34 c2 64 a6 d5 34 1a |......"..4.d..4.|
1147 00b0: c8 00 00 0d 00 00 22 99 a1 34 c2 64 a6 d5 34 1a |......"..4.d..4.|
1146 00c0: 00 00 06 86 83 4d 07 a8 d1 a0 68 01 a0 00 00 00 |.....M....h.....|
1148 00c0: 00 00 06 86 83 4d 07 a8 d1 a0 68 01 a0 00 00 00 |.....M....h.....|
1147 00d0: 00 0d 06 80 00 00 00 0d 00 03 40 00 00 04 a4 a1 |..........@.....|
1149 00d0: 00 0d 06 80 00 00 00 0d 00 03 40 00 00 04 a4 a1 |..........@.....|
1148 00e0: 4d a9 89 89 b4 9a 32 0c 43 46 86 87 a9 8d 41 9a |M.....2.CF....A.|
1150 00e0: 4d a9 89 89 b4 9a 32 0c 43 46 86 87 a9 8d 41 9a |M.....2.CF....A.|
1149 00f0: 98 46 9a 0d 31 32 1a 34 0d 0c 8d a2 0c 98 4d 06 |.F..12.4......M.|
1151 00f0: 98 46 9a 0d 31 32 1a 34 0d 0c 8d a2 0c 98 4d 06 |.F..12.4......M.|
1150 0100: 8c 40 c2 60 8d 0d 0c 20 c9 89 fa a0 d0 d3 21 a1 |.@.`... ......!.|
1152 0100: 8c 40 c2 60 8d 0d 0c 20 c9 89 fa a0 d0 d3 21 a1 |.@.`... ......!.|
1151 0110: ea 34 d3 68 9e a6 d1 74 05 33 cb 66 96 93 28 64 |.4.h...t.3.f..(d|
1153 0110: ea 34 d3 68 9e a6 d1 74 05 33 cb 66 96 93 28 64 |.4.h...t.3.f..(d|
1152 0120: 40 91 22 ac 55 9b ea 40 7b 38 94 e2 f8 06 00 cb |@.".U..@{8......|
1154 0120: 40 91 22 ac 55 9b ea 40 7b 38 94 e2 f8 06 00 cb |@.".U..@{8......|
1153 0130: 28 02 00 4d ab 40 24 10 43 18 cf 64 b4 06 83 0c |(..M.@$.C..d....|
1155 0130: 28 02 00 4d ab 40 24 10 43 18 cf 64 b4 06 83 0c |(..M.@$.C..d....|
1154 0140: 34 6c b4 a3 d4 0a 0a e4 a8 5c 4e 23 c0 c9 7a 31 |4l.......\N#..z1|
1156 0140: 34 6c b4 a3 d4 0a 0a e4 a8 5c 4e 23 c0 c9 7a 31 |4l.......\N#..z1|
1155 0150: 97 87 77 7a 64 88 80 8e 60 97 20 93 0f 8e eb c4 |..wzd...`. .....|
1157 0150: 97 87 77 7a 64 88 80 8e 60 97 20 93 0f 8e eb c4 |..wzd...`. .....|
1156 0160: 62 a4 44 a3 52 20 b2 99 a9 2e e1 d7 29 4a 54 ac |b.D.R ......)JT.|
1158 0160: 62 a4 44 a3 52 20 b2 99 a9 2e e1 d7 29 4a 54 ac |b.D.R ......)JT.|
1157 0170: 44 7a bb cc 04 3d e0 aa bd 6a 33 5e 9b a2 57 36 |Dz...=...j3^..W6|
1159 0170: 44 7a bb cc 04 3d e0 aa bd 6a 33 5e 9b a2 57 36 |Dz...=...j3^..W6|
1158 0180: fa cb 45 bb 6d 3e c1 d9 d9 f5 83 69 8a d0 e0 e2 |..E.m>.....i....|
1160 0180: fa cb 45 bb 6d 3e c1 d9 d9 f5 83 69 8a d0 e0 e2 |..E.m>.....i....|
1159 0190: e7 ae 90 55 24 da 3f ab 78 c0 4c b4 56 a3 9e a4 |...U$.?.x.L.V...|
1161 0190: e7 ae 90 55 24 da 3f ab 78 c0 4c b4 56 a3 9e a4 |...U$.?.x.L.V...|
1160 01a0: af 9c 65 74 86 ec 6d dc 62 dc 33 ca c8 50 dd 9d |..et..m.b.3..P..|
1162 01a0: af 9c 65 74 86 ec 6d dc 62 dc 33 ca c8 50 dd 9d |..et..m.b.3..P..|
1161 01b0: 98 8e 9e 59 20 f3 f0 42 91 4a 09 f5 75 8d 3d a5 |...Y ..B.J..u.=.|
1163 01b0: 98 8e 9e 59 20 f3 f0 42 91 4a 09 f5 75 8d 3d a5 |...Y ..B.J..u.=.|
1162 01c0: a5 15 cb 8d 10 63 b0 c2 2e b2 81 f7 c1 76 0e 53 |.....c.......v.S|
1164 01c0: a5 15 cb 8d 10 63 b0 c2 2e b2 81 f7 c1 76 0e 53 |.....c.......v.S|
1163 01d0: 6c 0e 46 73 b5 ae 67 f9 4c 0b 45 6b a8 32 2a 2f |l.Fs..g.L.Ek.2*/|
1165 01d0: 6c 0e 46 73 b5 ae 67 f9 4c 0b 45 6b a8 32 2a 2f |l.Fs..g.L.Ek.2*/|
1164 01e0: a2 54 a4 44 05 20 a1 38 d1 a4 c6 09 a8 2b 08 99 |.T.D. .8.....+..|
1166 01e0: a2 54 a4 44 05 20 a1 38 d1 a4 c6 09 a8 2b 08 99 |.T.D. .8.....+..|
1165 01f0: a4 14 ae 8d a3 e3 aa 34 27 d8 44 ca c3 5d 21 8b |.......4'.D..]!.|
1167 01f0: a4 14 ae 8d a3 e3 aa 34 27 d8 44 ca c3 5d 21 8b |.......4'.D..]!.|
1166 0200: 1a 1e 97 29 71 2b 09 4a 4a 55 55 94 58 65 b2 bc |...)q+.JJUU.Xe..|
1168 0200: 1a 1e 97 29 71 2b 09 4a 4a 55 55 94 58 65 b2 bc |...)q+.JJUU.Xe..|
1167 0210: f3 a5 90 26 36 76 67 7a 51 98 d6 8a 4a 99 50 b5 |...&6vgzQ...J.P.|
1169 0210: f3 a5 90 26 36 76 67 7a 51 98 d6 8a 4a 99 50 b5 |...&6vgzQ...J.P.|
1168 0220: 99 8f 94 21 17 a9 8b f3 ad 4c 33 d4 2e 40 c8 0c |...!.....L3..@..|
1170 0220: 99 8f 94 21 17 a9 8b f3 ad 4c 33 d4 2e 40 c8 0c |...!.....L3..@..|
1169 0230: 3b 90 53 39 db 48 02 34 83 48 d6 b3 99 13 d2 58 |;.S9.H.4.H.....X|
1171 0230: 3b 90 53 39 db 48 02 34 83 48 d6 b3 99 13 d2 58 |;.S9.H.4.H.....X|
1170 0240: 65 8e 71 ac a9 06 95 f2 c4 8e b4 08 6b d3 0c ae |e.q.........k...|
1172 0240: 65 8e 71 ac a9 06 95 f2 c4 8e b4 08 6b d3 0c ae |e.q.........k...|
1171 0250: d9 90 56 71 43 a7 a2 62 16 3e 50 63 d3 57 3c 2d |..VqC..b.>Pc.W<-|
1173 0250: d9 90 56 71 43 a7 a2 62 16 3e 50 63 d3 57 3c 2d |..VqC..b.>Pc.W<-|
1172 0260: 9f 0f 34 05 08 d8 a6 4b 59 31 54 66 3a 45 0c 8a |..4....KY1Tf:E..|
1174 0260: 9f 0f 34 05 08 d8 a6 4b 59 31 54 66 3a 45 0c 8a |..4....KY1Tf:E..|
1173 0270: c7 90 3a f0 6a 83 1b f5 ca fb 80 2b 50 06 fb 51 |..:.j......+P..Q|
1175 0270: c7 90 3a f0 6a 83 1b f5 ca fb 80 2b 50 06 fb 51 |..:.j......+P..Q|
1174 0280: 7e a6 a4 d4 81 44 82 21 54 00 5b 1a 30 83 62 a3 |~....D.!T.[.0.b.|
1176 0280: 7e a6 a4 d4 81 44 82 21 54 00 5b 1a 30 83 62 a3 |~....D.!T.[.0.b.|
1175 0290: 18 b6 24 19 1e 45 df 4d 5c db a6 af 5b ac 90 fa |..$..E.M\...[...|
1177 0290: 18 b6 24 19 1e 45 df 4d 5c db a6 af 5b ac 90 fa |..$..E.M\...[...|
1176 02a0: 3e ed f9 ec 4c ba 36 ee d8 60 20 a7 c7 3b cb d1 |>...L.6..` ..;..|
1178 02a0: 3e ed f9 ec 4c ba 36 ee d8 60 20 a7 c7 3b cb d1 |>...L.6..` ..;..|
1177 02b0: 90 43 7d 27 16 50 5d ad f4 14 07 0b 90 5c cc 6b |.C}'.P]......\.k|
1179 02b0: 90 43 7d 27 16 50 5d ad f4 14 07 0b 90 5c cc 6b |.C}'.P]......\.k|
1178 02c0: 8d 3f a6 88 f4 34 37 a8 cf 14 63 36 19 f7 3e 28 |.?...47...c6..>(|
1180 02c0: 8d 3f a6 88 f4 34 37 a8 cf 14 63 36 19 f7 3e 28 |.?...47...c6..>(|
1179 02d0: de 99 e8 16 a4 9d 0d 40 a1 a7 24 52 14 a6 72 62 |.......@..$R..rb|
1181 02d0: de 99 e8 16 a4 9d 0d 40 a1 a7 24 52 14 a6 72 62 |.......@..$R..rb|
1180 02e0: 59 5a ca 2d e5 51 90 78 88 d9 c6 c7 21 d0 f7 46 |YZ.-.Q.x....!..F|
1182 02e0: 59 5a ca 2d e5 51 90 78 88 d9 c6 c7 21 d0 f7 46 |YZ.-.Q.x....!..F|
1181 02f0: b2 04 46 44 4e 20 9c 12 b1 03 4e 25 e0 a9 0c 58 |..FDN ....N%...X|
1183 02f0: b2 04 46 44 4e 20 9c 12 b1 03 4e 25 e0 a9 0c 58 |..FDN ....N%...X|
1182 0300: 5b 1d 3c 93 20 01 51 de a9 1c 69 23 32 46 14 b4 |[.<. .Q...i#2F..|
1184 0300: 5b 1d 3c 93 20 01 51 de a9 1c 69 23 32 46 14 b4 |[.<. .Q...i#2F..|
1183 0310: 90 db 17 98 98 50 03 90 29 aa 40 b0 13 d8 43 d2 |.....P..).@...C.|
1185 0310: 90 db 17 98 98 50 03 90 29 aa 40 b0 13 d8 43 d2 |.....P..).@...C.|
1184 0320: 5f c5 9d eb f3 f2 ad 41 e8 7a a9 ed a1 58 84 a6 |_......A.z...X..|
1186 0320: 5f c5 9d eb f3 f2 ad 41 e8 7a a9 ed a1 58 84 a6 |_......A.z...X..|
1185 0330: 42 bf d6 fc 24 82 c1 20 32 26 4a 15 a6 1d 29 7f |B...$.. 2&J...).|
1187 0330: 42 bf d6 fc 24 82 c1 20 32 26 4a 15 a6 1d 29 7f |B...$.. 2&J...).|
1186 0340: 7e f4 3d 07 bc 62 9a 5b ec 44 3d 72 1d 41 8b 5c |~.=..b.[.D=r.A.\|
1188 0340: 7e f4 3d 07 bc 62 9a 5b ec 44 3d 72 1d 41 8b 5c |~.=..b.[.D=r.A.\|
1187 0350: 80 de 0e 62 9a 2e f8 83 00 d5 07 a0 9c c6 74 98 |...b..........t.|
1189 0350: 80 de 0e 62 9a 2e f8 83 00 d5 07 a0 9c c6 74 98 |...b..........t.|
1188 0360: 11 b2 5e a9 38 02 03 ee fd 86 5c f4 86 b3 ae da |..^.8.....\.....|
1190 0360: 11 b2 5e a9 38 02 03 ee fd 86 5c f4 86 b3 ae da |..^.8.....\.....|
1189 0370: 05 94 01 c5 c6 ea 18 e6 ba 2a ba b3 04 5c 96 89 |.........*...\..|
1191 0370: 05 94 01 c5 c6 ea 18 e6 ba 2a ba b3 04 5c 96 89 |.........*...\..|
1190 0380: 72 63 5b 10 11 f6 67 34 98 cb e4 c0 4e fa e6 99 |rc[...g4....N...|
1192 0380: 72 63 5b 10 11 f6 67 34 98 cb e4 c0 4e fa e6 99 |rc[...g4....N...|
1191 0390: 19 6e 50 e8 26 8d 0c 17 e0 be ef e1 8e 02 6f 32 |.nP.&.........o2|
1193 0390: 19 6e 50 e8 26 8d 0c 17 e0 be ef e1 8e 02 6f 32 |.nP.&.........o2|
1192 03a0: 82 dc 26 f8 a1 08 f3 8a 0d f3 c4 75 00 48 73 b8 |..&........u.Hs.|
1194 03a0: 82 dc 26 f8 a1 08 f3 8a 0d f3 c4 75 00 48 73 b8 |..&........u.Hs.|
1193 03b0: be 3b 0d 7f d0 fd c7 78 96 ec e0 03 80 68 4d 8d |.;.....x.....hM.|
1195 03b0: be 3b 0d 7f d0 fd c7 78 96 ec e0 03 80 68 4d 8d |.;.....x.....hM.|
1194 03c0: 43 8c d7 68 58 f9 50 f0 18 cb 21 58 1b 60 cd 1f |C..hX.P...!X.`..|
1196 03c0: 43 8c d7 68 58 f9 50 f0 18 cb 21 58 1b 60 cd 1f |C..hX.P...!X.`..|
1195 03d0: 84 36 2e 16 1f 0a f7 4e 8f eb df 01 2d c2 79 0b |.6.....N....-.y.|
1197 03d0: 84 36 2e 16 1f 0a f7 4e 8f eb df 01 2d c2 79 0b |.6.....N....-.y.|
1196 03e0: f7 24 ea 0d e8 59 86 51 6e 1c 30 a3 ad 2f ee 8c |.$...Y.Qn.0../..|
1198 03e0: f7 24 ea 0d e8 59 86 51 6e 1c 30 a3 ad 2f ee 8c |.$...Y.Qn.0../..|
1197 03f0: 90 c8 84 d5 e8 34 c1 95 b2 c9 f6 4d 87 1c 7d 19 |.....4.....M..}.|
1199 03f0: 90 c8 84 d5 e8 34 c1 95 b2 c9 f6 4d 87 1c 7d 19 |.....4.....M..}.|
1198 0400: d6 41 58 56 7a e0 6c ba 10 c7 e8 33 39 36 96 e7 |.AXVz.l....396..|
1200 0400: d6 41 58 56 7a e0 6c ba 10 c7 e8 33 39 36 96 e7 |.AXVz.l....396..|
1199 0410: d2 f9 59 9a 08 95 48 38 e7 0b b7 0a 24 67 c4 39 |..Y...H8....$g.9|
1201 0410: d2 f9 59 9a 08 95 48 38 e7 0b b7 0a 24 67 c4 39 |..Y...H8....$g.9|
1200 0420: 8b 43 88 57 9c 01 f5 61 b5 e1 27 41 7e af 83 fe |.C.W...a..'A~...|
1202 0420: 8b 43 88 57 9c 01 f5 61 b5 e1 27 41 7e af 83 fe |.C.W...a..'A~...|
1201 0430: 2e e4 8a 70 a1 21 46 96 30 7a |...p.!F.0z|
1203 0430: 2e e4 8a 70 a1 21 46 96 30 7a |...p.!F.0z|
1202 $ hg debugbundle ../rev.hg2.bz
1204 $ hg debugbundle ../rev.hg2.bz
1203 Stream params: {'Compression': 'BZ'}
1205 Stream params: {'Compression': 'BZ'}
1204 changegroup -- '{}'
1206 changegroup -- '{}'
1205 32af7686d403cf45b5d95f2d70cebea587ac806a
1207 32af7686d403cf45b5d95f2d70cebea587ac806a
1206 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
1208 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
1207 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
1209 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
1208 02de42196ebee42ef284b6780a87cdc96e8eaab6
1210 02de42196ebee42ef284b6780a87cdc96e8eaab6
1209 $ hg unbundle ../rev.hg2.bz
1211 $ hg unbundle ../rev.hg2.bz
1210 adding changesets
1212 adding changesets
1211 adding manifests
1213 adding manifests
1212 adding file changes
1214 adding file changes
1213 added 0 changesets with 0 changes to 3 files
1215 added 0 changesets with 0 changes to 3 files
1216 (run 'hg update' to get a working copy)
1214
1217
1215 unknown compression while unbundling
1218 unknown compression while unbundling
1216 -----------------------------
1219 -----------------------------
1217
1220
1218 $ hg bundle2 --param Compression=FooBarUnknown --rev '8+7+5+4' ../rev.hg2.bz
1221 $ hg bundle2 --param Compression=FooBarUnknown --rev '8+7+5+4' ../rev.hg2.bz
1219 $ cat ../rev.hg2.bz | hg statbundle2
1222 $ cat ../rev.hg2.bz | hg statbundle2
1220 abort: unknown parameters: Stream Parameter - Compression='FooBarUnknown'
1223 abort: unknown parameters: Stream Parameter - Compression='FooBarUnknown'
1221 [255]
1224 [255]
1222 $ hg unbundle ../rev.hg2.bz
1225 $ hg unbundle ../rev.hg2.bz
1223 abort: ../rev.hg2.bz: unknown bundle feature, Stream Parameter - Compression='FooBarUnknown'
1226 abort: ../rev.hg2.bz: unknown bundle feature, Stream Parameter - Compression='FooBarUnknown'
1224 (see https://mercurial-scm.org/wiki/BundleFeature for more information)
1227 (see https://mercurial-scm.org/wiki/BundleFeature for more information)
1225 [255]
1228 [255]
1226
1229
1227 $ cd ..
1230 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now