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