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