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