##// END OF EJS Templates
commands: document return values of add and paths commands
Nicolas Dumazet -
r11507:35e2d453 stable
parent child Browse files
Show More
@@ -1,4459 +1,4463
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, nullid, nullrev, short
8 from node import hex, nullid, nullrev, short
9 from lock import release
9 from lock import release
10 from i18n import _, gettext
10 from i18n import _, gettext
11 import os, re, sys, difflib, time, tempfile
11 import os, re, sys, difflib, time, tempfile
12 import hg, util, revlog, bundlerepo, extensions, copies, error
12 import hg, util, revlog, bundlerepo, extensions, copies, error
13 import patch, help, mdiff, url, encoding, templatekw, discovery
13 import patch, help, mdiff, url, encoding, templatekw, discovery
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server
15 import merge as mergemod
15 import merge as mergemod
16 import minirst, revset
16 import minirst, revset
17 import dagparser
17 import dagparser
18
18
19 # Commands start here, listed alphabetically
19 # Commands start here, listed alphabetically
20
20
21 def add(ui, repo, *pats, **opts):
21 def add(ui, repo, *pats, **opts):
22 """add the specified files on the next commit
22 """add the specified files on the next commit
23
23
24 Schedule files to be version controlled and added to the
24 Schedule files to be version controlled and added to the
25 repository.
25 repository.
26
26
27 The files will be added to the repository at the next commit. To
27 The files will be added to the repository at the next commit. To
28 undo an add before that, see :hg:`forget`.
28 undo an add before that, see :hg:`forget`.
29
29
30 If no names are given, add all files to the repository.
30 If no names are given, add all files to the repository.
31
31
32 .. container:: verbose
32 .. container:: verbose
33
33
34 An example showing how new (unknown) files are added
34 An example showing how new (unknown) files are added
35 automatically by :hg:`add`::
35 automatically by :hg:`add`::
36
36
37 $ ls
37 $ ls
38 foo.c
38 foo.c
39 $ hg status
39 $ hg status
40 ? foo.c
40 ? foo.c
41 $ hg add
41 $ hg add
42 adding foo.c
42 adding foo.c
43 $ hg status
43 $ hg status
44 A foo.c
44 A foo.c
45
46 Returns 0 if all files are successfully added.
45 """
47 """
46
48
47 bad = []
49 bad = []
48 names = []
50 names = []
49 m = cmdutil.match(repo, pats, opts)
51 m = cmdutil.match(repo, pats, opts)
50 oldbad = m.bad
52 oldbad = m.bad
51 m.bad = lambda x, y: bad.append(x) or oldbad(x, y)
53 m.bad = lambda x, y: bad.append(x) or oldbad(x, y)
52
54
53 for f in repo.walk(m):
55 for f in repo.walk(m):
54 exact = m.exact(f)
56 exact = m.exact(f)
55 if exact or f not in repo.dirstate:
57 if exact or f not in repo.dirstate:
56 names.append(f)
58 names.append(f)
57 if ui.verbose or not exact:
59 if ui.verbose or not exact:
58 ui.status(_('adding %s\n') % m.rel(f))
60 ui.status(_('adding %s\n') % m.rel(f))
59 if not opts.get('dry_run'):
61 if not opts.get('dry_run'):
60 bad += [f for f in repo[None].add(names) if f in m.files()]
62 bad += [f for f in repo[None].add(names) if f in m.files()]
61 return bad and 1 or 0
63 return bad and 1 or 0
62
64
63 def addremove(ui, repo, *pats, **opts):
65 def addremove(ui, repo, *pats, **opts):
64 """add all new files, delete all missing files
66 """add all new files, delete all missing files
65
67
66 Add all new files and remove all missing files from the
68 Add all new files and remove all missing files from the
67 repository.
69 repository.
68
70
69 New files are ignored if they match any of the patterns in
71 New files are ignored if they match any of the patterns in
70 .hgignore. As with add, these changes take effect at the next
72 .hgignore. As with add, these changes take effect at the next
71 commit.
73 commit.
72
74
73 Use the -s/--similarity option to detect renamed files. With a
75 Use the -s/--similarity option to detect renamed files. With a
74 parameter greater than 0, this compares every removed file with
76 parameter greater than 0, this compares every removed file with
75 every added file and records those similar enough as renames. This
77 every added file and records those similar enough as renames. This
76 option takes a percentage between 0 (disabled) and 100 (files must
78 option takes a percentage between 0 (disabled) and 100 (files must
77 be identical) as its parameter. Detecting renamed files this way
79 be identical) as its parameter. Detecting renamed files this way
78 can be expensive.
80 can be expensive.
79
81
80 Returns 0 if all files are successfully added.
82 Returns 0 if all files are successfully added.
81 """
83 """
82 try:
84 try:
83 sim = float(opts.get('similarity') or 0)
85 sim = float(opts.get('similarity') or 0)
84 except ValueError:
86 except ValueError:
85 raise util.Abort(_('similarity must be a number'))
87 raise util.Abort(_('similarity must be a number'))
86 if sim < 0 or sim > 100:
88 if sim < 0 or sim > 100:
87 raise util.Abort(_('similarity must be between 0 and 100'))
89 raise util.Abort(_('similarity must be between 0 and 100'))
88 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
90 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
89
91
90 def annotate(ui, repo, *pats, **opts):
92 def annotate(ui, repo, *pats, **opts):
91 """show changeset information by line for each file
93 """show changeset information by line for each file
92
94
93 List changes in files, showing the revision id responsible for
95 List changes in files, showing the revision id responsible for
94 each line
96 each line
95
97
96 This command is useful for discovering when a change was made and
98 This command is useful for discovering when a change was made and
97 by whom.
99 by whom.
98
100
99 Without the -a/--text option, annotate will avoid processing files
101 Without the -a/--text option, annotate will avoid processing files
100 it detects as binary. With -a, annotate will annotate the file
102 it detects as binary. With -a, annotate will annotate the file
101 anyway, although the results will probably be neither useful
103 anyway, although the results will probably be neither useful
102 nor desirable.
104 nor desirable.
103
105
104 Returns 0 on success.
106 Returns 0 on success.
105 """
107 """
106 if opts.get('follow'):
108 if opts.get('follow'):
107 # --follow is deprecated and now just an alias for -f/--file
109 # --follow is deprecated and now just an alias for -f/--file
108 # to mimic the behavior of Mercurial before version 1.5
110 # to mimic the behavior of Mercurial before version 1.5
109 opts['file'] = 1
111 opts['file'] = 1
110
112
111 datefunc = ui.quiet and util.shortdate or util.datestr
113 datefunc = ui.quiet and util.shortdate or util.datestr
112 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
114 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
113
115
114 if not pats:
116 if not pats:
115 raise util.Abort(_('at least one filename or pattern is required'))
117 raise util.Abort(_('at least one filename or pattern is required'))
116
118
117 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
119 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
118 ('number', lambda x: str(x[0].rev())),
120 ('number', lambda x: str(x[0].rev())),
119 ('changeset', lambda x: short(x[0].node())),
121 ('changeset', lambda x: short(x[0].node())),
120 ('date', getdate),
122 ('date', getdate),
121 ('file', lambda x: x[0].path()),
123 ('file', lambda x: x[0].path()),
122 ]
124 ]
123
125
124 if (not opts.get('user') and not opts.get('changeset')
126 if (not opts.get('user') and not opts.get('changeset')
125 and not opts.get('date') and not opts.get('file')):
127 and not opts.get('date') and not opts.get('file')):
126 opts['number'] = 1
128 opts['number'] = 1
127
129
128 linenumber = opts.get('line_number') is not None
130 linenumber = opts.get('line_number') is not None
129 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
131 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
130 raise util.Abort(_('at least one of -n/-c is required for -l'))
132 raise util.Abort(_('at least one of -n/-c is required for -l'))
131
133
132 funcmap = [func for op, func in opmap if opts.get(op)]
134 funcmap = [func for op, func in opmap if opts.get(op)]
133 if linenumber:
135 if linenumber:
134 lastfunc = funcmap[-1]
136 lastfunc = funcmap[-1]
135 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
137 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
136
138
137 ctx = repo[opts.get('rev')]
139 ctx = repo[opts.get('rev')]
138 m = cmdutil.match(repo, pats, opts)
140 m = cmdutil.match(repo, pats, opts)
139 follow = not opts.get('no_follow')
141 follow = not opts.get('no_follow')
140 for abs in ctx.walk(m):
142 for abs in ctx.walk(m):
141 fctx = ctx[abs]
143 fctx = ctx[abs]
142 if not opts.get('text') and util.binary(fctx.data()):
144 if not opts.get('text') and util.binary(fctx.data()):
143 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
145 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
144 continue
146 continue
145
147
146 lines = fctx.annotate(follow=follow, linenumber=linenumber)
148 lines = fctx.annotate(follow=follow, linenumber=linenumber)
147 pieces = []
149 pieces = []
148
150
149 for f in funcmap:
151 for f in funcmap:
150 l = [f(n) for n, dummy in lines]
152 l = [f(n) for n, dummy in lines]
151 if l:
153 if l:
152 ml = max(map(len, l))
154 ml = max(map(len, l))
153 pieces.append(["%*s" % (ml, x) for x in l])
155 pieces.append(["%*s" % (ml, x) for x in l])
154
156
155 if pieces:
157 if pieces:
156 for p, l in zip(zip(*pieces), lines):
158 for p, l in zip(zip(*pieces), lines):
157 ui.write("%s: %s" % (" ".join(p), l[1]))
159 ui.write("%s: %s" % (" ".join(p), l[1]))
158
160
159 def archive(ui, repo, dest, **opts):
161 def archive(ui, repo, dest, **opts):
160 '''create an unversioned archive of a repository revision
162 '''create an unversioned archive of a repository revision
161
163
162 By default, the revision used is the parent of the working
164 By default, the revision used is the parent of the working
163 directory; use -r/--rev to specify a different revision.
165 directory; use -r/--rev to specify a different revision.
164
166
165 The archive type is automatically detected based on file
167 The archive type is automatically detected based on file
166 extension (or override using -t/--type).
168 extension (or override using -t/--type).
167
169
168 Valid types are:
170 Valid types are:
169
171
170 :``files``: a directory full of files (default)
172 :``files``: a directory full of files (default)
171 :``tar``: tar archive, uncompressed
173 :``tar``: tar archive, uncompressed
172 :``tbz2``: tar archive, compressed using bzip2
174 :``tbz2``: tar archive, compressed using bzip2
173 :``tgz``: tar archive, compressed using gzip
175 :``tgz``: tar archive, compressed using gzip
174 :``uzip``: zip archive, uncompressed
176 :``uzip``: zip archive, uncompressed
175 :``zip``: zip archive, compressed using deflate
177 :``zip``: zip archive, compressed using deflate
176
178
177 The exact name of the destination archive or directory is given
179 The exact name of the destination archive or directory is given
178 using a format string; see :hg:`help export` for details.
180 using a format string; see :hg:`help export` for details.
179
181
180 Each member added to an archive file has a directory prefix
182 Each member added to an archive file has a directory prefix
181 prepended. Use -p/--prefix to specify a format string for the
183 prepended. Use -p/--prefix to specify a format string for the
182 prefix. The default is the basename of the archive, with suffixes
184 prefix. The default is the basename of the archive, with suffixes
183 removed.
185 removed.
184
186
185 Returns 0 on success.
187 Returns 0 on success.
186 '''
188 '''
187
189
188 ctx = repo[opts.get('rev')]
190 ctx = repo[opts.get('rev')]
189 if not ctx:
191 if not ctx:
190 raise util.Abort(_('no working directory: please specify a revision'))
192 raise util.Abort(_('no working directory: please specify a revision'))
191 node = ctx.node()
193 node = ctx.node()
192 dest = cmdutil.make_filename(repo, dest, node)
194 dest = cmdutil.make_filename(repo, dest, node)
193 if os.path.realpath(dest) == repo.root:
195 if os.path.realpath(dest) == repo.root:
194 raise util.Abort(_('repository root cannot be destination'))
196 raise util.Abort(_('repository root cannot be destination'))
195
197
196 def guess_type():
198 def guess_type():
197 exttypes = {
199 exttypes = {
198 'tar': ['.tar'],
200 'tar': ['.tar'],
199 'tbz2': ['.tbz2', '.tar.bz2'],
201 'tbz2': ['.tbz2', '.tar.bz2'],
200 'tgz': ['.tgz', '.tar.gz'],
202 'tgz': ['.tgz', '.tar.gz'],
201 'zip': ['.zip'],
203 'zip': ['.zip'],
202 }
204 }
203
205
204 for type, extensions in exttypes.items():
206 for type, extensions in exttypes.items():
205 if util.any(dest.endswith(ext) for ext in extensions):
207 if util.any(dest.endswith(ext) for ext in extensions):
206 return type
208 return type
207 return None
209 return None
208
210
209 kind = opts.get('type') or guess_type() or 'files'
211 kind = opts.get('type') or guess_type() or 'files'
210 prefix = opts.get('prefix')
212 prefix = opts.get('prefix')
211
213
212 if dest == '-':
214 if dest == '-':
213 if kind == 'files':
215 if kind == 'files':
214 raise util.Abort(_('cannot archive plain files to stdout'))
216 raise util.Abort(_('cannot archive plain files to stdout'))
215 dest = sys.stdout
217 dest = sys.stdout
216 if not prefix:
218 if not prefix:
217 prefix = os.path.basename(repo.root) + '-%h'
219 prefix = os.path.basename(repo.root) + '-%h'
218
220
219 prefix = cmdutil.make_filename(repo, prefix, node)
221 prefix = cmdutil.make_filename(repo, prefix, node)
220 matchfn = cmdutil.match(repo, [], opts)
222 matchfn = cmdutil.match(repo, [], opts)
221 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
223 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
222 matchfn, prefix)
224 matchfn, prefix)
223
225
224 def backout(ui, repo, node=None, rev=None, **opts):
226 def backout(ui, repo, node=None, rev=None, **opts):
225 '''reverse effect of earlier changeset
227 '''reverse effect of earlier changeset
226
228
227 Commit the backed out changes as a new changeset. The new
229 Commit the backed out changes as a new changeset. The new
228 changeset is a child of the backed out changeset.
230 changeset is a child of the backed out changeset.
229
231
230 If you backout a changeset other than the tip, a new head is
232 If you backout a changeset other than the tip, a new head is
231 created. This head will be the new tip and you should merge this
233 created. This head will be the new tip and you should merge this
232 backout changeset with another head.
234 backout changeset with another head.
233
235
234 The --merge option remembers the parent of the working directory
236 The --merge option remembers the parent of the working directory
235 before starting the backout, then merges the new head with that
237 before starting the backout, then merges the new head with that
236 changeset afterwards. This saves you from doing the merge by hand.
238 changeset afterwards. This saves you from doing the merge by hand.
237 The result of this merge is not committed, as with a normal merge.
239 The result of this merge is not committed, as with a normal merge.
238
240
239 See :hg:`help dates` for a list of formats valid for -d/--date.
241 See :hg:`help dates` for a list of formats valid for -d/--date.
240
242
241 Returns 0 on success.
243 Returns 0 on success.
242 '''
244 '''
243 if rev and node:
245 if rev and node:
244 raise util.Abort(_("please specify just one revision"))
246 raise util.Abort(_("please specify just one revision"))
245
247
246 if not rev:
248 if not rev:
247 rev = node
249 rev = node
248
250
249 if not rev:
251 if not rev:
250 raise util.Abort(_("please specify a revision to backout"))
252 raise util.Abort(_("please specify a revision to backout"))
251
253
252 date = opts.get('date')
254 date = opts.get('date')
253 if date:
255 if date:
254 opts['date'] = util.parsedate(date)
256 opts['date'] = util.parsedate(date)
255
257
256 cmdutil.bail_if_changed(repo)
258 cmdutil.bail_if_changed(repo)
257 node = repo.lookup(rev)
259 node = repo.lookup(rev)
258
260
259 op1, op2 = repo.dirstate.parents()
261 op1, op2 = repo.dirstate.parents()
260 a = repo.changelog.ancestor(op1, node)
262 a = repo.changelog.ancestor(op1, node)
261 if a != node:
263 if a != node:
262 raise util.Abort(_('cannot backout change on a different branch'))
264 raise util.Abort(_('cannot backout change on a different branch'))
263
265
264 p1, p2 = repo.changelog.parents(node)
266 p1, p2 = repo.changelog.parents(node)
265 if p1 == nullid:
267 if p1 == nullid:
266 raise util.Abort(_('cannot backout a change with no parents'))
268 raise util.Abort(_('cannot backout a change with no parents'))
267 if p2 != nullid:
269 if p2 != nullid:
268 if not opts.get('parent'):
270 if not opts.get('parent'):
269 raise util.Abort(_('cannot backout a merge changeset without '
271 raise util.Abort(_('cannot backout a merge changeset without '
270 '--parent'))
272 '--parent'))
271 p = repo.lookup(opts['parent'])
273 p = repo.lookup(opts['parent'])
272 if p not in (p1, p2):
274 if p not in (p1, p2):
273 raise util.Abort(_('%s is not a parent of %s') %
275 raise util.Abort(_('%s is not a parent of %s') %
274 (short(p), short(node)))
276 (short(p), short(node)))
275 parent = p
277 parent = p
276 else:
278 else:
277 if opts.get('parent'):
279 if opts.get('parent'):
278 raise util.Abort(_('cannot use --parent on non-merge changeset'))
280 raise util.Abort(_('cannot use --parent on non-merge changeset'))
279 parent = p1
281 parent = p1
280
282
281 # the backout should appear on the same branch
283 # the backout should appear on the same branch
282 branch = repo.dirstate.branch()
284 branch = repo.dirstate.branch()
283 hg.clean(repo, node, show_stats=False)
285 hg.clean(repo, node, show_stats=False)
284 repo.dirstate.setbranch(branch)
286 repo.dirstate.setbranch(branch)
285 revert_opts = opts.copy()
287 revert_opts = opts.copy()
286 revert_opts['date'] = None
288 revert_opts['date'] = None
287 revert_opts['all'] = True
289 revert_opts['all'] = True
288 revert_opts['rev'] = hex(parent)
290 revert_opts['rev'] = hex(parent)
289 revert_opts['no_backup'] = None
291 revert_opts['no_backup'] = None
290 revert(ui, repo, **revert_opts)
292 revert(ui, repo, **revert_opts)
291 commit_opts = opts.copy()
293 commit_opts = opts.copy()
292 commit_opts['addremove'] = False
294 commit_opts['addremove'] = False
293 if not commit_opts['message'] and not commit_opts['logfile']:
295 if not commit_opts['message'] and not commit_opts['logfile']:
294 # we don't translate commit messages
296 # we don't translate commit messages
295 commit_opts['message'] = "Backed out changeset %s" % short(node)
297 commit_opts['message'] = "Backed out changeset %s" % short(node)
296 commit_opts['force_editor'] = True
298 commit_opts['force_editor'] = True
297 commit(ui, repo, **commit_opts)
299 commit(ui, repo, **commit_opts)
298 def nice(node):
300 def nice(node):
299 return '%d:%s' % (repo.changelog.rev(node), short(node))
301 return '%d:%s' % (repo.changelog.rev(node), short(node))
300 ui.status(_('changeset %s backs out changeset %s\n') %
302 ui.status(_('changeset %s backs out changeset %s\n') %
301 (nice(repo.changelog.tip()), nice(node)))
303 (nice(repo.changelog.tip()), nice(node)))
302 if op1 != node:
304 if op1 != node:
303 hg.clean(repo, op1, show_stats=False)
305 hg.clean(repo, op1, show_stats=False)
304 if opts.get('merge'):
306 if opts.get('merge'):
305 ui.status(_('merging with changeset %s\n')
307 ui.status(_('merging with changeset %s\n')
306 % nice(repo.changelog.tip()))
308 % nice(repo.changelog.tip()))
307 hg.merge(repo, hex(repo.changelog.tip()))
309 hg.merge(repo, hex(repo.changelog.tip()))
308 else:
310 else:
309 ui.status(_('the backout changeset is a new head - '
311 ui.status(_('the backout changeset is a new head - '
310 'do not forget to merge\n'))
312 'do not forget to merge\n'))
311 ui.status(_('(use "backout --merge" '
313 ui.status(_('(use "backout --merge" '
312 'if you want to auto-merge)\n'))
314 'if you want to auto-merge)\n'))
313
315
314 def bisect(ui, repo, rev=None, extra=None, command=None,
316 def bisect(ui, repo, rev=None, extra=None, command=None,
315 reset=None, good=None, bad=None, skip=None, noupdate=None):
317 reset=None, good=None, bad=None, skip=None, noupdate=None):
316 """subdivision search of changesets
318 """subdivision search of changesets
317
319
318 This command helps to find changesets which introduce problems. To
320 This command helps to find changesets which introduce problems. To
319 use, mark the earliest changeset you know exhibits the problem as
321 use, mark the earliest changeset you know exhibits the problem as
320 bad, then mark the latest changeset which is free from the problem
322 bad, then mark the latest changeset which is free from the problem
321 as good. Bisect will update your working directory to a revision
323 as good. Bisect will update your working directory to a revision
322 for testing (unless the -U/--noupdate option is specified). Once
324 for testing (unless the -U/--noupdate option is specified). Once
323 you have performed tests, mark the working directory as good or
325 you have performed tests, mark the working directory as good or
324 bad, and bisect will either update to another candidate changeset
326 bad, and bisect will either update to another candidate changeset
325 or announce that it has found the bad revision.
327 or announce that it has found the bad revision.
326
328
327 As a shortcut, you can also use the revision argument to mark a
329 As a shortcut, you can also use the revision argument to mark a
328 revision as good or bad without checking it out first.
330 revision as good or bad without checking it out first.
329
331
330 If you supply a command, it will be used for automatic bisection.
332 If you supply a command, it will be used for automatic bisection.
331 Its exit status will be used to mark revisions as good or bad:
333 Its exit status will be used to mark revisions as good or bad:
332 status 0 means good, 125 means to skip the revision, 127
334 status 0 means good, 125 means to skip the revision, 127
333 (command not found) will abort the bisection, and any other
335 (command not found) will abort the bisection, and any other
334 non-zero exit status means the revision is bad.
336 non-zero exit status means the revision is bad.
335
337
336 Returns 0 on success.
338 Returns 0 on success.
337 """
339 """
338 def print_result(nodes, good):
340 def print_result(nodes, good):
339 displayer = cmdutil.show_changeset(ui, repo, {})
341 displayer = cmdutil.show_changeset(ui, repo, {})
340 if len(nodes) == 1:
342 if len(nodes) == 1:
341 # narrowed it down to a single revision
343 # narrowed it down to a single revision
342 if good:
344 if good:
343 ui.write(_("The first good revision is:\n"))
345 ui.write(_("The first good revision is:\n"))
344 else:
346 else:
345 ui.write(_("The first bad revision is:\n"))
347 ui.write(_("The first bad revision is:\n"))
346 displayer.show(repo[nodes[0]])
348 displayer.show(repo[nodes[0]])
347 else:
349 else:
348 # multiple possible revisions
350 # multiple possible revisions
349 if good:
351 if good:
350 ui.write(_("Due to skipped revisions, the first "
352 ui.write(_("Due to skipped revisions, the first "
351 "good revision could be any of:\n"))
353 "good revision could be any of:\n"))
352 else:
354 else:
353 ui.write(_("Due to skipped revisions, the first "
355 ui.write(_("Due to skipped revisions, the first "
354 "bad revision could be any of:\n"))
356 "bad revision could be any of:\n"))
355 for n in nodes:
357 for n in nodes:
356 displayer.show(repo[n])
358 displayer.show(repo[n])
357 displayer.close()
359 displayer.close()
358
360
359 def check_state(state, interactive=True):
361 def check_state(state, interactive=True):
360 if not state['good'] or not state['bad']:
362 if not state['good'] or not state['bad']:
361 if (good or bad or skip or reset) and interactive:
363 if (good or bad or skip or reset) and interactive:
362 return
364 return
363 if not state['good']:
365 if not state['good']:
364 raise util.Abort(_('cannot bisect (no known good revisions)'))
366 raise util.Abort(_('cannot bisect (no known good revisions)'))
365 else:
367 else:
366 raise util.Abort(_('cannot bisect (no known bad revisions)'))
368 raise util.Abort(_('cannot bisect (no known bad revisions)'))
367 return True
369 return True
368
370
369 # backward compatibility
371 # backward compatibility
370 if rev in "good bad reset init".split():
372 if rev in "good bad reset init".split():
371 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
373 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
372 cmd, rev, extra = rev, extra, None
374 cmd, rev, extra = rev, extra, None
373 if cmd == "good":
375 if cmd == "good":
374 good = True
376 good = True
375 elif cmd == "bad":
377 elif cmd == "bad":
376 bad = True
378 bad = True
377 else:
379 else:
378 reset = True
380 reset = True
379 elif extra or good + bad + skip + reset + bool(command) > 1:
381 elif extra or good + bad + skip + reset + bool(command) > 1:
380 raise util.Abort(_('incompatible arguments'))
382 raise util.Abort(_('incompatible arguments'))
381
383
382 if reset:
384 if reset:
383 p = repo.join("bisect.state")
385 p = repo.join("bisect.state")
384 if os.path.exists(p):
386 if os.path.exists(p):
385 os.unlink(p)
387 os.unlink(p)
386 return
388 return
387
389
388 state = hbisect.load_state(repo)
390 state = hbisect.load_state(repo)
389
391
390 if command:
392 if command:
391 changesets = 1
393 changesets = 1
392 try:
394 try:
393 while changesets:
395 while changesets:
394 # update state
396 # update state
395 status = util.system(command)
397 status = util.system(command)
396 if status == 125:
398 if status == 125:
397 transition = "skip"
399 transition = "skip"
398 elif status == 0:
400 elif status == 0:
399 transition = "good"
401 transition = "good"
400 # status < 0 means process was killed
402 # status < 0 means process was killed
401 elif status == 127:
403 elif status == 127:
402 raise util.Abort(_("failed to execute %s") % command)
404 raise util.Abort(_("failed to execute %s") % command)
403 elif status < 0:
405 elif status < 0:
404 raise util.Abort(_("%s killed") % command)
406 raise util.Abort(_("%s killed") % command)
405 else:
407 else:
406 transition = "bad"
408 transition = "bad"
407 ctx = repo[rev or '.']
409 ctx = repo[rev or '.']
408 state[transition].append(ctx.node())
410 state[transition].append(ctx.node())
409 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
411 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
410 check_state(state, interactive=False)
412 check_state(state, interactive=False)
411 # bisect
413 # bisect
412 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
414 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
413 # update to next check
415 # update to next check
414 cmdutil.bail_if_changed(repo)
416 cmdutil.bail_if_changed(repo)
415 hg.clean(repo, nodes[0], show_stats=False)
417 hg.clean(repo, nodes[0], show_stats=False)
416 finally:
418 finally:
417 hbisect.save_state(repo, state)
419 hbisect.save_state(repo, state)
418 print_result(nodes, good)
420 print_result(nodes, good)
419 return
421 return
420
422
421 # update state
423 # update state
422 node = repo.lookup(rev or '.')
424 node = repo.lookup(rev or '.')
423 if good or bad or skip:
425 if good or bad or skip:
424 if good:
426 if good:
425 state['good'].append(node)
427 state['good'].append(node)
426 elif bad:
428 elif bad:
427 state['bad'].append(node)
429 state['bad'].append(node)
428 elif skip:
430 elif skip:
429 state['skip'].append(node)
431 state['skip'].append(node)
430 hbisect.save_state(repo, state)
432 hbisect.save_state(repo, state)
431
433
432 if not check_state(state):
434 if not check_state(state):
433 return
435 return
434
436
435 # actually bisect
437 # actually bisect
436 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
438 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
437 if changesets == 0:
439 if changesets == 0:
438 print_result(nodes, good)
440 print_result(nodes, good)
439 else:
441 else:
440 assert len(nodes) == 1 # only a single node can be tested next
442 assert len(nodes) == 1 # only a single node can be tested next
441 node = nodes[0]
443 node = nodes[0]
442 # compute the approximate number of remaining tests
444 # compute the approximate number of remaining tests
443 tests, size = 0, 2
445 tests, size = 0, 2
444 while size <= changesets:
446 while size <= changesets:
445 tests, size = tests + 1, size * 2
447 tests, size = tests + 1, size * 2
446 rev = repo.changelog.rev(node)
448 rev = repo.changelog.rev(node)
447 ui.write(_("Testing changeset %d:%s "
449 ui.write(_("Testing changeset %d:%s "
448 "(%d changesets remaining, ~%d tests)\n")
450 "(%d changesets remaining, ~%d tests)\n")
449 % (rev, short(node), changesets, tests))
451 % (rev, short(node), changesets, tests))
450 if not noupdate:
452 if not noupdate:
451 cmdutil.bail_if_changed(repo)
453 cmdutil.bail_if_changed(repo)
452 return hg.clean(repo, node)
454 return hg.clean(repo, node)
453
455
454 def branch(ui, repo, label=None, **opts):
456 def branch(ui, repo, label=None, **opts):
455 """set or show the current branch name
457 """set or show the current branch name
456
458
457 With no argument, show the current branch name. With one argument,
459 With no argument, show the current branch name. With one argument,
458 set the working directory branch name (the branch will not exist
460 set the working directory branch name (the branch will not exist
459 in the repository until the next commit). Standard practice
461 in the repository until the next commit). Standard practice
460 recommends that primary development take place on the 'default'
462 recommends that primary development take place on the 'default'
461 branch.
463 branch.
462
464
463 Unless -f/--force is specified, branch will not let you set a
465 Unless -f/--force is specified, branch will not let you set a
464 branch name that already exists, even if it's inactive.
466 branch name that already exists, even if it's inactive.
465
467
466 Use -C/--clean to reset the working directory branch to that of
468 Use -C/--clean to reset the working directory branch to that of
467 the parent of the working directory, negating a previous branch
469 the parent of the working directory, negating a previous branch
468 change.
470 change.
469
471
470 Use the command :hg:`update` to switch to an existing branch. Use
472 Use the command :hg:`update` to switch to an existing branch. Use
471 :hg:`commit --close-branch` to mark this branch as closed.
473 :hg:`commit --close-branch` to mark this branch as closed.
472
474
473 Returns 0 on success.
475 Returns 0 on success.
474 """
476 """
475
477
476 if opts.get('clean'):
478 if opts.get('clean'):
477 label = repo[None].parents()[0].branch()
479 label = repo[None].parents()[0].branch()
478 repo.dirstate.setbranch(label)
480 repo.dirstate.setbranch(label)
479 ui.status(_('reset working directory to branch %s\n') % label)
481 ui.status(_('reset working directory to branch %s\n') % label)
480 elif label:
482 elif label:
481 utflabel = encoding.fromlocal(label)
483 utflabel = encoding.fromlocal(label)
482 if not opts.get('force') and utflabel in repo.branchtags():
484 if not opts.get('force') and utflabel in repo.branchtags():
483 if label not in [p.branch() for p in repo.parents()]:
485 if label not in [p.branch() for p in repo.parents()]:
484 raise util.Abort(_('a branch of the same name already exists'
486 raise util.Abort(_('a branch of the same name already exists'
485 " (use 'hg update' to switch to it)"))
487 " (use 'hg update' to switch to it)"))
486 repo.dirstate.setbranch(utflabel)
488 repo.dirstate.setbranch(utflabel)
487 ui.status(_('marked working directory as branch %s\n') % label)
489 ui.status(_('marked working directory as branch %s\n') % label)
488 else:
490 else:
489 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
491 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
490
492
491 def branches(ui, repo, active=False, closed=False):
493 def branches(ui, repo, active=False, closed=False):
492 """list repository named branches
494 """list repository named branches
493
495
494 List the repository's named branches, indicating which ones are
496 List the repository's named branches, indicating which ones are
495 inactive. If -c/--closed is specified, also list branches which have
497 inactive. If -c/--closed is specified, also list branches which have
496 been marked closed (see :hg:`commit --close-branch`).
498 been marked closed (see :hg:`commit --close-branch`).
497
499
498 If -a/--active is specified, only show active branches. A branch
500 If -a/--active is specified, only show active branches. A branch
499 is considered active if it contains repository heads.
501 is considered active if it contains repository heads.
500
502
501 Use the command :hg:`update` to switch to an existing branch.
503 Use the command :hg:`update` to switch to an existing branch.
502
504
503 Returns 0.
505 Returns 0.
504 """
506 """
505
507
506 hexfunc = ui.debugflag and hex or short
508 hexfunc = ui.debugflag and hex or short
507 activebranches = [repo[n].branch() for n in repo.heads()]
509 activebranches = [repo[n].branch() for n in repo.heads()]
508 def testactive(tag, node):
510 def testactive(tag, node):
509 realhead = tag in activebranches
511 realhead = tag in activebranches
510 open = node in repo.branchheads(tag, closed=False)
512 open = node in repo.branchheads(tag, closed=False)
511 return realhead and open
513 return realhead and open
512 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
514 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
513 for tag, node in repo.branchtags().items()],
515 for tag, node in repo.branchtags().items()],
514 reverse=True)
516 reverse=True)
515
517
516 for isactive, node, tag in branches:
518 for isactive, node, tag in branches:
517 if (not active) or isactive:
519 if (not active) or isactive:
518 encodedtag = encoding.tolocal(tag)
520 encodedtag = encoding.tolocal(tag)
519 if ui.quiet:
521 if ui.quiet:
520 ui.write("%s\n" % encodedtag)
522 ui.write("%s\n" % encodedtag)
521 else:
523 else:
522 hn = repo.lookup(node)
524 hn = repo.lookup(node)
523 if isactive:
525 if isactive:
524 notice = ''
526 notice = ''
525 elif hn not in repo.branchheads(tag, closed=False):
527 elif hn not in repo.branchheads(tag, closed=False):
526 if not closed:
528 if not closed:
527 continue
529 continue
528 notice = _(' (closed)')
530 notice = _(' (closed)')
529 else:
531 else:
530 notice = _(' (inactive)')
532 notice = _(' (inactive)')
531 rev = str(node).rjust(31 - encoding.colwidth(encodedtag))
533 rev = str(node).rjust(31 - encoding.colwidth(encodedtag))
532 data = encodedtag, rev, hexfunc(hn), notice
534 data = encodedtag, rev, hexfunc(hn), notice
533 ui.write("%s %s:%s%s\n" % data)
535 ui.write("%s %s:%s%s\n" % data)
534
536
535 def bundle(ui, repo, fname, dest=None, **opts):
537 def bundle(ui, repo, fname, dest=None, **opts):
536 """create a changegroup file
538 """create a changegroup file
537
539
538 Generate a compressed changegroup file collecting changesets not
540 Generate a compressed changegroup file collecting changesets not
539 known to be in another repository.
541 known to be in another repository.
540
542
541 If you omit the destination repository, then hg assumes the
543 If you omit the destination repository, then hg assumes the
542 destination will have all the nodes you specify with --base
544 destination will have all the nodes you specify with --base
543 parameters. To create a bundle containing all changesets, use
545 parameters. To create a bundle containing all changesets, use
544 -a/--all (or --base null).
546 -a/--all (or --base null).
545
547
546 You can change compression method with the -t/--type option.
548 You can change compression method with the -t/--type option.
547 The available compression methods are: none, bzip2, and
549 The available compression methods are: none, bzip2, and
548 gzip (by default, bundles are compressed using bzip2).
550 gzip (by default, bundles are compressed using bzip2).
549
551
550 The bundle file can then be transferred using conventional means
552 The bundle file can then be transferred using conventional means
551 and applied to another repository with the unbundle or pull
553 and applied to another repository with the unbundle or pull
552 command. This is useful when direct push and pull are not
554 command. This is useful when direct push and pull are not
553 available or when exporting an entire repository is undesirable.
555 available or when exporting an entire repository is undesirable.
554
556
555 Applying bundles preserves all changeset contents including
557 Applying bundles preserves all changeset contents including
556 permissions, copy/rename information, and revision history.
558 permissions, copy/rename information, and revision history.
557
559
558 Returns 0 on success, 1 if no changes found.
560 Returns 0 on success, 1 if no changes found.
559 """
561 """
560 revs = opts.get('rev') or None
562 revs = opts.get('rev') or None
561 if revs:
563 if revs:
562 revs = [repo.lookup(rev) for rev in revs]
564 revs = [repo.lookup(rev) for rev in revs]
563 if opts.get('all'):
565 if opts.get('all'):
564 base = ['null']
566 base = ['null']
565 else:
567 else:
566 base = opts.get('base')
568 base = opts.get('base')
567 if base:
569 if base:
568 if dest:
570 if dest:
569 raise util.Abort(_("--base is incompatible with specifying "
571 raise util.Abort(_("--base is incompatible with specifying "
570 "a destination"))
572 "a destination"))
571 base = [repo.lookup(rev) for rev in base]
573 base = [repo.lookup(rev) for rev in base]
572 # create the right base
574 # create the right base
573 # XXX: nodesbetween / changegroup* should be "fixed" instead
575 # XXX: nodesbetween / changegroup* should be "fixed" instead
574 o = []
576 o = []
575 has = set((nullid,))
577 has = set((nullid,))
576 for n in base:
578 for n in base:
577 has.update(repo.changelog.reachable(n))
579 has.update(repo.changelog.reachable(n))
578 if revs:
580 if revs:
579 visit = list(revs)
581 visit = list(revs)
580 has.difference_update(revs)
582 has.difference_update(revs)
581 else:
583 else:
582 visit = repo.changelog.heads()
584 visit = repo.changelog.heads()
583 seen = {}
585 seen = {}
584 while visit:
586 while visit:
585 n = visit.pop(0)
587 n = visit.pop(0)
586 parents = [p for p in repo.changelog.parents(n) if p not in has]
588 parents = [p for p in repo.changelog.parents(n) if p not in has]
587 if len(parents) == 0:
589 if len(parents) == 0:
588 if n not in has:
590 if n not in has:
589 o.append(n)
591 o.append(n)
590 else:
592 else:
591 for p in parents:
593 for p in parents:
592 if p not in seen:
594 if p not in seen:
593 seen[p] = 1
595 seen[p] = 1
594 visit.append(p)
596 visit.append(p)
595 else:
597 else:
596 dest = ui.expandpath(dest or 'default-push', dest or 'default')
598 dest = ui.expandpath(dest or 'default-push', dest or 'default')
597 dest, branches = hg.parseurl(dest, opts.get('branch'))
599 dest, branches = hg.parseurl(dest, opts.get('branch'))
598 other = hg.repository(hg.remoteui(repo, opts), dest)
600 other = hg.repository(hg.remoteui(repo, opts), dest)
599 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
601 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
600 o = discovery.findoutgoing(repo, other, force=opts.get('force'))
602 o = discovery.findoutgoing(repo, other, force=opts.get('force'))
601
603
602 if not o:
604 if not o:
603 ui.status(_("no changes found\n"))
605 ui.status(_("no changes found\n"))
604 return 1
606 return 1
605
607
606 if revs:
608 if revs:
607 cg = repo.changegroupsubset(o, revs, 'bundle')
609 cg = repo.changegroupsubset(o, revs, 'bundle')
608 else:
610 else:
609 cg = repo.changegroup(o, 'bundle')
611 cg = repo.changegroup(o, 'bundle')
610
612
611 bundletype = opts.get('type', 'bzip2').lower()
613 bundletype = opts.get('type', 'bzip2').lower()
612 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
614 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
613 bundletype = btypes.get(bundletype)
615 bundletype = btypes.get(bundletype)
614 if bundletype not in changegroup.bundletypes:
616 if bundletype not in changegroup.bundletypes:
615 raise util.Abort(_('unknown bundle type specified with --type'))
617 raise util.Abort(_('unknown bundle type specified with --type'))
616
618
617 changegroup.writebundle(cg, fname, bundletype)
619 changegroup.writebundle(cg, fname, bundletype)
618
620
619 def cat(ui, repo, file1, *pats, **opts):
621 def cat(ui, repo, file1, *pats, **opts):
620 """output the current or given revision of files
622 """output the current or given revision of files
621
623
622 Print the specified files as they were at the given revision. If
624 Print the specified files as they were at the given revision. If
623 no revision is given, the parent of the working directory is used,
625 no revision is given, the parent of the working directory is used,
624 or tip if no revision is checked out.
626 or tip if no revision is checked out.
625
627
626 Output may be to a file, in which case the name of the file is
628 Output may be to a file, in which case the name of the file is
627 given using a format string. The formatting rules are the same as
629 given using a format string. The formatting rules are the same as
628 for the export command, with the following additions:
630 for the export command, with the following additions:
629
631
630 :``%s``: basename of file being printed
632 :``%s``: basename of file being printed
631 :``%d``: dirname of file being printed, or '.' if in repository root
633 :``%d``: dirname of file being printed, or '.' if in repository root
632 :``%p``: root-relative path name of file being printed
634 :``%p``: root-relative path name of file being printed
633
635
634 Returns 0 on success.
636 Returns 0 on success.
635 """
637 """
636 ctx = repo[opts.get('rev')]
638 ctx = repo[opts.get('rev')]
637 err = 1
639 err = 1
638 m = cmdutil.match(repo, (file1,) + pats, opts)
640 m = cmdutil.match(repo, (file1,) + pats, opts)
639 for abs in ctx.walk(m):
641 for abs in ctx.walk(m):
640 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
642 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
641 data = ctx[abs].data()
643 data = ctx[abs].data()
642 if opts.get('decode'):
644 if opts.get('decode'):
643 data = repo.wwritedata(abs, data)
645 data = repo.wwritedata(abs, data)
644 fp.write(data)
646 fp.write(data)
645 err = 0
647 err = 0
646 return err
648 return err
647
649
648 def clone(ui, source, dest=None, **opts):
650 def clone(ui, source, dest=None, **opts):
649 """make a copy of an existing repository
651 """make a copy of an existing repository
650
652
651 Create a copy of an existing repository in a new directory.
653 Create a copy of an existing repository in a new directory.
652
654
653 If no destination directory name is specified, it defaults to the
655 If no destination directory name is specified, it defaults to the
654 basename of the source.
656 basename of the source.
655
657
656 The location of the source is added to the new repository's
658 The location of the source is added to the new repository's
657 .hg/hgrc file, as the default to be used for future pulls.
659 .hg/hgrc file, as the default to be used for future pulls.
658
660
659 See :hg:`help urls` for valid source format details.
661 See :hg:`help urls` for valid source format details.
660
662
661 It is possible to specify an ``ssh://`` URL as the destination, but no
663 It is possible to specify an ``ssh://`` URL as the destination, but no
662 .hg/hgrc and working directory will be created on the remote side.
664 .hg/hgrc and working directory will be created on the remote side.
663 Please see :hg:`help urls` for important details about ``ssh://`` URLs.
665 Please see :hg:`help urls` for important details about ``ssh://`` URLs.
664
666
665 A set of changesets (tags, or branch names) to pull may be specified
667 A set of changesets (tags, or branch names) to pull may be specified
666 by listing each changeset (tag, or branch name) with -r/--rev.
668 by listing each changeset (tag, or branch name) with -r/--rev.
667 If -r/--rev is used, the cloned repository will contain only a subset
669 If -r/--rev is used, the cloned repository will contain only a subset
668 of the changesets of the source repository. Only the set of changesets
670 of the changesets of the source repository. Only the set of changesets
669 defined by all -r/--rev options (including all their ancestors)
671 defined by all -r/--rev options (including all their ancestors)
670 will be pulled into the destination repository.
672 will be pulled into the destination repository.
671 No subsequent changesets (including subsequent tags) will be present
673 No subsequent changesets (including subsequent tags) will be present
672 in the destination.
674 in the destination.
673
675
674 Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
676 Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
675 local source repositories.
677 local source repositories.
676
678
677 For efficiency, hardlinks are used for cloning whenever the source
679 For efficiency, hardlinks are used for cloning whenever the source
678 and destination are on the same filesystem (note this applies only
680 and destination are on the same filesystem (note this applies only
679 to the repository data, not to the working directory). Some
681 to the repository data, not to the working directory). Some
680 filesystems, such as AFS, implement hardlinking incorrectly, but
682 filesystems, such as AFS, implement hardlinking incorrectly, but
681 do not report errors. In these cases, use the --pull option to
683 do not report errors. In these cases, use the --pull option to
682 avoid hardlinking.
684 avoid hardlinking.
683
685
684 In some cases, you can clone repositories and the working directory
686 In some cases, you can clone repositories and the working directory
685 using full hardlinks with ::
687 using full hardlinks with ::
686
688
687 $ cp -al REPO REPOCLONE
689 $ cp -al REPO REPOCLONE
688
690
689 This is the fastest way to clone, but it is not always safe. The
691 This is the fastest way to clone, but it is not always safe. The
690 operation is not atomic (making sure REPO is not modified during
692 operation is not atomic (making sure REPO is not modified during
691 the operation is up to you) and you have to make sure your editor
693 the operation is up to you) and you have to make sure your editor
692 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
694 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
693 this is not compatible with certain extensions that place their
695 this is not compatible with certain extensions that place their
694 metadata under the .hg directory, such as mq.
696 metadata under the .hg directory, such as mq.
695
697
696 Mercurial will update the working directory to the first applicable
698 Mercurial will update the working directory to the first applicable
697 revision from this list:
699 revision from this list:
698
700
699 a) null if -U or the source repository has no changesets
701 a) null if -U or the source repository has no changesets
700 b) if -u . and the source repository is local, the first parent of
702 b) if -u . and the source repository is local, the first parent of
701 the source repository's working directory
703 the source repository's working directory
702 c) the changeset specified with -u (if a branch name, this means the
704 c) the changeset specified with -u (if a branch name, this means the
703 latest head of that branch)
705 latest head of that branch)
704 d) the changeset specified with -r
706 d) the changeset specified with -r
705 e) the tipmost head specified with -b
707 e) the tipmost head specified with -b
706 f) the tipmost head specified with the url#branch source syntax
708 f) the tipmost head specified with the url#branch source syntax
707 g) the tipmost head of the default branch
709 g) the tipmost head of the default branch
708 h) tip
710 h) tip
709
711
710 Returns 0 on success.
712 Returns 0 on success.
711 """
713 """
712 if opts.get('noupdate') and opts.get('updaterev'):
714 if opts.get('noupdate') and opts.get('updaterev'):
713 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
715 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
714
716
715 r = hg.clone(hg.remoteui(ui, opts), source, dest,
717 r = hg.clone(hg.remoteui(ui, opts), source, dest,
716 pull=opts.get('pull'),
718 pull=opts.get('pull'),
717 stream=opts.get('uncompressed'),
719 stream=opts.get('uncompressed'),
718 rev=opts.get('rev'),
720 rev=opts.get('rev'),
719 update=opts.get('updaterev') or not opts.get('noupdate'),
721 update=opts.get('updaterev') or not opts.get('noupdate'),
720 branch=opts.get('branch'))
722 branch=opts.get('branch'))
721
723
722 return r is None
724 return r is None
723
725
724 def commit(ui, repo, *pats, **opts):
726 def commit(ui, repo, *pats, **opts):
725 """commit the specified files or all outstanding changes
727 """commit the specified files or all outstanding changes
726
728
727 Commit changes to the given files into the repository. Unlike a
729 Commit changes to the given files into the repository. Unlike a
728 centralized RCS, this operation is a local operation. See
730 centralized RCS, this operation is a local operation. See
729 :hg:`push` for a way to actively distribute your changes.
731 :hg:`push` for a way to actively distribute your changes.
730
732
731 If a list of files is omitted, all changes reported by :hg:`status`
733 If a list of files is omitted, all changes reported by :hg:`status`
732 will be committed.
734 will be committed.
733
735
734 If you are committing the result of a merge, do not provide any
736 If you are committing the result of a merge, do not provide any
735 filenames or -I/-X filters.
737 filenames or -I/-X filters.
736
738
737 If no commit message is specified, the configured editor is
739 If no commit message is specified, the configured editor is
738 started to prompt you for a message.
740 started to prompt you for a message.
739
741
740 See :hg:`help dates` for a list of formats valid for -d/--date.
742 See :hg:`help dates` for a list of formats valid for -d/--date.
741
743
742 Returns 0 on success, 1 if nothing changed.
744 Returns 0 on success, 1 if nothing changed.
743 """
745 """
744 extra = {}
746 extra = {}
745 if opts.get('close_branch'):
747 if opts.get('close_branch'):
746 if repo['.'].node() not in repo.branchheads():
748 if repo['.'].node() not in repo.branchheads():
747 # The topo heads set is included in the branch heads set of the
749 # The topo heads set is included in the branch heads set of the
748 # current branch, so it's sufficient to test branchheads
750 # current branch, so it's sufficient to test branchheads
749 raise util.Abort(_('can only close branch heads'))
751 raise util.Abort(_('can only close branch heads'))
750 extra['close'] = 1
752 extra['close'] = 1
751 e = cmdutil.commiteditor
753 e = cmdutil.commiteditor
752 if opts.get('force_editor'):
754 if opts.get('force_editor'):
753 e = cmdutil.commitforceeditor
755 e = cmdutil.commitforceeditor
754
756
755 def commitfunc(ui, repo, message, match, opts):
757 def commitfunc(ui, repo, message, match, opts):
756 return repo.commit(message, opts.get('user'), opts.get('date'), match,
758 return repo.commit(message, opts.get('user'), opts.get('date'), match,
757 editor=e, extra=extra)
759 editor=e, extra=extra)
758
760
759 branch = repo[None].branch()
761 branch = repo[None].branch()
760 bheads = repo.branchheads(branch)
762 bheads = repo.branchheads(branch)
761
763
762 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
764 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
763 if not node:
765 if not node:
764 ui.status(_("nothing changed\n"))
766 ui.status(_("nothing changed\n"))
765 return 1
767 return 1
766
768
767 ctx = repo[node]
769 ctx = repo[node]
768 parents = ctx.parents()
770 parents = ctx.parents()
769
771
770 if bheads and not [x for x in parents
772 if bheads and not [x for x in parents
771 if x.node() in bheads and x.branch() == branch]:
773 if x.node() in bheads and x.branch() == branch]:
772 ui.status(_('created new head\n'))
774 ui.status(_('created new head\n'))
773 # The message is not printed for initial roots. For the other
775 # The message is not printed for initial roots. For the other
774 # changesets, it is printed in the following situations:
776 # changesets, it is printed in the following situations:
775 #
777 #
776 # Par column: for the 2 parents with ...
778 # Par column: for the 2 parents with ...
777 # N: null or no parent
779 # N: null or no parent
778 # B: parent is on another named branch
780 # B: parent is on another named branch
779 # C: parent is a regular non head changeset
781 # C: parent is a regular non head changeset
780 # H: parent was a branch head of the current branch
782 # H: parent was a branch head of the current branch
781 # Msg column: whether we print "created new head" message
783 # Msg column: whether we print "created new head" message
782 # In the following, it is assumed that there already exists some
784 # In the following, it is assumed that there already exists some
783 # initial branch heads of the current branch, otherwise nothing is
785 # initial branch heads of the current branch, otherwise nothing is
784 # printed anyway.
786 # printed anyway.
785 #
787 #
786 # Par Msg Comment
788 # Par Msg Comment
787 # NN y additional topo root
789 # NN y additional topo root
788 #
790 #
789 # BN y additional branch root
791 # BN y additional branch root
790 # CN y additional topo head
792 # CN y additional topo head
791 # HN n usual case
793 # HN n usual case
792 #
794 #
793 # BB y weird additional branch root
795 # BB y weird additional branch root
794 # CB y branch merge
796 # CB y branch merge
795 # HB n merge with named branch
797 # HB n merge with named branch
796 #
798 #
797 # CC y additional head from merge
799 # CC y additional head from merge
798 # CH n merge with a head
800 # CH n merge with a head
799 #
801 #
800 # HH n head merge: head count decreases
802 # HH n head merge: head count decreases
801
803
802 if not opts.get('close_branch'):
804 if not opts.get('close_branch'):
803 for r in parents:
805 for r in parents:
804 if r.extra().get('close'):
806 if r.extra().get('close'):
805 ui.status(_('reopening closed branch head %d\n') % r)
807 ui.status(_('reopening closed branch head %d\n') % r)
806
808
807 if ui.debugflag:
809 if ui.debugflag:
808 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
810 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
809 elif ui.verbose:
811 elif ui.verbose:
810 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
812 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
811
813
812 def copy(ui, repo, *pats, **opts):
814 def copy(ui, repo, *pats, **opts):
813 """mark files as copied for the next commit
815 """mark files as copied for the next commit
814
816
815 Mark dest as having copies of source files. If dest is a
817 Mark dest as having copies of source files. If dest is a
816 directory, copies are put in that directory. If dest is a file,
818 directory, copies are put in that directory. If dest is a file,
817 the source must be a single file.
819 the source must be a single file.
818
820
819 By default, this command copies the contents of files as they
821 By default, this command copies the contents of files as they
820 exist in the working directory. If invoked with -A/--after, the
822 exist in the working directory. If invoked with -A/--after, the
821 operation is recorded, but no copying is performed.
823 operation is recorded, but no copying is performed.
822
824
823 This command takes effect with the next commit. To undo a copy
825 This command takes effect with the next commit. To undo a copy
824 before that, see :hg:`revert`.
826 before that, see :hg:`revert`.
825
827
826 Returns 0 on success, 1 if errors are encountered.
828 Returns 0 on success, 1 if errors are encountered.
827 """
829 """
828 wlock = repo.wlock(False)
830 wlock = repo.wlock(False)
829 try:
831 try:
830 return cmdutil.copy(ui, repo, pats, opts)
832 return cmdutil.copy(ui, repo, pats, opts)
831 finally:
833 finally:
832 wlock.release()
834 wlock.release()
833
835
834 def debugancestor(ui, repo, *args):
836 def debugancestor(ui, repo, *args):
835 """find the ancestor revision of two revisions in a given index"""
837 """find the ancestor revision of two revisions in a given index"""
836 if len(args) == 3:
838 if len(args) == 3:
837 index, rev1, rev2 = args
839 index, rev1, rev2 = args
838 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
840 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
839 lookup = r.lookup
841 lookup = r.lookup
840 elif len(args) == 2:
842 elif len(args) == 2:
841 if not repo:
843 if not repo:
842 raise util.Abort(_("There is no Mercurial repository here "
844 raise util.Abort(_("There is no Mercurial repository here "
843 "(.hg not found)"))
845 "(.hg not found)"))
844 rev1, rev2 = args
846 rev1, rev2 = args
845 r = repo.changelog
847 r = repo.changelog
846 lookup = repo.lookup
848 lookup = repo.lookup
847 else:
849 else:
848 raise util.Abort(_('either two or three arguments required'))
850 raise util.Abort(_('either two or three arguments required'))
849 a = r.ancestor(lookup(rev1), lookup(rev2))
851 a = r.ancestor(lookup(rev1), lookup(rev2))
850 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
852 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
851
853
852 def debugbuilddag(ui, repo, text,
854 def debugbuilddag(ui, repo, text,
853 mergeable_file=False,
855 mergeable_file=False,
854 appended_file=False,
856 appended_file=False,
855 overwritten_file=False,
857 overwritten_file=False,
856 new_file=False):
858 new_file=False):
857 """builds a repo with a given dag from scratch in the current empty repo
859 """builds a repo with a given dag from scratch in the current empty repo
858
860
859 Elements:
861 Elements:
860
862
861 - "+n" is a linear run of n nodes based on the current default parent
863 - "+n" is a linear run of n nodes based on the current default parent
862 - "." is a single node based on the current default parent
864 - "." is a single node based on the current default parent
863 - "$" resets the default parent to null (implied at the start);
865 - "$" resets the default parent to null (implied at the start);
864 otherwise the default parent is always the last node created
866 otherwise the default parent is always the last node created
865 - "<p" sets the default parent to the backref p
867 - "<p" sets the default parent to the backref p
866 - "*p" is a fork at parent p, which is a backref
868 - "*p" is a fork at parent p, which is a backref
867 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
869 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
868 - "/p2" is a merge of the preceding node and p2
870 - "/p2" is a merge of the preceding node and p2
869 - ":tag" defines a local tag for the preceding node
871 - ":tag" defines a local tag for the preceding node
870 - "@branch" sets the named branch for subsequent nodes
872 - "@branch" sets the named branch for subsequent nodes
871 - "!command" runs the command using your shell
873 - "!command" runs the command using your shell
872 - "!!my command\\n" is like "!", but to the end of the line
874 - "!!my command\\n" is like "!", but to the end of the line
873 - "#...\\n" is a comment up to the end of the line
875 - "#...\\n" is a comment up to the end of the line
874
876
875 Whitespace between the above elements is ignored.
877 Whitespace between the above elements is ignored.
876
878
877 A backref is either
879 A backref is either
878
880
879 - a number n, which references the node curr-n, where curr is the current
881 - a number n, which references the node curr-n, where curr is the current
880 node, or
882 node, or
881 - the name of a local tag you placed earlier using ":tag", or
883 - the name of a local tag you placed earlier using ":tag", or
882 - empty to denote the default parent.
884 - empty to denote the default parent.
883
885
884 All string valued-elements are either strictly alphanumeric, or must
886 All string valued-elements are either strictly alphanumeric, or must
885 be enclosed in double quotes ("..."), with "\" as escape character.
887 be enclosed in double quotes ("..."), with "\" as escape character.
886
888
887 Note that the --overwritten-file and --appended-file options imply the
889 Note that the --overwritten-file and --appended-file options imply the
888 use of "HGMERGE=internal:local" during DAG buildup.
890 use of "HGMERGE=internal:local" during DAG buildup.
889 """
891 """
890
892
891 if not (mergeable_file or appended_file or overwritten_file or new_file):
893 if not (mergeable_file or appended_file or overwritten_file or new_file):
892 raise util.Abort(_('need at least one of -m, -a, -o, -n'))
894 raise util.Abort(_('need at least one of -m, -a, -o, -n'))
893
895
894 if len(repo.changelog) > 0:
896 if len(repo.changelog) > 0:
895 raise util.Abort(_('repository is not empty'))
897 raise util.Abort(_('repository is not empty'))
896
898
897 if overwritten_file or appended_file:
899 if overwritten_file or appended_file:
898 # we don't want to fail in merges during buildup
900 # we don't want to fail in merges during buildup
899 os.environ['HGMERGE'] = 'internal:local'
901 os.environ['HGMERGE'] = 'internal:local'
900
902
901 def writefile(fname, text, fmode="w"):
903 def writefile(fname, text, fmode="w"):
902 f = open(fname, fmode)
904 f = open(fname, fmode)
903 try:
905 try:
904 f.write(text)
906 f.write(text)
905 finally:
907 finally:
906 f.close()
908 f.close()
907
909
908 if mergeable_file:
910 if mergeable_file:
909 linesperrev = 2
911 linesperrev = 2
910 # determine number of revs in DAG
912 # determine number of revs in DAG
911 n = 0
913 n = 0
912 for type, data in dagparser.parsedag(text):
914 for type, data in dagparser.parsedag(text):
913 if type == 'n':
915 if type == 'n':
914 n += 1
916 n += 1
915 # make a file with k lines per rev
917 # make a file with k lines per rev
916 writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev))
918 writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev))
917 + "\n")
919 + "\n")
918
920
919 at = -1
921 at = -1
920 atbranch = 'default'
922 atbranch = 'default'
921 for type, data in dagparser.parsedag(text):
923 for type, data in dagparser.parsedag(text):
922 if type == 'n':
924 if type == 'n':
923 ui.status('node %s\n' % str(data))
925 ui.status('node %s\n' % str(data))
924 id, ps = data
926 id, ps = data
925 p1 = ps[0]
927 p1 = ps[0]
926 if p1 != at:
928 if p1 != at:
927 update(ui, repo, node=p1, clean=True)
929 update(ui, repo, node=p1, clean=True)
928 at = p1
930 at = p1
929 if repo.dirstate.branch() != atbranch:
931 if repo.dirstate.branch() != atbranch:
930 branch(ui, repo, atbranch, force=True)
932 branch(ui, repo, atbranch, force=True)
931 if len(ps) > 1:
933 if len(ps) > 1:
932 p2 = ps[1]
934 p2 = ps[1]
933 merge(ui, repo, node=p2)
935 merge(ui, repo, node=p2)
934
936
935 if mergeable_file:
937 if mergeable_file:
936 f = open("mf", "r+")
938 f = open("mf", "r+")
937 try:
939 try:
938 lines = f.read().split("\n")
940 lines = f.read().split("\n")
939 lines[id * linesperrev] += " r%i" % id
941 lines[id * linesperrev] += " r%i" % id
940 f.seek(0)
942 f.seek(0)
941 f.write("\n".join(lines))
943 f.write("\n".join(lines))
942 finally:
944 finally:
943 f.close()
945 f.close()
944
946
945 if appended_file:
947 if appended_file:
946 writefile("af", "r%i\n" % id, "a")
948 writefile("af", "r%i\n" % id, "a")
947
949
948 if overwritten_file:
950 if overwritten_file:
949 writefile("of", "r%i\n" % id)
951 writefile("of", "r%i\n" % id)
950
952
951 if new_file:
953 if new_file:
952 writefile("nf%i" % id, "r%i\n" % id)
954 writefile("nf%i" % id, "r%i\n" % id)
953
955
954 commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0))
956 commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0))
955 at = id
957 at = id
956 elif type == 'l':
958 elif type == 'l':
957 id, name = data
959 id, name = data
958 ui.status('tag %s\n' % name)
960 ui.status('tag %s\n' % name)
959 tag(ui, repo, name, local=True)
961 tag(ui, repo, name, local=True)
960 elif type == 'a':
962 elif type == 'a':
961 ui.status('branch %s\n' % data)
963 ui.status('branch %s\n' % data)
962 atbranch = data
964 atbranch = data
963 elif type in 'cC':
965 elif type in 'cC':
964 r = util.system(data, cwd=repo.root)
966 r = util.system(data, cwd=repo.root)
965 if r:
967 if r:
966 desc, r = util.explain_exit(r)
968 desc, r = util.explain_exit(r)
967 raise util.Abort(_('%s command %s') % (data, desc))
969 raise util.Abort(_('%s command %s') % (data, desc))
968
970
969 def debugcommands(ui, cmd='', *args):
971 def debugcommands(ui, cmd='', *args):
970 """list all available commands and options"""
972 """list all available commands and options"""
971 for cmd, vals in sorted(table.iteritems()):
973 for cmd, vals in sorted(table.iteritems()):
972 cmd = cmd.split('|')[0].strip('^')
974 cmd = cmd.split('|')[0].strip('^')
973 opts = ', '.join([i[1] for i in vals[1]])
975 opts = ', '.join([i[1] for i in vals[1]])
974 ui.write('%s: %s\n' % (cmd, opts))
976 ui.write('%s: %s\n' % (cmd, opts))
975
977
976 def debugcomplete(ui, cmd='', **opts):
978 def debugcomplete(ui, cmd='', **opts):
977 """returns the completion list associated with the given command"""
979 """returns the completion list associated with the given command"""
978
980
979 if opts.get('options'):
981 if opts.get('options'):
980 options = []
982 options = []
981 otables = [globalopts]
983 otables = [globalopts]
982 if cmd:
984 if cmd:
983 aliases, entry = cmdutil.findcmd(cmd, table, False)
985 aliases, entry = cmdutil.findcmd(cmd, table, False)
984 otables.append(entry[1])
986 otables.append(entry[1])
985 for t in otables:
987 for t in otables:
986 for o in t:
988 for o in t:
987 if "(DEPRECATED)" in o[3]:
989 if "(DEPRECATED)" in o[3]:
988 continue
990 continue
989 if o[0]:
991 if o[0]:
990 options.append('-%s' % o[0])
992 options.append('-%s' % o[0])
991 options.append('--%s' % o[1])
993 options.append('--%s' % o[1])
992 ui.write("%s\n" % "\n".join(options))
994 ui.write("%s\n" % "\n".join(options))
993 return
995 return
994
996
995 cmdlist = cmdutil.findpossible(cmd, table)
997 cmdlist = cmdutil.findpossible(cmd, table)
996 if ui.verbose:
998 if ui.verbose:
997 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
999 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
998 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1000 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
999
1001
1000 def debugfsinfo(ui, path = "."):
1002 def debugfsinfo(ui, path = "."):
1001 """show information detected about current filesystem"""
1003 """show information detected about current filesystem"""
1002 open('.debugfsinfo', 'w').write('')
1004 open('.debugfsinfo', 'w').write('')
1003 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
1005 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
1004 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
1006 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
1005 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
1007 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
1006 and 'yes' or 'no'))
1008 and 'yes' or 'no'))
1007 os.unlink('.debugfsinfo')
1009 os.unlink('.debugfsinfo')
1008
1010
1009 def debugrebuildstate(ui, repo, rev="tip"):
1011 def debugrebuildstate(ui, repo, rev="tip"):
1010 """rebuild the dirstate as it would look like for the given revision"""
1012 """rebuild the dirstate as it would look like for the given revision"""
1011 ctx = repo[rev]
1013 ctx = repo[rev]
1012 wlock = repo.wlock()
1014 wlock = repo.wlock()
1013 try:
1015 try:
1014 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
1016 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
1015 finally:
1017 finally:
1016 wlock.release()
1018 wlock.release()
1017
1019
1018 def debugcheckstate(ui, repo):
1020 def debugcheckstate(ui, repo):
1019 """validate the correctness of the current dirstate"""
1021 """validate the correctness of the current dirstate"""
1020 parent1, parent2 = repo.dirstate.parents()
1022 parent1, parent2 = repo.dirstate.parents()
1021 m1 = repo[parent1].manifest()
1023 m1 = repo[parent1].manifest()
1022 m2 = repo[parent2].manifest()
1024 m2 = repo[parent2].manifest()
1023 errors = 0
1025 errors = 0
1024 for f in repo.dirstate:
1026 for f in repo.dirstate:
1025 state = repo.dirstate[f]
1027 state = repo.dirstate[f]
1026 if state in "nr" and f not in m1:
1028 if state in "nr" and f not in m1:
1027 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1029 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1028 errors += 1
1030 errors += 1
1029 if state in "a" and f in m1:
1031 if state in "a" and f in m1:
1030 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1032 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1031 errors += 1
1033 errors += 1
1032 if state in "m" and f not in m1 and f not in m2:
1034 if state in "m" and f not in m1 and f not in m2:
1033 ui.warn(_("%s in state %s, but not in either manifest\n") %
1035 ui.warn(_("%s in state %s, but not in either manifest\n") %
1034 (f, state))
1036 (f, state))
1035 errors += 1
1037 errors += 1
1036 for f in m1:
1038 for f in m1:
1037 state = repo.dirstate[f]
1039 state = repo.dirstate[f]
1038 if state not in "nrm":
1040 if state not in "nrm":
1039 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1041 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1040 errors += 1
1042 errors += 1
1041 if errors:
1043 if errors:
1042 error = _(".hg/dirstate inconsistent with current parent's manifest")
1044 error = _(".hg/dirstate inconsistent with current parent's manifest")
1043 raise util.Abort(error)
1045 raise util.Abort(error)
1044
1046
1045 def showconfig(ui, repo, *values, **opts):
1047 def showconfig(ui, repo, *values, **opts):
1046 """show combined config settings from all hgrc files
1048 """show combined config settings from all hgrc files
1047
1049
1048 With no arguments, print names and values of all config items.
1050 With no arguments, print names and values of all config items.
1049
1051
1050 With one argument of the form section.name, print just the value
1052 With one argument of the form section.name, print just the value
1051 of that config item.
1053 of that config item.
1052
1054
1053 With multiple arguments, print names and values of all config
1055 With multiple arguments, print names and values of all config
1054 items with matching section names.
1056 items with matching section names.
1055
1057
1056 With --debug, the source (filename and line number) is printed
1058 With --debug, the source (filename and line number) is printed
1057 for each config item.
1059 for each config item.
1058
1060
1059 Returns 0 on success.
1061 Returns 0 on success.
1060 """
1062 """
1061
1063
1062 for f in util.rcpath():
1064 for f in util.rcpath():
1063 ui.debug(_('read config from: %s\n') % f)
1065 ui.debug(_('read config from: %s\n') % f)
1064 untrusted = bool(opts.get('untrusted'))
1066 untrusted = bool(opts.get('untrusted'))
1065 if values:
1067 if values:
1066 if len([v for v in values if '.' in v]) > 1:
1068 if len([v for v in values if '.' in v]) > 1:
1067 raise util.Abort(_('only one config item permitted'))
1069 raise util.Abort(_('only one config item permitted'))
1068 for section, name, value in ui.walkconfig(untrusted=untrusted):
1070 for section, name, value in ui.walkconfig(untrusted=untrusted):
1069 sectname = section + '.' + name
1071 sectname = section + '.' + name
1070 if values:
1072 if values:
1071 for v in values:
1073 for v in values:
1072 if v == section:
1074 if v == section:
1073 ui.debug('%s: ' %
1075 ui.debug('%s: ' %
1074 ui.configsource(section, name, untrusted))
1076 ui.configsource(section, name, untrusted))
1075 ui.write('%s=%s\n' % (sectname, value))
1077 ui.write('%s=%s\n' % (sectname, value))
1076 elif v == sectname:
1078 elif v == sectname:
1077 ui.debug('%s: ' %
1079 ui.debug('%s: ' %
1078 ui.configsource(section, name, untrusted))
1080 ui.configsource(section, name, untrusted))
1079 ui.write(value, '\n')
1081 ui.write(value, '\n')
1080 else:
1082 else:
1081 ui.debug('%s: ' %
1083 ui.debug('%s: ' %
1082 ui.configsource(section, name, untrusted))
1084 ui.configsource(section, name, untrusted))
1083 ui.write('%s=%s\n' % (sectname, value))
1085 ui.write('%s=%s\n' % (sectname, value))
1084
1086
1085 def debugpushkey(ui, repopath, namespace, *keyinfo):
1087 def debugpushkey(ui, repopath, namespace, *keyinfo):
1086 '''access the pushkey key/value protocol
1088 '''access the pushkey key/value protocol
1087
1089
1088 With two args, list the keys in the given namespace.
1090 With two args, list the keys in the given namespace.
1089
1091
1090 With five args, set a key to new if it currently is set to old.
1092 With five args, set a key to new if it currently is set to old.
1091 Reports success or failure.
1093 Reports success or failure.
1092 '''
1094 '''
1093
1095
1094 target = hg.repository(ui, repopath)
1096 target = hg.repository(ui, repopath)
1095 if keyinfo:
1097 if keyinfo:
1096 key, old, new = keyinfo
1098 key, old, new = keyinfo
1097 r = target.pushkey(namespace, key, old, new)
1099 r = target.pushkey(namespace, key, old, new)
1098 ui.status(str(r) + '\n')
1100 ui.status(str(r) + '\n')
1099 return not(r)
1101 return not(r)
1100 else:
1102 else:
1101 for k, v in target.listkeys(namespace).iteritems():
1103 for k, v in target.listkeys(namespace).iteritems():
1102 ui.write("%s\t%s\n" % (k.encode('string-escape'),
1104 ui.write("%s\t%s\n" % (k.encode('string-escape'),
1103 v.encode('string-escape')))
1105 v.encode('string-escape')))
1104
1106
1105 def debugrevspec(ui, repo, expr):
1107 def debugrevspec(ui, repo, expr):
1106 '''parse and apply a revision specification'''
1108 '''parse and apply a revision specification'''
1107 if ui.verbose:
1109 if ui.verbose:
1108 tree = revset.parse(expr)
1110 tree = revset.parse(expr)
1109 ui.note(tree, "\n")
1111 ui.note(tree, "\n")
1110 func = revset.match(expr)
1112 func = revset.match(expr)
1111 for c in func(repo, range(len(repo))):
1113 for c in func(repo, range(len(repo))):
1112 ui.write("%s\n" % c)
1114 ui.write("%s\n" % c)
1113
1115
1114 def debugsetparents(ui, repo, rev1, rev2=None):
1116 def debugsetparents(ui, repo, rev1, rev2=None):
1115 """manually set the parents of the current working directory
1117 """manually set the parents of the current working directory
1116
1118
1117 This is useful for writing repository conversion tools, but should
1119 This is useful for writing repository conversion tools, but should
1118 be used with care.
1120 be used with care.
1119
1121
1120 Returns 0 on success.
1122 Returns 0 on success.
1121 """
1123 """
1122
1124
1123 if not rev2:
1125 if not rev2:
1124 rev2 = hex(nullid)
1126 rev2 = hex(nullid)
1125
1127
1126 wlock = repo.wlock()
1128 wlock = repo.wlock()
1127 try:
1129 try:
1128 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
1130 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
1129 finally:
1131 finally:
1130 wlock.release()
1132 wlock.release()
1131
1133
1132 def debugstate(ui, repo, nodates=None):
1134 def debugstate(ui, repo, nodates=None):
1133 """show the contents of the current dirstate"""
1135 """show the contents of the current dirstate"""
1134 timestr = ""
1136 timestr = ""
1135 showdate = not nodates
1137 showdate = not nodates
1136 for file_, ent in sorted(repo.dirstate._map.iteritems()):
1138 for file_, ent in sorted(repo.dirstate._map.iteritems()):
1137 if showdate:
1139 if showdate:
1138 if ent[3] == -1:
1140 if ent[3] == -1:
1139 # Pad or slice to locale representation
1141 # Pad or slice to locale representation
1140 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
1142 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
1141 time.localtime(0)))
1143 time.localtime(0)))
1142 timestr = 'unset'
1144 timestr = 'unset'
1143 timestr = (timestr[:locale_len] +
1145 timestr = (timestr[:locale_len] +
1144 ' ' * (locale_len - len(timestr)))
1146 ' ' * (locale_len - len(timestr)))
1145 else:
1147 else:
1146 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
1148 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
1147 time.localtime(ent[3]))
1149 time.localtime(ent[3]))
1148 if ent[1] & 020000:
1150 if ent[1] & 020000:
1149 mode = 'lnk'
1151 mode = 'lnk'
1150 else:
1152 else:
1151 mode = '%3o' % (ent[1] & 0777)
1153 mode = '%3o' % (ent[1] & 0777)
1152 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
1154 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
1153 for f in repo.dirstate.copies():
1155 for f in repo.dirstate.copies():
1154 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
1156 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
1155
1157
1156 def debugsub(ui, repo, rev=None):
1158 def debugsub(ui, repo, rev=None):
1157 if rev == '':
1159 if rev == '':
1158 rev = None
1160 rev = None
1159 for k, v in sorted(repo[rev].substate.items()):
1161 for k, v in sorted(repo[rev].substate.items()):
1160 ui.write('path %s\n' % k)
1162 ui.write('path %s\n' % k)
1161 ui.write(' source %s\n' % v[0])
1163 ui.write(' source %s\n' % v[0])
1162 ui.write(' revision %s\n' % v[1])
1164 ui.write(' revision %s\n' % v[1])
1163
1165
1164 def debugdag(ui, repo, file_=None, *revs, **opts):
1166 def debugdag(ui, repo, file_=None, *revs, **opts):
1165 """format the changelog or an index DAG as a concise textual description
1167 """format the changelog or an index DAG as a concise textual description
1166
1168
1167 If you pass a revlog index, the revlog's DAG is emitted. If you list
1169 If you pass a revlog index, the revlog's DAG is emitted. If you list
1168 revision numbers, they get labelled in the output as rN.
1170 revision numbers, they get labelled in the output as rN.
1169
1171
1170 Otherwise, the changelog DAG of the current repo is emitted.
1172 Otherwise, the changelog DAG of the current repo is emitted.
1171 """
1173 """
1172 spaces = opts.get('spaces')
1174 spaces = opts.get('spaces')
1173 dots = opts.get('dots')
1175 dots = opts.get('dots')
1174 if file_:
1176 if file_:
1175 rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
1177 rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
1176 revs = set((int(r) for r in revs))
1178 revs = set((int(r) for r in revs))
1177 def events():
1179 def events():
1178 for r in rlog:
1180 for r in rlog:
1179 yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
1181 yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
1180 if r in revs:
1182 if r in revs:
1181 yield 'l', (r, "r%i" % r)
1183 yield 'l', (r, "r%i" % r)
1182 elif repo:
1184 elif repo:
1183 cl = repo.changelog
1185 cl = repo.changelog
1184 tags = opts.get('tags')
1186 tags = opts.get('tags')
1185 branches = opts.get('branches')
1187 branches = opts.get('branches')
1186 if tags:
1188 if tags:
1187 labels = {}
1189 labels = {}
1188 for l, n in repo.tags().items():
1190 for l, n in repo.tags().items():
1189 labels.setdefault(cl.rev(n), []).append(l)
1191 labels.setdefault(cl.rev(n), []).append(l)
1190 def events():
1192 def events():
1191 b = "default"
1193 b = "default"
1192 for r in cl:
1194 for r in cl:
1193 if branches:
1195 if branches:
1194 newb = cl.read(cl.node(r))[5]['branch']
1196 newb = cl.read(cl.node(r))[5]['branch']
1195 if newb != b:
1197 if newb != b:
1196 yield 'a', newb
1198 yield 'a', newb
1197 b = newb
1199 b = newb
1198 yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
1200 yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
1199 if tags:
1201 if tags:
1200 ls = labels.get(r)
1202 ls = labels.get(r)
1201 if ls:
1203 if ls:
1202 for l in ls:
1204 for l in ls:
1203 yield 'l', (r, l)
1205 yield 'l', (r, l)
1204 else:
1206 else:
1205 raise util.Abort(_('need repo for changelog dag'))
1207 raise util.Abort(_('need repo for changelog dag'))
1206
1208
1207 for line in dagparser.dagtextlines(events(),
1209 for line in dagparser.dagtextlines(events(),
1208 addspaces=spaces,
1210 addspaces=spaces,
1209 wraplabels=True,
1211 wraplabels=True,
1210 wrapannotations=True,
1212 wrapannotations=True,
1211 wrapnonlinear=dots,
1213 wrapnonlinear=dots,
1212 usedots=dots,
1214 usedots=dots,
1213 maxlinewidth=70):
1215 maxlinewidth=70):
1214 ui.write(line)
1216 ui.write(line)
1215 ui.write("\n")
1217 ui.write("\n")
1216
1218
1217 def debugdata(ui, file_, rev):
1219 def debugdata(ui, file_, rev):
1218 """dump the contents of a data file revision"""
1220 """dump the contents of a data file revision"""
1219 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
1221 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
1220 try:
1222 try:
1221 ui.write(r.revision(r.lookup(rev)))
1223 ui.write(r.revision(r.lookup(rev)))
1222 except KeyError:
1224 except KeyError:
1223 raise util.Abort(_('invalid revision identifier %s') % rev)
1225 raise util.Abort(_('invalid revision identifier %s') % rev)
1224
1226
1225 def debugdate(ui, date, range=None, **opts):
1227 def debugdate(ui, date, range=None, **opts):
1226 """parse and display a date"""
1228 """parse and display a date"""
1227 if opts["extended"]:
1229 if opts["extended"]:
1228 d = util.parsedate(date, util.extendeddateformats)
1230 d = util.parsedate(date, util.extendeddateformats)
1229 else:
1231 else:
1230 d = util.parsedate(date)
1232 d = util.parsedate(date)
1231 ui.write("internal: %s %s\n" % d)
1233 ui.write("internal: %s %s\n" % d)
1232 ui.write("standard: %s\n" % util.datestr(d))
1234 ui.write("standard: %s\n" % util.datestr(d))
1233 if range:
1235 if range:
1234 m = util.matchdate(range)
1236 m = util.matchdate(range)
1235 ui.write("match: %s\n" % m(d[0]))
1237 ui.write("match: %s\n" % m(d[0]))
1236
1238
1237 def debugindex(ui, file_):
1239 def debugindex(ui, file_):
1238 """dump the contents of an index file"""
1240 """dump the contents of an index file"""
1239 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
1241 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
1240 ui.write(" rev offset length base linkrev"
1242 ui.write(" rev offset length base linkrev"
1241 " nodeid p1 p2\n")
1243 " nodeid p1 p2\n")
1242 for i in r:
1244 for i in r:
1243 node = r.node(i)
1245 node = r.node(i)
1244 try:
1246 try:
1245 pp = r.parents(node)
1247 pp = r.parents(node)
1246 except:
1248 except:
1247 pp = [nullid, nullid]
1249 pp = [nullid, nullid]
1248 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
1250 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
1249 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
1251 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
1250 short(node), short(pp[0]), short(pp[1])))
1252 short(node), short(pp[0]), short(pp[1])))
1251
1253
1252 def debugindexdot(ui, file_):
1254 def debugindexdot(ui, file_):
1253 """dump an index DAG as a graphviz dot file"""
1255 """dump an index DAG as a graphviz dot file"""
1254 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
1256 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
1255 ui.write("digraph G {\n")
1257 ui.write("digraph G {\n")
1256 for i in r:
1258 for i in r:
1257 node = r.node(i)
1259 node = r.node(i)
1258 pp = r.parents(node)
1260 pp = r.parents(node)
1259 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1261 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1260 if pp[1] != nullid:
1262 if pp[1] != nullid:
1261 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1263 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1262 ui.write("}\n")
1264 ui.write("}\n")
1263
1265
1264 def debuginstall(ui):
1266 def debuginstall(ui):
1265 '''test Mercurial installation
1267 '''test Mercurial installation
1266
1268
1267 Returns 0 on success.
1269 Returns 0 on success.
1268 '''
1270 '''
1269
1271
1270 def writetemp(contents):
1272 def writetemp(contents):
1271 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
1273 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
1272 f = os.fdopen(fd, "wb")
1274 f = os.fdopen(fd, "wb")
1273 f.write(contents)
1275 f.write(contents)
1274 f.close()
1276 f.close()
1275 return name
1277 return name
1276
1278
1277 problems = 0
1279 problems = 0
1278
1280
1279 # encoding
1281 # encoding
1280 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
1282 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
1281 try:
1283 try:
1282 encoding.fromlocal("test")
1284 encoding.fromlocal("test")
1283 except util.Abort, inst:
1285 except util.Abort, inst:
1284 ui.write(" %s\n" % inst)
1286 ui.write(" %s\n" % inst)
1285 ui.write(_(" (check that your locale is properly set)\n"))
1287 ui.write(_(" (check that your locale is properly set)\n"))
1286 problems += 1
1288 problems += 1
1287
1289
1288 # compiled modules
1290 # compiled modules
1289 ui.status(_("Checking extensions...\n"))
1291 ui.status(_("Checking extensions...\n"))
1290 try:
1292 try:
1291 import bdiff, mpatch, base85
1293 import bdiff, mpatch, base85
1292 except Exception, inst:
1294 except Exception, inst:
1293 ui.write(" %s\n" % inst)
1295 ui.write(" %s\n" % inst)
1294 ui.write(_(" One or more extensions could not be found"))
1296 ui.write(_(" One or more extensions could not be found"))
1295 ui.write(_(" (check that you compiled the extensions)\n"))
1297 ui.write(_(" (check that you compiled the extensions)\n"))
1296 problems += 1
1298 problems += 1
1297
1299
1298 # templates
1300 # templates
1299 ui.status(_("Checking templates...\n"))
1301 ui.status(_("Checking templates...\n"))
1300 try:
1302 try:
1301 import templater
1303 import templater
1302 templater.templater(templater.templatepath("map-cmdline.default"))
1304 templater.templater(templater.templatepath("map-cmdline.default"))
1303 except Exception, inst:
1305 except Exception, inst:
1304 ui.write(" %s\n" % inst)
1306 ui.write(" %s\n" % inst)
1305 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
1307 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
1306 problems += 1
1308 problems += 1
1307
1309
1308 # patch
1310 # patch
1309 ui.status(_("Checking patch...\n"))
1311 ui.status(_("Checking patch...\n"))
1310 patchproblems = 0
1312 patchproblems = 0
1311 a = "1\n2\n3\n4\n"
1313 a = "1\n2\n3\n4\n"
1312 b = "1\n2\n3\ninsert\n4\n"
1314 b = "1\n2\n3\ninsert\n4\n"
1313 fa = writetemp(a)
1315 fa = writetemp(a)
1314 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
1316 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
1315 os.path.basename(fa))
1317 os.path.basename(fa))
1316 fd = writetemp(d)
1318 fd = writetemp(d)
1317
1319
1318 files = {}
1320 files = {}
1319 try:
1321 try:
1320 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
1322 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
1321 except util.Abort, e:
1323 except util.Abort, e:
1322 ui.write(_(" patch call failed:\n"))
1324 ui.write(_(" patch call failed:\n"))
1323 ui.write(" " + str(e) + "\n")
1325 ui.write(" " + str(e) + "\n")
1324 patchproblems += 1
1326 patchproblems += 1
1325 else:
1327 else:
1326 if list(files) != [os.path.basename(fa)]:
1328 if list(files) != [os.path.basename(fa)]:
1327 ui.write(_(" unexpected patch output!\n"))
1329 ui.write(_(" unexpected patch output!\n"))
1328 patchproblems += 1
1330 patchproblems += 1
1329 a = open(fa).read()
1331 a = open(fa).read()
1330 if a != b:
1332 if a != b:
1331 ui.write(_(" patch test failed!\n"))
1333 ui.write(_(" patch test failed!\n"))
1332 patchproblems += 1
1334 patchproblems += 1
1333
1335
1334 if patchproblems:
1336 if patchproblems:
1335 if ui.config('ui', 'patch'):
1337 if ui.config('ui', 'patch'):
1336 ui.write(_(" (Current patch tool may be incompatible with patch,"
1338 ui.write(_(" (Current patch tool may be incompatible with patch,"
1337 " or misconfigured. Please check your .hgrc file)\n"))
1339 " or misconfigured. Please check your .hgrc file)\n"))
1338 else:
1340 else:
1339 ui.write(_(" Internal patcher failure, please report this error"
1341 ui.write(_(" Internal patcher failure, please report this error"
1340 " to http://mercurial.selenic.com/bts/\n"))
1342 " to http://mercurial.selenic.com/bts/\n"))
1341 problems += patchproblems
1343 problems += patchproblems
1342
1344
1343 os.unlink(fa)
1345 os.unlink(fa)
1344 os.unlink(fd)
1346 os.unlink(fd)
1345
1347
1346 # editor
1348 # editor
1347 ui.status(_("Checking commit editor...\n"))
1349 ui.status(_("Checking commit editor...\n"))
1348 editor = ui.geteditor()
1350 editor = ui.geteditor()
1349 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
1351 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
1350 if not cmdpath:
1352 if not cmdpath:
1351 if editor == 'vi':
1353 if editor == 'vi':
1352 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
1354 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
1353 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1355 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1354 else:
1356 else:
1355 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
1357 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
1356 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1358 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1357 problems += 1
1359 problems += 1
1358
1360
1359 # check username
1361 # check username
1360 ui.status(_("Checking username...\n"))
1362 ui.status(_("Checking username...\n"))
1361 try:
1363 try:
1362 user = ui.username()
1364 user = ui.username()
1363 except util.Abort, e:
1365 except util.Abort, e:
1364 ui.write(" %s\n" % e)
1366 ui.write(" %s\n" % e)
1365 ui.write(_(" (specify a username in your .hgrc file)\n"))
1367 ui.write(_(" (specify a username in your .hgrc file)\n"))
1366 problems += 1
1368 problems += 1
1367
1369
1368 if not problems:
1370 if not problems:
1369 ui.status(_("No problems detected\n"))
1371 ui.status(_("No problems detected\n"))
1370 else:
1372 else:
1371 ui.write(_("%s problems detected,"
1373 ui.write(_("%s problems detected,"
1372 " please check your install!\n") % problems)
1374 " please check your install!\n") % problems)
1373
1375
1374 return problems
1376 return problems
1375
1377
1376 def debugrename(ui, repo, file1, *pats, **opts):
1378 def debugrename(ui, repo, file1, *pats, **opts):
1377 """dump rename information"""
1379 """dump rename information"""
1378
1380
1379 ctx = repo[opts.get('rev')]
1381 ctx = repo[opts.get('rev')]
1380 m = cmdutil.match(repo, (file1,) + pats, opts)
1382 m = cmdutil.match(repo, (file1,) + pats, opts)
1381 for abs in ctx.walk(m):
1383 for abs in ctx.walk(m):
1382 fctx = ctx[abs]
1384 fctx = ctx[abs]
1383 o = fctx.filelog().renamed(fctx.filenode())
1385 o = fctx.filelog().renamed(fctx.filenode())
1384 rel = m.rel(abs)
1386 rel = m.rel(abs)
1385 if o:
1387 if o:
1386 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1388 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1387 else:
1389 else:
1388 ui.write(_("%s not renamed\n") % rel)
1390 ui.write(_("%s not renamed\n") % rel)
1389
1391
1390 def debugwalk(ui, repo, *pats, **opts):
1392 def debugwalk(ui, repo, *pats, **opts):
1391 """show how files match on given patterns"""
1393 """show how files match on given patterns"""
1392 m = cmdutil.match(repo, pats, opts)
1394 m = cmdutil.match(repo, pats, opts)
1393 items = list(repo.walk(m))
1395 items = list(repo.walk(m))
1394 if not items:
1396 if not items:
1395 return
1397 return
1396 fmt = 'f %%-%ds %%-%ds %%s' % (
1398 fmt = 'f %%-%ds %%-%ds %%s' % (
1397 max([len(abs) for abs in items]),
1399 max([len(abs) for abs in items]),
1398 max([len(m.rel(abs)) for abs in items]))
1400 max([len(m.rel(abs)) for abs in items]))
1399 for abs in items:
1401 for abs in items:
1400 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1402 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1401 ui.write("%s\n" % line.rstrip())
1403 ui.write("%s\n" % line.rstrip())
1402
1404
1403 def diff(ui, repo, *pats, **opts):
1405 def diff(ui, repo, *pats, **opts):
1404 """diff repository (or selected files)
1406 """diff repository (or selected files)
1405
1407
1406 Show differences between revisions for the specified files.
1408 Show differences between revisions for the specified files.
1407
1409
1408 Differences between files are shown using the unified diff format.
1410 Differences between files are shown using the unified diff format.
1409
1411
1410 NOTE: diff may generate unexpected results for merges, as it will
1412 NOTE: diff may generate unexpected results for merges, as it will
1411 default to comparing against the working directory's first parent
1413 default to comparing against the working directory's first parent
1412 changeset if no revisions are specified.
1414 changeset if no revisions are specified.
1413
1415
1414 When two revision arguments are given, then changes are shown
1416 When two revision arguments are given, then changes are shown
1415 between those revisions. If only one revision is specified then
1417 between those revisions. If only one revision is specified then
1416 that revision is compared to the working directory, and, when no
1418 that revision is compared to the working directory, and, when no
1417 revisions are specified, the working directory files are compared
1419 revisions are specified, the working directory files are compared
1418 to its parent.
1420 to its parent.
1419
1421
1420 Alternatively you can specify -c/--change with a revision to see
1422 Alternatively you can specify -c/--change with a revision to see
1421 the changes in that changeset relative to its first parent.
1423 the changes in that changeset relative to its first parent.
1422
1424
1423 Without the -a/--text option, diff will avoid generating diffs of
1425 Without the -a/--text option, diff will avoid generating diffs of
1424 files it detects as binary. With -a, diff will generate a diff
1426 files it detects as binary. With -a, diff will generate a diff
1425 anyway, probably with undesirable results.
1427 anyway, probably with undesirable results.
1426
1428
1427 Use the -g/--git option to generate diffs in the git extended diff
1429 Use the -g/--git option to generate diffs in the git extended diff
1428 format. For more information, read :hg:`help diffs`.
1430 format. For more information, read :hg:`help diffs`.
1429
1431
1430 Returns 0 on success.
1432 Returns 0 on success.
1431 """
1433 """
1432
1434
1433 revs = opts.get('rev')
1435 revs = opts.get('rev')
1434 change = opts.get('change')
1436 change = opts.get('change')
1435 stat = opts.get('stat')
1437 stat = opts.get('stat')
1436 reverse = opts.get('reverse')
1438 reverse = opts.get('reverse')
1437
1439
1438 if revs and change:
1440 if revs and change:
1439 msg = _('cannot specify --rev and --change at the same time')
1441 msg = _('cannot specify --rev and --change at the same time')
1440 raise util.Abort(msg)
1442 raise util.Abort(msg)
1441 elif change:
1443 elif change:
1442 node2 = repo.lookup(change)
1444 node2 = repo.lookup(change)
1443 node1 = repo[node2].parents()[0].node()
1445 node1 = repo[node2].parents()[0].node()
1444 else:
1446 else:
1445 node1, node2 = cmdutil.revpair(repo, revs)
1447 node1, node2 = cmdutil.revpair(repo, revs)
1446
1448
1447 if reverse:
1449 if reverse:
1448 node1, node2 = node2, node1
1450 node1, node2 = node2, node1
1449
1451
1450 diffopts = patch.diffopts(ui, opts)
1452 diffopts = patch.diffopts(ui, opts)
1451 m = cmdutil.match(repo, pats, opts)
1453 m = cmdutil.match(repo, pats, opts)
1452 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat)
1454 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat)
1453
1455
1454 def export(ui, repo, *changesets, **opts):
1456 def export(ui, repo, *changesets, **opts):
1455 """dump the header and diffs for one or more changesets
1457 """dump the header and diffs for one or more changesets
1456
1458
1457 Print the changeset header and diffs for one or more revisions.
1459 Print the changeset header and diffs for one or more revisions.
1458
1460
1459 The information shown in the changeset header is: author, date,
1461 The information shown in the changeset header is: author, date,
1460 branch name (if non-default), changeset hash, parent(s) and commit
1462 branch name (if non-default), changeset hash, parent(s) and commit
1461 comment.
1463 comment.
1462
1464
1463 NOTE: export may generate unexpected diff output for merge
1465 NOTE: export may generate unexpected diff output for merge
1464 changesets, as it will compare the merge changeset against its
1466 changesets, as it will compare the merge changeset against its
1465 first parent only.
1467 first parent only.
1466
1468
1467 Output may be to a file, in which case the name of the file is
1469 Output may be to a file, in which case the name of the file is
1468 given using a format string. The formatting rules are as follows:
1470 given using a format string. The formatting rules are as follows:
1469
1471
1470 :``%%``: literal "%" character
1472 :``%%``: literal "%" character
1471 :``%H``: changeset hash (40 bytes of hexadecimal)
1473 :``%H``: changeset hash (40 bytes of hexadecimal)
1472 :``%N``: number of patches being generated
1474 :``%N``: number of patches being generated
1473 :``%R``: changeset revision number
1475 :``%R``: changeset revision number
1474 :``%b``: basename of the exporting repository
1476 :``%b``: basename of the exporting repository
1475 :``%h``: short-form changeset hash (12 bytes of hexadecimal)
1477 :``%h``: short-form changeset hash (12 bytes of hexadecimal)
1476 :``%n``: zero-padded sequence number, starting at 1
1478 :``%n``: zero-padded sequence number, starting at 1
1477 :``%r``: zero-padded changeset revision number
1479 :``%r``: zero-padded changeset revision number
1478
1480
1479 Without the -a/--text option, export will avoid generating diffs
1481 Without the -a/--text option, export will avoid generating diffs
1480 of files it detects as binary. With -a, export will generate a
1482 of files it detects as binary. With -a, export will generate a
1481 diff anyway, probably with undesirable results.
1483 diff anyway, probably with undesirable results.
1482
1484
1483 Use the -g/--git option to generate diffs in the git extended diff
1485 Use the -g/--git option to generate diffs in the git extended diff
1484 format. See :hg:`help diffs` for more information.
1486 format. See :hg:`help diffs` for more information.
1485
1487
1486 With the --switch-parent option, the diff will be against the
1488 With the --switch-parent option, the diff will be against the
1487 second parent. It can be useful to review a merge.
1489 second parent. It can be useful to review a merge.
1488
1490
1489 Returns 0 on success.
1491 Returns 0 on success.
1490 """
1492 """
1491 changesets += tuple(opts.get('rev', []))
1493 changesets += tuple(opts.get('rev', []))
1492 if not changesets:
1494 if not changesets:
1493 raise util.Abort(_("export requires at least one changeset"))
1495 raise util.Abort(_("export requires at least one changeset"))
1494 revs = cmdutil.revrange(repo, changesets)
1496 revs = cmdutil.revrange(repo, changesets)
1495 if len(revs) > 1:
1497 if len(revs) > 1:
1496 ui.note(_('exporting patches:\n'))
1498 ui.note(_('exporting patches:\n'))
1497 else:
1499 else:
1498 ui.note(_('exporting patch:\n'))
1500 ui.note(_('exporting patch:\n'))
1499 cmdutil.export(repo, revs, template=opts.get('output'),
1501 cmdutil.export(repo, revs, template=opts.get('output'),
1500 switch_parent=opts.get('switch_parent'),
1502 switch_parent=opts.get('switch_parent'),
1501 opts=patch.diffopts(ui, opts))
1503 opts=patch.diffopts(ui, opts))
1502
1504
1503 def forget(ui, repo, *pats, **opts):
1505 def forget(ui, repo, *pats, **opts):
1504 """forget the specified files on the next commit
1506 """forget the specified files on the next commit
1505
1507
1506 Mark the specified files so they will no longer be tracked
1508 Mark the specified files so they will no longer be tracked
1507 after the next commit.
1509 after the next commit.
1508
1510
1509 This only removes files from the current branch, not from the
1511 This only removes files from the current branch, not from the
1510 entire project history, and it does not delete them from the
1512 entire project history, and it does not delete them from the
1511 working directory.
1513 working directory.
1512
1514
1513 To undo a forget before the next commit, see :hg:`add`.
1515 To undo a forget before the next commit, see :hg:`add`.
1514
1516
1515 Returns 0 on success.
1517 Returns 0 on success.
1516 """
1518 """
1517
1519
1518 if not pats:
1520 if not pats:
1519 raise util.Abort(_('no files specified'))
1521 raise util.Abort(_('no files specified'))
1520
1522
1521 m = cmdutil.match(repo, pats, opts)
1523 m = cmdutil.match(repo, pats, opts)
1522 s = repo.status(match=m, clean=True)
1524 s = repo.status(match=m, clean=True)
1523 forget = sorted(s[0] + s[1] + s[3] + s[6])
1525 forget = sorted(s[0] + s[1] + s[3] + s[6])
1524 errs = 0
1526 errs = 0
1525
1527
1526 for f in m.files():
1528 for f in m.files():
1527 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
1529 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
1528 ui.warn(_('not removing %s: file is already untracked\n')
1530 ui.warn(_('not removing %s: file is already untracked\n')
1529 % m.rel(f))
1531 % m.rel(f))
1530 errs = 1
1532 errs = 1
1531
1533
1532 for f in forget:
1534 for f in forget:
1533 if ui.verbose or not m.exact(f):
1535 if ui.verbose or not m.exact(f):
1534 ui.status(_('removing %s\n') % m.rel(f))
1536 ui.status(_('removing %s\n') % m.rel(f))
1535
1537
1536 repo[None].remove(forget, unlink=False)
1538 repo[None].remove(forget, unlink=False)
1537 return errs
1539 return errs
1538
1540
1539 def grep(ui, repo, pattern, *pats, **opts):
1541 def grep(ui, repo, pattern, *pats, **opts):
1540 """search for a pattern in specified files and revisions
1542 """search for a pattern in specified files and revisions
1541
1543
1542 Search revisions of files for a regular expression.
1544 Search revisions of files for a regular expression.
1543
1545
1544 This command behaves differently than Unix grep. It only accepts
1546 This command behaves differently than Unix grep. It only accepts
1545 Python/Perl regexps. It searches repository history, not the
1547 Python/Perl regexps. It searches repository history, not the
1546 working directory. It always prints the revision number in which a
1548 working directory. It always prints the revision number in which a
1547 match appears.
1549 match appears.
1548
1550
1549 By default, grep only prints output for the first revision of a
1551 By default, grep only prints output for the first revision of a
1550 file in which it finds a match. To get it to print every revision
1552 file in which it finds a match. To get it to print every revision
1551 that contains a change in match status ("-" for a match that
1553 that contains a change in match status ("-" for a match that
1552 becomes a non-match, or "+" for a non-match that becomes a match),
1554 becomes a non-match, or "+" for a non-match that becomes a match),
1553 use the --all flag.
1555 use the --all flag.
1554
1556
1555 Returns 0 if a match is found, 1 otherwise.
1557 Returns 0 if a match is found, 1 otherwise.
1556 """
1558 """
1557 reflags = 0
1559 reflags = 0
1558 if opts.get('ignore_case'):
1560 if opts.get('ignore_case'):
1559 reflags |= re.I
1561 reflags |= re.I
1560 try:
1562 try:
1561 regexp = re.compile(pattern, reflags)
1563 regexp = re.compile(pattern, reflags)
1562 except Exception, inst:
1564 except Exception, inst:
1563 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1565 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1564 return 1
1566 return 1
1565 sep, eol = ':', '\n'
1567 sep, eol = ':', '\n'
1566 if opts.get('print0'):
1568 if opts.get('print0'):
1567 sep = eol = '\0'
1569 sep = eol = '\0'
1568
1570
1569 getfile = util.lrucachefunc(repo.file)
1571 getfile = util.lrucachefunc(repo.file)
1570
1572
1571 def matchlines(body):
1573 def matchlines(body):
1572 begin = 0
1574 begin = 0
1573 linenum = 0
1575 linenum = 0
1574 while True:
1576 while True:
1575 match = regexp.search(body, begin)
1577 match = regexp.search(body, begin)
1576 if not match:
1578 if not match:
1577 break
1579 break
1578 mstart, mend = match.span()
1580 mstart, mend = match.span()
1579 linenum += body.count('\n', begin, mstart) + 1
1581 linenum += body.count('\n', begin, mstart) + 1
1580 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1582 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1581 begin = body.find('\n', mend) + 1 or len(body)
1583 begin = body.find('\n', mend) + 1 or len(body)
1582 lend = begin - 1
1584 lend = begin - 1
1583 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1585 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1584
1586
1585 class linestate(object):
1587 class linestate(object):
1586 def __init__(self, line, linenum, colstart, colend):
1588 def __init__(self, line, linenum, colstart, colend):
1587 self.line = line
1589 self.line = line
1588 self.linenum = linenum
1590 self.linenum = linenum
1589 self.colstart = colstart
1591 self.colstart = colstart
1590 self.colend = colend
1592 self.colend = colend
1591
1593
1592 def __hash__(self):
1594 def __hash__(self):
1593 return hash((self.linenum, self.line))
1595 return hash((self.linenum, self.line))
1594
1596
1595 def __eq__(self, other):
1597 def __eq__(self, other):
1596 return self.line == other.line
1598 return self.line == other.line
1597
1599
1598 matches = {}
1600 matches = {}
1599 copies = {}
1601 copies = {}
1600 def grepbody(fn, rev, body):
1602 def grepbody(fn, rev, body):
1601 matches[rev].setdefault(fn, [])
1603 matches[rev].setdefault(fn, [])
1602 m = matches[rev][fn]
1604 m = matches[rev][fn]
1603 for lnum, cstart, cend, line in matchlines(body):
1605 for lnum, cstart, cend, line in matchlines(body):
1604 s = linestate(line, lnum, cstart, cend)
1606 s = linestate(line, lnum, cstart, cend)
1605 m.append(s)
1607 m.append(s)
1606
1608
1607 def difflinestates(a, b):
1609 def difflinestates(a, b):
1608 sm = difflib.SequenceMatcher(None, a, b)
1610 sm = difflib.SequenceMatcher(None, a, b)
1609 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1611 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1610 if tag == 'insert':
1612 if tag == 'insert':
1611 for i in xrange(blo, bhi):
1613 for i in xrange(blo, bhi):
1612 yield ('+', b[i])
1614 yield ('+', b[i])
1613 elif tag == 'delete':
1615 elif tag == 'delete':
1614 for i in xrange(alo, ahi):
1616 for i in xrange(alo, ahi):
1615 yield ('-', a[i])
1617 yield ('-', a[i])
1616 elif tag == 'replace':
1618 elif tag == 'replace':
1617 for i in xrange(alo, ahi):
1619 for i in xrange(alo, ahi):
1618 yield ('-', a[i])
1620 yield ('-', a[i])
1619 for i in xrange(blo, bhi):
1621 for i in xrange(blo, bhi):
1620 yield ('+', b[i])
1622 yield ('+', b[i])
1621
1623
1622 def display(fn, ctx, pstates, states):
1624 def display(fn, ctx, pstates, states):
1623 rev = ctx.rev()
1625 rev = ctx.rev()
1624 datefunc = ui.quiet and util.shortdate or util.datestr
1626 datefunc = ui.quiet and util.shortdate or util.datestr
1625 found = False
1627 found = False
1626 filerevmatches = {}
1628 filerevmatches = {}
1627 if opts.get('all'):
1629 if opts.get('all'):
1628 iter = difflinestates(pstates, states)
1630 iter = difflinestates(pstates, states)
1629 else:
1631 else:
1630 iter = [('', l) for l in states]
1632 iter = [('', l) for l in states]
1631 for change, l in iter:
1633 for change, l in iter:
1632 cols = [fn, str(rev)]
1634 cols = [fn, str(rev)]
1633 before, match, after = None, None, None
1635 before, match, after = None, None, None
1634 if opts.get('line_number'):
1636 if opts.get('line_number'):
1635 cols.append(str(l.linenum))
1637 cols.append(str(l.linenum))
1636 if opts.get('all'):
1638 if opts.get('all'):
1637 cols.append(change)
1639 cols.append(change)
1638 if opts.get('user'):
1640 if opts.get('user'):
1639 cols.append(ui.shortuser(ctx.user()))
1641 cols.append(ui.shortuser(ctx.user()))
1640 if opts.get('date'):
1642 if opts.get('date'):
1641 cols.append(datefunc(ctx.date()))
1643 cols.append(datefunc(ctx.date()))
1642 if opts.get('files_with_matches'):
1644 if opts.get('files_with_matches'):
1643 c = (fn, rev)
1645 c = (fn, rev)
1644 if c in filerevmatches:
1646 if c in filerevmatches:
1645 continue
1647 continue
1646 filerevmatches[c] = 1
1648 filerevmatches[c] = 1
1647 else:
1649 else:
1648 before = l.line[:l.colstart]
1650 before = l.line[:l.colstart]
1649 match = l.line[l.colstart:l.colend]
1651 match = l.line[l.colstart:l.colend]
1650 after = l.line[l.colend:]
1652 after = l.line[l.colend:]
1651 ui.write(sep.join(cols))
1653 ui.write(sep.join(cols))
1652 if before is not None:
1654 if before is not None:
1653 ui.write(sep + before)
1655 ui.write(sep + before)
1654 ui.write(match, label='grep.match')
1656 ui.write(match, label='grep.match')
1655 ui.write(after)
1657 ui.write(after)
1656 ui.write(eol)
1658 ui.write(eol)
1657 found = True
1659 found = True
1658 return found
1660 return found
1659
1661
1660 skip = {}
1662 skip = {}
1661 revfiles = {}
1663 revfiles = {}
1662 matchfn = cmdutil.match(repo, pats, opts)
1664 matchfn = cmdutil.match(repo, pats, opts)
1663 found = False
1665 found = False
1664 follow = opts.get('follow')
1666 follow = opts.get('follow')
1665
1667
1666 def prep(ctx, fns):
1668 def prep(ctx, fns):
1667 rev = ctx.rev()
1669 rev = ctx.rev()
1668 pctx = ctx.parents()[0]
1670 pctx = ctx.parents()[0]
1669 parent = pctx.rev()
1671 parent = pctx.rev()
1670 matches.setdefault(rev, {})
1672 matches.setdefault(rev, {})
1671 matches.setdefault(parent, {})
1673 matches.setdefault(parent, {})
1672 files = revfiles.setdefault(rev, [])
1674 files = revfiles.setdefault(rev, [])
1673 for fn in fns:
1675 for fn in fns:
1674 flog = getfile(fn)
1676 flog = getfile(fn)
1675 try:
1677 try:
1676 fnode = ctx.filenode(fn)
1678 fnode = ctx.filenode(fn)
1677 except error.LookupError:
1679 except error.LookupError:
1678 continue
1680 continue
1679
1681
1680 copied = flog.renamed(fnode)
1682 copied = flog.renamed(fnode)
1681 copy = follow and copied and copied[0]
1683 copy = follow and copied and copied[0]
1682 if copy:
1684 if copy:
1683 copies.setdefault(rev, {})[fn] = copy
1685 copies.setdefault(rev, {})[fn] = copy
1684 if fn in skip:
1686 if fn in skip:
1685 if copy:
1687 if copy:
1686 skip[copy] = True
1688 skip[copy] = True
1687 continue
1689 continue
1688 files.append(fn)
1690 files.append(fn)
1689
1691
1690 if fn not in matches[rev]:
1692 if fn not in matches[rev]:
1691 grepbody(fn, rev, flog.read(fnode))
1693 grepbody(fn, rev, flog.read(fnode))
1692
1694
1693 pfn = copy or fn
1695 pfn = copy or fn
1694 if pfn not in matches[parent]:
1696 if pfn not in matches[parent]:
1695 try:
1697 try:
1696 fnode = pctx.filenode(pfn)
1698 fnode = pctx.filenode(pfn)
1697 grepbody(pfn, parent, flog.read(fnode))
1699 grepbody(pfn, parent, flog.read(fnode))
1698 except error.LookupError:
1700 except error.LookupError:
1699 pass
1701 pass
1700
1702
1701 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1703 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1702 rev = ctx.rev()
1704 rev = ctx.rev()
1703 parent = ctx.parents()[0].rev()
1705 parent = ctx.parents()[0].rev()
1704 for fn in sorted(revfiles.get(rev, [])):
1706 for fn in sorted(revfiles.get(rev, [])):
1705 states = matches[rev][fn]
1707 states = matches[rev][fn]
1706 copy = copies.get(rev, {}).get(fn)
1708 copy = copies.get(rev, {}).get(fn)
1707 if fn in skip:
1709 if fn in skip:
1708 if copy:
1710 if copy:
1709 skip[copy] = True
1711 skip[copy] = True
1710 continue
1712 continue
1711 pstates = matches.get(parent, {}).get(copy or fn, [])
1713 pstates = matches.get(parent, {}).get(copy or fn, [])
1712 if pstates or states:
1714 if pstates or states:
1713 r = display(fn, ctx, pstates, states)
1715 r = display(fn, ctx, pstates, states)
1714 found = found or r
1716 found = found or r
1715 if r and not opts.get('all'):
1717 if r and not opts.get('all'):
1716 skip[fn] = True
1718 skip[fn] = True
1717 if copy:
1719 if copy:
1718 skip[copy] = True
1720 skip[copy] = True
1719 del matches[rev]
1721 del matches[rev]
1720 del revfiles[rev]
1722 del revfiles[rev]
1721
1723
1722 return not found
1724 return not found
1723
1725
1724 def heads(ui, repo, *branchrevs, **opts):
1726 def heads(ui, repo, *branchrevs, **opts):
1725 """show current repository heads or show branch heads
1727 """show current repository heads or show branch heads
1726
1728
1727 With no arguments, show all repository branch heads.
1729 With no arguments, show all repository branch heads.
1728
1730
1729 Repository "heads" are changesets with no child changesets. They are
1731 Repository "heads" are changesets with no child changesets. They are
1730 where development generally takes place and are the usual targets
1732 where development generally takes place and are the usual targets
1731 for update and merge operations. Branch heads are changesets that have
1733 for update and merge operations. Branch heads are changesets that have
1732 no child changeset on the same branch.
1734 no child changeset on the same branch.
1733
1735
1734 If one or more REVs are given, only branch heads on the branches
1736 If one or more REVs are given, only branch heads on the branches
1735 associated with the specified changesets are shown.
1737 associated with the specified changesets are shown.
1736
1738
1737 If -c/--closed is specified, also show branch heads marked closed
1739 If -c/--closed is specified, also show branch heads marked closed
1738 (see :hg:`commit --close-branch`).
1740 (see :hg:`commit --close-branch`).
1739
1741
1740 If STARTREV is specified, only those heads that are descendants of
1742 If STARTREV is specified, only those heads that are descendants of
1741 STARTREV will be displayed.
1743 STARTREV will be displayed.
1742
1744
1743 If -t/--topo is specified, named branch mechanics will be ignored and only
1745 If -t/--topo is specified, named branch mechanics will be ignored and only
1744 changesets without children will be shown.
1746 changesets without children will be shown.
1745
1747
1746 Returns 0 if matching heads are found, 1 if not.
1748 Returns 0 if matching heads are found, 1 if not.
1747 """
1749 """
1748
1750
1749 if opts.get('rev'):
1751 if opts.get('rev'):
1750 start = repo.lookup(opts['rev'])
1752 start = repo.lookup(opts['rev'])
1751 else:
1753 else:
1752 start = None
1754 start = None
1753
1755
1754 if opts.get('topo'):
1756 if opts.get('topo'):
1755 heads = [repo[h] for h in repo.heads(start)]
1757 heads = [repo[h] for h in repo.heads(start)]
1756 else:
1758 else:
1757 heads = []
1759 heads = []
1758 for b, ls in repo.branchmap().iteritems():
1760 for b, ls in repo.branchmap().iteritems():
1759 if start is None:
1761 if start is None:
1760 heads += [repo[h] for h in ls]
1762 heads += [repo[h] for h in ls]
1761 continue
1763 continue
1762 startrev = repo.changelog.rev(start)
1764 startrev = repo.changelog.rev(start)
1763 descendants = set(repo.changelog.descendants(startrev))
1765 descendants = set(repo.changelog.descendants(startrev))
1764 descendants.add(startrev)
1766 descendants.add(startrev)
1765 rev = repo.changelog.rev
1767 rev = repo.changelog.rev
1766 heads += [repo[h] for h in ls if rev(h) in descendants]
1768 heads += [repo[h] for h in ls if rev(h) in descendants]
1767
1769
1768 if branchrevs:
1770 if branchrevs:
1769 decode, encode = encoding.fromlocal, encoding.tolocal
1771 decode, encode = encoding.fromlocal, encoding.tolocal
1770 branches = set(repo[decode(br)].branch() for br in branchrevs)
1772 branches = set(repo[decode(br)].branch() for br in branchrevs)
1771 heads = [h for h in heads if h.branch() in branches]
1773 heads = [h for h in heads if h.branch() in branches]
1772
1774
1773 if not opts.get('closed'):
1775 if not opts.get('closed'):
1774 heads = [h for h in heads if not h.extra().get('close')]
1776 heads = [h for h in heads if not h.extra().get('close')]
1775
1777
1776 if opts.get('active') and branchrevs:
1778 if opts.get('active') and branchrevs:
1777 dagheads = repo.heads(start)
1779 dagheads = repo.heads(start)
1778 heads = [h for h in heads if h.node() in dagheads]
1780 heads = [h for h in heads if h.node() in dagheads]
1779
1781
1780 if branchrevs:
1782 if branchrevs:
1781 haveheads = set(h.branch() for h in heads)
1783 haveheads = set(h.branch() for h in heads)
1782 if branches - haveheads:
1784 if branches - haveheads:
1783 headless = ', '.join(encode(b) for b in branches - haveheads)
1785 headless = ', '.join(encode(b) for b in branches - haveheads)
1784 msg = _('no open branch heads found on branches %s')
1786 msg = _('no open branch heads found on branches %s')
1785 if opts.get('rev'):
1787 if opts.get('rev'):
1786 msg += _(' (started at %s)' % opts['rev'])
1788 msg += _(' (started at %s)' % opts['rev'])
1787 ui.warn((msg + '\n') % headless)
1789 ui.warn((msg + '\n') % headless)
1788
1790
1789 if not heads:
1791 if not heads:
1790 return 1
1792 return 1
1791
1793
1792 heads = sorted(heads, key=lambda x: -x.rev())
1794 heads = sorted(heads, key=lambda x: -x.rev())
1793 displayer = cmdutil.show_changeset(ui, repo, opts)
1795 displayer = cmdutil.show_changeset(ui, repo, opts)
1794 for ctx in heads:
1796 for ctx in heads:
1795 displayer.show(ctx)
1797 displayer.show(ctx)
1796 displayer.close()
1798 displayer.close()
1797
1799
1798 def help_(ui, name=None, with_version=False, unknowncmd=False):
1800 def help_(ui, name=None, with_version=False, unknowncmd=False):
1799 """show help for a given topic or a help overview
1801 """show help for a given topic or a help overview
1800
1802
1801 With no arguments, print a list of commands with short help messages.
1803 With no arguments, print a list of commands with short help messages.
1802
1804
1803 Given a topic, extension, or command name, print help for that
1805 Given a topic, extension, or command name, print help for that
1804 topic.
1806 topic.
1805
1807
1806 Returns 0 if successful.
1808 Returns 0 if successful.
1807 """
1809 """
1808 option_lists = []
1810 option_lists = []
1809 textwidth = util.termwidth() - 2
1811 textwidth = util.termwidth() - 2
1810
1812
1811 def addglobalopts(aliases):
1813 def addglobalopts(aliases):
1812 if ui.verbose:
1814 if ui.verbose:
1813 option_lists.append((_("global options:"), globalopts))
1815 option_lists.append((_("global options:"), globalopts))
1814 if name == 'shortlist':
1816 if name == 'shortlist':
1815 option_lists.append((_('use "hg help" for the full list '
1817 option_lists.append((_('use "hg help" for the full list '
1816 'of commands'), ()))
1818 'of commands'), ()))
1817 else:
1819 else:
1818 if name == 'shortlist':
1820 if name == 'shortlist':
1819 msg = _('use "hg help" for the full list of commands '
1821 msg = _('use "hg help" for the full list of commands '
1820 'or "hg -v" for details')
1822 'or "hg -v" for details')
1821 elif aliases:
1823 elif aliases:
1822 msg = _('use "hg -v help%s" to show aliases and '
1824 msg = _('use "hg -v help%s" to show aliases and '
1823 'global options') % (name and " " + name or "")
1825 'global options') % (name and " " + name or "")
1824 else:
1826 else:
1825 msg = _('use "hg -v help %s" to show global options') % name
1827 msg = _('use "hg -v help %s" to show global options') % name
1826 option_lists.append((msg, ()))
1828 option_lists.append((msg, ()))
1827
1829
1828 def helpcmd(name):
1830 def helpcmd(name):
1829 if with_version:
1831 if with_version:
1830 version_(ui)
1832 version_(ui)
1831 ui.write('\n')
1833 ui.write('\n')
1832
1834
1833 try:
1835 try:
1834 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
1836 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
1835 except error.AmbiguousCommand, inst:
1837 except error.AmbiguousCommand, inst:
1836 # py3k fix: except vars can't be used outside the scope of the
1838 # py3k fix: except vars can't be used outside the scope of the
1837 # except block, nor can be used inside a lambda. python issue4617
1839 # except block, nor can be used inside a lambda. python issue4617
1838 prefix = inst.args[0]
1840 prefix = inst.args[0]
1839 select = lambda c: c.lstrip('^').startswith(prefix)
1841 select = lambda c: c.lstrip('^').startswith(prefix)
1840 helplist(_('list of commands:\n\n'), select)
1842 helplist(_('list of commands:\n\n'), select)
1841 return
1843 return
1842
1844
1843 # check if it's an invalid alias and display its error if it is
1845 # check if it's an invalid alias and display its error if it is
1844 if getattr(entry[0], 'badalias', False):
1846 if getattr(entry[0], 'badalias', False):
1845 if not unknowncmd:
1847 if not unknowncmd:
1846 entry[0](ui)
1848 entry[0](ui)
1847 return
1849 return
1848
1850
1849 # synopsis
1851 # synopsis
1850 if len(entry) > 2:
1852 if len(entry) > 2:
1851 if entry[2].startswith('hg'):
1853 if entry[2].startswith('hg'):
1852 ui.write("%s\n" % entry[2])
1854 ui.write("%s\n" % entry[2])
1853 else:
1855 else:
1854 ui.write('hg %s %s\n' % (aliases[0], entry[2]))
1856 ui.write('hg %s %s\n' % (aliases[0], entry[2]))
1855 else:
1857 else:
1856 ui.write('hg %s\n' % aliases[0])
1858 ui.write('hg %s\n' % aliases[0])
1857
1859
1858 # aliases
1860 # aliases
1859 if not ui.quiet and len(aliases) > 1:
1861 if not ui.quiet and len(aliases) > 1:
1860 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
1862 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
1861
1863
1862 # description
1864 # description
1863 doc = gettext(entry[0].__doc__)
1865 doc = gettext(entry[0].__doc__)
1864 if not doc:
1866 if not doc:
1865 doc = _("(no help text available)")
1867 doc = _("(no help text available)")
1866 if hasattr(entry[0], 'definition'): # aliased command
1868 if hasattr(entry[0], 'definition'): # aliased command
1867 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
1869 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
1868 if ui.quiet:
1870 if ui.quiet:
1869 doc = doc.splitlines()[0]
1871 doc = doc.splitlines()[0]
1870 keep = ui.verbose and ['verbose'] or []
1872 keep = ui.verbose and ['verbose'] or []
1871 formatted, pruned = minirst.format(doc, textwidth, keep=keep)
1873 formatted, pruned = minirst.format(doc, textwidth, keep=keep)
1872 ui.write("\n%s\n" % formatted)
1874 ui.write("\n%s\n" % formatted)
1873 if pruned:
1875 if pruned:
1874 ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
1876 ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
1875
1877
1876 if not ui.quiet:
1878 if not ui.quiet:
1877 # options
1879 # options
1878 if entry[1]:
1880 if entry[1]:
1879 option_lists.append((_("options:\n"), entry[1]))
1881 option_lists.append((_("options:\n"), entry[1]))
1880
1882
1881 addglobalopts(False)
1883 addglobalopts(False)
1882
1884
1883 def helplist(header, select=None):
1885 def helplist(header, select=None):
1884 h = {}
1886 h = {}
1885 cmds = {}
1887 cmds = {}
1886 for c, e in table.iteritems():
1888 for c, e in table.iteritems():
1887 f = c.split("|", 1)[0]
1889 f = c.split("|", 1)[0]
1888 if select and not select(f):
1890 if select and not select(f):
1889 continue
1891 continue
1890 if (not select and name != 'shortlist' and
1892 if (not select and name != 'shortlist' and
1891 e[0].__module__ != __name__):
1893 e[0].__module__ != __name__):
1892 continue
1894 continue
1893 if name == "shortlist" and not f.startswith("^"):
1895 if name == "shortlist" and not f.startswith("^"):
1894 continue
1896 continue
1895 f = f.lstrip("^")
1897 f = f.lstrip("^")
1896 if not ui.debugflag and f.startswith("debug"):
1898 if not ui.debugflag and f.startswith("debug"):
1897 continue
1899 continue
1898 doc = e[0].__doc__
1900 doc = e[0].__doc__
1899 if doc and 'DEPRECATED' in doc and not ui.verbose:
1901 if doc and 'DEPRECATED' in doc and not ui.verbose:
1900 continue
1902 continue
1901 doc = gettext(doc)
1903 doc = gettext(doc)
1902 if not doc:
1904 if not doc:
1903 doc = _("(no help text available)")
1905 doc = _("(no help text available)")
1904 h[f] = doc.splitlines()[0].rstrip()
1906 h[f] = doc.splitlines()[0].rstrip()
1905 cmds[f] = c.lstrip("^")
1907 cmds[f] = c.lstrip("^")
1906
1908
1907 if not h:
1909 if not h:
1908 ui.status(_('no commands defined\n'))
1910 ui.status(_('no commands defined\n'))
1909 return
1911 return
1910
1912
1911 ui.status(header)
1913 ui.status(header)
1912 fns = sorted(h)
1914 fns = sorted(h)
1913 m = max(map(len, fns))
1915 m = max(map(len, fns))
1914 for f in fns:
1916 for f in fns:
1915 if ui.verbose:
1917 if ui.verbose:
1916 commands = cmds[f].replace("|",", ")
1918 commands = cmds[f].replace("|",", ")
1917 ui.write(" %s:\n %s\n"%(commands, h[f]))
1919 ui.write(" %s:\n %s\n"%(commands, h[f]))
1918 else:
1920 else:
1919 ui.write('%s\n' % (util.wrap(h[f],
1921 ui.write('%s\n' % (util.wrap(h[f],
1920 initindent=' %-*s ' % (m, f),
1922 initindent=' %-*s ' % (m, f),
1921 hangindent=' ' * (m + 4))))
1923 hangindent=' ' * (m + 4))))
1922
1924
1923 if not ui.quiet:
1925 if not ui.quiet:
1924 addglobalopts(True)
1926 addglobalopts(True)
1925
1927
1926 def helptopic(name):
1928 def helptopic(name):
1927 for names, header, doc in help.helptable:
1929 for names, header, doc in help.helptable:
1928 if name in names:
1930 if name in names:
1929 break
1931 break
1930 else:
1932 else:
1931 raise error.UnknownCommand(name)
1933 raise error.UnknownCommand(name)
1932
1934
1933 # description
1935 # description
1934 if not doc:
1936 if not doc:
1935 doc = _("(no help text available)")
1937 doc = _("(no help text available)")
1936 if hasattr(doc, '__call__'):
1938 if hasattr(doc, '__call__'):
1937 doc = doc()
1939 doc = doc()
1938
1940
1939 ui.write("%s\n\n" % header)
1941 ui.write("%s\n\n" % header)
1940 ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
1942 ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
1941
1943
1942 def helpext(name):
1944 def helpext(name):
1943 try:
1945 try:
1944 mod = extensions.find(name)
1946 mod = extensions.find(name)
1945 doc = gettext(mod.__doc__) or _('no help text available')
1947 doc = gettext(mod.__doc__) or _('no help text available')
1946 except KeyError:
1948 except KeyError:
1947 mod = None
1949 mod = None
1948 doc = extensions.disabledext(name)
1950 doc = extensions.disabledext(name)
1949 if not doc:
1951 if not doc:
1950 raise error.UnknownCommand(name)
1952 raise error.UnknownCommand(name)
1951
1953
1952 if '\n' not in doc:
1954 if '\n' not in doc:
1953 head, tail = doc, ""
1955 head, tail = doc, ""
1954 else:
1956 else:
1955 head, tail = doc.split('\n', 1)
1957 head, tail = doc.split('\n', 1)
1956 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
1958 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
1957 if tail:
1959 if tail:
1958 ui.write(minirst.format(tail, textwidth))
1960 ui.write(minirst.format(tail, textwidth))
1959 ui.status('\n\n')
1961 ui.status('\n\n')
1960
1962
1961 if mod:
1963 if mod:
1962 try:
1964 try:
1963 ct = mod.cmdtable
1965 ct = mod.cmdtable
1964 except AttributeError:
1966 except AttributeError:
1965 ct = {}
1967 ct = {}
1966 modcmds = set([c.split('|', 1)[0] for c in ct])
1968 modcmds = set([c.split('|', 1)[0] for c in ct])
1967 helplist(_('list of commands:\n\n'), modcmds.__contains__)
1969 helplist(_('list of commands:\n\n'), modcmds.__contains__)
1968 else:
1970 else:
1969 ui.write(_('use "hg help extensions" for information on enabling '
1971 ui.write(_('use "hg help extensions" for information on enabling '
1970 'extensions\n'))
1972 'extensions\n'))
1971
1973
1972 def helpextcmd(name):
1974 def helpextcmd(name):
1973 cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict'))
1975 cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict'))
1974 doc = gettext(mod.__doc__).splitlines()[0]
1976 doc = gettext(mod.__doc__).splitlines()[0]
1975
1977
1976 msg = help.listexts(_("'%s' is provided by the following "
1978 msg = help.listexts(_("'%s' is provided by the following "
1977 "extension:") % cmd, {ext: doc}, len(ext),
1979 "extension:") % cmd, {ext: doc}, len(ext),
1978 indent=4)
1980 indent=4)
1979 ui.write(minirst.format(msg, textwidth))
1981 ui.write(minirst.format(msg, textwidth))
1980 ui.write('\n\n')
1982 ui.write('\n\n')
1981 ui.write(_('use "hg help extensions" for information on enabling '
1983 ui.write(_('use "hg help extensions" for information on enabling '
1982 'extensions\n'))
1984 'extensions\n'))
1983
1985
1984 if name and name != 'shortlist':
1986 if name and name != 'shortlist':
1985 i = None
1987 i = None
1986 if unknowncmd:
1988 if unknowncmd:
1987 queries = (helpextcmd,)
1989 queries = (helpextcmd,)
1988 else:
1990 else:
1989 queries = (helptopic, helpcmd, helpext, helpextcmd)
1991 queries = (helptopic, helpcmd, helpext, helpextcmd)
1990 for f in queries:
1992 for f in queries:
1991 try:
1993 try:
1992 f(name)
1994 f(name)
1993 i = None
1995 i = None
1994 break
1996 break
1995 except error.UnknownCommand, inst:
1997 except error.UnknownCommand, inst:
1996 i = inst
1998 i = inst
1997 if i:
1999 if i:
1998 raise i
2000 raise i
1999
2001
2000 else:
2002 else:
2001 # program name
2003 # program name
2002 if ui.verbose or with_version:
2004 if ui.verbose or with_version:
2003 version_(ui)
2005 version_(ui)
2004 else:
2006 else:
2005 ui.status(_("Mercurial Distributed SCM\n"))
2007 ui.status(_("Mercurial Distributed SCM\n"))
2006 ui.status('\n')
2008 ui.status('\n')
2007
2009
2008 # list of commands
2010 # list of commands
2009 if name == "shortlist":
2011 if name == "shortlist":
2010 header = _('basic commands:\n\n')
2012 header = _('basic commands:\n\n')
2011 else:
2013 else:
2012 header = _('list of commands:\n\n')
2014 header = _('list of commands:\n\n')
2013
2015
2014 helplist(header)
2016 helplist(header)
2015 if name != 'shortlist':
2017 if name != 'shortlist':
2016 exts, maxlength = extensions.enabled()
2018 exts, maxlength = extensions.enabled()
2017 text = help.listexts(_('enabled extensions:'), exts, maxlength)
2019 text = help.listexts(_('enabled extensions:'), exts, maxlength)
2018 if text:
2020 if text:
2019 ui.write("\n%s\n" % minirst.format(text, textwidth))
2021 ui.write("\n%s\n" % minirst.format(text, textwidth))
2020
2022
2021 # list all option lists
2023 # list all option lists
2022 opt_output = []
2024 opt_output = []
2023 multioccur = False
2025 multioccur = False
2024 for title, options in option_lists:
2026 for title, options in option_lists:
2025 opt_output.append(("\n%s" % title, None))
2027 opt_output.append(("\n%s" % title, None))
2026 for option in options:
2028 for option in options:
2027 if len(option) == 5:
2029 if len(option) == 5:
2028 shortopt, longopt, default, desc, optlabel = option
2030 shortopt, longopt, default, desc, optlabel = option
2029 else:
2031 else:
2030 shortopt, longopt, default, desc = option
2032 shortopt, longopt, default, desc = option
2031 optlabel = _("VALUE") # default label
2033 optlabel = _("VALUE") # default label
2032
2034
2033 if _("DEPRECATED") in desc and not ui.verbose:
2035 if _("DEPRECATED") in desc and not ui.verbose:
2034 continue
2036 continue
2035 if isinstance(default, list):
2037 if isinstance(default, list):
2036 numqualifier = " %s [+]" % optlabel
2038 numqualifier = " %s [+]" % optlabel
2037 multioccur = True
2039 multioccur = True
2038 elif (default is not None) and not isinstance(default, bool):
2040 elif (default is not None) and not isinstance(default, bool):
2039 numqualifier = " %s" % optlabel
2041 numqualifier = " %s" % optlabel
2040 else:
2042 else:
2041 numqualifier = ""
2043 numqualifier = ""
2042 opt_output.append(("%2s%s" %
2044 opt_output.append(("%2s%s" %
2043 (shortopt and "-%s" % shortopt,
2045 (shortopt and "-%s" % shortopt,
2044 longopt and " --%s%s" %
2046 longopt and " --%s%s" %
2045 (longopt, numqualifier)),
2047 (longopt, numqualifier)),
2046 "%s%s" % (desc,
2048 "%s%s" % (desc,
2047 default
2049 default
2048 and _(" (default: %s)") % default
2050 and _(" (default: %s)") % default
2049 or "")))
2051 or "")))
2050 if multioccur:
2052 if multioccur:
2051 msg = _("\n[+] marked option can be specified multiple times")
2053 msg = _("\n[+] marked option can be specified multiple times")
2052 if ui.verbose and name != 'shortlist':
2054 if ui.verbose and name != 'shortlist':
2053 opt_output.append((msg, ()))
2055 opt_output.append((msg, ()))
2054 else:
2056 else:
2055 opt_output.insert(-1, (msg, ()))
2057 opt_output.insert(-1, (msg, ()))
2056
2058
2057 if not name:
2059 if not name:
2058 ui.write(_("\nadditional help topics:\n\n"))
2060 ui.write(_("\nadditional help topics:\n\n"))
2059 topics = []
2061 topics = []
2060 for names, header, doc in help.helptable:
2062 for names, header, doc in help.helptable:
2061 topics.append((sorted(names, key=len, reverse=True)[0], header))
2063 topics.append((sorted(names, key=len, reverse=True)[0], header))
2062 topics_len = max([len(s[0]) for s in topics])
2064 topics_len = max([len(s[0]) for s in topics])
2063 for t, desc in topics:
2065 for t, desc in topics:
2064 ui.write(" %-*s %s\n" % (topics_len, t, desc))
2066 ui.write(" %-*s %s\n" % (topics_len, t, desc))
2065
2067
2066 if opt_output:
2068 if opt_output:
2067 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
2069 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
2068 for first, second in opt_output:
2070 for first, second in opt_output:
2069 if second:
2071 if second:
2070 initindent = ' %-*s ' % (opts_len, first)
2072 initindent = ' %-*s ' % (opts_len, first)
2071 hangindent = ' ' * (opts_len + 3)
2073 hangindent = ' ' * (opts_len + 3)
2072 ui.write('%s\n' % (util.wrap(second,
2074 ui.write('%s\n' % (util.wrap(second,
2073 initindent=initindent,
2075 initindent=initindent,
2074 hangindent=hangindent)))
2076 hangindent=hangindent)))
2075 else:
2077 else:
2076 ui.write("%s\n" % first)
2078 ui.write("%s\n" % first)
2077
2079
2078 def identify(ui, repo, source=None,
2080 def identify(ui, repo, source=None,
2079 rev=None, num=None, id=None, branch=None, tags=None):
2081 rev=None, num=None, id=None, branch=None, tags=None):
2080 """identify the working copy or specified revision
2082 """identify the working copy or specified revision
2081
2083
2082 With no revision, print a summary of the current state of the
2084 With no revision, print a summary of the current state of the
2083 repository.
2085 repository.
2084
2086
2085 Specifying a path to a repository root or Mercurial bundle will
2087 Specifying a path to a repository root or Mercurial bundle will
2086 cause lookup to operate on that repository/bundle.
2088 cause lookup to operate on that repository/bundle.
2087
2089
2088 This summary identifies the repository state using one or two
2090 This summary identifies the repository state using one or two
2089 parent hash identifiers, followed by a "+" if there are
2091 parent hash identifiers, followed by a "+" if there are
2090 uncommitted changes in the working directory, a list of tags for
2092 uncommitted changes in the working directory, a list of tags for
2091 this revision and a branch name for non-default branches.
2093 this revision and a branch name for non-default branches.
2092
2094
2093 Returns 0 if successful.
2095 Returns 0 if successful.
2094 """
2096 """
2095
2097
2096 if not repo and not source:
2098 if not repo and not source:
2097 raise util.Abort(_("There is no Mercurial repository here "
2099 raise util.Abort(_("There is no Mercurial repository here "
2098 "(.hg not found)"))
2100 "(.hg not found)"))
2099
2101
2100 hexfunc = ui.debugflag and hex or short
2102 hexfunc = ui.debugflag and hex or short
2101 default = not (num or id or branch or tags)
2103 default = not (num or id or branch or tags)
2102 output = []
2104 output = []
2103
2105
2104 revs = []
2106 revs = []
2105 if source:
2107 if source:
2106 source, branches = hg.parseurl(ui.expandpath(source))
2108 source, branches = hg.parseurl(ui.expandpath(source))
2107 repo = hg.repository(ui, source)
2109 repo = hg.repository(ui, source)
2108 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
2110 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
2109
2111
2110 if not repo.local():
2112 if not repo.local():
2111 if not rev and revs:
2113 if not rev and revs:
2112 rev = revs[0]
2114 rev = revs[0]
2113 if not rev:
2115 if not rev:
2114 rev = "tip"
2116 rev = "tip"
2115 if num or branch or tags:
2117 if num or branch or tags:
2116 raise util.Abort(
2118 raise util.Abort(
2117 "can't query remote revision number, branch, or tags")
2119 "can't query remote revision number, branch, or tags")
2118 output = [hexfunc(repo.lookup(rev))]
2120 output = [hexfunc(repo.lookup(rev))]
2119 elif not rev:
2121 elif not rev:
2120 ctx = repo[None]
2122 ctx = repo[None]
2121 parents = ctx.parents()
2123 parents = ctx.parents()
2122 changed = False
2124 changed = False
2123 if default or id or num:
2125 if default or id or num:
2124 changed = util.any(repo.status())
2126 changed = util.any(repo.status())
2125 if default or id:
2127 if default or id:
2126 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
2128 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
2127 (changed) and "+" or "")]
2129 (changed) and "+" or "")]
2128 if num:
2130 if num:
2129 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
2131 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
2130 (changed) and "+" or ""))
2132 (changed) and "+" or ""))
2131 else:
2133 else:
2132 ctx = repo[rev]
2134 ctx = repo[rev]
2133 if default or id:
2135 if default or id:
2134 output = [hexfunc(ctx.node())]
2136 output = [hexfunc(ctx.node())]
2135 if num:
2137 if num:
2136 output.append(str(ctx.rev()))
2138 output.append(str(ctx.rev()))
2137
2139
2138 if repo.local() and default and not ui.quiet:
2140 if repo.local() and default and not ui.quiet:
2139 b = encoding.tolocal(ctx.branch())
2141 b = encoding.tolocal(ctx.branch())
2140 if b != 'default':
2142 if b != 'default':
2141 output.append("(%s)" % b)
2143 output.append("(%s)" % b)
2142
2144
2143 # multiple tags for a single parent separated by '/'
2145 # multiple tags for a single parent separated by '/'
2144 t = "/".join(ctx.tags())
2146 t = "/".join(ctx.tags())
2145 if t:
2147 if t:
2146 output.append(t)
2148 output.append(t)
2147
2149
2148 if branch:
2150 if branch:
2149 output.append(encoding.tolocal(ctx.branch()))
2151 output.append(encoding.tolocal(ctx.branch()))
2150
2152
2151 if tags:
2153 if tags:
2152 output.extend(ctx.tags())
2154 output.extend(ctx.tags())
2153
2155
2154 ui.write("%s\n" % ' '.join(output))
2156 ui.write("%s\n" % ' '.join(output))
2155
2157
2156 def import_(ui, repo, patch1, *patches, **opts):
2158 def import_(ui, repo, patch1, *patches, **opts):
2157 """import an ordered set of patches
2159 """import an ordered set of patches
2158
2160
2159 Import a list of patches and commit them individually (unless
2161 Import a list of patches and commit them individually (unless
2160 --no-commit is specified).
2162 --no-commit is specified).
2161
2163
2162 If there are outstanding changes in the working directory, import
2164 If there are outstanding changes in the working directory, import
2163 will abort unless given the -f/--force flag.
2165 will abort unless given the -f/--force flag.
2164
2166
2165 You can import a patch straight from a mail message. Even patches
2167 You can import a patch straight from a mail message. Even patches
2166 as attachments work (to use the body part, it must have type
2168 as attachments work (to use the body part, it must have type
2167 text/plain or text/x-patch). From and Subject headers of email
2169 text/plain or text/x-patch). From and Subject headers of email
2168 message are used as default committer and commit message. All
2170 message are used as default committer and commit message. All
2169 text/plain body parts before first diff are added to commit
2171 text/plain body parts before first diff are added to commit
2170 message.
2172 message.
2171
2173
2172 If the imported patch was generated by :hg:`export`, user and
2174 If the imported patch was generated by :hg:`export`, user and
2173 description from patch override values from message headers and
2175 description from patch override values from message headers and
2174 body. Values given on command line with -m/--message and -u/--user
2176 body. Values given on command line with -m/--message and -u/--user
2175 override these.
2177 override these.
2176
2178
2177 If --exact is specified, import will set the working directory to
2179 If --exact is specified, import will set the working directory to
2178 the parent of each patch before applying it, and will abort if the
2180 the parent of each patch before applying it, and will abort if the
2179 resulting changeset has a different ID than the one recorded in
2181 resulting changeset has a different ID than the one recorded in
2180 the patch. This may happen due to character set problems or other
2182 the patch. This may happen due to character set problems or other
2181 deficiencies in the text patch format.
2183 deficiencies in the text patch format.
2182
2184
2183 With -s/--similarity, hg will attempt to discover renames and
2185 With -s/--similarity, hg will attempt to discover renames and
2184 copies in the patch in the same way as 'addremove'.
2186 copies in the patch in the same way as 'addremove'.
2185
2187
2186 To read a patch from standard input, use "-" as the patch name. If
2188 To read a patch from standard input, use "-" as the patch name. If
2187 a URL is specified, the patch will be downloaded from it.
2189 a URL is specified, the patch will be downloaded from it.
2188 See :hg:`help dates` for a list of formats valid for -d/--date.
2190 See :hg:`help dates` for a list of formats valid for -d/--date.
2189
2191
2190 Returns 0 on success.
2192 Returns 0 on success.
2191 """
2193 """
2192 patches = (patch1,) + patches
2194 patches = (patch1,) + patches
2193
2195
2194 date = opts.get('date')
2196 date = opts.get('date')
2195 if date:
2197 if date:
2196 opts['date'] = util.parsedate(date)
2198 opts['date'] = util.parsedate(date)
2197
2199
2198 try:
2200 try:
2199 sim = float(opts.get('similarity') or 0)
2201 sim = float(opts.get('similarity') or 0)
2200 except ValueError:
2202 except ValueError:
2201 raise util.Abort(_('similarity must be a number'))
2203 raise util.Abort(_('similarity must be a number'))
2202 if sim < 0 or sim > 100:
2204 if sim < 0 or sim > 100:
2203 raise util.Abort(_('similarity must be between 0 and 100'))
2205 raise util.Abort(_('similarity must be between 0 and 100'))
2204
2206
2205 if opts.get('exact') or not opts.get('force'):
2207 if opts.get('exact') or not opts.get('force'):
2206 cmdutil.bail_if_changed(repo)
2208 cmdutil.bail_if_changed(repo)
2207
2209
2208 d = opts["base"]
2210 d = opts["base"]
2209 strip = opts["strip"]
2211 strip = opts["strip"]
2210 wlock = lock = None
2212 wlock = lock = None
2211
2213
2212 def tryone(ui, hunk):
2214 def tryone(ui, hunk):
2213 tmpname, message, user, date, branch, nodeid, p1, p2 = \
2215 tmpname, message, user, date, branch, nodeid, p1, p2 = \
2214 patch.extract(ui, hunk)
2216 patch.extract(ui, hunk)
2215
2217
2216 if not tmpname:
2218 if not tmpname:
2217 return None
2219 return None
2218 commitid = _('to working directory')
2220 commitid = _('to working directory')
2219
2221
2220 try:
2222 try:
2221 cmdline_message = cmdutil.logmessage(opts)
2223 cmdline_message = cmdutil.logmessage(opts)
2222 if cmdline_message:
2224 if cmdline_message:
2223 # pickup the cmdline msg
2225 # pickup the cmdline msg
2224 message = cmdline_message
2226 message = cmdline_message
2225 elif message:
2227 elif message:
2226 # pickup the patch msg
2228 # pickup the patch msg
2227 message = message.strip()
2229 message = message.strip()
2228 else:
2230 else:
2229 # launch the editor
2231 # launch the editor
2230 message = None
2232 message = None
2231 ui.debug('message:\n%s\n' % message)
2233 ui.debug('message:\n%s\n' % message)
2232
2234
2233 wp = repo.parents()
2235 wp = repo.parents()
2234 if opts.get('exact'):
2236 if opts.get('exact'):
2235 if not nodeid or not p1:
2237 if not nodeid or not p1:
2236 raise util.Abort(_('not a Mercurial patch'))
2238 raise util.Abort(_('not a Mercurial patch'))
2237 p1 = repo.lookup(p1)
2239 p1 = repo.lookup(p1)
2238 p2 = repo.lookup(p2 or hex(nullid))
2240 p2 = repo.lookup(p2 or hex(nullid))
2239
2241
2240 if p1 != wp[0].node():
2242 if p1 != wp[0].node():
2241 hg.clean(repo, p1)
2243 hg.clean(repo, p1)
2242 repo.dirstate.setparents(p1, p2)
2244 repo.dirstate.setparents(p1, p2)
2243 elif p2:
2245 elif p2:
2244 try:
2246 try:
2245 p1 = repo.lookup(p1)
2247 p1 = repo.lookup(p1)
2246 p2 = repo.lookup(p2)
2248 p2 = repo.lookup(p2)
2247 if p1 == wp[0].node():
2249 if p1 == wp[0].node():
2248 repo.dirstate.setparents(p1, p2)
2250 repo.dirstate.setparents(p1, p2)
2249 except error.RepoError:
2251 except error.RepoError:
2250 pass
2252 pass
2251 if opts.get('exact') or opts.get('import_branch'):
2253 if opts.get('exact') or opts.get('import_branch'):
2252 repo.dirstate.setbranch(branch or 'default')
2254 repo.dirstate.setbranch(branch or 'default')
2253
2255
2254 files = {}
2256 files = {}
2255 try:
2257 try:
2256 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
2258 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
2257 files=files, eolmode=None)
2259 files=files, eolmode=None)
2258 finally:
2260 finally:
2259 files = patch.updatedir(ui, repo, files,
2261 files = patch.updatedir(ui, repo, files,
2260 similarity=sim / 100.0)
2262 similarity=sim / 100.0)
2261 if not opts.get('no_commit'):
2263 if not opts.get('no_commit'):
2262 if opts.get('exact'):
2264 if opts.get('exact'):
2263 m = None
2265 m = None
2264 else:
2266 else:
2265 m = cmdutil.matchfiles(repo, files or [])
2267 m = cmdutil.matchfiles(repo, files or [])
2266 n = repo.commit(message, opts.get('user') or user,
2268 n = repo.commit(message, opts.get('user') or user,
2267 opts.get('date') or date, match=m,
2269 opts.get('date') or date, match=m,
2268 editor=cmdutil.commiteditor)
2270 editor=cmdutil.commiteditor)
2269 if opts.get('exact'):
2271 if opts.get('exact'):
2270 if hex(n) != nodeid:
2272 if hex(n) != nodeid:
2271 repo.rollback()
2273 repo.rollback()
2272 raise util.Abort(_('patch is damaged'
2274 raise util.Abort(_('patch is damaged'
2273 ' or loses information'))
2275 ' or loses information'))
2274 # Force a dirstate write so that the next transaction
2276 # Force a dirstate write so that the next transaction
2275 # backups an up-do-date file.
2277 # backups an up-do-date file.
2276 repo.dirstate.write()
2278 repo.dirstate.write()
2277 if n:
2279 if n:
2278 commitid = short(n)
2280 commitid = short(n)
2279
2281
2280 return commitid
2282 return commitid
2281 finally:
2283 finally:
2282 os.unlink(tmpname)
2284 os.unlink(tmpname)
2283
2285
2284 try:
2286 try:
2285 wlock = repo.wlock()
2287 wlock = repo.wlock()
2286 lock = repo.lock()
2288 lock = repo.lock()
2287 lastcommit = None
2289 lastcommit = None
2288 for p in patches:
2290 for p in patches:
2289 pf = os.path.join(d, p)
2291 pf = os.path.join(d, p)
2290
2292
2291 if pf == '-':
2293 if pf == '-':
2292 ui.status(_("applying patch from stdin\n"))
2294 ui.status(_("applying patch from stdin\n"))
2293 pf = sys.stdin
2295 pf = sys.stdin
2294 else:
2296 else:
2295 ui.status(_("applying %s\n") % p)
2297 ui.status(_("applying %s\n") % p)
2296 pf = url.open(ui, pf)
2298 pf = url.open(ui, pf)
2297
2299
2298 haspatch = False
2300 haspatch = False
2299 for hunk in patch.split(pf):
2301 for hunk in patch.split(pf):
2300 commitid = tryone(ui, hunk)
2302 commitid = tryone(ui, hunk)
2301 if commitid:
2303 if commitid:
2302 haspatch = True
2304 haspatch = True
2303 if lastcommit:
2305 if lastcommit:
2304 ui.status(_('applied %s\n') % lastcommit)
2306 ui.status(_('applied %s\n') % lastcommit)
2305 lastcommit = commitid
2307 lastcommit = commitid
2306
2308
2307 if not haspatch:
2309 if not haspatch:
2308 raise util.Abort(_('no diffs found'))
2310 raise util.Abort(_('no diffs found'))
2309
2311
2310 finally:
2312 finally:
2311 release(lock, wlock)
2313 release(lock, wlock)
2312
2314
2313 def incoming(ui, repo, source="default", **opts):
2315 def incoming(ui, repo, source="default", **opts):
2314 """show new changesets found in source
2316 """show new changesets found in source
2315
2317
2316 Show new changesets found in the specified path/URL or the default
2318 Show new changesets found in the specified path/URL or the default
2317 pull location. These are the changesets that would have been pulled
2319 pull location. These are the changesets that would have been pulled
2318 if a pull at the time you issued this command.
2320 if a pull at the time you issued this command.
2319
2321
2320 For remote repository, using --bundle avoids downloading the
2322 For remote repository, using --bundle avoids downloading the
2321 changesets twice if the incoming is followed by a pull.
2323 changesets twice if the incoming is followed by a pull.
2322
2324
2323 See pull for valid source format details.
2325 See pull for valid source format details.
2324
2326
2325 Returns 0 if there are incoming changes, 1 otherwise.
2327 Returns 0 if there are incoming changes, 1 otherwise.
2326 """
2328 """
2327 limit = cmdutil.loglimit(opts)
2329 limit = cmdutil.loglimit(opts)
2328 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2330 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2329 other = hg.repository(hg.remoteui(repo, opts), source)
2331 other = hg.repository(hg.remoteui(repo, opts), source)
2330 ui.status(_('comparing with %s\n') % url.hidepassword(source))
2332 ui.status(_('comparing with %s\n') % url.hidepassword(source))
2331 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2333 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2332 if revs:
2334 if revs:
2333 revs = [other.lookup(rev) for rev in revs]
2335 revs = [other.lookup(rev) for rev in revs]
2334
2336
2335 tmp = discovery.findcommonincoming(repo, other, heads=revs,
2337 tmp = discovery.findcommonincoming(repo, other, heads=revs,
2336 force=opts.get('force'))
2338 force=opts.get('force'))
2337 common, incoming, rheads = tmp
2339 common, incoming, rheads = tmp
2338 if not incoming:
2340 if not incoming:
2339 try:
2341 try:
2340 os.unlink(opts["bundle"])
2342 os.unlink(opts["bundle"])
2341 except:
2343 except:
2342 pass
2344 pass
2343 ui.status(_("no changes found\n"))
2345 ui.status(_("no changes found\n"))
2344 return 1
2346 return 1
2345
2347
2346 cleanup = None
2348 cleanup = None
2347 try:
2349 try:
2348 fname = opts["bundle"]
2350 fname = opts["bundle"]
2349 if fname or not other.local():
2351 if fname or not other.local():
2350 # create a bundle (uncompressed if other repo is not local)
2352 # create a bundle (uncompressed if other repo is not local)
2351
2353
2352 if revs is None and other.capable('changegroupsubset'):
2354 if revs is None and other.capable('changegroupsubset'):
2353 revs = rheads
2355 revs = rheads
2354
2356
2355 if revs is None:
2357 if revs is None:
2356 cg = other.changegroup(incoming, "incoming")
2358 cg = other.changegroup(incoming, "incoming")
2357 else:
2359 else:
2358 cg = other.changegroupsubset(incoming, revs, 'incoming')
2360 cg = other.changegroupsubset(incoming, revs, 'incoming')
2359 bundletype = other.local() and "HG10BZ" or "HG10UN"
2361 bundletype = other.local() and "HG10BZ" or "HG10UN"
2360 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
2362 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
2361 # keep written bundle?
2363 # keep written bundle?
2362 if opts["bundle"]:
2364 if opts["bundle"]:
2363 cleanup = None
2365 cleanup = None
2364 if not other.local():
2366 if not other.local():
2365 # use the created uncompressed bundlerepo
2367 # use the created uncompressed bundlerepo
2366 other = bundlerepo.bundlerepository(ui, repo.root, fname)
2368 other = bundlerepo.bundlerepository(ui, repo.root, fname)
2367
2369
2368 o = other.changelog.nodesbetween(incoming, revs)[0]
2370 o = other.changelog.nodesbetween(incoming, revs)[0]
2369 if opts.get('newest_first'):
2371 if opts.get('newest_first'):
2370 o.reverse()
2372 o.reverse()
2371 displayer = cmdutil.show_changeset(ui, other, opts)
2373 displayer = cmdutil.show_changeset(ui, other, opts)
2372 count = 0
2374 count = 0
2373 for n in o:
2375 for n in o:
2374 if limit is not None and count >= limit:
2376 if limit is not None and count >= limit:
2375 break
2377 break
2376 parents = [p for p in other.changelog.parents(n) if p != nullid]
2378 parents = [p for p in other.changelog.parents(n) if p != nullid]
2377 if opts.get('no_merges') and len(parents) == 2:
2379 if opts.get('no_merges') and len(parents) == 2:
2378 continue
2380 continue
2379 count += 1
2381 count += 1
2380 displayer.show(other[n])
2382 displayer.show(other[n])
2381 displayer.close()
2383 displayer.close()
2382 finally:
2384 finally:
2383 if hasattr(other, 'close'):
2385 if hasattr(other, 'close'):
2384 other.close()
2386 other.close()
2385 if cleanup:
2387 if cleanup:
2386 os.unlink(cleanup)
2388 os.unlink(cleanup)
2387
2389
2388 def init(ui, dest=".", **opts):
2390 def init(ui, dest=".", **opts):
2389 """create a new repository in the given directory
2391 """create a new repository in the given directory
2390
2392
2391 Initialize a new repository in the given directory. If the given
2393 Initialize a new repository in the given directory. If the given
2392 directory does not exist, it will be created.
2394 directory does not exist, it will be created.
2393
2395
2394 If no directory is given, the current directory is used.
2396 If no directory is given, the current directory is used.
2395
2397
2396 It is possible to specify an ``ssh://`` URL as the destination.
2398 It is possible to specify an ``ssh://`` URL as the destination.
2397 See :hg:`help urls` for more information.
2399 See :hg:`help urls` for more information.
2398
2400
2399 Returns 0 on success.
2401 Returns 0 on success.
2400 """
2402 """
2401 hg.repository(hg.remoteui(ui, opts), dest, create=1)
2403 hg.repository(hg.remoteui(ui, opts), dest, create=1)
2402
2404
2403 def locate(ui, repo, *pats, **opts):
2405 def locate(ui, repo, *pats, **opts):
2404 """locate files matching specific patterns
2406 """locate files matching specific patterns
2405
2407
2406 Print files under Mercurial control in the working directory whose
2408 Print files under Mercurial control in the working directory whose
2407 names match the given patterns.
2409 names match the given patterns.
2408
2410
2409 By default, this command searches all directories in the working
2411 By default, this command searches all directories in the working
2410 directory. To search just the current directory and its
2412 directory. To search just the current directory and its
2411 subdirectories, use "--include .".
2413 subdirectories, use "--include .".
2412
2414
2413 If no patterns are given to match, this command prints the names
2415 If no patterns are given to match, this command prints the names
2414 of all files under Mercurial control in the working directory.
2416 of all files under Mercurial control in the working directory.
2415
2417
2416 If you want to feed the output of this command into the "xargs"
2418 If you want to feed the output of this command into the "xargs"
2417 command, use the -0 option to both this command and "xargs". This
2419 command, use the -0 option to both this command and "xargs". This
2418 will avoid the problem of "xargs" treating single filenames that
2420 will avoid the problem of "xargs" treating single filenames that
2419 contain whitespace as multiple filenames.
2421 contain whitespace as multiple filenames.
2420
2422
2421 Returns 0 if a match is found, 1 otherwise.
2423 Returns 0 if a match is found, 1 otherwise.
2422 """
2424 """
2423 end = opts.get('print0') and '\0' or '\n'
2425 end = opts.get('print0') and '\0' or '\n'
2424 rev = opts.get('rev') or None
2426 rev = opts.get('rev') or None
2425
2427
2426 ret = 1
2428 ret = 1
2427 m = cmdutil.match(repo, pats, opts, default='relglob')
2429 m = cmdutil.match(repo, pats, opts, default='relglob')
2428 m.bad = lambda x, y: False
2430 m.bad = lambda x, y: False
2429 for abs in repo[rev].walk(m):
2431 for abs in repo[rev].walk(m):
2430 if not rev and abs not in repo.dirstate:
2432 if not rev and abs not in repo.dirstate:
2431 continue
2433 continue
2432 if opts.get('fullpath'):
2434 if opts.get('fullpath'):
2433 ui.write(repo.wjoin(abs), end)
2435 ui.write(repo.wjoin(abs), end)
2434 else:
2436 else:
2435 ui.write(((pats and m.rel(abs)) or abs), end)
2437 ui.write(((pats and m.rel(abs)) or abs), end)
2436 ret = 0
2438 ret = 0
2437
2439
2438 return ret
2440 return ret
2439
2441
2440 def log(ui, repo, *pats, **opts):
2442 def log(ui, repo, *pats, **opts):
2441 """show revision history of entire repository or files
2443 """show revision history of entire repository or files
2442
2444
2443 Print the revision history of the specified files or the entire
2445 Print the revision history of the specified files or the entire
2444 project.
2446 project.
2445
2447
2446 File history is shown without following rename or copy history of
2448 File history is shown without following rename or copy history of
2447 files. Use -f/--follow with a filename to follow history across
2449 files. Use -f/--follow with a filename to follow history across
2448 renames and copies. --follow without a filename will only show
2450 renames and copies. --follow without a filename will only show
2449 ancestors or descendants of the starting revision. --follow-first
2451 ancestors or descendants of the starting revision. --follow-first
2450 only follows the first parent of merge revisions.
2452 only follows the first parent of merge revisions.
2451
2453
2452 If no revision range is specified, the default is tip:0 unless
2454 If no revision range is specified, the default is tip:0 unless
2453 --follow is set, in which case the working directory parent is
2455 --follow is set, in which case the working directory parent is
2454 used as the starting revision. You can specify a revision set for
2456 used as the starting revision. You can specify a revision set for
2455 log, see :hg:`help revsets` for more information.
2457 log, see :hg:`help revsets` for more information.
2456
2458
2457 See :hg:`help dates` for a list of formats valid for -d/--date.
2459 See :hg:`help dates` for a list of formats valid for -d/--date.
2458
2460
2459 By default this command prints revision number and changeset id,
2461 By default this command prints revision number and changeset id,
2460 tags, non-trivial parents, user, date and time, and a summary for
2462 tags, non-trivial parents, user, date and time, and a summary for
2461 each commit. When the -v/--verbose switch is used, the list of
2463 each commit. When the -v/--verbose switch is used, the list of
2462 changed files and full commit message are shown.
2464 changed files and full commit message are shown.
2463
2465
2464 NOTE: log -p/--patch may generate unexpected diff output for merge
2466 NOTE: log -p/--patch may generate unexpected diff output for merge
2465 changesets, as it will only compare the merge changeset against
2467 changesets, as it will only compare the merge changeset against
2466 its first parent. Also, only files different from BOTH parents
2468 its first parent. Also, only files different from BOTH parents
2467 will appear in files:.
2469 will appear in files:.
2468
2470
2469 Returns 0 on success.
2471 Returns 0 on success.
2470 """
2472 """
2471
2473
2472 matchfn = cmdutil.match(repo, pats, opts)
2474 matchfn = cmdutil.match(repo, pats, opts)
2473 limit = cmdutil.loglimit(opts)
2475 limit = cmdutil.loglimit(opts)
2474 count = 0
2476 count = 0
2475
2477
2476 endrev = None
2478 endrev = None
2477 if opts.get('copies') and opts.get('rev'):
2479 if opts.get('copies') and opts.get('rev'):
2478 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
2480 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
2479
2481
2480 df = False
2482 df = False
2481 if opts["date"]:
2483 if opts["date"]:
2482 df = util.matchdate(opts["date"])
2484 df = util.matchdate(opts["date"])
2483
2485
2484 branches = opts.get('branch', []) + opts.get('only_branch', [])
2486 branches = opts.get('branch', []) + opts.get('only_branch', [])
2485 opts['branch'] = [repo.lookupbranch(b) for b in branches]
2487 opts['branch'] = [repo.lookupbranch(b) for b in branches]
2486
2488
2487 displayer = cmdutil.show_changeset(ui, repo, opts, True)
2489 displayer = cmdutil.show_changeset(ui, repo, opts, True)
2488 def prep(ctx, fns):
2490 def prep(ctx, fns):
2489 rev = ctx.rev()
2491 rev = ctx.rev()
2490 parents = [p for p in repo.changelog.parentrevs(rev)
2492 parents = [p for p in repo.changelog.parentrevs(rev)
2491 if p != nullrev]
2493 if p != nullrev]
2492 if opts.get('no_merges') and len(parents) == 2:
2494 if opts.get('no_merges') and len(parents) == 2:
2493 return
2495 return
2494 if opts.get('only_merges') and len(parents) != 2:
2496 if opts.get('only_merges') and len(parents) != 2:
2495 return
2497 return
2496 if opts.get('branch') and ctx.branch() not in opts['branch']:
2498 if opts.get('branch') and ctx.branch() not in opts['branch']:
2497 return
2499 return
2498 if df and not df(ctx.date()[0]):
2500 if df and not df(ctx.date()[0]):
2499 return
2501 return
2500 if opts['user'] and not [k for k in opts['user'] if k in ctx.user()]:
2502 if opts['user'] and not [k for k in opts['user'] if k in ctx.user()]:
2501 return
2503 return
2502 if opts.get('keyword'):
2504 if opts.get('keyword'):
2503 for k in [kw.lower() for kw in opts['keyword']]:
2505 for k in [kw.lower() for kw in opts['keyword']]:
2504 if (k in ctx.user().lower() or
2506 if (k in ctx.user().lower() or
2505 k in ctx.description().lower() or
2507 k in ctx.description().lower() or
2506 k in " ".join(ctx.files()).lower()):
2508 k in " ".join(ctx.files()).lower()):
2507 break
2509 break
2508 else:
2510 else:
2509 return
2511 return
2510
2512
2511 copies = None
2513 copies = None
2512 if opts.get('copies') and rev:
2514 if opts.get('copies') and rev:
2513 copies = []
2515 copies = []
2514 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
2516 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
2515 for fn in ctx.files():
2517 for fn in ctx.files():
2516 rename = getrenamed(fn, rev)
2518 rename = getrenamed(fn, rev)
2517 if rename:
2519 if rename:
2518 copies.append((fn, rename[0]))
2520 copies.append((fn, rename[0]))
2519
2521
2520 revmatchfn = None
2522 revmatchfn = None
2521 if opts.get('patch') or opts.get('stat'):
2523 if opts.get('patch') or opts.get('stat'):
2522 revmatchfn = cmdutil.match(repo, fns)
2524 revmatchfn = cmdutil.match(repo, fns)
2523
2525
2524 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
2526 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
2525
2527
2526 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2528 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2527 if count == limit:
2529 if count == limit:
2528 break
2530 break
2529 if displayer.flush(ctx.rev()):
2531 if displayer.flush(ctx.rev()):
2530 count += 1
2532 count += 1
2531 displayer.close()
2533 displayer.close()
2532
2534
2533 def manifest(ui, repo, node=None, rev=None):
2535 def manifest(ui, repo, node=None, rev=None):
2534 """output the current or given revision of the project manifest
2536 """output the current or given revision of the project manifest
2535
2537
2536 Print a list of version controlled files for the given revision.
2538 Print a list of version controlled files for the given revision.
2537 If no revision is given, the first parent of the working directory
2539 If no revision is given, the first parent of the working directory
2538 is used, or the null revision if no revision is checked out.
2540 is used, or the null revision if no revision is checked out.
2539
2541
2540 With -v, print file permissions, symlink and executable bits.
2542 With -v, print file permissions, symlink and executable bits.
2541 With --debug, print file revision hashes.
2543 With --debug, print file revision hashes.
2542
2544
2543 Returns 0 on success.
2545 Returns 0 on success.
2544 """
2546 """
2545
2547
2546 if rev and node:
2548 if rev and node:
2547 raise util.Abort(_("please specify just one revision"))
2549 raise util.Abort(_("please specify just one revision"))
2548
2550
2549 if not node:
2551 if not node:
2550 node = rev
2552 node = rev
2551
2553
2552 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2554 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2553 ctx = repo[node]
2555 ctx = repo[node]
2554 for f in ctx:
2556 for f in ctx:
2555 if ui.debugflag:
2557 if ui.debugflag:
2556 ui.write("%40s " % hex(ctx.manifest()[f]))
2558 ui.write("%40s " % hex(ctx.manifest()[f]))
2557 if ui.verbose:
2559 if ui.verbose:
2558 ui.write(decor[ctx.flags(f)])
2560 ui.write(decor[ctx.flags(f)])
2559 ui.write("%s\n" % f)
2561 ui.write("%s\n" % f)
2560
2562
2561 def merge(ui, repo, node=None, **opts):
2563 def merge(ui, repo, node=None, **opts):
2562 """merge working directory with another revision
2564 """merge working directory with another revision
2563
2565
2564 The current working directory is updated with all changes made in
2566 The current working directory is updated with all changes made in
2565 the requested revision since the last common predecessor revision.
2567 the requested revision since the last common predecessor revision.
2566
2568
2567 Files that changed between either parent are marked as changed for
2569 Files that changed between either parent are marked as changed for
2568 the next commit and a commit must be performed before any further
2570 the next commit and a commit must be performed before any further
2569 updates to the repository are allowed. The next commit will have
2571 updates to the repository are allowed. The next commit will have
2570 two parents.
2572 two parents.
2571
2573
2572 If no revision is specified, the working directory's parent is a
2574 If no revision is specified, the working directory's parent is a
2573 head revision, and the current branch contains exactly one other
2575 head revision, and the current branch contains exactly one other
2574 head, the other head is merged with by default. Otherwise, an
2576 head, the other head is merged with by default. Otherwise, an
2575 explicit revision with which to merge with must be provided.
2577 explicit revision with which to merge with must be provided.
2576
2578
2577 To undo an uncommitted merge, use :hg:`update --clean .` which
2579 To undo an uncommitted merge, use :hg:`update --clean .` which
2578 will check out a clean copy of the original merge parent, losing
2580 will check out a clean copy of the original merge parent, losing
2579 all changes.
2581 all changes.
2580
2582
2581 Returns 0 on success, 1 if there are unresolved files.
2583 Returns 0 on success, 1 if there are unresolved files.
2582 """
2584 """
2583
2585
2584 if opts.get('rev') and node:
2586 if opts.get('rev') and node:
2585 raise util.Abort(_("please specify just one revision"))
2587 raise util.Abort(_("please specify just one revision"))
2586 if not node:
2588 if not node:
2587 node = opts.get('rev')
2589 node = opts.get('rev')
2588
2590
2589 if not node:
2591 if not node:
2590 branch = repo.changectx(None).branch()
2592 branch = repo.changectx(None).branch()
2591 bheads = repo.branchheads(branch)
2593 bheads = repo.branchheads(branch)
2592 if len(bheads) > 2:
2594 if len(bheads) > 2:
2593 raise util.Abort(_(
2595 raise util.Abort(_(
2594 'branch \'%s\' has %d heads - '
2596 'branch \'%s\' has %d heads - '
2595 'please merge with an explicit rev\n'
2597 'please merge with an explicit rev\n'
2596 '(run \'hg heads .\' to see heads)')
2598 '(run \'hg heads .\' to see heads)')
2597 % (branch, len(bheads)))
2599 % (branch, len(bheads)))
2598
2600
2599 parent = repo.dirstate.parents()[0]
2601 parent = repo.dirstate.parents()[0]
2600 if len(bheads) == 1:
2602 if len(bheads) == 1:
2601 if len(repo.heads()) > 1:
2603 if len(repo.heads()) > 1:
2602 raise util.Abort(_(
2604 raise util.Abort(_(
2603 'branch \'%s\' has one head - '
2605 'branch \'%s\' has one head - '
2604 'please merge with an explicit rev\n'
2606 'please merge with an explicit rev\n'
2605 '(run \'hg heads\' to see all heads)')
2607 '(run \'hg heads\' to see all heads)')
2606 % branch)
2608 % branch)
2607 msg = _('there is nothing to merge')
2609 msg = _('there is nothing to merge')
2608 if parent != repo.lookup(repo[None].branch()):
2610 if parent != repo.lookup(repo[None].branch()):
2609 msg = _('%s - use "hg update" instead') % msg
2611 msg = _('%s - use "hg update" instead') % msg
2610 raise util.Abort(msg)
2612 raise util.Abort(msg)
2611
2613
2612 if parent not in bheads:
2614 if parent not in bheads:
2613 raise util.Abort(_('working dir not at a head rev - '
2615 raise util.Abort(_('working dir not at a head rev - '
2614 'use "hg update" or merge with an explicit rev'))
2616 'use "hg update" or merge with an explicit rev'))
2615 node = parent == bheads[0] and bheads[-1] or bheads[0]
2617 node = parent == bheads[0] and bheads[-1] or bheads[0]
2616
2618
2617 if opts.get('preview'):
2619 if opts.get('preview'):
2618 # find nodes that are ancestors of p2 but not of p1
2620 # find nodes that are ancestors of p2 but not of p1
2619 p1 = repo.lookup('.')
2621 p1 = repo.lookup('.')
2620 p2 = repo.lookup(node)
2622 p2 = repo.lookup(node)
2621 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
2623 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
2622
2624
2623 displayer = cmdutil.show_changeset(ui, repo, opts)
2625 displayer = cmdutil.show_changeset(ui, repo, opts)
2624 for node in nodes:
2626 for node in nodes:
2625 displayer.show(repo[node])
2627 displayer.show(repo[node])
2626 displayer.close()
2628 displayer.close()
2627 return 0
2629 return 0
2628
2630
2629 return hg.merge(repo, node, force=opts.get('force'))
2631 return hg.merge(repo, node, force=opts.get('force'))
2630
2632
2631 def outgoing(ui, repo, dest=None, **opts):
2633 def outgoing(ui, repo, dest=None, **opts):
2632 """show changesets not found in the destination
2634 """show changesets not found in the destination
2633
2635
2634 Show changesets not found in the specified destination repository
2636 Show changesets not found in the specified destination repository
2635 or the default push location. These are the changesets that would
2637 or the default push location. These are the changesets that would
2636 be pushed if a push was requested.
2638 be pushed if a push was requested.
2637
2639
2638 See pull for details of valid destination formats.
2640 See pull for details of valid destination formats.
2639
2641
2640 Returns 0 if there are outgoing changes, 1 otherwise.
2642 Returns 0 if there are outgoing changes, 1 otherwise.
2641 """
2643 """
2642 limit = cmdutil.loglimit(opts)
2644 limit = cmdutil.loglimit(opts)
2643 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2645 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2644 dest, branches = hg.parseurl(dest, opts.get('branch'))
2646 dest, branches = hg.parseurl(dest, opts.get('branch'))
2645 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2647 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2646 if revs:
2648 if revs:
2647 revs = [repo.lookup(rev) for rev in revs]
2649 revs = [repo.lookup(rev) for rev in revs]
2648
2650
2649 other = hg.repository(hg.remoteui(repo, opts), dest)
2651 other = hg.repository(hg.remoteui(repo, opts), dest)
2650 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2652 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2651 o = discovery.findoutgoing(repo, other, force=opts.get('force'))
2653 o = discovery.findoutgoing(repo, other, force=opts.get('force'))
2652 if not o:
2654 if not o:
2653 ui.status(_("no changes found\n"))
2655 ui.status(_("no changes found\n"))
2654 return 1
2656 return 1
2655 o = repo.changelog.nodesbetween(o, revs)[0]
2657 o = repo.changelog.nodesbetween(o, revs)[0]
2656 if opts.get('newest_first'):
2658 if opts.get('newest_first'):
2657 o.reverse()
2659 o.reverse()
2658 displayer = cmdutil.show_changeset(ui, repo, opts)
2660 displayer = cmdutil.show_changeset(ui, repo, opts)
2659 count = 0
2661 count = 0
2660 for n in o:
2662 for n in o:
2661 if limit is not None and count >= limit:
2663 if limit is not None and count >= limit:
2662 break
2664 break
2663 parents = [p for p in repo.changelog.parents(n) if p != nullid]
2665 parents = [p for p in repo.changelog.parents(n) if p != nullid]
2664 if opts.get('no_merges') and len(parents) == 2:
2666 if opts.get('no_merges') and len(parents) == 2:
2665 continue
2667 continue
2666 count += 1
2668 count += 1
2667 displayer.show(repo[n])
2669 displayer.show(repo[n])
2668 displayer.close()
2670 displayer.close()
2669
2671
2670 def parents(ui, repo, file_=None, **opts):
2672 def parents(ui, repo, file_=None, **opts):
2671 """show the parents of the working directory or revision
2673 """show the parents of the working directory or revision
2672
2674
2673 Print the working directory's parent revisions. If a revision is
2675 Print the working directory's parent revisions. If a revision is
2674 given via -r/--rev, the parent of that revision will be printed.
2676 given via -r/--rev, the parent of that revision will be printed.
2675 If a file argument is given, the revision in which the file was
2677 If a file argument is given, the revision in which the file was
2676 last changed (before the working directory revision or the
2678 last changed (before the working directory revision or the
2677 argument to --rev if given) is printed.
2679 argument to --rev if given) is printed.
2678
2680
2679 Returns 0 on success.
2681 Returns 0 on success.
2680 """
2682 """
2681 rev = opts.get('rev')
2683 rev = opts.get('rev')
2682 if rev:
2684 if rev:
2683 ctx = repo[rev]
2685 ctx = repo[rev]
2684 else:
2686 else:
2685 ctx = repo[None]
2687 ctx = repo[None]
2686
2688
2687 if file_:
2689 if file_:
2688 m = cmdutil.match(repo, (file_,), opts)
2690 m = cmdutil.match(repo, (file_,), opts)
2689 if m.anypats() or len(m.files()) != 1:
2691 if m.anypats() or len(m.files()) != 1:
2690 raise util.Abort(_('can only specify an explicit filename'))
2692 raise util.Abort(_('can only specify an explicit filename'))
2691 file_ = m.files()[0]
2693 file_ = m.files()[0]
2692 filenodes = []
2694 filenodes = []
2693 for cp in ctx.parents():
2695 for cp in ctx.parents():
2694 if not cp:
2696 if not cp:
2695 continue
2697 continue
2696 try:
2698 try:
2697 filenodes.append(cp.filenode(file_))
2699 filenodes.append(cp.filenode(file_))
2698 except error.LookupError:
2700 except error.LookupError:
2699 pass
2701 pass
2700 if not filenodes:
2702 if not filenodes:
2701 raise util.Abort(_("'%s' not found in manifest!") % file_)
2703 raise util.Abort(_("'%s' not found in manifest!") % file_)
2702 fl = repo.file(file_)
2704 fl = repo.file(file_)
2703 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2705 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2704 else:
2706 else:
2705 p = [cp.node() for cp in ctx.parents()]
2707 p = [cp.node() for cp in ctx.parents()]
2706
2708
2707 displayer = cmdutil.show_changeset(ui, repo, opts)
2709 displayer = cmdutil.show_changeset(ui, repo, opts)
2708 for n in p:
2710 for n in p:
2709 if n != nullid:
2711 if n != nullid:
2710 displayer.show(repo[n])
2712 displayer.show(repo[n])
2711 displayer.close()
2713 displayer.close()
2712
2714
2713 def paths(ui, repo, search=None):
2715 def paths(ui, repo, search=None):
2714 """show aliases for remote repositories
2716 """show aliases for remote repositories
2715
2717
2716 Show definition of symbolic path name NAME. If no name is given,
2718 Show definition of symbolic path name NAME. If no name is given,
2717 show definition of all available names.
2719 show definition of all available names.
2718
2720
2719 Path names are defined in the [paths] section of
2721 Path names are defined in the [paths] section of
2720 ``/etc/mercurial/hgrc`` and ``$HOME/.hgrc``. If run inside a
2722 ``/etc/mercurial/hgrc`` and ``$HOME/.hgrc``. If run inside a
2721 repository, ``.hg/hgrc`` is used, too.
2723 repository, ``.hg/hgrc`` is used, too.
2722
2724
2723 The path names ``default`` and ``default-push`` have a special
2725 The path names ``default`` and ``default-push`` have a special
2724 meaning. When performing a push or pull operation, they are used
2726 meaning. When performing a push or pull operation, they are used
2725 as fallbacks if no location is specified on the command-line.
2727 as fallbacks if no location is specified on the command-line.
2726 When ``default-push`` is set, it will be used for push and
2728 When ``default-push`` is set, it will be used for push and
2727 ``default`` will be used for pull; otherwise ``default`` is used
2729 ``default`` will be used for pull; otherwise ``default`` is used
2728 as the fallback for both. When cloning a repository, the clone
2730 as the fallback for both. When cloning a repository, the clone
2729 source is written as ``default`` in ``.hg/hgrc``. Note that
2731 source is written as ``default`` in ``.hg/hgrc``. Note that
2730 ``default`` and ``default-push`` apply to all inbound (e.g.
2732 ``default`` and ``default-push`` apply to all inbound (e.g.
2731 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
2733 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
2732 :hg:`bundle`) operations.
2734 :hg:`bundle`) operations.
2733
2735
2734 See :hg:`help urls` for more information.
2736 See :hg:`help urls` for more information.
2737
2738 Returns 0 on success.
2735 """
2739 """
2736 if search:
2740 if search:
2737 for name, path in ui.configitems("paths"):
2741 for name, path in ui.configitems("paths"):
2738 if name == search:
2742 if name == search:
2739 ui.write("%s\n" % url.hidepassword(path))
2743 ui.write("%s\n" % url.hidepassword(path))
2740 return
2744 return
2741 ui.warn(_("not found!\n"))
2745 ui.warn(_("not found!\n"))
2742 return 1
2746 return 1
2743 else:
2747 else:
2744 for name, path in ui.configitems("paths"):
2748 for name, path in ui.configitems("paths"):
2745 ui.write("%s = %s\n" % (name, url.hidepassword(path)))
2749 ui.write("%s = %s\n" % (name, url.hidepassword(path)))
2746
2750
2747 def postincoming(ui, repo, modheads, optupdate, checkout):
2751 def postincoming(ui, repo, modheads, optupdate, checkout):
2748 if modheads == 0:
2752 if modheads == 0:
2749 return
2753 return
2750 if optupdate:
2754 if optupdate:
2751 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
2755 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
2752 return hg.update(repo, checkout)
2756 return hg.update(repo, checkout)
2753 else:
2757 else:
2754 ui.status(_("not updating, since new heads added\n"))
2758 ui.status(_("not updating, since new heads added\n"))
2755 if modheads > 1:
2759 if modheads > 1:
2756 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2760 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2757 else:
2761 else:
2758 ui.status(_("(run 'hg update' to get a working copy)\n"))
2762 ui.status(_("(run 'hg update' to get a working copy)\n"))
2759
2763
2760 def pull(ui, repo, source="default", **opts):
2764 def pull(ui, repo, source="default", **opts):
2761 """pull changes from the specified source
2765 """pull changes from the specified source
2762
2766
2763 Pull changes from a remote repository to a local one.
2767 Pull changes from a remote repository to a local one.
2764
2768
2765 This finds all changes from the repository at the specified path
2769 This finds all changes from the repository at the specified path
2766 or URL and adds them to a local repository (the current one unless
2770 or URL and adds them to a local repository (the current one unless
2767 -R is specified). By default, this does not update the copy of the
2771 -R is specified). By default, this does not update the copy of the
2768 project in the working directory.
2772 project in the working directory.
2769
2773
2770 Use :hg:`incoming` if you want to see what would have been added
2774 Use :hg:`incoming` if you want to see what would have been added
2771 by a pull at the time you issued this command. If you then decide
2775 by a pull at the time you issued this command. If you then decide
2772 to add those changes to the repository, you should use :hg:`pull
2776 to add those changes to the repository, you should use :hg:`pull
2773 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
2777 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
2774
2778
2775 If SOURCE is omitted, the 'default' path will be used.
2779 If SOURCE is omitted, the 'default' path will be used.
2776 See :hg:`help urls` for more information.
2780 See :hg:`help urls` for more information.
2777
2781
2778 Returns 0 on success, 1 if an update had unresolved files.
2782 Returns 0 on success, 1 if an update had unresolved files.
2779 """
2783 """
2780 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2784 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2781 other = hg.repository(hg.remoteui(repo, opts), source)
2785 other = hg.repository(hg.remoteui(repo, opts), source)
2782 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2786 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2783 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2787 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2784 if revs:
2788 if revs:
2785 try:
2789 try:
2786 revs = [other.lookup(rev) for rev in revs]
2790 revs = [other.lookup(rev) for rev in revs]
2787 except error.CapabilityError:
2791 except error.CapabilityError:
2788 err = _("Other repository doesn't support revision lookup, "
2792 err = _("Other repository doesn't support revision lookup, "
2789 "so a rev cannot be specified.")
2793 "so a rev cannot be specified.")
2790 raise util.Abort(err)
2794 raise util.Abort(err)
2791
2795
2792 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
2796 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
2793 if checkout:
2797 if checkout:
2794 checkout = str(repo.changelog.rev(other.lookup(checkout)))
2798 checkout = str(repo.changelog.rev(other.lookup(checkout)))
2795 return postincoming(ui, repo, modheads, opts.get('update'), checkout)
2799 return postincoming(ui, repo, modheads, opts.get('update'), checkout)
2796
2800
2797 def push(ui, repo, dest=None, **opts):
2801 def push(ui, repo, dest=None, **opts):
2798 """push changes to the specified destination
2802 """push changes to the specified destination
2799
2803
2800 Push changesets from the local repository to the specified
2804 Push changesets from the local repository to the specified
2801 destination.
2805 destination.
2802
2806
2803 This operation is symmetrical to pull: it is identical to a pull
2807 This operation is symmetrical to pull: it is identical to a pull
2804 in the destination repository from the current one.
2808 in the destination repository from the current one.
2805
2809
2806 By default, push will not allow creation of new heads at the
2810 By default, push will not allow creation of new heads at the
2807 destination, since multiple heads would make it unclear which head
2811 destination, since multiple heads would make it unclear which head
2808 to use. In this situation, it is recommended to pull and merge
2812 to use. In this situation, it is recommended to pull and merge
2809 before pushing.
2813 before pushing.
2810
2814
2811 Use --new-branch if you want to allow push to create a new named
2815 Use --new-branch if you want to allow push to create a new named
2812 branch that is not present at the destination. This allows you to
2816 branch that is not present at the destination. This allows you to
2813 only create a new branch without forcing other changes.
2817 only create a new branch without forcing other changes.
2814
2818
2815 Use -f/--force to override the default behavior and push all
2819 Use -f/--force to override the default behavior and push all
2816 changesets on all branches.
2820 changesets on all branches.
2817
2821
2818 If -r/--rev is used, the specified revision and all its ancestors
2822 If -r/--rev is used, the specified revision and all its ancestors
2819 will be pushed to the remote repository.
2823 will be pushed to the remote repository.
2820
2824
2821 Please see :hg:`help urls` for important details about ``ssh://``
2825 Please see :hg:`help urls` for important details about ``ssh://``
2822 URLs. If DESTINATION is omitted, a default path will be used.
2826 URLs. If DESTINATION is omitted, a default path will be used.
2823
2827
2824 Returns 0 if push was successful, 1 if nothing to push.
2828 Returns 0 if push was successful, 1 if nothing to push.
2825 """
2829 """
2826 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2830 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2827 dest, branches = hg.parseurl(dest, opts.get('branch'))
2831 dest, branches = hg.parseurl(dest, opts.get('branch'))
2828 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2832 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2829 other = hg.repository(hg.remoteui(repo, opts), dest)
2833 other = hg.repository(hg.remoteui(repo, opts), dest)
2830 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2834 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2831 if revs:
2835 if revs:
2832 revs = [repo.lookup(rev) for rev in revs]
2836 revs = [repo.lookup(rev) for rev in revs]
2833
2837
2834 # push subrepos depth-first for coherent ordering
2838 # push subrepos depth-first for coherent ordering
2835 c = repo['']
2839 c = repo['']
2836 subs = c.substate # only repos that are committed
2840 subs = c.substate # only repos that are committed
2837 for s in sorted(subs):
2841 for s in sorted(subs):
2838 if not c.sub(s).push(opts.get('force')):
2842 if not c.sub(s).push(opts.get('force')):
2839 return False
2843 return False
2840
2844
2841 r = repo.push(other, opts.get('force'), revs=revs,
2845 r = repo.push(other, opts.get('force'), revs=revs,
2842 newbranch=opts.get('new_branch'))
2846 newbranch=opts.get('new_branch'))
2843 return r == 0
2847 return r == 0
2844
2848
2845 def recover(ui, repo):
2849 def recover(ui, repo):
2846 """roll back an interrupted transaction
2850 """roll back an interrupted transaction
2847
2851
2848 Recover from an interrupted commit or pull.
2852 Recover from an interrupted commit or pull.
2849
2853
2850 This command tries to fix the repository status after an
2854 This command tries to fix the repository status after an
2851 interrupted operation. It should only be necessary when Mercurial
2855 interrupted operation. It should only be necessary when Mercurial
2852 suggests it.
2856 suggests it.
2853
2857
2854 Returns 0 if successful, 1 if nothing to recover or verify fails.
2858 Returns 0 if successful, 1 if nothing to recover or verify fails.
2855 """
2859 """
2856 if repo.recover():
2860 if repo.recover():
2857 return hg.verify(repo)
2861 return hg.verify(repo)
2858 return 1
2862 return 1
2859
2863
2860 def remove(ui, repo, *pats, **opts):
2864 def remove(ui, repo, *pats, **opts):
2861 """remove the specified files on the next commit
2865 """remove the specified files on the next commit
2862
2866
2863 Schedule the indicated files for removal from the repository.
2867 Schedule the indicated files for removal from the repository.
2864
2868
2865 This only removes files from the current branch, not from the
2869 This only removes files from the current branch, not from the
2866 entire project history. -A/--after can be used to remove only
2870 entire project history. -A/--after can be used to remove only
2867 files that have already been deleted, -f/--force can be used to
2871 files that have already been deleted, -f/--force can be used to
2868 force deletion, and -Af can be used to remove files from the next
2872 force deletion, and -Af can be used to remove files from the next
2869 revision without deleting them from the working directory.
2873 revision without deleting them from the working directory.
2870
2874
2871 The following table details the behavior of remove for different
2875 The following table details the behavior of remove for different
2872 file states (columns) and option combinations (rows). The file
2876 file states (columns) and option combinations (rows). The file
2873 states are Added [A], Clean [C], Modified [M] and Missing [!] (as
2877 states are Added [A], Clean [C], Modified [M] and Missing [!] (as
2874 reported by :hg:`status`). The actions are Warn, Remove (from
2878 reported by :hg:`status`). The actions are Warn, Remove (from
2875 branch) and Delete (from disk)::
2879 branch) and Delete (from disk)::
2876
2880
2877 A C M !
2881 A C M !
2878 none W RD W R
2882 none W RD W R
2879 -f R RD RD R
2883 -f R RD RD R
2880 -A W W W R
2884 -A W W W R
2881 -Af R R R R
2885 -Af R R R R
2882
2886
2883 This command schedules the files to be removed at the next commit.
2887 This command schedules the files to be removed at the next commit.
2884 To undo a remove before that, see :hg:`revert`.
2888 To undo a remove before that, see :hg:`revert`.
2885
2889
2886 Returns 0 on success, 1 if any warnings encountered.
2890 Returns 0 on success, 1 if any warnings encountered.
2887 """
2891 """
2888
2892
2889 ret = 0
2893 ret = 0
2890 after, force = opts.get('after'), opts.get('force')
2894 after, force = opts.get('after'), opts.get('force')
2891 if not pats and not after:
2895 if not pats and not after:
2892 raise util.Abort(_('no files specified'))
2896 raise util.Abort(_('no files specified'))
2893
2897
2894 m = cmdutil.match(repo, pats, opts)
2898 m = cmdutil.match(repo, pats, opts)
2895 s = repo.status(match=m, clean=True)
2899 s = repo.status(match=m, clean=True)
2896 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2900 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2897
2901
2898 for f in m.files():
2902 for f in m.files():
2899 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
2903 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
2900 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
2904 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
2901 ret = 1
2905 ret = 1
2902
2906
2903 def warn(files, reason):
2907 def warn(files, reason):
2904 for f in files:
2908 for f in files:
2905 ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
2909 ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
2906 % (m.rel(f), reason))
2910 % (m.rel(f), reason))
2907 ret = 1
2911 ret = 1
2908
2912
2909 if force:
2913 if force:
2910 remove, forget = modified + deleted + clean, added
2914 remove, forget = modified + deleted + clean, added
2911 elif after:
2915 elif after:
2912 remove, forget = deleted, []
2916 remove, forget = deleted, []
2913 warn(modified + added + clean, _('still exists'))
2917 warn(modified + added + clean, _('still exists'))
2914 else:
2918 else:
2915 remove, forget = deleted + clean, []
2919 remove, forget = deleted + clean, []
2916 warn(modified, _('is modified'))
2920 warn(modified, _('is modified'))
2917 warn(added, _('has been marked for add'))
2921 warn(added, _('has been marked for add'))
2918
2922
2919 for f in sorted(remove + forget):
2923 for f in sorted(remove + forget):
2920 if ui.verbose or not m.exact(f):
2924 if ui.verbose or not m.exact(f):
2921 ui.status(_('removing %s\n') % m.rel(f))
2925 ui.status(_('removing %s\n') % m.rel(f))
2922
2926
2923 repo[None].forget(forget)
2927 repo[None].forget(forget)
2924 repo[None].remove(remove, unlink=not after)
2928 repo[None].remove(remove, unlink=not after)
2925 return ret
2929 return ret
2926
2930
2927 def rename(ui, repo, *pats, **opts):
2931 def rename(ui, repo, *pats, **opts):
2928 """rename files; equivalent of copy + remove
2932 """rename files; equivalent of copy + remove
2929
2933
2930 Mark dest as copies of sources; mark sources for deletion. If dest
2934 Mark dest as copies of sources; mark sources for deletion. If dest
2931 is a directory, copies are put in that directory. If dest is a
2935 is a directory, copies are put in that directory. If dest is a
2932 file, there can only be one source.
2936 file, there can only be one source.
2933
2937
2934 By default, this command copies the contents of files as they
2938 By default, this command copies the contents of files as they
2935 exist in the working directory. If invoked with -A/--after, the
2939 exist in the working directory. If invoked with -A/--after, the
2936 operation is recorded, but no copying is performed.
2940 operation is recorded, but no copying is performed.
2937
2941
2938 This command takes effect at the next commit. To undo a rename
2942 This command takes effect at the next commit. To undo a rename
2939 before that, see :hg:`revert`.
2943 before that, see :hg:`revert`.
2940
2944
2941 Returns 0 on success, 1 if errors are encountered.
2945 Returns 0 on success, 1 if errors are encountered.
2942 """
2946 """
2943 wlock = repo.wlock(False)
2947 wlock = repo.wlock(False)
2944 try:
2948 try:
2945 return cmdutil.copy(ui, repo, pats, opts, rename=True)
2949 return cmdutil.copy(ui, repo, pats, opts, rename=True)
2946 finally:
2950 finally:
2947 wlock.release()
2951 wlock.release()
2948
2952
2949 def resolve(ui, repo, *pats, **opts):
2953 def resolve(ui, repo, *pats, **opts):
2950 """various operations to help finish a merge
2954 """various operations to help finish a merge
2951
2955
2952 This command includes several actions that are often useful while
2956 This command includes several actions that are often useful while
2953 performing a merge, after running ``merge`` but before running
2957 performing a merge, after running ``merge`` but before running
2954 ``commit``. (It is only meaningful if your working directory has
2958 ``commit``. (It is only meaningful if your working directory has
2955 two parents.) It is most relevant for merges with unresolved
2959 two parents.) It is most relevant for merges with unresolved
2956 conflicts, which are typically a result of non-interactive merging with
2960 conflicts, which are typically a result of non-interactive merging with
2957 ``internal:merge`` or a command-line merge tool like ``diff3``.
2961 ``internal:merge`` or a command-line merge tool like ``diff3``.
2958
2962
2959 The available actions are:
2963 The available actions are:
2960
2964
2961 1) list files that were merged with conflicts (U, for unresolved)
2965 1) list files that were merged with conflicts (U, for unresolved)
2962 and without conflicts (R, for resolved): ``hg resolve -l``
2966 and without conflicts (R, for resolved): ``hg resolve -l``
2963 (this is like ``status`` for merges)
2967 (this is like ``status`` for merges)
2964 2) record that you have resolved conflicts in certain files:
2968 2) record that you have resolved conflicts in certain files:
2965 ``hg resolve -m [file ...]`` (default: mark all unresolved files)
2969 ``hg resolve -m [file ...]`` (default: mark all unresolved files)
2966 3) forget that you have resolved conflicts in certain files:
2970 3) forget that you have resolved conflicts in certain files:
2967 ``hg resolve -u [file ...]`` (default: unmark all resolved files)
2971 ``hg resolve -u [file ...]`` (default: unmark all resolved files)
2968 4) discard your current attempt(s) at resolving conflicts and
2972 4) discard your current attempt(s) at resolving conflicts and
2969 restart the merge from scratch: ``hg resolve file...``
2973 restart the merge from scratch: ``hg resolve file...``
2970 (or ``-a`` for all unresolved files)
2974 (or ``-a`` for all unresolved files)
2971
2975
2972 Note that Mercurial will not let you commit files with unresolved merge
2976 Note that Mercurial will not let you commit files with unresolved merge
2973 conflicts. You must use ``hg resolve -m ...`` before you can commit
2977 conflicts. You must use ``hg resolve -m ...`` before you can commit
2974 after a conflicting merge.
2978 after a conflicting merge.
2975
2979
2976 Returns 0 on success, 1 if any files fail a resolve attempt.
2980 Returns 0 on success, 1 if any files fail a resolve attempt.
2977 """
2981 """
2978
2982
2979 all, mark, unmark, show, nostatus = \
2983 all, mark, unmark, show, nostatus = \
2980 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
2984 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
2981
2985
2982 if (show and (mark or unmark)) or (mark and unmark):
2986 if (show and (mark or unmark)) or (mark and unmark):
2983 raise util.Abort(_("too many options specified"))
2987 raise util.Abort(_("too many options specified"))
2984 if pats and all:
2988 if pats and all:
2985 raise util.Abort(_("can't specify --all and patterns"))
2989 raise util.Abort(_("can't specify --all and patterns"))
2986 if not (all or pats or show or mark or unmark):
2990 if not (all or pats or show or mark or unmark):
2987 raise util.Abort(_('no files or directories specified; '
2991 raise util.Abort(_('no files or directories specified; '
2988 'use --all to remerge all files'))
2992 'use --all to remerge all files'))
2989
2993
2990 ms = mergemod.mergestate(repo)
2994 ms = mergemod.mergestate(repo)
2991 m = cmdutil.match(repo, pats, opts)
2995 m = cmdutil.match(repo, pats, opts)
2992 ret = 0
2996 ret = 0
2993
2997
2994 for f in ms:
2998 for f in ms:
2995 if m(f):
2999 if m(f):
2996 if show:
3000 if show:
2997 if nostatus:
3001 if nostatus:
2998 ui.write("%s\n" % f)
3002 ui.write("%s\n" % f)
2999 else:
3003 else:
3000 ui.write("%s %s\n" % (ms[f].upper(), f),
3004 ui.write("%s %s\n" % (ms[f].upper(), f),
3001 label='resolve.' +
3005 label='resolve.' +
3002 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
3006 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
3003 elif mark:
3007 elif mark:
3004 ms.mark(f, "r")
3008 ms.mark(f, "r")
3005 elif unmark:
3009 elif unmark:
3006 ms.mark(f, "u")
3010 ms.mark(f, "u")
3007 else:
3011 else:
3008 wctx = repo[None]
3012 wctx = repo[None]
3009 mctx = wctx.parents()[-1]
3013 mctx = wctx.parents()[-1]
3010
3014
3011 # backup pre-resolve (merge uses .orig for its own purposes)
3015 # backup pre-resolve (merge uses .orig for its own purposes)
3012 a = repo.wjoin(f)
3016 a = repo.wjoin(f)
3013 util.copyfile(a, a + ".resolve")
3017 util.copyfile(a, a + ".resolve")
3014
3018
3015 # resolve file
3019 # resolve file
3016 if ms.resolve(f, wctx, mctx):
3020 if ms.resolve(f, wctx, mctx):
3017 ret = 1
3021 ret = 1
3018
3022
3019 # replace filemerge's .orig file with our resolve file
3023 # replace filemerge's .orig file with our resolve file
3020 util.rename(a + ".resolve", a + ".orig")
3024 util.rename(a + ".resolve", a + ".orig")
3021 return ret
3025 return ret
3022
3026
3023 def revert(ui, repo, *pats, **opts):
3027 def revert(ui, repo, *pats, **opts):
3024 """restore individual files or directories to an earlier state
3028 """restore individual files or directories to an earlier state
3025
3029
3026 NOTE: This command is most likely not what you are looking for. revert
3030 NOTE: This command is most likely not what you are looking for. revert
3027 will partially overwrite content in the working directory without changing
3031 will partially overwrite content in the working directory without changing
3028 the working directory parents. Use :hg:`update -r rev` to check out earlier
3032 the working directory parents. Use :hg:`update -r rev` to check out earlier
3029 revisions, or :hg:`update --clean .` to undo a merge which has added
3033 revisions, or :hg:`update --clean .` to undo a merge which has added
3030 another parent.
3034 another parent.
3031
3035
3032 With no revision specified, revert the named files or directories
3036 With no revision specified, revert the named files or directories
3033 to the contents they had in the parent of the working directory.
3037 to the contents they had in the parent of the working directory.
3034 This restores the contents of the affected files to an unmodified
3038 This restores the contents of the affected files to an unmodified
3035 state and unschedules adds, removes, copies, and renames. If the
3039 state and unschedules adds, removes, copies, and renames. If the
3036 working directory has two parents, you must explicitly specify a
3040 working directory has two parents, you must explicitly specify a
3037 revision.
3041 revision.
3038
3042
3039 Using the -r/--rev option, revert the given files or directories
3043 Using the -r/--rev option, revert the given files or directories
3040 to their contents as of a specific revision. This can be helpful
3044 to their contents as of a specific revision. This can be helpful
3041 to "roll back" some or all of an earlier change. See :hg:`help
3045 to "roll back" some or all of an earlier change. See :hg:`help
3042 dates` for a list of formats valid for -d/--date.
3046 dates` for a list of formats valid for -d/--date.
3043
3047
3044 Revert modifies the working directory. It does not commit any
3048 Revert modifies the working directory. It does not commit any
3045 changes, or change the parent of the working directory. If you
3049 changes, or change the parent of the working directory. If you
3046 revert to a revision other than the parent of the working
3050 revert to a revision other than the parent of the working
3047 directory, the reverted files will thus appear modified
3051 directory, the reverted files will thus appear modified
3048 afterwards.
3052 afterwards.
3049
3053
3050 If a file has been deleted, it is restored. If the executable mode
3054 If a file has been deleted, it is restored. If the executable mode
3051 of a file was changed, it is reset.
3055 of a file was changed, it is reset.
3052
3056
3053 If names are given, all files matching the names are reverted.
3057 If names are given, all files matching the names are reverted.
3054 If no arguments are given, no files are reverted.
3058 If no arguments are given, no files are reverted.
3055
3059
3056 Modified files are saved with a .orig suffix before reverting.
3060 Modified files are saved with a .orig suffix before reverting.
3057 To disable these backups, use --no-backup.
3061 To disable these backups, use --no-backup.
3058
3062
3059 Returns 0 on success.
3063 Returns 0 on success.
3060 """
3064 """
3061
3065
3062 if opts["date"]:
3066 if opts["date"]:
3063 if opts["rev"]:
3067 if opts["rev"]:
3064 raise util.Abort(_("you can't specify a revision and a date"))
3068 raise util.Abort(_("you can't specify a revision and a date"))
3065 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
3069 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
3066
3070
3067 if not pats and not opts.get('all'):
3071 if not pats and not opts.get('all'):
3068 raise util.Abort(_('no files or directories specified; '
3072 raise util.Abort(_('no files or directories specified; '
3069 'use --all to revert the whole repo'))
3073 'use --all to revert the whole repo'))
3070
3074
3071 parent, p2 = repo.dirstate.parents()
3075 parent, p2 = repo.dirstate.parents()
3072 if not opts.get('rev') and p2 != nullid:
3076 if not opts.get('rev') and p2 != nullid:
3073 raise util.Abort(_('uncommitted merge - please provide a '
3077 raise util.Abort(_('uncommitted merge - please provide a '
3074 'specific revision'))
3078 'specific revision'))
3075 ctx = repo[opts.get('rev')]
3079 ctx = repo[opts.get('rev')]
3076 node = ctx.node()
3080 node = ctx.node()
3077 mf = ctx.manifest()
3081 mf = ctx.manifest()
3078 if node == parent:
3082 if node == parent:
3079 pmf = mf
3083 pmf = mf
3080 else:
3084 else:
3081 pmf = None
3085 pmf = None
3082
3086
3083 # need all matching names in dirstate and manifest of target rev,
3087 # need all matching names in dirstate and manifest of target rev,
3084 # so have to walk both. do not print errors if files exist in one
3088 # so have to walk both. do not print errors if files exist in one
3085 # but not other.
3089 # but not other.
3086
3090
3087 names = {}
3091 names = {}
3088
3092
3089 wlock = repo.wlock()
3093 wlock = repo.wlock()
3090 try:
3094 try:
3091 # walk dirstate.
3095 # walk dirstate.
3092
3096
3093 m = cmdutil.match(repo, pats, opts)
3097 m = cmdutil.match(repo, pats, opts)
3094 m.bad = lambda x, y: False
3098 m.bad = lambda x, y: False
3095 for abs in repo.walk(m):
3099 for abs in repo.walk(m):
3096 names[abs] = m.rel(abs), m.exact(abs)
3100 names[abs] = m.rel(abs), m.exact(abs)
3097
3101
3098 # walk target manifest.
3102 # walk target manifest.
3099
3103
3100 def badfn(path, msg):
3104 def badfn(path, msg):
3101 if path in names:
3105 if path in names:
3102 return
3106 return
3103 path_ = path + '/'
3107 path_ = path + '/'
3104 for f in names:
3108 for f in names:
3105 if f.startswith(path_):
3109 if f.startswith(path_):
3106 return
3110 return
3107 ui.warn("%s: %s\n" % (m.rel(path), msg))
3111 ui.warn("%s: %s\n" % (m.rel(path), msg))
3108
3112
3109 m = cmdutil.match(repo, pats, opts)
3113 m = cmdutil.match(repo, pats, opts)
3110 m.bad = badfn
3114 m.bad = badfn
3111 for abs in repo[node].walk(m):
3115 for abs in repo[node].walk(m):
3112 if abs not in names:
3116 if abs not in names:
3113 names[abs] = m.rel(abs), m.exact(abs)
3117 names[abs] = m.rel(abs), m.exact(abs)
3114
3118
3115 m = cmdutil.matchfiles(repo, names)
3119 m = cmdutil.matchfiles(repo, names)
3116 changes = repo.status(match=m)[:4]
3120 changes = repo.status(match=m)[:4]
3117 modified, added, removed, deleted = map(set, changes)
3121 modified, added, removed, deleted = map(set, changes)
3118
3122
3119 # if f is a rename, also revert the source
3123 # if f is a rename, also revert the source
3120 cwd = repo.getcwd()
3124 cwd = repo.getcwd()
3121 for f in added:
3125 for f in added:
3122 src = repo.dirstate.copied(f)
3126 src = repo.dirstate.copied(f)
3123 if src and src not in names and repo.dirstate[src] == 'r':
3127 if src and src not in names and repo.dirstate[src] == 'r':
3124 removed.add(src)
3128 removed.add(src)
3125 names[src] = (repo.pathto(src, cwd), True)
3129 names[src] = (repo.pathto(src, cwd), True)
3126
3130
3127 def removeforget(abs):
3131 def removeforget(abs):
3128 if repo.dirstate[abs] == 'a':
3132 if repo.dirstate[abs] == 'a':
3129 return _('forgetting %s\n')
3133 return _('forgetting %s\n')
3130 return _('removing %s\n')
3134 return _('removing %s\n')
3131
3135
3132 revert = ([], _('reverting %s\n'))
3136 revert = ([], _('reverting %s\n'))
3133 add = ([], _('adding %s\n'))
3137 add = ([], _('adding %s\n'))
3134 remove = ([], removeforget)
3138 remove = ([], removeforget)
3135 undelete = ([], _('undeleting %s\n'))
3139 undelete = ([], _('undeleting %s\n'))
3136
3140
3137 disptable = (
3141 disptable = (
3138 # dispatch table:
3142 # dispatch table:
3139 # file state
3143 # file state
3140 # action if in target manifest
3144 # action if in target manifest
3141 # action if not in target manifest
3145 # action if not in target manifest
3142 # make backup if in target manifest
3146 # make backup if in target manifest
3143 # make backup if not in target manifest
3147 # make backup if not in target manifest
3144 (modified, revert, remove, True, True),
3148 (modified, revert, remove, True, True),
3145 (added, revert, remove, True, False),
3149 (added, revert, remove, True, False),
3146 (removed, undelete, None, False, False),
3150 (removed, undelete, None, False, False),
3147 (deleted, revert, remove, False, False),
3151 (deleted, revert, remove, False, False),
3148 )
3152 )
3149
3153
3150 for abs, (rel, exact) in sorted(names.items()):
3154 for abs, (rel, exact) in sorted(names.items()):
3151 mfentry = mf.get(abs)
3155 mfentry = mf.get(abs)
3152 target = repo.wjoin(abs)
3156 target = repo.wjoin(abs)
3153 def handle(xlist, dobackup):
3157 def handle(xlist, dobackup):
3154 xlist[0].append(abs)
3158 xlist[0].append(abs)
3155 if dobackup and not opts.get('no_backup') and util.lexists(target):
3159 if dobackup and not opts.get('no_backup') and util.lexists(target):
3156 bakname = "%s.orig" % rel
3160 bakname = "%s.orig" % rel
3157 ui.note(_('saving current version of %s as %s\n') %
3161 ui.note(_('saving current version of %s as %s\n') %
3158 (rel, bakname))
3162 (rel, bakname))
3159 if not opts.get('dry_run'):
3163 if not opts.get('dry_run'):
3160 util.copyfile(target, bakname)
3164 util.copyfile(target, bakname)
3161 if ui.verbose or not exact:
3165 if ui.verbose or not exact:
3162 msg = xlist[1]
3166 msg = xlist[1]
3163 if not isinstance(msg, basestring):
3167 if not isinstance(msg, basestring):
3164 msg = msg(abs)
3168 msg = msg(abs)
3165 ui.status(msg % rel)
3169 ui.status(msg % rel)
3166 for table, hitlist, misslist, backuphit, backupmiss in disptable:
3170 for table, hitlist, misslist, backuphit, backupmiss in disptable:
3167 if abs not in table:
3171 if abs not in table:
3168 continue
3172 continue
3169 # file has changed in dirstate
3173 # file has changed in dirstate
3170 if mfentry:
3174 if mfentry:
3171 handle(hitlist, backuphit)
3175 handle(hitlist, backuphit)
3172 elif misslist is not None:
3176 elif misslist is not None:
3173 handle(misslist, backupmiss)
3177 handle(misslist, backupmiss)
3174 break
3178 break
3175 else:
3179 else:
3176 if abs not in repo.dirstate:
3180 if abs not in repo.dirstate:
3177 if mfentry:
3181 if mfentry:
3178 handle(add, True)
3182 handle(add, True)
3179 elif exact:
3183 elif exact:
3180 ui.warn(_('file not managed: %s\n') % rel)
3184 ui.warn(_('file not managed: %s\n') % rel)
3181 continue
3185 continue
3182 # file has not changed in dirstate
3186 # file has not changed in dirstate
3183 if node == parent:
3187 if node == parent:
3184 if exact:
3188 if exact:
3185 ui.warn(_('no changes needed to %s\n') % rel)
3189 ui.warn(_('no changes needed to %s\n') % rel)
3186 continue
3190 continue
3187 if pmf is None:
3191 if pmf is None:
3188 # only need parent manifest in this unlikely case,
3192 # only need parent manifest in this unlikely case,
3189 # so do not read by default
3193 # so do not read by default
3190 pmf = repo[parent].manifest()
3194 pmf = repo[parent].manifest()
3191 if abs in pmf:
3195 if abs in pmf:
3192 if mfentry:
3196 if mfentry:
3193 # if version of file is same in parent and target
3197 # if version of file is same in parent and target
3194 # manifests, do nothing
3198 # manifests, do nothing
3195 if (pmf[abs] != mfentry or
3199 if (pmf[abs] != mfentry or
3196 pmf.flags(abs) != mf.flags(abs)):
3200 pmf.flags(abs) != mf.flags(abs)):
3197 handle(revert, False)
3201 handle(revert, False)
3198 else:
3202 else:
3199 handle(remove, False)
3203 handle(remove, False)
3200
3204
3201 if not opts.get('dry_run'):
3205 if not opts.get('dry_run'):
3202 def checkout(f):
3206 def checkout(f):
3203 fc = ctx[f]
3207 fc = ctx[f]
3204 repo.wwrite(f, fc.data(), fc.flags())
3208 repo.wwrite(f, fc.data(), fc.flags())
3205
3209
3206 audit_path = util.path_auditor(repo.root)
3210 audit_path = util.path_auditor(repo.root)
3207 for f in remove[0]:
3211 for f in remove[0]:
3208 if repo.dirstate[f] == 'a':
3212 if repo.dirstate[f] == 'a':
3209 repo.dirstate.forget(f)
3213 repo.dirstate.forget(f)
3210 continue
3214 continue
3211 audit_path(f)
3215 audit_path(f)
3212 try:
3216 try:
3213 util.unlink(repo.wjoin(f))
3217 util.unlink(repo.wjoin(f))
3214 except OSError:
3218 except OSError:
3215 pass
3219 pass
3216 repo.dirstate.remove(f)
3220 repo.dirstate.remove(f)
3217
3221
3218 normal = None
3222 normal = None
3219 if node == parent:
3223 if node == parent:
3220 # We're reverting to our parent. If possible, we'd like status
3224 # We're reverting to our parent. If possible, we'd like status
3221 # to report the file as clean. We have to use normallookup for
3225 # to report the file as clean. We have to use normallookup for
3222 # merges to avoid losing information about merged/dirty files.
3226 # merges to avoid losing information about merged/dirty files.
3223 if p2 != nullid:
3227 if p2 != nullid:
3224 normal = repo.dirstate.normallookup
3228 normal = repo.dirstate.normallookup
3225 else:
3229 else:
3226 normal = repo.dirstate.normal
3230 normal = repo.dirstate.normal
3227 for f in revert[0]:
3231 for f in revert[0]:
3228 checkout(f)
3232 checkout(f)
3229 if normal:
3233 if normal:
3230 normal(f)
3234 normal(f)
3231
3235
3232 for f in add[0]:
3236 for f in add[0]:
3233 checkout(f)
3237 checkout(f)
3234 repo.dirstate.add(f)
3238 repo.dirstate.add(f)
3235
3239
3236 normal = repo.dirstate.normallookup
3240 normal = repo.dirstate.normallookup
3237 if node == parent and p2 == nullid:
3241 if node == parent and p2 == nullid:
3238 normal = repo.dirstate.normal
3242 normal = repo.dirstate.normal
3239 for f in undelete[0]:
3243 for f in undelete[0]:
3240 checkout(f)
3244 checkout(f)
3241 normal(f)
3245 normal(f)
3242
3246
3243 finally:
3247 finally:
3244 wlock.release()
3248 wlock.release()
3245
3249
3246 def rollback(ui, repo, **opts):
3250 def rollback(ui, repo, **opts):
3247 """roll back the last transaction (dangerous)
3251 """roll back the last transaction (dangerous)
3248
3252
3249 This command should be used with care. There is only one level of
3253 This command should be used with care. There is only one level of
3250 rollback, and there is no way to undo a rollback. It will also
3254 rollback, and there is no way to undo a rollback. It will also
3251 restore the dirstate at the time of the last transaction, losing
3255 restore the dirstate at the time of the last transaction, losing
3252 any dirstate changes since that time. This command does not alter
3256 any dirstate changes since that time. This command does not alter
3253 the working directory.
3257 the working directory.
3254
3258
3255 Transactions are used to encapsulate the effects of all commands
3259 Transactions are used to encapsulate the effects of all commands
3256 that create new changesets or propagate existing changesets into a
3260 that create new changesets or propagate existing changesets into a
3257 repository. For example, the following commands are transactional,
3261 repository. For example, the following commands are transactional,
3258 and their effects can be rolled back:
3262 and their effects can be rolled back:
3259
3263
3260 - commit
3264 - commit
3261 - import
3265 - import
3262 - pull
3266 - pull
3263 - push (with this repository as the destination)
3267 - push (with this repository as the destination)
3264 - unbundle
3268 - unbundle
3265
3269
3266 This command is not intended for use on public repositories. Once
3270 This command is not intended for use on public repositories. Once
3267 changes are visible for pull by other users, rolling a transaction
3271 changes are visible for pull by other users, rolling a transaction
3268 back locally is ineffective (someone else may already have pulled
3272 back locally is ineffective (someone else may already have pulled
3269 the changes). Furthermore, a race is possible with readers of the
3273 the changes). Furthermore, a race is possible with readers of the
3270 repository; for example an in-progress pull from the repository
3274 repository; for example an in-progress pull from the repository
3271 may fail if a rollback is performed.
3275 may fail if a rollback is performed.
3272
3276
3273 Returns 0 on success, 1 if no rollback data is available.
3277 Returns 0 on success, 1 if no rollback data is available.
3274 """
3278 """
3275 return repo.rollback(opts.get('dry_run'))
3279 return repo.rollback(opts.get('dry_run'))
3276
3280
3277 def root(ui, repo):
3281 def root(ui, repo):
3278 """print the root (top) of the current working directory
3282 """print the root (top) of the current working directory
3279
3283
3280 Print the root directory of the current repository.
3284 Print the root directory of the current repository.
3281
3285
3282 Returns 0 on success.
3286 Returns 0 on success.
3283 """
3287 """
3284 ui.write(repo.root + "\n")
3288 ui.write(repo.root + "\n")
3285
3289
3286 def serve(ui, repo, **opts):
3290 def serve(ui, repo, **opts):
3287 """start stand-alone webserver
3291 """start stand-alone webserver
3288
3292
3289 Start a local HTTP repository browser and pull server. You can use
3293 Start a local HTTP repository browser and pull server. You can use
3290 this for ad-hoc sharing and browing of repositories. It is
3294 this for ad-hoc sharing and browing of repositories. It is
3291 recommended to use a real web server to serve a repository for
3295 recommended to use a real web server to serve a repository for
3292 longer periods of time.
3296 longer periods of time.
3293
3297
3294 Please note that the server does not implement access control.
3298 Please note that the server does not implement access control.
3295 This means that, by default, anybody can read from the server and
3299 This means that, by default, anybody can read from the server and
3296 nobody can write to it by default. Set the ``web.allow_push``
3300 nobody can write to it by default. Set the ``web.allow_push``
3297 option to ``*`` to allow everybody to push to the server. You
3301 option to ``*`` to allow everybody to push to the server. You
3298 should use a real web server if you need to authenticate users.
3302 should use a real web server if you need to authenticate users.
3299
3303
3300 By default, the server logs accesses to stdout and errors to
3304 By default, the server logs accesses to stdout and errors to
3301 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
3305 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
3302 files.
3306 files.
3303
3307
3304 To have the server choose a free port number to listen on, specify
3308 To have the server choose a free port number to listen on, specify
3305 a port number of 0; in this case, the server will print the port
3309 a port number of 0; in this case, the server will print the port
3306 number it uses.
3310 number it uses.
3307
3311
3308 Returns 0 on success.
3312 Returns 0 on success.
3309 """
3313 """
3310
3314
3311 if opts["stdio"]:
3315 if opts["stdio"]:
3312 if repo is None:
3316 if repo is None:
3313 raise error.RepoError(_("There is no Mercurial repository here"
3317 raise error.RepoError(_("There is no Mercurial repository here"
3314 " (.hg not found)"))
3318 " (.hg not found)"))
3315 s = sshserver.sshserver(ui, repo)
3319 s = sshserver.sshserver(ui, repo)
3316 s.serve_forever()
3320 s.serve_forever()
3317
3321
3318 # this way we can check if something was given in the command-line
3322 # this way we can check if something was given in the command-line
3319 if opts.get('port'):
3323 if opts.get('port'):
3320 opts['port'] = int(opts.get('port'))
3324 opts['port'] = int(opts.get('port'))
3321
3325
3322 baseui = repo and repo.baseui or ui
3326 baseui = repo and repo.baseui or ui
3323 optlist = ("name templates style address port prefix ipv6"
3327 optlist = ("name templates style address port prefix ipv6"
3324 " accesslog errorlog certificate encoding")
3328 " accesslog errorlog certificate encoding")
3325 for o in optlist.split():
3329 for o in optlist.split():
3326 val = opts.get(o, '')
3330 val = opts.get(o, '')
3327 if val in (None, ''): # should check against default options instead
3331 if val in (None, ''): # should check against default options instead
3328 continue
3332 continue
3329 baseui.setconfig("web", o, val)
3333 baseui.setconfig("web", o, val)
3330 if repo and repo.ui != baseui:
3334 if repo and repo.ui != baseui:
3331 repo.ui.setconfig("web", o, val)
3335 repo.ui.setconfig("web", o, val)
3332
3336
3333 o = opts.get('web_conf') or opts.get('webdir_conf')
3337 o = opts.get('web_conf') or opts.get('webdir_conf')
3334 if not o:
3338 if not o:
3335 if not repo:
3339 if not repo:
3336 raise error.RepoError(_("There is no Mercurial repository"
3340 raise error.RepoError(_("There is no Mercurial repository"
3337 " here (.hg not found)"))
3341 " here (.hg not found)"))
3338 o = repo.root
3342 o = repo.root
3339
3343
3340 app = hgweb.hgweb(o, baseui=ui)
3344 app = hgweb.hgweb(o, baseui=ui)
3341
3345
3342 class service(object):
3346 class service(object):
3343 def init(self):
3347 def init(self):
3344 util.set_signal_handler()
3348 util.set_signal_handler()
3345 self.httpd = hgweb.server.create_server(ui, app)
3349 self.httpd = hgweb.server.create_server(ui, app)
3346
3350
3347 if opts['port'] and not ui.verbose:
3351 if opts['port'] and not ui.verbose:
3348 return
3352 return
3349
3353
3350 if self.httpd.prefix:
3354 if self.httpd.prefix:
3351 prefix = self.httpd.prefix.strip('/') + '/'
3355 prefix = self.httpd.prefix.strip('/') + '/'
3352 else:
3356 else:
3353 prefix = ''
3357 prefix = ''
3354
3358
3355 port = ':%d' % self.httpd.port
3359 port = ':%d' % self.httpd.port
3356 if port == ':80':
3360 if port == ':80':
3357 port = ''
3361 port = ''
3358
3362
3359 bindaddr = self.httpd.addr
3363 bindaddr = self.httpd.addr
3360 if bindaddr == '0.0.0.0':
3364 if bindaddr == '0.0.0.0':
3361 bindaddr = '*'
3365 bindaddr = '*'
3362 elif ':' in bindaddr: # IPv6
3366 elif ':' in bindaddr: # IPv6
3363 bindaddr = '[%s]' % bindaddr
3367 bindaddr = '[%s]' % bindaddr
3364
3368
3365 fqaddr = self.httpd.fqaddr
3369 fqaddr = self.httpd.fqaddr
3366 if ':' in fqaddr:
3370 if ':' in fqaddr:
3367 fqaddr = '[%s]' % fqaddr
3371 fqaddr = '[%s]' % fqaddr
3368 if opts['port']:
3372 if opts['port']:
3369 write = ui.status
3373 write = ui.status
3370 else:
3374 else:
3371 write = ui.write
3375 write = ui.write
3372 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
3376 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
3373 (fqaddr, port, prefix, bindaddr, self.httpd.port))
3377 (fqaddr, port, prefix, bindaddr, self.httpd.port))
3374
3378
3375 def run(self):
3379 def run(self):
3376 self.httpd.serve_forever()
3380 self.httpd.serve_forever()
3377
3381
3378 service = service()
3382 service = service()
3379
3383
3380 cmdutil.service(opts, initfn=service.init, runfn=service.run)
3384 cmdutil.service(opts, initfn=service.init, runfn=service.run)
3381
3385
3382 def status(ui, repo, *pats, **opts):
3386 def status(ui, repo, *pats, **opts):
3383 """show changed files in the working directory
3387 """show changed files in the working directory
3384
3388
3385 Show status of files in the repository. If names are given, only
3389 Show status of files in the repository. If names are given, only
3386 files that match are shown. Files that are clean or ignored or
3390 files that match are shown. Files that are clean or ignored or
3387 the source of a copy/move operation, are not listed unless
3391 the source of a copy/move operation, are not listed unless
3388 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
3392 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
3389 Unless options described with "show only ..." are given, the
3393 Unless options described with "show only ..." are given, the
3390 options -mardu are used.
3394 options -mardu are used.
3391
3395
3392 Option -q/--quiet hides untracked (unknown and ignored) files
3396 Option -q/--quiet hides untracked (unknown and ignored) files
3393 unless explicitly requested with -u/--unknown or -i/--ignored.
3397 unless explicitly requested with -u/--unknown or -i/--ignored.
3394
3398
3395 NOTE: status may appear to disagree with diff if permissions have
3399 NOTE: status may appear to disagree with diff if permissions have
3396 changed or a merge has occurred. The standard diff format does not
3400 changed or a merge has occurred. The standard diff format does not
3397 report permission changes and diff only reports changes relative
3401 report permission changes and diff only reports changes relative
3398 to one merge parent.
3402 to one merge parent.
3399
3403
3400 If one revision is given, it is used as the base revision.
3404 If one revision is given, it is used as the base revision.
3401 If two revisions are given, the differences between them are
3405 If two revisions are given, the differences between them are
3402 shown. The --change option can also be used as a shortcut to list
3406 shown. The --change option can also be used as a shortcut to list
3403 the changed files of a revision from its first parent.
3407 the changed files of a revision from its first parent.
3404
3408
3405 The codes used to show the status of files are::
3409 The codes used to show the status of files are::
3406
3410
3407 M = modified
3411 M = modified
3408 A = added
3412 A = added
3409 R = removed
3413 R = removed
3410 C = clean
3414 C = clean
3411 ! = missing (deleted by non-hg command, but still tracked)
3415 ! = missing (deleted by non-hg command, but still tracked)
3412 ? = not tracked
3416 ? = not tracked
3413 I = ignored
3417 I = ignored
3414 = origin of the previous file listed as A (added)
3418 = origin of the previous file listed as A (added)
3415
3419
3416 Returns 0 on success.
3420 Returns 0 on success.
3417 """
3421 """
3418
3422
3419 revs = opts.get('rev')
3423 revs = opts.get('rev')
3420 change = opts.get('change')
3424 change = opts.get('change')
3421
3425
3422 if revs and change:
3426 if revs and change:
3423 msg = _('cannot specify --rev and --change at the same time')
3427 msg = _('cannot specify --rev and --change at the same time')
3424 raise util.Abort(msg)
3428 raise util.Abort(msg)
3425 elif change:
3429 elif change:
3426 node2 = repo.lookup(change)
3430 node2 = repo.lookup(change)
3427 node1 = repo[node2].parents()[0].node()
3431 node1 = repo[node2].parents()[0].node()
3428 else:
3432 else:
3429 node1, node2 = cmdutil.revpair(repo, revs)
3433 node1, node2 = cmdutil.revpair(repo, revs)
3430
3434
3431 cwd = (pats and repo.getcwd()) or ''
3435 cwd = (pats and repo.getcwd()) or ''
3432 end = opts.get('print0') and '\0' or '\n'
3436 end = opts.get('print0') and '\0' or '\n'
3433 copy = {}
3437 copy = {}
3434 states = 'modified added removed deleted unknown ignored clean'.split()
3438 states = 'modified added removed deleted unknown ignored clean'.split()
3435 show = [k for k in states if opts.get(k)]
3439 show = [k for k in states if opts.get(k)]
3436 if opts.get('all'):
3440 if opts.get('all'):
3437 show += ui.quiet and (states[:4] + ['clean']) or states
3441 show += ui.quiet and (states[:4] + ['clean']) or states
3438 if not show:
3442 if not show:
3439 show = ui.quiet and states[:4] or states[:5]
3443 show = ui.quiet and states[:4] or states[:5]
3440
3444
3441 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
3445 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
3442 'ignored' in show, 'clean' in show, 'unknown' in show)
3446 'ignored' in show, 'clean' in show, 'unknown' in show)
3443 changestates = zip(states, 'MAR!?IC', stat)
3447 changestates = zip(states, 'MAR!?IC', stat)
3444
3448
3445 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
3449 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
3446 ctxn = repo[nullid]
3450 ctxn = repo[nullid]
3447 ctx1 = repo[node1]
3451 ctx1 = repo[node1]
3448 ctx2 = repo[node2]
3452 ctx2 = repo[node2]
3449 added = stat[1]
3453 added = stat[1]
3450 if node2 is None:
3454 if node2 is None:
3451 added = stat[0] + stat[1] # merged?
3455 added = stat[0] + stat[1] # merged?
3452
3456
3453 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
3457 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
3454 if k in added:
3458 if k in added:
3455 copy[k] = v
3459 copy[k] = v
3456 elif v in added:
3460 elif v in added:
3457 copy[v] = k
3461 copy[v] = k
3458
3462
3459 for state, char, files in changestates:
3463 for state, char, files in changestates:
3460 if state in show:
3464 if state in show:
3461 format = "%s %%s%s" % (char, end)
3465 format = "%s %%s%s" % (char, end)
3462 if opts.get('no_status'):
3466 if opts.get('no_status'):
3463 format = "%%s%s" % end
3467 format = "%%s%s" % end
3464
3468
3465 for f in files:
3469 for f in files:
3466 ui.write(format % repo.pathto(f, cwd),
3470 ui.write(format % repo.pathto(f, cwd),
3467 label='status.' + state)
3471 label='status.' + state)
3468 if f in copy:
3472 if f in copy:
3469 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end),
3473 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end),
3470 label='status.copied')
3474 label='status.copied')
3471
3475
3472 def summary(ui, repo, **opts):
3476 def summary(ui, repo, **opts):
3473 """summarize working directory state
3477 """summarize working directory state
3474
3478
3475 This generates a brief summary of the working directory state,
3479 This generates a brief summary of the working directory state,
3476 including parents, branch, commit status, and available updates.
3480 including parents, branch, commit status, and available updates.
3477
3481
3478 With the --remote option, this will check the default paths for
3482 With the --remote option, this will check the default paths for
3479 incoming and outgoing changes. This can be time-consuming.
3483 incoming and outgoing changes. This can be time-consuming.
3480
3484
3481 Returns 0 on success.
3485 Returns 0 on success.
3482 """
3486 """
3483
3487
3484 ctx = repo[None]
3488 ctx = repo[None]
3485 parents = ctx.parents()
3489 parents = ctx.parents()
3486 pnode = parents[0].node()
3490 pnode = parents[0].node()
3487
3491
3488 for p in parents:
3492 for p in parents:
3489 # label with log.changeset (instead of log.parent) since this
3493 # label with log.changeset (instead of log.parent) since this
3490 # shows a working directory parent *changeset*:
3494 # shows a working directory parent *changeset*:
3491 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
3495 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
3492 label='log.changeset')
3496 label='log.changeset')
3493 ui.write(' '.join(p.tags()), label='log.tag')
3497 ui.write(' '.join(p.tags()), label='log.tag')
3494 if p.rev() == -1:
3498 if p.rev() == -1:
3495 if not len(repo):
3499 if not len(repo):
3496 ui.write(_(' (empty repository)'))
3500 ui.write(_(' (empty repository)'))
3497 else:
3501 else:
3498 ui.write(_(' (no revision checked out)'))
3502 ui.write(_(' (no revision checked out)'))
3499 ui.write('\n')
3503 ui.write('\n')
3500 if p.description():
3504 if p.description():
3501 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
3505 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
3502 label='log.summary')
3506 label='log.summary')
3503
3507
3504 branch = ctx.branch()
3508 branch = ctx.branch()
3505 bheads = repo.branchheads(branch)
3509 bheads = repo.branchheads(branch)
3506 m = _('branch: %s\n') % branch
3510 m = _('branch: %s\n') % branch
3507 if branch != 'default':
3511 if branch != 'default':
3508 ui.write(m, label='log.branch')
3512 ui.write(m, label='log.branch')
3509 else:
3513 else:
3510 ui.status(m, label='log.branch')
3514 ui.status(m, label='log.branch')
3511
3515
3512 st = list(repo.status(unknown=True))[:6]
3516 st = list(repo.status(unknown=True))[:6]
3513
3517
3514 c = repo.dirstate.copies()
3518 c = repo.dirstate.copies()
3515 copied, renamed = [], []
3519 copied, renamed = [], []
3516 for d, s in c.iteritems():
3520 for d, s in c.iteritems():
3517 if s in st[2]:
3521 if s in st[2]:
3518 st[2].remove(s)
3522 st[2].remove(s)
3519 renamed.append(d)
3523 renamed.append(d)
3520 else:
3524 else:
3521 copied.append(d)
3525 copied.append(d)
3522 if d in st[1]:
3526 if d in st[1]:
3523 st[1].remove(d)
3527 st[1].remove(d)
3524 st.insert(3, renamed)
3528 st.insert(3, renamed)
3525 st.insert(4, copied)
3529 st.insert(4, copied)
3526
3530
3527 ms = mergemod.mergestate(repo)
3531 ms = mergemod.mergestate(repo)
3528 st.append([f for f in ms if ms[f] == 'u'])
3532 st.append([f for f in ms if ms[f] == 'u'])
3529
3533
3530 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
3534 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
3531 st.append(subs)
3535 st.append(subs)
3532
3536
3533 labels = [ui.label(_('%d modified'), 'status.modified'),
3537 labels = [ui.label(_('%d modified'), 'status.modified'),
3534 ui.label(_('%d added'), 'status.added'),
3538 ui.label(_('%d added'), 'status.added'),
3535 ui.label(_('%d removed'), 'status.removed'),
3539 ui.label(_('%d removed'), 'status.removed'),
3536 ui.label(_('%d renamed'), 'status.copied'),
3540 ui.label(_('%d renamed'), 'status.copied'),
3537 ui.label(_('%d copied'), 'status.copied'),
3541 ui.label(_('%d copied'), 'status.copied'),
3538 ui.label(_('%d deleted'), 'status.deleted'),
3542 ui.label(_('%d deleted'), 'status.deleted'),
3539 ui.label(_('%d unknown'), 'status.unknown'),
3543 ui.label(_('%d unknown'), 'status.unknown'),
3540 ui.label(_('%d ignored'), 'status.ignored'),
3544 ui.label(_('%d ignored'), 'status.ignored'),
3541 ui.label(_('%d unresolved'), 'resolve.unresolved'),
3545 ui.label(_('%d unresolved'), 'resolve.unresolved'),
3542 ui.label(_('%d subrepos'), 'status.modified')]
3546 ui.label(_('%d subrepos'), 'status.modified')]
3543 t = []
3547 t = []
3544 for s, l in zip(st, labels):
3548 for s, l in zip(st, labels):
3545 if s:
3549 if s:
3546 t.append(l % len(s))
3550 t.append(l % len(s))
3547
3551
3548 t = ', '.join(t)
3552 t = ', '.join(t)
3549 cleanworkdir = False
3553 cleanworkdir = False
3550
3554
3551 if len(parents) > 1:
3555 if len(parents) > 1:
3552 t += _(' (merge)')
3556 t += _(' (merge)')
3553 elif branch != parents[0].branch():
3557 elif branch != parents[0].branch():
3554 t += _(' (new branch)')
3558 t += _(' (new branch)')
3555 elif (parents[0].extra().get('close') and
3559 elif (parents[0].extra().get('close') and
3556 pnode in repo.branchheads(branch, closed=True)):
3560 pnode in repo.branchheads(branch, closed=True)):
3557 t += _(' (head closed)')
3561 t += _(' (head closed)')
3558 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
3562 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
3559 t += _(' (clean)')
3563 t += _(' (clean)')
3560 cleanworkdir = True
3564 cleanworkdir = True
3561 elif pnode not in bheads:
3565 elif pnode not in bheads:
3562 t += _(' (new branch head)')
3566 t += _(' (new branch head)')
3563
3567
3564 if cleanworkdir:
3568 if cleanworkdir:
3565 ui.status(_('commit: %s\n') % t.strip())
3569 ui.status(_('commit: %s\n') % t.strip())
3566 else:
3570 else:
3567 ui.write(_('commit: %s\n') % t.strip())
3571 ui.write(_('commit: %s\n') % t.strip())
3568
3572
3569 # all ancestors of branch heads - all ancestors of parent = new csets
3573 # all ancestors of branch heads - all ancestors of parent = new csets
3570 new = [0] * len(repo)
3574 new = [0] * len(repo)
3571 cl = repo.changelog
3575 cl = repo.changelog
3572 for a in [cl.rev(n) for n in bheads]:
3576 for a in [cl.rev(n) for n in bheads]:
3573 new[a] = 1
3577 new[a] = 1
3574 for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
3578 for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
3575 new[a] = 1
3579 new[a] = 1
3576 for a in [p.rev() for p in parents]:
3580 for a in [p.rev() for p in parents]:
3577 if a >= 0:
3581 if a >= 0:
3578 new[a] = 0
3582 new[a] = 0
3579 for a in cl.ancestors(*[p.rev() for p in parents]):
3583 for a in cl.ancestors(*[p.rev() for p in parents]):
3580 new[a] = 0
3584 new[a] = 0
3581 new = sum(new)
3585 new = sum(new)
3582
3586
3583 if new == 0:
3587 if new == 0:
3584 ui.status(_('update: (current)\n'))
3588 ui.status(_('update: (current)\n'))
3585 elif pnode not in bheads:
3589 elif pnode not in bheads:
3586 ui.write(_('update: %d new changesets (update)\n') % new)
3590 ui.write(_('update: %d new changesets (update)\n') % new)
3587 else:
3591 else:
3588 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
3592 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
3589 (new, len(bheads)))
3593 (new, len(bheads)))
3590
3594
3591 if opts.get('remote'):
3595 if opts.get('remote'):
3592 t = []
3596 t = []
3593 source, branches = hg.parseurl(ui.expandpath('default'))
3597 source, branches = hg.parseurl(ui.expandpath('default'))
3594 other = hg.repository(hg.remoteui(repo, {}), source)
3598 other = hg.repository(hg.remoteui(repo, {}), source)
3595 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3599 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3596 ui.debug('comparing with %s\n' % url.hidepassword(source))
3600 ui.debug('comparing with %s\n' % url.hidepassword(source))
3597 repo.ui.pushbuffer()
3601 repo.ui.pushbuffer()
3598 common, incoming, rheads = discovery.findcommonincoming(repo, other)
3602 common, incoming, rheads = discovery.findcommonincoming(repo, other)
3599 repo.ui.popbuffer()
3603 repo.ui.popbuffer()
3600 if incoming:
3604 if incoming:
3601 t.append(_('1 or more incoming'))
3605 t.append(_('1 or more incoming'))
3602
3606
3603 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3607 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3604 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3608 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3605 other = hg.repository(hg.remoteui(repo, {}), dest)
3609 other = hg.repository(hg.remoteui(repo, {}), dest)
3606 ui.debug('comparing with %s\n' % url.hidepassword(dest))
3610 ui.debug('comparing with %s\n' % url.hidepassword(dest))
3607 repo.ui.pushbuffer()
3611 repo.ui.pushbuffer()
3608 o = discovery.findoutgoing(repo, other)
3612 o = discovery.findoutgoing(repo, other)
3609 repo.ui.popbuffer()
3613 repo.ui.popbuffer()
3610 o = repo.changelog.nodesbetween(o, None)[0]
3614 o = repo.changelog.nodesbetween(o, None)[0]
3611 if o:
3615 if o:
3612 t.append(_('%d outgoing') % len(o))
3616 t.append(_('%d outgoing') % len(o))
3613
3617
3614 if t:
3618 if t:
3615 ui.write(_('remote: %s\n') % (', '.join(t)))
3619 ui.write(_('remote: %s\n') % (', '.join(t)))
3616 else:
3620 else:
3617 ui.status(_('remote: (synced)\n'))
3621 ui.status(_('remote: (synced)\n'))
3618
3622
3619 def tag(ui, repo, name1, *names, **opts):
3623 def tag(ui, repo, name1, *names, **opts):
3620 """add one or more tags for the current or given revision
3624 """add one or more tags for the current or given revision
3621
3625
3622 Name a particular revision using <name>.
3626 Name a particular revision using <name>.
3623
3627
3624 Tags are used to name particular revisions of the repository and are
3628 Tags are used to name particular revisions of the repository and are
3625 very useful to compare different revisions, to go back to significant
3629 very useful to compare different revisions, to go back to significant
3626 earlier versions or to mark branch points as releases, etc.
3630 earlier versions or to mark branch points as releases, etc.
3627
3631
3628 If no revision is given, the parent of the working directory is
3632 If no revision is given, the parent of the working directory is
3629 used, or tip if no revision is checked out.
3633 used, or tip if no revision is checked out.
3630
3634
3631 To facilitate version control, distribution, and merging of tags,
3635 To facilitate version control, distribution, and merging of tags,
3632 they are stored as a file named ".hgtags" which is managed
3636 they are stored as a file named ".hgtags" which is managed
3633 similarly to other project files and can be hand-edited if
3637 similarly to other project files and can be hand-edited if
3634 necessary. The file '.hg/localtags' is used for local tags (not
3638 necessary. The file '.hg/localtags' is used for local tags (not
3635 shared among repositories).
3639 shared among repositories).
3636
3640
3637 See :hg:`help dates` for a list of formats valid for -d/--date.
3641 See :hg:`help dates` for a list of formats valid for -d/--date.
3638
3642
3639 Since tag names have priority over branch names during revision
3643 Since tag names have priority over branch names during revision
3640 lookup, using an existing branch name as a tag name is discouraged.
3644 lookup, using an existing branch name as a tag name is discouraged.
3641
3645
3642 Returns 0 on success.
3646 Returns 0 on success.
3643 """
3647 """
3644
3648
3645 rev_ = "."
3649 rev_ = "."
3646 names = [t.strip() for t in (name1,) + names]
3650 names = [t.strip() for t in (name1,) + names]
3647 if len(names) != len(set(names)):
3651 if len(names) != len(set(names)):
3648 raise util.Abort(_('tag names must be unique'))
3652 raise util.Abort(_('tag names must be unique'))
3649 for n in names:
3653 for n in names:
3650 if n in ['tip', '.', 'null']:
3654 if n in ['tip', '.', 'null']:
3651 raise util.Abort(_('the name \'%s\' is reserved') % n)
3655 raise util.Abort(_('the name \'%s\' is reserved') % n)
3652 if opts.get('rev') and opts.get('remove'):
3656 if opts.get('rev') and opts.get('remove'):
3653 raise util.Abort(_("--rev and --remove are incompatible"))
3657 raise util.Abort(_("--rev and --remove are incompatible"))
3654 if opts.get('rev'):
3658 if opts.get('rev'):
3655 rev_ = opts['rev']
3659 rev_ = opts['rev']
3656 message = opts.get('message')
3660 message = opts.get('message')
3657 if opts.get('remove'):
3661 if opts.get('remove'):
3658 expectedtype = opts.get('local') and 'local' or 'global'
3662 expectedtype = opts.get('local') and 'local' or 'global'
3659 for n in names:
3663 for n in names:
3660 if not repo.tagtype(n):
3664 if not repo.tagtype(n):
3661 raise util.Abort(_('tag \'%s\' does not exist') % n)
3665 raise util.Abort(_('tag \'%s\' does not exist') % n)
3662 if repo.tagtype(n) != expectedtype:
3666 if repo.tagtype(n) != expectedtype:
3663 if expectedtype == 'global':
3667 if expectedtype == 'global':
3664 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
3668 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
3665 else:
3669 else:
3666 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
3670 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
3667 rev_ = nullid
3671 rev_ = nullid
3668 if not message:
3672 if not message:
3669 # we don't translate commit messages
3673 # we don't translate commit messages
3670 message = 'Removed tag %s' % ', '.join(names)
3674 message = 'Removed tag %s' % ', '.join(names)
3671 elif not opts.get('force'):
3675 elif not opts.get('force'):
3672 for n in names:
3676 for n in names:
3673 if n in repo.tags():
3677 if n in repo.tags():
3674 raise util.Abort(_('tag \'%s\' already exists '
3678 raise util.Abort(_('tag \'%s\' already exists '
3675 '(use -f to force)') % n)
3679 '(use -f to force)') % n)
3676 if not rev_ and repo.dirstate.parents()[1] != nullid:
3680 if not rev_ and repo.dirstate.parents()[1] != nullid:
3677 raise util.Abort(_('uncommitted merge - please provide a '
3681 raise util.Abort(_('uncommitted merge - please provide a '
3678 'specific revision'))
3682 'specific revision'))
3679 r = repo[rev_].node()
3683 r = repo[rev_].node()
3680
3684
3681 if not message:
3685 if not message:
3682 # we don't translate commit messages
3686 # we don't translate commit messages
3683 message = ('Added tag %s for changeset %s' %
3687 message = ('Added tag %s for changeset %s' %
3684 (', '.join(names), short(r)))
3688 (', '.join(names), short(r)))
3685
3689
3686 date = opts.get('date')
3690 date = opts.get('date')
3687 if date:
3691 if date:
3688 date = util.parsedate(date)
3692 date = util.parsedate(date)
3689
3693
3690 if opts.get('edit'):
3694 if opts.get('edit'):
3691 message = ui.edit(message, ui.username())
3695 message = ui.edit(message, ui.username())
3692
3696
3693 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
3697 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
3694
3698
3695 def tags(ui, repo):
3699 def tags(ui, repo):
3696 """list repository tags
3700 """list repository tags
3697
3701
3698 This lists both regular and local tags. When the -v/--verbose
3702 This lists both regular and local tags. When the -v/--verbose
3699 switch is used, a third column "local" is printed for local tags.
3703 switch is used, a third column "local" is printed for local tags.
3700
3704
3701 Returns 0 on success.
3705 Returns 0 on success.
3702 """
3706 """
3703
3707
3704 hexfunc = ui.debugflag and hex or short
3708 hexfunc = ui.debugflag and hex or short
3705 tagtype = ""
3709 tagtype = ""
3706
3710
3707 for t, n in reversed(repo.tagslist()):
3711 for t, n in reversed(repo.tagslist()):
3708 if ui.quiet:
3712 if ui.quiet:
3709 ui.write("%s\n" % t)
3713 ui.write("%s\n" % t)
3710 continue
3714 continue
3711
3715
3712 try:
3716 try:
3713 hn = hexfunc(n)
3717 hn = hexfunc(n)
3714 r = "%5d:%s" % (repo.changelog.rev(n), hn)
3718 r = "%5d:%s" % (repo.changelog.rev(n), hn)
3715 except error.LookupError:
3719 except error.LookupError:
3716 r = " ?:%s" % hn
3720 r = " ?:%s" % hn
3717 else:
3721 else:
3718 spaces = " " * (30 - encoding.colwidth(t))
3722 spaces = " " * (30 - encoding.colwidth(t))
3719 if ui.verbose:
3723 if ui.verbose:
3720 if repo.tagtype(t) == 'local':
3724 if repo.tagtype(t) == 'local':
3721 tagtype = " local"
3725 tagtype = " local"
3722 else:
3726 else:
3723 tagtype = ""
3727 tagtype = ""
3724 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
3728 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
3725
3729
3726 def tip(ui, repo, **opts):
3730 def tip(ui, repo, **opts):
3727 """show the tip revision
3731 """show the tip revision
3728
3732
3729 The tip revision (usually just called the tip) is the changeset
3733 The tip revision (usually just called the tip) is the changeset
3730 most recently added to the repository (and therefore the most
3734 most recently added to the repository (and therefore the most
3731 recently changed head).
3735 recently changed head).
3732
3736
3733 If you have just made a commit, that commit will be the tip. If
3737 If you have just made a commit, that commit will be the tip. If
3734 you have just pulled changes from another repository, the tip of
3738 you have just pulled changes from another repository, the tip of
3735 that repository becomes the current tip. The "tip" tag is special
3739 that repository becomes the current tip. The "tip" tag is special
3736 and cannot be renamed or assigned to a different changeset.
3740 and cannot be renamed or assigned to a different changeset.
3737
3741
3738 Returns 0 on success.
3742 Returns 0 on success.
3739 """
3743 """
3740 displayer = cmdutil.show_changeset(ui, repo, opts)
3744 displayer = cmdutil.show_changeset(ui, repo, opts)
3741 displayer.show(repo[len(repo) - 1])
3745 displayer.show(repo[len(repo) - 1])
3742 displayer.close()
3746 displayer.close()
3743
3747
3744 def unbundle(ui, repo, fname1, *fnames, **opts):
3748 def unbundle(ui, repo, fname1, *fnames, **opts):
3745 """apply one or more changegroup files
3749 """apply one or more changegroup files
3746
3750
3747 Apply one or more compressed changegroup files generated by the
3751 Apply one or more compressed changegroup files generated by the
3748 bundle command.
3752 bundle command.
3749
3753
3750 Returns 0 on success, 1 if an update has unresolved files.
3754 Returns 0 on success, 1 if an update has unresolved files.
3751 """
3755 """
3752 fnames = (fname1,) + fnames
3756 fnames = (fname1,) + fnames
3753
3757
3754 lock = repo.lock()
3758 lock = repo.lock()
3755 try:
3759 try:
3756 for fname in fnames:
3760 for fname in fnames:
3757 f = url.open(ui, fname)
3761 f = url.open(ui, fname)
3758 gen = changegroup.readbundle(f, fname)
3762 gen = changegroup.readbundle(f, fname)
3759 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname,
3763 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname,
3760 lock=lock)
3764 lock=lock)
3761 finally:
3765 finally:
3762 lock.release()
3766 lock.release()
3763
3767
3764 return postincoming(ui, repo, modheads, opts.get('update'), None)
3768 return postincoming(ui, repo, modheads, opts.get('update'), None)
3765
3769
3766 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
3770 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
3767 """update working directory (or switch revisions)
3771 """update working directory (or switch revisions)
3768
3772
3769 Update the repository's working directory to the specified
3773 Update the repository's working directory to the specified
3770 changeset.
3774 changeset.
3771
3775
3772 If no changeset is specified, attempt to update to the head of the
3776 If no changeset is specified, attempt to update to the head of the
3773 current branch. If this head is a descendant of the working
3777 current branch. If this head is a descendant of the working
3774 directory's parent, update to it, otherwise abort.
3778 directory's parent, update to it, otherwise abort.
3775
3779
3776 The following rules apply when the working directory contains
3780 The following rules apply when the working directory contains
3777 uncommitted changes:
3781 uncommitted changes:
3778
3782
3779 1. If neither -c/--check nor -C/--clean is specified, and if
3783 1. If neither -c/--check nor -C/--clean is specified, and if
3780 the requested changeset is an ancestor or descendant of
3784 the requested changeset is an ancestor or descendant of
3781 the working directory's parent, the uncommitted changes
3785 the working directory's parent, the uncommitted changes
3782 are merged into the requested changeset and the merged
3786 are merged into the requested changeset and the merged
3783 result is left uncommitted. If the requested changeset is
3787 result is left uncommitted. If the requested changeset is
3784 not an ancestor or descendant (that is, it is on another
3788 not an ancestor or descendant (that is, it is on another
3785 branch), the update is aborted and the uncommitted changes
3789 branch), the update is aborted and the uncommitted changes
3786 are preserved.
3790 are preserved.
3787
3791
3788 2. With the -c/--check option, the update is aborted and the
3792 2. With the -c/--check option, the update is aborted and the
3789 uncommitted changes are preserved.
3793 uncommitted changes are preserved.
3790
3794
3791 3. With the -C/--clean option, uncommitted changes are discarded and
3795 3. With the -C/--clean option, uncommitted changes are discarded and
3792 the working directory is updated to the requested changeset.
3796 the working directory is updated to the requested changeset.
3793
3797
3794 Use null as the changeset to remove the working directory (like
3798 Use null as the changeset to remove the working directory (like
3795 :hg:`clone -U`).
3799 :hg:`clone -U`).
3796
3800
3797 If you want to update just one file to an older changeset, use :hg:`revert`.
3801 If you want to update just one file to an older changeset, use :hg:`revert`.
3798
3802
3799 See :hg:`help dates` for a list of formats valid for -d/--date.
3803 See :hg:`help dates` for a list of formats valid for -d/--date.
3800
3804
3801 Returns 0 on success, 1 if there are unresolved files.
3805 Returns 0 on success, 1 if there are unresolved files.
3802 """
3806 """
3803 if rev and node:
3807 if rev and node:
3804 raise util.Abort(_("please specify just one revision"))
3808 raise util.Abort(_("please specify just one revision"))
3805
3809
3806 if not rev:
3810 if not rev:
3807 rev = node
3811 rev = node
3808
3812
3809 if check and clean:
3813 if check and clean:
3810 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
3814 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
3811
3815
3812 if check:
3816 if check:
3813 # we could use dirty() but we can ignore merge and branch trivia
3817 # we could use dirty() but we can ignore merge and branch trivia
3814 c = repo[None]
3818 c = repo[None]
3815 if c.modified() or c.added() or c.removed():
3819 if c.modified() or c.added() or c.removed():
3816 raise util.Abort(_("uncommitted local changes"))
3820 raise util.Abort(_("uncommitted local changes"))
3817
3821
3818 if date:
3822 if date:
3819 if rev:
3823 if rev:
3820 raise util.Abort(_("you can't specify a revision and a date"))
3824 raise util.Abort(_("you can't specify a revision and a date"))
3821 rev = cmdutil.finddate(ui, repo, date)
3825 rev = cmdutil.finddate(ui, repo, date)
3822
3826
3823 if clean or check:
3827 if clean or check:
3824 return hg.clean(repo, rev)
3828 return hg.clean(repo, rev)
3825 else:
3829 else:
3826 return hg.update(repo, rev)
3830 return hg.update(repo, rev)
3827
3831
3828 def verify(ui, repo):
3832 def verify(ui, repo):
3829 """verify the integrity of the repository
3833 """verify the integrity of the repository
3830
3834
3831 Verify the integrity of the current repository.
3835 Verify the integrity of the current repository.
3832
3836
3833 This will perform an extensive check of the repository's
3837 This will perform an extensive check of the repository's
3834 integrity, validating the hashes and checksums of each entry in
3838 integrity, validating the hashes and checksums of each entry in
3835 the changelog, manifest, and tracked files, as well as the
3839 the changelog, manifest, and tracked files, as well as the
3836 integrity of their crosslinks and indices.
3840 integrity of their crosslinks and indices.
3837
3841
3838 Returns 0 on success, 1 if errors are encountered.
3842 Returns 0 on success, 1 if errors are encountered.
3839 """
3843 """
3840 return hg.verify(repo)
3844 return hg.verify(repo)
3841
3845
3842 def version_(ui):
3846 def version_(ui):
3843 """output version and copyright information"""
3847 """output version and copyright information"""
3844 ui.write(_("Mercurial Distributed SCM (version %s)\n")
3848 ui.write(_("Mercurial Distributed SCM (version %s)\n")
3845 % util.version())
3849 % util.version())
3846 ui.status(_(
3850 ui.status(_(
3847 "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n"
3851 "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n"
3848 "This is free software; see the source for copying conditions. "
3852 "This is free software; see the source for copying conditions. "
3849 "There is NO\nwarranty; "
3853 "There is NO\nwarranty; "
3850 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
3854 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
3851 ))
3855 ))
3852
3856
3853 # Command options and aliases are listed here, alphabetically
3857 # Command options and aliases are listed here, alphabetically
3854
3858
3855 globalopts = [
3859 globalopts = [
3856 ('R', 'repository', '',
3860 ('R', 'repository', '',
3857 _('repository root directory or name of overlay bundle file'),
3861 _('repository root directory or name of overlay bundle file'),
3858 _('REPO')),
3862 _('REPO')),
3859 ('', 'cwd', '',
3863 ('', 'cwd', '',
3860 _('change working directory'), _('DIR')),
3864 _('change working directory'), _('DIR')),
3861 ('y', 'noninteractive', None,
3865 ('y', 'noninteractive', None,
3862 _('do not prompt, assume \'yes\' for any required answers')),
3866 _('do not prompt, assume \'yes\' for any required answers')),
3863 ('q', 'quiet', None, _('suppress output')),
3867 ('q', 'quiet', None, _('suppress output')),
3864 ('v', 'verbose', None, _('enable additional output')),
3868 ('v', 'verbose', None, _('enable additional output')),
3865 ('', 'config', [],
3869 ('', 'config', [],
3866 _('set/override config option (use \'section.name=value\')'),
3870 _('set/override config option (use \'section.name=value\')'),
3867 _('CONFIG')),
3871 _('CONFIG')),
3868 ('', 'debug', None, _('enable debugging output')),
3872 ('', 'debug', None, _('enable debugging output')),
3869 ('', 'debugger', None, _('start debugger')),
3873 ('', 'debugger', None, _('start debugger')),
3870 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
3874 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
3871 _('ENCODE')),
3875 _('ENCODE')),
3872 ('', 'encodingmode', encoding.encodingmode,
3876 ('', 'encodingmode', encoding.encodingmode,
3873 _('set the charset encoding mode'), _('MODE')),
3877 _('set the charset encoding mode'), _('MODE')),
3874 ('', 'traceback', None, _('always print a traceback on exception')),
3878 ('', 'traceback', None, _('always print a traceback on exception')),
3875 ('', 'time', None, _('time how long the command takes')),
3879 ('', 'time', None, _('time how long the command takes')),
3876 ('', 'profile', None, _('print command execution profile')),
3880 ('', 'profile', None, _('print command execution profile')),
3877 ('', 'version', None, _('output version information and exit')),
3881 ('', 'version', None, _('output version information and exit')),
3878 ('h', 'help', None, _('display help and exit')),
3882 ('h', 'help', None, _('display help and exit')),
3879 ]
3883 ]
3880
3884
3881 dryrunopts = [('n', 'dry-run', None,
3885 dryrunopts = [('n', 'dry-run', None,
3882 _('do not perform actions, just print output'))]
3886 _('do not perform actions, just print output'))]
3883
3887
3884 remoteopts = [
3888 remoteopts = [
3885 ('e', 'ssh', '',
3889 ('e', 'ssh', '',
3886 _('specify ssh command to use'), _('CMD')),
3890 _('specify ssh command to use'), _('CMD')),
3887 ('', 'remotecmd', '',
3891 ('', 'remotecmd', '',
3888 _('specify hg command to run on the remote side'), _('CMD')),
3892 _('specify hg command to run on the remote side'), _('CMD')),
3889 ]
3893 ]
3890
3894
3891 walkopts = [
3895 walkopts = [
3892 ('I', 'include', [],
3896 ('I', 'include', [],
3893 _('include names matching the given patterns'), _('PATTERN')),
3897 _('include names matching the given patterns'), _('PATTERN')),
3894 ('X', 'exclude', [],
3898 ('X', 'exclude', [],
3895 _('exclude names matching the given patterns'), _('PATTERN')),
3899 _('exclude names matching the given patterns'), _('PATTERN')),
3896 ]
3900 ]
3897
3901
3898 commitopts = [
3902 commitopts = [
3899 ('m', 'message', '',
3903 ('m', 'message', '',
3900 _('use text as commit message'), _('TEXT')),
3904 _('use text as commit message'), _('TEXT')),
3901 ('l', 'logfile', '',
3905 ('l', 'logfile', '',
3902 _('read commit message from file'), _('FILE')),
3906 _('read commit message from file'), _('FILE')),
3903 ]
3907 ]
3904
3908
3905 commitopts2 = [
3909 commitopts2 = [
3906 ('d', 'date', '',
3910 ('d', 'date', '',
3907 _('record datecode as commit date'), _('DATE')),
3911 _('record datecode as commit date'), _('DATE')),
3908 ('u', 'user', '',
3912 ('u', 'user', '',
3909 _('record the specified user as committer'), _('USER')),
3913 _('record the specified user as committer'), _('USER')),
3910 ]
3914 ]
3911
3915
3912 templateopts = [
3916 templateopts = [
3913 ('', 'style', '',
3917 ('', 'style', '',
3914 _('display using template map file'), _('STYLE')),
3918 _('display using template map file'), _('STYLE')),
3915 ('', 'template', '',
3919 ('', 'template', '',
3916 _('display with template'), _('TEMPLATE')),
3920 _('display with template'), _('TEMPLATE')),
3917 ]
3921 ]
3918
3922
3919 logopts = [
3923 logopts = [
3920 ('p', 'patch', None, _('show patch')),
3924 ('p', 'patch', None, _('show patch')),
3921 ('g', 'git', None, _('use git extended diff format')),
3925 ('g', 'git', None, _('use git extended diff format')),
3922 ('l', 'limit', '',
3926 ('l', 'limit', '',
3923 _('limit number of changes displayed'), _('NUM')),
3927 _('limit number of changes displayed'), _('NUM')),
3924 ('M', 'no-merges', None, _('do not show merges')),
3928 ('M', 'no-merges', None, _('do not show merges')),
3925 ('', 'stat', None, _('output diffstat-style summary of changes')),
3929 ('', 'stat', None, _('output diffstat-style summary of changes')),
3926 ] + templateopts
3930 ] + templateopts
3927
3931
3928 diffopts = [
3932 diffopts = [
3929 ('a', 'text', None, _('treat all files as text')),
3933 ('a', 'text', None, _('treat all files as text')),
3930 ('g', 'git', None, _('use git extended diff format')),
3934 ('g', 'git', None, _('use git extended diff format')),
3931 ('', 'nodates', None, _('omit dates from diff headers'))
3935 ('', 'nodates', None, _('omit dates from diff headers'))
3932 ]
3936 ]
3933
3937
3934 diffopts2 = [
3938 diffopts2 = [
3935 ('p', 'show-function', None, _('show which function each change is in')),
3939 ('p', 'show-function', None, _('show which function each change is in')),
3936 ('', 'reverse', None, _('produce a diff that undoes the changes')),
3940 ('', 'reverse', None, _('produce a diff that undoes the changes')),
3937 ('w', 'ignore-all-space', None,
3941 ('w', 'ignore-all-space', None,
3938 _('ignore white space when comparing lines')),
3942 _('ignore white space when comparing lines')),
3939 ('b', 'ignore-space-change', None,
3943 ('b', 'ignore-space-change', None,
3940 _('ignore changes in the amount of white space')),
3944 _('ignore changes in the amount of white space')),
3941 ('B', 'ignore-blank-lines', None,
3945 ('B', 'ignore-blank-lines', None,
3942 _('ignore changes whose lines are all blank')),
3946 _('ignore changes whose lines are all blank')),
3943 ('U', 'unified', '',
3947 ('U', 'unified', '',
3944 _('number of lines of context to show'), _('NUM')),
3948 _('number of lines of context to show'), _('NUM')),
3945 ('', 'stat', None, _('output diffstat-style summary of changes')),
3949 ('', 'stat', None, _('output diffstat-style summary of changes')),
3946 ]
3950 ]
3947
3951
3948 similarityopts = [
3952 similarityopts = [
3949 ('s', 'similarity', '',
3953 ('s', 'similarity', '',
3950 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
3954 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
3951 ]
3955 ]
3952
3956
3953 table = {
3957 table = {
3954 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),
3958 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),
3955 "addremove":
3959 "addremove":
3956 (addremove, similarityopts + walkopts + dryrunopts,
3960 (addremove, similarityopts + walkopts + dryrunopts,
3957 _('[OPTION]... [FILE]...')),
3961 _('[OPTION]... [FILE]...')),
3958 "^annotate|blame":
3962 "^annotate|blame":
3959 (annotate,
3963 (annotate,
3960 [('r', 'rev', '',
3964 [('r', 'rev', '',
3961 _('annotate the specified revision'), _('REV')),
3965 _('annotate the specified revision'), _('REV')),
3962 ('', 'follow', None,
3966 ('', 'follow', None,
3963 _('follow copies/renames and list the filename (DEPRECATED)')),
3967 _('follow copies/renames and list the filename (DEPRECATED)')),
3964 ('', 'no-follow', None, _("don't follow copies and renames")),
3968 ('', 'no-follow', None, _("don't follow copies and renames")),
3965 ('a', 'text', None, _('treat all files as text')),
3969 ('a', 'text', None, _('treat all files as text')),
3966 ('u', 'user', None, _('list the author (long with -v)')),
3970 ('u', 'user', None, _('list the author (long with -v)')),
3967 ('f', 'file', None, _('list the filename')),
3971 ('f', 'file', None, _('list the filename')),
3968 ('d', 'date', None, _('list the date (short with -q)')),
3972 ('d', 'date', None, _('list the date (short with -q)')),
3969 ('n', 'number', None, _('list the revision number (default)')),
3973 ('n', 'number', None, _('list the revision number (default)')),
3970 ('c', 'changeset', None, _('list the changeset')),
3974 ('c', 'changeset', None, _('list the changeset')),
3971 ('l', 'line-number', None,
3975 ('l', 'line-number', None,
3972 _('show line number at the first appearance'))
3976 _('show line number at the first appearance'))
3973 ] + walkopts,
3977 ] + walkopts,
3974 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
3978 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
3975 "archive":
3979 "archive":
3976 (archive,
3980 (archive,
3977 [('', 'no-decode', None, _('do not pass files through decoders')),
3981 [('', 'no-decode', None, _('do not pass files through decoders')),
3978 ('p', 'prefix', '',
3982 ('p', 'prefix', '',
3979 _('directory prefix for files in archive'), _('PREFIX')),
3983 _('directory prefix for files in archive'), _('PREFIX')),
3980 ('r', 'rev', '',
3984 ('r', 'rev', '',
3981 _('revision to distribute'), _('REV')),
3985 _('revision to distribute'), _('REV')),
3982 ('t', 'type', '',
3986 ('t', 'type', '',
3983 _('type of distribution to create'), _('TYPE')),
3987 _('type of distribution to create'), _('TYPE')),
3984 ] + walkopts,
3988 ] + walkopts,
3985 _('[OPTION]... DEST')),
3989 _('[OPTION]... DEST')),
3986 "backout":
3990 "backout":
3987 (backout,
3991 (backout,
3988 [('', 'merge', None,
3992 [('', 'merge', None,
3989 _('merge with old dirstate parent after backout')),
3993 _('merge with old dirstate parent after backout')),
3990 ('', 'parent', '',
3994 ('', 'parent', '',
3991 _('parent to choose when backing out merge'), _('REV')),
3995 _('parent to choose when backing out merge'), _('REV')),
3992 ('r', 'rev', '',
3996 ('r', 'rev', '',
3993 _('revision to backout'), _('REV')),
3997 _('revision to backout'), _('REV')),
3994 ] + walkopts + commitopts + commitopts2,
3998 ] + walkopts + commitopts + commitopts2,
3995 _('[OPTION]... [-r] REV')),
3999 _('[OPTION]... [-r] REV')),
3996 "bisect":
4000 "bisect":
3997 (bisect,
4001 (bisect,
3998 [('r', 'reset', False, _('reset bisect state')),
4002 [('r', 'reset', False, _('reset bisect state')),
3999 ('g', 'good', False, _('mark changeset good')),
4003 ('g', 'good', False, _('mark changeset good')),
4000 ('b', 'bad', False, _('mark changeset bad')),
4004 ('b', 'bad', False, _('mark changeset bad')),
4001 ('s', 'skip', False, _('skip testing changeset')),
4005 ('s', 'skip', False, _('skip testing changeset')),
4002 ('c', 'command', '',
4006 ('c', 'command', '',
4003 _('use command to check changeset state'), _('CMD')),
4007 _('use command to check changeset state'), _('CMD')),
4004 ('U', 'noupdate', False, _('do not update to target'))],
4008 ('U', 'noupdate', False, _('do not update to target'))],
4005 _("[-gbsr] [-U] [-c CMD] [REV]")),
4009 _("[-gbsr] [-U] [-c CMD] [REV]")),
4006 "branch":
4010 "branch":
4007 (branch,
4011 (branch,
4008 [('f', 'force', None,
4012 [('f', 'force', None,
4009 _('set branch name even if it shadows an existing branch')),
4013 _('set branch name even if it shadows an existing branch')),
4010 ('C', 'clean', None, _('reset branch name to parent branch name'))],
4014 ('C', 'clean', None, _('reset branch name to parent branch name'))],
4011 _('[-fC] [NAME]')),
4015 _('[-fC] [NAME]')),
4012 "branches":
4016 "branches":
4013 (branches,
4017 (branches,
4014 [('a', 'active', False,
4018 [('a', 'active', False,
4015 _('show only branches that have unmerged heads')),
4019 _('show only branches that have unmerged heads')),
4016 ('c', 'closed', False,
4020 ('c', 'closed', False,
4017 _('show normal and closed branches'))],
4021 _('show normal and closed branches'))],
4018 _('[-ac]')),
4022 _('[-ac]')),
4019 "bundle":
4023 "bundle":
4020 (bundle,
4024 (bundle,
4021 [('f', 'force', None,
4025 [('f', 'force', None,
4022 _('run even when the destination is unrelated')),
4026 _('run even when the destination is unrelated')),
4023 ('r', 'rev', [],
4027 ('r', 'rev', [],
4024 _('a changeset intended to be added to the destination'),
4028 _('a changeset intended to be added to the destination'),
4025 _('REV')),
4029 _('REV')),
4026 ('b', 'branch', [],
4030 ('b', 'branch', [],
4027 _('a specific branch you would like to bundle'),
4031 _('a specific branch you would like to bundle'),
4028 _('BRANCH')),
4032 _('BRANCH')),
4029 ('', 'base', [],
4033 ('', 'base', [],
4030 _('a base changeset assumed to be available at the destination'),
4034 _('a base changeset assumed to be available at the destination'),
4031 _('REV')),
4035 _('REV')),
4032 ('a', 'all', None, _('bundle all changesets in the repository')),
4036 ('a', 'all', None, _('bundle all changesets in the repository')),
4033 ('t', 'type', 'bzip2',
4037 ('t', 'type', 'bzip2',
4034 _('bundle compression type to use'), _('TYPE')),
4038 _('bundle compression type to use'), _('TYPE')),
4035 ] + remoteopts,
4039 ] + remoteopts,
4036 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
4040 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
4037 "cat":
4041 "cat":
4038 (cat,
4042 (cat,
4039 [('o', 'output', '',
4043 [('o', 'output', '',
4040 _('print output to file with formatted name'), _('FORMAT')),
4044 _('print output to file with formatted name'), _('FORMAT')),
4041 ('r', 'rev', '',
4045 ('r', 'rev', '',
4042 _('print the given revision'), _('REV')),
4046 _('print the given revision'), _('REV')),
4043 ('', 'decode', None, _('apply any matching decode filter')),
4047 ('', 'decode', None, _('apply any matching decode filter')),
4044 ] + walkopts,
4048 ] + walkopts,
4045 _('[OPTION]... FILE...')),
4049 _('[OPTION]... FILE...')),
4046 "^clone":
4050 "^clone":
4047 (clone,
4051 (clone,
4048 [('U', 'noupdate', None,
4052 [('U', 'noupdate', None,
4049 _('the clone will include an empty working copy (only a repository)')),
4053 _('the clone will include an empty working copy (only a repository)')),
4050 ('u', 'updaterev', '',
4054 ('u', 'updaterev', '',
4051 _('revision, tag or branch to check out'), _('REV')),
4055 _('revision, tag or branch to check out'), _('REV')),
4052 ('r', 'rev', [],
4056 ('r', 'rev', [],
4053 _('include the specified changeset'), _('REV')),
4057 _('include the specified changeset'), _('REV')),
4054 ('b', 'branch', [],
4058 ('b', 'branch', [],
4055 _('clone only the specified branch'), _('BRANCH')),
4059 _('clone only the specified branch'), _('BRANCH')),
4056 ('', 'pull', None, _('use pull protocol to copy metadata')),
4060 ('', 'pull', None, _('use pull protocol to copy metadata')),
4057 ('', 'uncompressed', None,
4061 ('', 'uncompressed', None,
4058 _('use uncompressed transfer (fast over LAN)')),
4062 _('use uncompressed transfer (fast over LAN)')),
4059 ] + remoteopts,
4063 ] + remoteopts,
4060 _('[OPTION]... SOURCE [DEST]')),
4064 _('[OPTION]... SOURCE [DEST]')),
4061 "^commit|ci":
4065 "^commit|ci":
4062 (commit,
4066 (commit,
4063 [('A', 'addremove', None,
4067 [('A', 'addremove', None,
4064 _('mark new/missing files as added/removed before committing')),
4068 _('mark new/missing files as added/removed before committing')),
4065 ('', 'close-branch', None,
4069 ('', 'close-branch', None,
4066 _('mark a branch as closed, hiding it from the branch list')),
4070 _('mark a branch as closed, hiding it from the branch list')),
4067 ] + walkopts + commitopts + commitopts2,
4071 ] + walkopts + commitopts + commitopts2,
4068 _('[OPTION]... [FILE]...')),
4072 _('[OPTION]... [FILE]...')),
4069 "copy|cp":
4073 "copy|cp":
4070 (copy,
4074 (copy,
4071 [('A', 'after', None, _('record a copy that has already occurred')),
4075 [('A', 'after', None, _('record a copy that has already occurred')),
4072 ('f', 'force', None,
4076 ('f', 'force', None,
4073 _('forcibly copy over an existing managed file')),
4077 _('forcibly copy over an existing managed file')),
4074 ] + walkopts + dryrunopts,
4078 ] + walkopts + dryrunopts,
4075 _('[OPTION]... [SOURCE]... DEST')),
4079 _('[OPTION]... [SOURCE]... DEST')),
4076 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
4080 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
4077 "debugbuilddag":
4081 "debugbuilddag":
4078 (debugbuilddag,
4082 (debugbuilddag,
4079 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
4083 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
4080 ('a', 'appended-file', None, _('add single file all revs append to')),
4084 ('a', 'appended-file', None, _('add single file all revs append to')),
4081 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
4085 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
4082 ('n', 'new-file', None, _('add new file at each rev')),
4086 ('n', 'new-file', None, _('add new file at each rev')),
4083 ],
4087 ],
4084 _('[OPTION]... TEXT')),
4088 _('[OPTION]... TEXT')),
4085 "debugcheckstate": (debugcheckstate, [], ''),
4089 "debugcheckstate": (debugcheckstate, [], ''),
4086 "debugcommands": (debugcommands, [], _('[COMMAND]')),
4090 "debugcommands": (debugcommands, [], _('[COMMAND]')),
4087 "debugcomplete":
4091 "debugcomplete":
4088 (debugcomplete,
4092 (debugcomplete,
4089 [('o', 'options', None, _('show the command options'))],
4093 [('o', 'options', None, _('show the command options'))],
4090 _('[-o] CMD')),
4094 _('[-o] CMD')),
4091 "debugdag":
4095 "debugdag":
4092 (debugdag,
4096 (debugdag,
4093 [('t', 'tags', None, _('use tags as labels')),
4097 [('t', 'tags', None, _('use tags as labels')),
4094 ('b', 'branches', None, _('annotate with branch names')),
4098 ('b', 'branches', None, _('annotate with branch names')),
4095 ('', 'dots', None, _('use dots for runs')),
4099 ('', 'dots', None, _('use dots for runs')),
4096 ('s', 'spaces', None, _('separate elements by spaces')),
4100 ('s', 'spaces', None, _('separate elements by spaces')),
4097 ],
4101 ],
4098 _('[OPTION]... [FILE [REV]...]')),
4102 _('[OPTION]... [FILE [REV]...]')),
4099 "debugdate":
4103 "debugdate":
4100 (debugdate,
4104 (debugdate,
4101 [('e', 'extended', None, _('try extended date formats'))],
4105 [('e', 'extended', None, _('try extended date formats'))],
4102 _('[-e] DATE [RANGE]')),
4106 _('[-e] DATE [RANGE]')),
4103 "debugdata": (debugdata, [], _('FILE REV')),
4107 "debugdata": (debugdata, [], _('FILE REV')),
4104 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
4108 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
4105 "debugindex": (debugindex, [], _('FILE')),
4109 "debugindex": (debugindex, [], _('FILE')),
4106 "debugindexdot": (debugindexdot, [], _('FILE')),
4110 "debugindexdot": (debugindexdot, [], _('FILE')),
4107 "debuginstall": (debuginstall, [], ''),
4111 "debuginstall": (debuginstall, [], ''),
4108 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4112 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4109 "debugrebuildstate":
4113 "debugrebuildstate":
4110 (debugrebuildstate,
4114 (debugrebuildstate,
4111 [('r', 'rev', '',
4115 [('r', 'rev', '',
4112 _('revision to rebuild to'), _('REV'))],
4116 _('revision to rebuild to'), _('REV'))],
4113 _('[-r REV] [REV]')),
4117 _('[-r REV] [REV]')),
4114 "debugrename":
4118 "debugrename":
4115 (debugrename,
4119 (debugrename,
4116 [('r', 'rev', '',
4120 [('r', 'rev', '',
4117 _('revision to debug'), _('REV'))],
4121 _('revision to debug'), _('REV'))],
4118 _('[-r REV] FILE')),
4122 _('[-r REV] FILE')),
4119 "debugrevspec":
4123 "debugrevspec":
4120 (debugrevspec, [], ('REVSPEC')),
4124 (debugrevspec, [], ('REVSPEC')),
4121 "debugsetparents":
4125 "debugsetparents":
4122 (debugsetparents, [], _('REV1 [REV2]')),
4126 (debugsetparents, [], _('REV1 [REV2]')),
4123 "debugstate":
4127 "debugstate":
4124 (debugstate,
4128 (debugstate,
4125 [('', 'nodates', None, _('do not display the saved mtime'))],
4129 [('', 'nodates', None, _('do not display the saved mtime'))],
4126 _('[OPTION]...')),
4130 _('[OPTION]...')),
4127 "debugsub":
4131 "debugsub":
4128 (debugsub,
4132 (debugsub,
4129 [('r', 'rev', '',
4133 [('r', 'rev', '',
4130 _('revision to check'), _('REV'))],
4134 _('revision to check'), _('REV'))],
4131 _('[-r REV] [REV]')),
4135 _('[-r REV] [REV]')),
4132 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
4136 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
4133 "^diff":
4137 "^diff":
4134 (diff,
4138 (diff,
4135 [('r', 'rev', [],
4139 [('r', 'rev', [],
4136 _('revision'), _('REV')),
4140 _('revision'), _('REV')),
4137 ('c', 'change', '',
4141 ('c', 'change', '',
4138 _('change made by revision'), _('REV'))
4142 _('change made by revision'), _('REV'))
4139 ] + diffopts + diffopts2 + walkopts,
4143 ] + diffopts + diffopts2 + walkopts,
4140 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')),
4144 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')),
4141 "^export":
4145 "^export":
4142 (export,
4146 (export,
4143 [('o', 'output', '',
4147 [('o', 'output', '',
4144 _('print output to file with formatted name'), _('FORMAT')),
4148 _('print output to file with formatted name'), _('FORMAT')),
4145 ('', 'switch-parent', None, _('diff against the second parent')),
4149 ('', 'switch-parent', None, _('diff against the second parent')),
4146 ('r', 'rev', [],
4150 ('r', 'rev', [],
4147 _('revisions to export'), _('REV')),
4151 _('revisions to export'), _('REV')),
4148 ] + diffopts,
4152 ] + diffopts,
4149 _('[OPTION]... [-o OUTFILESPEC] REV...')),
4153 _('[OPTION]... [-o OUTFILESPEC] REV...')),
4150 "^forget":
4154 "^forget":
4151 (forget,
4155 (forget,
4152 [] + walkopts,
4156 [] + walkopts,
4153 _('[OPTION]... FILE...')),
4157 _('[OPTION]... FILE...')),
4154 "grep":
4158 "grep":
4155 (grep,
4159 (grep,
4156 [('0', 'print0', None, _('end fields with NUL')),
4160 [('0', 'print0', None, _('end fields with NUL')),
4157 ('', 'all', None, _('print all revisions that match')),
4161 ('', 'all', None, _('print all revisions that match')),
4158 ('f', 'follow', None,
4162 ('f', 'follow', None,
4159 _('follow changeset history,'
4163 _('follow changeset history,'
4160 ' or file history across copies and renames')),
4164 ' or file history across copies and renames')),
4161 ('i', 'ignore-case', None, _('ignore case when matching')),
4165 ('i', 'ignore-case', None, _('ignore case when matching')),
4162 ('l', 'files-with-matches', None,
4166 ('l', 'files-with-matches', None,
4163 _('print only filenames and revisions that match')),
4167 _('print only filenames and revisions that match')),
4164 ('n', 'line-number', None, _('print matching line numbers')),
4168 ('n', 'line-number', None, _('print matching line numbers')),
4165 ('r', 'rev', [],
4169 ('r', 'rev', [],
4166 _('only search files changed within revision range'), _('REV')),
4170 _('only search files changed within revision range'), _('REV')),
4167 ('u', 'user', None, _('list the author (long with -v)')),
4171 ('u', 'user', None, _('list the author (long with -v)')),
4168 ('d', 'date', None, _('list the date (short with -q)')),
4172 ('d', 'date', None, _('list the date (short with -q)')),
4169 ] + walkopts,
4173 ] + walkopts,
4170 _('[OPTION]... PATTERN [FILE]...')),
4174 _('[OPTION]... PATTERN [FILE]...')),
4171 "heads":
4175 "heads":
4172 (heads,
4176 (heads,
4173 [('r', 'rev', '',
4177 [('r', 'rev', '',
4174 _('show only heads which are descendants of REV'), _('REV')),
4178 _('show only heads which are descendants of REV'), _('REV')),
4175 ('t', 'topo', False, _('show topological heads only')),
4179 ('t', 'topo', False, _('show topological heads only')),
4176 ('a', 'active', False,
4180 ('a', 'active', False,
4177 _('show active branchheads only [DEPRECATED]')),
4181 _('show active branchheads only [DEPRECATED]')),
4178 ('c', 'closed', False,
4182 ('c', 'closed', False,
4179 _('show normal and closed branch heads')),
4183 _('show normal and closed branch heads')),
4180 ] + templateopts,
4184 ] + templateopts,
4181 _('[-ac] [-r REV] [REV]...')),
4185 _('[-ac] [-r REV] [REV]...')),
4182 "help": (help_, [], _('[TOPIC]')),
4186 "help": (help_, [], _('[TOPIC]')),
4183 "identify|id":
4187 "identify|id":
4184 (identify,
4188 (identify,
4185 [('r', 'rev', '',
4189 [('r', 'rev', '',
4186 _('identify the specified revision'), _('REV')),
4190 _('identify the specified revision'), _('REV')),
4187 ('n', 'num', None, _('show local revision number')),
4191 ('n', 'num', None, _('show local revision number')),
4188 ('i', 'id', None, _('show global revision id')),
4192 ('i', 'id', None, _('show global revision id')),
4189 ('b', 'branch', None, _('show branch')),
4193 ('b', 'branch', None, _('show branch')),
4190 ('t', 'tags', None, _('show tags'))],
4194 ('t', 'tags', None, _('show tags'))],
4191 _('[-nibt] [-r REV] [SOURCE]')),
4195 _('[-nibt] [-r REV] [SOURCE]')),
4192 "import|patch":
4196 "import|patch":
4193 (import_,
4197 (import_,
4194 [('p', 'strip', 1,
4198 [('p', 'strip', 1,
4195 _('directory strip option for patch. This has the same '
4199 _('directory strip option for patch. This has the same '
4196 'meaning as the corresponding patch option'),
4200 'meaning as the corresponding patch option'),
4197 _('NUM')),
4201 _('NUM')),
4198 ('b', 'base', '',
4202 ('b', 'base', '',
4199 _('base path'), _('PATH')),
4203 _('base path'), _('PATH')),
4200 ('f', 'force', None,
4204 ('f', 'force', None,
4201 _('skip check for outstanding uncommitted changes')),
4205 _('skip check for outstanding uncommitted changes')),
4202 ('', 'no-commit', None,
4206 ('', 'no-commit', None,
4203 _("don't commit, just update the working directory")),
4207 _("don't commit, just update the working directory")),
4204 ('', 'exact', None,
4208 ('', 'exact', None,
4205 _('apply patch to the nodes from which it was generated')),
4209 _('apply patch to the nodes from which it was generated')),
4206 ('', 'import-branch', None,
4210 ('', 'import-branch', None,
4207 _('use any branch information in patch (implied by --exact)'))] +
4211 _('use any branch information in patch (implied by --exact)'))] +
4208 commitopts + commitopts2 + similarityopts,
4212 commitopts + commitopts2 + similarityopts,
4209 _('[OPTION]... PATCH...')),
4213 _('[OPTION]... PATCH...')),
4210 "incoming|in":
4214 "incoming|in":
4211 (incoming,
4215 (incoming,
4212 [('f', 'force', None,
4216 [('f', 'force', None,
4213 _('run even if remote repository is unrelated')),
4217 _('run even if remote repository is unrelated')),
4214 ('n', 'newest-first', None, _('show newest record first')),
4218 ('n', 'newest-first', None, _('show newest record first')),
4215 ('', 'bundle', '',
4219 ('', 'bundle', '',
4216 _('file to store the bundles into'), _('FILE')),
4220 _('file to store the bundles into'), _('FILE')),
4217 ('r', 'rev', [],
4221 ('r', 'rev', [],
4218 _('a remote changeset intended to be added'), _('REV')),
4222 _('a remote changeset intended to be added'), _('REV')),
4219 ('b', 'branch', [],
4223 ('b', 'branch', [],
4220 _('a specific branch you would like to pull'), _('BRANCH')),
4224 _('a specific branch you would like to pull'), _('BRANCH')),
4221 ] + logopts + remoteopts,
4225 ] + logopts + remoteopts,
4222 _('[-p] [-n] [-M] [-f] [-r REV]...'
4226 _('[-p] [-n] [-M] [-f] [-r REV]...'
4223 ' [--bundle FILENAME] [SOURCE]')),
4227 ' [--bundle FILENAME] [SOURCE]')),
4224 "^init":
4228 "^init":
4225 (init,
4229 (init,
4226 remoteopts,
4230 remoteopts,
4227 _('[-e CMD] [--remotecmd CMD] [DEST]')),
4231 _('[-e CMD] [--remotecmd CMD] [DEST]')),
4228 "locate":
4232 "locate":
4229 (locate,
4233 (locate,
4230 [('r', 'rev', '',
4234 [('r', 'rev', '',
4231 _('search the repository as it is in REV'), _('REV')),
4235 _('search the repository as it is in REV'), _('REV')),
4232 ('0', 'print0', None,
4236 ('0', 'print0', None,
4233 _('end filenames with NUL, for use with xargs')),
4237 _('end filenames with NUL, for use with xargs')),
4234 ('f', 'fullpath', None,
4238 ('f', 'fullpath', None,
4235 _('print complete paths from the filesystem root')),
4239 _('print complete paths from the filesystem root')),
4236 ] + walkopts,
4240 ] + walkopts,
4237 _('[OPTION]... [PATTERN]...')),
4241 _('[OPTION]... [PATTERN]...')),
4238 "^log|history":
4242 "^log|history":
4239 (log,
4243 (log,
4240 [('f', 'follow', None,
4244 [('f', 'follow', None,
4241 _('follow changeset history,'
4245 _('follow changeset history,'
4242 ' or file history across copies and renames')),
4246 ' or file history across copies and renames')),
4243 ('', 'follow-first', None,
4247 ('', 'follow-first', None,
4244 _('only follow the first parent of merge changesets')),
4248 _('only follow the first parent of merge changesets')),
4245 ('d', 'date', '',
4249 ('d', 'date', '',
4246 _('show revisions matching date spec'), _('DATE')),
4250 _('show revisions matching date spec'), _('DATE')),
4247 ('C', 'copies', None, _('show copied files')),
4251 ('C', 'copies', None, _('show copied files')),
4248 ('k', 'keyword', [],
4252 ('k', 'keyword', [],
4249 _('do case-insensitive search for a given text'), _('TEXT')),
4253 _('do case-insensitive search for a given text'), _('TEXT')),
4250 ('r', 'rev', [],
4254 ('r', 'rev', [],
4251 _('show the specified revision or range'), _('REV')),
4255 _('show the specified revision or range'), _('REV')),
4252 ('', 'removed', None, _('include revisions where files were removed')),
4256 ('', 'removed', None, _('include revisions where files were removed')),
4253 ('m', 'only-merges', None, _('show only merges')),
4257 ('m', 'only-merges', None, _('show only merges')),
4254 ('u', 'user', [],
4258 ('u', 'user', [],
4255 _('revisions committed by user'), _('USER')),
4259 _('revisions committed by user'), _('USER')),
4256 ('', 'only-branch', [],
4260 ('', 'only-branch', [],
4257 _('show only changesets within the given named branch (DEPRECATED)'),
4261 _('show only changesets within the given named branch (DEPRECATED)'),
4258 _('BRANCH')),
4262 _('BRANCH')),
4259 ('b', 'branch', [],
4263 ('b', 'branch', [],
4260 _('show changesets within the given named branch'), _('BRANCH')),
4264 _('show changesets within the given named branch'), _('BRANCH')),
4261 ('P', 'prune', [],
4265 ('P', 'prune', [],
4262 _('do not display revision or any of its ancestors'), _('REV')),
4266 _('do not display revision or any of its ancestors'), _('REV')),
4263 ] + logopts + walkopts,
4267 ] + logopts + walkopts,
4264 _('[OPTION]... [FILE]')),
4268 _('[OPTION]... [FILE]')),
4265 "manifest":
4269 "manifest":
4266 (manifest,
4270 (manifest,
4267 [('r', 'rev', '',
4271 [('r', 'rev', '',
4268 _('revision to display'), _('REV'))],
4272 _('revision to display'), _('REV'))],
4269 _('[-r REV]')),
4273 _('[-r REV]')),
4270 "^merge":
4274 "^merge":
4271 (merge,
4275 (merge,
4272 [('f', 'force', None, _('force a merge with outstanding changes')),
4276 [('f', 'force', None, _('force a merge with outstanding changes')),
4273 ('r', 'rev', '',
4277 ('r', 'rev', '',
4274 _('revision to merge'), _('REV')),
4278 _('revision to merge'), _('REV')),
4275 ('P', 'preview', None,
4279 ('P', 'preview', None,
4276 _('review revisions to merge (no merge is performed)'))],
4280 _('review revisions to merge (no merge is performed)'))],
4277 _('[-P] [-f] [[-r] REV]')),
4281 _('[-P] [-f] [[-r] REV]')),
4278 "outgoing|out":
4282 "outgoing|out":
4279 (outgoing,
4283 (outgoing,
4280 [('f', 'force', None,
4284 [('f', 'force', None,
4281 _('run even when the destination is unrelated')),
4285 _('run even when the destination is unrelated')),
4282 ('r', 'rev', [],
4286 ('r', 'rev', [],
4283 _('a changeset intended to be included in the destination'),
4287 _('a changeset intended to be included in the destination'),
4284 _('REV')),
4288 _('REV')),
4285 ('n', 'newest-first', None, _('show newest record first')),
4289 ('n', 'newest-first', None, _('show newest record first')),
4286 ('b', 'branch', [],
4290 ('b', 'branch', [],
4287 _('a specific branch you would like to push'), _('BRANCH')),
4291 _('a specific branch you would like to push'), _('BRANCH')),
4288 ] + logopts + remoteopts,
4292 ] + logopts + remoteopts,
4289 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
4293 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
4290 "parents":
4294 "parents":
4291 (parents,
4295 (parents,
4292 [('r', 'rev', '',
4296 [('r', 'rev', '',
4293 _('show parents of the specified revision'), _('REV')),
4297 _('show parents of the specified revision'), _('REV')),
4294 ] + templateopts,
4298 ] + templateopts,
4295 _('[-r REV] [FILE]')),
4299 _('[-r REV] [FILE]')),
4296 "paths": (paths, [], _('[NAME]')),
4300 "paths": (paths, [], _('[NAME]')),
4297 "^pull":
4301 "^pull":
4298 (pull,
4302 (pull,
4299 [('u', 'update', None,
4303 [('u', 'update', None,
4300 _('update to new branch head if changesets were pulled')),
4304 _('update to new branch head if changesets were pulled')),
4301 ('f', 'force', None,
4305 ('f', 'force', None,
4302 _('run even when remote repository is unrelated')),
4306 _('run even when remote repository is unrelated')),
4303 ('r', 'rev', [],
4307 ('r', 'rev', [],
4304 _('a remote changeset intended to be added'), _('REV')),
4308 _('a remote changeset intended to be added'), _('REV')),
4305 ('b', 'branch', [],
4309 ('b', 'branch', [],
4306 _('a specific branch you would like to pull'), _('BRANCH')),
4310 _('a specific branch you would like to pull'), _('BRANCH')),
4307 ] + remoteopts,
4311 ] + remoteopts,
4308 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
4312 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
4309 "^push":
4313 "^push":
4310 (push,
4314 (push,
4311 [('f', 'force', None, _('force push')),
4315 [('f', 'force', None, _('force push')),
4312 ('r', 'rev', [],
4316 ('r', 'rev', [],
4313 _('a changeset intended to be included in the destination'),
4317 _('a changeset intended to be included in the destination'),
4314 _('REV')),
4318 _('REV')),
4315 ('b', 'branch', [],
4319 ('b', 'branch', [],
4316 _('a specific branch you would like to push'), _('BRANCH')),
4320 _('a specific branch you would like to push'), _('BRANCH')),
4317 ('', 'new-branch', False, _('allow pushing a new branch')),
4321 ('', 'new-branch', False, _('allow pushing a new branch')),
4318 ] + remoteopts,
4322 ] + remoteopts,
4319 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
4323 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
4320 "recover": (recover, []),
4324 "recover": (recover, []),
4321 "^remove|rm":
4325 "^remove|rm":
4322 (remove,
4326 (remove,
4323 [('A', 'after', None, _('record delete for missing files')),
4327 [('A', 'after', None, _('record delete for missing files')),
4324 ('f', 'force', None,
4328 ('f', 'force', None,
4325 _('remove (and delete) file even if added or modified')),
4329 _('remove (and delete) file even if added or modified')),
4326 ] + walkopts,
4330 ] + walkopts,
4327 _('[OPTION]... FILE...')),
4331 _('[OPTION]... FILE...')),
4328 "rename|mv":
4332 "rename|mv":
4329 (rename,
4333 (rename,
4330 [('A', 'after', None, _('record a rename that has already occurred')),
4334 [('A', 'after', None, _('record a rename that has already occurred')),
4331 ('f', 'force', None,
4335 ('f', 'force', None,
4332 _('forcibly copy over an existing managed file')),
4336 _('forcibly copy over an existing managed file')),
4333 ] + walkopts + dryrunopts,
4337 ] + walkopts + dryrunopts,
4334 _('[OPTION]... SOURCE... DEST')),
4338 _('[OPTION]... SOURCE... DEST')),
4335 "resolve":
4339 "resolve":
4336 (resolve,
4340 (resolve,
4337 [('a', 'all', None, _('select all unresolved files')),
4341 [('a', 'all', None, _('select all unresolved files')),
4338 ('l', 'list', None, _('list state of files needing merge')),
4342 ('l', 'list', None, _('list state of files needing merge')),
4339 ('m', 'mark', None, _('mark files as resolved')),
4343 ('m', 'mark', None, _('mark files as resolved')),
4340 ('u', 'unmark', None, _('unmark files as resolved')),
4344 ('u', 'unmark', None, _('unmark files as resolved')),
4341 ('n', 'no-status', None, _('hide status prefix'))]
4345 ('n', 'no-status', None, _('hide status prefix'))]
4342 + walkopts,
4346 + walkopts,
4343 _('[OPTION]... [FILE]...')),
4347 _('[OPTION]... [FILE]...')),
4344 "revert":
4348 "revert":
4345 (revert,
4349 (revert,
4346 [('a', 'all', None, _('revert all changes when no arguments given')),
4350 [('a', 'all', None, _('revert all changes when no arguments given')),
4347 ('d', 'date', '',
4351 ('d', 'date', '',
4348 _('tipmost revision matching date'), _('DATE')),
4352 _('tipmost revision matching date'), _('DATE')),
4349 ('r', 'rev', '',
4353 ('r', 'rev', '',
4350 _('revert to the specified revision'), _('REV')),
4354 _('revert to the specified revision'), _('REV')),
4351 ('', 'no-backup', None, _('do not save backup copies of files')),
4355 ('', 'no-backup', None, _('do not save backup copies of files')),
4352 ] + walkopts + dryrunopts,
4356 ] + walkopts + dryrunopts,
4353 _('[OPTION]... [-r REV] [NAME]...')),
4357 _('[OPTION]... [-r REV] [NAME]...')),
4354 "rollback": (rollback, dryrunopts),
4358 "rollback": (rollback, dryrunopts),
4355 "root": (root, []),
4359 "root": (root, []),
4356 "^serve":
4360 "^serve":
4357 (serve,
4361 (serve,
4358 [('A', 'accesslog', '',
4362 [('A', 'accesslog', '',
4359 _('name of access log file to write to'), _('FILE')),
4363 _('name of access log file to write to'), _('FILE')),
4360 ('d', 'daemon', None, _('run server in background')),
4364 ('d', 'daemon', None, _('run server in background')),
4361 ('', 'daemon-pipefds', '',
4365 ('', 'daemon-pipefds', '',
4362 _('used internally by daemon mode'), _('NUM')),
4366 _('used internally by daemon mode'), _('NUM')),
4363 ('E', 'errorlog', '',
4367 ('E', 'errorlog', '',
4364 _('name of error log file to write to'), _('FILE')),
4368 _('name of error log file to write to'), _('FILE')),
4365 # use string type, then we can check if something was passed
4369 # use string type, then we can check if something was passed
4366 ('p', 'port', '',
4370 ('p', 'port', '',
4367 _('port to listen on (default: 8000)'), _('PORT')),
4371 _('port to listen on (default: 8000)'), _('PORT')),
4368 ('a', 'address', '',
4372 ('a', 'address', '',
4369 _('address to listen on (default: all interfaces)'), _('ADDR')),
4373 _('address to listen on (default: all interfaces)'), _('ADDR')),
4370 ('', 'prefix', '',
4374 ('', 'prefix', '',
4371 _('prefix path to serve from (default: server root)'), _('PREFIX')),
4375 _('prefix path to serve from (default: server root)'), _('PREFIX')),
4372 ('n', 'name', '',
4376 ('n', 'name', '',
4373 _('name to show in web pages (default: working directory)'),
4377 _('name to show in web pages (default: working directory)'),
4374 _('NAME')),
4378 _('NAME')),
4375 ('', 'web-conf', '',
4379 ('', 'web-conf', '',
4376 _('name of the hgweb config file (serve more than one repository)'),
4380 _('name of the hgweb config file (serve more than one repository)'),
4377 _('FILE')),
4381 _('FILE')),
4378 ('', 'webdir-conf', '',
4382 ('', 'webdir-conf', '',
4379 _('name of the hgweb config file (DEPRECATED)'), _('FILE')),
4383 _('name of the hgweb config file (DEPRECATED)'), _('FILE')),
4380 ('', 'pid-file', '',
4384 ('', 'pid-file', '',
4381 _('name of file to write process ID to'), _('FILE')),
4385 _('name of file to write process ID to'), _('FILE')),
4382 ('', 'stdio', None, _('for remote clients')),
4386 ('', 'stdio', None, _('for remote clients')),
4383 ('t', 'templates', '',
4387 ('t', 'templates', '',
4384 _('web templates to use'), _('TEMPLATE')),
4388 _('web templates to use'), _('TEMPLATE')),
4385 ('', 'style', '',
4389 ('', 'style', '',
4386 _('template style to use'), _('STYLE')),
4390 _('template style to use'), _('STYLE')),
4387 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4391 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4388 ('', 'certificate', '',
4392 ('', 'certificate', '',
4389 _('SSL certificate file'), _('FILE'))],
4393 _('SSL certificate file'), _('FILE'))],
4390 _('[OPTION]...')),
4394 _('[OPTION]...')),
4391 "showconfig|debugconfig":
4395 "showconfig|debugconfig":
4392 (showconfig,
4396 (showconfig,
4393 [('u', 'untrusted', None, _('show untrusted configuration options'))],
4397 [('u', 'untrusted', None, _('show untrusted configuration options'))],
4394 _('[-u] [NAME]...')),
4398 _('[-u] [NAME]...')),
4395 "^summary|sum":
4399 "^summary|sum":
4396 (summary,
4400 (summary,
4397 [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
4401 [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
4398 "^status|st":
4402 "^status|st":
4399 (status,
4403 (status,
4400 [('A', 'all', None, _('show status of all files')),
4404 [('A', 'all', None, _('show status of all files')),
4401 ('m', 'modified', None, _('show only modified files')),
4405 ('m', 'modified', None, _('show only modified files')),
4402 ('a', 'added', None, _('show only added files')),
4406 ('a', 'added', None, _('show only added files')),
4403 ('r', 'removed', None, _('show only removed files')),
4407 ('r', 'removed', None, _('show only removed files')),
4404 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4408 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4405 ('c', 'clean', None, _('show only files without changes')),
4409 ('c', 'clean', None, _('show only files without changes')),
4406 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4410 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4407 ('i', 'ignored', None, _('show only ignored files')),
4411 ('i', 'ignored', None, _('show only ignored files')),
4408 ('n', 'no-status', None, _('hide status prefix')),
4412 ('n', 'no-status', None, _('hide status prefix')),
4409 ('C', 'copies', None, _('show source of copied files')),
4413 ('C', 'copies', None, _('show source of copied files')),
4410 ('0', 'print0', None,
4414 ('0', 'print0', None,
4411 _('end filenames with NUL, for use with xargs')),
4415 _('end filenames with NUL, for use with xargs')),
4412 ('', 'rev', [],
4416 ('', 'rev', [],
4413 _('show difference from revision'), _('REV')),
4417 _('show difference from revision'), _('REV')),
4414 ('', 'change', '',
4418 ('', 'change', '',
4415 _('list the changed files of a revision'), _('REV')),
4419 _('list the changed files of a revision'), _('REV')),
4416 ] + walkopts,
4420 ] + walkopts,
4417 _('[OPTION]... [FILE]...')),
4421 _('[OPTION]... [FILE]...')),
4418 "tag":
4422 "tag":
4419 (tag,
4423 (tag,
4420 [('f', 'force', None, _('replace existing tag')),
4424 [('f', 'force', None, _('replace existing tag')),
4421 ('l', 'local', None, _('make the tag local')),
4425 ('l', 'local', None, _('make the tag local')),
4422 ('r', 'rev', '',
4426 ('r', 'rev', '',
4423 _('revision to tag'), _('REV')),
4427 _('revision to tag'), _('REV')),
4424 ('', 'remove', None, _('remove a tag')),
4428 ('', 'remove', None, _('remove a tag')),
4425 # -l/--local is already there, commitopts cannot be used
4429 # -l/--local is already there, commitopts cannot be used
4426 ('e', 'edit', None, _('edit commit message')),
4430 ('e', 'edit', None, _('edit commit message')),
4427 ('m', 'message', '',
4431 ('m', 'message', '',
4428 _('use <text> as commit message'), _('TEXT')),
4432 _('use <text> as commit message'), _('TEXT')),
4429 ] + commitopts2,
4433 ] + commitopts2,
4430 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
4434 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
4431 "tags": (tags, [], ''),
4435 "tags": (tags, [], ''),
4432 "tip":
4436 "tip":
4433 (tip,
4437 (tip,
4434 [('p', 'patch', None, _('show patch')),
4438 [('p', 'patch', None, _('show patch')),
4435 ('g', 'git', None, _('use git extended diff format')),
4439 ('g', 'git', None, _('use git extended diff format')),
4436 ] + templateopts,
4440 ] + templateopts,
4437 _('[-p] [-g]')),
4441 _('[-p] [-g]')),
4438 "unbundle":
4442 "unbundle":
4439 (unbundle,
4443 (unbundle,
4440 [('u', 'update', None,
4444 [('u', 'update', None,
4441 _('update to new branch head if changesets were unbundled'))],
4445 _('update to new branch head if changesets were unbundled'))],
4442 _('[-u] FILE...')),
4446 _('[-u] FILE...')),
4443 "^update|up|checkout|co":
4447 "^update|up|checkout|co":
4444 (update,
4448 (update,
4445 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
4449 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
4446 ('c', 'check', None, _('check for uncommitted changes')),
4450 ('c', 'check', None, _('check for uncommitted changes')),
4447 ('d', 'date', '',
4451 ('d', 'date', '',
4448 _('tipmost revision matching date'), _('DATE')),
4452 _('tipmost revision matching date'), _('DATE')),
4449 ('r', 'rev', '',
4453 ('r', 'rev', '',
4450 _('revision'), _('REV'))],
4454 _('revision'), _('REV'))],
4451 _('[-c] [-C] [-d DATE] [[-r] REV]')),
4455 _('[-c] [-C] [-d DATE] [[-r] REV]')),
4452 "verify": (verify, []),
4456 "verify": (verify, []),
4453 "version": (version_, []),
4457 "version": (version_, []),
4454 }
4458 }
4455
4459
4456 norepo = ("clone init version help debugcommands debugcomplete debugdata"
4460 norepo = ("clone init version help debugcommands debugcomplete debugdata"
4457 " debugindex debugindexdot debugdate debuginstall debugfsinfo"
4461 " debugindex debugindexdot debugdate debuginstall debugfsinfo"
4458 " debugpushkey")
4462 " debugpushkey")
4459 optionalrepo = ("identify paths serve showconfig debugancestor debugdag")
4463 optionalrepo = ("identify paths serve showconfig debugancestor debugdag")
@@ -1,670 +1,678
1 Mercurial Distributed SCM
1 Mercurial Distributed SCM
2
2
3 basic commands:
3 basic commands:
4
4
5 add add the specified files on the next commit
5 add add the specified files on the next commit
6 annotate show changeset information by line for each file
6 annotate show changeset information by line for each file
7 clone make a copy of an existing repository
7 clone make a copy of an existing repository
8 commit commit the specified files or all outstanding changes
8 commit commit the specified files or all outstanding changes
9 diff diff repository (or selected files)
9 diff diff repository (or selected files)
10 export dump the header and diffs for one or more changesets
10 export dump the header and diffs for one or more changesets
11 forget forget the specified files on the next commit
11 forget forget the specified files on the next commit
12 init create a new repository in the given directory
12 init create a new repository in the given directory
13 log show revision history of entire repository or files
13 log show revision history of entire repository or files
14 merge merge working directory with another revision
14 merge merge working directory with another revision
15 pull pull changes from the specified source
15 pull pull changes from the specified source
16 push push changes to the specified destination
16 push push changes to the specified destination
17 remove remove the specified files on the next commit
17 remove remove the specified files on the next commit
18 serve start stand-alone webserver
18 serve start stand-alone webserver
19 status show changed files in the working directory
19 status show changed files in the working directory
20 summary summarize working directory state
20 summary summarize working directory state
21 update update working directory (or switch revisions)
21 update update working directory (or switch revisions)
22
22
23 use "hg help" for the full list of commands or "hg -v" for details
23 use "hg help" for the full list of commands or "hg -v" for details
24 add add the specified files on the next commit
24 add add the specified files on the next commit
25 annotate show changeset information by line for each file
25 annotate show changeset information by line for each file
26 clone make a copy of an existing repository
26 clone make a copy of an existing repository
27 commit commit the specified files or all outstanding changes
27 commit commit the specified files or all outstanding changes
28 diff diff repository (or selected files)
28 diff diff repository (or selected files)
29 export dump the header and diffs for one or more changesets
29 export dump the header and diffs for one or more changesets
30 forget forget the specified files on the next commit
30 forget forget the specified files on the next commit
31 init create a new repository in the given directory
31 init create a new repository in the given directory
32 log show revision history of entire repository or files
32 log show revision history of entire repository or files
33 merge merge working directory with another revision
33 merge merge working directory with another revision
34 pull pull changes from the specified source
34 pull pull changes from the specified source
35 push push changes to the specified destination
35 push push changes to the specified destination
36 remove remove the specified files on the next commit
36 remove remove the specified files on the next commit
37 serve start stand-alone webserver
37 serve start stand-alone webserver
38 status show changed files in the working directory
38 status show changed files in the working directory
39 summary summarize working directory state
39 summary summarize working directory state
40 update update working directory (or switch revisions)
40 update update working directory (or switch revisions)
41 Mercurial Distributed SCM
41 Mercurial Distributed SCM
42
42
43 list of commands:
43 list of commands:
44
44
45 add add the specified files on the next commit
45 add add the specified files on the next commit
46 addremove add all new files, delete all missing files
46 addremove add all new files, delete all missing files
47 annotate show changeset information by line for each file
47 annotate show changeset information by line for each file
48 archive create an unversioned archive of a repository revision
48 archive create an unversioned archive of a repository revision
49 backout reverse effect of earlier changeset
49 backout reverse effect of earlier changeset
50 bisect subdivision search of changesets
50 bisect subdivision search of changesets
51 branch set or show the current branch name
51 branch set or show the current branch name
52 branches list repository named branches
52 branches list repository named branches
53 bundle create a changegroup file
53 bundle create a changegroup file
54 cat output the current or given revision of files
54 cat output the current or given revision of files
55 clone make a copy of an existing repository
55 clone make a copy of an existing repository
56 commit commit the specified files or all outstanding changes
56 commit commit the specified files or all outstanding changes
57 copy mark files as copied for the next commit
57 copy mark files as copied for the next commit
58 diff diff repository (or selected files)
58 diff diff repository (or selected files)
59 export dump the header and diffs for one or more changesets
59 export dump the header and diffs for one or more changesets
60 forget forget the specified files on the next commit
60 forget forget the specified files on the next commit
61 grep search for a pattern in specified files and revisions
61 grep search for a pattern in specified files and revisions
62 heads show current repository heads or show branch heads
62 heads show current repository heads or show branch heads
63 help show help for a given topic or a help overview
63 help show help for a given topic or a help overview
64 identify identify the working copy or specified revision
64 identify identify the working copy or specified revision
65 import import an ordered set of patches
65 import import an ordered set of patches
66 incoming show new changesets found in source
66 incoming show new changesets found in source
67 init create a new repository in the given directory
67 init create a new repository in the given directory
68 locate locate files matching specific patterns
68 locate locate files matching specific patterns
69 log show revision history of entire repository or files
69 log show revision history of entire repository or files
70 manifest output the current or given revision of the project manifest
70 manifest output the current or given revision of the project manifest
71 merge merge working directory with another revision
71 merge merge working directory with another revision
72 outgoing show changesets not found in the destination
72 outgoing show changesets not found in the destination
73 parents show the parents of the working directory or revision
73 parents show the parents of the working directory or revision
74 paths show aliases for remote repositories
74 paths show aliases for remote repositories
75 pull pull changes from the specified source
75 pull pull changes from the specified source
76 push push changes to the specified destination
76 push push changes to the specified destination
77 recover roll back an interrupted transaction
77 recover roll back an interrupted transaction
78 remove remove the specified files on the next commit
78 remove remove the specified files on the next commit
79 rename rename files; equivalent of copy + remove
79 rename rename files; equivalent of copy + remove
80 resolve various operations to help finish a merge
80 resolve various operations to help finish a merge
81 revert restore individual files or directories to an earlier state
81 revert restore individual files or directories to an earlier state
82 rollback roll back the last transaction (dangerous)
82 rollback roll back the last transaction (dangerous)
83 root print the root (top) of the current working directory
83 root print the root (top) of the current working directory
84 serve start stand-alone webserver
84 serve start stand-alone webserver
85 showconfig show combined config settings from all hgrc files
85 showconfig show combined config settings from all hgrc files
86 status show changed files in the working directory
86 status show changed files in the working directory
87 summary summarize working directory state
87 summary summarize working directory state
88 tag add one or more tags for the current or given revision
88 tag add one or more tags for the current or given revision
89 tags list repository tags
89 tags list repository tags
90 tip show the tip revision
90 tip show the tip revision
91 unbundle apply one or more changegroup files
91 unbundle apply one or more changegroup files
92 update update working directory (or switch revisions)
92 update update working directory (or switch revisions)
93 verify verify the integrity of the repository
93 verify verify the integrity of the repository
94 version output version and copyright information
94 version output version and copyright information
95
95
96 additional help topics:
96 additional help topics:
97
97
98 config Configuration Files
98 config Configuration Files
99 dates Date Formats
99 dates Date Formats
100 patterns File Name Patterns
100 patterns File Name Patterns
101 environment Environment Variables
101 environment Environment Variables
102 revisions Specifying Single Revisions
102 revisions Specifying Single Revisions
103 multirevs Specifying Multiple Revisions
103 multirevs Specifying Multiple Revisions
104 revsets Specifying Revision Sets
104 revsets Specifying Revision Sets
105 diffs Diff Formats
105 diffs Diff Formats
106 templating Template Usage
106 templating Template Usage
107 urls URL Paths
107 urls URL Paths
108 extensions Using additional features
108 extensions Using additional features
109 hgweb Configuring hgweb
109 hgweb Configuring hgweb
110 glossary Glossary
110 glossary Glossary
111
111
112 use "hg -v help" to show aliases and global options
112 use "hg -v help" to show aliases and global options
113 add add the specified files on the next commit
113 add add the specified files on the next commit
114 addremove add all new files, delete all missing files
114 addremove add all new files, delete all missing files
115 annotate show changeset information by line for each file
115 annotate show changeset information by line for each file
116 archive create an unversioned archive of a repository revision
116 archive create an unversioned archive of a repository revision
117 backout reverse effect of earlier changeset
117 backout reverse effect of earlier changeset
118 bisect subdivision search of changesets
118 bisect subdivision search of changesets
119 branch set or show the current branch name
119 branch set or show the current branch name
120 branches list repository named branches
120 branches list repository named branches
121 bundle create a changegroup file
121 bundle create a changegroup file
122 cat output the current or given revision of files
122 cat output the current or given revision of files
123 clone make a copy of an existing repository
123 clone make a copy of an existing repository
124 commit commit the specified files or all outstanding changes
124 commit commit the specified files or all outstanding changes
125 copy mark files as copied for the next commit
125 copy mark files as copied for the next commit
126 diff diff repository (or selected files)
126 diff diff repository (or selected files)
127 export dump the header and diffs for one or more changesets
127 export dump the header and diffs for one or more changesets
128 forget forget the specified files on the next commit
128 forget forget the specified files on the next commit
129 grep search for a pattern in specified files and revisions
129 grep search for a pattern in specified files and revisions
130 heads show current repository heads or show branch heads
130 heads show current repository heads or show branch heads
131 help show help for a given topic or a help overview
131 help show help for a given topic or a help overview
132 identify identify the working copy or specified revision
132 identify identify the working copy or specified revision
133 import import an ordered set of patches
133 import import an ordered set of patches
134 incoming show new changesets found in source
134 incoming show new changesets found in source
135 init create a new repository in the given directory
135 init create a new repository in the given directory
136 locate locate files matching specific patterns
136 locate locate files matching specific patterns
137 log show revision history of entire repository or files
137 log show revision history of entire repository or files
138 manifest output the current or given revision of the project manifest
138 manifest output the current or given revision of the project manifest
139 merge merge working directory with another revision
139 merge merge working directory with another revision
140 outgoing show changesets not found in the destination
140 outgoing show changesets not found in the destination
141 parents show the parents of the working directory or revision
141 parents show the parents of the working directory or revision
142 paths show aliases for remote repositories
142 paths show aliases for remote repositories
143 pull pull changes from the specified source
143 pull pull changes from the specified source
144 push push changes to the specified destination
144 push push changes to the specified destination
145 recover roll back an interrupted transaction
145 recover roll back an interrupted transaction
146 remove remove the specified files on the next commit
146 remove remove the specified files on the next commit
147 rename rename files; equivalent of copy + remove
147 rename rename files; equivalent of copy + remove
148 resolve various operations to help finish a merge
148 resolve various operations to help finish a merge
149 revert restore individual files or directories to an earlier state
149 revert restore individual files or directories to an earlier state
150 rollback roll back the last transaction (dangerous)
150 rollback roll back the last transaction (dangerous)
151 root print the root (top) of the current working directory
151 root print the root (top) of the current working directory
152 serve start stand-alone webserver
152 serve start stand-alone webserver
153 showconfig show combined config settings from all hgrc files
153 showconfig show combined config settings from all hgrc files
154 status show changed files in the working directory
154 status show changed files in the working directory
155 summary summarize working directory state
155 summary summarize working directory state
156 tag add one or more tags for the current or given revision
156 tag add one or more tags for the current or given revision
157 tags list repository tags
157 tags list repository tags
158 tip show the tip revision
158 tip show the tip revision
159 unbundle apply one or more changegroup files
159 unbundle apply one or more changegroup files
160 update update working directory (or switch revisions)
160 update update working directory (or switch revisions)
161 verify verify the integrity of the repository
161 verify verify the integrity of the repository
162 version output version and copyright information
162 version output version and copyright information
163
163
164 additional help topics:
164 additional help topics:
165
165
166 config Configuration Files
166 config Configuration Files
167 dates Date Formats
167 dates Date Formats
168 patterns File Name Patterns
168 patterns File Name Patterns
169 environment Environment Variables
169 environment Environment Variables
170 revisions Specifying Single Revisions
170 revisions Specifying Single Revisions
171 multirevs Specifying Multiple Revisions
171 multirevs Specifying Multiple Revisions
172 revsets Specifying Revision Sets
172 revsets Specifying Revision Sets
173 diffs Diff Formats
173 diffs Diff Formats
174 templating Template Usage
174 templating Template Usage
175 urls URL Paths
175 urls URL Paths
176 extensions Using additional features
176 extensions Using additional features
177 hgweb Configuring hgweb
177 hgweb Configuring hgweb
178 glossary Glossary
178 glossary Glossary
179 %% test short command list with verbose option
179 %% test short command list with verbose option
180 Mercurial Distributed SCM (version xxx)
180 Mercurial Distributed SCM (version xxx)
181
181
182 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
182 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
183 This is free software; see the source for copying conditions. There is NO
183 This is free software; see the source for copying conditions. There is NO
184 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
184 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
185
185
186 basic commands:
186 basic commands:
187
187
188 add:
188 add:
189 add the specified files on the next commit
189 add the specified files on the next commit
190 annotate, blame:
190 annotate, blame:
191 show changeset information by line for each file
191 show changeset information by line for each file
192 clone:
192 clone:
193 make a copy of an existing repository
193 make a copy of an existing repository
194 commit, ci:
194 commit, ci:
195 commit the specified files or all outstanding changes
195 commit the specified files or all outstanding changes
196 diff:
196 diff:
197 diff repository (or selected files)
197 diff repository (or selected files)
198 export:
198 export:
199 dump the header and diffs for one or more changesets
199 dump the header and diffs for one or more changesets
200 forget:
200 forget:
201 forget the specified files on the next commit
201 forget the specified files on the next commit
202 init:
202 init:
203 create a new repository in the given directory
203 create a new repository in the given directory
204 log, history:
204 log, history:
205 show revision history of entire repository or files
205 show revision history of entire repository or files
206 merge:
206 merge:
207 merge working directory with another revision
207 merge working directory with another revision
208 pull:
208 pull:
209 pull changes from the specified source
209 pull changes from the specified source
210 push:
210 push:
211 push changes to the specified destination
211 push changes to the specified destination
212 remove, rm:
212 remove, rm:
213 remove the specified files on the next commit
213 remove the specified files on the next commit
214 serve:
214 serve:
215 start stand-alone webserver
215 start stand-alone webserver
216 status, st:
216 status, st:
217 show changed files in the working directory
217 show changed files in the working directory
218 summary, sum:
218 summary, sum:
219 summarize working directory state
219 summarize working directory state
220 update, up, checkout, co:
220 update, up, checkout, co:
221 update working directory (or switch revisions)
221 update working directory (or switch revisions)
222
222
223 global options:
223 global options:
224 -R --repository REPO repository root directory or name of overlay bundle
224 -R --repository REPO repository root directory or name of overlay bundle
225 file
225 file
226 --cwd DIR change working directory
226 --cwd DIR change working directory
227 -y --noninteractive do not prompt, assume 'yes' for any required answers
227 -y --noninteractive do not prompt, assume 'yes' for any required answers
228 -q --quiet suppress output
228 -q --quiet suppress output
229 -v --verbose enable additional output
229 -v --verbose enable additional output
230 --config CONFIG [+] set/override config option (use 'section.name=value')
230 --config CONFIG [+] set/override config option (use 'section.name=value')
231 --debug enable debugging output
231 --debug enable debugging output
232 --debugger start debugger
232 --debugger start debugger
233 --encoding ENCODE set the charset encoding (default: ascii)
233 --encoding ENCODE set the charset encoding (default: ascii)
234 --encodingmode MODE set the charset encoding mode (default: strict)
234 --encodingmode MODE set the charset encoding mode (default: strict)
235 --traceback always print a traceback on exception
235 --traceback always print a traceback on exception
236 --time time how long the command takes
236 --time time how long the command takes
237 --profile print command execution profile
237 --profile print command execution profile
238 --version output version information and exit
238 --version output version information and exit
239 -h --help display help and exit
239 -h --help display help and exit
240
240
241 [+] marked option can be specified multiple times
241 [+] marked option can be specified multiple times
242
242
243 use "hg help" for the full list of commands
243 use "hg help" for the full list of commands
244 hg add [OPTION]... [FILE]...
244 hg add [OPTION]... [FILE]...
245
245
246 add the specified files on the next commit
246 add the specified files on the next commit
247
247
248 Schedule files to be version controlled and added to the repository.
248 Schedule files to be version controlled and added to the repository.
249
249
250 The files will be added to the repository at the next commit. To undo an
250 The files will be added to the repository at the next commit. To undo an
251 add before that, see "hg forget".
251 add before that, see "hg forget".
252
252
253 If no names are given, add all files to the repository.
253 If no names are given, add all files to the repository.
254
254
255 Returns 0 if all files are successfully added.
256
255 use "hg -v help add" to show verbose help
257 use "hg -v help add" to show verbose help
256
258
257 options:
259 options:
258
260
259 -I --include PATTERN [+] include names matching the given patterns
261 -I --include PATTERN [+] include names matching the given patterns
260 -X --exclude PATTERN [+] exclude names matching the given patterns
262 -X --exclude PATTERN [+] exclude names matching the given patterns
261 -n --dry-run do not perform actions, just print output
263 -n --dry-run do not perform actions, just print output
262
264
263 [+] marked option can be specified multiple times
265 [+] marked option can be specified multiple times
264
266
265 use "hg -v help add" to show global options
267 use "hg -v help add" to show global options
266 %% verbose help for add
268 %% verbose help for add
267 hg add [OPTION]... [FILE]...
269 hg add [OPTION]... [FILE]...
268
270
269 add the specified files on the next commit
271 add the specified files on the next commit
270
272
271 Schedule files to be version controlled and added to the repository.
273 Schedule files to be version controlled and added to the repository.
272
274
273 The files will be added to the repository at the next commit. To undo an
275 The files will be added to the repository at the next commit. To undo an
274 add before that, see "hg forget".
276 add before that, see "hg forget".
275
277
276 If no names are given, add all files to the repository.
278 If no names are given, add all files to the repository.
277
279
278 An example showing how new (unknown) files are added automatically by "hg
280 An example showing how new (unknown) files are added automatically by "hg
279 add":
281 add":
280
282
281 $ ls
283 $ ls
282 foo.c
284 foo.c
283 $ hg status
285 $ hg status
284 ? foo.c
286 ? foo.c
285 $ hg add
287 $ hg add
286 adding foo.c
288 adding foo.c
287 $ hg status
289 $ hg status
288 A foo.c
290 A foo.c
289
291
292 Returns 0 if all files are successfully added.
293
290 options:
294 options:
291
295
292 -I --include PATTERN [+] include names matching the given patterns
296 -I --include PATTERN [+] include names matching the given patterns
293 -X --exclude PATTERN [+] exclude names matching the given patterns
297 -X --exclude PATTERN [+] exclude names matching the given patterns
294 -n --dry-run do not perform actions, just print output
298 -n --dry-run do not perform actions, just print output
295
299
296 global options:
300 global options:
297 -R --repository REPO repository root directory or name of overlay bundle
301 -R --repository REPO repository root directory or name of overlay bundle
298 file
302 file
299 --cwd DIR change working directory
303 --cwd DIR change working directory
300 -y --noninteractive do not prompt, assume 'yes' for any required
304 -y --noninteractive do not prompt, assume 'yes' for any required
301 answers
305 answers
302 -q --quiet suppress output
306 -q --quiet suppress output
303 -v --verbose enable additional output
307 -v --verbose enable additional output
304 --config CONFIG [+] set/override config option (use
308 --config CONFIG [+] set/override config option (use
305 'section.name=value')
309 'section.name=value')
306 --debug enable debugging output
310 --debug enable debugging output
307 --debugger start debugger
311 --debugger start debugger
308 --encoding ENCODE set the charset encoding (default: ascii)
312 --encoding ENCODE set the charset encoding (default: ascii)
309 --encodingmode MODE set the charset encoding mode (default: strict)
313 --encodingmode MODE set the charset encoding mode (default: strict)
310 --traceback always print a traceback on exception
314 --traceback always print a traceback on exception
311 --time time how long the command takes
315 --time time how long the command takes
312 --profile print command execution profile
316 --profile print command execution profile
313 --version output version information and exit
317 --version output version information and exit
314 -h --help display help and exit
318 -h --help display help and exit
315
319
316 [+] marked option can be specified multiple times
320 [+] marked option can be specified multiple times
317 %% test help option with version option
321 %% test help option with version option
318 Mercurial Distributed SCM (version xxx)
322 Mercurial Distributed SCM (version xxx)
319
323
320 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
324 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
321 This is free software; see the source for copying conditions. There is NO
325 This is free software; see the source for copying conditions. There is NO
322 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
326 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
323
327
324 hg add [OPTION]... [FILE]...
328 hg add [OPTION]... [FILE]...
325
329
326 add the specified files on the next commit
330 add the specified files on the next commit
327
331
328 Schedule files to be version controlled and added to the repository.
332 Schedule files to be version controlled and added to the repository.
329
333
330 The files will be added to the repository at the next commit. To undo an
334 The files will be added to the repository at the next commit. To undo an
331 add before that, see "hg forget".
335 add before that, see "hg forget".
332
336
333 If no names are given, add all files to the repository.
337 If no names are given, add all files to the repository.
334
338
339 Returns 0 if all files are successfully added.
340
335 use "hg -v help add" to show verbose help
341 use "hg -v help add" to show verbose help
336
342
337 options:
343 options:
338
344
339 -I --include PATTERN [+] include names matching the given patterns
345 -I --include PATTERN [+] include names matching the given patterns
340 -X --exclude PATTERN [+] exclude names matching the given patterns
346 -X --exclude PATTERN [+] exclude names matching the given patterns
341 -n --dry-run do not perform actions, just print output
347 -n --dry-run do not perform actions, just print output
342
348
343 [+] marked option can be specified multiple times
349 [+] marked option can be specified multiple times
344
350
345 use "hg -v help add" to show global options
351 use "hg -v help add" to show global options
346 hg add: option --skjdfks not recognized
352 hg add: option --skjdfks not recognized
347 hg add [OPTION]... [FILE]...
353 hg add [OPTION]... [FILE]...
348
354
349 add the specified files on the next commit
355 add the specified files on the next commit
350
356
351 Schedule files to be version controlled and added to the repository.
357 Schedule files to be version controlled and added to the repository.
352
358
353 The files will be added to the repository at the next commit. To undo an
359 The files will be added to the repository at the next commit. To undo an
354 add before that, see "hg forget".
360 add before that, see "hg forget".
355
361
356 If no names are given, add all files to the repository.
362 If no names are given, add all files to the repository.
357
363
364 Returns 0 if all files are successfully added.
365
358 use "hg -v help add" to show verbose help
366 use "hg -v help add" to show verbose help
359
367
360 options:
368 options:
361
369
362 -I --include PATTERN [+] include names matching the given patterns
370 -I --include PATTERN [+] include names matching the given patterns
363 -X --exclude PATTERN [+] exclude names matching the given patterns
371 -X --exclude PATTERN [+] exclude names matching the given patterns
364 -n --dry-run do not perform actions, just print output
372 -n --dry-run do not perform actions, just print output
365
373
366 [+] marked option can be specified multiple times
374 [+] marked option can be specified multiple times
367
375
368 use "hg -v help add" to show global options
376 use "hg -v help add" to show global options
369 %% test ambiguous command help
377 %% test ambiguous command help
370 list of commands:
378 list of commands:
371
379
372 add add the specified files on the next commit
380 add add the specified files on the next commit
373 addremove add all new files, delete all missing files
381 addremove add all new files, delete all missing files
374
382
375 use "hg -v help ad" to show aliases and global options
383 use "hg -v help ad" to show aliases and global options
376 %% test command without options
384 %% test command without options
377 hg verify
385 hg verify
378
386
379 verify the integrity of the repository
387 verify the integrity of the repository
380
388
381 Verify the integrity of the current repository.
389 Verify the integrity of the current repository.
382
390
383 This will perform an extensive check of the repository's integrity,
391 This will perform an extensive check of the repository's integrity,
384 validating the hashes and checksums of each entry in the changelog,
392 validating the hashes and checksums of each entry in the changelog,
385 manifest, and tracked files, as well as the integrity of their crosslinks
393 manifest, and tracked files, as well as the integrity of their crosslinks
386 and indices.
394 and indices.
387
395
388 Returns 0 on success, 1 if errors are encountered.
396 Returns 0 on success, 1 if errors are encountered.
389
397
390 use "hg -v help verify" to show global options
398 use "hg -v help verify" to show global options
391 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
399 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
392
400
393 diff repository (or selected files)
401 diff repository (or selected files)
394
402
395 Show differences between revisions for the specified files.
403 Show differences between revisions for the specified files.
396
404
397 Differences between files are shown using the unified diff format.
405 Differences between files are shown using the unified diff format.
398
406
399 NOTE: diff may generate unexpected results for merges, as it will default
407 NOTE: diff may generate unexpected results for merges, as it will default
400 to comparing against the working directory's first parent changeset if no
408 to comparing against the working directory's first parent changeset if no
401 revisions are specified.
409 revisions are specified.
402
410
403 When two revision arguments are given, then changes are shown between
411 When two revision arguments are given, then changes are shown between
404 those revisions. If only one revision is specified then that revision is
412 those revisions. If only one revision is specified then that revision is
405 compared to the working directory, and, when no revisions are specified,
413 compared to the working directory, and, when no revisions are specified,
406 the working directory files are compared to its parent.
414 the working directory files are compared to its parent.
407
415
408 Alternatively you can specify -c/--change with a revision to see the
416 Alternatively you can specify -c/--change with a revision to see the
409 changes in that changeset relative to its first parent.
417 changes in that changeset relative to its first parent.
410
418
411 Without the -a/--text option, diff will avoid generating diffs of files it
419 Without the -a/--text option, diff will avoid generating diffs of files it
412 detects as binary. With -a, diff will generate a diff anyway, probably
420 detects as binary. With -a, diff will generate a diff anyway, probably
413 with undesirable results.
421 with undesirable results.
414
422
415 Use the -g/--git option to generate diffs in the git extended diff format.
423 Use the -g/--git option to generate diffs in the git extended diff format.
416 For more information, read "hg help diffs".
424 For more information, read "hg help diffs".
417
425
418 Returns 0 on success.
426 Returns 0 on success.
419
427
420 options:
428 options:
421
429
422 -r --rev REV [+] revision
430 -r --rev REV [+] revision
423 -c --change REV change made by revision
431 -c --change REV change made by revision
424 -a --text treat all files as text
432 -a --text treat all files as text
425 -g --git use git extended diff format
433 -g --git use git extended diff format
426 --nodates omit dates from diff headers
434 --nodates omit dates from diff headers
427 -p --show-function show which function each change is in
435 -p --show-function show which function each change is in
428 --reverse produce a diff that undoes the changes
436 --reverse produce a diff that undoes the changes
429 -w --ignore-all-space ignore white space when comparing lines
437 -w --ignore-all-space ignore white space when comparing lines
430 -b --ignore-space-change ignore changes in the amount of white space
438 -b --ignore-space-change ignore changes in the amount of white space
431 -B --ignore-blank-lines ignore changes whose lines are all blank
439 -B --ignore-blank-lines ignore changes whose lines are all blank
432 -U --unified NUM number of lines of context to show
440 -U --unified NUM number of lines of context to show
433 --stat output diffstat-style summary of changes
441 --stat output diffstat-style summary of changes
434 -I --include PATTERN [+] include names matching the given patterns
442 -I --include PATTERN [+] include names matching the given patterns
435 -X --exclude PATTERN [+] exclude names matching the given patterns
443 -X --exclude PATTERN [+] exclude names matching the given patterns
436
444
437 [+] marked option can be specified multiple times
445 [+] marked option can be specified multiple times
438
446
439 use "hg -v help diff" to show global options
447 use "hg -v help diff" to show global options
440 hg status [OPTION]... [FILE]...
448 hg status [OPTION]... [FILE]...
441
449
442 aliases: st
450 aliases: st
443
451
444 show changed files in the working directory
452 show changed files in the working directory
445
453
446 Show status of files in the repository. If names are given, only files
454 Show status of files in the repository. If names are given, only files
447 that match are shown. Files that are clean or ignored or the source of a
455 that match are shown. Files that are clean or ignored or the source of a
448 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
456 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
449 -C/--copies or -A/--all are given. Unless options described with "show
457 -C/--copies or -A/--all are given. Unless options described with "show
450 only ..." are given, the options -mardu are used.
458 only ..." are given, the options -mardu are used.
451
459
452 Option -q/--quiet hides untracked (unknown and ignored) files unless
460 Option -q/--quiet hides untracked (unknown and ignored) files unless
453 explicitly requested with -u/--unknown or -i/--ignored.
461 explicitly requested with -u/--unknown or -i/--ignored.
454
462
455 NOTE: status may appear to disagree with diff if permissions have changed
463 NOTE: status may appear to disagree with diff if permissions have changed
456 or a merge has occurred. The standard diff format does not report
464 or a merge has occurred. The standard diff format does not report
457 permission changes and diff only reports changes relative to one merge
465 permission changes and diff only reports changes relative to one merge
458 parent.
466 parent.
459
467
460 If one revision is given, it is used as the base revision. If two
468 If one revision is given, it is used as the base revision. If two
461 revisions are given, the differences between them are shown. The --change
469 revisions are given, the differences between them are shown. The --change
462 option can also be used as a shortcut to list the changed files of a
470 option can also be used as a shortcut to list the changed files of a
463 revision from its first parent.
471 revision from its first parent.
464
472
465 The codes used to show the status of files are:
473 The codes used to show the status of files are:
466
474
467 M = modified
475 M = modified
468 A = added
476 A = added
469 R = removed
477 R = removed
470 C = clean
478 C = clean
471 ! = missing (deleted by non-hg command, but still tracked)
479 ! = missing (deleted by non-hg command, but still tracked)
472 ? = not tracked
480 ? = not tracked
473 I = ignored
481 I = ignored
474 = origin of the previous file listed as A (added)
482 = origin of the previous file listed as A (added)
475
483
476 Returns 0 on success.
484 Returns 0 on success.
477
485
478 options:
486 options:
479
487
480 -A --all show status of all files
488 -A --all show status of all files
481 -m --modified show only modified files
489 -m --modified show only modified files
482 -a --added show only added files
490 -a --added show only added files
483 -r --removed show only removed files
491 -r --removed show only removed files
484 -d --deleted show only deleted (but tracked) files
492 -d --deleted show only deleted (but tracked) files
485 -c --clean show only files without changes
493 -c --clean show only files without changes
486 -u --unknown show only unknown (not tracked) files
494 -u --unknown show only unknown (not tracked) files
487 -i --ignored show only ignored files
495 -i --ignored show only ignored files
488 -n --no-status hide status prefix
496 -n --no-status hide status prefix
489 -C --copies show source of copied files
497 -C --copies show source of copied files
490 -0 --print0 end filenames with NUL, for use with xargs
498 -0 --print0 end filenames with NUL, for use with xargs
491 --rev REV [+] show difference from revision
499 --rev REV [+] show difference from revision
492 --change REV list the changed files of a revision
500 --change REV list the changed files of a revision
493 -I --include PATTERN [+] include names matching the given patterns
501 -I --include PATTERN [+] include names matching the given patterns
494 -X --exclude PATTERN [+] exclude names matching the given patterns
502 -X --exclude PATTERN [+] exclude names matching the given patterns
495
503
496 [+] marked option can be specified multiple times
504 [+] marked option can be specified multiple times
497
505
498 use "hg -v help status" to show global options
506 use "hg -v help status" to show global options
499 hg status [OPTION]... [FILE]...
507 hg status [OPTION]... [FILE]...
500
508
501 show changed files in the working directory
509 show changed files in the working directory
502 hg: unknown command 'foo'
510 hg: unknown command 'foo'
503 Mercurial Distributed SCM
511 Mercurial Distributed SCM
504
512
505 basic commands:
513 basic commands:
506
514
507 add add the specified files on the next commit
515 add add the specified files on the next commit
508 annotate show changeset information by line for each file
516 annotate show changeset information by line for each file
509 clone make a copy of an existing repository
517 clone make a copy of an existing repository
510 commit commit the specified files or all outstanding changes
518 commit commit the specified files or all outstanding changes
511 diff diff repository (or selected files)
519 diff diff repository (or selected files)
512 export dump the header and diffs for one or more changesets
520 export dump the header and diffs for one or more changesets
513 forget forget the specified files on the next commit
521 forget forget the specified files on the next commit
514 init create a new repository in the given directory
522 init create a new repository in the given directory
515 log show revision history of entire repository or files
523 log show revision history of entire repository or files
516 merge merge working directory with another revision
524 merge merge working directory with another revision
517 pull pull changes from the specified source
525 pull pull changes from the specified source
518 push push changes to the specified destination
526 push push changes to the specified destination
519 remove remove the specified files on the next commit
527 remove remove the specified files on the next commit
520 serve start stand-alone webserver
528 serve start stand-alone webserver
521 status show changed files in the working directory
529 status show changed files in the working directory
522 summary summarize working directory state
530 summary summarize working directory state
523 update update working directory (or switch revisions)
531 update update working directory (or switch revisions)
524
532
525 use "hg help" for the full list of commands or "hg -v" for details
533 use "hg help" for the full list of commands or "hg -v" for details
526 hg: unknown command 'skjdfks'
534 hg: unknown command 'skjdfks'
527 Mercurial Distributed SCM
535 Mercurial Distributed SCM
528
536
529 basic commands:
537 basic commands:
530
538
531 add add the specified files on the next commit
539 add add the specified files on the next commit
532 annotate show changeset information by line for each file
540 annotate show changeset information by line for each file
533 clone make a copy of an existing repository
541 clone make a copy of an existing repository
534 commit commit the specified files or all outstanding changes
542 commit commit the specified files or all outstanding changes
535 diff diff repository (or selected files)
543 diff diff repository (or selected files)
536 export dump the header and diffs for one or more changesets
544 export dump the header and diffs for one or more changesets
537 forget forget the specified files on the next commit
545 forget forget the specified files on the next commit
538 init create a new repository in the given directory
546 init create a new repository in the given directory
539 log show revision history of entire repository or files
547 log show revision history of entire repository or files
540 merge merge working directory with another revision
548 merge merge working directory with another revision
541 pull pull changes from the specified source
549 pull pull changes from the specified source
542 push push changes to the specified destination
550 push push changes to the specified destination
543 remove remove the specified files on the next commit
551 remove remove the specified files on the next commit
544 serve start stand-alone webserver
552 serve start stand-alone webserver
545 status show changed files in the working directory
553 status show changed files in the working directory
546 summary summarize working directory state
554 summary summarize working directory state
547 update update working directory (or switch revisions)
555 update update working directory (or switch revisions)
548
556
549 use "hg help" for the full list of commands or "hg -v" for details
557 use "hg help" for the full list of commands or "hg -v" for details
550 %% test command with no help text
558 %% test command with no help text
551 hg nohelp
559 hg nohelp
552
560
553 (no help text available)
561 (no help text available)
554
562
555 use "hg -v help nohelp" to show global options
563 use "hg -v help nohelp" to show global options
556 %% test that default list of commands omits extension commands
564 %% test that default list of commands omits extension commands
557 Mercurial Distributed SCM
565 Mercurial Distributed SCM
558
566
559 list of commands:
567 list of commands:
560
568
561 add add the specified files on the next commit
569 add add the specified files on the next commit
562 addremove add all new files, delete all missing files
570 addremove add all new files, delete all missing files
563 annotate show changeset information by line for each file
571 annotate show changeset information by line for each file
564 archive create an unversioned archive of a repository revision
572 archive create an unversioned archive of a repository revision
565 backout reverse effect of earlier changeset
573 backout reverse effect of earlier changeset
566 bisect subdivision search of changesets
574 bisect subdivision search of changesets
567 branch set or show the current branch name
575 branch set or show the current branch name
568 branches list repository named branches
576 branches list repository named branches
569 bundle create a changegroup file
577 bundle create a changegroup file
570 cat output the current or given revision of files
578 cat output the current or given revision of files
571 clone make a copy of an existing repository
579 clone make a copy of an existing repository
572 commit commit the specified files or all outstanding changes
580 commit commit the specified files or all outstanding changes
573 copy mark files as copied for the next commit
581 copy mark files as copied for the next commit
574 diff diff repository (or selected files)
582 diff diff repository (or selected files)
575 export dump the header and diffs for one or more changesets
583 export dump the header and diffs for one or more changesets
576 forget forget the specified files on the next commit
584 forget forget the specified files on the next commit
577 grep search for a pattern in specified files and revisions
585 grep search for a pattern in specified files and revisions
578 heads show current repository heads or show branch heads
586 heads show current repository heads or show branch heads
579 help show help for a given topic or a help overview
587 help show help for a given topic or a help overview
580 identify identify the working copy or specified revision
588 identify identify the working copy or specified revision
581 import import an ordered set of patches
589 import import an ordered set of patches
582 incoming show new changesets found in source
590 incoming show new changesets found in source
583 init create a new repository in the given directory
591 init create a new repository in the given directory
584 locate locate files matching specific patterns
592 locate locate files matching specific patterns
585 log show revision history of entire repository or files
593 log show revision history of entire repository or files
586 manifest output the current or given revision of the project manifest
594 manifest output the current or given revision of the project manifest
587 merge merge working directory with another revision
595 merge merge working directory with another revision
588 outgoing show changesets not found in the destination
596 outgoing show changesets not found in the destination
589 parents show the parents of the working directory or revision
597 parents show the parents of the working directory or revision
590 paths show aliases for remote repositories
598 paths show aliases for remote repositories
591 pull pull changes from the specified source
599 pull pull changes from the specified source
592 push push changes to the specified destination
600 push push changes to the specified destination
593 recover roll back an interrupted transaction
601 recover roll back an interrupted transaction
594 remove remove the specified files on the next commit
602 remove remove the specified files on the next commit
595 rename rename files; equivalent of copy + remove
603 rename rename files; equivalent of copy + remove
596 resolve various operations to help finish a merge
604 resolve various operations to help finish a merge
597 revert restore individual files or directories to an earlier state
605 revert restore individual files or directories to an earlier state
598 rollback roll back the last transaction (dangerous)
606 rollback roll back the last transaction (dangerous)
599 root print the root (top) of the current working directory
607 root print the root (top) of the current working directory
600 serve start stand-alone webserver
608 serve start stand-alone webserver
601 showconfig show combined config settings from all hgrc files
609 showconfig show combined config settings from all hgrc files
602 status show changed files in the working directory
610 status show changed files in the working directory
603 summary summarize working directory state
611 summary summarize working directory state
604 tag add one or more tags for the current or given revision
612 tag add one or more tags for the current or given revision
605 tags list repository tags
613 tags list repository tags
606 tip show the tip revision
614 tip show the tip revision
607 unbundle apply one or more changegroup files
615 unbundle apply one or more changegroup files
608 update update working directory (or switch revisions)
616 update update working directory (or switch revisions)
609 verify verify the integrity of the repository
617 verify verify the integrity of the repository
610 version output version and copyright information
618 version output version and copyright information
611
619
612 enabled extensions:
620 enabled extensions:
613
621
614 helpext (no help text available)
622 helpext (no help text available)
615
623
616 additional help topics:
624 additional help topics:
617
625
618 config Configuration Files
626 config Configuration Files
619 dates Date Formats
627 dates Date Formats
620 patterns File Name Patterns
628 patterns File Name Patterns
621 environment Environment Variables
629 environment Environment Variables
622 revisions Specifying Single Revisions
630 revisions Specifying Single Revisions
623 multirevs Specifying Multiple Revisions
631 multirevs Specifying Multiple Revisions
624 revsets Specifying Revision Sets
632 revsets Specifying Revision Sets
625 diffs Diff Formats
633 diffs Diff Formats
626 templating Template Usage
634 templating Template Usage
627 urls URL Paths
635 urls URL Paths
628 extensions Using additional features
636 extensions Using additional features
629 hgweb Configuring hgweb
637 hgweb Configuring hgweb
630 glossary Glossary
638 glossary Glossary
631
639
632 use "hg -v help" to show aliases and global options
640 use "hg -v help" to show aliases and global options
633 %% test list of commands with command with no help text
641 %% test list of commands with command with no help text
634 helpext extension - no help text available
642 helpext extension - no help text available
635
643
636 list of commands:
644 list of commands:
637
645
638 nohelp (no help text available)
646 nohelp (no help text available)
639
647
640 use "hg -v help helpext" to show aliases and global options
648 use "hg -v help helpext" to show aliases and global options
641 %% test a help topic
649 %% test a help topic
642 Specifying Single Revisions
650 Specifying Single Revisions
643
651
644 Mercurial supports several ways to specify individual revisions.
652 Mercurial supports several ways to specify individual revisions.
645
653
646 A plain integer is treated as a revision number. Negative integers are
654 A plain integer is treated as a revision number. Negative integers are
647 treated as sequential offsets from the tip, with -1 denoting the tip, -2
655 treated as sequential offsets from the tip, with -1 denoting the tip, -2
648 denoting the revision prior to the tip, and so forth.
656 denoting the revision prior to the tip, and so forth.
649
657
650 A 40-digit hexadecimal string is treated as a unique revision identifier.
658 A 40-digit hexadecimal string is treated as a unique revision identifier.
651
659
652 A hexadecimal string less than 40 characters long is treated as a unique
660 A hexadecimal string less than 40 characters long is treated as a unique
653 revision identifier and is referred to as a short-form identifier. A
661 revision identifier and is referred to as a short-form identifier. A
654 short-form identifier is only valid if it is the prefix of exactly one
662 short-form identifier is only valid if it is the prefix of exactly one
655 full-length identifier.
663 full-length identifier.
656
664
657 Any other string is treated as a tag or branch name. A tag name is a
665 Any other string is treated as a tag or branch name. A tag name is a
658 symbolic name associated with a revision identifier. A branch name denotes
666 symbolic name associated with a revision identifier. A branch name denotes
659 the tipmost revision of that branch. Tag and branch names must not contain
667 the tipmost revision of that branch. Tag and branch names must not contain
660 the ":" character.
668 the ":" character.
661
669
662 The reserved name "tip" is a special tag that always identifies the most
670 The reserved name "tip" is a special tag that always identifies the most
663 recent revision.
671 recent revision.
664
672
665 The reserved name "null" indicates the null revision. This is the revision
673 The reserved name "null" indicates the null revision. This is the revision
666 of an empty repository, and the parent of revision 0.
674 of an empty repository, and the parent of revision 0.
667
675
668 The reserved name "." indicates the working directory parent. If no
676 The reserved name "." indicates the working directory parent. If no
669 working directory is checked out, it is equivalent to null. If an
677 working directory is checked out, it is equivalent to null. If an
670 uncommitted merge is in progress, "." is the revision of the first parent.
678 uncommitted merge is in progress, "." is the revision of the first parent.
General Comments 0
You need to be logged in to leave comments. Login now