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