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