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