##// END OF EJS Templates
commands: add verbose example to help text for add
Martin Geisler -
r10446:a565a244 default
parent child Browse files
Show More
@@ -1,3813 +1,3826 b''
1 # commands.py - command processing for mercurial
1 # commands.py - command processing for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from node import hex, 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
13 import patch, help, mdiff, url, encoding, templatekw
14 import archival, changegroup, cmdutil, sshserver, hbisect
14 import archival, changegroup, cmdutil, sshserver, hbisect
15 from hgweb import server
15 from hgweb import server
16 import merge as merge_
16 import merge as merge_
17 import minirst
17 import minirst
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
32 .. container:: verbose
33
34 An example showing how new (unknown) files are added
35 automatically by ``hg add``::
36
37 $ ls
38 foo.c
39 $ hg status
40 ? foo.c
41 $ hg add
42 adding foo.c
43 $ hg status
31 """
44 """
32
45
33 bad = []
46 bad = []
34 names = []
47 names = []
35 m = cmdutil.match(repo, pats, opts)
48 m = cmdutil.match(repo, pats, opts)
36 oldbad = m.bad
49 oldbad = m.bad
37 m.bad = lambda x, y: bad.append(x) or oldbad(x, y)
50 m.bad = lambda x, y: bad.append(x) or oldbad(x, y)
38
51
39 for f in repo.walk(m):
52 for f in repo.walk(m):
40 exact = m.exact(f)
53 exact = m.exact(f)
41 if exact or f not in repo.dirstate:
54 if exact or f not in repo.dirstate:
42 names.append(f)
55 names.append(f)
43 if ui.verbose or not exact:
56 if ui.verbose or not exact:
44 ui.status(_('adding %s\n') % m.rel(f))
57 ui.status(_('adding %s\n') % m.rel(f))
45 if not opts.get('dry_run'):
58 if not opts.get('dry_run'):
46 bad += [f for f in repo.add(names) if f in m.files()]
59 bad += [f for f in repo.add(names) if f in m.files()]
47 return bad and 1 or 0
60 return bad and 1 or 0
48
61
49 def addremove(ui, repo, *pats, **opts):
62 def addremove(ui, repo, *pats, **opts):
50 """add all new files, delete all missing files
63 """add all new files, delete all missing files
51
64
52 Add all new files and remove all missing files from the
65 Add all new files and remove all missing files from the
53 repository.
66 repository.
54
67
55 New files are ignored if they match any of the patterns in
68 New files are ignored if they match any of the patterns in
56 .hgignore. As with add, these changes take effect at the next
69 .hgignore. As with add, these changes take effect at the next
57 commit.
70 commit.
58
71
59 Use the -s/--similarity option to detect renamed files. With a
72 Use the -s/--similarity option to detect renamed files. With a
60 parameter greater than 0, this compares every removed file with
73 parameter greater than 0, this compares every removed file with
61 every added file and records those similar enough as renames. This
74 every added file and records those similar enough as renames. This
62 option takes a percentage between 0 (disabled) and 100 (files must
75 option takes a percentage between 0 (disabled) and 100 (files must
63 be identical) as its parameter. Detecting renamed files this way
76 be identical) as its parameter. Detecting renamed files this way
64 can be expensive.
77 can be expensive.
65 """
78 """
66 try:
79 try:
67 sim = float(opts.get('similarity') or 0)
80 sim = float(opts.get('similarity') or 0)
68 except ValueError:
81 except ValueError:
69 raise util.Abort(_('similarity must be a number'))
82 raise util.Abort(_('similarity must be a number'))
70 if sim < 0 or sim > 100:
83 if sim < 0 or sim > 100:
71 raise util.Abort(_('similarity must be between 0 and 100'))
84 raise util.Abort(_('similarity must be between 0 and 100'))
72 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
85 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
73
86
74 def annotate(ui, repo, *pats, **opts):
87 def annotate(ui, repo, *pats, **opts):
75 """show changeset information by line for each file
88 """show changeset information by line for each file
76
89
77 List changes in files, showing the revision id responsible for
90 List changes in files, showing the revision id responsible for
78 each line
91 each line
79
92
80 This command is useful for discovering when a change was made and
93 This command is useful for discovering when a change was made and
81 by whom.
94 by whom.
82
95
83 Without the -a/--text option, annotate will avoid processing files
96 Without the -a/--text option, annotate will avoid processing files
84 it detects as binary. With -a, annotate will annotate the file
97 it detects as binary. With -a, annotate will annotate the file
85 anyway, although the results will probably be neither useful
98 anyway, although the results will probably be neither useful
86 nor desirable.
99 nor desirable.
87 """
100 """
88 datefunc = ui.quiet and util.shortdate or util.datestr
101 datefunc = ui.quiet and util.shortdate or util.datestr
89 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
102 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
90
103
91 if not pats:
104 if not pats:
92 raise util.Abort(_('at least one filename or pattern is required'))
105 raise util.Abort(_('at least one filename or pattern is required'))
93
106
94 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
107 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
95 ('number', lambda x: str(x[0].rev())),
108 ('number', lambda x: str(x[0].rev())),
96 ('changeset', lambda x: short(x[0].node())),
109 ('changeset', lambda x: short(x[0].node())),
97 ('date', getdate),
110 ('date', getdate),
98 ('file', lambda x: x[0].path()),
111 ('file', lambda x: x[0].path()),
99 ]
112 ]
100
113
101 if (not opts.get('user') and not opts.get('changeset')
114 if (not opts.get('user') and not opts.get('changeset')
102 and not opts.get('date') and not opts.get('file')):
115 and not opts.get('date') and not opts.get('file')):
103 opts['number'] = 1
116 opts['number'] = 1
104
117
105 linenumber = opts.get('line_number') is not None
118 linenumber = opts.get('line_number') is not None
106 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
119 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
107 raise util.Abort(_('at least one of -n/-c is required for -l'))
120 raise util.Abort(_('at least one of -n/-c is required for -l'))
108
121
109 funcmap = [func for op, func in opmap if opts.get(op)]
122 funcmap = [func for op, func in opmap if opts.get(op)]
110 if linenumber:
123 if linenumber:
111 lastfunc = funcmap[-1]
124 lastfunc = funcmap[-1]
112 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
125 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
113
126
114 ctx = repo[opts.get('rev')]
127 ctx = repo[opts.get('rev')]
115 m = cmdutil.match(repo, pats, opts)
128 m = cmdutil.match(repo, pats, opts)
116 follow = not opts.get('no_follow')
129 follow = not opts.get('no_follow')
117 for abs in ctx.walk(m):
130 for abs in ctx.walk(m):
118 fctx = ctx[abs]
131 fctx = ctx[abs]
119 if not opts.get('text') and util.binary(fctx.data()):
132 if not opts.get('text') and util.binary(fctx.data()):
120 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
133 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
121 continue
134 continue
122
135
123 lines = fctx.annotate(follow=follow, linenumber=linenumber)
136 lines = fctx.annotate(follow=follow, linenumber=linenumber)
124 pieces = []
137 pieces = []
125
138
126 for f in funcmap:
139 for f in funcmap:
127 l = [f(n) for n, dummy in lines]
140 l = [f(n) for n, dummy in lines]
128 if l:
141 if l:
129 ml = max(map(len, l))
142 ml = max(map(len, l))
130 pieces.append(["%*s" % (ml, x) for x in l])
143 pieces.append(["%*s" % (ml, x) for x in l])
131
144
132 if pieces:
145 if pieces:
133 for p, l in zip(zip(*pieces), lines):
146 for p, l in zip(zip(*pieces), lines):
134 ui.write("%s: %s" % (" ".join(p), l[1]))
147 ui.write("%s: %s" % (" ".join(p), l[1]))
135
148
136 def archive(ui, repo, dest, **opts):
149 def archive(ui, repo, dest, **opts):
137 '''create an unversioned archive of a repository revision
150 '''create an unversioned archive of a repository revision
138
151
139 By default, the revision used is the parent of the working
152 By default, the revision used is the parent of the working
140 directory; use -r/--rev to specify a different revision.
153 directory; use -r/--rev to specify a different revision.
141
154
142 To specify the type of archive to create, use -t/--type. Valid
155 To specify the type of archive to create, use -t/--type. Valid
143 types are:
156 types are:
144
157
145 :``files``: a directory full of files (default)
158 :``files``: a directory full of files (default)
146 :``tar``: tar archive, uncompressed
159 :``tar``: tar archive, uncompressed
147 :``tbz2``: tar archive, compressed using bzip2
160 :``tbz2``: tar archive, compressed using bzip2
148 :``tgz``: tar archive, compressed using gzip
161 :``tgz``: tar archive, compressed using gzip
149 :``uzip``: zip archive, uncompressed
162 :``uzip``: zip archive, uncompressed
150 :``zip``: zip archive, compressed using deflate
163 :``zip``: zip archive, compressed using deflate
151
164
152 The exact name of the destination archive or directory is given
165 The exact name of the destination archive or directory is given
153 using a format string; see 'hg help export' for details.
166 using a format string; see 'hg help export' for details.
154
167
155 Each member added to an archive file has a directory prefix
168 Each member added to an archive file has a directory prefix
156 prepended. Use -p/--prefix to specify a format string for the
169 prepended. Use -p/--prefix to specify a format string for the
157 prefix. The default is the basename of the archive, with suffixes
170 prefix. The default is the basename of the archive, with suffixes
158 removed.
171 removed.
159 '''
172 '''
160
173
161 ctx = repo[opts.get('rev')]
174 ctx = repo[opts.get('rev')]
162 if not ctx:
175 if not ctx:
163 raise util.Abort(_('no working directory: please specify a revision'))
176 raise util.Abort(_('no working directory: please specify a revision'))
164 node = ctx.node()
177 node = ctx.node()
165 dest = cmdutil.make_filename(repo, dest, node)
178 dest = cmdutil.make_filename(repo, dest, node)
166 if os.path.realpath(dest) == repo.root:
179 if os.path.realpath(dest) == repo.root:
167 raise util.Abort(_('repository root cannot be destination'))
180 raise util.Abort(_('repository root cannot be destination'))
168 matchfn = cmdutil.match(repo, [], opts)
181 matchfn = cmdutil.match(repo, [], opts)
169 kind = opts.get('type') or 'files'
182 kind = opts.get('type') or 'files'
170 prefix = opts.get('prefix')
183 prefix = opts.get('prefix')
171 if dest == '-':
184 if dest == '-':
172 if kind == 'files':
185 if kind == 'files':
173 raise util.Abort(_('cannot archive plain files to stdout'))
186 raise util.Abort(_('cannot archive plain files to stdout'))
174 dest = sys.stdout
187 dest = sys.stdout
175 if not prefix:
188 if not prefix:
176 prefix = os.path.basename(repo.root) + '-%h'
189 prefix = os.path.basename(repo.root) + '-%h'
177 prefix = cmdutil.make_filename(repo, prefix, node)
190 prefix = cmdutil.make_filename(repo, prefix, node)
178 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
191 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
179 matchfn, prefix)
192 matchfn, prefix)
180
193
181 def backout(ui, repo, node=None, rev=None, **opts):
194 def backout(ui, repo, node=None, rev=None, **opts):
182 '''reverse effect of earlier changeset
195 '''reverse effect of earlier changeset
183
196
184 Commit the backed out changes as a new changeset. The new
197 Commit the backed out changes as a new changeset. The new
185 changeset is a child of the backed out changeset.
198 changeset is a child of the backed out changeset.
186
199
187 If you backout a changeset other than the tip, a new head is
200 If you backout a changeset other than the tip, a new head is
188 created. This head will be the new tip and you should merge this
201 created. This head will be the new tip and you should merge this
189 backout changeset with another head.
202 backout changeset with another head.
190
203
191 The --merge option remembers the parent of the working directory
204 The --merge option remembers the parent of the working directory
192 before starting the backout, then merges the new head with that
205 before starting the backout, then merges the new head with that
193 changeset afterwards. This saves you from doing the merge by hand.
206 changeset afterwards. This saves you from doing the merge by hand.
194 The result of this merge is not committed, as with a normal merge.
207 The result of this merge is not committed, as with a normal merge.
195
208
196 See 'hg help dates' for a list of formats valid for -d/--date.
209 See 'hg help dates' for a list of formats valid for -d/--date.
197 '''
210 '''
198 if rev and node:
211 if rev and node:
199 raise util.Abort(_("please specify just one revision"))
212 raise util.Abort(_("please specify just one revision"))
200
213
201 if not rev:
214 if not rev:
202 rev = node
215 rev = node
203
216
204 if not rev:
217 if not rev:
205 raise util.Abort(_("please specify a revision to backout"))
218 raise util.Abort(_("please specify a revision to backout"))
206
219
207 date = opts.get('date')
220 date = opts.get('date')
208 if date:
221 if date:
209 opts['date'] = util.parsedate(date)
222 opts['date'] = util.parsedate(date)
210
223
211 cmdutil.bail_if_changed(repo)
224 cmdutil.bail_if_changed(repo)
212 node = repo.lookup(rev)
225 node = repo.lookup(rev)
213
226
214 op1, op2 = repo.dirstate.parents()
227 op1, op2 = repo.dirstate.parents()
215 a = repo.changelog.ancestor(op1, node)
228 a = repo.changelog.ancestor(op1, node)
216 if a != node:
229 if a != node:
217 raise util.Abort(_('cannot backout change on a different branch'))
230 raise util.Abort(_('cannot backout change on a different branch'))
218
231
219 p1, p2 = repo.changelog.parents(node)
232 p1, p2 = repo.changelog.parents(node)
220 if p1 == nullid:
233 if p1 == nullid:
221 raise util.Abort(_('cannot backout a change with no parents'))
234 raise util.Abort(_('cannot backout a change with no parents'))
222 if p2 != nullid:
235 if p2 != nullid:
223 if not opts.get('parent'):
236 if not opts.get('parent'):
224 raise util.Abort(_('cannot backout a merge changeset without '
237 raise util.Abort(_('cannot backout a merge changeset without '
225 '--parent'))
238 '--parent'))
226 p = repo.lookup(opts['parent'])
239 p = repo.lookup(opts['parent'])
227 if p not in (p1, p2):
240 if p not in (p1, p2):
228 raise util.Abort(_('%s is not a parent of %s') %
241 raise util.Abort(_('%s is not a parent of %s') %
229 (short(p), short(node)))
242 (short(p), short(node)))
230 parent = p
243 parent = p
231 else:
244 else:
232 if opts.get('parent'):
245 if opts.get('parent'):
233 raise util.Abort(_('cannot use --parent on non-merge changeset'))
246 raise util.Abort(_('cannot use --parent on non-merge changeset'))
234 parent = p1
247 parent = p1
235
248
236 # the backout should appear on the same branch
249 # the backout should appear on the same branch
237 branch = repo.dirstate.branch()
250 branch = repo.dirstate.branch()
238 hg.clean(repo, node, show_stats=False)
251 hg.clean(repo, node, show_stats=False)
239 repo.dirstate.setbranch(branch)
252 repo.dirstate.setbranch(branch)
240 revert_opts = opts.copy()
253 revert_opts = opts.copy()
241 revert_opts['date'] = None
254 revert_opts['date'] = None
242 revert_opts['all'] = True
255 revert_opts['all'] = True
243 revert_opts['rev'] = hex(parent)
256 revert_opts['rev'] = hex(parent)
244 revert_opts['no_backup'] = None
257 revert_opts['no_backup'] = None
245 revert(ui, repo, **revert_opts)
258 revert(ui, repo, **revert_opts)
246 commit_opts = opts.copy()
259 commit_opts = opts.copy()
247 commit_opts['addremove'] = False
260 commit_opts['addremove'] = False
248 if not commit_opts['message'] and not commit_opts['logfile']:
261 if not commit_opts['message'] and not commit_opts['logfile']:
249 # we don't translate commit messages
262 # we don't translate commit messages
250 commit_opts['message'] = "Backed out changeset %s" % short(node)
263 commit_opts['message'] = "Backed out changeset %s" % short(node)
251 commit_opts['force_editor'] = True
264 commit_opts['force_editor'] = True
252 commit(ui, repo, **commit_opts)
265 commit(ui, repo, **commit_opts)
253 def nice(node):
266 def nice(node):
254 return '%d:%s' % (repo.changelog.rev(node), short(node))
267 return '%d:%s' % (repo.changelog.rev(node), short(node))
255 ui.status(_('changeset %s backs out changeset %s\n') %
268 ui.status(_('changeset %s backs out changeset %s\n') %
256 (nice(repo.changelog.tip()), nice(node)))
269 (nice(repo.changelog.tip()), nice(node)))
257 if op1 != node:
270 if op1 != node:
258 hg.clean(repo, op1, show_stats=False)
271 hg.clean(repo, op1, show_stats=False)
259 if opts.get('merge'):
272 if opts.get('merge'):
260 ui.status(_('merging with changeset %s\n')
273 ui.status(_('merging with changeset %s\n')
261 % nice(repo.changelog.tip()))
274 % nice(repo.changelog.tip()))
262 hg.merge(repo, hex(repo.changelog.tip()))
275 hg.merge(repo, hex(repo.changelog.tip()))
263 else:
276 else:
264 ui.status(_('the backout changeset is a new head - '
277 ui.status(_('the backout changeset is a new head - '
265 'do not forget to merge\n'))
278 'do not forget to merge\n'))
266 ui.status(_('(use "backout --merge" '
279 ui.status(_('(use "backout --merge" '
267 'if you want to auto-merge)\n'))
280 'if you want to auto-merge)\n'))
268
281
269 def bisect(ui, repo, rev=None, extra=None, command=None,
282 def bisect(ui, repo, rev=None, extra=None, command=None,
270 reset=None, good=None, bad=None, skip=None, noupdate=None):
283 reset=None, good=None, bad=None, skip=None, noupdate=None):
271 """subdivision search of changesets
284 """subdivision search of changesets
272
285
273 This command helps to find changesets which introduce problems. To
286 This command helps to find changesets which introduce problems. To
274 use, mark the earliest changeset you know exhibits the problem as
287 use, mark the earliest changeset you know exhibits the problem as
275 bad, then mark the latest changeset which is free from the problem
288 bad, then mark the latest changeset which is free from the problem
276 as good. Bisect will update your working directory to a revision
289 as good. Bisect will update your working directory to a revision
277 for testing (unless the -U/--noupdate option is specified). Once
290 for testing (unless the -U/--noupdate option is specified). Once
278 you have performed tests, mark the working directory as good or
291 you have performed tests, mark the working directory as good or
279 bad, and bisect will either update to another candidate changeset
292 bad, and bisect will either update to another candidate changeset
280 or announce that it has found the bad revision.
293 or announce that it has found the bad revision.
281
294
282 As a shortcut, you can also use the revision argument to mark a
295 As a shortcut, you can also use the revision argument to mark a
283 revision as good or bad without checking it out first.
296 revision as good or bad without checking it out first.
284
297
285 If you supply a command, it will be used for automatic bisection.
298 If you supply a command, it will be used for automatic bisection.
286 Its exit status will be used to mark revisions as good or bad:
299 Its exit status will be used to mark revisions as good or bad:
287 status 0 means good, 125 means to skip the revision, 127
300 status 0 means good, 125 means to skip the revision, 127
288 (command not found) will abort the bisection, and any other
301 (command not found) will abort the bisection, and any other
289 non-zero exit status means the revision is bad.
302 non-zero exit status means the revision is bad.
290 """
303 """
291 def print_result(nodes, good):
304 def print_result(nodes, good):
292 displayer = cmdutil.show_changeset(ui, repo, {})
305 displayer = cmdutil.show_changeset(ui, repo, {})
293 if len(nodes) == 1:
306 if len(nodes) == 1:
294 # narrowed it down to a single revision
307 # narrowed it down to a single revision
295 if good:
308 if good:
296 ui.write(_("The first good revision is:\n"))
309 ui.write(_("The first good revision is:\n"))
297 else:
310 else:
298 ui.write(_("The first bad revision is:\n"))
311 ui.write(_("The first bad revision is:\n"))
299 displayer.show(repo[nodes[0]])
312 displayer.show(repo[nodes[0]])
300 else:
313 else:
301 # multiple possible revisions
314 # multiple possible revisions
302 if good:
315 if good:
303 ui.write(_("Due to skipped revisions, the first "
316 ui.write(_("Due to skipped revisions, the first "
304 "good revision could be any of:\n"))
317 "good revision could be any of:\n"))
305 else:
318 else:
306 ui.write(_("Due to skipped revisions, the first "
319 ui.write(_("Due to skipped revisions, the first "
307 "bad revision could be any of:\n"))
320 "bad revision could be any of:\n"))
308 for n in nodes:
321 for n in nodes:
309 displayer.show(repo[n])
322 displayer.show(repo[n])
310 displayer.close()
323 displayer.close()
311
324
312 def check_state(state, interactive=True):
325 def check_state(state, interactive=True):
313 if not state['good'] or not state['bad']:
326 if not state['good'] or not state['bad']:
314 if (good or bad or skip or reset) and interactive:
327 if (good or bad or skip or reset) and interactive:
315 return
328 return
316 if not state['good']:
329 if not state['good']:
317 raise util.Abort(_('cannot bisect (no known good revisions)'))
330 raise util.Abort(_('cannot bisect (no known good revisions)'))
318 else:
331 else:
319 raise util.Abort(_('cannot bisect (no known bad revisions)'))
332 raise util.Abort(_('cannot bisect (no known bad revisions)'))
320 return True
333 return True
321
334
322 # backward compatibility
335 # backward compatibility
323 if rev in "good bad reset init".split():
336 if rev in "good bad reset init".split():
324 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
337 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
325 cmd, rev, extra = rev, extra, None
338 cmd, rev, extra = rev, extra, None
326 if cmd == "good":
339 if cmd == "good":
327 good = True
340 good = True
328 elif cmd == "bad":
341 elif cmd == "bad":
329 bad = True
342 bad = True
330 else:
343 else:
331 reset = True
344 reset = True
332 elif extra or good + bad + skip + reset + bool(command) > 1:
345 elif extra or good + bad + skip + reset + bool(command) > 1:
333 raise util.Abort(_('incompatible arguments'))
346 raise util.Abort(_('incompatible arguments'))
334
347
335 if reset:
348 if reset:
336 p = repo.join("bisect.state")
349 p = repo.join("bisect.state")
337 if os.path.exists(p):
350 if os.path.exists(p):
338 os.unlink(p)
351 os.unlink(p)
339 return
352 return
340
353
341 state = hbisect.load_state(repo)
354 state = hbisect.load_state(repo)
342
355
343 if command:
356 if command:
344 changesets = 1
357 changesets = 1
345 try:
358 try:
346 while changesets:
359 while changesets:
347 # update state
360 # update state
348 status = util.system(command)
361 status = util.system(command)
349 if status == 125:
362 if status == 125:
350 transition = "skip"
363 transition = "skip"
351 elif status == 0:
364 elif status == 0:
352 transition = "good"
365 transition = "good"
353 # status < 0 means process was killed
366 # status < 0 means process was killed
354 elif status == 127:
367 elif status == 127:
355 raise util.Abort(_("failed to execute %s") % command)
368 raise util.Abort(_("failed to execute %s") % command)
356 elif status < 0:
369 elif status < 0:
357 raise util.Abort(_("%s killed") % command)
370 raise util.Abort(_("%s killed") % command)
358 else:
371 else:
359 transition = "bad"
372 transition = "bad"
360 ctx = repo[rev or '.']
373 ctx = repo[rev or '.']
361 state[transition].append(ctx.node())
374 state[transition].append(ctx.node())
362 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
375 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
363 check_state(state, interactive=False)
376 check_state(state, interactive=False)
364 # bisect
377 # bisect
365 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
378 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
366 # update to next check
379 # update to next check
367 cmdutil.bail_if_changed(repo)
380 cmdutil.bail_if_changed(repo)
368 hg.clean(repo, nodes[0], show_stats=False)
381 hg.clean(repo, nodes[0], show_stats=False)
369 finally:
382 finally:
370 hbisect.save_state(repo, state)
383 hbisect.save_state(repo, state)
371 return print_result(nodes, good)
384 return print_result(nodes, good)
372
385
373 # update state
386 # update state
374 node = repo.lookup(rev or '.')
387 node = repo.lookup(rev or '.')
375 if good or bad or skip:
388 if good or bad or skip:
376 if good:
389 if good:
377 state['good'].append(node)
390 state['good'].append(node)
378 elif bad:
391 elif bad:
379 state['bad'].append(node)
392 state['bad'].append(node)
380 elif skip:
393 elif skip:
381 state['skip'].append(node)
394 state['skip'].append(node)
382 hbisect.save_state(repo, state)
395 hbisect.save_state(repo, state)
383
396
384 if not check_state(state):
397 if not check_state(state):
385 return
398 return
386
399
387 # actually bisect
400 # actually bisect
388 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
401 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
389 if changesets == 0:
402 if changesets == 0:
390 print_result(nodes, good)
403 print_result(nodes, good)
391 else:
404 else:
392 assert len(nodes) == 1 # only a single node can be tested next
405 assert len(nodes) == 1 # only a single node can be tested next
393 node = nodes[0]
406 node = nodes[0]
394 # compute the approximate number of remaining tests
407 # compute the approximate number of remaining tests
395 tests, size = 0, 2
408 tests, size = 0, 2
396 while size <= changesets:
409 while size <= changesets:
397 tests, size = tests + 1, size * 2
410 tests, size = tests + 1, size * 2
398 rev = repo.changelog.rev(node)
411 rev = repo.changelog.rev(node)
399 ui.write(_("Testing changeset %d:%s "
412 ui.write(_("Testing changeset %d:%s "
400 "(%d changesets remaining, ~%d tests)\n")
413 "(%d changesets remaining, ~%d tests)\n")
401 % (rev, short(node), changesets, tests))
414 % (rev, short(node), changesets, tests))
402 if not noupdate:
415 if not noupdate:
403 cmdutil.bail_if_changed(repo)
416 cmdutil.bail_if_changed(repo)
404 return hg.clean(repo, node)
417 return hg.clean(repo, node)
405
418
406 def branch(ui, repo, label=None, **opts):
419 def branch(ui, repo, label=None, **opts):
407 """set or show the current branch name
420 """set or show the current branch name
408
421
409 With no argument, show the current branch name. With one argument,
422 With no argument, show the current branch name. With one argument,
410 set the working directory branch name (the branch will not exist
423 set the working directory branch name (the branch will not exist
411 in the repository until the next commit). Standard practice
424 in the repository until the next commit). Standard practice
412 recommends that primary development take place on the 'default'
425 recommends that primary development take place on the 'default'
413 branch.
426 branch.
414
427
415 Unless -f/--force is specified, branch will not let you set a
428 Unless -f/--force is specified, branch will not let you set a
416 branch name that already exists, even if it's inactive.
429 branch name that already exists, even if it's inactive.
417
430
418 Use -C/--clean to reset the working directory branch to that of
431 Use -C/--clean to reset the working directory branch to that of
419 the parent of the working directory, negating a previous branch
432 the parent of the working directory, negating a previous branch
420 change.
433 change.
421
434
422 Use the command 'hg update' to switch to an existing branch. Use
435 Use the command 'hg update' to switch to an existing branch. Use
423 'hg commit --close-branch' to mark this branch as closed.
436 'hg commit --close-branch' to mark this branch as closed.
424 """
437 """
425
438
426 if opts.get('clean'):
439 if opts.get('clean'):
427 label = repo[None].parents()[0].branch()
440 label = repo[None].parents()[0].branch()
428 repo.dirstate.setbranch(label)
441 repo.dirstate.setbranch(label)
429 ui.status(_('reset working directory to branch %s\n') % label)
442 ui.status(_('reset working directory to branch %s\n') % label)
430 elif label:
443 elif label:
431 utflabel = encoding.fromlocal(label)
444 utflabel = encoding.fromlocal(label)
432 if not opts.get('force') and utflabel in repo.branchtags():
445 if not opts.get('force') and utflabel in repo.branchtags():
433 if label not in [p.branch() for p in repo.parents()]:
446 if label not in [p.branch() for p in repo.parents()]:
434 raise util.Abort(_('a branch of the same name already exists'
447 raise util.Abort(_('a branch of the same name already exists'
435 ' (use --force to override)'))
448 ' (use --force to override)'))
436 repo.dirstate.setbranch(utflabel)
449 repo.dirstate.setbranch(utflabel)
437 ui.status(_('marked working directory as branch %s\n') % label)
450 ui.status(_('marked working directory as branch %s\n') % label)
438 else:
451 else:
439 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
452 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
440
453
441 def branches(ui, repo, active=False, closed=False):
454 def branches(ui, repo, active=False, closed=False):
442 """list repository named branches
455 """list repository named branches
443
456
444 List the repository's named branches, indicating which ones are
457 List the repository's named branches, indicating which ones are
445 inactive. If -c/--closed is specified, also list branches which have
458 inactive. If -c/--closed is specified, also list branches which have
446 been marked closed (see hg commit --close-branch).
459 been marked closed (see hg commit --close-branch).
447
460
448 If -a/--active is specified, only show active branches. A branch
461 If -a/--active is specified, only show active branches. A branch
449 is considered active if it contains repository heads.
462 is considered active if it contains repository heads.
450
463
451 Use the command 'hg update' to switch to an existing branch.
464 Use the command 'hg update' to switch to an existing branch.
452 """
465 """
453
466
454 hexfunc = ui.debugflag and hex or short
467 hexfunc = ui.debugflag and hex or short
455 activebranches = [repo[n].branch() for n in repo.heads()]
468 activebranches = [repo[n].branch() for n in repo.heads()]
456 def testactive(tag, node):
469 def testactive(tag, node):
457 realhead = tag in activebranches
470 realhead = tag in activebranches
458 open = node in repo.branchheads(tag, closed=False)
471 open = node in repo.branchheads(tag, closed=False)
459 return realhead and open
472 return realhead and open
460 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
473 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
461 for tag, node in repo.branchtags().items()],
474 for tag, node in repo.branchtags().items()],
462 reverse=True)
475 reverse=True)
463
476
464 for isactive, node, tag in branches:
477 for isactive, node, tag in branches:
465 if (not active) or isactive:
478 if (not active) or isactive:
466 encodedtag = encoding.tolocal(tag)
479 encodedtag = encoding.tolocal(tag)
467 if ui.quiet:
480 if ui.quiet:
468 ui.write("%s\n" % encodedtag)
481 ui.write("%s\n" % encodedtag)
469 else:
482 else:
470 hn = repo.lookup(node)
483 hn = repo.lookup(node)
471 if isactive:
484 if isactive:
472 notice = ''
485 notice = ''
473 elif hn not in repo.branchheads(tag, closed=False):
486 elif hn not in repo.branchheads(tag, closed=False):
474 if not closed:
487 if not closed:
475 continue
488 continue
476 notice = _(' (closed)')
489 notice = _(' (closed)')
477 else:
490 else:
478 notice = _(' (inactive)')
491 notice = _(' (inactive)')
479 rev = str(node).rjust(31 - encoding.colwidth(encodedtag))
492 rev = str(node).rjust(31 - encoding.colwidth(encodedtag))
480 data = encodedtag, rev, hexfunc(hn), notice
493 data = encodedtag, rev, hexfunc(hn), notice
481 ui.write("%s %s:%s%s\n" % data)
494 ui.write("%s %s:%s%s\n" % data)
482
495
483 def bundle(ui, repo, fname, dest=None, **opts):
496 def bundle(ui, repo, fname, dest=None, **opts):
484 """create a changegroup file
497 """create a changegroup file
485
498
486 Generate a compressed changegroup file collecting changesets not
499 Generate a compressed changegroup file collecting changesets not
487 known to be in another repository.
500 known to be in another repository.
488
501
489 If you omit the destination repository, then hg assumes the
502 If you omit the destination repository, then hg assumes the
490 destination will have all the nodes you specify with --base
503 destination will have all the nodes you specify with --base
491 parameters. To create a bundle containing all changesets, use
504 parameters. To create a bundle containing all changesets, use
492 -a/--all (or --base null).
505 -a/--all (or --base null).
493
506
494 You can change compression method with the -t/--type option.
507 You can change compression method with the -t/--type option.
495 The available compression methods are: none, bzip2, and
508 The available compression methods are: none, bzip2, and
496 gzip (by default, bundles are compressed using bzip2).
509 gzip (by default, bundles are compressed using bzip2).
497
510
498 The bundle file can then be transferred using conventional means
511 The bundle file can then be transferred using conventional means
499 and applied to another repository with the unbundle or pull
512 and applied to another repository with the unbundle or pull
500 command. This is useful when direct push and pull are not
513 command. This is useful when direct push and pull are not
501 available or when exporting an entire repository is undesirable.
514 available or when exporting an entire repository is undesirable.
502
515
503 Applying bundles preserves all changeset contents including
516 Applying bundles preserves all changeset contents including
504 permissions, copy/rename information, and revision history.
517 permissions, copy/rename information, and revision history.
505 """
518 """
506 revs = opts.get('rev') or None
519 revs = opts.get('rev') or None
507 if revs:
520 if revs:
508 revs = [repo.lookup(rev) for rev in revs]
521 revs = [repo.lookup(rev) for rev in revs]
509 if opts.get('all'):
522 if opts.get('all'):
510 base = ['null']
523 base = ['null']
511 else:
524 else:
512 base = opts.get('base')
525 base = opts.get('base')
513 if base:
526 if base:
514 if dest:
527 if dest:
515 raise util.Abort(_("--base is incompatible with specifying "
528 raise util.Abort(_("--base is incompatible with specifying "
516 "a destination"))
529 "a destination"))
517 base = [repo.lookup(rev) for rev in base]
530 base = [repo.lookup(rev) for rev in base]
518 # create the right base
531 # create the right base
519 # XXX: nodesbetween / changegroup* should be "fixed" instead
532 # XXX: nodesbetween / changegroup* should be "fixed" instead
520 o = []
533 o = []
521 has = set((nullid,))
534 has = set((nullid,))
522 for n in base:
535 for n in base:
523 has.update(repo.changelog.reachable(n))
536 has.update(repo.changelog.reachable(n))
524 if revs:
537 if revs:
525 visit = list(revs)
538 visit = list(revs)
526 else:
539 else:
527 visit = repo.changelog.heads()
540 visit = repo.changelog.heads()
528 seen = {}
541 seen = {}
529 while visit:
542 while visit:
530 n = visit.pop(0)
543 n = visit.pop(0)
531 parents = [p for p in repo.changelog.parents(n) if p not in has]
544 parents = [p for p in repo.changelog.parents(n) if p not in has]
532 if len(parents) == 0:
545 if len(parents) == 0:
533 o.insert(0, n)
546 o.insert(0, n)
534 else:
547 else:
535 for p in parents:
548 for p in parents:
536 if p not in seen:
549 if p not in seen:
537 seen[p] = 1
550 seen[p] = 1
538 visit.append(p)
551 visit.append(p)
539 else:
552 else:
540 dest = ui.expandpath(dest or 'default-push', dest or 'default')
553 dest = ui.expandpath(dest or 'default-push', dest or 'default')
541 dest, branches = hg.parseurl(dest, opts.get('branch'))
554 dest, branches = hg.parseurl(dest, opts.get('branch'))
542 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
555 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
543 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
556 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
544 o = repo.findoutgoing(other, force=opts.get('force'))
557 o = repo.findoutgoing(other, force=opts.get('force'))
545
558
546 if revs:
559 if revs:
547 cg = repo.changegroupsubset(o, revs, 'bundle')
560 cg = repo.changegroupsubset(o, revs, 'bundle')
548 else:
561 else:
549 cg = repo.changegroup(o, 'bundle')
562 cg = repo.changegroup(o, 'bundle')
550
563
551 bundletype = opts.get('type', 'bzip2').lower()
564 bundletype = opts.get('type', 'bzip2').lower()
552 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
565 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
553 bundletype = btypes.get(bundletype)
566 bundletype = btypes.get(bundletype)
554 if bundletype not in changegroup.bundletypes:
567 if bundletype not in changegroup.bundletypes:
555 raise util.Abort(_('unknown bundle type specified with --type'))
568 raise util.Abort(_('unknown bundle type specified with --type'))
556
569
557 changegroup.writebundle(cg, fname, bundletype)
570 changegroup.writebundle(cg, fname, bundletype)
558
571
559 def cat(ui, repo, file1, *pats, **opts):
572 def cat(ui, repo, file1, *pats, **opts):
560 """output the current or given revision of files
573 """output the current or given revision of files
561
574
562 Print the specified files as they were at the given revision. If
575 Print the specified files as they were at the given revision. If
563 no revision is given, the parent of the working directory is used,
576 no revision is given, the parent of the working directory is used,
564 or tip if no revision is checked out.
577 or tip if no revision is checked out.
565
578
566 Output may be to a file, in which case the name of the file is
579 Output may be to a file, in which case the name of the file is
567 given using a format string. The formatting rules are the same as
580 given using a format string. The formatting rules are the same as
568 for the export command, with the following additions:
581 for the export command, with the following additions:
569
582
570 :``%s``: basename of file being printed
583 :``%s``: basename of file being printed
571 :``%d``: dirname of file being printed, or '.' if in repository root
584 :``%d``: dirname of file being printed, or '.' if in repository root
572 :``%p``: root-relative path name of file being printed
585 :``%p``: root-relative path name of file being printed
573 """
586 """
574 ctx = repo[opts.get('rev')]
587 ctx = repo[opts.get('rev')]
575 err = 1
588 err = 1
576 m = cmdutil.match(repo, (file1,) + pats, opts)
589 m = cmdutil.match(repo, (file1,) + pats, opts)
577 for abs in ctx.walk(m):
590 for abs in ctx.walk(m):
578 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
591 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
579 data = ctx[abs].data()
592 data = ctx[abs].data()
580 if opts.get('decode'):
593 if opts.get('decode'):
581 data = repo.wwritedata(abs, data)
594 data = repo.wwritedata(abs, data)
582 fp.write(data)
595 fp.write(data)
583 err = 0
596 err = 0
584 return err
597 return err
585
598
586 def clone(ui, source, dest=None, **opts):
599 def clone(ui, source, dest=None, **opts):
587 """make a copy of an existing repository
600 """make a copy of an existing repository
588
601
589 Create a copy of an existing repository in a new directory.
602 Create a copy of an existing repository in a new directory.
590
603
591 If no destination directory name is specified, it defaults to the
604 If no destination directory name is specified, it defaults to the
592 basename of the source.
605 basename of the source.
593
606
594 The location of the source is added to the new repository's
607 The location of the source is added to the new repository's
595 .hg/hgrc file, as the default to be used for future pulls.
608 .hg/hgrc file, as the default to be used for future pulls.
596
609
597 See 'hg help urls' for valid source format details.
610 See 'hg help urls' for valid source format details.
598
611
599 It is possible to specify an ``ssh://`` URL as the destination, but no
612 It is possible to specify an ``ssh://`` URL as the destination, but no
600 .hg/hgrc and working directory will be created on the remote side.
613 .hg/hgrc and working directory will be created on the remote side.
601 Please see 'hg help urls' for important details about ``ssh://`` URLs.
614 Please see 'hg help urls' for important details about ``ssh://`` URLs.
602
615
603 If the -U/--noupdate option is specified, the new clone will contain
616 If the -U/--noupdate option is specified, the new clone will contain
604 only a repository (.hg) and no working copy (the working copy parent
617 only a repository (.hg) and no working copy (the working copy parent
605 will be the null changeset). Otherwise, clone will initially check
618 will be the null changeset). Otherwise, clone will initially check
606 out (in order of precedence):
619 out (in order of precedence):
607
620
608 a) the changeset, tag or branch specified with -u/--updaterev
621 a) the changeset, tag or branch specified with -u/--updaterev
609 b) the changeset, tag or branch given with the first -r/--rev
622 b) the changeset, tag or branch given with the first -r/--rev
610 c) the branch given with the first -b/--branch
623 c) the branch given with the first -b/--branch
611 d) the branch given with the url#branch source syntax
624 d) the branch given with the url#branch source syntax
612 e) the head of the default branch
625 e) the head of the default branch
613
626
614 Use 'hg clone -u . src dst' to checkout the source repository's
627 Use 'hg clone -u . src dst' to checkout the source repository's
615 parent changeset (applicable for local source repositories only).
628 parent changeset (applicable for local source repositories only).
616
629
617 A set of changesets (tags, or branch names) to pull may be specified
630 A set of changesets (tags, or branch names) to pull may be specified
618 by listing each changeset (tag, or branch name) with -r/--rev.
631 by listing each changeset (tag, or branch name) with -r/--rev.
619 If -r/--rev is used, the cloned repository will contain only a subset
632 If -r/--rev is used, the cloned repository will contain only a subset
620 of the changesets of the source repository. Only the set of changesets
633 of the changesets of the source repository. Only the set of changesets
621 defined by all -r/--rev options (including all their ancestors)
634 defined by all -r/--rev options (including all their ancestors)
622 will be pulled into the destination repository.
635 will be pulled into the destination repository.
623 No subsequent changesets (including subsequent tags) will be present
636 No subsequent changesets (including subsequent tags) will be present
624 in the destination.
637 in the destination.
625
638
626 Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
639 Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
627 local source repositories.
640 local source repositories.
628
641
629 For efficiency, hardlinks are used for cloning whenever the source
642 For efficiency, hardlinks are used for cloning whenever the source
630 and destination are on the same filesystem (note this applies only
643 and destination are on the same filesystem (note this applies only
631 to the repository data, not to the checked out files). Some
644 to the repository data, not to the checked out files). Some
632 filesystems, such as AFS, implement hardlinking incorrectly, but
645 filesystems, such as AFS, implement hardlinking incorrectly, but
633 do not report errors. In these cases, use the --pull option to
646 do not report errors. In these cases, use the --pull option to
634 avoid hardlinking.
647 avoid hardlinking.
635
648
636 In some cases, you can clone repositories and checked out files
649 In some cases, you can clone repositories and checked out files
637 using full hardlinks with ::
650 using full hardlinks with ::
638
651
639 $ cp -al REPO REPOCLONE
652 $ cp -al REPO REPOCLONE
640
653
641 This is the fastest way to clone, but it is not always safe. The
654 This is the fastest way to clone, but it is not always safe. The
642 operation is not atomic (making sure REPO is not modified during
655 operation is not atomic (making sure REPO is not modified during
643 the operation is up to you) and you have to make sure your editor
656 the operation is up to you) and you have to make sure your editor
644 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
657 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
645 this is not compatible with certain extensions that place their
658 this is not compatible with certain extensions that place their
646 metadata under the .hg directory, such as mq.
659 metadata under the .hg directory, such as mq.
647 """
660 """
648 if opts.get('noupdate') and opts.get('updaterev'):
661 if opts.get('noupdate') and opts.get('updaterev'):
649 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
662 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
650
663
651 hg.clone(cmdutil.remoteui(ui, opts), source, dest,
664 hg.clone(cmdutil.remoteui(ui, opts), source, dest,
652 pull=opts.get('pull'),
665 pull=opts.get('pull'),
653 stream=opts.get('uncompressed'),
666 stream=opts.get('uncompressed'),
654 rev=opts.get('rev'),
667 rev=opts.get('rev'),
655 update=opts.get('updaterev') or not opts.get('noupdate'),
668 update=opts.get('updaterev') or not opts.get('noupdate'),
656 branch=opts.get('branch'))
669 branch=opts.get('branch'))
657
670
658 def commit(ui, repo, *pats, **opts):
671 def commit(ui, repo, *pats, **opts):
659 """commit the specified files or all outstanding changes
672 """commit the specified files or all outstanding changes
660
673
661 Commit changes to the given files into the repository. Unlike a
674 Commit changes to the given files into the repository. Unlike a
662 centralized RCS, this operation is a local operation. See hg push
675 centralized RCS, this operation is a local operation. See hg push
663 for a way to actively distribute your changes.
676 for a way to actively distribute your changes.
664
677
665 If a list of files is omitted, all changes reported by "hg status"
678 If a list of files is omitted, all changes reported by "hg status"
666 will be committed.
679 will be committed.
667
680
668 If you are committing the result of a merge, do not provide any
681 If you are committing the result of a merge, do not provide any
669 filenames or -I/-X filters.
682 filenames or -I/-X filters.
670
683
671 If no commit message is specified, the configured editor is
684 If no commit message is specified, the configured editor is
672 started to prompt you for a message.
685 started to prompt you for a message.
673
686
674 See 'hg help dates' for a list of formats valid for -d/--date.
687 See 'hg help dates' for a list of formats valid for -d/--date.
675 """
688 """
676 extra = {}
689 extra = {}
677 if opts.get('close_branch'):
690 if opts.get('close_branch'):
678 extra['close'] = 1
691 extra['close'] = 1
679 e = cmdutil.commiteditor
692 e = cmdutil.commiteditor
680 if opts.get('force_editor'):
693 if opts.get('force_editor'):
681 e = cmdutil.commitforceeditor
694 e = cmdutil.commitforceeditor
682
695
683 def commitfunc(ui, repo, message, match, opts):
696 def commitfunc(ui, repo, message, match, opts):
684 return repo.commit(message, opts.get('user'), opts.get('date'), match,
697 return repo.commit(message, opts.get('user'), opts.get('date'), match,
685 editor=e, extra=extra)
698 editor=e, extra=extra)
686
699
687 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
700 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
688 if not node:
701 if not node:
689 ui.status(_("nothing changed\n"))
702 ui.status(_("nothing changed\n"))
690 return
703 return
691 cl = repo.changelog
704 cl = repo.changelog
692 rev = cl.rev(node)
705 rev = cl.rev(node)
693 parents = cl.parentrevs(rev)
706 parents = cl.parentrevs(rev)
694 if rev - 1 in parents:
707 if rev - 1 in parents:
695 # one of the parents was the old tip
708 # one of the parents was the old tip
696 pass
709 pass
697 elif (parents == (nullrev, nullrev) or
710 elif (parents == (nullrev, nullrev) or
698 len(cl.heads(cl.node(parents[0]))) > 1 and
711 len(cl.heads(cl.node(parents[0]))) > 1 and
699 (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)):
712 (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)):
700 ui.status(_('created new head\n'))
713 ui.status(_('created new head\n'))
701
714
702 if ui.debugflag:
715 if ui.debugflag:
703 ui.write(_('committed changeset %d:%s\n') % (rev, hex(node)))
716 ui.write(_('committed changeset %d:%s\n') % (rev, hex(node)))
704 elif ui.verbose:
717 elif ui.verbose:
705 ui.write(_('committed changeset %d:%s\n') % (rev, short(node)))
718 ui.write(_('committed changeset %d:%s\n') % (rev, short(node)))
706
719
707 def copy(ui, repo, *pats, **opts):
720 def copy(ui, repo, *pats, **opts):
708 """mark files as copied for the next commit
721 """mark files as copied for the next commit
709
722
710 Mark dest as having copies of source files. If dest is a
723 Mark dest as having copies of source files. If dest is a
711 directory, copies are put in that directory. If dest is a file,
724 directory, copies are put in that directory. If dest is a file,
712 the source must be a single file.
725 the source must be a single file.
713
726
714 By default, this command copies the contents of files as they
727 By default, this command copies the contents of files as they
715 exist in the working directory. If invoked with -A/--after, the
728 exist in the working directory. If invoked with -A/--after, the
716 operation is recorded, but no copying is performed.
729 operation is recorded, but no copying is performed.
717
730
718 This command takes effect with the next commit. To undo a copy
731 This command takes effect with the next commit. To undo a copy
719 before that, see hg revert.
732 before that, see hg revert.
720 """
733 """
721 wlock = repo.wlock(False)
734 wlock = repo.wlock(False)
722 try:
735 try:
723 return cmdutil.copy(ui, repo, pats, opts)
736 return cmdutil.copy(ui, repo, pats, opts)
724 finally:
737 finally:
725 wlock.release()
738 wlock.release()
726
739
727 def debugancestor(ui, repo, *args):
740 def debugancestor(ui, repo, *args):
728 """find the ancestor revision of two revisions in a given index"""
741 """find the ancestor revision of two revisions in a given index"""
729 if len(args) == 3:
742 if len(args) == 3:
730 index, rev1, rev2 = args
743 index, rev1, rev2 = args
731 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
744 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
732 lookup = r.lookup
745 lookup = r.lookup
733 elif len(args) == 2:
746 elif len(args) == 2:
734 if not repo:
747 if not repo:
735 raise util.Abort(_("There is no Mercurial repository here "
748 raise util.Abort(_("There is no Mercurial repository here "
736 "(.hg not found)"))
749 "(.hg not found)"))
737 rev1, rev2 = args
750 rev1, rev2 = args
738 r = repo.changelog
751 r = repo.changelog
739 lookup = repo.lookup
752 lookup = repo.lookup
740 else:
753 else:
741 raise util.Abort(_('either two or three arguments required'))
754 raise util.Abort(_('either two or three arguments required'))
742 a = r.ancestor(lookup(rev1), lookup(rev2))
755 a = r.ancestor(lookup(rev1), lookup(rev2))
743 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
756 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
744
757
745 def debugcommands(ui, cmd='', *args):
758 def debugcommands(ui, cmd='', *args):
746 for cmd, vals in sorted(table.iteritems()):
759 for cmd, vals in sorted(table.iteritems()):
747 cmd = cmd.split('|')[0].strip('^')
760 cmd = cmd.split('|')[0].strip('^')
748 opts = ', '.join([i[1] for i in vals[1]])
761 opts = ', '.join([i[1] for i in vals[1]])
749 ui.write('%s: %s\n' % (cmd, opts))
762 ui.write('%s: %s\n' % (cmd, opts))
750
763
751 def debugcomplete(ui, cmd='', **opts):
764 def debugcomplete(ui, cmd='', **opts):
752 """returns the completion list associated with the given command"""
765 """returns the completion list associated with the given command"""
753
766
754 if opts.get('options'):
767 if opts.get('options'):
755 options = []
768 options = []
756 otables = [globalopts]
769 otables = [globalopts]
757 if cmd:
770 if cmd:
758 aliases, entry = cmdutil.findcmd(cmd, table, False)
771 aliases, entry = cmdutil.findcmd(cmd, table, False)
759 otables.append(entry[1])
772 otables.append(entry[1])
760 for t in otables:
773 for t in otables:
761 for o in t:
774 for o in t:
762 if o[0]:
775 if o[0]:
763 options.append('-%s' % o[0])
776 options.append('-%s' % o[0])
764 options.append('--%s' % o[1])
777 options.append('--%s' % o[1])
765 ui.write("%s\n" % "\n".join(options))
778 ui.write("%s\n" % "\n".join(options))
766 return
779 return
767
780
768 cmdlist = cmdutil.findpossible(cmd, table)
781 cmdlist = cmdutil.findpossible(cmd, table)
769 if ui.verbose:
782 if ui.verbose:
770 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
783 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
771 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
784 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
772
785
773 def debugfsinfo(ui, path = "."):
786 def debugfsinfo(ui, path = "."):
774 open('.debugfsinfo', 'w').write('')
787 open('.debugfsinfo', 'w').write('')
775 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
788 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
776 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
789 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
777 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
790 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
778 and 'yes' or 'no'))
791 and 'yes' or 'no'))
779 os.unlink('.debugfsinfo')
792 os.unlink('.debugfsinfo')
780
793
781 def debugrebuildstate(ui, repo, rev="tip"):
794 def debugrebuildstate(ui, repo, rev="tip"):
782 """rebuild the dirstate as it would look like for the given revision"""
795 """rebuild the dirstate as it would look like for the given revision"""
783 ctx = repo[rev]
796 ctx = repo[rev]
784 wlock = repo.wlock()
797 wlock = repo.wlock()
785 try:
798 try:
786 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
799 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
787 finally:
800 finally:
788 wlock.release()
801 wlock.release()
789
802
790 def debugcheckstate(ui, repo):
803 def debugcheckstate(ui, repo):
791 """validate the correctness of the current dirstate"""
804 """validate the correctness of the current dirstate"""
792 parent1, parent2 = repo.dirstate.parents()
805 parent1, parent2 = repo.dirstate.parents()
793 m1 = repo[parent1].manifest()
806 m1 = repo[parent1].manifest()
794 m2 = repo[parent2].manifest()
807 m2 = repo[parent2].manifest()
795 errors = 0
808 errors = 0
796 for f in repo.dirstate:
809 for f in repo.dirstate:
797 state = repo.dirstate[f]
810 state = repo.dirstate[f]
798 if state in "nr" and f not in m1:
811 if state in "nr" and f not in m1:
799 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
812 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
800 errors += 1
813 errors += 1
801 if state in "a" and f in m1:
814 if state in "a" and f in m1:
802 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
815 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
803 errors += 1
816 errors += 1
804 if state in "m" and f not in m1 and f not in m2:
817 if state in "m" and f not in m1 and f not in m2:
805 ui.warn(_("%s in state %s, but not in either manifest\n") %
818 ui.warn(_("%s in state %s, but not in either manifest\n") %
806 (f, state))
819 (f, state))
807 errors += 1
820 errors += 1
808 for f in m1:
821 for f in m1:
809 state = repo.dirstate[f]
822 state = repo.dirstate[f]
810 if state not in "nrm":
823 if state not in "nrm":
811 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
824 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
812 errors += 1
825 errors += 1
813 if errors:
826 if errors:
814 error = _(".hg/dirstate inconsistent with current parent's manifest")
827 error = _(".hg/dirstate inconsistent with current parent's manifest")
815 raise util.Abort(error)
828 raise util.Abort(error)
816
829
817 def showconfig(ui, repo, *values, **opts):
830 def showconfig(ui, repo, *values, **opts):
818 """show combined config settings from all hgrc files
831 """show combined config settings from all hgrc files
819
832
820 With no arguments, print names and values of all config items.
833 With no arguments, print names and values of all config items.
821
834
822 With one argument of the form section.name, print just the value
835 With one argument of the form section.name, print just the value
823 of that config item.
836 of that config item.
824
837
825 With multiple arguments, print names and values of all config
838 With multiple arguments, print names and values of all config
826 items with matching section names.
839 items with matching section names.
827
840
828 With --debug, the source (filename and line number) is printed
841 With --debug, the source (filename and line number) is printed
829 for each config item.
842 for each config item.
830 """
843 """
831
844
832 untrusted = bool(opts.get('untrusted'))
845 untrusted = bool(opts.get('untrusted'))
833 if values:
846 if values:
834 if len([v for v in values if '.' in v]) > 1:
847 if len([v for v in values if '.' in v]) > 1:
835 raise util.Abort(_('only one config item permitted'))
848 raise util.Abort(_('only one config item permitted'))
836 for section, name, value in ui.walkconfig(untrusted=untrusted):
849 for section, name, value in ui.walkconfig(untrusted=untrusted):
837 sectname = section + '.' + name
850 sectname = section + '.' + name
838 if values:
851 if values:
839 for v in values:
852 for v in values:
840 if v == section:
853 if v == section:
841 ui.debug('%s: ' %
854 ui.debug('%s: ' %
842 ui.configsource(section, name, untrusted))
855 ui.configsource(section, name, untrusted))
843 ui.write('%s=%s\n' % (sectname, value))
856 ui.write('%s=%s\n' % (sectname, value))
844 elif v == sectname:
857 elif v == sectname:
845 ui.debug('%s: ' %
858 ui.debug('%s: ' %
846 ui.configsource(section, name, untrusted))
859 ui.configsource(section, name, untrusted))
847 ui.write(value, '\n')
860 ui.write(value, '\n')
848 else:
861 else:
849 ui.debug('%s: ' %
862 ui.debug('%s: ' %
850 ui.configsource(section, name, untrusted))
863 ui.configsource(section, name, untrusted))
851 ui.write('%s=%s\n' % (sectname, value))
864 ui.write('%s=%s\n' % (sectname, value))
852
865
853 def debugsetparents(ui, repo, rev1, rev2=None):
866 def debugsetparents(ui, repo, rev1, rev2=None):
854 """manually set the parents of the current working directory
867 """manually set the parents of the current working directory
855
868
856 This is useful for writing repository conversion tools, but should
869 This is useful for writing repository conversion tools, but should
857 be used with care.
870 be used with care.
858 """
871 """
859
872
860 if not rev2:
873 if not rev2:
861 rev2 = hex(nullid)
874 rev2 = hex(nullid)
862
875
863 wlock = repo.wlock()
876 wlock = repo.wlock()
864 try:
877 try:
865 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
878 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
866 finally:
879 finally:
867 wlock.release()
880 wlock.release()
868
881
869 def debugstate(ui, repo, nodates=None):
882 def debugstate(ui, repo, nodates=None):
870 """show the contents of the current dirstate"""
883 """show the contents of the current dirstate"""
871 timestr = ""
884 timestr = ""
872 showdate = not nodates
885 showdate = not nodates
873 for file_, ent in sorted(repo.dirstate._map.iteritems()):
886 for file_, ent in sorted(repo.dirstate._map.iteritems()):
874 if showdate:
887 if showdate:
875 if ent[3] == -1:
888 if ent[3] == -1:
876 # Pad or slice to locale representation
889 # Pad or slice to locale representation
877 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
890 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
878 time.localtime(0)))
891 time.localtime(0)))
879 timestr = 'unset'
892 timestr = 'unset'
880 timestr = (timestr[:locale_len] +
893 timestr = (timestr[:locale_len] +
881 ' ' * (locale_len - len(timestr)))
894 ' ' * (locale_len - len(timestr)))
882 else:
895 else:
883 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
896 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
884 time.localtime(ent[3]))
897 time.localtime(ent[3]))
885 if ent[1] & 020000:
898 if ent[1] & 020000:
886 mode = 'lnk'
899 mode = 'lnk'
887 else:
900 else:
888 mode = '%3o' % (ent[1] & 0777)
901 mode = '%3o' % (ent[1] & 0777)
889 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
902 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
890 for f in repo.dirstate.copies():
903 for f in repo.dirstate.copies():
891 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
904 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
892
905
893 def debugsub(ui, repo, rev=None):
906 def debugsub(ui, repo, rev=None):
894 if rev == '':
907 if rev == '':
895 rev = None
908 rev = None
896 for k, v in sorted(repo[rev].substate.items()):
909 for k, v in sorted(repo[rev].substate.items()):
897 ui.write('path %s\n' % k)
910 ui.write('path %s\n' % k)
898 ui.write(' source %s\n' % v[0])
911 ui.write(' source %s\n' % v[0])
899 ui.write(' revision %s\n' % v[1])
912 ui.write(' revision %s\n' % v[1])
900
913
901 def debugdata(ui, file_, rev):
914 def debugdata(ui, file_, rev):
902 """dump the contents of a data file revision"""
915 """dump the contents of a data file revision"""
903 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
916 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
904 try:
917 try:
905 ui.write(r.revision(r.lookup(rev)))
918 ui.write(r.revision(r.lookup(rev)))
906 except KeyError:
919 except KeyError:
907 raise util.Abort(_('invalid revision identifier %s') % rev)
920 raise util.Abort(_('invalid revision identifier %s') % rev)
908
921
909 def debugdate(ui, date, range=None, **opts):
922 def debugdate(ui, date, range=None, **opts):
910 """parse and display a date"""
923 """parse and display a date"""
911 if opts["extended"]:
924 if opts["extended"]:
912 d = util.parsedate(date, util.extendeddateformats)
925 d = util.parsedate(date, util.extendeddateformats)
913 else:
926 else:
914 d = util.parsedate(date)
927 d = util.parsedate(date)
915 ui.write("internal: %s %s\n" % d)
928 ui.write("internal: %s %s\n" % d)
916 ui.write("standard: %s\n" % util.datestr(d))
929 ui.write("standard: %s\n" % util.datestr(d))
917 if range:
930 if range:
918 m = util.matchdate(range)
931 m = util.matchdate(range)
919 ui.write("match: %s\n" % m(d[0]))
932 ui.write("match: %s\n" % m(d[0]))
920
933
921 def debugindex(ui, file_):
934 def debugindex(ui, file_):
922 """dump the contents of an index file"""
935 """dump the contents of an index file"""
923 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
936 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
924 ui.write(" rev offset length base linkrev"
937 ui.write(" rev offset length base linkrev"
925 " nodeid p1 p2\n")
938 " nodeid p1 p2\n")
926 for i in r:
939 for i in r:
927 node = r.node(i)
940 node = r.node(i)
928 try:
941 try:
929 pp = r.parents(node)
942 pp = r.parents(node)
930 except:
943 except:
931 pp = [nullid, nullid]
944 pp = [nullid, nullid]
932 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
945 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
933 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
946 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
934 short(node), short(pp[0]), short(pp[1])))
947 short(node), short(pp[0]), short(pp[1])))
935
948
936 def debugindexdot(ui, file_):
949 def debugindexdot(ui, file_):
937 """dump an index DAG as a graphviz dot file"""
950 """dump an index DAG as a graphviz dot file"""
938 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
951 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
939 ui.write("digraph G {\n")
952 ui.write("digraph G {\n")
940 for i in r:
953 for i in r:
941 node = r.node(i)
954 node = r.node(i)
942 pp = r.parents(node)
955 pp = r.parents(node)
943 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
956 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
944 if pp[1] != nullid:
957 if pp[1] != nullid:
945 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
958 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
946 ui.write("}\n")
959 ui.write("}\n")
947
960
948 def debuginstall(ui):
961 def debuginstall(ui):
949 '''test Mercurial installation'''
962 '''test Mercurial installation'''
950
963
951 def writetemp(contents):
964 def writetemp(contents):
952 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
965 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
953 f = os.fdopen(fd, "wb")
966 f = os.fdopen(fd, "wb")
954 f.write(contents)
967 f.write(contents)
955 f.close()
968 f.close()
956 return name
969 return name
957
970
958 problems = 0
971 problems = 0
959
972
960 # encoding
973 # encoding
961 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
974 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
962 try:
975 try:
963 encoding.fromlocal("test")
976 encoding.fromlocal("test")
964 except util.Abort, inst:
977 except util.Abort, inst:
965 ui.write(" %s\n" % inst)
978 ui.write(" %s\n" % inst)
966 ui.write(_(" (check that your locale is properly set)\n"))
979 ui.write(_(" (check that your locale is properly set)\n"))
967 problems += 1
980 problems += 1
968
981
969 # compiled modules
982 # compiled modules
970 ui.status(_("Checking extensions...\n"))
983 ui.status(_("Checking extensions...\n"))
971 try:
984 try:
972 import bdiff, mpatch, base85
985 import bdiff, mpatch, base85
973 except Exception, inst:
986 except Exception, inst:
974 ui.write(" %s\n" % inst)
987 ui.write(" %s\n" % inst)
975 ui.write(_(" One or more extensions could not be found"))
988 ui.write(_(" One or more extensions could not be found"))
976 ui.write(_(" (check that you compiled the extensions)\n"))
989 ui.write(_(" (check that you compiled the extensions)\n"))
977 problems += 1
990 problems += 1
978
991
979 # templates
992 # templates
980 ui.status(_("Checking templates...\n"))
993 ui.status(_("Checking templates...\n"))
981 try:
994 try:
982 import templater
995 import templater
983 templater.templater(templater.templatepath("map-cmdline.default"))
996 templater.templater(templater.templatepath("map-cmdline.default"))
984 except Exception, inst:
997 except Exception, inst:
985 ui.write(" %s\n" % inst)
998 ui.write(" %s\n" % inst)
986 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
999 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
987 problems += 1
1000 problems += 1
988
1001
989 # patch
1002 # patch
990 ui.status(_("Checking patch...\n"))
1003 ui.status(_("Checking patch...\n"))
991 patchproblems = 0
1004 patchproblems = 0
992 a = "1\n2\n3\n4\n"
1005 a = "1\n2\n3\n4\n"
993 b = "1\n2\n3\ninsert\n4\n"
1006 b = "1\n2\n3\ninsert\n4\n"
994 fa = writetemp(a)
1007 fa = writetemp(a)
995 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
1008 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
996 os.path.basename(fa))
1009 os.path.basename(fa))
997 fd = writetemp(d)
1010 fd = writetemp(d)
998
1011
999 files = {}
1012 files = {}
1000 try:
1013 try:
1001 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
1014 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
1002 except util.Abort, e:
1015 except util.Abort, e:
1003 ui.write(_(" patch call failed:\n"))
1016 ui.write(_(" patch call failed:\n"))
1004 ui.write(" " + str(e) + "\n")
1017 ui.write(" " + str(e) + "\n")
1005 patchproblems += 1
1018 patchproblems += 1
1006 else:
1019 else:
1007 if list(files) != [os.path.basename(fa)]:
1020 if list(files) != [os.path.basename(fa)]:
1008 ui.write(_(" unexpected patch output!\n"))
1021 ui.write(_(" unexpected patch output!\n"))
1009 patchproblems += 1
1022 patchproblems += 1
1010 a = open(fa).read()
1023 a = open(fa).read()
1011 if a != b:
1024 if a != b:
1012 ui.write(_(" patch test failed!\n"))
1025 ui.write(_(" patch test failed!\n"))
1013 patchproblems += 1
1026 patchproblems += 1
1014
1027
1015 if patchproblems:
1028 if patchproblems:
1016 if ui.config('ui', 'patch'):
1029 if ui.config('ui', 'patch'):
1017 ui.write(_(" (Current patch tool may be incompatible with patch,"
1030 ui.write(_(" (Current patch tool may be incompatible with patch,"
1018 " or misconfigured. Please check your .hgrc file)\n"))
1031 " or misconfigured. Please check your .hgrc file)\n"))
1019 else:
1032 else:
1020 ui.write(_(" Internal patcher failure, please report this error"
1033 ui.write(_(" Internal patcher failure, please report this error"
1021 " to http://mercurial.selenic.com/bts/\n"))
1034 " to http://mercurial.selenic.com/bts/\n"))
1022 problems += patchproblems
1035 problems += patchproblems
1023
1036
1024 os.unlink(fa)
1037 os.unlink(fa)
1025 os.unlink(fd)
1038 os.unlink(fd)
1026
1039
1027 # editor
1040 # editor
1028 ui.status(_("Checking commit editor...\n"))
1041 ui.status(_("Checking commit editor...\n"))
1029 editor = ui.geteditor()
1042 editor = ui.geteditor()
1030 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
1043 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
1031 if not cmdpath:
1044 if not cmdpath:
1032 if editor == 'vi':
1045 if editor == 'vi':
1033 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
1046 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
1034 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1047 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1035 else:
1048 else:
1036 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
1049 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
1037 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1050 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
1038 problems += 1
1051 problems += 1
1039
1052
1040 # check username
1053 # check username
1041 ui.status(_("Checking username...\n"))
1054 ui.status(_("Checking username...\n"))
1042 try:
1055 try:
1043 user = ui.username()
1056 user = ui.username()
1044 except util.Abort, e:
1057 except util.Abort, e:
1045 ui.write(" %s\n" % e)
1058 ui.write(" %s\n" % e)
1046 ui.write(_(" (specify a username in your .hgrc file)\n"))
1059 ui.write(_(" (specify a username in your .hgrc file)\n"))
1047 problems += 1
1060 problems += 1
1048
1061
1049 if not problems:
1062 if not problems:
1050 ui.status(_("No problems detected\n"))
1063 ui.status(_("No problems detected\n"))
1051 else:
1064 else:
1052 ui.write(_("%s problems detected,"
1065 ui.write(_("%s problems detected,"
1053 " please check your install!\n") % problems)
1066 " please check your install!\n") % problems)
1054
1067
1055 return problems
1068 return problems
1056
1069
1057 def debugrename(ui, repo, file1, *pats, **opts):
1070 def debugrename(ui, repo, file1, *pats, **opts):
1058 """dump rename information"""
1071 """dump rename information"""
1059
1072
1060 ctx = repo[opts.get('rev')]
1073 ctx = repo[opts.get('rev')]
1061 m = cmdutil.match(repo, (file1,) + pats, opts)
1074 m = cmdutil.match(repo, (file1,) + pats, opts)
1062 for abs in ctx.walk(m):
1075 for abs in ctx.walk(m):
1063 fctx = ctx[abs]
1076 fctx = ctx[abs]
1064 o = fctx.filelog().renamed(fctx.filenode())
1077 o = fctx.filelog().renamed(fctx.filenode())
1065 rel = m.rel(abs)
1078 rel = m.rel(abs)
1066 if o:
1079 if o:
1067 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1080 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1068 else:
1081 else:
1069 ui.write(_("%s not renamed\n") % rel)
1082 ui.write(_("%s not renamed\n") % rel)
1070
1083
1071 def debugwalk(ui, repo, *pats, **opts):
1084 def debugwalk(ui, repo, *pats, **opts):
1072 """show how files match on given patterns"""
1085 """show how files match on given patterns"""
1073 m = cmdutil.match(repo, pats, opts)
1086 m = cmdutil.match(repo, pats, opts)
1074 items = list(repo.walk(m))
1087 items = list(repo.walk(m))
1075 if not items:
1088 if not items:
1076 return
1089 return
1077 fmt = 'f %%-%ds %%-%ds %%s' % (
1090 fmt = 'f %%-%ds %%-%ds %%s' % (
1078 max([len(abs) for abs in items]),
1091 max([len(abs) for abs in items]),
1079 max([len(m.rel(abs)) for abs in items]))
1092 max([len(m.rel(abs)) for abs in items]))
1080 for abs in items:
1093 for abs in items:
1081 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1094 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1082 ui.write("%s\n" % line.rstrip())
1095 ui.write("%s\n" % line.rstrip())
1083
1096
1084 def diff(ui, repo, *pats, **opts):
1097 def diff(ui, repo, *pats, **opts):
1085 """diff repository (or selected files)
1098 """diff repository (or selected files)
1086
1099
1087 Show differences between revisions for the specified files.
1100 Show differences between revisions for the specified files.
1088
1101
1089 Differences between files are shown using the unified diff format.
1102 Differences between files are shown using the unified diff format.
1090
1103
1091 NOTE: diff may generate unexpected results for merges, as it will
1104 NOTE: diff may generate unexpected results for merges, as it will
1092 default to comparing against the working directory's first parent
1105 default to comparing against the working directory's first parent
1093 changeset if no revisions are specified.
1106 changeset if no revisions are specified.
1094
1107
1095 When two revision arguments are given, then changes are shown
1108 When two revision arguments are given, then changes are shown
1096 between those revisions. If only one revision is specified then
1109 between those revisions. If only one revision is specified then
1097 that revision is compared to the working directory, and, when no
1110 that revision is compared to the working directory, and, when no
1098 revisions are specified, the working directory files are compared
1111 revisions are specified, the working directory files are compared
1099 to its parent.
1112 to its parent.
1100
1113
1101 Without the -a/--text option, diff will avoid generating diffs of
1114 Without the -a/--text option, diff will avoid generating diffs of
1102 files it detects as binary. With -a, diff will generate a diff
1115 files it detects as binary. With -a, diff will generate a diff
1103 anyway, probably with undesirable results.
1116 anyway, probably with undesirable results.
1104
1117
1105 Use the -g/--git option to generate diffs in the git extended diff
1118 Use the -g/--git option to generate diffs in the git extended diff
1106 format. For more information, read 'hg help diffs'.
1119 format. For more information, read 'hg help diffs'.
1107 """
1120 """
1108
1121
1109 revs = opts.get('rev')
1122 revs = opts.get('rev')
1110 change = opts.get('change')
1123 change = opts.get('change')
1111 stat = opts.get('stat')
1124 stat = opts.get('stat')
1112 reverse = opts.get('reverse')
1125 reverse = opts.get('reverse')
1113
1126
1114 if revs and change:
1127 if revs and change:
1115 msg = _('cannot specify --rev and --change at the same time')
1128 msg = _('cannot specify --rev and --change at the same time')
1116 raise util.Abort(msg)
1129 raise util.Abort(msg)
1117 elif change:
1130 elif change:
1118 node2 = repo.lookup(change)
1131 node2 = repo.lookup(change)
1119 node1 = repo[node2].parents()[0].node()
1132 node1 = repo[node2].parents()[0].node()
1120 else:
1133 else:
1121 node1, node2 = cmdutil.revpair(repo, revs)
1134 node1, node2 = cmdutil.revpair(repo, revs)
1122
1135
1123 if reverse:
1136 if reverse:
1124 node1, node2 = node2, node1
1137 node1, node2 = node2, node1
1125
1138
1126 if stat:
1139 if stat:
1127 opts['unified'] = '0'
1140 opts['unified'] = '0'
1128 diffopts = patch.diffopts(ui, opts)
1141 diffopts = patch.diffopts(ui, opts)
1129
1142
1130 m = cmdutil.match(repo, pats, opts)
1143 m = cmdutil.match(repo, pats, opts)
1131 it = patch.diff(repo, node1, node2, match=m, opts=diffopts)
1144 it = patch.diff(repo, node1, node2, match=m, opts=diffopts)
1132 if stat:
1145 if stat:
1133 width = ui.interactive() and util.termwidth() or 80
1146 width = ui.interactive() and util.termwidth() or 80
1134 ui.write(patch.diffstat(util.iterlines(it), width=width,
1147 ui.write(patch.diffstat(util.iterlines(it), width=width,
1135 git=diffopts.git))
1148 git=diffopts.git))
1136 else:
1149 else:
1137 for chunk in it:
1150 for chunk in it:
1138 ui.write(chunk)
1151 ui.write(chunk)
1139
1152
1140 def export(ui, repo, *changesets, **opts):
1153 def export(ui, repo, *changesets, **opts):
1141 """dump the header and diffs for one or more changesets
1154 """dump the header and diffs for one or more changesets
1142
1155
1143 Print the changeset header and diffs for one or more revisions.
1156 Print the changeset header and diffs for one or more revisions.
1144
1157
1145 The information shown in the changeset header is: author, date,
1158 The information shown in the changeset header is: author, date,
1146 branch name (if non-default), changeset hash, parent(s) and commit
1159 branch name (if non-default), changeset hash, parent(s) and commit
1147 comment.
1160 comment.
1148
1161
1149 NOTE: export may generate unexpected diff output for merge
1162 NOTE: export may generate unexpected diff output for merge
1150 changesets, as it will compare the merge changeset against its
1163 changesets, as it will compare the merge changeset against its
1151 first parent only.
1164 first parent only.
1152
1165
1153 Output may be to a file, in which case the name of the file is
1166 Output may be to a file, in which case the name of the file is
1154 given using a format string. The formatting rules are as follows:
1167 given using a format string. The formatting rules are as follows:
1155
1168
1156 :``%%``: literal "%" character
1169 :``%%``: literal "%" character
1157 :``%H``: changeset hash (40 bytes of hexadecimal)
1170 :``%H``: changeset hash (40 bytes of hexadecimal)
1158 :``%N``: number of patches being generated
1171 :``%N``: number of patches being generated
1159 :``%R``: changeset revision number
1172 :``%R``: changeset revision number
1160 :``%b``: basename of the exporting repository
1173 :``%b``: basename of the exporting repository
1161 :``%h``: short-form changeset hash (12 bytes of hexadecimal)
1174 :``%h``: short-form changeset hash (12 bytes of hexadecimal)
1162 :``%n``: zero-padded sequence number, starting at 1
1175 :``%n``: zero-padded sequence number, starting at 1
1163 :``%r``: zero-padded changeset revision number
1176 :``%r``: zero-padded changeset revision number
1164
1177
1165 Without the -a/--text option, export will avoid generating diffs
1178 Without the -a/--text option, export will avoid generating diffs
1166 of files it detects as binary. With -a, export will generate a
1179 of files it detects as binary. With -a, export will generate a
1167 diff anyway, probably with undesirable results.
1180 diff anyway, probably with undesirable results.
1168
1181
1169 Use the -g/--git option to generate diffs in the git extended diff
1182 Use the -g/--git option to generate diffs in the git extended diff
1170 format. See 'hg help diffs' for more information.
1183 format. See 'hg help diffs' for more information.
1171
1184
1172 With the --switch-parent option, the diff will be against the
1185 With the --switch-parent option, the diff will be against the
1173 second parent. It can be useful to review a merge.
1186 second parent. It can be useful to review a merge.
1174 """
1187 """
1175 changesets += tuple(opts.get('rev', []))
1188 changesets += tuple(opts.get('rev', []))
1176 if not changesets:
1189 if not changesets:
1177 raise util.Abort(_("export requires at least one changeset"))
1190 raise util.Abort(_("export requires at least one changeset"))
1178 revs = cmdutil.revrange(repo, changesets)
1191 revs = cmdutil.revrange(repo, changesets)
1179 if len(revs) > 1:
1192 if len(revs) > 1:
1180 ui.note(_('exporting patches:\n'))
1193 ui.note(_('exporting patches:\n'))
1181 else:
1194 else:
1182 ui.note(_('exporting patch:\n'))
1195 ui.note(_('exporting patch:\n'))
1183 patch.export(repo, revs, template=opts.get('output'),
1196 patch.export(repo, revs, template=opts.get('output'),
1184 switch_parent=opts.get('switch_parent'),
1197 switch_parent=opts.get('switch_parent'),
1185 opts=patch.diffopts(ui, opts))
1198 opts=patch.diffopts(ui, opts))
1186
1199
1187 def forget(ui, repo, *pats, **opts):
1200 def forget(ui, repo, *pats, **opts):
1188 """forget the specified files on the next commit
1201 """forget the specified files on the next commit
1189
1202
1190 Mark the specified files so they will no longer be tracked
1203 Mark the specified files so they will no longer be tracked
1191 after the next commit.
1204 after the next commit.
1192
1205
1193 This only removes files from the current branch, not from the
1206 This only removes files from the current branch, not from the
1194 entire project history, and it does not delete them from the
1207 entire project history, and it does not delete them from the
1195 working directory.
1208 working directory.
1196
1209
1197 To undo a forget before the next commit, see hg add.
1210 To undo a forget before the next commit, see hg add.
1198 """
1211 """
1199
1212
1200 if not pats:
1213 if not pats:
1201 raise util.Abort(_('no files specified'))
1214 raise util.Abort(_('no files specified'))
1202
1215
1203 m = cmdutil.match(repo, pats, opts)
1216 m = cmdutil.match(repo, pats, opts)
1204 s = repo.status(match=m, clean=True)
1217 s = repo.status(match=m, clean=True)
1205 forget = sorted(s[0] + s[1] + s[3] + s[6])
1218 forget = sorted(s[0] + s[1] + s[3] + s[6])
1206
1219
1207 for f in m.files():
1220 for f in m.files():
1208 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
1221 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
1209 ui.warn(_('not removing %s: file is already untracked\n')
1222 ui.warn(_('not removing %s: file is already untracked\n')
1210 % m.rel(f))
1223 % m.rel(f))
1211
1224
1212 for f in forget:
1225 for f in forget:
1213 if ui.verbose or not m.exact(f):
1226 if ui.verbose or not m.exact(f):
1214 ui.status(_('removing %s\n') % m.rel(f))
1227 ui.status(_('removing %s\n') % m.rel(f))
1215
1228
1216 repo.remove(forget, unlink=False)
1229 repo.remove(forget, unlink=False)
1217
1230
1218 def grep(ui, repo, pattern, *pats, **opts):
1231 def grep(ui, repo, pattern, *pats, **opts):
1219 """search for a pattern in specified files and revisions
1232 """search for a pattern in specified files and revisions
1220
1233
1221 Search revisions of files for a regular expression.
1234 Search revisions of files for a regular expression.
1222
1235
1223 This command behaves differently than Unix grep. It only accepts
1236 This command behaves differently than Unix grep. It only accepts
1224 Python/Perl regexps. It searches repository history, not the
1237 Python/Perl regexps. It searches repository history, not the
1225 working directory. It always prints the revision number in which a
1238 working directory. It always prints the revision number in which a
1226 match appears.
1239 match appears.
1227
1240
1228 By default, grep only prints output for the first revision of a
1241 By default, grep only prints output for the first revision of a
1229 file in which it finds a match. To get it to print every revision
1242 file in which it finds a match. To get it to print every revision
1230 that contains a change in match status ("-" for a match that
1243 that contains a change in match status ("-" for a match that
1231 becomes a non-match, or "+" for a non-match that becomes a match),
1244 becomes a non-match, or "+" for a non-match that becomes a match),
1232 use the --all flag.
1245 use the --all flag.
1233 """
1246 """
1234 reflags = 0
1247 reflags = 0
1235 if opts.get('ignore_case'):
1248 if opts.get('ignore_case'):
1236 reflags |= re.I
1249 reflags |= re.I
1237 try:
1250 try:
1238 regexp = re.compile(pattern, reflags)
1251 regexp = re.compile(pattern, reflags)
1239 except Exception, inst:
1252 except Exception, inst:
1240 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1253 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1241 return None
1254 return None
1242 sep, eol = ':', '\n'
1255 sep, eol = ':', '\n'
1243 if opts.get('print0'):
1256 if opts.get('print0'):
1244 sep = eol = '\0'
1257 sep = eol = '\0'
1245
1258
1246 getfile = util.lrucachefunc(repo.file)
1259 getfile = util.lrucachefunc(repo.file)
1247
1260
1248 def matchlines(body):
1261 def matchlines(body):
1249 begin = 0
1262 begin = 0
1250 linenum = 0
1263 linenum = 0
1251 while True:
1264 while True:
1252 match = regexp.search(body, begin)
1265 match = regexp.search(body, begin)
1253 if not match:
1266 if not match:
1254 break
1267 break
1255 mstart, mend = match.span()
1268 mstart, mend = match.span()
1256 linenum += body.count('\n', begin, mstart) + 1
1269 linenum += body.count('\n', begin, mstart) + 1
1257 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1270 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1258 begin = body.find('\n', mend) + 1 or len(body)
1271 begin = body.find('\n', mend) + 1 or len(body)
1259 lend = begin - 1
1272 lend = begin - 1
1260 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1273 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1261
1274
1262 class linestate(object):
1275 class linestate(object):
1263 def __init__(self, line, linenum, colstart, colend):
1276 def __init__(self, line, linenum, colstart, colend):
1264 self.line = line
1277 self.line = line
1265 self.linenum = linenum
1278 self.linenum = linenum
1266 self.colstart = colstart
1279 self.colstart = colstart
1267 self.colend = colend
1280 self.colend = colend
1268
1281
1269 def __hash__(self):
1282 def __hash__(self):
1270 return hash((self.linenum, self.line))
1283 return hash((self.linenum, self.line))
1271
1284
1272 def __eq__(self, other):
1285 def __eq__(self, other):
1273 return self.line == other.line
1286 return self.line == other.line
1274
1287
1275 matches = {}
1288 matches = {}
1276 copies = {}
1289 copies = {}
1277 def grepbody(fn, rev, body):
1290 def grepbody(fn, rev, body):
1278 matches[rev].setdefault(fn, [])
1291 matches[rev].setdefault(fn, [])
1279 m = matches[rev][fn]
1292 m = matches[rev][fn]
1280 for lnum, cstart, cend, line in matchlines(body):
1293 for lnum, cstart, cend, line in matchlines(body):
1281 s = linestate(line, lnum, cstart, cend)
1294 s = linestate(line, lnum, cstart, cend)
1282 m.append(s)
1295 m.append(s)
1283
1296
1284 def difflinestates(a, b):
1297 def difflinestates(a, b):
1285 sm = difflib.SequenceMatcher(None, a, b)
1298 sm = difflib.SequenceMatcher(None, a, b)
1286 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1299 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1287 if tag == 'insert':
1300 if tag == 'insert':
1288 for i in xrange(blo, bhi):
1301 for i in xrange(blo, bhi):
1289 yield ('+', b[i])
1302 yield ('+', b[i])
1290 elif tag == 'delete':
1303 elif tag == 'delete':
1291 for i in xrange(alo, ahi):
1304 for i in xrange(alo, ahi):
1292 yield ('-', a[i])
1305 yield ('-', a[i])
1293 elif tag == 'replace':
1306 elif tag == 'replace':
1294 for i in xrange(alo, ahi):
1307 for i in xrange(alo, ahi):
1295 yield ('-', a[i])
1308 yield ('-', a[i])
1296 for i in xrange(blo, bhi):
1309 for i in xrange(blo, bhi):
1297 yield ('+', b[i])
1310 yield ('+', b[i])
1298
1311
1299 def display(fn, ctx, pstates, states):
1312 def display(fn, ctx, pstates, states):
1300 rev = ctx.rev()
1313 rev = ctx.rev()
1301 datefunc = ui.quiet and util.shortdate or util.datestr
1314 datefunc = ui.quiet and util.shortdate or util.datestr
1302 found = False
1315 found = False
1303 filerevmatches = {}
1316 filerevmatches = {}
1304 if opts.get('all'):
1317 if opts.get('all'):
1305 iter = difflinestates(pstates, states)
1318 iter = difflinestates(pstates, states)
1306 else:
1319 else:
1307 iter = [('', l) for l in states]
1320 iter = [('', l) for l in states]
1308 for change, l in iter:
1321 for change, l in iter:
1309 cols = [fn, str(rev)]
1322 cols = [fn, str(rev)]
1310 if opts.get('line_number'):
1323 if opts.get('line_number'):
1311 cols.append(str(l.linenum))
1324 cols.append(str(l.linenum))
1312 if opts.get('all'):
1325 if opts.get('all'):
1313 cols.append(change)
1326 cols.append(change)
1314 if opts.get('user'):
1327 if opts.get('user'):
1315 cols.append(ui.shortuser(ctx.user()))
1328 cols.append(ui.shortuser(ctx.user()))
1316 if opts.get('date'):
1329 if opts.get('date'):
1317 cols.append(datefunc(ctx.date()))
1330 cols.append(datefunc(ctx.date()))
1318 if opts.get('files_with_matches'):
1331 if opts.get('files_with_matches'):
1319 c = (fn, rev)
1332 c = (fn, rev)
1320 if c in filerevmatches:
1333 if c in filerevmatches:
1321 continue
1334 continue
1322 filerevmatches[c] = 1
1335 filerevmatches[c] = 1
1323 else:
1336 else:
1324 cols.append(l.line)
1337 cols.append(l.line)
1325 ui.write(sep.join(cols), eol)
1338 ui.write(sep.join(cols), eol)
1326 found = True
1339 found = True
1327 return found
1340 return found
1328
1341
1329 skip = {}
1342 skip = {}
1330 revfiles = {}
1343 revfiles = {}
1331 matchfn = cmdutil.match(repo, pats, opts)
1344 matchfn = cmdutil.match(repo, pats, opts)
1332 found = False
1345 found = False
1333 follow = opts.get('follow')
1346 follow = opts.get('follow')
1334
1347
1335 def prep(ctx, fns):
1348 def prep(ctx, fns):
1336 rev = ctx.rev()
1349 rev = ctx.rev()
1337 pctx = ctx.parents()[0]
1350 pctx = ctx.parents()[0]
1338 parent = pctx.rev()
1351 parent = pctx.rev()
1339 matches.setdefault(rev, {})
1352 matches.setdefault(rev, {})
1340 matches.setdefault(parent, {})
1353 matches.setdefault(parent, {})
1341 files = revfiles.setdefault(rev, [])
1354 files = revfiles.setdefault(rev, [])
1342 for fn in fns:
1355 for fn in fns:
1343 flog = getfile(fn)
1356 flog = getfile(fn)
1344 try:
1357 try:
1345 fnode = ctx.filenode(fn)
1358 fnode = ctx.filenode(fn)
1346 except error.LookupError:
1359 except error.LookupError:
1347 continue
1360 continue
1348
1361
1349 copied = flog.renamed(fnode)
1362 copied = flog.renamed(fnode)
1350 copy = follow and copied and copied[0]
1363 copy = follow and copied and copied[0]
1351 if copy:
1364 if copy:
1352 copies.setdefault(rev, {})[fn] = copy
1365 copies.setdefault(rev, {})[fn] = copy
1353 if fn in skip:
1366 if fn in skip:
1354 if copy:
1367 if copy:
1355 skip[copy] = True
1368 skip[copy] = True
1356 continue
1369 continue
1357 files.append(fn)
1370 files.append(fn)
1358
1371
1359 if fn not in matches[rev]:
1372 if fn not in matches[rev]:
1360 grepbody(fn, rev, flog.read(fnode))
1373 grepbody(fn, rev, flog.read(fnode))
1361
1374
1362 pfn = copy or fn
1375 pfn = copy or fn
1363 if pfn not in matches[parent]:
1376 if pfn not in matches[parent]:
1364 try:
1377 try:
1365 fnode = pctx.filenode(pfn)
1378 fnode = pctx.filenode(pfn)
1366 grepbody(pfn, parent, flog.read(fnode))
1379 grepbody(pfn, parent, flog.read(fnode))
1367 except error.LookupError:
1380 except error.LookupError:
1368 pass
1381 pass
1369
1382
1370 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1383 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1371 rev = ctx.rev()
1384 rev = ctx.rev()
1372 parent = ctx.parents()[0].rev()
1385 parent = ctx.parents()[0].rev()
1373 for fn in sorted(revfiles.get(rev, [])):
1386 for fn in sorted(revfiles.get(rev, [])):
1374 states = matches[rev][fn]
1387 states = matches[rev][fn]
1375 copy = copies.get(rev, {}).get(fn)
1388 copy = copies.get(rev, {}).get(fn)
1376 if fn in skip:
1389 if fn in skip:
1377 if copy:
1390 if copy:
1378 skip[copy] = True
1391 skip[copy] = True
1379 continue
1392 continue
1380 pstates = matches.get(parent, {}).get(copy or fn, [])
1393 pstates = matches.get(parent, {}).get(copy or fn, [])
1381 if pstates or states:
1394 if pstates or states:
1382 r = display(fn, ctx, pstates, states)
1395 r = display(fn, ctx, pstates, states)
1383 found = found or r
1396 found = found or r
1384 if r and not opts.get('all'):
1397 if r and not opts.get('all'):
1385 skip[fn] = True
1398 skip[fn] = True
1386 if copy:
1399 if copy:
1387 skip[copy] = True
1400 skip[copy] = True
1388 del matches[rev]
1401 del matches[rev]
1389 del revfiles[rev]
1402 del revfiles[rev]
1390
1403
1391 def heads(ui, repo, *branchrevs, **opts):
1404 def heads(ui, repo, *branchrevs, **opts):
1392 """show current repository heads or show branch heads
1405 """show current repository heads or show branch heads
1393
1406
1394 With no arguments, show all repository branch heads.
1407 With no arguments, show all repository branch heads.
1395
1408
1396 Repository "heads" are changesets with no child changesets. They are
1409 Repository "heads" are changesets with no child changesets. They are
1397 where development generally takes place and are the usual targets
1410 where development generally takes place and are the usual targets
1398 for update and merge operations. Branch heads are changesets that have
1411 for update and merge operations. Branch heads are changesets that have
1399 no child changeset on the same branch.
1412 no child changeset on the same branch.
1400
1413
1401 If one or more REVs are given, only branch heads on the branches
1414 If one or more REVs are given, only branch heads on the branches
1402 associated with the specified changesets are shown.
1415 associated with the specified changesets are shown.
1403
1416
1404 If -c/--closed is specified, also show branch heads marked closed
1417 If -c/--closed is specified, also show branch heads marked closed
1405 (see hg commit --close-branch).
1418 (see hg commit --close-branch).
1406
1419
1407 If STARTREV is specified, only those heads that are descendants of
1420 If STARTREV is specified, only those heads that are descendants of
1408 STARTREV will be displayed.
1421 STARTREV will be displayed.
1409
1422
1410 If -t/--topo is specified, named branch mechanics will be ignored and only
1423 If -t/--topo is specified, named branch mechanics will be ignored and only
1411 changesets without children will be shown.
1424 changesets without children will be shown.
1412 """
1425 """
1413
1426
1414 if opts.get('rev'):
1427 if opts.get('rev'):
1415 start = repo.lookup(opts['rev'])
1428 start = repo.lookup(opts['rev'])
1416 else:
1429 else:
1417 start = None
1430 start = None
1418
1431
1419 if opts.get('topo'):
1432 if opts.get('topo'):
1420 heads = [repo[h] for h in repo.heads(start)]
1433 heads = [repo[h] for h in repo.heads(start)]
1421 else:
1434 else:
1422 heads = []
1435 heads = []
1423 for b, ls in repo.branchmap().iteritems():
1436 for b, ls in repo.branchmap().iteritems():
1424 if start is None:
1437 if start is None:
1425 heads += [repo[h] for h in ls]
1438 heads += [repo[h] for h in ls]
1426 continue
1439 continue
1427 startrev = repo.changelog.rev(start)
1440 startrev = repo.changelog.rev(start)
1428 descendants = set(repo.changelog.descendants(startrev))
1441 descendants = set(repo.changelog.descendants(startrev))
1429 descendants.add(startrev)
1442 descendants.add(startrev)
1430 rev = repo.changelog.rev
1443 rev = repo.changelog.rev
1431 heads += [repo[h] for h in ls if rev(h) in descendants]
1444 heads += [repo[h] for h in ls if rev(h) in descendants]
1432
1445
1433 if branchrevs:
1446 if branchrevs:
1434 decode, encode = encoding.fromlocal, encoding.tolocal
1447 decode, encode = encoding.fromlocal, encoding.tolocal
1435 branches = set(repo[decode(br)].branch() for br in branchrevs)
1448 branches = set(repo[decode(br)].branch() for br in branchrevs)
1436 heads = [h for h in heads if h.branch() in branches]
1449 heads = [h for h in heads if h.branch() in branches]
1437
1450
1438 if not opts.get('closed'):
1451 if not opts.get('closed'):
1439 heads = [h for h in heads if not h.extra().get('close')]
1452 heads = [h for h in heads if not h.extra().get('close')]
1440
1453
1441 if opts.get('active') and branchrevs:
1454 if opts.get('active') and branchrevs:
1442 dagheads = repo.heads(start)
1455 dagheads = repo.heads(start)
1443 heads = [h for h in heads if h.node() in dagheads]
1456 heads = [h for h in heads if h.node() in dagheads]
1444
1457
1445 if branchrevs:
1458 if branchrevs:
1446 haveheads = set(h.branch() for h in heads)
1459 haveheads = set(h.branch() for h in heads)
1447 if branches - haveheads:
1460 if branches - haveheads:
1448 headless = ', '.join(encode(b) for b in branches - haveheads)
1461 headless = ', '.join(encode(b) for b in branches - haveheads)
1449 msg = _('no open branch heads found on branches %s')
1462 msg = _('no open branch heads found on branches %s')
1450 if opts.get('rev'):
1463 if opts.get('rev'):
1451 msg += _(' (started at %s)' % opts['rev'])
1464 msg += _(' (started at %s)' % opts['rev'])
1452 ui.warn((msg + '\n') % headless)
1465 ui.warn((msg + '\n') % headless)
1453
1466
1454 if not heads:
1467 if not heads:
1455 return 1
1468 return 1
1456
1469
1457 heads = sorted(heads, key=lambda x: -x.rev())
1470 heads = sorted(heads, key=lambda x: -x.rev())
1458 displayer = cmdutil.show_changeset(ui, repo, opts)
1471 displayer = cmdutil.show_changeset(ui, repo, opts)
1459 for ctx in heads:
1472 for ctx in heads:
1460 displayer.show(ctx)
1473 displayer.show(ctx)
1461 displayer.close()
1474 displayer.close()
1462
1475
1463 def help_(ui, name=None, with_version=False, unknowncmd=False):
1476 def help_(ui, name=None, with_version=False, unknowncmd=False):
1464 """show help for a given topic or a help overview
1477 """show help for a given topic or a help overview
1465
1478
1466 With no arguments, print a list of commands with short help messages.
1479 With no arguments, print a list of commands with short help messages.
1467
1480
1468 Given a topic, extension, or command name, print help for that
1481 Given a topic, extension, or command name, print help for that
1469 topic."""
1482 topic."""
1470 option_lists = []
1483 option_lists = []
1471 textwidth = util.termwidth() - 2
1484 textwidth = util.termwidth() - 2
1472
1485
1473 def addglobalopts(aliases):
1486 def addglobalopts(aliases):
1474 if ui.verbose:
1487 if ui.verbose:
1475 option_lists.append((_("global options:"), globalopts))
1488 option_lists.append((_("global options:"), globalopts))
1476 if name == 'shortlist':
1489 if name == 'shortlist':
1477 option_lists.append((_('use "hg help" for the full list '
1490 option_lists.append((_('use "hg help" for the full list '
1478 'of commands'), ()))
1491 'of commands'), ()))
1479 else:
1492 else:
1480 if name == 'shortlist':
1493 if name == 'shortlist':
1481 msg = _('use "hg help" for the full list of commands '
1494 msg = _('use "hg help" for the full list of commands '
1482 'or "hg -v" for details')
1495 'or "hg -v" for details')
1483 elif aliases:
1496 elif aliases:
1484 msg = _('use "hg -v help%s" to show aliases and '
1497 msg = _('use "hg -v help%s" to show aliases and '
1485 'global options') % (name and " " + name or "")
1498 'global options') % (name and " " + name or "")
1486 else:
1499 else:
1487 msg = _('use "hg -v help %s" to show global options') % name
1500 msg = _('use "hg -v help %s" to show global options') % name
1488 option_lists.append((msg, ()))
1501 option_lists.append((msg, ()))
1489
1502
1490 def helpcmd(name):
1503 def helpcmd(name):
1491 if with_version:
1504 if with_version:
1492 version_(ui)
1505 version_(ui)
1493 ui.write('\n')
1506 ui.write('\n')
1494
1507
1495 try:
1508 try:
1496 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
1509 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
1497 except error.AmbiguousCommand, inst:
1510 except error.AmbiguousCommand, inst:
1498 # py3k fix: except vars can't be used outside the scope of the
1511 # py3k fix: except vars can't be used outside the scope of the
1499 # except block, nor can be used inside a lambda. python issue4617
1512 # except block, nor can be used inside a lambda. python issue4617
1500 prefix = inst.args[0]
1513 prefix = inst.args[0]
1501 select = lambda c: c.lstrip('^').startswith(prefix)
1514 select = lambda c: c.lstrip('^').startswith(prefix)
1502 helplist(_('list of commands:\n\n'), select)
1515 helplist(_('list of commands:\n\n'), select)
1503 return
1516 return
1504
1517
1505 # check if it's an invalid alias and display its error if it is
1518 # check if it's an invalid alias and display its error if it is
1506 if getattr(entry[0], 'badalias', False):
1519 if getattr(entry[0], 'badalias', False):
1507 if not unknowncmd:
1520 if not unknowncmd:
1508 entry[0](ui)
1521 entry[0](ui)
1509 return
1522 return
1510
1523
1511 # synopsis
1524 # synopsis
1512 if len(entry) > 2:
1525 if len(entry) > 2:
1513 if entry[2].startswith('hg'):
1526 if entry[2].startswith('hg'):
1514 ui.write("%s\n" % entry[2])
1527 ui.write("%s\n" % entry[2])
1515 else:
1528 else:
1516 ui.write('hg %s %s\n' % (aliases[0], entry[2]))
1529 ui.write('hg %s %s\n' % (aliases[0], entry[2]))
1517 else:
1530 else:
1518 ui.write('hg %s\n' % aliases[0])
1531 ui.write('hg %s\n' % aliases[0])
1519
1532
1520 # aliases
1533 # aliases
1521 if not ui.quiet and len(aliases) > 1:
1534 if not ui.quiet and len(aliases) > 1:
1522 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
1535 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
1523
1536
1524 # description
1537 # description
1525 doc = gettext(entry[0].__doc__)
1538 doc = gettext(entry[0].__doc__)
1526 if not doc:
1539 if not doc:
1527 doc = _("(no help text available)")
1540 doc = _("(no help text available)")
1528 if ui.quiet:
1541 if ui.quiet:
1529 doc = doc.splitlines()[0]
1542 doc = doc.splitlines()[0]
1530 keep = ui.verbose and ['verbose'] or []
1543 keep = ui.verbose and ['verbose'] or []
1531 formatted, pruned = minirst.format(doc, textwidth, keep=keep)
1544 formatted, pruned = minirst.format(doc, textwidth, keep=keep)
1532 ui.write("\n%s\n" % formatted)
1545 ui.write("\n%s\n" % formatted)
1533 if pruned:
1546 if pruned:
1534 ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
1547 ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
1535
1548
1536 if not ui.quiet:
1549 if not ui.quiet:
1537 # options
1550 # options
1538 if entry[1]:
1551 if entry[1]:
1539 option_lists.append((_("options:\n"), entry[1]))
1552 option_lists.append((_("options:\n"), entry[1]))
1540
1553
1541 addglobalopts(False)
1554 addglobalopts(False)
1542
1555
1543 def helplist(header, select=None):
1556 def helplist(header, select=None):
1544 h = {}
1557 h = {}
1545 cmds = {}
1558 cmds = {}
1546 for c, e in table.iteritems():
1559 for c, e in table.iteritems():
1547 f = c.split("|", 1)[0]
1560 f = c.split("|", 1)[0]
1548 if select and not select(f):
1561 if select and not select(f):
1549 continue
1562 continue
1550 if (not select and name != 'shortlist' and
1563 if (not select and name != 'shortlist' and
1551 e[0].__module__ != __name__):
1564 e[0].__module__ != __name__):
1552 continue
1565 continue
1553 if name == "shortlist" and not f.startswith("^"):
1566 if name == "shortlist" and not f.startswith("^"):
1554 continue
1567 continue
1555 f = f.lstrip("^")
1568 f = f.lstrip("^")
1556 if not ui.debugflag and f.startswith("debug"):
1569 if not ui.debugflag and f.startswith("debug"):
1557 continue
1570 continue
1558 doc = e[0].__doc__
1571 doc = e[0].__doc__
1559 if doc and 'DEPRECATED' in doc and not ui.verbose:
1572 if doc and 'DEPRECATED' in doc and not ui.verbose:
1560 continue
1573 continue
1561 doc = gettext(doc)
1574 doc = gettext(doc)
1562 if not doc:
1575 if not doc:
1563 doc = _("(no help text available)")
1576 doc = _("(no help text available)")
1564 h[f] = doc.splitlines()[0].rstrip()
1577 h[f] = doc.splitlines()[0].rstrip()
1565 cmds[f] = c.lstrip("^")
1578 cmds[f] = c.lstrip("^")
1566
1579
1567 if not h:
1580 if not h:
1568 ui.status(_('no commands defined\n'))
1581 ui.status(_('no commands defined\n'))
1569 return
1582 return
1570
1583
1571 ui.status(header)
1584 ui.status(header)
1572 fns = sorted(h)
1585 fns = sorted(h)
1573 m = max(map(len, fns))
1586 m = max(map(len, fns))
1574 for f in fns:
1587 for f in fns:
1575 if ui.verbose:
1588 if ui.verbose:
1576 commands = cmds[f].replace("|",", ")
1589 commands = cmds[f].replace("|",", ")
1577 ui.write(" %s:\n %s\n"%(commands, h[f]))
1590 ui.write(" %s:\n %s\n"%(commands, h[f]))
1578 else:
1591 else:
1579 ui.write(' %-*s %s\n' % (m, f, util.wrap(h[f], m + 4)))
1592 ui.write(' %-*s %s\n' % (m, f, util.wrap(h[f], m + 4)))
1580
1593
1581 if not ui.quiet:
1594 if not ui.quiet:
1582 addglobalopts(True)
1595 addglobalopts(True)
1583
1596
1584 def helptopic(name):
1597 def helptopic(name):
1585 for names, header, doc in help.helptable:
1598 for names, header, doc in help.helptable:
1586 if name in names:
1599 if name in names:
1587 break
1600 break
1588 else:
1601 else:
1589 raise error.UnknownCommand(name)
1602 raise error.UnknownCommand(name)
1590
1603
1591 # description
1604 # description
1592 if not doc:
1605 if not doc:
1593 doc = _("(no help text available)")
1606 doc = _("(no help text available)")
1594 if hasattr(doc, '__call__'):
1607 if hasattr(doc, '__call__'):
1595 doc = doc()
1608 doc = doc()
1596
1609
1597 ui.write("%s\n\n" % header)
1610 ui.write("%s\n\n" % header)
1598 ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
1611 ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
1599
1612
1600 def helpext(name):
1613 def helpext(name):
1601 try:
1614 try:
1602 mod = extensions.find(name)
1615 mod = extensions.find(name)
1603 doc = gettext(mod.__doc__) or _('no help text available')
1616 doc = gettext(mod.__doc__) or _('no help text available')
1604 except KeyError:
1617 except KeyError:
1605 mod = None
1618 mod = None
1606 doc = extensions.disabledext(name)
1619 doc = extensions.disabledext(name)
1607 if not doc:
1620 if not doc:
1608 raise error.UnknownCommand(name)
1621 raise error.UnknownCommand(name)
1609
1622
1610 if '\n' not in doc:
1623 if '\n' not in doc:
1611 head, tail = doc, ""
1624 head, tail = doc, ""
1612 else:
1625 else:
1613 head, tail = doc.split('\n', 1)
1626 head, tail = doc.split('\n', 1)
1614 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
1627 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
1615 if tail:
1628 if tail:
1616 ui.write(minirst.format(tail, textwidth))
1629 ui.write(minirst.format(tail, textwidth))
1617 ui.status('\n\n')
1630 ui.status('\n\n')
1618
1631
1619 if mod:
1632 if mod:
1620 try:
1633 try:
1621 ct = mod.cmdtable
1634 ct = mod.cmdtable
1622 except AttributeError:
1635 except AttributeError:
1623 ct = {}
1636 ct = {}
1624 modcmds = set([c.split('|', 1)[0] for c in ct])
1637 modcmds = set([c.split('|', 1)[0] for c in ct])
1625 helplist(_('list of commands:\n\n'), modcmds.__contains__)
1638 helplist(_('list of commands:\n\n'), modcmds.__contains__)
1626 else:
1639 else:
1627 ui.write(_('use "hg help extensions" for information on enabling '
1640 ui.write(_('use "hg help extensions" for information on enabling '
1628 'extensions\n'))
1641 'extensions\n'))
1629
1642
1630 def helpextcmd(name):
1643 def helpextcmd(name):
1631 cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict'))
1644 cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict'))
1632 doc = gettext(mod.__doc__).splitlines()[0]
1645 doc = gettext(mod.__doc__).splitlines()[0]
1633
1646
1634 msg = help.listexts(_("'%s' is provided by the following "
1647 msg = help.listexts(_("'%s' is provided by the following "
1635 "extension:") % cmd, {ext: doc}, len(ext),
1648 "extension:") % cmd, {ext: doc}, len(ext),
1636 indent=4)
1649 indent=4)
1637 ui.write(minirst.format(msg, textwidth))
1650 ui.write(minirst.format(msg, textwidth))
1638 ui.write('\n\n')
1651 ui.write('\n\n')
1639 ui.write(_('use "hg help extensions" for information on enabling '
1652 ui.write(_('use "hg help extensions" for information on enabling '
1640 'extensions\n'))
1653 'extensions\n'))
1641
1654
1642 if name and name != 'shortlist':
1655 if name and name != 'shortlist':
1643 i = None
1656 i = None
1644 if unknowncmd:
1657 if unknowncmd:
1645 queries = (helpextcmd,)
1658 queries = (helpextcmd,)
1646 else:
1659 else:
1647 queries = (helptopic, helpcmd, helpext, helpextcmd)
1660 queries = (helptopic, helpcmd, helpext, helpextcmd)
1648 for f in queries:
1661 for f in queries:
1649 try:
1662 try:
1650 f(name)
1663 f(name)
1651 i = None
1664 i = None
1652 break
1665 break
1653 except error.UnknownCommand, inst:
1666 except error.UnknownCommand, inst:
1654 i = inst
1667 i = inst
1655 if i:
1668 if i:
1656 raise i
1669 raise i
1657
1670
1658 else:
1671 else:
1659 # program name
1672 # program name
1660 if ui.verbose or with_version:
1673 if ui.verbose or with_version:
1661 version_(ui)
1674 version_(ui)
1662 else:
1675 else:
1663 ui.status(_("Mercurial Distributed SCM\n"))
1676 ui.status(_("Mercurial Distributed SCM\n"))
1664 ui.status('\n')
1677 ui.status('\n')
1665
1678
1666 # list of commands
1679 # list of commands
1667 if name == "shortlist":
1680 if name == "shortlist":
1668 header = _('basic commands:\n\n')
1681 header = _('basic commands:\n\n')
1669 else:
1682 else:
1670 header = _('list of commands:\n\n')
1683 header = _('list of commands:\n\n')
1671
1684
1672 helplist(header)
1685 helplist(header)
1673 if name != 'shortlist':
1686 if name != 'shortlist':
1674 exts, maxlength = extensions.enabled()
1687 exts, maxlength = extensions.enabled()
1675 text = help.listexts(_('enabled extensions:'), exts, maxlength)
1688 text = help.listexts(_('enabled extensions:'), exts, maxlength)
1676 if text:
1689 if text:
1677 ui.write("\n%s\n" % minirst.format(text, textwidth))
1690 ui.write("\n%s\n" % minirst.format(text, textwidth))
1678
1691
1679 # list all option lists
1692 # list all option lists
1680 opt_output = []
1693 opt_output = []
1681 for title, options in option_lists:
1694 for title, options in option_lists:
1682 opt_output.append(("\n%s" % title, None))
1695 opt_output.append(("\n%s" % title, None))
1683 for shortopt, longopt, default, desc in options:
1696 for shortopt, longopt, default, desc in options:
1684 if _("DEPRECATED") in desc and not ui.verbose:
1697 if _("DEPRECATED") in desc and not ui.verbose:
1685 continue
1698 continue
1686 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
1699 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
1687 longopt and " --%s" % longopt),
1700 longopt and " --%s" % longopt),
1688 "%s%s" % (desc,
1701 "%s%s" % (desc,
1689 default
1702 default
1690 and _(" (default: %s)") % default
1703 and _(" (default: %s)") % default
1691 or "")))
1704 or "")))
1692
1705
1693 if not name:
1706 if not name:
1694 ui.write(_("\nadditional help topics:\n\n"))
1707 ui.write(_("\nadditional help topics:\n\n"))
1695 topics = []
1708 topics = []
1696 for names, header, doc in help.helptable:
1709 for names, header, doc in help.helptable:
1697 topics.append((sorted(names, key=len, reverse=True)[0], header))
1710 topics.append((sorted(names, key=len, reverse=True)[0], header))
1698 topics_len = max([len(s[0]) for s in topics])
1711 topics_len = max([len(s[0]) for s in topics])
1699 for t, desc in topics:
1712 for t, desc in topics:
1700 ui.write(" %-*s %s\n" % (topics_len, t, desc))
1713 ui.write(" %-*s %s\n" % (topics_len, t, desc))
1701
1714
1702 if opt_output:
1715 if opt_output:
1703 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
1716 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
1704 for first, second in opt_output:
1717 for first, second in opt_output:
1705 if second:
1718 if second:
1706 second = util.wrap(second, opts_len + 3)
1719 second = util.wrap(second, opts_len + 3)
1707 ui.write(" %-*s %s\n" % (opts_len, first, second))
1720 ui.write(" %-*s %s\n" % (opts_len, first, second))
1708 else:
1721 else:
1709 ui.write("%s\n" % first)
1722 ui.write("%s\n" % first)
1710
1723
1711 def identify(ui, repo, source=None,
1724 def identify(ui, repo, source=None,
1712 rev=None, num=None, id=None, branch=None, tags=None):
1725 rev=None, num=None, id=None, branch=None, tags=None):
1713 """identify the working copy or specified revision
1726 """identify the working copy or specified revision
1714
1727
1715 With no revision, print a summary of the current state of the
1728 With no revision, print a summary of the current state of the
1716 repository.
1729 repository.
1717
1730
1718 Specifying a path to a repository root or Mercurial bundle will
1731 Specifying a path to a repository root or Mercurial bundle will
1719 cause lookup to operate on that repository/bundle.
1732 cause lookup to operate on that repository/bundle.
1720
1733
1721 This summary identifies the repository state using one or two
1734 This summary identifies the repository state using one or two
1722 parent hash identifiers, followed by a "+" if there are
1735 parent hash identifiers, followed by a "+" if there are
1723 uncommitted changes in the working directory, a list of tags for
1736 uncommitted changes in the working directory, a list of tags for
1724 this revision and a branch name for non-default branches.
1737 this revision and a branch name for non-default branches.
1725 """
1738 """
1726
1739
1727 if not repo and not source:
1740 if not repo and not source:
1728 raise util.Abort(_("There is no Mercurial repository here "
1741 raise util.Abort(_("There is no Mercurial repository here "
1729 "(.hg not found)"))
1742 "(.hg not found)"))
1730
1743
1731 hexfunc = ui.debugflag and hex or short
1744 hexfunc = ui.debugflag and hex or short
1732 default = not (num or id or branch or tags)
1745 default = not (num or id or branch or tags)
1733 output = []
1746 output = []
1734
1747
1735 revs = []
1748 revs = []
1736 if source:
1749 if source:
1737 source, branches = hg.parseurl(ui.expandpath(source))
1750 source, branches = hg.parseurl(ui.expandpath(source))
1738 repo = hg.repository(ui, source)
1751 repo = hg.repository(ui, source)
1739 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
1752 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
1740
1753
1741 if not repo.local():
1754 if not repo.local():
1742 if not rev and revs:
1755 if not rev and revs:
1743 rev = revs[0]
1756 rev = revs[0]
1744 if not rev:
1757 if not rev:
1745 rev = "tip"
1758 rev = "tip"
1746 if num or branch or tags:
1759 if num or branch or tags:
1747 raise util.Abort(
1760 raise util.Abort(
1748 "can't query remote revision number, branch, or tags")
1761 "can't query remote revision number, branch, or tags")
1749 output = [hexfunc(repo.lookup(rev))]
1762 output = [hexfunc(repo.lookup(rev))]
1750 elif not rev:
1763 elif not rev:
1751 ctx = repo[None]
1764 ctx = repo[None]
1752 parents = ctx.parents()
1765 parents = ctx.parents()
1753 changed = False
1766 changed = False
1754 if default or id or num:
1767 if default or id or num:
1755 changed = ctx.files() + ctx.deleted()
1768 changed = ctx.files() + ctx.deleted()
1756 if default or id:
1769 if default or id:
1757 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
1770 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
1758 (changed) and "+" or "")]
1771 (changed) and "+" or "")]
1759 if num:
1772 if num:
1760 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
1773 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
1761 (changed) and "+" or ""))
1774 (changed) and "+" or ""))
1762 else:
1775 else:
1763 ctx = repo[rev]
1776 ctx = repo[rev]
1764 if default or id:
1777 if default or id:
1765 output = [hexfunc(ctx.node())]
1778 output = [hexfunc(ctx.node())]
1766 if num:
1779 if num:
1767 output.append(str(ctx.rev()))
1780 output.append(str(ctx.rev()))
1768
1781
1769 if repo.local() and default and not ui.quiet:
1782 if repo.local() and default and not ui.quiet:
1770 b = encoding.tolocal(ctx.branch())
1783 b = encoding.tolocal(ctx.branch())
1771 if b != 'default':
1784 if b != 'default':
1772 output.append("(%s)" % b)
1785 output.append("(%s)" % b)
1773
1786
1774 # multiple tags for a single parent separated by '/'
1787 # multiple tags for a single parent separated by '/'
1775 t = "/".join(ctx.tags())
1788 t = "/".join(ctx.tags())
1776 if t:
1789 if t:
1777 output.append(t)
1790 output.append(t)
1778
1791
1779 if branch:
1792 if branch:
1780 output.append(encoding.tolocal(ctx.branch()))
1793 output.append(encoding.tolocal(ctx.branch()))
1781
1794
1782 if tags:
1795 if tags:
1783 output.extend(ctx.tags())
1796 output.extend(ctx.tags())
1784
1797
1785 ui.write("%s\n" % ' '.join(output))
1798 ui.write("%s\n" % ' '.join(output))
1786
1799
1787 def import_(ui, repo, patch1, *patches, **opts):
1800 def import_(ui, repo, patch1, *patches, **opts):
1788 """import an ordered set of patches
1801 """import an ordered set of patches
1789
1802
1790 Import a list of patches and commit them individually (unless
1803 Import a list of patches and commit them individually (unless
1791 --no-commit is specified).
1804 --no-commit is specified).
1792
1805
1793 If there are outstanding changes in the working directory, import
1806 If there are outstanding changes in the working directory, import
1794 will abort unless given the -f/--force flag.
1807 will abort unless given the -f/--force flag.
1795
1808
1796 You can import a patch straight from a mail message. Even patches
1809 You can import a patch straight from a mail message. Even patches
1797 as attachments work (to use the body part, it must have type
1810 as attachments work (to use the body part, it must have type
1798 text/plain or text/x-patch). From and Subject headers of email
1811 text/plain or text/x-patch). From and Subject headers of email
1799 message are used as default committer and commit message. All
1812 message are used as default committer and commit message. All
1800 text/plain body parts before first diff are added to commit
1813 text/plain body parts before first diff are added to commit
1801 message.
1814 message.
1802
1815
1803 If the imported patch was generated by hg export, user and
1816 If the imported patch was generated by hg export, user and
1804 description from patch override values from message headers and
1817 description from patch override values from message headers and
1805 body. Values given on command line with -m/--message and -u/--user
1818 body. Values given on command line with -m/--message and -u/--user
1806 override these.
1819 override these.
1807
1820
1808 If --exact is specified, import will set the working directory to
1821 If --exact is specified, import will set the working directory to
1809 the parent of each patch before applying it, and will abort if the
1822 the parent of each patch before applying it, and will abort if the
1810 resulting changeset has a different ID than the one recorded in
1823 resulting changeset has a different ID than the one recorded in
1811 the patch. This may happen due to character set problems or other
1824 the patch. This may happen due to character set problems or other
1812 deficiencies in the text patch format.
1825 deficiencies in the text patch format.
1813
1826
1814 With -s/--similarity, hg will attempt to discover renames and
1827 With -s/--similarity, hg will attempt to discover renames and
1815 copies in the patch in the same way as 'addremove'.
1828 copies in the patch in the same way as 'addremove'.
1816
1829
1817 To read a patch from standard input, use "-" as the patch name. If
1830 To read a patch from standard input, use "-" as the patch name. If
1818 a URL is specified, the patch will be downloaded from it.
1831 a URL is specified, the patch will be downloaded from it.
1819 See 'hg help dates' for a list of formats valid for -d/--date.
1832 See 'hg help dates' for a list of formats valid for -d/--date.
1820 """
1833 """
1821 patches = (patch1,) + patches
1834 patches = (patch1,) + patches
1822
1835
1823 date = opts.get('date')
1836 date = opts.get('date')
1824 if date:
1837 if date:
1825 opts['date'] = util.parsedate(date)
1838 opts['date'] = util.parsedate(date)
1826
1839
1827 try:
1840 try:
1828 sim = float(opts.get('similarity') or 0)
1841 sim = float(opts.get('similarity') or 0)
1829 except ValueError:
1842 except ValueError:
1830 raise util.Abort(_('similarity must be a number'))
1843 raise util.Abort(_('similarity must be a number'))
1831 if sim < 0 or sim > 100:
1844 if sim < 0 or sim > 100:
1832 raise util.Abort(_('similarity must be between 0 and 100'))
1845 raise util.Abort(_('similarity must be between 0 and 100'))
1833
1846
1834 if opts.get('exact') or not opts.get('force'):
1847 if opts.get('exact') or not opts.get('force'):
1835 cmdutil.bail_if_changed(repo)
1848 cmdutil.bail_if_changed(repo)
1836
1849
1837 d = opts["base"]
1850 d = opts["base"]
1838 strip = opts["strip"]
1851 strip = opts["strip"]
1839 wlock = lock = None
1852 wlock = lock = None
1840
1853
1841 def tryone(ui, hunk):
1854 def tryone(ui, hunk):
1842 tmpname, message, user, date, branch, nodeid, p1, p2 = \
1855 tmpname, message, user, date, branch, nodeid, p1, p2 = \
1843 patch.extract(ui, hunk)
1856 patch.extract(ui, hunk)
1844
1857
1845 if not tmpname:
1858 if not tmpname:
1846 return None
1859 return None
1847 commitid = _('to working directory')
1860 commitid = _('to working directory')
1848
1861
1849 try:
1862 try:
1850 cmdline_message = cmdutil.logmessage(opts)
1863 cmdline_message = cmdutil.logmessage(opts)
1851 if cmdline_message:
1864 if cmdline_message:
1852 # pickup the cmdline msg
1865 # pickup the cmdline msg
1853 message = cmdline_message
1866 message = cmdline_message
1854 elif message:
1867 elif message:
1855 # pickup the patch msg
1868 # pickup the patch msg
1856 message = message.strip()
1869 message = message.strip()
1857 else:
1870 else:
1858 # launch the editor
1871 # launch the editor
1859 message = None
1872 message = None
1860 ui.debug('message:\n%s\n' % message)
1873 ui.debug('message:\n%s\n' % message)
1861
1874
1862 wp = repo.parents()
1875 wp = repo.parents()
1863 if opts.get('exact'):
1876 if opts.get('exact'):
1864 if not nodeid or not p1:
1877 if not nodeid or not p1:
1865 raise util.Abort(_('not a Mercurial patch'))
1878 raise util.Abort(_('not a Mercurial patch'))
1866 p1 = repo.lookup(p1)
1879 p1 = repo.lookup(p1)
1867 p2 = repo.lookup(p2 or hex(nullid))
1880 p2 = repo.lookup(p2 or hex(nullid))
1868
1881
1869 if p1 != wp[0].node():
1882 if p1 != wp[0].node():
1870 hg.clean(repo, p1)
1883 hg.clean(repo, p1)
1871 repo.dirstate.setparents(p1, p2)
1884 repo.dirstate.setparents(p1, p2)
1872 elif p2:
1885 elif p2:
1873 try:
1886 try:
1874 p1 = repo.lookup(p1)
1887 p1 = repo.lookup(p1)
1875 p2 = repo.lookup(p2)
1888 p2 = repo.lookup(p2)
1876 if p1 == wp[0].node():
1889 if p1 == wp[0].node():
1877 repo.dirstate.setparents(p1, p2)
1890 repo.dirstate.setparents(p1, p2)
1878 except error.RepoError:
1891 except error.RepoError:
1879 pass
1892 pass
1880 if opts.get('exact') or opts.get('import_branch'):
1893 if opts.get('exact') or opts.get('import_branch'):
1881 repo.dirstate.setbranch(branch or 'default')
1894 repo.dirstate.setbranch(branch or 'default')
1882
1895
1883 files = {}
1896 files = {}
1884 try:
1897 try:
1885 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
1898 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
1886 files=files, eolmode=None)
1899 files=files, eolmode=None)
1887 finally:
1900 finally:
1888 files = patch.updatedir(ui, repo, files,
1901 files = patch.updatedir(ui, repo, files,
1889 similarity=sim / 100.0)
1902 similarity=sim / 100.0)
1890 if not opts.get('no_commit'):
1903 if not opts.get('no_commit'):
1891 if opts.get('exact'):
1904 if opts.get('exact'):
1892 m = None
1905 m = None
1893 else:
1906 else:
1894 m = cmdutil.matchfiles(repo, files or [])
1907 m = cmdutil.matchfiles(repo, files or [])
1895 n = repo.commit(message, opts.get('user') or user,
1908 n = repo.commit(message, opts.get('user') or user,
1896 opts.get('date') or date, match=m,
1909 opts.get('date') or date, match=m,
1897 editor=cmdutil.commiteditor)
1910 editor=cmdutil.commiteditor)
1898 if opts.get('exact'):
1911 if opts.get('exact'):
1899 if hex(n) != nodeid:
1912 if hex(n) != nodeid:
1900 repo.rollback()
1913 repo.rollback()
1901 raise util.Abort(_('patch is damaged'
1914 raise util.Abort(_('patch is damaged'
1902 ' or loses information'))
1915 ' or loses information'))
1903 # Force a dirstate write so that the next transaction
1916 # Force a dirstate write so that the next transaction
1904 # backups an up-do-date file.
1917 # backups an up-do-date file.
1905 repo.dirstate.write()
1918 repo.dirstate.write()
1906 if n:
1919 if n:
1907 commitid = short(n)
1920 commitid = short(n)
1908
1921
1909 return commitid
1922 return commitid
1910 finally:
1923 finally:
1911 os.unlink(tmpname)
1924 os.unlink(tmpname)
1912
1925
1913 try:
1926 try:
1914 wlock = repo.wlock()
1927 wlock = repo.wlock()
1915 lock = repo.lock()
1928 lock = repo.lock()
1916 lastcommit = None
1929 lastcommit = None
1917 for p in patches:
1930 for p in patches:
1918 pf = os.path.join(d, p)
1931 pf = os.path.join(d, p)
1919
1932
1920 if pf == '-':
1933 if pf == '-':
1921 ui.status(_("applying patch from stdin\n"))
1934 ui.status(_("applying patch from stdin\n"))
1922 pf = sys.stdin
1935 pf = sys.stdin
1923 else:
1936 else:
1924 ui.status(_("applying %s\n") % p)
1937 ui.status(_("applying %s\n") % p)
1925 pf = url.open(ui, pf)
1938 pf = url.open(ui, pf)
1926
1939
1927 haspatch = False
1940 haspatch = False
1928 for hunk in patch.split(pf):
1941 for hunk in patch.split(pf):
1929 commitid = tryone(ui, hunk)
1942 commitid = tryone(ui, hunk)
1930 if commitid:
1943 if commitid:
1931 haspatch = True
1944 haspatch = True
1932 if lastcommit:
1945 if lastcommit:
1933 ui.status(_('applied %s\n') % lastcommit)
1946 ui.status(_('applied %s\n') % lastcommit)
1934 lastcommit = commitid
1947 lastcommit = commitid
1935
1948
1936 if not haspatch:
1949 if not haspatch:
1937 raise util.Abort(_('no diffs found'))
1950 raise util.Abort(_('no diffs found'))
1938
1951
1939 finally:
1952 finally:
1940 release(lock, wlock)
1953 release(lock, wlock)
1941
1954
1942 def incoming(ui, repo, source="default", **opts):
1955 def incoming(ui, repo, source="default", **opts):
1943 """show new changesets found in source
1956 """show new changesets found in source
1944
1957
1945 Show new changesets found in the specified path/URL or the default
1958 Show new changesets found in the specified path/URL or the default
1946 pull location. These are the changesets that would have been pulled
1959 pull location. These are the changesets that would have been pulled
1947 if a pull at the time you issued this command.
1960 if a pull at the time you issued this command.
1948
1961
1949 For remote repository, using --bundle avoids downloading the
1962 For remote repository, using --bundle avoids downloading the
1950 changesets twice if the incoming is followed by a pull.
1963 changesets twice if the incoming is followed by a pull.
1951
1964
1952 See pull for valid source format details.
1965 See pull for valid source format details.
1953 """
1966 """
1954 limit = cmdutil.loglimit(opts)
1967 limit = cmdutil.loglimit(opts)
1955 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
1968 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
1956 other = hg.repository(cmdutil.remoteui(repo, opts), source)
1969 other = hg.repository(cmdutil.remoteui(repo, opts), source)
1957 ui.status(_('comparing with %s\n') % url.hidepassword(source))
1970 ui.status(_('comparing with %s\n') % url.hidepassword(source))
1958 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
1971 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
1959 if revs:
1972 if revs:
1960 revs = [other.lookup(rev) for rev in revs]
1973 revs = [other.lookup(rev) for rev in revs]
1961 common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
1974 common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
1962 force=opts["force"])
1975 force=opts["force"])
1963 if not incoming:
1976 if not incoming:
1964 try:
1977 try:
1965 os.unlink(opts["bundle"])
1978 os.unlink(opts["bundle"])
1966 except:
1979 except:
1967 pass
1980 pass
1968 ui.status(_("no changes found\n"))
1981 ui.status(_("no changes found\n"))
1969 return 1
1982 return 1
1970
1983
1971 cleanup = None
1984 cleanup = None
1972 try:
1985 try:
1973 fname = opts["bundle"]
1986 fname = opts["bundle"]
1974 if fname or not other.local():
1987 if fname or not other.local():
1975 # create a bundle (uncompressed if other repo is not local)
1988 # create a bundle (uncompressed if other repo is not local)
1976
1989
1977 if revs is None and other.capable('changegroupsubset'):
1990 if revs is None and other.capable('changegroupsubset'):
1978 revs = rheads
1991 revs = rheads
1979
1992
1980 if revs is None:
1993 if revs is None:
1981 cg = other.changegroup(incoming, "incoming")
1994 cg = other.changegroup(incoming, "incoming")
1982 else:
1995 else:
1983 cg = other.changegroupsubset(incoming, revs, 'incoming')
1996 cg = other.changegroupsubset(incoming, revs, 'incoming')
1984 bundletype = other.local() and "HG10BZ" or "HG10UN"
1997 bundletype = other.local() and "HG10BZ" or "HG10UN"
1985 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
1998 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
1986 # keep written bundle?
1999 # keep written bundle?
1987 if opts["bundle"]:
2000 if opts["bundle"]:
1988 cleanup = None
2001 cleanup = None
1989 if not other.local():
2002 if not other.local():
1990 # use the created uncompressed bundlerepo
2003 # use the created uncompressed bundlerepo
1991 other = bundlerepo.bundlerepository(ui, repo.root, fname)
2004 other = bundlerepo.bundlerepository(ui, repo.root, fname)
1992
2005
1993 o = other.changelog.nodesbetween(incoming, revs)[0]
2006 o = other.changelog.nodesbetween(incoming, revs)[0]
1994 if opts.get('newest_first'):
2007 if opts.get('newest_first'):
1995 o.reverse()
2008 o.reverse()
1996 displayer = cmdutil.show_changeset(ui, other, opts)
2009 displayer = cmdutil.show_changeset(ui, other, opts)
1997 count = 0
2010 count = 0
1998 for n in o:
2011 for n in o:
1999 if limit is not None and count >= limit:
2012 if limit is not None and count >= limit:
2000 break
2013 break
2001 parents = [p for p in other.changelog.parents(n) if p != nullid]
2014 parents = [p for p in other.changelog.parents(n) if p != nullid]
2002 if opts.get('no_merges') and len(parents) == 2:
2015 if opts.get('no_merges') and len(parents) == 2:
2003 continue
2016 continue
2004 count += 1
2017 count += 1
2005 displayer.show(other[n])
2018 displayer.show(other[n])
2006 displayer.close()
2019 displayer.close()
2007 finally:
2020 finally:
2008 if hasattr(other, 'close'):
2021 if hasattr(other, 'close'):
2009 other.close()
2022 other.close()
2010 if cleanup:
2023 if cleanup:
2011 os.unlink(cleanup)
2024 os.unlink(cleanup)
2012
2025
2013 def init(ui, dest=".", **opts):
2026 def init(ui, dest=".", **opts):
2014 """create a new repository in the given directory
2027 """create a new repository in the given directory
2015
2028
2016 Initialize a new repository in the given directory. If the given
2029 Initialize a new repository in the given directory. If the given
2017 directory does not exist, it will be created.
2030 directory does not exist, it will be created.
2018
2031
2019 If no directory is given, the current directory is used.
2032 If no directory is given, the current directory is used.
2020
2033
2021 It is possible to specify an ``ssh://`` URL as the destination.
2034 It is possible to specify an ``ssh://`` URL as the destination.
2022 See 'hg help urls' for more information.
2035 See 'hg help urls' for more information.
2023 """
2036 """
2024 hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
2037 hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
2025
2038
2026 def locate(ui, repo, *pats, **opts):
2039 def locate(ui, repo, *pats, **opts):
2027 """locate files matching specific patterns
2040 """locate files matching specific patterns
2028
2041
2029 Print files under Mercurial control in the working directory whose
2042 Print files under Mercurial control in the working directory whose
2030 names match the given patterns.
2043 names match the given patterns.
2031
2044
2032 By default, this command searches all directories in the working
2045 By default, this command searches all directories in the working
2033 directory. To search just the current directory and its
2046 directory. To search just the current directory and its
2034 subdirectories, use "--include .".
2047 subdirectories, use "--include .".
2035
2048
2036 If no patterns are given to match, this command prints the names
2049 If no patterns are given to match, this command prints the names
2037 of all files under Mercurial control in the working directory.
2050 of all files under Mercurial control in the working directory.
2038
2051
2039 If you want to feed the output of this command into the "xargs"
2052 If you want to feed the output of this command into the "xargs"
2040 command, use the -0 option to both this command and "xargs". This
2053 command, use the -0 option to both this command and "xargs". This
2041 will avoid the problem of "xargs" treating single filenames that
2054 will avoid the problem of "xargs" treating single filenames that
2042 contain whitespace as multiple filenames.
2055 contain whitespace as multiple filenames.
2043 """
2056 """
2044 end = opts.get('print0') and '\0' or '\n'
2057 end = opts.get('print0') and '\0' or '\n'
2045 rev = opts.get('rev') or None
2058 rev = opts.get('rev') or None
2046
2059
2047 ret = 1
2060 ret = 1
2048 m = cmdutil.match(repo, pats, opts, default='relglob')
2061 m = cmdutil.match(repo, pats, opts, default='relglob')
2049 m.bad = lambda x, y: False
2062 m.bad = lambda x, y: False
2050 for abs in repo[rev].walk(m):
2063 for abs in repo[rev].walk(m):
2051 if not rev and abs not in repo.dirstate:
2064 if not rev and abs not in repo.dirstate:
2052 continue
2065 continue
2053 if opts.get('fullpath'):
2066 if opts.get('fullpath'):
2054 ui.write(repo.wjoin(abs), end)
2067 ui.write(repo.wjoin(abs), end)
2055 else:
2068 else:
2056 ui.write(((pats and m.rel(abs)) or abs), end)
2069 ui.write(((pats and m.rel(abs)) or abs), end)
2057 ret = 0
2070 ret = 0
2058
2071
2059 return ret
2072 return ret
2060
2073
2061 def log(ui, repo, *pats, **opts):
2074 def log(ui, repo, *pats, **opts):
2062 """show revision history of entire repository or files
2075 """show revision history of entire repository or files
2063
2076
2064 Print the revision history of the specified files or the entire
2077 Print the revision history of the specified files or the entire
2065 project.
2078 project.
2066
2079
2067 File history is shown without following rename or copy history of
2080 File history is shown without following rename or copy history of
2068 files. Use -f/--follow with a filename to follow history across
2081 files. Use -f/--follow with a filename to follow history across
2069 renames and copies. --follow without a filename will only show
2082 renames and copies. --follow without a filename will only show
2070 ancestors or descendants of the starting revision. --follow-first
2083 ancestors or descendants of the starting revision. --follow-first
2071 only follows the first parent of merge revisions.
2084 only follows the first parent of merge revisions.
2072
2085
2073 If no revision range is specified, the default is tip:0 unless
2086 If no revision range is specified, the default is tip:0 unless
2074 --follow is set, in which case the working directory parent is
2087 --follow is set, in which case the working directory parent is
2075 used as the starting revision.
2088 used as the starting revision.
2076
2089
2077 See 'hg help dates' for a list of formats valid for -d/--date.
2090 See 'hg help dates' for a list of formats valid for -d/--date.
2078
2091
2079 By default this command prints revision number and changeset id,
2092 By default this command prints revision number and changeset id,
2080 tags, non-trivial parents, user, date and time, and a summary for
2093 tags, non-trivial parents, user, date and time, and a summary for
2081 each commit. When the -v/--verbose switch is used, the list of
2094 each commit. When the -v/--verbose switch is used, the list of
2082 changed files and full commit message are shown.
2095 changed files and full commit message are shown.
2083
2096
2084 NOTE: log -p/--patch may generate unexpected diff output for merge
2097 NOTE: log -p/--patch may generate unexpected diff output for merge
2085 changesets, as it will only compare the merge changeset against
2098 changesets, as it will only compare the merge changeset against
2086 its first parent. Also, only files different from BOTH parents
2099 its first parent. Also, only files different from BOTH parents
2087 will appear in files:.
2100 will appear in files:.
2088 """
2101 """
2089
2102
2090 matchfn = cmdutil.match(repo, pats, opts)
2103 matchfn = cmdutil.match(repo, pats, opts)
2091 limit = cmdutil.loglimit(opts)
2104 limit = cmdutil.loglimit(opts)
2092 count = 0
2105 count = 0
2093
2106
2094 endrev = None
2107 endrev = None
2095 if opts.get('copies') and opts.get('rev'):
2108 if opts.get('copies') and opts.get('rev'):
2096 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
2109 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
2097
2110
2098 df = False
2111 df = False
2099 if opts["date"]:
2112 if opts["date"]:
2100 df = util.matchdate(opts["date"])
2113 df = util.matchdate(opts["date"])
2101
2114
2102 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
2115 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
2103 def prep(ctx, fns):
2116 def prep(ctx, fns):
2104 rev = ctx.rev()
2117 rev = ctx.rev()
2105 parents = [p for p in repo.changelog.parentrevs(rev)
2118 parents = [p for p in repo.changelog.parentrevs(rev)
2106 if p != nullrev]
2119 if p != nullrev]
2107 if opts.get('no_merges') and len(parents) == 2:
2120 if opts.get('no_merges') and len(parents) == 2:
2108 return
2121 return
2109 if opts.get('only_merges') and len(parents) != 2:
2122 if opts.get('only_merges') and len(parents) != 2:
2110 return
2123 return
2111 if opts.get('only_branch') and ctx.branch() not in opts['only_branch']:
2124 if opts.get('only_branch') and ctx.branch() not in opts['only_branch']:
2112 return
2125 return
2113 if df and not df(ctx.date()[0]):
2126 if df and not df(ctx.date()[0]):
2114 return
2127 return
2115 if opts['user'] and not [k for k in opts['user'] if k in ctx.user()]:
2128 if opts['user'] and not [k for k in opts['user'] if k in ctx.user()]:
2116 return
2129 return
2117 if opts.get('keyword'):
2130 if opts.get('keyword'):
2118 for k in [kw.lower() for kw in opts['keyword']]:
2131 for k in [kw.lower() for kw in opts['keyword']]:
2119 if (k in ctx.user().lower() or
2132 if (k in ctx.user().lower() or
2120 k in ctx.description().lower() or
2133 k in ctx.description().lower() or
2121 k in " ".join(ctx.files()).lower()):
2134 k in " ".join(ctx.files()).lower()):
2122 break
2135 break
2123 else:
2136 else:
2124 return
2137 return
2125
2138
2126 copies = None
2139 copies = None
2127 if opts.get('copies') and rev:
2140 if opts.get('copies') and rev:
2128 copies = []
2141 copies = []
2129 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
2142 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
2130 for fn in ctx.files():
2143 for fn in ctx.files():
2131 rename = getrenamed(fn, rev)
2144 rename = getrenamed(fn, rev)
2132 if rename:
2145 if rename:
2133 copies.append((fn, rename[0]))
2146 copies.append((fn, rename[0]))
2134
2147
2135 displayer.show(ctx, copies=copies)
2148 displayer.show(ctx, copies=copies)
2136
2149
2137 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2150 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2138 if count == limit:
2151 if count == limit:
2139 break
2152 break
2140 if displayer.flush(ctx.rev()):
2153 if displayer.flush(ctx.rev()):
2141 count += 1
2154 count += 1
2142 displayer.close()
2155 displayer.close()
2143
2156
2144 def manifest(ui, repo, node=None, rev=None):
2157 def manifest(ui, repo, node=None, rev=None):
2145 """output the current or given revision of the project manifest
2158 """output the current or given revision of the project manifest
2146
2159
2147 Print a list of version controlled files for the given revision.
2160 Print a list of version controlled files for the given revision.
2148 If no revision is given, the first parent of the working directory
2161 If no revision is given, the first parent of the working directory
2149 is used, or the null revision if no revision is checked out.
2162 is used, or the null revision if no revision is checked out.
2150
2163
2151 With -v, print file permissions, symlink and executable bits.
2164 With -v, print file permissions, symlink and executable bits.
2152 With --debug, print file revision hashes.
2165 With --debug, print file revision hashes.
2153 """
2166 """
2154
2167
2155 if rev and node:
2168 if rev and node:
2156 raise util.Abort(_("please specify just one revision"))
2169 raise util.Abort(_("please specify just one revision"))
2157
2170
2158 if not node:
2171 if not node:
2159 node = rev
2172 node = rev
2160
2173
2161 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2174 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2162 ctx = repo[node]
2175 ctx = repo[node]
2163 for f in ctx:
2176 for f in ctx:
2164 if ui.debugflag:
2177 if ui.debugflag:
2165 ui.write("%40s " % hex(ctx.manifest()[f]))
2178 ui.write("%40s " % hex(ctx.manifest()[f]))
2166 if ui.verbose:
2179 if ui.verbose:
2167 ui.write(decor[ctx.flags(f)])
2180 ui.write(decor[ctx.flags(f)])
2168 ui.write("%s\n" % f)
2181 ui.write("%s\n" % f)
2169
2182
2170 def merge(ui, repo, node=None, **opts):
2183 def merge(ui, repo, node=None, **opts):
2171 """merge working directory with another revision
2184 """merge working directory with another revision
2172
2185
2173 The current working directory is updated with all changes made in
2186 The current working directory is updated with all changes made in
2174 the requested revision since the last common predecessor revision.
2187 the requested revision since the last common predecessor revision.
2175
2188
2176 Files that changed between either parent are marked as changed for
2189 Files that changed between either parent are marked as changed for
2177 the next commit and a commit must be performed before any further
2190 the next commit and a commit must be performed before any further
2178 updates to the repository are allowed. The next commit will have
2191 updates to the repository are allowed. The next commit will have
2179 two parents.
2192 two parents.
2180
2193
2181 If no revision is specified, the working directory's parent is a
2194 If no revision is specified, the working directory's parent is a
2182 head revision, and the current branch contains exactly one other
2195 head revision, and the current branch contains exactly one other
2183 head, the other head is merged with by default. Otherwise, an
2196 head, the other head is merged with by default. Otherwise, an
2184 explicit revision with which to merge with must be provided.
2197 explicit revision with which to merge with must be provided.
2185 """
2198 """
2186
2199
2187 if opts.get('rev') and node:
2200 if opts.get('rev') and node:
2188 raise util.Abort(_("please specify just one revision"))
2201 raise util.Abort(_("please specify just one revision"))
2189 if not node:
2202 if not node:
2190 node = opts.get('rev')
2203 node = opts.get('rev')
2191
2204
2192 if not node:
2205 if not node:
2193 branch = repo.changectx(None).branch()
2206 branch = repo.changectx(None).branch()
2194 bheads = repo.branchheads(branch)
2207 bheads = repo.branchheads(branch)
2195 if len(bheads) > 2:
2208 if len(bheads) > 2:
2196 ui.warn(_("abort: branch '%s' has %d heads - "
2209 ui.warn(_("abort: branch '%s' has %d heads - "
2197 "please merge with an explicit rev\n")
2210 "please merge with an explicit rev\n")
2198 % (branch, len(bheads)))
2211 % (branch, len(bheads)))
2199 ui.status(_("(run 'hg heads .' to see heads)\n"))
2212 ui.status(_("(run 'hg heads .' to see heads)\n"))
2200 return False
2213 return False
2201
2214
2202 parent = repo.dirstate.parents()[0]
2215 parent = repo.dirstate.parents()[0]
2203 if len(bheads) == 1:
2216 if len(bheads) == 1:
2204 if len(repo.heads()) > 1:
2217 if len(repo.heads()) > 1:
2205 ui.warn(_("abort: branch '%s' has one head - "
2218 ui.warn(_("abort: branch '%s' has one head - "
2206 "please merge with an explicit rev\n" % branch))
2219 "please merge with an explicit rev\n" % branch))
2207 ui.status(_("(run 'hg heads' to see all heads)\n"))
2220 ui.status(_("(run 'hg heads' to see all heads)\n"))
2208 return False
2221 return False
2209 msg = _('there is nothing to merge')
2222 msg = _('there is nothing to merge')
2210 if parent != repo.lookup(repo[None].branch()):
2223 if parent != repo.lookup(repo[None].branch()):
2211 msg = _('%s - use "hg update" instead') % msg
2224 msg = _('%s - use "hg update" instead') % msg
2212 raise util.Abort(msg)
2225 raise util.Abort(msg)
2213
2226
2214 if parent not in bheads:
2227 if parent not in bheads:
2215 raise util.Abort(_('working dir not at a head rev - '
2228 raise util.Abort(_('working dir not at a head rev - '
2216 'use "hg update" or merge with an explicit rev'))
2229 'use "hg update" or merge with an explicit rev'))
2217 node = parent == bheads[0] and bheads[-1] or bheads[0]
2230 node = parent == bheads[0] and bheads[-1] or bheads[0]
2218
2231
2219 if opts.get('preview'):
2232 if opts.get('preview'):
2220 p1 = repo['.']
2233 p1 = repo['.']
2221 p2 = repo[node]
2234 p2 = repo[node]
2222 common = p1.ancestor(p2)
2235 common = p1.ancestor(p2)
2223 roots, heads = [common.node()], [p2.node()]
2236 roots, heads = [common.node()], [p2.node()]
2224 displayer = cmdutil.show_changeset(ui, repo, opts)
2237 displayer = cmdutil.show_changeset(ui, repo, opts)
2225 for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]:
2238 for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]:
2226 if node not in roots:
2239 if node not in roots:
2227 displayer.show(repo[node])
2240 displayer.show(repo[node])
2228 displayer.close()
2241 displayer.close()
2229 return 0
2242 return 0
2230
2243
2231 return hg.merge(repo, node, force=opts.get('force'))
2244 return hg.merge(repo, node, force=opts.get('force'))
2232
2245
2233 def outgoing(ui, repo, dest=None, **opts):
2246 def outgoing(ui, repo, dest=None, **opts):
2234 """show changesets not found in the destination
2247 """show changesets not found in the destination
2235
2248
2236 Show changesets not found in the specified destination repository
2249 Show changesets not found in the specified destination repository
2237 or the default push location. These are the changesets that would
2250 or the default push location. These are the changesets that would
2238 be pushed if a push was requested.
2251 be pushed if a push was requested.
2239
2252
2240 See pull for details of valid destination formats.
2253 See pull for details of valid destination formats.
2241 """
2254 """
2242 limit = cmdutil.loglimit(opts)
2255 limit = cmdutil.loglimit(opts)
2243 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2256 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2244 dest, branches = hg.parseurl(dest, opts.get('branch'))
2257 dest, branches = hg.parseurl(dest, opts.get('branch'))
2245 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2258 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2246 if revs:
2259 if revs:
2247 revs = [repo.lookup(rev) for rev in revs]
2260 revs = [repo.lookup(rev) for rev in revs]
2248
2261
2249 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2262 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2250 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2263 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2251 o = repo.findoutgoing(other, force=opts.get('force'))
2264 o = repo.findoutgoing(other, force=opts.get('force'))
2252 if not o:
2265 if not o:
2253 ui.status(_("no changes found\n"))
2266 ui.status(_("no changes found\n"))
2254 return 1
2267 return 1
2255 o = repo.changelog.nodesbetween(o, revs)[0]
2268 o = repo.changelog.nodesbetween(o, revs)[0]
2256 if opts.get('newest_first'):
2269 if opts.get('newest_first'):
2257 o.reverse()
2270 o.reverse()
2258 displayer = cmdutil.show_changeset(ui, repo, opts)
2271 displayer = cmdutil.show_changeset(ui, repo, opts)
2259 count = 0
2272 count = 0
2260 for n in o:
2273 for n in o:
2261 if limit is not None and count >= limit:
2274 if limit is not None and count >= limit:
2262 break
2275 break
2263 parents = [p for p in repo.changelog.parents(n) if p != nullid]
2276 parents = [p for p in repo.changelog.parents(n) if p != nullid]
2264 if opts.get('no_merges') and len(parents) == 2:
2277 if opts.get('no_merges') and len(parents) == 2:
2265 continue
2278 continue
2266 count += 1
2279 count += 1
2267 displayer.show(repo[n])
2280 displayer.show(repo[n])
2268 displayer.close()
2281 displayer.close()
2269
2282
2270 def parents(ui, repo, file_=None, **opts):
2283 def parents(ui, repo, file_=None, **opts):
2271 """show the parents of the working directory or revision
2284 """show the parents of the working directory or revision
2272
2285
2273 Print the working directory's parent revisions. If a revision is
2286 Print the working directory's parent revisions. If a revision is
2274 given via -r/--rev, the parent of that revision will be printed.
2287 given via -r/--rev, the parent of that revision will be printed.
2275 If a file argument is given, the revision in which the file was
2288 If a file argument is given, the revision in which the file was
2276 last changed (before the working directory revision or the
2289 last changed (before the working directory revision or the
2277 argument to --rev if given) is printed.
2290 argument to --rev if given) is printed.
2278 """
2291 """
2279 rev = opts.get('rev')
2292 rev = opts.get('rev')
2280 if rev:
2293 if rev:
2281 ctx = repo[rev]
2294 ctx = repo[rev]
2282 else:
2295 else:
2283 ctx = repo[None]
2296 ctx = repo[None]
2284
2297
2285 if file_:
2298 if file_:
2286 m = cmdutil.match(repo, (file_,), opts)
2299 m = cmdutil.match(repo, (file_,), opts)
2287 if m.anypats() or len(m.files()) != 1:
2300 if m.anypats() or len(m.files()) != 1:
2288 raise util.Abort(_('can only specify an explicit filename'))
2301 raise util.Abort(_('can only specify an explicit filename'))
2289 file_ = m.files()[0]
2302 file_ = m.files()[0]
2290 filenodes = []
2303 filenodes = []
2291 for cp in ctx.parents():
2304 for cp in ctx.parents():
2292 if not cp:
2305 if not cp:
2293 continue
2306 continue
2294 try:
2307 try:
2295 filenodes.append(cp.filenode(file_))
2308 filenodes.append(cp.filenode(file_))
2296 except error.LookupError:
2309 except error.LookupError:
2297 pass
2310 pass
2298 if not filenodes:
2311 if not filenodes:
2299 raise util.Abort(_("'%s' not found in manifest!") % file_)
2312 raise util.Abort(_("'%s' not found in manifest!") % file_)
2300 fl = repo.file(file_)
2313 fl = repo.file(file_)
2301 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2314 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2302 else:
2315 else:
2303 p = [cp.node() for cp in ctx.parents()]
2316 p = [cp.node() for cp in ctx.parents()]
2304
2317
2305 displayer = cmdutil.show_changeset(ui, repo, opts)
2318 displayer = cmdutil.show_changeset(ui, repo, opts)
2306 for n in p:
2319 for n in p:
2307 if n != nullid:
2320 if n != nullid:
2308 displayer.show(repo[n])
2321 displayer.show(repo[n])
2309 displayer.close()
2322 displayer.close()
2310
2323
2311 def paths(ui, repo, search=None):
2324 def paths(ui, repo, search=None):
2312 """show aliases for remote repositories
2325 """show aliases for remote repositories
2313
2326
2314 Show definition of symbolic path name NAME. If no name is given,
2327 Show definition of symbolic path name NAME. If no name is given,
2315 show definition of all available names.
2328 show definition of all available names.
2316
2329
2317 Path names are defined in the [paths] section of /etc/mercurial/hgrc
2330 Path names are defined in the [paths] section of /etc/mercurial/hgrc
2318 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
2331 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
2319
2332
2320 See 'hg help urls' for more information.
2333 See 'hg help urls' for more information.
2321 """
2334 """
2322 if search:
2335 if search:
2323 for name, path in ui.configitems("paths"):
2336 for name, path in ui.configitems("paths"):
2324 if name == search:
2337 if name == search:
2325 ui.write("%s\n" % url.hidepassword(path))
2338 ui.write("%s\n" % url.hidepassword(path))
2326 return
2339 return
2327 ui.warn(_("not found!\n"))
2340 ui.warn(_("not found!\n"))
2328 return 1
2341 return 1
2329 else:
2342 else:
2330 for name, path in ui.configitems("paths"):
2343 for name, path in ui.configitems("paths"):
2331 ui.write("%s = %s\n" % (name, url.hidepassword(path)))
2344 ui.write("%s = %s\n" % (name, url.hidepassword(path)))
2332
2345
2333 def postincoming(ui, repo, modheads, optupdate, checkout):
2346 def postincoming(ui, repo, modheads, optupdate, checkout):
2334 if modheads == 0:
2347 if modheads == 0:
2335 return
2348 return
2336 if optupdate:
2349 if optupdate:
2337 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
2350 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
2338 return hg.update(repo, checkout)
2351 return hg.update(repo, checkout)
2339 else:
2352 else:
2340 ui.status(_("not updating, since new heads added\n"))
2353 ui.status(_("not updating, since new heads added\n"))
2341 if modheads > 1:
2354 if modheads > 1:
2342 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2355 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2343 else:
2356 else:
2344 ui.status(_("(run 'hg update' to get a working copy)\n"))
2357 ui.status(_("(run 'hg update' to get a working copy)\n"))
2345
2358
2346 def pull(ui, repo, source="default", **opts):
2359 def pull(ui, repo, source="default", **opts):
2347 """pull changes from the specified source
2360 """pull changes from the specified source
2348
2361
2349 Pull changes from a remote repository to a local one.
2362 Pull changes from a remote repository to a local one.
2350
2363
2351 This finds all changes from the repository at the specified path
2364 This finds all changes from the repository at the specified path
2352 or URL and adds them to a local repository (the current one unless
2365 or URL and adds them to a local repository (the current one unless
2353 -R is specified). By default, this does not update the copy of the
2366 -R is specified). By default, this does not update the copy of the
2354 project in the working directory.
2367 project in the working directory.
2355
2368
2356 Use hg incoming if you want to see what would have been added by a
2369 Use hg incoming if you want to see what would have been added by a
2357 pull at the time you issued this command. If you then decide to
2370 pull at the time you issued this command. If you then decide to
2358 added those changes to the repository, you should use pull -r X
2371 added those changes to the repository, you should use pull -r X
2359 where X is the last changeset listed by hg incoming.
2372 where X is the last changeset listed by hg incoming.
2360
2373
2361 If SOURCE is omitted, the 'default' path will be used.
2374 If SOURCE is omitted, the 'default' path will be used.
2362 See 'hg help urls' for more information.
2375 See 'hg help urls' for more information.
2363 """
2376 """
2364 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2377 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2365 other = hg.repository(cmdutil.remoteui(repo, opts), source)
2378 other = hg.repository(cmdutil.remoteui(repo, opts), source)
2366 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2379 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2367 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2380 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2368 if revs:
2381 if revs:
2369 try:
2382 try:
2370 revs = [other.lookup(rev) for rev in revs]
2383 revs = [other.lookup(rev) for rev in revs]
2371 except error.CapabilityError:
2384 except error.CapabilityError:
2372 err = _("Other repository doesn't support revision lookup, "
2385 err = _("Other repository doesn't support revision lookup, "
2373 "so a rev cannot be specified.")
2386 "so a rev cannot be specified.")
2374 raise util.Abort(err)
2387 raise util.Abort(err)
2375
2388
2376 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
2389 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
2377 if checkout:
2390 if checkout:
2378 checkout = str(repo.changelog.rev(other.lookup(checkout)))
2391 checkout = str(repo.changelog.rev(other.lookup(checkout)))
2379 return postincoming(ui, repo, modheads, opts.get('update'), checkout)
2392 return postincoming(ui, repo, modheads, opts.get('update'), checkout)
2380
2393
2381 def push(ui, repo, dest=None, **opts):
2394 def push(ui, repo, dest=None, **opts):
2382 """push changes to the specified destination
2395 """push changes to the specified destination
2383
2396
2384 Push changes from the local repository to the specified destination.
2397 Push changes from the local repository to the specified destination.
2385
2398
2386 This is the symmetrical operation for pull. It moves changes from
2399 This is the symmetrical operation for pull. It moves changes from
2387 the current repository to a different one. If the destination is
2400 the current repository to a different one. If the destination is
2388 local this is identical to a pull in that directory from the
2401 local this is identical to a pull in that directory from the
2389 current one.
2402 current one.
2390
2403
2391 By default, push will refuse to run if it detects the result would
2404 By default, push will refuse to run if it detects the result would
2392 increase the number of remote heads. This generally indicates the
2405 increase the number of remote heads. This generally indicates the
2393 user forgot to pull and merge before pushing.
2406 user forgot to pull and merge before pushing.
2394
2407
2395 If -r/--rev is used, the named revision and all its ancestors will
2408 If -r/--rev is used, the named revision and all its ancestors will
2396 be pushed to the remote repository.
2409 be pushed to the remote repository.
2397
2410
2398 Please see 'hg help urls' for important details about ``ssh://``
2411 Please see 'hg help urls' for important details about ``ssh://``
2399 URLs. If DESTINATION is omitted, a default path will be used.
2412 URLs. If DESTINATION is omitted, a default path will be used.
2400 """
2413 """
2401 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2414 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2402 dest, branches = hg.parseurl(dest, opts.get('branch'))
2415 dest, branches = hg.parseurl(dest, opts.get('branch'))
2403 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2416 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2404 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2417 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2405 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2418 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2406 if revs:
2419 if revs:
2407 revs = [repo.lookup(rev) for rev in revs]
2420 revs = [repo.lookup(rev) for rev in revs]
2408
2421
2409 # push subrepos depth-first for coherent ordering
2422 # push subrepos depth-first for coherent ordering
2410 c = repo['']
2423 c = repo['']
2411 subs = c.substate # only repos that are committed
2424 subs = c.substate # only repos that are committed
2412 for s in sorted(subs):
2425 for s in sorted(subs):
2413 c.sub(s).push(opts.get('force'))
2426 c.sub(s).push(opts.get('force'))
2414
2427
2415 r = repo.push(other, opts.get('force'), revs=revs)
2428 r = repo.push(other, opts.get('force'), revs=revs)
2416 return r == 0
2429 return r == 0
2417
2430
2418 def recover(ui, repo):
2431 def recover(ui, repo):
2419 """roll back an interrupted transaction
2432 """roll back an interrupted transaction
2420
2433
2421 Recover from an interrupted commit or pull.
2434 Recover from an interrupted commit or pull.
2422
2435
2423 This command tries to fix the repository status after an
2436 This command tries to fix the repository status after an
2424 interrupted operation. It should only be necessary when Mercurial
2437 interrupted operation. It should only be necessary when Mercurial
2425 suggests it.
2438 suggests it.
2426 """
2439 """
2427 if repo.recover():
2440 if repo.recover():
2428 return hg.verify(repo)
2441 return hg.verify(repo)
2429 return 1
2442 return 1
2430
2443
2431 def remove(ui, repo, *pats, **opts):
2444 def remove(ui, repo, *pats, **opts):
2432 """remove the specified files on the next commit
2445 """remove the specified files on the next commit
2433
2446
2434 Schedule the indicated files for removal from the repository.
2447 Schedule the indicated files for removal from the repository.
2435
2448
2436 This only removes files from the current branch, not from the
2449 This only removes files from the current branch, not from the
2437 entire project history. -A/--after can be used to remove only
2450 entire project history. -A/--after can be used to remove only
2438 files that have already been deleted, -f/--force can be used to
2451 files that have already been deleted, -f/--force can be used to
2439 force deletion, and -Af can be used to remove files from the next
2452 force deletion, and -Af can be used to remove files from the next
2440 revision without deleting them from the working directory.
2453 revision without deleting them from the working directory.
2441
2454
2442 The following table details the behavior of remove for different
2455 The following table details the behavior of remove for different
2443 file states (columns) and option combinations (rows). The file
2456 file states (columns) and option combinations (rows). The file
2444 states are Added [A], Clean [C], Modified [M] and Missing [!] (as
2457 states are Added [A], Clean [C], Modified [M] and Missing [!] (as
2445 reported by hg status). The actions are Warn, Remove (from branch)
2458 reported by hg status). The actions are Warn, Remove (from branch)
2446 and Delete (from disk)::
2459 and Delete (from disk)::
2447
2460
2448 A C M !
2461 A C M !
2449 none W RD W R
2462 none W RD W R
2450 -f R RD RD R
2463 -f R RD RD R
2451 -A W W W R
2464 -A W W W R
2452 -Af R R R R
2465 -Af R R R R
2453
2466
2454 This command schedules the files to be removed at the next commit.
2467 This command schedules the files to be removed at the next commit.
2455 To undo a remove before that, see hg revert.
2468 To undo a remove before that, see hg revert.
2456 """
2469 """
2457
2470
2458 after, force = opts.get('after'), opts.get('force')
2471 after, force = opts.get('after'), opts.get('force')
2459 if not pats and not after:
2472 if not pats and not after:
2460 raise util.Abort(_('no files specified'))
2473 raise util.Abort(_('no files specified'))
2461
2474
2462 m = cmdutil.match(repo, pats, opts)
2475 m = cmdutil.match(repo, pats, opts)
2463 s = repo.status(match=m, clean=True)
2476 s = repo.status(match=m, clean=True)
2464 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2477 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2465
2478
2466 for f in m.files():
2479 for f in m.files():
2467 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
2480 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
2468 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
2481 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
2469
2482
2470 def warn(files, reason):
2483 def warn(files, reason):
2471 for f in files:
2484 for f in files:
2472 ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
2485 ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
2473 % (m.rel(f), reason))
2486 % (m.rel(f), reason))
2474
2487
2475 if force:
2488 if force:
2476 remove, forget = modified + deleted + clean, added
2489 remove, forget = modified + deleted + clean, added
2477 elif after:
2490 elif after:
2478 remove, forget = deleted, []
2491 remove, forget = deleted, []
2479 warn(modified + added + clean, _('still exists'))
2492 warn(modified + added + clean, _('still exists'))
2480 else:
2493 else:
2481 remove, forget = deleted + clean, []
2494 remove, forget = deleted + clean, []
2482 warn(modified, _('is modified'))
2495 warn(modified, _('is modified'))
2483 warn(added, _('has been marked for add'))
2496 warn(added, _('has been marked for add'))
2484
2497
2485 for f in sorted(remove + forget):
2498 for f in sorted(remove + forget):
2486 if ui.verbose or not m.exact(f):
2499 if ui.verbose or not m.exact(f):
2487 ui.status(_('removing %s\n') % m.rel(f))
2500 ui.status(_('removing %s\n') % m.rel(f))
2488
2501
2489 repo.forget(forget)
2502 repo.forget(forget)
2490 repo.remove(remove, unlink=not after)
2503 repo.remove(remove, unlink=not after)
2491
2504
2492 def rename(ui, repo, *pats, **opts):
2505 def rename(ui, repo, *pats, **opts):
2493 """rename files; equivalent of copy + remove
2506 """rename files; equivalent of copy + remove
2494
2507
2495 Mark dest as copies of sources; mark sources for deletion. If dest
2508 Mark dest as copies of sources; mark sources for deletion. If dest
2496 is a directory, copies are put in that directory. If dest is a
2509 is a directory, copies are put in that directory. If dest is a
2497 file, there can only be one source.
2510 file, there can only be one source.
2498
2511
2499 By default, this command copies the contents of files as they
2512 By default, this command copies the contents of files as they
2500 exist in the working directory. If invoked with -A/--after, the
2513 exist in the working directory. If invoked with -A/--after, the
2501 operation is recorded, but no copying is performed.
2514 operation is recorded, but no copying is performed.
2502
2515
2503 This command takes effect at the next commit. To undo a rename
2516 This command takes effect at the next commit. To undo a rename
2504 before that, see hg revert.
2517 before that, see hg revert.
2505 """
2518 """
2506 wlock = repo.wlock(False)
2519 wlock = repo.wlock(False)
2507 try:
2520 try:
2508 return cmdutil.copy(ui, repo, pats, opts, rename=True)
2521 return cmdutil.copy(ui, repo, pats, opts, rename=True)
2509 finally:
2522 finally:
2510 wlock.release()
2523 wlock.release()
2511
2524
2512 def resolve(ui, repo, *pats, **opts):
2525 def resolve(ui, repo, *pats, **opts):
2513 """retry file merges from a merge or update
2526 """retry file merges from a merge or update
2514
2527
2515 This command can cleanly retry unresolved file merges using file
2528 This command can cleanly retry unresolved file merges using file
2516 revisions preserved from the last update or merge.
2529 revisions preserved from the last update or merge.
2517
2530
2518 If a conflict is resolved manually, please note that the changes
2531 If a conflict is resolved manually, please note that the changes
2519 will be overwritten if the merge is retried with resolve. The
2532 will be overwritten if the merge is retried with resolve. The
2520 -m/--mark switch should be used to mark the file as resolved.
2533 -m/--mark switch should be used to mark the file as resolved.
2521
2534
2522 You can specify a set of files to operate on, or use the -a/--all
2535 You can specify a set of files to operate on, or use the -a/--all
2523 switch to select all unresolved files.
2536 switch to select all unresolved files.
2524
2537
2525 This command also allows listing resolved files and manually
2538 This command also allows listing resolved files and manually
2526 indicating whether or not files are resolved. All files must be
2539 indicating whether or not files are resolved. All files must be
2527 marked as resolved before a commit is permitted.
2540 marked as resolved before a commit is permitted.
2528
2541
2529 The codes used to show the status of files are::
2542 The codes used to show the status of files are::
2530
2543
2531 U = unresolved
2544 U = unresolved
2532 R = resolved
2545 R = resolved
2533 """
2546 """
2534
2547
2535 all, mark, unmark, show, nostatus = \
2548 all, mark, unmark, show, nostatus = \
2536 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
2549 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
2537
2550
2538 if (show and (mark or unmark)) or (mark and unmark):
2551 if (show and (mark or unmark)) or (mark and unmark):
2539 raise util.Abort(_("too many options specified"))
2552 raise util.Abort(_("too many options specified"))
2540 if pats and all:
2553 if pats and all:
2541 raise util.Abort(_("can't specify --all and patterns"))
2554 raise util.Abort(_("can't specify --all and patterns"))
2542 if not (all or pats or show or mark or unmark):
2555 if not (all or pats or show or mark or unmark):
2543 raise util.Abort(_('no files or directories specified; '
2556 raise util.Abort(_('no files or directories specified; '
2544 'use --all to remerge all files'))
2557 'use --all to remerge all files'))
2545
2558
2546 ms = merge_.mergestate(repo)
2559 ms = merge_.mergestate(repo)
2547 m = cmdutil.match(repo, pats, opts)
2560 m = cmdutil.match(repo, pats, opts)
2548
2561
2549 for f in ms:
2562 for f in ms:
2550 if m(f):
2563 if m(f):
2551 if show:
2564 if show:
2552 if nostatus:
2565 if nostatus:
2553 ui.write("%s\n" % f)
2566 ui.write("%s\n" % f)
2554 else:
2567 else:
2555 ui.write("%s %s\n" % (ms[f].upper(), f))
2568 ui.write("%s %s\n" % (ms[f].upper(), f))
2556 elif mark:
2569 elif mark:
2557 ms.mark(f, "r")
2570 ms.mark(f, "r")
2558 elif unmark:
2571 elif unmark:
2559 ms.mark(f, "u")
2572 ms.mark(f, "u")
2560 else:
2573 else:
2561 wctx = repo[None]
2574 wctx = repo[None]
2562 mctx = wctx.parents()[-1]
2575 mctx = wctx.parents()[-1]
2563
2576
2564 # backup pre-resolve (merge uses .orig for its own purposes)
2577 # backup pre-resolve (merge uses .orig for its own purposes)
2565 a = repo.wjoin(f)
2578 a = repo.wjoin(f)
2566 util.copyfile(a, a + ".resolve")
2579 util.copyfile(a, a + ".resolve")
2567
2580
2568 # resolve file
2581 # resolve file
2569 ms.resolve(f, wctx, mctx)
2582 ms.resolve(f, wctx, mctx)
2570
2583
2571 # replace filemerge's .orig file with our resolve file
2584 # replace filemerge's .orig file with our resolve file
2572 util.rename(a + ".resolve", a + ".orig")
2585 util.rename(a + ".resolve", a + ".orig")
2573
2586
2574 def revert(ui, repo, *pats, **opts):
2587 def revert(ui, repo, *pats, **opts):
2575 """restore individual files or directories to an earlier state
2588 """restore individual files or directories to an earlier state
2576
2589
2577 (Use update -r to check out earlier revisions, revert does not
2590 (Use update -r to check out earlier revisions, revert does not
2578 change the working directory parents.)
2591 change the working directory parents.)
2579
2592
2580 With no revision specified, revert the named files or directories
2593 With no revision specified, revert the named files or directories
2581 to the contents they had in the parent of the working directory.
2594 to the contents they had in the parent of the working directory.
2582 This restores the contents of the affected files to an unmodified
2595 This restores the contents of the affected files to an unmodified
2583 state and unschedules adds, removes, copies, and renames. If the
2596 state and unschedules adds, removes, copies, and renames. If the
2584 working directory has two parents, you must explicitly specify a
2597 working directory has two parents, you must explicitly specify a
2585 revision.
2598 revision.
2586
2599
2587 Using the -r/--rev option, revert the given files or directories
2600 Using the -r/--rev option, revert the given files or directories
2588 to their contents as of a specific revision. This can be helpful
2601 to their contents as of a specific revision. This can be helpful
2589 to "roll back" some or all of an earlier change. See 'hg help
2602 to "roll back" some or all of an earlier change. See 'hg help
2590 dates' for a list of formats valid for -d/--date.
2603 dates' for a list of formats valid for -d/--date.
2591
2604
2592 Revert modifies the working directory. It does not commit any
2605 Revert modifies the working directory. It does not commit any
2593 changes, or change the parent of the working directory. If you
2606 changes, or change the parent of the working directory. If you
2594 revert to a revision other than the parent of the working
2607 revert to a revision other than the parent of the working
2595 directory, the reverted files will thus appear modified
2608 directory, the reverted files will thus appear modified
2596 afterwards.
2609 afterwards.
2597
2610
2598 If a file has been deleted, it is restored. If the executable mode
2611 If a file has been deleted, it is restored. If the executable mode
2599 of a file was changed, it is reset.
2612 of a file was changed, it is reset.
2600
2613
2601 If names are given, all files matching the names are reverted.
2614 If names are given, all files matching the names are reverted.
2602 If no arguments are given, no files are reverted.
2615 If no arguments are given, no files are reverted.
2603
2616
2604 Modified files are saved with a .orig suffix before reverting.
2617 Modified files are saved with a .orig suffix before reverting.
2605 To disable these backups, use --no-backup.
2618 To disable these backups, use --no-backup.
2606 """
2619 """
2607
2620
2608 if opts["date"]:
2621 if opts["date"]:
2609 if opts["rev"]:
2622 if opts["rev"]:
2610 raise util.Abort(_("you can't specify a revision and a date"))
2623 raise util.Abort(_("you can't specify a revision and a date"))
2611 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
2624 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
2612
2625
2613 if not pats and not opts.get('all'):
2626 if not pats and not opts.get('all'):
2614 raise util.Abort(_('no files or directories specified; '
2627 raise util.Abort(_('no files or directories specified; '
2615 'use --all to revert the whole repo'))
2628 'use --all to revert the whole repo'))
2616
2629
2617 parent, p2 = repo.dirstate.parents()
2630 parent, p2 = repo.dirstate.parents()
2618 if not opts.get('rev') and p2 != nullid:
2631 if not opts.get('rev') and p2 != nullid:
2619 raise util.Abort(_('uncommitted merge - please provide a '
2632 raise util.Abort(_('uncommitted merge - please provide a '
2620 'specific revision'))
2633 'specific revision'))
2621 ctx = repo[opts.get('rev')]
2634 ctx = repo[opts.get('rev')]
2622 node = ctx.node()
2635 node = ctx.node()
2623 mf = ctx.manifest()
2636 mf = ctx.manifest()
2624 if node == parent:
2637 if node == parent:
2625 pmf = mf
2638 pmf = mf
2626 else:
2639 else:
2627 pmf = None
2640 pmf = None
2628
2641
2629 # need all matching names in dirstate and manifest of target rev,
2642 # need all matching names in dirstate and manifest of target rev,
2630 # so have to walk both. do not print errors if files exist in one
2643 # so have to walk both. do not print errors if files exist in one
2631 # but not other.
2644 # but not other.
2632
2645
2633 names = {}
2646 names = {}
2634
2647
2635 wlock = repo.wlock()
2648 wlock = repo.wlock()
2636 try:
2649 try:
2637 # walk dirstate.
2650 # walk dirstate.
2638
2651
2639 m = cmdutil.match(repo, pats, opts)
2652 m = cmdutil.match(repo, pats, opts)
2640 m.bad = lambda x, y: False
2653 m.bad = lambda x, y: False
2641 for abs in repo.walk(m):
2654 for abs in repo.walk(m):
2642 names[abs] = m.rel(abs), m.exact(abs)
2655 names[abs] = m.rel(abs), m.exact(abs)
2643
2656
2644 # walk target manifest.
2657 # walk target manifest.
2645
2658
2646 def badfn(path, msg):
2659 def badfn(path, msg):
2647 if path in names:
2660 if path in names:
2648 return
2661 return
2649 path_ = path + '/'
2662 path_ = path + '/'
2650 for f in names:
2663 for f in names:
2651 if f.startswith(path_):
2664 if f.startswith(path_):
2652 return
2665 return
2653 ui.warn("%s: %s\n" % (m.rel(path), msg))
2666 ui.warn("%s: %s\n" % (m.rel(path), msg))
2654
2667
2655 m = cmdutil.match(repo, pats, opts)
2668 m = cmdutil.match(repo, pats, opts)
2656 m.bad = badfn
2669 m.bad = badfn
2657 for abs in repo[node].walk(m):
2670 for abs in repo[node].walk(m):
2658 if abs not in names:
2671 if abs not in names:
2659 names[abs] = m.rel(abs), m.exact(abs)
2672 names[abs] = m.rel(abs), m.exact(abs)
2660
2673
2661 m = cmdutil.matchfiles(repo, names)
2674 m = cmdutil.matchfiles(repo, names)
2662 changes = repo.status(match=m)[:4]
2675 changes = repo.status(match=m)[:4]
2663 modified, added, removed, deleted = map(set, changes)
2676 modified, added, removed, deleted = map(set, changes)
2664
2677
2665 # if f is a rename, also revert the source
2678 # if f is a rename, also revert the source
2666 cwd = repo.getcwd()
2679 cwd = repo.getcwd()
2667 for f in added:
2680 for f in added:
2668 src = repo.dirstate.copied(f)
2681 src = repo.dirstate.copied(f)
2669 if src and src not in names and repo.dirstate[src] == 'r':
2682 if src and src not in names and repo.dirstate[src] == 'r':
2670 removed.add(src)
2683 removed.add(src)
2671 names[src] = (repo.pathto(src, cwd), True)
2684 names[src] = (repo.pathto(src, cwd), True)
2672
2685
2673 def removeforget(abs):
2686 def removeforget(abs):
2674 if repo.dirstate[abs] == 'a':
2687 if repo.dirstate[abs] == 'a':
2675 return _('forgetting %s\n')
2688 return _('forgetting %s\n')
2676 return _('removing %s\n')
2689 return _('removing %s\n')
2677
2690
2678 revert = ([], _('reverting %s\n'))
2691 revert = ([], _('reverting %s\n'))
2679 add = ([], _('adding %s\n'))
2692 add = ([], _('adding %s\n'))
2680 remove = ([], removeforget)
2693 remove = ([], removeforget)
2681 undelete = ([], _('undeleting %s\n'))
2694 undelete = ([], _('undeleting %s\n'))
2682
2695
2683 disptable = (
2696 disptable = (
2684 # dispatch table:
2697 # dispatch table:
2685 # file state
2698 # file state
2686 # action if in target manifest
2699 # action if in target manifest
2687 # action if not in target manifest
2700 # action if not in target manifest
2688 # make backup if in target manifest
2701 # make backup if in target manifest
2689 # make backup if not in target manifest
2702 # make backup if not in target manifest
2690 (modified, revert, remove, True, True),
2703 (modified, revert, remove, True, True),
2691 (added, revert, remove, True, False),
2704 (added, revert, remove, True, False),
2692 (removed, undelete, None, False, False),
2705 (removed, undelete, None, False, False),
2693 (deleted, revert, remove, False, False),
2706 (deleted, revert, remove, False, False),
2694 )
2707 )
2695
2708
2696 for abs, (rel, exact) in sorted(names.items()):
2709 for abs, (rel, exact) in sorted(names.items()):
2697 mfentry = mf.get(abs)
2710 mfentry = mf.get(abs)
2698 target = repo.wjoin(abs)
2711 target = repo.wjoin(abs)
2699 def handle(xlist, dobackup):
2712 def handle(xlist, dobackup):
2700 xlist[0].append(abs)
2713 xlist[0].append(abs)
2701 if dobackup and not opts.get('no_backup') and util.lexists(target):
2714 if dobackup and not opts.get('no_backup') and util.lexists(target):
2702 bakname = "%s.orig" % rel
2715 bakname = "%s.orig" % rel
2703 ui.note(_('saving current version of %s as %s\n') %
2716 ui.note(_('saving current version of %s as %s\n') %
2704 (rel, bakname))
2717 (rel, bakname))
2705 if not opts.get('dry_run'):
2718 if not opts.get('dry_run'):
2706 util.copyfile(target, bakname)
2719 util.copyfile(target, bakname)
2707 if ui.verbose or not exact:
2720 if ui.verbose or not exact:
2708 msg = xlist[1]
2721 msg = xlist[1]
2709 if not isinstance(msg, basestring):
2722 if not isinstance(msg, basestring):
2710 msg = msg(abs)
2723 msg = msg(abs)
2711 ui.status(msg % rel)
2724 ui.status(msg % rel)
2712 for table, hitlist, misslist, backuphit, backupmiss in disptable:
2725 for table, hitlist, misslist, backuphit, backupmiss in disptable:
2713 if abs not in table:
2726 if abs not in table:
2714 continue
2727 continue
2715 # file has changed in dirstate
2728 # file has changed in dirstate
2716 if mfentry:
2729 if mfentry:
2717 handle(hitlist, backuphit)
2730 handle(hitlist, backuphit)
2718 elif misslist is not None:
2731 elif misslist is not None:
2719 handle(misslist, backupmiss)
2732 handle(misslist, backupmiss)
2720 break
2733 break
2721 else:
2734 else:
2722 if abs not in repo.dirstate:
2735 if abs not in repo.dirstate:
2723 if mfentry:
2736 if mfentry:
2724 handle(add, True)
2737 handle(add, True)
2725 elif exact:
2738 elif exact:
2726 ui.warn(_('file not managed: %s\n') % rel)
2739 ui.warn(_('file not managed: %s\n') % rel)
2727 continue
2740 continue
2728 # file has not changed in dirstate
2741 # file has not changed in dirstate
2729 if node == parent:
2742 if node == parent:
2730 if exact:
2743 if exact:
2731 ui.warn(_('no changes needed to %s\n') % rel)
2744 ui.warn(_('no changes needed to %s\n') % rel)
2732 continue
2745 continue
2733 if pmf is None:
2746 if pmf is None:
2734 # only need parent manifest in this unlikely case,
2747 # only need parent manifest in this unlikely case,
2735 # so do not read by default
2748 # so do not read by default
2736 pmf = repo[parent].manifest()
2749 pmf = repo[parent].manifest()
2737 if abs in pmf:
2750 if abs in pmf:
2738 if mfentry:
2751 if mfentry:
2739 # if version of file is same in parent and target
2752 # if version of file is same in parent and target
2740 # manifests, do nothing
2753 # manifests, do nothing
2741 if (pmf[abs] != mfentry or
2754 if (pmf[abs] != mfentry or
2742 pmf.flags(abs) != mf.flags(abs)):
2755 pmf.flags(abs) != mf.flags(abs)):
2743 handle(revert, False)
2756 handle(revert, False)
2744 else:
2757 else:
2745 handle(remove, False)
2758 handle(remove, False)
2746
2759
2747 if not opts.get('dry_run'):
2760 if not opts.get('dry_run'):
2748 def checkout(f):
2761 def checkout(f):
2749 fc = ctx[f]
2762 fc = ctx[f]
2750 repo.wwrite(f, fc.data(), fc.flags())
2763 repo.wwrite(f, fc.data(), fc.flags())
2751
2764
2752 audit_path = util.path_auditor(repo.root)
2765 audit_path = util.path_auditor(repo.root)
2753 for f in remove[0]:
2766 for f in remove[0]:
2754 if repo.dirstate[f] == 'a':
2767 if repo.dirstate[f] == 'a':
2755 repo.dirstate.forget(f)
2768 repo.dirstate.forget(f)
2756 continue
2769 continue
2757 audit_path(f)
2770 audit_path(f)
2758 try:
2771 try:
2759 util.unlink(repo.wjoin(f))
2772 util.unlink(repo.wjoin(f))
2760 except OSError:
2773 except OSError:
2761 pass
2774 pass
2762 repo.dirstate.remove(f)
2775 repo.dirstate.remove(f)
2763
2776
2764 normal = None
2777 normal = None
2765 if node == parent:
2778 if node == parent:
2766 # We're reverting to our parent. If possible, we'd like status
2779 # We're reverting to our parent. If possible, we'd like status
2767 # to report the file as clean. We have to use normallookup for
2780 # to report the file as clean. We have to use normallookup for
2768 # merges to avoid losing information about merged/dirty files.
2781 # merges to avoid losing information about merged/dirty files.
2769 if p2 != nullid:
2782 if p2 != nullid:
2770 normal = repo.dirstate.normallookup
2783 normal = repo.dirstate.normallookup
2771 else:
2784 else:
2772 normal = repo.dirstate.normal
2785 normal = repo.dirstate.normal
2773 for f in revert[0]:
2786 for f in revert[0]:
2774 checkout(f)
2787 checkout(f)
2775 if normal:
2788 if normal:
2776 normal(f)
2789 normal(f)
2777
2790
2778 for f in add[0]:
2791 for f in add[0]:
2779 checkout(f)
2792 checkout(f)
2780 repo.dirstate.add(f)
2793 repo.dirstate.add(f)
2781
2794
2782 normal = repo.dirstate.normallookup
2795 normal = repo.dirstate.normallookup
2783 if node == parent and p2 == nullid:
2796 if node == parent and p2 == nullid:
2784 normal = repo.dirstate.normal
2797 normal = repo.dirstate.normal
2785 for f in undelete[0]:
2798 for f in undelete[0]:
2786 checkout(f)
2799 checkout(f)
2787 normal(f)
2800 normal(f)
2788
2801
2789 finally:
2802 finally:
2790 wlock.release()
2803 wlock.release()
2791
2804
2792 def rollback(ui, repo):
2805 def rollback(ui, repo):
2793 """roll back the last transaction
2806 """roll back the last transaction
2794
2807
2795 This command should be used with care. There is only one level of
2808 This command should be used with care. There is only one level of
2796 rollback, and there is no way to undo a rollback. It will also
2809 rollback, and there is no way to undo a rollback. It will also
2797 restore the dirstate at the time of the last transaction, losing
2810 restore the dirstate at the time of the last transaction, losing
2798 any dirstate changes since that time. This command does not alter
2811 any dirstate changes since that time. This command does not alter
2799 the working directory.
2812 the working directory.
2800
2813
2801 Transactions are used to encapsulate the effects of all commands
2814 Transactions are used to encapsulate the effects of all commands
2802 that create new changesets or propagate existing changesets into a
2815 that create new changesets or propagate existing changesets into a
2803 repository. For example, the following commands are transactional,
2816 repository. For example, the following commands are transactional,
2804 and their effects can be rolled back:
2817 and their effects can be rolled back:
2805
2818
2806 - commit
2819 - commit
2807 - import
2820 - import
2808 - pull
2821 - pull
2809 - push (with this repository as the destination)
2822 - push (with this repository as the destination)
2810 - unbundle
2823 - unbundle
2811
2824
2812 This command is not intended for use on public repositories. Once
2825 This command is not intended for use on public repositories. Once
2813 changes are visible for pull by other users, rolling a transaction
2826 changes are visible for pull by other users, rolling a transaction
2814 back locally is ineffective (someone else may already have pulled
2827 back locally is ineffective (someone else may already have pulled
2815 the changes). Furthermore, a race is possible with readers of the
2828 the changes). Furthermore, a race is possible with readers of the
2816 repository; for example an in-progress pull from the repository
2829 repository; for example an in-progress pull from the repository
2817 may fail if a rollback is performed.
2830 may fail if a rollback is performed.
2818 """
2831 """
2819 repo.rollback()
2832 repo.rollback()
2820
2833
2821 def root(ui, repo):
2834 def root(ui, repo):
2822 """print the root (top) of the current working directory
2835 """print the root (top) of the current working directory
2823
2836
2824 Print the root directory of the current repository.
2837 Print the root directory of the current repository.
2825 """
2838 """
2826 ui.write(repo.root + "\n")
2839 ui.write(repo.root + "\n")
2827
2840
2828 def serve(ui, repo, **opts):
2841 def serve(ui, repo, **opts):
2829 """export the repository via HTTP
2842 """export the repository via HTTP
2830
2843
2831 Start a local HTTP repository browser and pull server.
2844 Start a local HTTP repository browser and pull server.
2832
2845
2833 By default, the server logs accesses to stdout and errors to
2846 By default, the server logs accesses to stdout and errors to
2834 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
2847 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
2835 files.
2848 files.
2836 """
2849 """
2837
2850
2838 if opts["stdio"]:
2851 if opts["stdio"]:
2839 if repo is None:
2852 if repo is None:
2840 raise error.RepoError(_("There is no Mercurial repository here"
2853 raise error.RepoError(_("There is no Mercurial repository here"
2841 " (.hg not found)"))
2854 " (.hg not found)"))
2842 s = sshserver.sshserver(ui, repo)
2855 s = sshserver.sshserver(ui, repo)
2843 s.serve_forever()
2856 s.serve_forever()
2844
2857
2845 baseui = repo and repo.baseui or ui
2858 baseui = repo and repo.baseui or ui
2846 optlist = ("name templates style address port prefix ipv6"
2859 optlist = ("name templates style address port prefix ipv6"
2847 " accesslog errorlog webdir_conf certificate encoding")
2860 " accesslog errorlog webdir_conf certificate encoding")
2848 for o in optlist.split():
2861 for o in optlist.split():
2849 if opts.get(o, None):
2862 if opts.get(o, None):
2850 baseui.setconfig("web", o, str(opts[o]))
2863 baseui.setconfig("web", o, str(opts[o]))
2851 if (repo is not None) and (repo.ui != baseui):
2864 if (repo is not None) and (repo.ui != baseui):
2852 repo.ui.setconfig("web", o, str(opts[o]))
2865 repo.ui.setconfig("web", o, str(opts[o]))
2853
2866
2854 if repo is None and not ui.config("web", "webdir_conf"):
2867 if repo is None and not ui.config("web", "webdir_conf"):
2855 raise error.RepoError(_("There is no Mercurial repository here"
2868 raise error.RepoError(_("There is no Mercurial repository here"
2856 " (.hg not found)"))
2869 " (.hg not found)"))
2857
2870
2858 class service(object):
2871 class service(object):
2859 def init(self):
2872 def init(self):
2860 util.set_signal_handler()
2873 util.set_signal_handler()
2861 self.httpd = server.create_server(baseui, repo)
2874 self.httpd = server.create_server(baseui, repo)
2862
2875
2863 if not ui.verbose:
2876 if not ui.verbose:
2864 return
2877 return
2865
2878
2866 if self.httpd.prefix:
2879 if self.httpd.prefix:
2867 prefix = self.httpd.prefix.strip('/') + '/'
2880 prefix = self.httpd.prefix.strip('/') + '/'
2868 else:
2881 else:
2869 prefix = ''
2882 prefix = ''
2870
2883
2871 port = ':%d' % self.httpd.port
2884 port = ':%d' % self.httpd.port
2872 if port == ':80':
2885 if port == ':80':
2873 port = ''
2886 port = ''
2874
2887
2875 bindaddr = self.httpd.addr
2888 bindaddr = self.httpd.addr
2876 if bindaddr == '0.0.0.0':
2889 if bindaddr == '0.0.0.0':
2877 bindaddr = '*'
2890 bindaddr = '*'
2878 elif ':' in bindaddr: # IPv6
2891 elif ':' in bindaddr: # IPv6
2879 bindaddr = '[%s]' % bindaddr
2892 bindaddr = '[%s]' % bindaddr
2880
2893
2881 fqaddr = self.httpd.fqaddr
2894 fqaddr = self.httpd.fqaddr
2882 if ':' in fqaddr:
2895 if ':' in fqaddr:
2883 fqaddr = '[%s]' % fqaddr
2896 fqaddr = '[%s]' % fqaddr
2884 ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
2897 ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
2885 (fqaddr, port, prefix, bindaddr, self.httpd.port))
2898 (fqaddr, port, prefix, bindaddr, self.httpd.port))
2886
2899
2887 def run(self):
2900 def run(self):
2888 self.httpd.serve_forever()
2901 self.httpd.serve_forever()
2889
2902
2890 service = service()
2903 service = service()
2891
2904
2892 cmdutil.service(opts, initfn=service.init, runfn=service.run)
2905 cmdutil.service(opts, initfn=service.init, runfn=service.run)
2893
2906
2894 def status(ui, repo, *pats, **opts):
2907 def status(ui, repo, *pats, **opts):
2895 """show changed files in the working directory
2908 """show changed files in the working directory
2896
2909
2897 Show status of files in the repository. If names are given, only
2910 Show status of files in the repository. If names are given, only
2898 files that match are shown. Files that are clean or ignored or
2911 files that match are shown. Files that are clean or ignored or
2899 the source of a copy/move operation, are not listed unless
2912 the source of a copy/move operation, are not listed unless
2900 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
2913 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
2901 Unless options described with "show only ..." are given, the
2914 Unless options described with "show only ..." are given, the
2902 options -mardu are used.
2915 options -mardu are used.
2903
2916
2904 Option -q/--quiet hides untracked (unknown and ignored) files
2917 Option -q/--quiet hides untracked (unknown and ignored) files
2905 unless explicitly requested with -u/--unknown or -i/--ignored.
2918 unless explicitly requested with -u/--unknown or -i/--ignored.
2906
2919
2907 NOTE: status may appear to disagree with diff if permissions have
2920 NOTE: status may appear to disagree with diff if permissions have
2908 changed or a merge has occurred. The standard diff format does not
2921 changed or a merge has occurred. The standard diff format does not
2909 report permission changes and diff only reports changes relative
2922 report permission changes and diff only reports changes relative
2910 to one merge parent.
2923 to one merge parent.
2911
2924
2912 If one revision is given, it is used as the base revision.
2925 If one revision is given, it is used as the base revision.
2913 If two revisions are given, the differences between them are
2926 If two revisions are given, the differences between them are
2914 shown. The --change option can also be used as a shortcut to list
2927 shown. The --change option can also be used as a shortcut to list
2915 the changed files of a revision from its first parent.
2928 the changed files of a revision from its first parent.
2916
2929
2917 The codes used to show the status of files are::
2930 The codes used to show the status of files are::
2918
2931
2919 M = modified
2932 M = modified
2920 A = added
2933 A = added
2921 R = removed
2934 R = removed
2922 C = clean
2935 C = clean
2923 ! = missing (deleted by non-hg command, but still tracked)
2936 ! = missing (deleted by non-hg command, but still tracked)
2924 ? = not tracked
2937 ? = not tracked
2925 I = ignored
2938 I = ignored
2926 = origin of the previous file listed as A (added)
2939 = origin of the previous file listed as A (added)
2927 """
2940 """
2928
2941
2929 revs = opts.get('rev')
2942 revs = opts.get('rev')
2930 change = opts.get('change')
2943 change = opts.get('change')
2931
2944
2932 if revs and change:
2945 if revs and change:
2933 msg = _('cannot specify --rev and --change at the same time')
2946 msg = _('cannot specify --rev and --change at the same time')
2934 raise util.Abort(msg)
2947 raise util.Abort(msg)
2935 elif change:
2948 elif change:
2936 node2 = repo.lookup(change)
2949 node2 = repo.lookup(change)
2937 node1 = repo[node2].parents()[0].node()
2950 node1 = repo[node2].parents()[0].node()
2938 else:
2951 else:
2939 node1, node2 = cmdutil.revpair(repo, revs)
2952 node1, node2 = cmdutil.revpair(repo, revs)
2940
2953
2941 cwd = (pats and repo.getcwd()) or ''
2954 cwd = (pats and repo.getcwd()) or ''
2942 end = opts.get('print0') and '\0' or '\n'
2955 end = opts.get('print0') and '\0' or '\n'
2943 copy = {}
2956 copy = {}
2944 states = 'modified added removed deleted unknown ignored clean'.split()
2957 states = 'modified added removed deleted unknown ignored clean'.split()
2945 show = [k for k in states if opts.get(k)]
2958 show = [k for k in states if opts.get(k)]
2946 if opts.get('all'):
2959 if opts.get('all'):
2947 show += ui.quiet and (states[:4] + ['clean']) or states
2960 show += ui.quiet and (states[:4] + ['clean']) or states
2948 if not show:
2961 if not show:
2949 show = ui.quiet and states[:4] or states[:5]
2962 show = ui.quiet and states[:4] or states[:5]
2950
2963
2951 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
2964 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
2952 'ignored' in show, 'clean' in show, 'unknown' in show)
2965 'ignored' in show, 'clean' in show, 'unknown' in show)
2953 changestates = zip(states, 'MAR!?IC', stat)
2966 changestates = zip(states, 'MAR!?IC', stat)
2954
2967
2955 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
2968 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
2956 ctxn = repo[nullid]
2969 ctxn = repo[nullid]
2957 ctx1 = repo[node1]
2970 ctx1 = repo[node1]
2958 ctx2 = repo[node2]
2971 ctx2 = repo[node2]
2959 added = stat[1]
2972 added = stat[1]
2960 if node2 is None:
2973 if node2 is None:
2961 added = stat[0] + stat[1] # merged?
2974 added = stat[0] + stat[1] # merged?
2962
2975
2963 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
2976 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
2964 if k in added:
2977 if k in added:
2965 copy[k] = v
2978 copy[k] = v
2966 elif v in added:
2979 elif v in added:
2967 copy[v] = k
2980 copy[v] = k
2968
2981
2969 for state, char, files in changestates:
2982 for state, char, files in changestates:
2970 if state in show:
2983 if state in show:
2971 format = "%s %%s%s" % (char, end)
2984 format = "%s %%s%s" % (char, end)
2972 if opts.get('no_status'):
2985 if opts.get('no_status'):
2973 format = "%%s%s" % end
2986 format = "%%s%s" % end
2974
2987
2975 for f in files:
2988 for f in files:
2976 ui.write(format % repo.pathto(f, cwd))
2989 ui.write(format % repo.pathto(f, cwd))
2977 if f in copy:
2990 if f in copy:
2978 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end))
2991 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end))
2979
2992
2980 def summary(ui, repo, **opts):
2993 def summary(ui, repo, **opts):
2981 """summarize working directory state
2994 """summarize working directory state
2982
2995
2983 This generates a brief summary of the working directory state,
2996 This generates a brief summary of the working directory state,
2984 including parents, branch, commit status, and available updates.
2997 including parents, branch, commit status, and available updates.
2985
2998
2986 With the --remote option, this will check the default paths for
2999 With the --remote option, this will check the default paths for
2987 incoming and outgoing changes. This can be time-consuming.
3000 incoming and outgoing changes. This can be time-consuming.
2988 """
3001 """
2989
3002
2990 ctx = repo[None]
3003 ctx = repo[None]
2991 parents = ctx.parents()
3004 parents = ctx.parents()
2992 pnode = parents[0].node()
3005 pnode = parents[0].node()
2993 tags = repo.tags()
3006 tags = repo.tags()
2994
3007
2995 for p in parents:
3008 for p in parents:
2996 t = ' '.join([t for t in tags if tags[t] == p.node()])
3009 t = ' '.join([t for t in tags if tags[t] == p.node()])
2997 if p.rev() == -1:
3010 if p.rev() == -1:
2998 if not len(repo):
3011 if not len(repo):
2999 t += _(' (empty repository)')
3012 t += _(' (empty repository)')
3000 else:
3013 else:
3001 t += _(' (no revision checked out)')
3014 t += _(' (no revision checked out)')
3002 ui.write(_('parent: %d:%s %s\n') % (p.rev(), str(p), t))
3015 ui.write(_('parent: %d:%s %s\n') % (p.rev(), str(p), t))
3003 if p.description():
3016 if p.description():
3004 ui.status(' ' + p.description().splitlines()[0].strip() + '\n')
3017 ui.status(' ' + p.description().splitlines()[0].strip() + '\n')
3005
3018
3006 branch = ctx.branch()
3019 branch = ctx.branch()
3007 bheads = repo.branchheads(branch)
3020 bheads = repo.branchheads(branch)
3008 m = _('branch: %s\n') % branch
3021 m = _('branch: %s\n') % branch
3009 if branch != 'default':
3022 if branch != 'default':
3010 ui.write(m)
3023 ui.write(m)
3011 else:
3024 else:
3012 ui.status(m)
3025 ui.status(m)
3013
3026
3014 st = list(repo.status(unknown=True))[:6]
3027 st = list(repo.status(unknown=True))[:6]
3015 ms = merge_.mergestate(repo)
3028 ms = merge_.mergestate(repo)
3016 st.append([f for f in ms if ms[f] == 'u'])
3029 st.append([f for f in ms if ms[f] == 'u'])
3017 labels = [_('%d modified'), _('%d added'), _('%d removed'),
3030 labels = [_('%d modified'), _('%d added'), _('%d removed'),
3018 _('%d deleted'), _('%d unknown'), _('%d ignored'),
3031 _('%d deleted'), _('%d unknown'), _('%d ignored'),
3019 _('%d unresolved')]
3032 _('%d unresolved')]
3020 t = []
3033 t = []
3021 for s, l in zip(st, labels):
3034 for s, l in zip(st, labels):
3022 if s:
3035 if s:
3023 t.append(l % len(s))
3036 t.append(l % len(s))
3024
3037
3025 t = ', '.join(t)
3038 t = ', '.join(t)
3026 cleanworkdir = False
3039 cleanworkdir = False
3027
3040
3028 if len(parents) > 1:
3041 if len(parents) > 1:
3029 t += _(' (merge)')
3042 t += _(' (merge)')
3030 elif branch != parents[0].branch():
3043 elif branch != parents[0].branch():
3031 t += _(' (new branch)')
3044 t += _(' (new branch)')
3032 elif (not st[0] and not st[1] and not st[2]):
3045 elif (not st[0] and not st[1] and not st[2]):
3033 t += _(' (clean)')
3046 t += _(' (clean)')
3034 cleanworkdir = True
3047 cleanworkdir = True
3035 elif pnode not in bheads:
3048 elif pnode not in bheads:
3036 t += _(' (new branch head)')
3049 t += _(' (new branch head)')
3037
3050
3038 if cleanworkdir:
3051 if cleanworkdir:
3039 ui.status(_('commit: %s\n') % t.strip())
3052 ui.status(_('commit: %s\n') % t.strip())
3040 else:
3053 else:
3041 ui.write(_('commit: %s\n') % t.strip())
3054 ui.write(_('commit: %s\n') % t.strip())
3042
3055
3043 # all ancestors of branch heads - all ancestors of parent = new csets
3056 # all ancestors of branch heads - all ancestors of parent = new csets
3044 new = [0] * len(repo)
3057 new = [0] * len(repo)
3045 cl = repo.changelog
3058 cl = repo.changelog
3046 for a in [cl.rev(n) for n in bheads]:
3059 for a in [cl.rev(n) for n in bheads]:
3047 new[a] = 1
3060 new[a] = 1
3048 for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
3061 for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
3049 new[a] = 1
3062 new[a] = 1
3050 for a in [p.rev() for p in parents]:
3063 for a in [p.rev() for p in parents]:
3051 if a >= 0:
3064 if a >= 0:
3052 new[a] = 0
3065 new[a] = 0
3053 for a in cl.ancestors(*[p.rev() for p in parents]):
3066 for a in cl.ancestors(*[p.rev() for p in parents]):
3054 new[a] = 0
3067 new[a] = 0
3055 new = sum(new)
3068 new = sum(new)
3056
3069
3057 if new == 0:
3070 if new == 0:
3058 ui.status(_('update: (current)\n'))
3071 ui.status(_('update: (current)\n'))
3059 elif pnode not in bheads:
3072 elif pnode not in bheads:
3060 ui.write(_('update: %d new changesets (update)\n') % new)
3073 ui.write(_('update: %d new changesets (update)\n') % new)
3061 else:
3074 else:
3062 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
3075 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
3063 (new, len(bheads)))
3076 (new, len(bheads)))
3064
3077
3065 if opts.get('remote'):
3078 if opts.get('remote'):
3066 t = []
3079 t = []
3067 source, branches = hg.parseurl(ui.expandpath('default'))
3080 source, branches = hg.parseurl(ui.expandpath('default'))
3068 other = hg.repository(cmdutil.remoteui(repo, {}), source)
3081 other = hg.repository(cmdutil.remoteui(repo, {}), source)
3069 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3082 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3070 ui.debug('comparing with %s\n' % url.hidepassword(source))
3083 ui.debug('comparing with %s\n' % url.hidepassword(source))
3071 repo.ui.pushbuffer()
3084 repo.ui.pushbuffer()
3072 common, incoming, rheads = repo.findcommonincoming(other)
3085 common, incoming, rheads = repo.findcommonincoming(other)
3073 repo.ui.popbuffer()
3086 repo.ui.popbuffer()
3074 if incoming:
3087 if incoming:
3075 t.append(_('1 or more incoming'))
3088 t.append(_('1 or more incoming'))
3076
3089
3077 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3090 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3078 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3091 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3079 other = hg.repository(cmdutil.remoteui(repo, {}), dest)
3092 other = hg.repository(cmdutil.remoteui(repo, {}), dest)
3080 ui.debug('comparing with %s\n' % url.hidepassword(dest))
3093 ui.debug('comparing with %s\n' % url.hidepassword(dest))
3081 repo.ui.pushbuffer()
3094 repo.ui.pushbuffer()
3082 o = repo.findoutgoing(other)
3095 o = repo.findoutgoing(other)
3083 repo.ui.popbuffer()
3096 repo.ui.popbuffer()
3084 o = repo.changelog.nodesbetween(o, None)[0]
3097 o = repo.changelog.nodesbetween(o, None)[0]
3085 if o:
3098 if o:
3086 t.append(_('%d outgoing') % len(o))
3099 t.append(_('%d outgoing') % len(o))
3087
3100
3088 if t:
3101 if t:
3089 ui.write(_('remote: %s\n') % (', '.join(t)))
3102 ui.write(_('remote: %s\n') % (', '.join(t)))
3090 else:
3103 else:
3091 ui.status(_('remote: (synced)\n'))
3104 ui.status(_('remote: (synced)\n'))
3092
3105
3093 def tag(ui, repo, name1, *names, **opts):
3106 def tag(ui, repo, name1, *names, **opts):
3094 """add one or more tags for the current or given revision
3107 """add one or more tags for the current or given revision
3095
3108
3096 Name a particular revision using <name>.
3109 Name a particular revision using <name>.
3097
3110
3098 Tags are used to name particular revisions of the repository and are
3111 Tags are used to name particular revisions of the repository and are
3099 very useful to compare different revisions, to go back to significant
3112 very useful to compare different revisions, to go back to significant
3100 earlier versions or to mark branch points as releases, etc.
3113 earlier versions or to mark branch points as releases, etc.
3101
3114
3102 If no revision is given, the parent of the working directory is
3115 If no revision is given, the parent of the working directory is
3103 used, or tip if no revision is checked out.
3116 used, or tip if no revision is checked out.
3104
3117
3105 To facilitate version control, distribution, and merging of tags,
3118 To facilitate version control, distribution, and merging of tags,
3106 they are stored as a file named ".hgtags" which is managed
3119 they are stored as a file named ".hgtags" which is managed
3107 similarly to other project files and can be hand-edited if
3120 similarly to other project files and can be hand-edited if
3108 necessary. The file '.hg/localtags' is used for local tags (not
3121 necessary. The file '.hg/localtags' is used for local tags (not
3109 shared among repositories).
3122 shared among repositories).
3110
3123
3111 See 'hg help dates' for a list of formats valid for -d/--date.
3124 See 'hg help dates' for a list of formats valid for -d/--date.
3112 """
3125 """
3113
3126
3114 rev_ = "."
3127 rev_ = "."
3115 names = (name1,) + names
3128 names = (name1,) + names
3116 if len(names) != len(set(names)):
3129 if len(names) != len(set(names)):
3117 raise util.Abort(_('tag names must be unique'))
3130 raise util.Abort(_('tag names must be unique'))
3118 for n in names:
3131 for n in names:
3119 if n in ['tip', '.', 'null']:
3132 if n in ['tip', '.', 'null']:
3120 raise util.Abort(_('the name \'%s\' is reserved') % n)
3133 raise util.Abort(_('the name \'%s\' is reserved') % n)
3121 if opts.get('rev') and opts.get('remove'):
3134 if opts.get('rev') and opts.get('remove'):
3122 raise util.Abort(_("--rev and --remove are incompatible"))
3135 raise util.Abort(_("--rev and --remove are incompatible"))
3123 if opts.get('rev'):
3136 if opts.get('rev'):
3124 rev_ = opts['rev']
3137 rev_ = opts['rev']
3125 message = opts.get('message')
3138 message = opts.get('message')
3126 if opts.get('remove'):
3139 if opts.get('remove'):
3127 expectedtype = opts.get('local') and 'local' or 'global'
3140 expectedtype = opts.get('local') and 'local' or 'global'
3128 for n in names:
3141 for n in names:
3129 if not repo.tagtype(n):
3142 if not repo.tagtype(n):
3130 raise util.Abort(_('tag \'%s\' does not exist') % n)
3143 raise util.Abort(_('tag \'%s\' does not exist') % n)
3131 if repo.tagtype(n) != expectedtype:
3144 if repo.tagtype(n) != expectedtype:
3132 if expectedtype == 'global':
3145 if expectedtype == 'global':
3133 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
3146 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
3134 else:
3147 else:
3135 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
3148 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
3136 rev_ = nullid
3149 rev_ = nullid
3137 if not message:
3150 if not message:
3138 # we don't translate commit messages
3151 # we don't translate commit messages
3139 message = 'Removed tag %s' % ', '.join(names)
3152 message = 'Removed tag %s' % ', '.join(names)
3140 elif not opts.get('force'):
3153 elif not opts.get('force'):
3141 for n in names:
3154 for n in names:
3142 if n in repo.tags():
3155 if n in repo.tags():
3143 raise util.Abort(_('tag \'%s\' already exists '
3156 raise util.Abort(_('tag \'%s\' already exists '
3144 '(use -f to force)') % n)
3157 '(use -f to force)') % n)
3145 if not rev_ and repo.dirstate.parents()[1] != nullid:
3158 if not rev_ and repo.dirstate.parents()[1] != nullid:
3146 raise util.Abort(_('uncommitted merge - please provide a '
3159 raise util.Abort(_('uncommitted merge - please provide a '
3147 'specific revision'))
3160 'specific revision'))
3148 r = repo[rev_].node()
3161 r = repo[rev_].node()
3149
3162
3150 if not message:
3163 if not message:
3151 # we don't translate commit messages
3164 # we don't translate commit messages
3152 message = ('Added tag %s for changeset %s' %
3165 message = ('Added tag %s for changeset %s' %
3153 (', '.join(names), short(r)))
3166 (', '.join(names), short(r)))
3154
3167
3155 date = opts.get('date')
3168 date = opts.get('date')
3156 if date:
3169 if date:
3157 date = util.parsedate(date)
3170 date = util.parsedate(date)
3158
3171
3159 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
3172 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
3160
3173
3161 def tags(ui, repo):
3174 def tags(ui, repo):
3162 """list repository tags
3175 """list repository tags
3163
3176
3164 This lists both regular and local tags. When the -v/--verbose
3177 This lists both regular and local tags. When the -v/--verbose
3165 switch is used, a third column "local" is printed for local tags.
3178 switch is used, a third column "local" is printed for local tags.
3166 """
3179 """
3167
3180
3168 hexfunc = ui.debugflag and hex or short
3181 hexfunc = ui.debugflag and hex or short
3169 tagtype = ""
3182 tagtype = ""
3170
3183
3171 for t, n in reversed(repo.tagslist()):
3184 for t, n in reversed(repo.tagslist()):
3172 if ui.quiet:
3185 if ui.quiet:
3173 ui.write("%s\n" % t)
3186 ui.write("%s\n" % t)
3174 continue
3187 continue
3175
3188
3176 try:
3189 try:
3177 hn = hexfunc(n)
3190 hn = hexfunc(n)
3178 r = "%5d:%s" % (repo.changelog.rev(n), hn)
3191 r = "%5d:%s" % (repo.changelog.rev(n), hn)
3179 except error.LookupError:
3192 except error.LookupError:
3180 r = " ?:%s" % hn
3193 r = " ?:%s" % hn
3181 else:
3194 else:
3182 spaces = " " * (30 - encoding.colwidth(t))
3195 spaces = " " * (30 - encoding.colwidth(t))
3183 if ui.verbose:
3196 if ui.verbose:
3184 if repo.tagtype(t) == 'local':
3197 if repo.tagtype(t) == 'local':
3185 tagtype = " local"
3198 tagtype = " local"
3186 else:
3199 else:
3187 tagtype = ""
3200 tagtype = ""
3188 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
3201 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
3189
3202
3190 def tip(ui, repo, **opts):
3203 def tip(ui, repo, **opts):
3191 """show the tip revision
3204 """show the tip revision
3192
3205
3193 The tip revision (usually just called the tip) is the changeset
3206 The tip revision (usually just called the tip) is the changeset
3194 most recently added to the repository (and therefore the most
3207 most recently added to the repository (and therefore the most
3195 recently changed head).
3208 recently changed head).
3196
3209
3197 If you have just made a commit, that commit will be the tip. If
3210 If you have just made a commit, that commit will be the tip. If
3198 you have just pulled changes from another repository, the tip of
3211 you have just pulled changes from another repository, the tip of
3199 that repository becomes the current tip. The "tip" tag is special
3212 that repository becomes the current tip. The "tip" tag is special
3200 and cannot be renamed or assigned to a different changeset.
3213 and cannot be renamed or assigned to a different changeset.
3201 """
3214 """
3202 displayer = cmdutil.show_changeset(ui, repo, opts)
3215 displayer = cmdutil.show_changeset(ui, repo, opts)
3203 displayer.show(repo[len(repo) - 1])
3216 displayer.show(repo[len(repo) - 1])
3204 displayer.close()
3217 displayer.close()
3205
3218
3206 def unbundle(ui, repo, fname1, *fnames, **opts):
3219 def unbundle(ui, repo, fname1, *fnames, **opts):
3207 """apply one or more changegroup files
3220 """apply one or more changegroup files
3208
3221
3209 Apply one or more compressed changegroup files generated by the
3222 Apply one or more compressed changegroup files generated by the
3210 bundle command.
3223 bundle command.
3211 """
3224 """
3212 fnames = (fname1,) + fnames
3225 fnames = (fname1,) + fnames
3213
3226
3214 lock = repo.lock()
3227 lock = repo.lock()
3215 try:
3228 try:
3216 for fname in fnames:
3229 for fname in fnames:
3217 f = url.open(ui, fname)
3230 f = url.open(ui, fname)
3218 gen = changegroup.readbundle(f, fname)
3231 gen = changegroup.readbundle(f, fname)
3219 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
3232 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
3220 finally:
3233 finally:
3221 lock.release()
3234 lock.release()
3222
3235
3223 return postincoming(ui, repo, modheads, opts.get('update'), None)
3236 return postincoming(ui, repo, modheads, opts.get('update'), None)
3224
3237
3225 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
3238 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
3226 """update working directory
3239 """update working directory
3227
3240
3228 Update the repository's working directory to the specified
3241 Update the repository's working directory to the specified
3229 changeset.
3242 changeset.
3230
3243
3231 If no changeset is specified, attempt to update to the head of the
3244 If no changeset is specified, attempt to update to the head of the
3232 current branch. If this head is a descendant of the working
3245 current branch. If this head is a descendant of the working
3233 directory's parent, update to it, otherwise abort.
3246 directory's parent, update to it, otherwise abort.
3234
3247
3235 The following rules apply when the working directory contains
3248 The following rules apply when the working directory contains
3236 uncommitted changes:
3249 uncommitted changes:
3237
3250
3238 1. If neither -c/--check nor -C/--clean is specified, and if
3251 1. If neither -c/--check nor -C/--clean is specified, and if
3239 the requested changeset is an ancestor or descendant of
3252 the requested changeset is an ancestor or descendant of
3240 the working directory's parent, the uncommitted changes
3253 the working directory's parent, the uncommitted changes
3241 are merged into the requested changeset and the merged
3254 are merged into the requested changeset and the merged
3242 result is left uncommitted. If the requested changeset is
3255 result is left uncommitted. If the requested changeset is
3243 not an ancestor or descendant (that is, it is on another
3256 not an ancestor or descendant (that is, it is on another
3244 branch), the update is aborted and the uncommitted changes
3257 branch), the update is aborted and the uncommitted changes
3245 are preserved.
3258 are preserved.
3246
3259
3247 2. With the -c/--check option, the update is aborted and the
3260 2. With the -c/--check option, the update is aborted and the
3248 uncommitted changes are preserved.
3261 uncommitted changes are preserved.
3249
3262
3250 3. With the -C/--clean option, uncommitted changes are discarded and
3263 3. With the -C/--clean option, uncommitted changes are discarded and
3251 the working directory is updated to the requested changeset.
3264 the working directory is updated to the requested changeset.
3252
3265
3253 Use null as the changeset to remove the working directory (like 'hg
3266 Use null as the changeset to remove the working directory (like 'hg
3254 clone -U').
3267 clone -U').
3255
3268
3256 If you want to update just one file to an older changeset, use 'hg revert'.
3269 If you want to update just one file to an older changeset, use 'hg revert'.
3257
3270
3258 See 'hg help dates' for a list of formats valid for -d/--date.
3271 See 'hg help dates' for a list of formats valid for -d/--date.
3259 """
3272 """
3260 if rev and node:
3273 if rev and node:
3261 raise util.Abort(_("please specify just one revision"))
3274 raise util.Abort(_("please specify just one revision"))
3262
3275
3263 if not rev:
3276 if not rev:
3264 rev = node
3277 rev = node
3265
3278
3266 if check and clean:
3279 if check and clean:
3267 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
3280 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
3268
3281
3269 if check:
3282 if check:
3270 # we could use dirty() but we can ignore merge and branch trivia
3283 # we could use dirty() but we can ignore merge and branch trivia
3271 c = repo[None]
3284 c = repo[None]
3272 if c.modified() or c.added() or c.removed():
3285 if c.modified() or c.added() or c.removed():
3273 raise util.Abort(_("uncommitted local changes"))
3286 raise util.Abort(_("uncommitted local changes"))
3274
3287
3275 if date:
3288 if date:
3276 if rev:
3289 if rev:
3277 raise util.Abort(_("you can't specify a revision and a date"))
3290 raise util.Abort(_("you can't specify a revision and a date"))
3278 rev = cmdutil.finddate(ui, repo, date)
3291 rev = cmdutil.finddate(ui, repo, date)
3279
3292
3280 if clean or check:
3293 if clean or check:
3281 return hg.clean(repo, rev)
3294 return hg.clean(repo, rev)
3282 else:
3295 else:
3283 return hg.update(repo, rev)
3296 return hg.update(repo, rev)
3284
3297
3285 def verify(ui, repo):
3298 def verify(ui, repo):
3286 """verify the integrity of the repository
3299 """verify the integrity of the repository
3287
3300
3288 Verify the integrity of the current repository.
3301 Verify the integrity of the current repository.
3289
3302
3290 This will perform an extensive check of the repository's
3303 This will perform an extensive check of the repository's
3291 integrity, validating the hashes and checksums of each entry in
3304 integrity, validating the hashes and checksums of each entry in
3292 the changelog, manifest, and tracked files, as well as the
3305 the changelog, manifest, and tracked files, as well as the
3293 integrity of their crosslinks and indices.
3306 integrity of their crosslinks and indices.
3294 """
3307 """
3295 return hg.verify(repo)
3308 return hg.verify(repo)
3296
3309
3297 def version_(ui):
3310 def version_(ui):
3298 """output version and copyright information"""
3311 """output version and copyright information"""
3299 ui.write(_("Mercurial Distributed SCM (version %s)\n")
3312 ui.write(_("Mercurial Distributed SCM (version %s)\n")
3300 % util.version())
3313 % util.version())
3301 ui.status(_(
3314 ui.status(_(
3302 "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n"
3315 "\nCopyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others\n"
3303 "This is free software; see the source for copying conditions. "
3316 "This is free software; see the source for copying conditions. "
3304 "There is NO\nwarranty; "
3317 "There is NO\nwarranty; "
3305 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
3318 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
3306 ))
3319 ))
3307
3320
3308 # Command options and aliases are listed here, alphabetically
3321 # Command options and aliases are listed here, alphabetically
3309
3322
3310 globalopts = [
3323 globalopts = [
3311 ('R', 'repository', '',
3324 ('R', 'repository', '',
3312 _('repository root directory or name of overlay bundle file')),
3325 _('repository root directory or name of overlay bundle file')),
3313 ('', 'cwd', '', _('change working directory')),
3326 ('', 'cwd', '', _('change working directory')),
3314 ('y', 'noninteractive', None,
3327 ('y', 'noninteractive', None,
3315 _('do not prompt, assume \'yes\' for any required answers')),
3328 _('do not prompt, assume \'yes\' for any required answers')),
3316 ('q', 'quiet', None, _('suppress output')),
3329 ('q', 'quiet', None, _('suppress output')),
3317 ('v', 'verbose', None, _('enable additional output')),
3330 ('v', 'verbose', None, _('enable additional output')),
3318 ('', 'config', [], _('set/override config option')),
3331 ('', 'config', [], _('set/override config option')),
3319 ('', 'debug', None, _('enable debugging output')),
3332 ('', 'debug', None, _('enable debugging output')),
3320 ('', 'debugger', None, _('start debugger')),
3333 ('', 'debugger', None, _('start debugger')),
3321 ('', 'encoding', encoding.encoding, _('set the charset encoding')),
3334 ('', 'encoding', encoding.encoding, _('set the charset encoding')),
3322 ('', 'encodingmode', encoding.encodingmode,
3335 ('', 'encodingmode', encoding.encodingmode,
3323 _('set the charset encoding mode')),
3336 _('set the charset encoding mode')),
3324 ('', 'traceback', None, _('always print a traceback on exception')),
3337 ('', 'traceback', None, _('always print a traceback on exception')),
3325 ('', 'time', None, _('time how long the command takes')),
3338 ('', 'time', None, _('time how long the command takes')),
3326 ('', 'profile', None, _('print command execution profile')),
3339 ('', 'profile', None, _('print command execution profile')),
3327 ('', 'version', None, _('output version information and exit')),
3340 ('', 'version', None, _('output version information and exit')),
3328 ('h', 'help', None, _('display help and exit')),
3341 ('h', 'help', None, _('display help and exit')),
3329 ]
3342 ]
3330
3343
3331 dryrunopts = [('n', 'dry-run', None,
3344 dryrunopts = [('n', 'dry-run', None,
3332 _('do not perform actions, just print output'))]
3345 _('do not perform actions, just print output'))]
3333
3346
3334 remoteopts = [
3347 remoteopts = [
3335 ('e', 'ssh', '', _('specify ssh command to use')),
3348 ('e', 'ssh', '', _('specify ssh command to use')),
3336 ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
3349 ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
3337 ]
3350 ]
3338
3351
3339 walkopts = [
3352 walkopts = [
3340 ('I', 'include', [], _('include names matching the given patterns')),
3353 ('I', 'include', [], _('include names matching the given patterns')),
3341 ('X', 'exclude', [], _('exclude names matching the given patterns')),
3354 ('X', 'exclude', [], _('exclude names matching the given patterns')),
3342 ]
3355 ]
3343
3356
3344 commitopts = [
3357 commitopts = [
3345 ('m', 'message', '', _('use <text> as commit message')),
3358 ('m', 'message', '', _('use <text> as commit message')),
3346 ('l', 'logfile', '', _('read commit message from <file>')),
3359 ('l', 'logfile', '', _('read commit message from <file>')),
3347 ]
3360 ]
3348
3361
3349 commitopts2 = [
3362 commitopts2 = [
3350 ('d', 'date', '', _('record datecode as commit date')),
3363 ('d', 'date', '', _('record datecode as commit date')),
3351 ('u', 'user', '', _('record the specified user as committer')),
3364 ('u', 'user', '', _('record the specified user as committer')),
3352 ]
3365 ]
3353
3366
3354 templateopts = [
3367 templateopts = [
3355 ('', 'style', '', _('display using template map file')),
3368 ('', 'style', '', _('display using template map file')),
3356 ('', 'template', '', _('display with template')),
3369 ('', 'template', '', _('display with template')),
3357 ]
3370 ]
3358
3371
3359 logopts = [
3372 logopts = [
3360 ('p', 'patch', None, _('show patch')),
3373 ('p', 'patch', None, _('show patch')),
3361 ('g', 'git', None, _('use git extended diff format')),
3374 ('g', 'git', None, _('use git extended diff format')),
3362 ('l', 'limit', '', _('limit number of changes displayed')),
3375 ('l', 'limit', '', _('limit number of changes displayed')),
3363 ('M', 'no-merges', None, _('do not show merges')),
3376 ('M', 'no-merges', None, _('do not show merges')),
3364 ] + templateopts
3377 ] + templateopts
3365
3378
3366 diffopts = [
3379 diffopts = [
3367 ('a', 'text', None, _('treat all files as text')),
3380 ('a', 'text', None, _('treat all files as text')),
3368 ('g', 'git', None, _('use git extended diff format')),
3381 ('g', 'git', None, _('use git extended diff format')),
3369 ('', 'nodates', None, _('omit dates from diff headers'))
3382 ('', 'nodates', None, _('omit dates from diff headers'))
3370 ]
3383 ]
3371
3384
3372 diffopts2 = [
3385 diffopts2 = [
3373 ('p', 'show-function', None, _('show which function each change is in')),
3386 ('p', 'show-function', None, _('show which function each change is in')),
3374 ('', 'reverse', None, _('produce a diff that undoes the changes')),
3387 ('', 'reverse', None, _('produce a diff that undoes the changes')),
3375 ('w', 'ignore-all-space', None,
3388 ('w', 'ignore-all-space', None,
3376 _('ignore white space when comparing lines')),
3389 _('ignore white space when comparing lines')),
3377 ('b', 'ignore-space-change', None,
3390 ('b', 'ignore-space-change', None,
3378 _('ignore changes in the amount of white space')),
3391 _('ignore changes in the amount of white space')),
3379 ('B', 'ignore-blank-lines', None,
3392 ('B', 'ignore-blank-lines', None,
3380 _('ignore changes whose lines are all blank')),
3393 _('ignore changes whose lines are all blank')),
3381 ('U', 'unified', '', _('number of lines of context to show')),
3394 ('U', 'unified', '', _('number of lines of context to show')),
3382 ('', 'stat', None, _('output diffstat-style summary of changes')),
3395 ('', 'stat', None, _('output diffstat-style summary of changes')),
3383 ]
3396 ]
3384
3397
3385 similarityopts = [
3398 similarityopts = [
3386 ('s', 'similarity', '',
3399 ('s', 'similarity', '',
3387 _('guess renamed files by similarity (0<=s<=100)'))
3400 _('guess renamed files by similarity (0<=s<=100)'))
3388 ]
3401 ]
3389
3402
3390 table = {
3403 table = {
3391 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),
3404 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),
3392 "addremove":
3405 "addremove":
3393 (addremove, similarityopts + walkopts + dryrunopts,
3406 (addremove, similarityopts + walkopts + dryrunopts,
3394 _('[OPTION]... [FILE]...')),
3407 _('[OPTION]... [FILE]...')),
3395 "^annotate|blame":
3408 "^annotate|blame":
3396 (annotate,
3409 (annotate,
3397 [('r', 'rev', '', _('annotate the specified revision')),
3410 [('r', 'rev', '', _('annotate the specified revision')),
3398 ('', 'follow', None, _('follow copies and renames (DEPRECATED)')),
3411 ('', 'follow', None, _('follow copies and renames (DEPRECATED)')),
3399 ('', 'no-follow', None, _("don't follow copies and renames")),
3412 ('', 'no-follow', None, _("don't follow copies and renames")),
3400 ('a', 'text', None, _('treat all files as text')),
3413 ('a', 'text', None, _('treat all files as text')),
3401 ('u', 'user', None, _('list the author (long with -v)')),
3414 ('u', 'user', None, _('list the author (long with -v)')),
3402 ('f', 'file', None, _('list the filename')),
3415 ('f', 'file', None, _('list the filename')),
3403 ('d', 'date', None, _('list the date (short with -q)')),
3416 ('d', 'date', None, _('list the date (short with -q)')),
3404 ('n', 'number', None, _('list the revision number (default)')),
3417 ('n', 'number', None, _('list the revision number (default)')),
3405 ('c', 'changeset', None, _('list the changeset')),
3418 ('c', 'changeset', None, _('list the changeset')),
3406 ('l', 'line-number', None,
3419 ('l', 'line-number', None,
3407 _('show line number at the first appearance'))
3420 _('show line number at the first appearance'))
3408 ] + walkopts,
3421 ] + walkopts,
3409 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
3422 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
3410 "archive":
3423 "archive":
3411 (archive,
3424 (archive,
3412 [('', 'no-decode', None, _('do not pass files through decoders')),
3425 [('', 'no-decode', None, _('do not pass files through decoders')),
3413 ('p', 'prefix', '', _('directory prefix for files in archive')),
3426 ('p', 'prefix', '', _('directory prefix for files in archive')),
3414 ('r', 'rev', '', _('revision to distribute')),
3427 ('r', 'rev', '', _('revision to distribute')),
3415 ('t', 'type', '', _('type of distribution to create')),
3428 ('t', 'type', '', _('type of distribution to create')),
3416 ] + walkopts,
3429 ] + walkopts,
3417 _('[OPTION]... DEST')),
3430 _('[OPTION]... DEST')),
3418 "backout":
3431 "backout":
3419 (backout,
3432 (backout,
3420 [('', 'merge', None,
3433 [('', 'merge', None,
3421 _('merge with old dirstate parent after backout')),
3434 _('merge with old dirstate parent after backout')),
3422 ('', 'parent', '', _('parent to choose when backing out merge')),
3435 ('', 'parent', '', _('parent to choose when backing out merge')),
3423 ('r', 'rev', '', _('revision to backout')),
3436 ('r', 'rev', '', _('revision to backout')),
3424 ] + walkopts + commitopts + commitopts2,
3437 ] + walkopts + commitopts + commitopts2,
3425 _('[OPTION]... [-r] REV')),
3438 _('[OPTION]... [-r] REV')),
3426 "bisect":
3439 "bisect":
3427 (bisect,
3440 (bisect,
3428 [('r', 'reset', False, _('reset bisect state')),
3441 [('r', 'reset', False, _('reset bisect state')),
3429 ('g', 'good', False, _('mark changeset good')),
3442 ('g', 'good', False, _('mark changeset good')),
3430 ('b', 'bad', False, _('mark changeset bad')),
3443 ('b', 'bad', False, _('mark changeset bad')),
3431 ('s', 'skip', False, _('skip testing changeset')),
3444 ('s', 'skip', False, _('skip testing changeset')),
3432 ('c', 'command', '', _('use command to check changeset state')),
3445 ('c', 'command', '', _('use command to check changeset state')),
3433 ('U', 'noupdate', False, _('do not update to target'))],
3446 ('U', 'noupdate', False, _('do not update to target'))],
3434 _("[-gbsr] [-U] [-c CMD] [REV]")),
3447 _("[-gbsr] [-U] [-c CMD] [REV]")),
3435 "branch":
3448 "branch":
3436 (branch,
3449 (branch,
3437 [('f', 'force', None,
3450 [('f', 'force', None,
3438 _('set branch name even if it shadows an existing branch')),
3451 _('set branch name even if it shadows an existing branch')),
3439 ('C', 'clean', None, _('reset branch name to parent branch name'))],
3452 ('C', 'clean', None, _('reset branch name to parent branch name'))],
3440 _('[-fC] [NAME]')),
3453 _('[-fC] [NAME]')),
3441 "branches":
3454 "branches":
3442 (branches,
3455 (branches,
3443 [('a', 'active', False,
3456 [('a', 'active', False,
3444 _('show only branches that have unmerged heads')),
3457 _('show only branches that have unmerged heads')),
3445 ('c', 'closed', False,
3458 ('c', 'closed', False,
3446 _('show normal and closed branches'))],
3459 _('show normal and closed branches'))],
3447 _('[-ac]')),
3460 _('[-ac]')),
3448 "bundle":
3461 "bundle":
3449 (bundle,
3462 (bundle,
3450 [('f', 'force', None,
3463 [('f', 'force', None,
3451 _('run even when the destination is unrelated')),
3464 _('run even when the destination is unrelated')),
3452 ('r', 'rev', [],
3465 ('r', 'rev', [],
3453 _('a changeset intended to be added to the destination')),
3466 _('a changeset intended to be added to the destination')),
3454 ('b', 'branch', [],
3467 ('b', 'branch', [],
3455 _('a specific branch you would like to bundle')),
3468 _('a specific branch you would like to bundle')),
3456 ('', 'base', [],
3469 ('', 'base', [],
3457 _('a base changeset assumed to be available at the destination')),
3470 _('a base changeset assumed to be available at the destination')),
3458 ('a', 'all', None, _('bundle all changesets in the repository')),
3471 ('a', 'all', None, _('bundle all changesets in the repository')),
3459 ('t', 'type', 'bzip2', _('bundle compression type to use')),
3472 ('t', 'type', 'bzip2', _('bundle compression type to use')),
3460 ] + remoteopts,
3473 ] + remoteopts,
3461 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
3474 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
3462 "cat":
3475 "cat":
3463 (cat,
3476 (cat,
3464 [('o', 'output', '', _('print output to file with formatted name')),
3477 [('o', 'output', '', _('print output to file with formatted name')),
3465 ('r', 'rev', '', _('print the given revision')),
3478 ('r', 'rev', '', _('print the given revision')),
3466 ('', 'decode', None, _('apply any matching decode filter')),
3479 ('', 'decode', None, _('apply any matching decode filter')),
3467 ] + walkopts,
3480 ] + walkopts,
3468 _('[OPTION]... FILE...')),
3481 _('[OPTION]... FILE...')),
3469 "^clone":
3482 "^clone":
3470 (clone,
3483 (clone,
3471 [('U', 'noupdate', None,
3484 [('U', 'noupdate', None,
3472 _('the clone will include an empty working copy (only a repository)')),
3485 _('the clone will include an empty working copy (only a repository)')),
3473 ('u', 'updaterev', '',
3486 ('u', 'updaterev', '',
3474 _('revision, tag or branch to check out')),
3487 _('revision, tag or branch to check out')),
3475 ('r', 'rev', [],
3488 ('r', 'rev', [],
3476 _('include the specified changeset')),
3489 _('include the specified changeset')),
3477 ('b', 'branch', [],
3490 ('b', 'branch', [],
3478 _('clone only the specified branch')),
3491 _('clone only the specified branch')),
3479 ('', 'pull', None, _('use pull protocol to copy metadata')),
3492 ('', 'pull', None, _('use pull protocol to copy metadata')),
3480 ('', 'uncompressed', None,
3493 ('', 'uncompressed', None,
3481 _('use uncompressed transfer (fast over LAN)')),
3494 _('use uncompressed transfer (fast over LAN)')),
3482 ] + remoteopts,
3495 ] + remoteopts,
3483 _('[OPTION]... SOURCE [DEST]')),
3496 _('[OPTION]... SOURCE [DEST]')),
3484 "^commit|ci":
3497 "^commit|ci":
3485 (commit,
3498 (commit,
3486 [('A', 'addremove', None,
3499 [('A', 'addremove', None,
3487 _('mark new/missing files as added/removed before committing')),
3500 _('mark new/missing files as added/removed before committing')),
3488 ('', 'close-branch', None,
3501 ('', 'close-branch', None,
3489 _('mark a branch as closed, hiding it from the branch list')),
3502 _('mark a branch as closed, hiding it from the branch list')),
3490 ] + walkopts + commitopts + commitopts2,
3503 ] + walkopts + commitopts + commitopts2,
3491 _('[OPTION]... [FILE]...')),
3504 _('[OPTION]... [FILE]...')),
3492 "copy|cp":
3505 "copy|cp":
3493 (copy,
3506 (copy,
3494 [('A', 'after', None, _('record a copy that has already occurred')),
3507 [('A', 'after', None, _('record a copy that has already occurred')),
3495 ('f', 'force', None,
3508 ('f', 'force', None,
3496 _('forcibly copy over an existing managed file')),
3509 _('forcibly copy over an existing managed file')),
3497 ] + walkopts + dryrunopts,
3510 ] + walkopts + dryrunopts,
3498 _('[OPTION]... [SOURCE]... DEST')),
3511 _('[OPTION]... [SOURCE]... DEST')),
3499 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
3512 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
3500 "debugcheckstate": (debugcheckstate, [], ''),
3513 "debugcheckstate": (debugcheckstate, [], ''),
3501 "debugcommands": (debugcommands, [], _('[COMMAND]')),
3514 "debugcommands": (debugcommands, [], _('[COMMAND]')),
3502 "debugcomplete":
3515 "debugcomplete":
3503 (debugcomplete,
3516 (debugcomplete,
3504 [('o', 'options', None, _('show the command options'))],
3517 [('o', 'options', None, _('show the command options'))],
3505 _('[-o] CMD')),
3518 _('[-o] CMD')),
3506 "debugdate":
3519 "debugdate":
3507 (debugdate,
3520 (debugdate,
3508 [('e', 'extended', None, _('try extended date formats'))],
3521 [('e', 'extended', None, _('try extended date formats'))],
3509 _('[-e] DATE [RANGE]')),
3522 _('[-e] DATE [RANGE]')),
3510 "debugdata": (debugdata, [], _('FILE REV')),
3523 "debugdata": (debugdata, [], _('FILE REV')),
3511 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
3524 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
3512 "debugindex": (debugindex, [], _('FILE')),
3525 "debugindex": (debugindex, [], _('FILE')),
3513 "debugindexdot": (debugindexdot, [], _('FILE')),
3526 "debugindexdot": (debugindexdot, [], _('FILE')),
3514 "debuginstall": (debuginstall, [], ''),
3527 "debuginstall": (debuginstall, [], ''),
3515 "debugrebuildstate":
3528 "debugrebuildstate":
3516 (debugrebuildstate,
3529 (debugrebuildstate,
3517 [('r', 'rev', '', _('revision to rebuild to'))],
3530 [('r', 'rev', '', _('revision to rebuild to'))],
3518 _('[-r REV] [REV]')),
3531 _('[-r REV] [REV]')),
3519 "debugrename":
3532 "debugrename":
3520 (debugrename,
3533 (debugrename,
3521 [('r', 'rev', '', _('revision to debug'))],
3534 [('r', 'rev', '', _('revision to debug'))],
3522 _('[-r REV] FILE')),
3535 _('[-r REV] FILE')),
3523 "debugsetparents":
3536 "debugsetparents":
3524 (debugsetparents, [], _('REV1 [REV2]')),
3537 (debugsetparents, [], _('REV1 [REV2]')),
3525 "debugstate":
3538 "debugstate":
3526 (debugstate,
3539 (debugstate,
3527 [('', 'nodates', None, _('do not display the saved mtime'))],
3540 [('', 'nodates', None, _('do not display the saved mtime'))],
3528 _('[OPTION]...')),
3541 _('[OPTION]...')),
3529 "debugsub":
3542 "debugsub":
3530 (debugsub,
3543 (debugsub,
3531 [('r', 'rev', '', _('revision to check'))],
3544 [('r', 'rev', '', _('revision to check'))],
3532 _('[-r REV] [REV]')),
3545 _('[-r REV] [REV]')),
3533 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3546 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3534 "^diff":
3547 "^diff":
3535 (diff,
3548 (diff,
3536 [('r', 'rev', [], _('revision')),
3549 [('r', 'rev', [], _('revision')),
3537 ('c', 'change', '', _('change made by revision'))
3550 ('c', 'change', '', _('change made by revision'))
3538 ] + diffopts + diffopts2 + walkopts,
3551 ] + diffopts + diffopts2 + walkopts,
3539 _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
3552 _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
3540 "^export":
3553 "^export":
3541 (export,
3554 (export,
3542 [('o', 'output', '', _('print output to file with formatted name')),
3555 [('o', 'output', '', _('print output to file with formatted name')),
3543 ('', 'switch-parent', None, _('diff against the second parent')),
3556 ('', 'switch-parent', None, _('diff against the second parent')),
3544 ('r', 'rev', [], _('revisions to export')),
3557 ('r', 'rev', [], _('revisions to export')),
3545 ] + diffopts,
3558 ] + diffopts,
3546 _('[OPTION]... [-o OUTFILESPEC] REV...')),
3559 _('[OPTION]... [-o OUTFILESPEC] REV...')),
3547 "^forget":
3560 "^forget":
3548 (forget,
3561 (forget,
3549 [] + walkopts,
3562 [] + walkopts,
3550 _('[OPTION]... FILE...')),
3563 _('[OPTION]... FILE...')),
3551 "grep":
3564 "grep":
3552 (grep,
3565 (grep,
3553 [('0', 'print0', None, _('end fields with NUL')),
3566 [('0', 'print0', None, _('end fields with NUL')),
3554 ('', 'all', None, _('print all revisions that match')),
3567 ('', 'all', None, _('print all revisions that match')),
3555 ('f', 'follow', None,
3568 ('f', 'follow', None,
3556 _('follow changeset history,'
3569 _('follow changeset history,'
3557 ' or file history across copies and renames')),
3570 ' or file history across copies and renames')),
3558 ('i', 'ignore-case', None, _('ignore case when matching')),
3571 ('i', 'ignore-case', None, _('ignore case when matching')),
3559 ('l', 'files-with-matches', None,
3572 ('l', 'files-with-matches', None,
3560 _('print only filenames and revisions that match')),
3573 _('print only filenames and revisions that match')),
3561 ('n', 'line-number', None, _('print matching line numbers')),
3574 ('n', 'line-number', None, _('print matching line numbers')),
3562 ('r', 'rev', [], _('search in given revision range')),
3575 ('r', 'rev', [], _('search in given revision range')),
3563 ('u', 'user', None, _('list the author (long with -v)')),
3576 ('u', 'user', None, _('list the author (long with -v)')),
3564 ('d', 'date', None, _('list the date (short with -q)')),
3577 ('d', 'date', None, _('list the date (short with -q)')),
3565 ] + walkopts,
3578 ] + walkopts,
3566 _('[OPTION]... PATTERN [FILE]...')),
3579 _('[OPTION]... PATTERN [FILE]...')),
3567 "heads":
3580 "heads":
3568 (heads,
3581 (heads,
3569 [('r', 'rev', '', _('show only heads which are descendants of REV')),
3582 [('r', 'rev', '', _('show only heads which are descendants of REV')),
3570 ('t', 'topo', False, _('show topological heads only')),
3583 ('t', 'topo', False, _('show topological heads only')),
3571 ('a', 'active', False,
3584 ('a', 'active', False,
3572 _('show active branchheads only [DEPRECATED]')),
3585 _('show active branchheads only [DEPRECATED]')),
3573 ('c', 'closed', False,
3586 ('c', 'closed', False,
3574 _('show normal and closed branch heads')),
3587 _('show normal and closed branch heads')),
3575 ] + templateopts,
3588 ] + templateopts,
3576 _('[-ac] [-r STARTREV] [REV]...')),
3589 _('[-ac] [-r STARTREV] [REV]...')),
3577 "help": (help_, [], _('[TOPIC]')),
3590 "help": (help_, [], _('[TOPIC]')),
3578 "identify|id":
3591 "identify|id":
3579 (identify,
3592 (identify,
3580 [('r', 'rev', '', _('identify the specified revision')),
3593 [('r', 'rev', '', _('identify the specified revision')),
3581 ('n', 'num', None, _('show local revision number')),
3594 ('n', 'num', None, _('show local revision number')),
3582 ('i', 'id', None, _('show global revision id')),
3595 ('i', 'id', None, _('show global revision id')),
3583 ('b', 'branch', None, _('show branch')),
3596 ('b', 'branch', None, _('show branch')),
3584 ('t', 'tags', None, _('show tags'))],
3597 ('t', 'tags', None, _('show tags'))],
3585 _('[-nibt] [-r REV] [SOURCE]')),
3598 _('[-nibt] [-r REV] [SOURCE]')),
3586 "import|patch":
3599 "import|patch":
3587 (import_,
3600 (import_,
3588 [('p', 'strip', 1,
3601 [('p', 'strip', 1,
3589 _('directory strip option for patch. This has the same '
3602 _('directory strip option for patch. This has the same '
3590 'meaning as the corresponding patch option')),
3603 'meaning as the corresponding patch option')),
3591 ('b', 'base', '', _('base path')),
3604 ('b', 'base', '', _('base path')),
3592 ('f', 'force', None,
3605 ('f', 'force', None,
3593 _('skip check for outstanding uncommitted changes')),
3606 _('skip check for outstanding uncommitted changes')),
3594 ('', 'no-commit', None,
3607 ('', 'no-commit', None,
3595 _("don't commit, just update the working directory")),
3608 _("don't commit, just update the working directory")),
3596 ('', 'exact', None,
3609 ('', 'exact', None,
3597 _('apply patch to the nodes from which it was generated')),
3610 _('apply patch to the nodes from which it was generated')),
3598 ('', 'import-branch', None,
3611 ('', 'import-branch', None,
3599 _('use any branch information in patch (implied by --exact)'))] +
3612 _('use any branch information in patch (implied by --exact)'))] +
3600 commitopts + commitopts2 + similarityopts,
3613 commitopts + commitopts2 + similarityopts,
3601 _('[OPTION]... PATCH...')),
3614 _('[OPTION]... PATCH...')),
3602 "incoming|in":
3615 "incoming|in":
3603 (incoming,
3616 (incoming,
3604 [('f', 'force', None,
3617 [('f', 'force', None,
3605 _('run even if remote repository is unrelated')),
3618 _('run even if remote repository is unrelated')),
3606 ('n', 'newest-first', None, _('show newest record first')),
3619 ('n', 'newest-first', None, _('show newest record first')),
3607 ('', 'bundle', '', _('file to store the bundles into')),
3620 ('', 'bundle', '', _('file to store the bundles into')),
3608 ('r', 'rev', [],
3621 ('r', 'rev', [],
3609 _('a remote changeset intended to be added')),
3622 _('a remote changeset intended to be added')),
3610 ('b', 'branch', [],
3623 ('b', 'branch', [],
3611 _('a specific branch you would like to pull')),
3624 _('a specific branch you would like to pull')),
3612 ] + logopts + remoteopts,
3625 ] + logopts + remoteopts,
3613 _('[-p] [-n] [-M] [-f] [-r REV]...'
3626 _('[-p] [-n] [-M] [-f] [-r REV]...'
3614 ' [--bundle FILENAME] [SOURCE]')),
3627 ' [--bundle FILENAME] [SOURCE]')),
3615 "^init":
3628 "^init":
3616 (init,
3629 (init,
3617 remoteopts,
3630 remoteopts,
3618 _('[-e CMD] [--remotecmd CMD] [DEST]')),
3631 _('[-e CMD] [--remotecmd CMD] [DEST]')),
3619 "locate":
3632 "locate":
3620 (locate,
3633 (locate,
3621 [('r', 'rev', '', _('search the repository as it is in REV')),
3634 [('r', 'rev', '', _('search the repository as it is in REV')),
3622 ('0', 'print0', None,
3635 ('0', 'print0', None,
3623 _('end filenames with NUL, for use with xargs')),
3636 _('end filenames with NUL, for use with xargs')),
3624 ('f', 'fullpath', None,
3637 ('f', 'fullpath', None,
3625 _('print complete paths from the filesystem root')),
3638 _('print complete paths from the filesystem root')),
3626 ] + walkopts,
3639 ] + walkopts,
3627 _('[OPTION]... [PATTERN]...')),
3640 _('[OPTION]... [PATTERN]...')),
3628 "^log|history":
3641 "^log|history":
3629 (log,
3642 (log,
3630 [('f', 'follow', None,
3643 [('f', 'follow', None,
3631 _('follow changeset history,'
3644 _('follow changeset history,'
3632 ' or file history across copies and renames')),
3645 ' or file history across copies and renames')),
3633 ('', 'follow-first', None,
3646 ('', 'follow-first', None,
3634 _('only follow the first parent of merge changesets')),
3647 _('only follow the first parent of merge changesets')),
3635 ('d', 'date', '', _('show revisions matching date spec')),
3648 ('d', 'date', '', _('show revisions matching date spec')),
3636 ('C', 'copies', None, _('show copied files')),
3649 ('C', 'copies', None, _('show copied files')),
3637 ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
3650 ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
3638 ('r', 'rev', [], _('show the specified revision or range')),
3651 ('r', 'rev', [], _('show the specified revision or range')),
3639 ('', 'removed', None, _('include revisions where files were removed')),
3652 ('', 'removed', None, _('include revisions where files were removed')),
3640 ('m', 'only-merges', None, _('show only merges')),
3653 ('m', 'only-merges', None, _('show only merges')),
3641 ('u', 'user', [], _('revisions committed by user')),
3654 ('u', 'user', [], _('revisions committed by user')),
3642 ('b', 'only-branch', [],
3655 ('b', 'only-branch', [],
3643 _('show only changesets within the given named branch')),
3656 _('show only changesets within the given named branch')),
3644 ('P', 'prune', [],
3657 ('P', 'prune', [],
3645 _('do not display revision or any of its ancestors')),
3658 _('do not display revision or any of its ancestors')),
3646 ] + logopts + walkopts,
3659 ] + logopts + walkopts,
3647 _('[OPTION]... [FILE]')),
3660 _('[OPTION]... [FILE]')),
3648 "manifest":
3661 "manifest":
3649 (manifest,
3662 (manifest,
3650 [('r', 'rev', '', _('revision to display'))],
3663 [('r', 'rev', '', _('revision to display'))],
3651 _('[-r REV]')),
3664 _('[-r REV]')),
3652 "^merge":
3665 "^merge":
3653 (merge,
3666 (merge,
3654 [('f', 'force', None, _('force a merge with outstanding changes')),
3667 [('f', 'force', None, _('force a merge with outstanding changes')),
3655 ('r', 'rev', '', _('revision to merge')),
3668 ('r', 'rev', '', _('revision to merge')),
3656 ('P', 'preview', None,
3669 ('P', 'preview', None,
3657 _('review revisions to merge (no merge is performed)'))],
3670 _('review revisions to merge (no merge is performed)'))],
3658 _('[-P] [-f] [[-r] REV]')),
3671 _('[-P] [-f] [[-r] REV]')),
3659 "outgoing|out":
3672 "outgoing|out":
3660 (outgoing,
3673 (outgoing,
3661 [('f', 'force', None,
3674 [('f', 'force', None,
3662 _('run even when the destination is unrelated')),
3675 _('run even when the destination is unrelated')),
3663 ('r', 'rev', [],
3676 ('r', 'rev', [],
3664 _('a changeset intended to be included in the destination')),
3677 _('a changeset intended to be included in the destination')),
3665 ('n', 'newest-first', None, _('show newest record first')),
3678 ('n', 'newest-first', None, _('show newest record first')),
3666 ('b', 'branch', [],
3679 ('b', 'branch', [],
3667 _('a specific branch you would like to push')),
3680 _('a specific branch you would like to push')),
3668 ] + logopts + remoteopts,
3681 ] + logopts + remoteopts,
3669 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
3682 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
3670 "parents":
3683 "parents":
3671 (parents,
3684 (parents,
3672 [('r', 'rev', '', _('show parents of the specified revision')),
3685 [('r', 'rev', '', _('show parents of the specified revision')),
3673 ] + templateopts,
3686 ] + templateopts,
3674 _('[-r REV] [FILE]')),
3687 _('[-r REV] [FILE]')),
3675 "paths": (paths, [], _('[NAME]')),
3688 "paths": (paths, [], _('[NAME]')),
3676 "^pull":
3689 "^pull":
3677 (pull,
3690 (pull,
3678 [('u', 'update', None,
3691 [('u', 'update', None,
3679 _('update to new branch head if changesets were pulled')),
3692 _('update to new branch head if changesets were pulled')),
3680 ('f', 'force', None,
3693 ('f', 'force', None,
3681 _('run even when remote repository is unrelated')),
3694 _('run even when remote repository is unrelated')),
3682 ('r', 'rev', [],
3695 ('r', 'rev', [],
3683 _('a remote changeset intended to be added')),
3696 _('a remote changeset intended to be added')),
3684 ('b', 'branch', [],
3697 ('b', 'branch', [],
3685 _('a specific branch you would like to pull')),
3698 _('a specific branch you would like to pull')),
3686 ] + remoteopts,
3699 ] + remoteopts,
3687 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
3700 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
3688 "^push":
3701 "^push":
3689 (push,
3702 (push,
3690 [('f', 'force', None, _('force push')),
3703 [('f', 'force', None, _('force push')),
3691 ('r', 'rev', [],
3704 ('r', 'rev', [],
3692 _('a changeset intended to be included in the destination')),
3705 _('a changeset intended to be included in the destination')),
3693 ('b', 'branch', [],
3706 ('b', 'branch', [],
3694 _('a specific branch you would like to push')),
3707 _('a specific branch you would like to push')),
3695 ] + remoteopts,
3708 ] + remoteopts,
3696 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
3709 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
3697 "recover": (recover, []),
3710 "recover": (recover, []),
3698 "^remove|rm":
3711 "^remove|rm":
3699 (remove,
3712 (remove,
3700 [('A', 'after', None, _('record delete for missing files')),
3713 [('A', 'after', None, _('record delete for missing files')),
3701 ('f', 'force', None,
3714 ('f', 'force', None,
3702 _('remove (and delete) file even if added or modified')),
3715 _('remove (and delete) file even if added or modified')),
3703 ] + walkopts,
3716 ] + walkopts,
3704 _('[OPTION]... FILE...')),
3717 _('[OPTION]... FILE...')),
3705 "rename|mv":
3718 "rename|mv":
3706 (rename,
3719 (rename,
3707 [('A', 'after', None, _('record a rename that has already occurred')),
3720 [('A', 'after', None, _('record a rename that has already occurred')),
3708 ('f', 'force', None,
3721 ('f', 'force', None,
3709 _('forcibly copy over an existing managed file')),
3722 _('forcibly copy over an existing managed file')),
3710 ] + walkopts + dryrunopts,
3723 ] + walkopts + dryrunopts,
3711 _('[OPTION]... SOURCE... DEST')),
3724 _('[OPTION]... SOURCE... DEST')),
3712 "resolve":
3725 "resolve":
3713 (resolve,
3726 (resolve,
3714 [('a', 'all', None, _('select all unresolved files')),
3727 [('a', 'all', None, _('select all unresolved files')),
3715 ('l', 'list', None, _('list state of files needing merge')),
3728 ('l', 'list', None, _('list state of files needing merge')),
3716 ('m', 'mark', None, _('mark files as resolved')),
3729 ('m', 'mark', None, _('mark files as resolved')),
3717 ('u', 'unmark', None, _('unmark files as resolved')),
3730 ('u', 'unmark', None, _('unmark files as resolved')),
3718 ('n', 'no-status', None, _('hide status prefix'))]
3731 ('n', 'no-status', None, _('hide status prefix'))]
3719 + walkopts,
3732 + walkopts,
3720 _('[OPTION]... [FILE]...')),
3733 _('[OPTION]... [FILE]...')),
3721 "revert":
3734 "revert":
3722 (revert,
3735 (revert,
3723 [('a', 'all', None, _('revert all changes when no arguments given')),
3736 [('a', 'all', None, _('revert all changes when no arguments given')),
3724 ('d', 'date', '', _('tipmost revision matching date')),
3737 ('d', 'date', '', _('tipmost revision matching date')),
3725 ('r', 'rev', '', _('revert to the specified revision')),
3738 ('r', 'rev', '', _('revert to the specified revision')),
3726 ('', 'no-backup', None, _('do not save backup copies of files')),
3739 ('', 'no-backup', None, _('do not save backup copies of files')),
3727 ] + walkopts + dryrunopts,
3740 ] + walkopts + dryrunopts,
3728 _('[OPTION]... [-r REV] [NAME]...')),
3741 _('[OPTION]... [-r REV] [NAME]...')),
3729 "rollback": (rollback, []),
3742 "rollback": (rollback, []),
3730 "root": (root, []),
3743 "root": (root, []),
3731 "^serve":
3744 "^serve":
3732 (serve,
3745 (serve,
3733 [('A', 'accesslog', '', _('name of access log file to write to')),
3746 [('A', 'accesslog', '', _('name of access log file to write to')),
3734 ('d', 'daemon', None, _('run server in background')),
3747 ('d', 'daemon', None, _('run server in background')),
3735 ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
3748 ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
3736 ('E', 'errorlog', '', _('name of error log file to write to')),
3749 ('E', 'errorlog', '', _('name of error log file to write to')),
3737 ('p', 'port', 0, _('port to listen on (default: 8000)')),
3750 ('p', 'port', 0, _('port to listen on (default: 8000)')),
3738 ('a', 'address', '',
3751 ('a', 'address', '',
3739 _('address to listen on (default: all interfaces)')),
3752 _('address to listen on (default: all interfaces)')),
3740 ('', 'prefix', '',
3753 ('', 'prefix', '',
3741 _('prefix path to serve from (default: server root)')),
3754 _('prefix path to serve from (default: server root)')),
3742 ('n', 'name', '',
3755 ('n', 'name', '',
3743 _('name to show in web pages (default: working directory)')),
3756 _('name to show in web pages (default: working directory)')),
3744 ('', 'webdir-conf', '', _('name of the webdir config file'
3757 ('', 'webdir-conf', '', _('name of the webdir config file'
3745 ' (serve more than one repository)')),
3758 ' (serve more than one repository)')),
3746 ('', 'pid-file', '', _('name of file to write process ID to')),
3759 ('', 'pid-file', '', _('name of file to write process ID to')),
3747 ('', 'stdio', None, _('for remote clients')),
3760 ('', 'stdio', None, _('for remote clients')),
3748 ('t', 'templates', '', _('web templates to use')),
3761 ('t', 'templates', '', _('web templates to use')),
3749 ('', 'style', '', _('template style to use')),
3762 ('', 'style', '', _('template style to use')),
3750 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
3763 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
3751 ('', 'certificate', '', _('SSL certificate file'))],
3764 ('', 'certificate', '', _('SSL certificate file'))],
3752 _('[OPTION]...')),
3765 _('[OPTION]...')),
3753 "showconfig|debugconfig":
3766 "showconfig|debugconfig":
3754 (showconfig,
3767 (showconfig,
3755 [('u', 'untrusted', None, _('show untrusted configuration options'))],
3768 [('u', 'untrusted', None, _('show untrusted configuration options'))],
3756 _('[-u] [NAME]...')),
3769 _('[-u] [NAME]...')),
3757 "^summary|sum":
3770 "^summary|sum":
3758 (summary,
3771 (summary,
3759 [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
3772 [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
3760 "^status|st":
3773 "^status|st":
3761 (status,
3774 (status,
3762 [('A', 'all', None, _('show status of all files')),
3775 [('A', 'all', None, _('show status of all files')),
3763 ('m', 'modified', None, _('show only modified files')),
3776 ('m', 'modified', None, _('show only modified files')),
3764 ('a', 'added', None, _('show only added files')),
3777 ('a', 'added', None, _('show only added files')),
3765 ('r', 'removed', None, _('show only removed files')),
3778 ('r', 'removed', None, _('show only removed files')),
3766 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
3779 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
3767 ('c', 'clean', None, _('show only files without changes')),
3780 ('c', 'clean', None, _('show only files without changes')),
3768 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
3781 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
3769 ('i', 'ignored', None, _('show only ignored files')),
3782 ('i', 'ignored', None, _('show only ignored files')),
3770 ('n', 'no-status', None, _('hide status prefix')),
3783 ('n', 'no-status', None, _('hide status prefix')),
3771 ('C', 'copies', None, _('show source of copied files')),
3784 ('C', 'copies', None, _('show source of copied files')),
3772 ('0', 'print0', None,
3785 ('0', 'print0', None,
3773 _('end filenames with NUL, for use with xargs')),
3786 _('end filenames with NUL, for use with xargs')),
3774 ('', 'rev', [], _('show difference from revision')),
3787 ('', 'rev', [], _('show difference from revision')),
3775 ('', 'change', '', _('list the changed files of a revision')),
3788 ('', 'change', '', _('list the changed files of a revision')),
3776 ] + walkopts,
3789 ] + walkopts,
3777 _('[OPTION]... [FILE]...')),
3790 _('[OPTION]... [FILE]...')),
3778 "tag":
3791 "tag":
3779 (tag,
3792 (tag,
3780 [('f', 'force', None, _('replace existing tag')),
3793 [('f', 'force', None, _('replace existing tag')),
3781 ('l', 'local', None, _('make the tag local')),
3794 ('l', 'local', None, _('make the tag local')),
3782 ('r', 'rev', '', _('revision to tag')),
3795 ('r', 'rev', '', _('revision to tag')),
3783 ('', 'remove', None, _('remove a tag')),
3796 ('', 'remove', None, _('remove a tag')),
3784 # -l/--local is already there, commitopts cannot be used
3797 # -l/--local is already there, commitopts cannot be used
3785 ('m', 'message', '', _('use <text> as commit message')),
3798 ('m', 'message', '', _('use <text> as commit message')),
3786 ] + commitopts2,
3799 ] + commitopts2,
3787 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
3800 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
3788 "tags": (tags, [], ''),
3801 "tags": (tags, [], ''),
3789 "tip":
3802 "tip":
3790 (tip,
3803 (tip,
3791 [('p', 'patch', None, _('show patch')),
3804 [('p', 'patch', None, _('show patch')),
3792 ('g', 'git', None, _('use git extended diff format')),
3805 ('g', 'git', None, _('use git extended diff format')),
3793 ] + templateopts,
3806 ] + templateopts,
3794 _('[-p] [-g]')),
3807 _('[-p] [-g]')),
3795 "unbundle":
3808 "unbundle":
3796 (unbundle,
3809 (unbundle,
3797 [('u', 'update', None,
3810 [('u', 'update', None,
3798 _('update to new branch head if changesets were unbundled'))],
3811 _('update to new branch head if changesets were unbundled'))],
3799 _('[-u] FILE...')),
3812 _('[-u] FILE...')),
3800 "^update|up|checkout|co":
3813 "^update|up|checkout|co":
3801 (update,
3814 (update,
3802 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
3815 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
3803 ('c', 'check', None, _('check for uncommitted changes')),
3816 ('c', 'check', None, _('check for uncommitted changes')),
3804 ('d', 'date', '', _('tipmost revision matching date')),
3817 ('d', 'date', '', _('tipmost revision matching date')),
3805 ('r', 'rev', '', _('revision'))],
3818 ('r', 'rev', '', _('revision'))],
3806 _('[-c] [-C] [-d DATE] [[-r] REV]')),
3819 _('[-c] [-C] [-d DATE] [[-r] REV]')),
3807 "verify": (verify, []),
3820 "verify": (verify, []),
3808 "version": (version_, []),
3821 "version": (version_, []),
3809 }
3822 }
3810
3823
3811 norepo = ("clone init version help debugcommands debugcomplete debugdata"
3824 norepo = ("clone init version help debugcommands debugcomplete debugdata"
3812 " debugindex debugindexdot debugdate debuginstall debugfsinfo")
3825 " debugindex debugindexdot debugdate debuginstall debugfsinfo")
3813 optionalrepo = ("identify paths serve showconfig debugancestor")
3826 optionalrepo = ("identify paths serve showconfig debugancestor")
@@ -1,60 +1,63 b''
1 #!/bin/sh
1 #!/bin/sh
2
2
3 hg
3 hg
4 hg -q
4 hg -q
5 hg help
5 hg help
6 hg -q help
6 hg -q help
7
7
8 echo %% test short command list with verbose option
8 echo %% test short command list with verbose option
9 hg -v help shortlist | sed 's/[(]version [^)]*[)]/(version xxx)/'
9 hg -v help shortlist | sed 's/[(]version [^)]*[)]/(version xxx)/'
10
10
11 hg add -h
11 hg add -h
12
12
13 echo %% verbose help for add
14 hg add -hv
15
13 echo %% test help option with version option
16 echo %% test help option with version option
14 hg add -h --version | sed 's/[(]version [^)]*[)]/(version xxx)/'
17 hg add -h --version | sed 's/[(]version [^)]*[)]/(version xxx)/'
15
18
16 hg add --skjdfks
19 hg add --skjdfks
17
20
18 echo %% test ambiguous command help
21 echo %% test ambiguous command help
19 hg help ad
22 hg help ad
20
23
21 echo %% test command without options
24 echo %% test command without options
22 hg help verify
25 hg help verify
23
26
24 hg help diff
27 hg help diff
25 hg help status
28 hg help status
26 hg -q help status
29 hg -q help status
27 hg help foo
30 hg help foo
28 hg skjdfks
31 hg skjdfks
29
32
30 cat > helpext.py <<EOF
33 cat > helpext.py <<EOF
31 import os
34 import os
32 from mercurial import commands
35 from mercurial import commands
33
36
34 def nohelp(ui, *args, **kwargs):
37 def nohelp(ui, *args, **kwargs):
35 pass
38 pass
36
39
37 cmdtable = {
40 cmdtable = {
38 "nohelp": (nohelp, [], "hg nohelp"),
41 "nohelp": (nohelp, [], "hg nohelp"),
39 }
42 }
40
43
41 commands.norepo += ' nohelp'
44 commands.norepo += ' nohelp'
42 EOF
45 EOF
43 abspath=`pwd`/helpext.py
46 abspath=`pwd`/helpext.py
44
47
45 echo '[extensions]' >> $HGRCPATH
48 echo '[extensions]' >> $HGRCPATH
46 echo "helpext = $abspath" >> $HGRCPATH
49 echo "helpext = $abspath" >> $HGRCPATH
47
50
48 echo %% test command with no help text
51 echo %% test command with no help text
49 hg help nohelp
52 hg help nohelp
50
53
51 echo %% test that default list of commands omits extension commands
54 echo %% test that default list of commands omits extension commands
52 hg help
55 hg help
53
56
54 echo %% test list of commands with command with no help text
57 echo %% test list of commands with command with no help text
55 hg help helpext
58 hg help helpext
56
59
57 echo %% test a help topic
60 echo %% test a help topic
58 hg help revs
61 hg help revs
59
62
60 exit 0
63 exit 0
@@ -1,582 +1,633 b''
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 export the repository via HTTP
18 serve export the repository via HTTP
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
21 update update working directory
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 export the repository via HTTP
37 serve export the repository via HTTP
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
40 update update working directory
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 retry file merges from a merge or update
80 resolve retry file merges from a merge or update
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
82 rollback roll back the last transaction
83 root print the root (top) of the current working directory
83 root print the root (top) of the current working directory
84 serve export the repository via HTTP
84 serve export the repository via HTTP
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
92 update update working directory
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 diffs Diff Formats
104 diffs Diff Formats
105 templating Template Usage
105 templating Template Usage
106 urls URL Paths
106 urls URL Paths
107 extensions Using additional features
107 extensions Using additional features
108
108
109 use "hg -v help" to show aliases and global options
109 use "hg -v help" to show aliases and global options
110 add add the specified files on the next commit
110 add add the specified files on the next commit
111 addremove add all new files, delete all missing files
111 addremove add all new files, delete all missing files
112 annotate show changeset information by line for each file
112 annotate show changeset information by line for each file
113 archive create an unversioned archive of a repository revision
113 archive create an unversioned archive of a repository revision
114 backout reverse effect of earlier changeset
114 backout reverse effect of earlier changeset
115 bisect subdivision search of changesets
115 bisect subdivision search of changesets
116 branch set or show the current branch name
116 branch set or show the current branch name
117 branches list repository named branches
117 branches list repository named branches
118 bundle create a changegroup file
118 bundle create a changegroup file
119 cat output the current or given revision of files
119 cat output the current or given revision of files
120 clone make a copy of an existing repository
120 clone make a copy of an existing repository
121 commit commit the specified files or all outstanding changes
121 commit commit the specified files or all outstanding changes
122 copy mark files as copied for the next commit
122 copy mark files as copied for the next commit
123 diff diff repository (or selected files)
123 diff diff repository (or selected files)
124 export dump the header and diffs for one or more changesets
124 export dump the header and diffs for one or more changesets
125 forget forget the specified files on the next commit
125 forget forget the specified files on the next commit
126 grep search for a pattern in specified files and revisions
126 grep search for a pattern in specified files and revisions
127 heads show current repository heads or show branch heads
127 heads show current repository heads or show branch heads
128 help show help for a given topic or a help overview
128 help show help for a given topic or a help overview
129 identify identify the working copy or specified revision
129 identify identify the working copy or specified revision
130 import import an ordered set of patches
130 import import an ordered set of patches
131 incoming show new changesets found in source
131 incoming show new changesets found in source
132 init create a new repository in the given directory
132 init create a new repository in the given directory
133 locate locate files matching specific patterns
133 locate locate files matching specific patterns
134 log show revision history of entire repository or files
134 log show revision history of entire repository or files
135 manifest output the current or given revision of the project manifest
135 manifest output the current or given revision of the project manifest
136 merge merge working directory with another revision
136 merge merge working directory with another revision
137 outgoing show changesets not found in the destination
137 outgoing show changesets not found in the destination
138 parents show the parents of the working directory or revision
138 parents show the parents of the working directory or revision
139 paths show aliases for remote repositories
139 paths show aliases for remote repositories
140 pull pull changes from the specified source
140 pull pull changes from the specified source
141 push push changes to the specified destination
141 push push changes to the specified destination
142 recover roll back an interrupted transaction
142 recover roll back an interrupted transaction
143 remove remove the specified files on the next commit
143 remove remove the specified files on the next commit
144 rename rename files; equivalent of copy + remove
144 rename rename files; equivalent of copy + remove
145 resolve retry file merges from a merge or update
145 resolve retry file merges from a merge or update
146 revert restore individual files or directories to an earlier state
146 revert restore individual files or directories to an earlier state
147 rollback roll back the last transaction
147 rollback roll back the last transaction
148 root print the root (top) of the current working directory
148 root print the root (top) of the current working directory
149 serve export the repository via HTTP
149 serve export the repository via HTTP
150 showconfig show combined config settings from all hgrc files
150 showconfig show combined config settings from all hgrc files
151 status show changed files in the working directory
151 status show changed files in the working directory
152 summary summarize working directory state
152 summary summarize working directory state
153 tag add one or more tags for the current or given revision
153 tag add one or more tags for the current or given revision
154 tags list repository tags
154 tags list repository tags
155 tip show the tip revision
155 tip show the tip revision
156 unbundle apply one or more changegroup files
156 unbundle apply one or more changegroup files
157 update update working directory
157 update update working directory
158 verify verify the integrity of the repository
158 verify verify the integrity of the repository
159 version output version and copyright information
159 version output version and copyright information
160
160
161 additional help topics:
161 additional help topics:
162
162
163 config Configuration Files
163 config Configuration Files
164 dates Date Formats
164 dates Date Formats
165 patterns File Name Patterns
165 patterns File Name Patterns
166 environment Environment Variables
166 environment Environment Variables
167 revisions Specifying Single Revisions
167 revisions Specifying Single Revisions
168 multirevs Specifying Multiple Revisions
168 multirevs Specifying Multiple Revisions
169 diffs Diff Formats
169 diffs Diff Formats
170 templating Template Usage
170 templating Template Usage
171 urls URL Paths
171 urls URL Paths
172 extensions Using additional features
172 extensions Using additional features
173 %% test short command list with verbose option
173 %% test short command list with verbose option
174 Mercurial Distributed SCM (version xxx)
174 Mercurial Distributed SCM (version xxx)
175
175
176 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
176 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
177 This is free software; see the source for copying conditions. There is NO
177 This is free software; see the source for copying conditions. There is NO
178 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
178 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
179
179
180 basic commands:
180 basic commands:
181
181
182 add:
182 add:
183 add the specified files on the next commit
183 add the specified files on the next commit
184 annotate, blame:
184 annotate, blame:
185 show changeset information by line for each file
185 show changeset information by line for each file
186 clone:
186 clone:
187 make a copy of an existing repository
187 make a copy of an existing repository
188 commit, ci:
188 commit, ci:
189 commit the specified files or all outstanding changes
189 commit the specified files or all outstanding changes
190 diff:
190 diff:
191 diff repository (or selected files)
191 diff repository (or selected files)
192 export:
192 export:
193 dump the header and diffs for one or more changesets
193 dump the header and diffs for one or more changesets
194 forget:
194 forget:
195 forget the specified files on the next commit
195 forget the specified files on the next commit
196 init:
196 init:
197 create a new repository in the given directory
197 create a new repository in the given directory
198 log, history:
198 log, history:
199 show revision history of entire repository or files
199 show revision history of entire repository or files
200 merge:
200 merge:
201 merge working directory with another revision
201 merge working directory with another revision
202 pull:
202 pull:
203 pull changes from the specified source
203 pull changes from the specified source
204 push:
204 push:
205 push changes to the specified destination
205 push changes to the specified destination
206 remove, rm:
206 remove, rm:
207 remove the specified files on the next commit
207 remove the specified files on the next commit
208 serve:
208 serve:
209 export the repository via HTTP
209 export the repository via HTTP
210 status, st:
210 status, st:
211 show changed files in the working directory
211 show changed files in the working directory
212 summary, sum:
212 summary, sum:
213 summarize working directory state
213 summarize working directory state
214 update, up, checkout, co:
214 update, up, checkout, co:
215 update working directory
215 update working directory
216
216
217 global options:
217 global options:
218 -R --repository repository root directory or name of overlay bundle file
218 -R --repository repository root directory or name of overlay bundle file
219 --cwd change working directory
219 --cwd change working directory
220 -y --noninteractive do not prompt, assume 'yes' for any required answers
220 -y --noninteractive do not prompt, assume 'yes' for any required answers
221 -q --quiet suppress output
221 -q --quiet suppress output
222 -v --verbose enable additional output
222 -v --verbose enable additional output
223 --config set/override config option
223 --config set/override config option
224 --debug enable debugging output
224 --debug enable debugging output
225 --debugger start debugger
225 --debugger start debugger
226 --encoding set the charset encoding (default: ascii)
226 --encoding set the charset encoding (default: ascii)
227 --encodingmode set the charset encoding mode (default: strict)
227 --encodingmode set the charset encoding mode (default: strict)
228 --traceback always print a traceback on exception
228 --traceback always print a traceback on exception
229 --time time how long the command takes
229 --time time how long the command takes
230 --profile print command execution profile
230 --profile print command execution profile
231 --version output version information and exit
231 --version output version information and exit
232 -h --help display help and exit
232 -h --help display help and exit
233
233
234 use "hg help" for the full list of commands
234 use "hg help" for the full list of commands
235 hg add [OPTION]... [FILE]...
235 hg add [OPTION]... [FILE]...
236
236
237 add the specified files on the next commit
237 add the specified files on the next commit
238
238
239 Schedule files to be version controlled and added to the repository.
239 Schedule files to be version controlled and added to the repository.
240
240
241 The files will be added to the repository at the next commit. To undo an
241 The files will be added to the repository at the next commit. To undo an
242 add before that, see hg forget.
242 add before that, see hg forget.
243
243
244 If no names are given, add all files to the repository.
244 If no names are given, add all files to the repository.
245
245
246 use "hg -v help add" to show verbose help
247
246 options:
248 options:
247
249
248 -I --include include names matching the given patterns
250 -I --include include names matching the given patterns
249 -X --exclude exclude names matching the given patterns
251 -X --exclude exclude names matching the given patterns
250 -n --dry-run do not perform actions, just print output
252 -n --dry-run do not perform actions, just print output
251
253
252 use "hg -v help add" to show global options
254 use "hg -v help add" to show global options
255 %% verbose help for add
256 hg add [OPTION]... [FILE]...
257
258 add the specified files on the next commit
259
260 Schedule files to be version controlled and added to the repository.
261
262 The files will be added to the repository at the next commit. To undo an
263 add before that, see hg forget.
264
265 If no names are given, add all files to the repository.
266
267 An example showing how new (unknown) files are added automatically by "hg
268 add":
269
270 $ ls
271 foo.c
272 $ hg status
273 ? foo.c
274 $ hg add
275 adding foo.c
276 $ hg status
277
278 options:
279
280 -I --include include names matching the given patterns
281 -X --exclude exclude names matching the given patterns
282 -n --dry-run do not perform actions, just print output
283
284 global options:
285 -R --repository repository root directory or name of overlay bundle file
286 --cwd change working directory
287 -y --noninteractive do not prompt, assume 'yes' for any required answers
288 -q --quiet suppress output
289 -v --verbose enable additional output
290 --config set/override config option
291 --debug enable debugging output
292 --debugger start debugger
293 --encoding set the charset encoding (default: ascii)
294 --encodingmode set the charset encoding mode (default: strict)
295 --traceback always print a traceback on exception
296 --time time how long the command takes
297 --profile print command execution profile
298 --version output version information and exit
299 -h --help display help and exit
253 %% test help option with version option
300 %% test help option with version option
254 Mercurial Distributed SCM (version xxx)
301 Mercurial Distributed SCM (version xxx)
255
302
256 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
303 Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
257 This is free software; see the source for copying conditions. There is NO
304 This is free software; see the source for copying conditions. There is NO
258 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
305 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
259
306
260 hg add [OPTION]... [FILE]...
307 hg add [OPTION]... [FILE]...
261
308
262 add the specified files on the next commit
309 add the specified files on the next commit
263
310
264 Schedule files to be version controlled and added to the repository.
311 Schedule files to be version controlled and added to the repository.
265
312
266 The files will be added to the repository at the next commit. To undo an
313 The files will be added to the repository at the next commit. To undo an
267 add before that, see hg forget.
314 add before that, see hg forget.
268
315
269 If no names are given, add all files to the repository.
316 If no names are given, add all files to the repository.
270
317
318 use "hg -v help add" to show verbose help
319
271 options:
320 options:
272
321
273 -I --include include names matching the given patterns
322 -I --include include names matching the given patterns
274 -X --exclude exclude names matching the given patterns
323 -X --exclude exclude names matching the given patterns
275 -n --dry-run do not perform actions, just print output
324 -n --dry-run do not perform actions, just print output
276
325
277 use "hg -v help add" to show global options
326 use "hg -v help add" to show global options
278 hg add: option --skjdfks not recognized
327 hg add: option --skjdfks not recognized
279 hg add [OPTION]... [FILE]...
328 hg add [OPTION]... [FILE]...
280
329
281 add the specified files on the next commit
330 add the specified files on the next commit
282
331
283 Schedule files to be version controlled and added to the repository.
332 Schedule files to be version controlled and added to the repository.
284
333
285 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
286 add before that, see hg forget.
335 add before that, see hg forget.
287
336
288 If no names are given, add all files to the repository.
337 If no names are given, add all files to the repository.
289
338
339 use "hg -v help add" to show verbose help
340
290 options:
341 options:
291
342
292 -I --include include names matching the given patterns
343 -I --include include names matching the given patterns
293 -X --exclude exclude names matching the given patterns
344 -X --exclude exclude names matching the given patterns
294 -n --dry-run do not perform actions, just print output
345 -n --dry-run do not perform actions, just print output
295
346
296 use "hg -v help add" to show global options
347 use "hg -v help add" to show global options
297 %% test ambiguous command help
348 %% test ambiguous command help
298 list of commands:
349 list of commands:
299
350
300 add add the specified files on the next commit
351 add add the specified files on the next commit
301 addremove add all new files, delete all missing files
352 addremove add all new files, delete all missing files
302
353
303 use "hg -v help ad" to show aliases and global options
354 use "hg -v help ad" to show aliases and global options
304 %% test command without options
355 %% test command without options
305 hg verify
356 hg verify
306
357
307 verify the integrity of the repository
358 verify the integrity of the repository
308
359
309 Verify the integrity of the current repository.
360 Verify the integrity of the current repository.
310
361
311 This will perform an extensive check of the repository's integrity,
362 This will perform an extensive check of the repository's integrity,
312 validating the hashes and checksums of each entry in the changelog,
363 validating the hashes and checksums of each entry in the changelog,
313 manifest, and tracked files, as well as the integrity of their crosslinks
364 manifest, and tracked files, as well as the integrity of their crosslinks
314 and indices.
365 and indices.
315
366
316 use "hg -v help verify" to show global options
367 use "hg -v help verify" to show global options
317 hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...
368 hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...
318
369
319 diff repository (or selected files)
370 diff repository (or selected files)
320
371
321 Show differences between revisions for the specified files.
372 Show differences between revisions for the specified files.
322
373
323 Differences between files are shown using the unified diff format.
374 Differences between files are shown using the unified diff format.
324
375
325 NOTE: diff may generate unexpected results for merges, as it will default
376 NOTE: diff may generate unexpected results for merges, as it will default
326 to comparing against the working directory's first parent changeset if no
377 to comparing against the working directory's first parent changeset if no
327 revisions are specified.
378 revisions are specified.
328
379
329 When two revision arguments are given, then changes are shown between
380 When two revision arguments are given, then changes are shown between
330 those revisions. If only one revision is specified then that revision is
381 those revisions. If only one revision is specified then that revision is
331 compared to the working directory, and, when no revisions are specified,
382 compared to the working directory, and, when no revisions are specified,
332 the working directory files are compared to its parent.
383 the working directory files are compared to its parent.
333
384
334 Without the -a/--text option, diff will avoid generating diffs of files it
385 Without the -a/--text option, diff will avoid generating diffs of files it
335 detects as binary. With -a, diff will generate a diff anyway, probably
386 detects as binary. With -a, diff will generate a diff anyway, probably
336 with undesirable results.
387 with undesirable results.
337
388
338 Use the -g/--git option to generate diffs in the git extended diff format.
389 Use the -g/--git option to generate diffs in the git extended diff format.
339 For more information, read 'hg help diffs'.
390 For more information, read 'hg help diffs'.
340
391
341 options:
392 options:
342
393
343 -r --rev revision
394 -r --rev revision
344 -c --change change made by revision
395 -c --change change made by revision
345 -a --text treat all files as text
396 -a --text treat all files as text
346 -g --git use git extended diff format
397 -g --git use git extended diff format
347 --nodates omit dates from diff headers
398 --nodates omit dates from diff headers
348 -p --show-function show which function each change is in
399 -p --show-function show which function each change is in
349 --reverse produce a diff that undoes the changes
400 --reverse produce a diff that undoes the changes
350 -w --ignore-all-space ignore white space when comparing lines
401 -w --ignore-all-space ignore white space when comparing lines
351 -b --ignore-space-change ignore changes in the amount of white space
402 -b --ignore-space-change ignore changes in the amount of white space
352 -B --ignore-blank-lines ignore changes whose lines are all blank
403 -B --ignore-blank-lines ignore changes whose lines are all blank
353 -U --unified number of lines of context to show
404 -U --unified number of lines of context to show
354 --stat output diffstat-style summary of changes
405 --stat output diffstat-style summary of changes
355 -I --include include names matching the given patterns
406 -I --include include names matching the given patterns
356 -X --exclude exclude names matching the given patterns
407 -X --exclude exclude names matching the given patterns
357
408
358 use "hg -v help diff" to show global options
409 use "hg -v help diff" to show global options
359 hg status [OPTION]... [FILE]...
410 hg status [OPTION]... [FILE]...
360
411
361 aliases: st
412 aliases: st
362
413
363 show changed files in the working directory
414 show changed files in the working directory
364
415
365 Show status of files in the repository. If names are given, only files
416 Show status of files in the repository. If names are given, only files
366 that match are shown. Files that are clean or ignored or the source of a
417 that match are shown. Files that are clean or ignored or the source of a
367 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
418 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
368 -C/--copies or -A/--all are given. Unless options described with "show
419 -C/--copies or -A/--all are given. Unless options described with "show
369 only ..." are given, the options -mardu are used.
420 only ..." are given, the options -mardu are used.
370
421
371 Option -q/--quiet hides untracked (unknown and ignored) files unless
422 Option -q/--quiet hides untracked (unknown and ignored) files unless
372 explicitly requested with -u/--unknown or -i/--ignored.
423 explicitly requested with -u/--unknown or -i/--ignored.
373
424
374 NOTE: status may appear to disagree with diff if permissions have changed
425 NOTE: status may appear to disagree with diff if permissions have changed
375 or a merge has occurred. The standard diff format does not report
426 or a merge has occurred. The standard diff format does not report
376 permission changes and diff only reports changes relative to one merge
427 permission changes and diff only reports changes relative to one merge
377 parent.
428 parent.
378
429
379 If one revision is given, it is used as the base revision. If two
430 If one revision is given, it is used as the base revision. If two
380 revisions are given, the differences between them are shown. The --change
431 revisions are given, the differences between them are shown. The --change
381 option can also be used as a shortcut to list the changed files of a
432 option can also be used as a shortcut to list the changed files of a
382 revision from its first parent.
433 revision from its first parent.
383
434
384 The codes used to show the status of files are:
435 The codes used to show the status of files are:
385
436
386 M = modified
437 M = modified
387 A = added
438 A = added
388 R = removed
439 R = removed
389 C = clean
440 C = clean
390 ! = missing (deleted by non-hg command, but still tracked)
441 ! = missing (deleted by non-hg command, but still tracked)
391 ? = not tracked
442 ? = not tracked
392 I = ignored
443 I = ignored
393 = origin of the previous file listed as A (added)
444 = origin of the previous file listed as A (added)
394
445
395 options:
446 options:
396
447
397 -A --all show status of all files
448 -A --all show status of all files
398 -m --modified show only modified files
449 -m --modified show only modified files
399 -a --added show only added files
450 -a --added show only added files
400 -r --removed show only removed files
451 -r --removed show only removed files
401 -d --deleted show only deleted (but tracked) files
452 -d --deleted show only deleted (but tracked) files
402 -c --clean show only files without changes
453 -c --clean show only files without changes
403 -u --unknown show only unknown (not tracked) files
454 -u --unknown show only unknown (not tracked) files
404 -i --ignored show only ignored files
455 -i --ignored show only ignored files
405 -n --no-status hide status prefix
456 -n --no-status hide status prefix
406 -C --copies show source of copied files
457 -C --copies show source of copied files
407 -0 --print0 end filenames with NUL, for use with xargs
458 -0 --print0 end filenames with NUL, for use with xargs
408 --rev show difference from revision
459 --rev show difference from revision
409 --change list the changed files of a revision
460 --change list the changed files of a revision
410 -I --include include names matching the given patterns
461 -I --include include names matching the given patterns
411 -X --exclude exclude names matching the given patterns
462 -X --exclude exclude names matching the given patterns
412
463
413 use "hg -v help status" to show global options
464 use "hg -v help status" to show global options
414 hg status [OPTION]... [FILE]...
465 hg status [OPTION]... [FILE]...
415
466
416 show changed files in the working directory
467 show changed files in the working directory
417 hg: unknown command 'foo'
468 hg: unknown command 'foo'
418 Mercurial Distributed SCM
469 Mercurial Distributed SCM
419
470
420 basic commands:
471 basic commands:
421
472
422 add add the specified files on the next commit
473 add add the specified files on the next commit
423 annotate show changeset information by line for each file
474 annotate show changeset information by line for each file
424 clone make a copy of an existing repository
475 clone make a copy of an existing repository
425 commit commit the specified files or all outstanding changes
476 commit commit the specified files or all outstanding changes
426 diff diff repository (or selected files)
477 diff diff repository (or selected files)
427 export dump the header and diffs for one or more changesets
478 export dump the header and diffs for one or more changesets
428 forget forget the specified files on the next commit
479 forget forget the specified files on the next commit
429 init create a new repository in the given directory
480 init create a new repository in the given directory
430 log show revision history of entire repository or files
481 log show revision history of entire repository or files
431 merge merge working directory with another revision
482 merge merge working directory with another revision
432 pull pull changes from the specified source
483 pull pull changes from the specified source
433 push push changes to the specified destination
484 push push changes to the specified destination
434 remove remove the specified files on the next commit
485 remove remove the specified files on the next commit
435 serve export the repository via HTTP
486 serve export the repository via HTTP
436 status show changed files in the working directory
487 status show changed files in the working directory
437 summary summarize working directory state
488 summary summarize working directory state
438 update update working directory
489 update update working directory
439
490
440 use "hg help" for the full list of commands or "hg -v" for details
491 use "hg help" for the full list of commands or "hg -v" for details
441 hg: unknown command 'skjdfks'
492 hg: unknown command 'skjdfks'
442 Mercurial Distributed SCM
493 Mercurial Distributed SCM
443
494
444 basic commands:
495 basic commands:
445
496
446 add add the specified files on the next commit
497 add add the specified files on the next commit
447 annotate show changeset information by line for each file
498 annotate show changeset information by line for each file
448 clone make a copy of an existing repository
499 clone make a copy of an existing repository
449 commit commit the specified files or all outstanding changes
500 commit commit the specified files or all outstanding changes
450 diff diff repository (or selected files)
501 diff diff repository (or selected files)
451 export dump the header and diffs for one or more changesets
502 export dump the header and diffs for one or more changesets
452 forget forget the specified files on the next commit
503 forget forget the specified files on the next commit
453 init create a new repository in the given directory
504 init create a new repository in the given directory
454 log show revision history of entire repository or files
505 log show revision history of entire repository or files
455 merge merge working directory with another revision
506 merge merge working directory with another revision
456 pull pull changes from the specified source
507 pull pull changes from the specified source
457 push push changes to the specified destination
508 push push changes to the specified destination
458 remove remove the specified files on the next commit
509 remove remove the specified files on the next commit
459 serve export the repository via HTTP
510 serve export the repository via HTTP
460 status show changed files in the working directory
511 status show changed files in the working directory
461 summary summarize working directory state
512 summary summarize working directory state
462 update update working directory
513 update update working directory
463
514
464 use "hg help" for the full list of commands or "hg -v" for details
515 use "hg help" for the full list of commands or "hg -v" for details
465 %% test command with no help text
516 %% test command with no help text
466 hg nohelp
517 hg nohelp
467
518
468 (no help text available)
519 (no help text available)
469
520
470 use "hg -v help nohelp" to show global options
521 use "hg -v help nohelp" to show global options
471 %% test that default list of commands omits extension commands
522 %% test that default list of commands omits extension commands
472 Mercurial Distributed SCM
523 Mercurial Distributed SCM
473
524
474 list of commands:
525 list of commands:
475
526
476 add add the specified files on the next commit
527 add add the specified files on the next commit
477 addremove add all new files, delete all missing files
528 addremove add all new files, delete all missing files
478 annotate show changeset information by line for each file
529 annotate show changeset information by line for each file
479 archive create an unversioned archive of a repository revision
530 archive create an unversioned archive of a repository revision
480 backout reverse effect of earlier changeset
531 backout reverse effect of earlier changeset
481 bisect subdivision search of changesets
532 bisect subdivision search of changesets
482 branch set or show the current branch name
533 branch set or show the current branch name
483 branches list repository named branches
534 branches list repository named branches
484 bundle create a changegroup file
535 bundle create a changegroup file
485 cat output the current or given revision of files
536 cat output the current or given revision of files
486 clone make a copy of an existing repository
537 clone make a copy of an existing repository
487 commit commit the specified files or all outstanding changes
538 commit commit the specified files or all outstanding changes
488 copy mark files as copied for the next commit
539 copy mark files as copied for the next commit
489 diff diff repository (or selected files)
540 diff diff repository (or selected files)
490 export dump the header and diffs for one or more changesets
541 export dump the header and diffs for one or more changesets
491 forget forget the specified files on the next commit
542 forget forget the specified files on the next commit
492 grep search for a pattern in specified files and revisions
543 grep search for a pattern in specified files and revisions
493 heads show current repository heads or show branch heads
544 heads show current repository heads or show branch heads
494 help show help for a given topic or a help overview
545 help show help for a given topic or a help overview
495 identify identify the working copy or specified revision
546 identify identify the working copy or specified revision
496 import import an ordered set of patches
547 import import an ordered set of patches
497 incoming show new changesets found in source
548 incoming show new changesets found in source
498 init create a new repository in the given directory
549 init create a new repository in the given directory
499 locate locate files matching specific patterns
550 locate locate files matching specific patterns
500 log show revision history of entire repository or files
551 log show revision history of entire repository or files
501 manifest output the current or given revision of the project manifest
552 manifest output the current or given revision of the project manifest
502 merge merge working directory with another revision
553 merge merge working directory with another revision
503 outgoing show changesets not found in the destination
554 outgoing show changesets not found in the destination
504 parents show the parents of the working directory or revision
555 parents show the parents of the working directory or revision
505 paths show aliases for remote repositories
556 paths show aliases for remote repositories
506 pull pull changes from the specified source
557 pull pull changes from the specified source
507 push push changes to the specified destination
558 push push changes to the specified destination
508 recover roll back an interrupted transaction
559 recover roll back an interrupted transaction
509 remove remove the specified files on the next commit
560 remove remove the specified files on the next commit
510 rename rename files; equivalent of copy + remove
561 rename rename files; equivalent of copy + remove
511 resolve retry file merges from a merge or update
562 resolve retry file merges from a merge or update
512 revert restore individual files or directories to an earlier state
563 revert restore individual files or directories to an earlier state
513 rollback roll back the last transaction
564 rollback roll back the last transaction
514 root print the root (top) of the current working directory
565 root print the root (top) of the current working directory
515 serve export the repository via HTTP
566 serve export the repository via HTTP
516 showconfig show combined config settings from all hgrc files
567 showconfig show combined config settings from all hgrc files
517 status show changed files in the working directory
568 status show changed files in the working directory
518 summary summarize working directory state
569 summary summarize working directory state
519 tag add one or more tags for the current or given revision
570 tag add one or more tags for the current or given revision
520 tags list repository tags
571 tags list repository tags
521 tip show the tip revision
572 tip show the tip revision
522 unbundle apply one or more changegroup files
573 unbundle apply one or more changegroup files
523 update update working directory
574 update update working directory
524 verify verify the integrity of the repository
575 verify verify the integrity of the repository
525 version output version and copyright information
576 version output version and copyright information
526
577
527 enabled extensions:
578 enabled extensions:
528
579
529 helpext (no help text available)
580 helpext (no help text available)
530
581
531 additional help topics:
582 additional help topics:
532
583
533 config Configuration Files
584 config Configuration Files
534 dates Date Formats
585 dates Date Formats
535 patterns File Name Patterns
586 patterns File Name Patterns
536 environment Environment Variables
587 environment Environment Variables
537 revisions Specifying Single Revisions
588 revisions Specifying Single Revisions
538 multirevs Specifying Multiple Revisions
589 multirevs Specifying Multiple Revisions
539 diffs Diff Formats
590 diffs Diff Formats
540 templating Template Usage
591 templating Template Usage
541 urls URL Paths
592 urls URL Paths
542 extensions Using additional features
593 extensions Using additional features
543
594
544 use "hg -v help" to show aliases and global options
595 use "hg -v help" to show aliases and global options
545 %% test list of commands with command with no help text
596 %% test list of commands with command with no help text
546 helpext extension - no help text available
597 helpext extension - no help text available
547
598
548 list of commands:
599 list of commands:
549
600
550 nohelp (no help text available)
601 nohelp (no help text available)
551
602
552 use "hg -v help helpext" to show aliases and global options
603 use "hg -v help helpext" to show aliases and global options
553 %% test a help topic
604 %% test a help topic
554 Specifying Single Revisions
605 Specifying Single Revisions
555
606
556 Mercurial supports several ways to specify individual revisions.
607 Mercurial supports several ways to specify individual revisions.
557
608
558 A plain integer is treated as a revision number. Negative integers are
609 A plain integer is treated as a revision number. Negative integers are
559 treated as sequential offsets from the tip, with -1 denoting the tip, -2
610 treated as sequential offsets from the tip, with -1 denoting the tip, -2
560 denoting the revision prior to the tip, and so forth.
611 denoting the revision prior to the tip, and so forth.
561
612
562 A 40-digit hexadecimal string is treated as a unique revision identifier.
613 A 40-digit hexadecimal string is treated as a unique revision identifier.
563
614
564 A hexadecimal string less than 40 characters long is treated as a unique
615 A hexadecimal string less than 40 characters long is treated as a unique
565 revision identifier and is referred to as a short-form identifier. A
616 revision identifier and is referred to as a short-form identifier. A
566 short-form identifier is only valid if it is the prefix of exactly one
617 short-form identifier is only valid if it is the prefix of exactly one
567 full-length identifier.
618 full-length identifier.
568
619
569 Any other string is treated as a tag or branch name. A tag name is a
620 Any other string is treated as a tag or branch name. A tag name is a
570 symbolic name associated with a revision identifier. A branch name denotes
621 symbolic name associated with a revision identifier. A branch name denotes
571 the tipmost revision of that branch. Tag and branch names must not contain
622 the tipmost revision of that branch. Tag and branch names must not contain
572 the ":" character.
623 the ":" character.
573
624
574 The reserved name "tip" is a special tag that always identifies the most
625 The reserved name "tip" is a special tag that always identifies the most
575 recent revision.
626 recent revision.
576
627
577 The reserved name "null" indicates the null revision. This is the revision
628 The reserved name "null" indicates the null revision. This is the revision
578 of an empty repository, and the parent of revision 0.
629 of an empty repository, and the parent of revision 0.
579
630
580 The reserved name "." indicates the working directory parent. If no
631 The reserved name "." indicates the working directory parent. If no
581 working directory is checked out, it is equivalent to null. If an
632 working directory is checked out, it is equivalent to null. If an
582 uncommitted merge is in progress, "." is the revision of the first parent.
633 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