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