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