Show More
@@ -1,1365 +1,1370 b'' | |||||
1 | # cmdutil.py - help for command processing in mercurial |
|
1 | # cmdutil.py - help for command processing in 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 of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import hex, nullid, nullrev, short |
|
8 | from node import hex, nullid, nullrev, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import os, sys, errno, re, glob, tempfile |
|
10 | import os, sys, errno, re, glob, tempfile | |
11 | import util, templater, patch, error, encoding, templatekw |
|
11 | import util, templater, patch, error, encoding, templatekw | |
12 | import match as matchmod |
|
12 | import match as matchmod | |
13 | import similar, revset, subrepo |
|
13 | import similar, revset, subrepo | |
14 |
|
14 | |||
15 | revrangesep = ':' |
|
15 | revrangesep = ':' | |
16 |
|
16 | |||
17 | def parsealiases(cmd): |
|
17 | def parsealiases(cmd): | |
18 | return cmd.lstrip("^").split("|") |
|
18 | return cmd.lstrip("^").split("|") | |
19 |
|
19 | |||
20 | def findpossible(cmd, table, strict=False): |
|
20 | def findpossible(cmd, table, strict=False): | |
21 | """ |
|
21 | """ | |
22 | Return cmd -> (aliases, command table entry) |
|
22 | Return cmd -> (aliases, command table entry) | |
23 | for each matching command. |
|
23 | for each matching command. | |
24 | Return debug commands (or their aliases) only if no normal command matches. |
|
24 | Return debug commands (or their aliases) only if no normal command matches. | |
25 | """ |
|
25 | """ | |
26 | choice = {} |
|
26 | choice = {} | |
27 | debugchoice = {} |
|
27 | debugchoice = {} | |
28 | for e in table.keys(): |
|
28 | for e in table.keys(): | |
29 | aliases = parsealiases(e) |
|
29 | aliases = parsealiases(e) | |
30 | found = None |
|
30 | found = None | |
31 | if cmd in aliases: |
|
31 | if cmd in aliases: | |
32 | found = cmd |
|
32 | found = cmd | |
33 | elif not strict: |
|
33 | elif not strict: | |
34 | for a in aliases: |
|
34 | for a in aliases: | |
35 | if a.startswith(cmd): |
|
35 | if a.startswith(cmd): | |
36 | found = a |
|
36 | found = a | |
37 | break |
|
37 | break | |
38 | if found is not None: |
|
38 | if found is not None: | |
39 | if aliases[0].startswith("debug") or found.startswith("debug"): |
|
39 | if aliases[0].startswith("debug") or found.startswith("debug"): | |
40 | debugchoice[found] = (aliases, table[e]) |
|
40 | debugchoice[found] = (aliases, table[e]) | |
41 | else: |
|
41 | else: | |
42 | choice[found] = (aliases, table[e]) |
|
42 | choice[found] = (aliases, table[e]) | |
43 |
|
43 | |||
44 | if not choice and debugchoice: |
|
44 | if not choice and debugchoice: | |
45 | choice = debugchoice |
|
45 | choice = debugchoice | |
46 |
|
46 | |||
47 | return choice |
|
47 | return choice | |
48 |
|
48 | |||
49 | def findcmd(cmd, table, strict=True): |
|
49 | def findcmd(cmd, table, strict=True): | |
50 | """Return (aliases, command table entry) for command string.""" |
|
50 | """Return (aliases, command table entry) for command string.""" | |
51 | choice = findpossible(cmd, table, strict) |
|
51 | choice = findpossible(cmd, table, strict) | |
52 |
|
52 | |||
53 | if cmd in choice: |
|
53 | if cmd in choice: | |
54 | return choice[cmd] |
|
54 | return choice[cmd] | |
55 |
|
55 | |||
56 | if len(choice) > 1: |
|
56 | if len(choice) > 1: | |
57 | clist = choice.keys() |
|
57 | clist = choice.keys() | |
58 | clist.sort() |
|
58 | clist.sort() | |
59 | raise error.AmbiguousCommand(cmd, clist) |
|
59 | raise error.AmbiguousCommand(cmd, clist) | |
60 |
|
60 | |||
61 | if choice: |
|
61 | if choice: | |
62 | return choice.values()[0] |
|
62 | return choice.values()[0] | |
63 |
|
63 | |||
64 | raise error.UnknownCommand(cmd) |
|
64 | raise error.UnknownCommand(cmd) | |
65 |
|
65 | |||
66 | def findrepo(p): |
|
66 | def findrepo(p): | |
67 | while not os.path.isdir(os.path.join(p, ".hg")): |
|
67 | while not os.path.isdir(os.path.join(p, ".hg")): | |
68 | oldp, p = p, os.path.dirname(p) |
|
68 | oldp, p = p, os.path.dirname(p) | |
69 | if p == oldp: |
|
69 | if p == oldp: | |
70 | return None |
|
70 | return None | |
71 |
|
71 | |||
72 | return p |
|
72 | return p | |
73 |
|
73 | |||
74 | def bail_if_changed(repo): |
|
74 | def bail_if_changed(repo): | |
75 | if repo.dirstate.parents()[1] != nullid: |
|
75 | if repo.dirstate.parents()[1] != nullid: | |
76 | raise util.Abort(_('outstanding uncommitted merge')) |
|
76 | raise util.Abort(_('outstanding uncommitted merge')) | |
77 | modified, added, removed, deleted = repo.status()[:4] |
|
77 | modified, added, removed, deleted = repo.status()[:4] | |
78 | if modified or added or removed or deleted: |
|
78 | if modified or added or removed or deleted: | |
79 | raise util.Abort(_("outstanding uncommitted changes")) |
|
79 | raise util.Abort(_("outstanding uncommitted changes")) | |
80 |
|
80 | |||
81 | def logmessage(opts): |
|
81 | def logmessage(opts): | |
82 | """ get the log message according to -m and -l option """ |
|
82 | """ get the log message according to -m and -l option """ | |
83 | message = opts.get('message') |
|
83 | message = opts.get('message') | |
84 | logfile = opts.get('logfile') |
|
84 | logfile = opts.get('logfile') | |
85 |
|
85 | |||
86 | if message and logfile: |
|
86 | if message and logfile: | |
87 | raise util.Abort(_('options --message and --logfile are mutually ' |
|
87 | raise util.Abort(_('options --message and --logfile are mutually ' | |
88 | 'exclusive')) |
|
88 | 'exclusive')) | |
89 | if not message and logfile: |
|
89 | if not message and logfile: | |
90 | try: |
|
90 | try: | |
91 | if logfile == '-': |
|
91 | if logfile == '-': | |
92 | message = sys.stdin.read() |
|
92 | message = sys.stdin.read() | |
93 | else: |
|
93 | else: | |
94 | message = open(logfile).read() |
|
94 | message = open(logfile).read() | |
95 | except IOError, inst: |
|
95 | except IOError, inst: | |
96 | raise util.Abort(_("can't read commit message '%s': %s") % |
|
96 | raise util.Abort(_("can't read commit message '%s': %s") % | |
97 | (logfile, inst.strerror)) |
|
97 | (logfile, inst.strerror)) | |
98 | return message |
|
98 | return message | |
99 |
|
99 | |||
100 | def loglimit(opts): |
|
100 | def loglimit(opts): | |
101 | """get the log limit according to option -l/--limit""" |
|
101 | """get the log limit according to option -l/--limit""" | |
102 | limit = opts.get('limit') |
|
102 | limit = opts.get('limit') | |
103 | if limit: |
|
103 | if limit: | |
104 | try: |
|
104 | try: | |
105 | limit = int(limit) |
|
105 | limit = int(limit) | |
106 | except ValueError: |
|
106 | except ValueError: | |
107 | raise util.Abort(_('limit must be a positive integer')) |
|
107 | raise util.Abort(_('limit must be a positive integer')) | |
108 | if limit <= 0: |
|
108 | if limit <= 0: | |
109 | raise util.Abort(_('limit must be positive')) |
|
109 | raise util.Abort(_('limit must be positive')) | |
110 | else: |
|
110 | else: | |
111 | limit = None |
|
111 | limit = None | |
112 | return limit |
|
112 | return limit | |
113 |
|
113 | |||
114 | def revsingle(repo, revspec, default='.'): |
|
114 | def revsingle(repo, revspec, default='.'): | |
115 | if not revspec: |
|
115 | if not revspec: | |
116 | return repo[default] |
|
116 | return repo[default] | |
117 |
|
117 | |||
118 | l = revrange(repo, [revspec]) |
|
118 | l = revrange(repo, [revspec]) | |
119 | if len(l) < 1: |
|
119 | if len(l) < 1: | |
120 | raise util.Abort(_('empty revision set')) |
|
120 | raise util.Abort(_('empty revision set')) | |
121 | return repo[l[-1]] |
|
121 | return repo[l[-1]] | |
122 |
|
122 | |||
123 | def revpair(repo, revs): |
|
123 | def revpair(repo, revs): | |
124 | if not revs: |
|
124 | if not revs: | |
125 | return repo.dirstate.parents()[0], None |
|
125 | return repo.dirstate.parents()[0], None | |
126 |
|
126 | |||
127 | l = revrange(repo, revs) |
|
127 | l = revrange(repo, revs) | |
128 |
|
128 | |||
129 | if len(l) == 0: |
|
129 | if len(l) == 0: | |
130 | return repo.dirstate.parents()[0], None |
|
130 | return repo.dirstate.parents()[0], None | |
131 |
|
131 | |||
132 | if len(l) == 1: |
|
132 | if len(l) == 1: | |
133 | return repo.lookup(l[0]), None |
|
133 | return repo.lookup(l[0]), None | |
134 |
|
134 | |||
135 | return repo.lookup(l[0]), repo.lookup(l[-1]) |
|
135 | return repo.lookup(l[0]), repo.lookup(l[-1]) | |
136 |
|
136 | |||
137 | def revrange(repo, revs): |
|
137 | def revrange(repo, revs): | |
138 | """Yield revision as strings from a list of revision specifications.""" |
|
138 | """Yield revision as strings from a list of revision specifications.""" | |
139 |
|
139 | |||
140 | def revfix(repo, val, defval): |
|
140 | def revfix(repo, val, defval): | |
141 | if not val and val != 0 and defval is not None: |
|
141 | if not val and val != 0 and defval is not None: | |
142 | return defval |
|
142 | return defval | |
143 | return repo.changelog.rev(repo.lookup(val)) |
|
143 | return repo.changelog.rev(repo.lookup(val)) | |
144 |
|
144 | |||
145 | seen, l = set(), [] |
|
145 | seen, l = set(), [] | |
146 | for spec in revs: |
|
146 | for spec in revs: | |
147 | # attempt to parse old-style ranges first to deal with |
|
147 | # attempt to parse old-style ranges first to deal with | |
148 | # things like old-tag which contain query metacharacters |
|
148 | # things like old-tag which contain query metacharacters | |
149 | try: |
|
149 | try: | |
|
150 | if isinstance(spec, int): | |||
|
151 | seen.add(spec) | |||
|
152 | l.append(spec) | |||
|
153 | continue | |||
|
154 | ||||
150 | if revrangesep in spec: |
|
155 | if revrangesep in spec: | |
151 | start, end = spec.split(revrangesep, 1) |
|
156 | start, end = spec.split(revrangesep, 1) | |
152 | start = revfix(repo, start, 0) |
|
157 | start = revfix(repo, start, 0) | |
153 | end = revfix(repo, end, len(repo) - 1) |
|
158 | end = revfix(repo, end, len(repo) - 1) | |
154 | step = start > end and -1 or 1 |
|
159 | step = start > end and -1 or 1 | |
155 | for rev in xrange(start, end + step, step): |
|
160 | for rev in xrange(start, end + step, step): | |
156 | if rev in seen: |
|
161 | if rev in seen: | |
157 | continue |
|
162 | continue | |
158 | seen.add(rev) |
|
163 | seen.add(rev) | |
159 | l.append(rev) |
|
164 | l.append(rev) | |
160 | continue |
|
165 | continue | |
161 | elif spec and spec in repo: # single unquoted rev |
|
166 | elif spec and spec in repo: # single unquoted rev | |
162 | rev = revfix(repo, spec, None) |
|
167 | rev = revfix(repo, spec, None) | |
163 | if rev in seen: |
|
168 | if rev in seen: | |
164 | continue |
|
169 | continue | |
165 | seen.add(rev) |
|
170 | seen.add(rev) | |
166 | l.append(rev) |
|
171 | l.append(rev) | |
167 | continue |
|
172 | continue | |
168 | except error.RepoLookupError: |
|
173 | except error.RepoLookupError: | |
169 | pass |
|
174 | pass | |
170 |
|
175 | |||
171 | # fall through to new-style queries if old-style fails |
|
176 | # fall through to new-style queries if old-style fails | |
172 | m = revset.match(spec) |
|
177 | m = revset.match(spec) | |
173 | for r in m(repo, range(len(repo))): |
|
178 | for r in m(repo, range(len(repo))): | |
174 | if r not in seen: |
|
179 | if r not in seen: | |
175 | l.append(r) |
|
180 | l.append(r) | |
176 | seen.update(l) |
|
181 | seen.update(l) | |
177 |
|
182 | |||
178 | return l |
|
183 | return l | |
179 |
|
184 | |||
180 | def make_filename(repo, pat, node, |
|
185 | def make_filename(repo, pat, node, | |
181 | total=None, seqno=None, revwidth=None, pathname=None): |
|
186 | total=None, seqno=None, revwidth=None, pathname=None): | |
182 | node_expander = { |
|
187 | node_expander = { | |
183 | 'H': lambda: hex(node), |
|
188 | 'H': lambda: hex(node), | |
184 | 'R': lambda: str(repo.changelog.rev(node)), |
|
189 | 'R': lambda: str(repo.changelog.rev(node)), | |
185 | 'h': lambda: short(node), |
|
190 | 'h': lambda: short(node), | |
186 | } |
|
191 | } | |
187 | expander = { |
|
192 | expander = { | |
188 | '%': lambda: '%', |
|
193 | '%': lambda: '%', | |
189 | 'b': lambda: os.path.basename(repo.root), |
|
194 | 'b': lambda: os.path.basename(repo.root), | |
190 | } |
|
195 | } | |
191 |
|
196 | |||
192 | try: |
|
197 | try: | |
193 | if node: |
|
198 | if node: | |
194 | expander.update(node_expander) |
|
199 | expander.update(node_expander) | |
195 | if node: |
|
200 | if node: | |
196 | expander['r'] = (lambda: |
|
201 | expander['r'] = (lambda: | |
197 | str(repo.changelog.rev(node)).zfill(revwidth or 0)) |
|
202 | str(repo.changelog.rev(node)).zfill(revwidth or 0)) | |
198 | if total is not None: |
|
203 | if total is not None: | |
199 | expander['N'] = lambda: str(total) |
|
204 | expander['N'] = lambda: str(total) | |
200 | if seqno is not None: |
|
205 | if seqno is not None: | |
201 | expander['n'] = lambda: str(seqno) |
|
206 | expander['n'] = lambda: str(seqno) | |
202 | if total is not None and seqno is not None: |
|
207 | if total is not None and seqno is not None: | |
203 | expander['n'] = lambda: str(seqno).zfill(len(str(total))) |
|
208 | expander['n'] = lambda: str(seqno).zfill(len(str(total))) | |
204 | if pathname is not None: |
|
209 | if pathname is not None: | |
205 | expander['s'] = lambda: os.path.basename(pathname) |
|
210 | expander['s'] = lambda: os.path.basename(pathname) | |
206 | expander['d'] = lambda: os.path.dirname(pathname) or '.' |
|
211 | expander['d'] = lambda: os.path.dirname(pathname) or '.' | |
207 | expander['p'] = lambda: pathname |
|
212 | expander['p'] = lambda: pathname | |
208 |
|
213 | |||
209 | newname = [] |
|
214 | newname = [] | |
210 | patlen = len(pat) |
|
215 | patlen = len(pat) | |
211 | i = 0 |
|
216 | i = 0 | |
212 | while i < patlen: |
|
217 | while i < patlen: | |
213 | c = pat[i] |
|
218 | c = pat[i] | |
214 | if c == '%': |
|
219 | if c == '%': | |
215 | i += 1 |
|
220 | i += 1 | |
216 | c = pat[i] |
|
221 | c = pat[i] | |
217 | c = expander[c]() |
|
222 | c = expander[c]() | |
218 | newname.append(c) |
|
223 | newname.append(c) | |
219 | i += 1 |
|
224 | i += 1 | |
220 | return ''.join(newname) |
|
225 | return ''.join(newname) | |
221 | except KeyError, inst: |
|
226 | except KeyError, inst: | |
222 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % |
|
227 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % | |
223 | inst.args[0]) |
|
228 | inst.args[0]) | |
224 |
|
229 | |||
225 | def make_file(repo, pat, node=None, |
|
230 | def make_file(repo, pat, node=None, | |
226 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): |
|
231 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): | |
227 |
|
232 | |||
228 | writable = 'w' in mode or 'a' in mode |
|
233 | writable = 'w' in mode or 'a' in mode | |
229 |
|
234 | |||
230 | if not pat or pat == '-': |
|
235 | if not pat or pat == '-': | |
231 | return writable and sys.stdout or sys.stdin |
|
236 | return writable and sys.stdout or sys.stdin | |
232 | if hasattr(pat, 'write') and writable: |
|
237 | if hasattr(pat, 'write') and writable: | |
233 | return pat |
|
238 | return pat | |
234 | if hasattr(pat, 'read') and 'r' in mode: |
|
239 | if hasattr(pat, 'read') and 'r' in mode: | |
235 | return pat |
|
240 | return pat | |
236 | return open(make_filename(repo, pat, node, total, seqno, revwidth, |
|
241 | return open(make_filename(repo, pat, node, total, seqno, revwidth, | |
237 | pathname), |
|
242 | pathname), | |
238 | mode) |
|
243 | mode) | |
239 |
|
244 | |||
240 | def expandpats(pats): |
|
245 | def expandpats(pats): | |
241 | if not util.expandglobs: |
|
246 | if not util.expandglobs: | |
242 | return list(pats) |
|
247 | return list(pats) | |
243 | ret = [] |
|
248 | ret = [] | |
244 | for p in pats: |
|
249 | for p in pats: | |
245 | kind, name = matchmod._patsplit(p, None) |
|
250 | kind, name = matchmod._patsplit(p, None) | |
246 | if kind is None: |
|
251 | if kind is None: | |
247 | try: |
|
252 | try: | |
248 | globbed = glob.glob(name) |
|
253 | globbed = glob.glob(name) | |
249 | except re.error: |
|
254 | except re.error: | |
250 | globbed = [name] |
|
255 | globbed = [name] | |
251 | if globbed: |
|
256 | if globbed: | |
252 | ret.extend(globbed) |
|
257 | ret.extend(globbed) | |
253 | continue |
|
258 | continue | |
254 | ret.append(p) |
|
259 | ret.append(p) | |
255 | return ret |
|
260 | return ret | |
256 |
|
261 | |||
257 | def match(repo, pats=[], opts={}, globbed=False, default='relpath'): |
|
262 | def match(repo, pats=[], opts={}, globbed=False, default='relpath'): | |
258 | if not globbed and default == 'relpath': |
|
263 | if not globbed and default == 'relpath': | |
259 | pats = expandpats(pats or []) |
|
264 | pats = expandpats(pats or []) | |
260 | m = matchmod.match(repo.root, repo.getcwd(), pats, |
|
265 | m = matchmod.match(repo.root, repo.getcwd(), pats, | |
261 | opts.get('include'), opts.get('exclude'), default, |
|
266 | opts.get('include'), opts.get('exclude'), default, | |
262 | auditor=repo.auditor) |
|
267 | auditor=repo.auditor) | |
263 | def badfn(f, msg): |
|
268 | def badfn(f, msg): | |
264 | repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) |
|
269 | repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) | |
265 | m.bad = badfn |
|
270 | m.bad = badfn | |
266 | return m |
|
271 | return m | |
267 |
|
272 | |||
268 | def matchall(repo): |
|
273 | def matchall(repo): | |
269 | return matchmod.always(repo.root, repo.getcwd()) |
|
274 | return matchmod.always(repo.root, repo.getcwd()) | |
270 |
|
275 | |||
271 | def matchfiles(repo, files): |
|
276 | def matchfiles(repo, files): | |
272 | return matchmod.exact(repo.root, repo.getcwd(), files) |
|
277 | return matchmod.exact(repo.root, repo.getcwd(), files) | |
273 |
|
278 | |||
274 | def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): |
|
279 | def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): | |
275 | if dry_run is None: |
|
280 | if dry_run is None: | |
276 | dry_run = opts.get('dry_run') |
|
281 | dry_run = opts.get('dry_run') | |
277 | if similarity is None: |
|
282 | if similarity is None: | |
278 | similarity = float(opts.get('similarity') or 0) |
|
283 | similarity = float(opts.get('similarity') or 0) | |
279 | # we'd use status here, except handling of symlinks and ignore is tricky |
|
284 | # we'd use status here, except handling of symlinks and ignore is tricky | |
280 | added, unknown, deleted, removed = [], [], [], [] |
|
285 | added, unknown, deleted, removed = [], [], [], [] | |
281 | audit_path = util.path_auditor(repo.root) |
|
286 | audit_path = util.path_auditor(repo.root) | |
282 | m = match(repo, pats, opts) |
|
287 | m = match(repo, pats, opts) | |
283 | for abs in repo.walk(m): |
|
288 | for abs in repo.walk(m): | |
284 | target = repo.wjoin(abs) |
|
289 | target = repo.wjoin(abs) | |
285 | good = True |
|
290 | good = True | |
286 | try: |
|
291 | try: | |
287 | audit_path(abs) |
|
292 | audit_path(abs) | |
288 | except: |
|
293 | except: | |
289 | good = False |
|
294 | good = False | |
290 | rel = m.rel(abs) |
|
295 | rel = m.rel(abs) | |
291 | exact = m.exact(abs) |
|
296 | exact = m.exact(abs) | |
292 | if good and abs not in repo.dirstate: |
|
297 | if good and abs not in repo.dirstate: | |
293 | unknown.append(abs) |
|
298 | unknown.append(abs) | |
294 | if repo.ui.verbose or not exact: |
|
299 | if repo.ui.verbose or not exact: | |
295 | repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
|
300 | repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) | |
296 | elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) |
|
301 | elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) | |
297 | or (os.path.isdir(target) and not os.path.islink(target))): |
|
302 | or (os.path.isdir(target) and not os.path.islink(target))): | |
298 | deleted.append(abs) |
|
303 | deleted.append(abs) | |
299 | if repo.ui.verbose or not exact: |
|
304 | if repo.ui.verbose or not exact: | |
300 | repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) |
|
305 | repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) | |
301 | # for finding renames |
|
306 | # for finding renames | |
302 | elif repo.dirstate[abs] == 'r': |
|
307 | elif repo.dirstate[abs] == 'r': | |
303 | removed.append(abs) |
|
308 | removed.append(abs) | |
304 | elif repo.dirstate[abs] == 'a': |
|
309 | elif repo.dirstate[abs] == 'a': | |
305 | added.append(abs) |
|
310 | added.append(abs) | |
306 | copies = {} |
|
311 | copies = {} | |
307 | if similarity > 0: |
|
312 | if similarity > 0: | |
308 | for old, new, score in similar.findrenames(repo, |
|
313 | for old, new, score in similar.findrenames(repo, | |
309 | added + unknown, removed + deleted, similarity): |
|
314 | added + unknown, removed + deleted, similarity): | |
310 | if repo.ui.verbose or not m.exact(old) or not m.exact(new): |
|
315 | if repo.ui.verbose or not m.exact(old) or not m.exact(new): | |
311 | repo.ui.status(_('recording removal of %s as rename to %s ' |
|
316 | repo.ui.status(_('recording removal of %s as rename to %s ' | |
312 | '(%d%% similar)\n') % |
|
317 | '(%d%% similar)\n') % | |
313 | (m.rel(old), m.rel(new), score * 100)) |
|
318 | (m.rel(old), m.rel(new), score * 100)) | |
314 | copies[new] = old |
|
319 | copies[new] = old | |
315 |
|
320 | |||
316 | if not dry_run: |
|
321 | if not dry_run: | |
317 | wctx = repo[None] |
|
322 | wctx = repo[None] | |
318 | wlock = repo.wlock() |
|
323 | wlock = repo.wlock() | |
319 | try: |
|
324 | try: | |
320 | wctx.remove(deleted) |
|
325 | wctx.remove(deleted) | |
321 | wctx.add(unknown) |
|
326 | wctx.add(unknown) | |
322 | for new, old in copies.iteritems(): |
|
327 | for new, old in copies.iteritems(): | |
323 | wctx.copy(old, new) |
|
328 | wctx.copy(old, new) | |
324 | finally: |
|
329 | finally: | |
325 | wlock.release() |
|
330 | wlock.release() | |
326 |
|
331 | |||
327 | def updatedir(ui, repo, patches, similarity=0): |
|
332 | def updatedir(ui, repo, patches, similarity=0): | |
328 | '''Update dirstate after patch application according to metadata''' |
|
333 | '''Update dirstate after patch application according to metadata''' | |
329 | if not patches: |
|
334 | if not patches: | |
330 | return |
|
335 | return | |
331 | copies = [] |
|
336 | copies = [] | |
332 | removes = set() |
|
337 | removes = set() | |
333 | cfiles = patches.keys() |
|
338 | cfiles = patches.keys() | |
334 | cwd = repo.getcwd() |
|
339 | cwd = repo.getcwd() | |
335 | if cwd: |
|
340 | if cwd: | |
336 | cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] |
|
341 | cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] | |
337 | for f in patches: |
|
342 | for f in patches: | |
338 | gp = patches[f] |
|
343 | gp = patches[f] | |
339 | if not gp: |
|
344 | if not gp: | |
340 | continue |
|
345 | continue | |
341 | if gp.op == 'RENAME': |
|
346 | if gp.op == 'RENAME': | |
342 | copies.append((gp.oldpath, gp.path)) |
|
347 | copies.append((gp.oldpath, gp.path)) | |
343 | removes.add(gp.oldpath) |
|
348 | removes.add(gp.oldpath) | |
344 | elif gp.op == 'COPY': |
|
349 | elif gp.op == 'COPY': | |
345 | copies.append((gp.oldpath, gp.path)) |
|
350 | copies.append((gp.oldpath, gp.path)) | |
346 | elif gp.op == 'DELETE': |
|
351 | elif gp.op == 'DELETE': | |
347 | removes.add(gp.path) |
|
352 | removes.add(gp.path) | |
348 |
|
353 | |||
349 | wctx = repo[None] |
|
354 | wctx = repo[None] | |
350 | for src, dst in copies: |
|
355 | for src, dst in copies: | |
351 | dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd) |
|
356 | dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd) | |
352 | if (not similarity) and removes: |
|
357 | if (not similarity) and removes: | |
353 | wctx.remove(sorted(removes), True) |
|
358 | wctx.remove(sorted(removes), True) | |
354 |
|
359 | |||
355 | for f in patches: |
|
360 | for f in patches: | |
356 | gp = patches[f] |
|
361 | gp = patches[f] | |
357 | if gp and gp.mode: |
|
362 | if gp and gp.mode: | |
358 | islink, isexec = gp.mode |
|
363 | islink, isexec = gp.mode | |
359 | dst = repo.wjoin(gp.path) |
|
364 | dst = repo.wjoin(gp.path) | |
360 | # patch won't create empty files |
|
365 | # patch won't create empty files | |
361 | if gp.op == 'ADD' and not os.path.lexists(dst): |
|
366 | if gp.op == 'ADD' and not os.path.lexists(dst): | |
362 | flags = (isexec and 'x' or '') + (islink and 'l' or '') |
|
367 | flags = (isexec and 'x' or '') + (islink and 'l' or '') | |
363 | repo.wwrite(gp.path, '', flags) |
|
368 | repo.wwrite(gp.path, '', flags) | |
364 | util.set_flags(dst, islink, isexec) |
|
369 | util.set_flags(dst, islink, isexec) | |
365 | addremove(repo, cfiles, similarity=similarity) |
|
370 | addremove(repo, cfiles, similarity=similarity) | |
366 | files = patches.keys() |
|
371 | files = patches.keys() | |
367 | files.extend([r for r in removes if r not in files]) |
|
372 | files.extend([r for r in removes if r not in files]) | |
368 | return sorted(files) |
|
373 | return sorted(files) | |
369 |
|
374 | |||
370 | def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): |
|
375 | def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): | |
371 | """Update the dirstate to reflect the intent of copying src to dst. For |
|
376 | """Update the dirstate to reflect the intent of copying src to dst. For | |
372 | different reasons it might not end with dst being marked as copied from src. |
|
377 | different reasons it might not end with dst being marked as copied from src. | |
373 | """ |
|
378 | """ | |
374 | origsrc = repo.dirstate.copied(src) or src |
|
379 | origsrc = repo.dirstate.copied(src) or src | |
375 | if dst == origsrc: # copying back a copy? |
|
380 | if dst == origsrc: # copying back a copy? | |
376 | if repo.dirstate[dst] not in 'mn' and not dryrun: |
|
381 | if repo.dirstate[dst] not in 'mn' and not dryrun: | |
377 | repo.dirstate.normallookup(dst) |
|
382 | repo.dirstate.normallookup(dst) | |
378 | else: |
|
383 | else: | |
379 | if repo.dirstate[origsrc] == 'a' and origsrc == src: |
|
384 | if repo.dirstate[origsrc] == 'a' and origsrc == src: | |
380 | if not ui.quiet: |
|
385 | if not ui.quiet: | |
381 | ui.warn(_("%s has not been committed yet, so no copy " |
|
386 | ui.warn(_("%s has not been committed yet, so no copy " | |
382 | "data will be stored for %s.\n") |
|
387 | "data will be stored for %s.\n") | |
383 | % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd))) |
|
388 | % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd))) | |
384 | if repo.dirstate[dst] in '?r' and not dryrun: |
|
389 | if repo.dirstate[dst] in '?r' and not dryrun: | |
385 | wctx.add([dst]) |
|
390 | wctx.add([dst]) | |
386 | elif not dryrun: |
|
391 | elif not dryrun: | |
387 | wctx.copy(origsrc, dst) |
|
392 | wctx.copy(origsrc, dst) | |
388 |
|
393 | |||
389 | def copy(ui, repo, pats, opts, rename=False): |
|
394 | def copy(ui, repo, pats, opts, rename=False): | |
390 | # called with the repo lock held |
|
395 | # called with the repo lock held | |
391 | # |
|
396 | # | |
392 | # hgsep => pathname that uses "/" to separate directories |
|
397 | # hgsep => pathname that uses "/" to separate directories | |
393 | # ossep => pathname that uses os.sep to separate directories |
|
398 | # ossep => pathname that uses os.sep to separate directories | |
394 | cwd = repo.getcwd() |
|
399 | cwd = repo.getcwd() | |
395 | targets = {} |
|
400 | targets = {} | |
396 | after = opts.get("after") |
|
401 | after = opts.get("after") | |
397 | dryrun = opts.get("dry_run") |
|
402 | dryrun = opts.get("dry_run") | |
398 | wctx = repo[None] |
|
403 | wctx = repo[None] | |
399 |
|
404 | |||
400 | def walkpat(pat): |
|
405 | def walkpat(pat): | |
401 | srcs = [] |
|
406 | srcs = [] | |
402 | badstates = after and '?' or '?r' |
|
407 | badstates = after and '?' or '?r' | |
403 | m = match(repo, [pat], opts, globbed=True) |
|
408 | m = match(repo, [pat], opts, globbed=True) | |
404 | for abs in repo.walk(m): |
|
409 | for abs in repo.walk(m): | |
405 | state = repo.dirstate[abs] |
|
410 | state = repo.dirstate[abs] | |
406 | rel = m.rel(abs) |
|
411 | rel = m.rel(abs) | |
407 | exact = m.exact(abs) |
|
412 | exact = m.exact(abs) | |
408 | if state in badstates: |
|
413 | if state in badstates: | |
409 | if exact and state == '?': |
|
414 | if exact and state == '?': | |
410 | ui.warn(_('%s: not copying - file is not managed\n') % rel) |
|
415 | ui.warn(_('%s: not copying - file is not managed\n') % rel) | |
411 | if exact and state == 'r': |
|
416 | if exact and state == 'r': | |
412 | ui.warn(_('%s: not copying - file has been marked for' |
|
417 | ui.warn(_('%s: not copying - file has been marked for' | |
413 | ' remove\n') % rel) |
|
418 | ' remove\n') % rel) | |
414 | continue |
|
419 | continue | |
415 | # abs: hgsep |
|
420 | # abs: hgsep | |
416 | # rel: ossep |
|
421 | # rel: ossep | |
417 | srcs.append((abs, rel, exact)) |
|
422 | srcs.append((abs, rel, exact)) | |
418 | return srcs |
|
423 | return srcs | |
419 |
|
424 | |||
420 | # abssrc: hgsep |
|
425 | # abssrc: hgsep | |
421 | # relsrc: ossep |
|
426 | # relsrc: ossep | |
422 | # otarget: ossep |
|
427 | # otarget: ossep | |
423 | def copyfile(abssrc, relsrc, otarget, exact): |
|
428 | def copyfile(abssrc, relsrc, otarget, exact): | |
424 | abstarget = util.canonpath(repo.root, cwd, otarget) |
|
429 | abstarget = util.canonpath(repo.root, cwd, otarget) | |
425 | reltarget = repo.pathto(abstarget, cwd) |
|
430 | reltarget = repo.pathto(abstarget, cwd) | |
426 | target = repo.wjoin(abstarget) |
|
431 | target = repo.wjoin(abstarget) | |
427 | src = repo.wjoin(abssrc) |
|
432 | src = repo.wjoin(abssrc) | |
428 | state = repo.dirstate[abstarget] |
|
433 | state = repo.dirstate[abstarget] | |
429 |
|
434 | |||
430 | # check for collisions |
|
435 | # check for collisions | |
431 | prevsrc = targets.get(abstarget) |
|
436 | prevsrc = targets.get(abstarget) | |
432 | if prevsrc is not None: |
|
437 | if prevsrc is not None: | |
433 | ui.warn(_('%s: not overwriting - %s collides with %s\n') % |
|
438 | ui.warn(_('%s: not overwriting - %s collides with %s\n') % | |
434 | (reltarget, repo.pathto(abssrc, cwd), |
|
439 | (reltarget, repo.pathto(abssrc, cwd), | |
435 | repo.pathto(prevsrc, cwd))) |
|
440 | repo.pathto(prevsrc, cwd))) | |
436 | return |
|
441 | return | |
437 |
|
442 | |||
438 | # check for overwrites |
|
443 | # check for overwrites | |
439 | exists = os.path.lexists(target) |
|
444 | exists = os.path.lexists(target) | |
440 | if not after and exists or after and state in 'mn': |
|
445 | if not after and exists or after and state in 'mn': | |
441 | if not opts['force']: |
|
446 | if not opts['force']: | |
442 | ui.warn(_('%s: not overwriting - file exists\n') % |
|
447 | ui.warn(_('%s: not overwriting - file exists\n') % | |
443 | reltarget) |
|
448 | reltarget) | |
444 | return |
|
449 | return | |
445 |
|
450 | |||
446 | if after: |
|
451 | if after: | |
447 | if not exists: |
|
452 | if not exists: | |
448 | if rename: |
|
453 | if rename: | |
449 | ui.warn(_('%s: not recording move - %s does not exist\n') % |
|
454 | ui.warn(_('%s: not recording move - %s does not exist\n') % | |
450 | (relsrc, reltarget)) |
|
455 | (relsrc, reltarget)) | |
451 | else: |
|
456 | else: | |
452 | ui.warn(_('%s: not recording copy - %s does not exist\n') % |
|
457 | ui.warn(_('%s: not recording copy - %s does not exist\n') % | |
453 | (relsrc, reltarget)) |
|
458 | (relsrc, reltarget)) | |
454 | return |
|
459 | return | |
455 | elif not dryrun: |
|
460 | elif not dryrun: | |
456 | try: |
|
461 | try: | |
457 | if exists: |
|
462 | if exists: | |
458 | os.unlink(target) |
|
463 | os.unlink(target) | |
459 | targetdir = os.path.dirname(target) or '.' |
|
464 | targetdir = os.path.dirname(target) or '.' | |
460 | if not os.path.isdir(targetdir): |
|
465 | if not os.path.isdir(targetdir): | |
461 | os.makedirs(targetdir) |
|
466 | os.makedirs(targetdir) | |
462 | util.copyfile(src, target) |
|
467 | util.copyfile(src, target) | |
463 | except IOError, inst: |
|
468 | except IOError, inst: | |
464 | if inst.errno == errno.ENOENT: |
|
469 | if inst.errno == errno.ENOENT: | |
465 | ui.warn(_('%s: deleted in working copy\n') % relsrc) |
|
470 | ui.warn(_('%s: deleted in working copy\n') % relsrc) | |
466 | else: |
|
471 | else: | |
467 | ui.warn(_('%s: cannot copy - %s\n') % |
|
472 | ui.warn(_('%s: cannot copy - %s\n') % | |
468 | (relsrc, inst.strerror)) |
|
473 | (relsrc, inst.strerror)) | |
469 | return True # report a failure |
|
474 | return True # report a failure | |
470 |
|
475 | |||
471 | if ui.verbose or not exact: |
|
476 | if ui.verbose or not exact: | |
472 | if rename: |
|
477 | if rename: | |
473 | ui.status(_('moving %s to %s\n') % (relsrc, reltarget)) |
|
478 | ui.status(_('moving %s to %s\n') % (relsrc, reltarget)) | |
474 | else: |
|
479 | else: | |
475 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
|
480 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | |
476 |
|
481 | |||
477 | targets[abstarget] = abssrc |
|
482 | targets[abstarget] = abssrc | |
478 |
|
483 | |||
479 | # fix up dirstate |
|
484 | # fix up dirstate | |
480 | dirstatecopy(ui, repo, wctx, abssrc, abstarget, dryrun=dryrun, cwd=cwd) |
|
485 | dirstatecopy(ui, repo, wctx, abssrc, abstarget, dryrun=dryrun, cwd=cwd) | |
481 | if rename and not dryrun: |
|
486 | if rename and not dryrun: | |
482 | wctx.remove([abssrc], not after) |
|
487 | wctx.remove([abssrc], not after) | |
483 |
|
488 | |||
484 | # pat: ossep |
|
489 | # pat: ossep | |
485 | # dest ossep |
|
490 | # dest ossep | |
486 | # srcs: list of (hgsep, hgsep, ossep, bool) |
|
491 | # srcs: list of (hgsep, hgsep, ossep, bool) | |
487 | # return: function that takes hgsep and returns ossep |
|
492 | # return: function that takes hgsep and returns ossep | |
488 | def targetpathfn(pat, dest, srcs): |
|
493 | def targetpathfn(pat, dest, srcs): | |
489 | if os.path.isdir(pat): |
|
494 | if os.path.isdir(pat): | |
490 | abspfx = util.canonpath(repo.root, cwd, pat) |
|
495 | abspfx = util.canonpath(repo.root, cwd, pat) | |
491 | abspfx = util.localpath(abspfx) |
|
496 | abspfx = util.localpath(abspfx) | |
492 | if destdirexists: |
|
497 | if destdirexists: | |
493 | striplen = len(os.path.split(abspfx)[0]) |
|
498 | striplen = len(os.path.split(abspfx)[0]) | |
494 | else: |
|
499 | else: | |
495 | striplen = len(abspfx) |
|
500 | striplen = len(abspfx) | |
496 | if striplen: |
|
501 | if striplen: | |
497 | striplen += len(os.sep) |
|
502 | striplen += len(os.sep) | |
498 | res = lambda p: os.path.join(dest, util.localpath(p)[striplen:]) |
|
503 | res = lambda p: os.path.join(dest, util.localpath(p)[striplen:]) | |
499 | elif destdirexists: |
|
504 | elif destdirexists: | |
500 | res = lambda p: os.path.join(dest, |
|
505 | res = lambda p: os.path.join(dest, | |
501 | os.path.basename(util.localpath(p))) |
|
506 | os.path.basename(util.localpath(p))) | |
502 | else: |
|
507 | else: | |
503 | res = lambda p: dest |
|
508 | res = lambda p: dest | |
504 | return res |
|
509 | return res | |
505 |
|
510 | |||
506 | # pat: ossep |
|
511 | # pat: ossep | |
507 | # dest ossep |
|
512 | # dest ossep | |
508 | # srcs: list of (hgsep, hgsep, ossep, bool) |
|
513 | # srcs: list of (hgsep, hgsep, ossep, bool) | |
509 | # return: function that takes hgsep and returns ossep |
|
514 | # return: function that takes hgsep and returns ossep | |
510 | def targetpathafterfn(pat, dest, srcs): |
|
515 | def targetpathafterfn(pat, dest, srcs): | |
511 | if matchmod.patkind(pat): |
|
516 | if matchmod.patkind(pat): | |
512 | # a mercurial pattern |
|
517 | # a mercurial pattern | |
513 | res = lambda p: os.path.join(dest, |
|
518 | res = lambda p: os.path.join(dest, | |
514 | os.path.basename(util.localpath(p))) |
|
519 | os.path.basename(util.localpath(p))) | |
515 | else: |
|
520 | else: | |
516 | abspfx = util.canonpath(repo.root, cwd, pat) |
|
521 | abspfx = util.canonpath(repo.root, cwd, pat) | |
517 | if len(abspfx) < len(srcs[0][0]): |
|
522 | if len(abspfx) < len(srcs[0][0]): | |
518 | # A directory. Either the target path contains the last |
|
523 | # A directory. Either the target path contains the last | |
519 | # component of the source path or it does not. |
|
524 | # component of the source path or it does not. | |
520 | def evalpath(striplen): |
|
525 | def evalpath(striplen): | |
521 | score = 0 |
|
526 | score = 0 | |
522 | for s in srcs: |
|
527 | for s in srcs: | |
523 | t = os.path.join(dest, util.localpath(s[0])[striplen:]) |
|
528 | t = os.path.join(dest, util.localpath(s[0])[striplen:]) | |
524 | if os.path.lexists(t): |
|
529 | if os.path.lexists(t): | |
525 | score += 1 |
|
530 | score += 1 | |
526 | return score |
|
531 | return score | |
527 |
|
532 | |||
528 | abspfx = util.localpath(abspfx) |
|
533 | abspfx = util.localpath(abspfx) | |
529 | striplen = len(abspfx) |
|
534 | striplen = len(abspfx) | |
530 | if striplen: |
|
535 | if striplen: | |
531 | striplen += len(os.sep) |
|
536 | striplen += len(os.sep) | |
532 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): |
|
537 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): | |
533 | score = evalpath(striplen) |
|
538 | score = evalpath(striplen) | |
534 | striplen1 = len(os.path.split(abspfx)[0]) |
|
539 | striplen1 = len(os.path.split(abspfx)[0]) | |
535 | if striplen1: |
|
540 | if striplen1: | |
536 | striplen1 += len(os.sep) |
|
541 | striplen1 += len(os.sep) | |
537 | if evalpath(striplen1) > score: |
|
542 | if evalpath(striplen1) > score: | |
538 | striplen = striplen1 |
|
543 | striplen = striplen1 | |
539 | res = lambda p: os.path.join(dest, |
|
544 | res = lambda p: os.path.join(dest, | |
540 | util.localpath(p)[striplen:]) |
|
545 | util.localpath(p)[striplen:]) | |
541 | else: |
|
546 | else: | |
542 | # a file |
|
547 | # a file | |
543 | if destdirexists: |
|
548 | if destdirexists: | |
544 | res = lambda p: os.path.join(dest, |
|
549 | res = lambda p: os.path.join(dest, | |
545 | os.path.basename(util.localpath(p))) |
|
550 | os.path.basename(util.localpath(p))) | |
546 | else: |
|
551 | else: | |
547 | res = lambda p: dest |
|
552 | res = lambda p: dest | |
548 | return res |
|
553 | return res | |
549 |
|
554 | |||
550 |
|
555 | |||
551 | pats = expandpats(pats) |
|
556 | pats = expandpats(pats) | |
552 | if not pats: |
|
557 | if not pats: | |
553 | raise util.Abort(_('no source or destination specified')) |
|
558 | raise util.Abort(_('no source or destination specified')) | |
554 | if len(pats) == 1: |
|
559 | if len(pats) == 1: | |
555 | raise util.Abort(_('no destination specified')) |
|
560 | raise util.Abort(_('no destination specified')) | |
556 | dest = pats.pop() |
|
561 | dest = pats.pop() | |
557 | destdirexists = os.path.isdir(dest) and not os.path.islink(dest) |
|
562 | destdirexists = os.path.isdir(dest) and not os.path.islink(dest) | |
558 | if not destdirexists: |
|
563 | if not destdirexists: | |
559 | if len(pats) > 1 or matchmod.patkind(pats[0]): |
|
564 | if len(pats) > 1 or matchmod.patkind(pats[0]): | |
560 | raise util.Abort(_('with multiple sources, destination must be an ' |
|
565 | raise util.Abort(_('with multiple sources, destination must be an ' | |
561 | 'existing directory')) |
|
566 | 'existing directory')) | |
562 | if util.endswithsep(dest): |
|
567 | if util.endswithsep(dest): | |
563 | raise util.Abort(_('destination %s is not a directory') % dest) |
|
568 | raise util.Abort(_('destination %s is not a directory') % dest) | |
564 |
|
569 | |||
565 | tfn = targetpathfn |
|
570 | tfn = targetpathfn | |
566 | if after: |
|
571 | if after: | |
567 | tfn = targetpathafterfn |
|
572 | tfn = targetpathafterfn | |
568 | copylist = [] |
|
573 | copylist = [] | |
569 | for pat in pats: |
|
574 | for pat in pats: | |
570 | srcs = walkpat(pat) |
|
575 | srcs = walkpat(pat) | |
571 | if not srcs: |
|
576 | if not srcs: | |
572 | continue |
|
577 | continue | |
573 | copylist.append((tfn(pat, dest, srcs), srcs)) |
|
578 | copylist.append((tfn(pat, dest, srcs), srcs)) | |
574 | if not copylist: |
|
579 | if not copylist: | |
575 | raise util.Abort(_('no files to copy')) |
|
580 | raise util.Abort(_('no files to copy')) | |
576 |
|
581 | |||
577 | errors = 0 |
|
582 | errors = 0 | |
578 | for targetpath, srcs in copylist: |
|
583 | for targetpath, srcs in copylist: | |
579 | for abssrc, relsrc, exact in srcs: |
|
584 | for abssrc, relsrc, exact in srcs: | |
580 | if copyfile(abssrc, relsrc, targetpath(abssrc), exact): |
|
585 | if copyfile(abssrc, relsrc, targetpath(abssrc), exact): | |
581 | errors += 1 |
|
586 | errors += 1 | |
582 |
|
587 | |||
583 | if errors: |
|
588 | if errors: | |
584 | ui.warn(_('(consider using --after)\n')) |
|
589 | ui.warn(_('(consider using --after)\n')) | |
585 |
|
590 | |||
586 | return errors != 0 |
|
591 | return errors != 0 | |
587 |
|
592 | |||
588 | def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, |
|
593 | def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, | |
589 | runargs=None, appendpid=False): |
|
594 | runargs=None, appendpid=False): | |
590 | '''Run a command as a service.''' |
|
595 | '''Run a command as a service.''' | |
591 |
|
596 | |||
592 | if opts['daemon'] and not opts['daemon_pipefds']: |
|
597 | if opts['daemon'] and not opts['daemon_pipefds']: | |
593 | # Signal child process startup with file removal |
|
598 | # Signal child process startup with file removal | |
594 | lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') |
|
599 | lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') | |
595 | os.close(lockfd) |
|
600 | os.close(lockfd) | |
596 | try: |
|
601 | try: | |
597 | if not runargs: |
|
602 | if not runargs: | |
598 | runargs = util.hgcmd() + sys.argv[1:] |
|
603 | runargs = util.hgcmd() + sys.argv[1:] | |
599 | runargs.append('--daemon-pipefds=%s' % lockpath) |
|
604 | runargs.append('--daemon-pipefds=%s' % lockpath) | |
600 | # Don't pass --cwd to the child process, because we've already |
|
605 | # Don't pass --cwd to the child process, because we've already | |
601 | # changed directory. |
|
606 | # changed directory. | |
602 | for i in xrange(1, len(runargs)): |
|
607 | for i in xrange(1, len(runargs)): | |
603 | if runargs[i].startswith('--cwd='): |
|
608 | if runargs[i].startswith('--cwd='): | |
604 | del runargs[i] |
|
609 | del runargs[i] | |
605 | break |
|
610 | break | |
606 | elif runargs[i].startswith('--cwd'): |
|
611 | elif runargs[i].startswith('--cwd'): | |
607 | del runargs[i:i + 2] |
|
612 | del runargs[i:i + 2] | |
608 | break |
|
613 | break | |
609 | def condfn(): |
|
614 | def condfn(): | |
610 | return not os.path.exists(lockpath) |
|
615 | return not os.path.exists(lockpath) | |
611 | pid = util.rundetached(runargs, condfn) |
|
616 | pid = util.rundetached(runargs, condfn) | |
612 | if pid < 0: |
|
617 | if pid < 0: | |
613 | raise util.Abort(_('child process failed to start')) |
|
618 | raise util.Abort(_('child process failed to start')) | |
614 | finally: |
|
619 | finally: | |
615 | try: |
|
620 | try: | |
616 | os.unlink(lockpath) |
|
621 | os.unlink(lockpath) | |
617 | except OSError, e: |
|
622 | except OSError, e: | |
618 | if e.errno != errno.ENOENT: |
|
623 | if e.errno != errno.ENOENT: | |
619 | raise |
|
624 | raise | |
620 | if parentfn: |
|
625 | if parentfn: | |
621 | return parentfn(pid) |
|
626 | return parentfn(pid) | |
622 | else: |
|
627 | else: | |
623 | return |
|
628 | return | |
624 |
|
629 | |||
625 | if initfn: |
|
630 | if initfn: | |
626 | initfn() |
|
631 | initfn() | |
627 |
|
632 | |||
628 | if opts['pid_file']: |
|
633 | if opts['pid_file']: | |
629 | mode = appendpid and 'a' or 'w' |
|
634 | mode = appendpid and 'a' or 'w' | |
630 | fp = open(opts['pid_file'], mode) |
|
635 | fp = open(opts['pid_file'], mode) | |
631 | fp.write(str(os.getpid()) + '\n') |
|
636 | fp.write(str(os.getpid()) + '\n') | |
632 | fp.close() |
|
637 | fp.close() | |
633 |
|
638 | |||
634 | if opts['daemon_pipefds']: |
|
639 | if opts['daemon_pipefds']: | |
635 | lockpath = opts['daemon_pipefds'] |
|
640 | lockpath = opts['daemon_pipefds'] | |
636 | try: |
|
641 | try: | |
637 | os.setsid() |
|
642 | os.setsid() | |
638 | except AttributeError: |
|
643 | except AttributeError: | |
639 | pass |
|
644 | pass | |
640 | os.unlink(lockpath) |
|
645 | os.unlink(lockpath) | |
641 | util.hidewindow() |
|
646 | util.hidewindow() | |
642 | sys.stdout.flush() |
|
647 | sys.stdout.flush() | |
643 | sys.stderr.flush() |
|
648 | sys.stderr.flush() | |
644 |
|
649 | |||
645 | nullfd = os.open(util.nulldev, os.O_RDWR) |
|
650 | nullfd = os.open(util.nulldev, os.O_RDWR) | |
646 | logfilefd = nullfd |
|
651 | logfilefd = nullfd | |
647 | if logfile: |
|
652 | if logfile: | |
648 | logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND) |
|
653 | logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND) | |
649 | os.dup2(nullfd, 0) |
|
654 | os.dup2(nullfd, 0) | |
650 | os.dup2(logfilefd, 1) |
|
655 | os.dup2(logfilefd, 1) | |
651 | os.dup2(logfilefd, 2) |
|
656 | os.dup2(logfilefd, 2) | |
652 | if nullfd not in (0, 1, 2): |
|
657 | if nullfd not in (0, 1, 2): | |
653 | os.close(nullfd) |
|
658 | os.close(nullfd) | |
654 | if logfile and logfilefd not in (0, 1, 2): |
|
659 | if logfile and logfilefd not in (0, 1, 2): | |
655 | os.close(logfilefd) |
|
660 | os.close(logfilefd) | |
656 |
|
661 | |||
657 | if runfn: |
|
662 | if runfn: | |
658 | return runfn() |
|
663 | return runfn() | |
659 |
|
664 | |||
660 | def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, |
|
665 | def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, | |
661 | opts=None): |
|
666 | opts=None): | |
662 | '''export changesets as hg patches.''' |
|
667 | '''export changesets as hg patches.''' | |
663 |
|
668 | |||
664 | total = len(revs) |
|
669 | total = len(revs) | |
665 | revwidth = max([len(str(rev)) for rev in revs]) |
|
670 | revwidth = max([len(str(rev)) for rev in revs]) | |
666 |
|
671 | |||
667 | def single(rev, seqno, fp): |
|
672 | def single(rev, seqno, fp): | |
668 | ctx = repo[rev] |
|
673 | ctx = repo[rev] | |
669 | node = ctx.node() |
|
674 | node = ctx.node() | |
670 | parents = [p.node() for p in ctx.parents() if p] |
|
675 | parents = [p.node() for p in ctx.parents() if p] | |
671 | branch = ctx.branch() |
|
676 | branch = ctx.branch() | |
672 | if switch_parent: |
|
677 | if switch_parent: | |
673 | parents.reverse() |
|
678 | parents.reverse() | |
674 | prev = (parents and parents[0]) or nullid |
|
679 | prev = (parents and parents[0]) or nullid | |
675 |
|
680 | |||
676 | if not fp: |
|
681 | if not fp: | |
677 | fp = make_file(repo, template, node, total=total, seqno=seqno, |
|
682 | fp = make_file(repo, template, node, total=total, seqno=seqno, | |
678 | revwidth=revwidth, mode='ab') |
|
683 | revwidth=revwidth, mode='ab') | |
679 | if fp != sys.stdout and hasattr(fp, 'name'): |
|
684 | if fp != sys.stdout and hasattr(fp, 'name'): | |
680 | repo.ui.note("%s\n" % fp.name) |
|
685 | repo.ui.note("%s\n" % fp.name) | |
681 |
|
686 | |||
682 | fp.write("# HG changeset patch\n") |
|
687 | fp.write("# HG changeset patch\n") | |
683 | fp.write("# User %s\n" % ctx.user()) |
|
688 | fp.write("# User %s\n" % ctx.user()) | |
684 | fp.write("# Date %d %d\n" % ctx.date()) |
|
689 | fp.write("# Date %d %d\n" % ctx.date()) | |
685 | if branch and branch != 'default': |
|
690 | if branch and branch != 'default': | |
686 | fp.write("# Branch %s\n" % branch) |
|
691 | fp.write("# Branch %s\n" % branch) | |
687 | fp.write("# Node ID %s\n" % hex(node)) |
|
692 | fp.write("# Node ID %s\n" % hex(node)) | |
688 | fp.write("# Parent %s\n" % hex(prev)) |
|
693 | fp.write("# Parent %s\n" % hex(prev)) | |
689 | if len(parents) > 1: |
|
694 | if len(parents) > 1: | |
690 | fp.write("# Parent %s\n" % hex(parents[1])) |
|
695 | fp.write("# Parent %s\n" % hex(parents[1])) | |
691 | fp.write(ctx.description().rstrip()) |
|
696 | fp.write(ctx.description().rstrip()) | |
692 | fp.write("\n\n") |
|
697 | fp.write("\n\n") | |
693 |
|
698 | |||
694 | for chunk in patch.diff(repo, prev, node, opts=opts): |
|
699 | for chunk in patch.diff(repo, prev, node, opts=opts): | |
695 | fp.write(chunk) |
|
700 | fp.write(chunk) | |
696 |
|
701 | |||
697 | for seqno, rev in enumerate(revs): |
|
702 | for seqno, rev in enumerate(revs): | |
698 | single(rev, seqno + 1, fp) |
|
703 | single(rev, seqno + 1, fp) | |
699 |
|
704 | |||
700 | def diffordiffstat(ui, repo, diffopts, node1, node2, match, |
|
705 | def diffordiffstat(ui, repo, diffopts, node1, node2, match, | |
701 | changes=None, stat=False, fp=None, prefix='', |
|
706 | changes=None, stat=False, fp=None, prefix='', | |
702 | listsubrepos=False): |
|
707 | listsubrepos=False): | |
703 | '''show diff or diffstat.''' |
|
708 | '''show diff or diffstat.''' | |
704 | if fp is None: |
|
709 | if fp is None: | |
705 | write = ui.write |
|
710 | write = ui.write | |
706 | else: |
|
711 | else: | |
707 | def write(s, **kw): |
|
712 | def write(s, **kw): | |
708 | fp.write(s) |
|
713 | fp.write(s) | |
709 |
|
714 | |||
710 | if stat: |
|
715 | if stat: | |
711 | diffopts = diffopts.copy(context=0) |
|
716 | diffopts = diffopts.copy(context=0) | |
712 | width = 80 |
|
717 | width = 80 | |
713 | if not ui.plain(): |
|
718 | if not ui.plain(): | |
714 | width = ui.termwidth() |
|
719 | width = ui.termwidth() | |
715 | chunks = patch.diff(repo, node1, node2, match, changes, diffopts, |
|
720 | chunks = patch.diff(repo, node1, node2, match, changes, diffopts, | |
716 | prefix=prefix) |
|
721 | prefix=prefix) | |
717 | for chunk, label in patch.diffstatui(util.iterlines(chunks), |
|
722 | for chunk, label in patch.diffstatui(util.iterlines(chunks), | |
718 | width=width, |
|
723 | width=width, | |
719 | git=diffopts.git): |
|
724 | git=diffopts.git): | |
720 | write(chunk, label=label) |
|
725 | write(chunk, label=label) | |
721 | else: |
|
726 | else: | |
722 | for chunk, label in patch.diffui(repo, node1, node2, match, |
|
727 | for chunk, label in patch.diffui(repo, node1, node2, match, | |
723 | changes, diffopts, prefix=prefix): |
|
728 | changes, diffopts, prefix=prefix): | |
724 | write(chunk, label=label) |
|
729 | write(chunk, label=label) | |
725 |
|
730 | |||
726 | if listsubrepos: |
|
731 | if listsubrepos: | |
727 | ctx1 = repo[node1] |
|
732 | ctx1 = repo[node1] | |
728 | ctx2 = repo[node2] |
|
733 | ctx2 = repo[node2] | |
729 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): |
|
734 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): | |
730 | if node2 is not None: |
|
735 | if node2 is not None: | |
731 | node2 = ctx2.substate[subpath][1] |
|
736 | node2 = ctx2.substate[subpath][1] | |
732 | submatch = matchmod.narrowmatcher(subpath, match) |
|
737 | submatch = matchmod.narrowmatcher(subpath, match) | |
733 | sub.diff(diffopts, node2, submatch, changes=changes, |
|
738 | sub.diff(diffopts, node2, submatch, changes=changes, | |
734 | stat=stat, fp=fp, prefix=prefix) |
|
739 | stat=stat, fp=fp, prefix=prefix) | |
735 |
|
740 | |||
736 | class changeset_printer(object): |
|
741 | class changeset_printer(object): | |
737 | '''show changeset information when templating not requested.''' |
|
742 | '''show changeset information when templating not requested.''' | |
738 |
|
743 | |||
739 | def __init__(self, ui, repo, patch, diffopts, buffered): |
|
744 | def __init__(self, ui, repo, patch, diffopts, buffered): | |
740 | self.ui = ui |
|
745 | self.ui = ui | |
741 | self.repo = repo |
|
746 | self.repo = repo | |
742 | self.buffered = buffered |
|
747 | self.buffered = buffered | |
743 | self.patch = patch |
|
748 | self.patch = patch | |
744 | self.diffopts = diffopts |
|
749 | self.diffopts = diffopts | |
745 | self.header = {} |
|
750 | self.header = {} | |
746 | self.hunk = {} |
|
751 | self.hunk = {} | |
747 | self.lastheader = None |
|
752 | self.lastheader = None | |
748 | self.footer = None |
|
753 | self.footer = None | |
749 |
|
754 | |||
750 | def flush(self, rev): |
|
755 | def flush(self, rev): | |
751 | if rev in self.header: |
|
756 | if rev in self.header: | |
752 | h = self.header[rev] |
|
757 | h = self.header[rev] | |
753 | if h != self.lastheader: |
|
758 | if h != self.lastheader: | |
754 | self.lastheader = h |
|
759 | self.lastheader = h | |
755 | self.ui.write(h) |
|
760 | self.ui.write(h) | |
756 | del self.header[rev] |
|
761 | del self.header[rev] | |
757 | if rev in self.hunk: |
|
762 | if rev in self.hunk: | |
758 | self.ui.write(self.hunk[rev]) |
|
763 | self.ui.write(self.hunk[rev]) | |
759 | del self.hunk[rev] |
|
764 | del self.hunk[rev] | |
760 | return 1 |
|
765 | return 1 | |
761 | return 0 |
|
766 | return 0 | |
762 |
|
767 | |||
763 | def close(self): |
|
768 | def close(self): | |
764 | if self.footer: |
|
769 | if self.footer: | |
765 | self.ui.write(self.footer) |
|
770 | self.ui.write(self.footer) | |
766 |
|
771 | |||
767 | def show(self, ctx, copies=None, matchfn=None, **props): |
|
772 | def show(self, ctx, copies=None, matchfn=None, **props): | |
768 | if self.buffered: |
|
773 | if self.buffered: | |
769 | self.ui.pushbuffer() |
|
774 | self.ui.pushbuffer() | |
770 | self._show(ctx, copies, matchfn, props) |
|
775 | self._show(ctx, copies, matchfn, props) | |
771 | self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True) |
|
776 | self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True) | |
772 | else: |
|
777 | else: | |
773 | self._show(ctx, copies, matchfn, props) |
|
778 | self._show(ctx, copies, matchfn, props) | |
774 |
|
779 | |||
775 | def _show(self, ctx, copies, matchfn, props): |
|
780 | def _show(self, ctx, copies, matchfn, props): | |
776 | '''show a single changeset or file revision''' |
|
781 | '''show a single changeset or file revision''' | |
777 | changenode = ctx.node() |
|
782 | changenode = ctx.node() | |
778 | rev = ctx.rev() |
|
783 | rev = ctx.rev() | |
779 |
|
784 | |||
780 | if self.ui.quiet: |
|
785 | if self.ui.quiet: | |
781 | self.ui.write("%d:%s\n" % (rev, short(changenode)), |
|
786 | self.ui.write("%d:%s\n" % (rev, short(changenode)), | |
782 | label='log.node') |
|
787 | label='log.node') | |
783 | return |
|
788 | return | |
784 |
|
789 | |||
785 | log = self.repo.changelog |
|
790 | log = self.repo.changelog | |
786 | date = util.datestr(ctx.date()) |
|
791 | date = util.datestr(ctx.date()) | |
787 |
|
792 | |||
788 | hexfunc = self.ui.debugflag and hex or short |
|
793 | hexfunc = self.ui.debugflag and hex or short | |
789 |
|
794 | |||
790 | parents = [(p, hexfunc(log.node(p))) |
|
795 | parents = [(p, hexfunc(log.node(p))) | |
791 | for p in self._meaningful_parentrevs(log, rev)] |
|
796 | for p in self._meaningful_parentrevs(log, rev)] | |
792 |
|
797 | |||
793 | self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), |
|
798 | self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), | |
794 | label='log.changeset') |
|
799 | label='log.changeset') | |
795 |
|
800 | |||
796 | branch = ctx.branch() |
|
801 | branch = ctx.branch() | |
797 | # don't show the default branch name |
|
802 | # don't show the default branch name | |
798 | if branch != 'default': |
|
803 | if branch != 'default': | |
799 | branch = encoding.tolocal(branch) |
|
804 | branch = encoding.tolocal(branch) | |
800 | self.ui.write(_("branch: %s\n") % branch, |
|
805 | self.ui.write(_("branch: %s\n") % branch, | |
801 | label='log.branch') |
|
806 | label='log.branch') | |
802 | for tag in self.repo.nodetags(changenode): |
|
807 | for tag in self.repo.nodetags(changenode): | |
803 | self.ui.write(_("tag: %s\n") % tag, |
|
808 | self.ui.write(_("tag: %s\n") % tag, | |
804 | label='log.tag') |
|
809 | label='log.tag') | |
805 | for parent in parents: |
|
810 | for parent in parents: | |
806 | self.ui.write(_("parent: %d:%s\n") % parent, |
|
811 | self.ui.write(_("parent: %d:%s\n") % parent, | |
807 | label='log.parent') |
|
812 | label='log.parent') | |
808 |
|
813 | |||
809 | if self.ui.debugflag: |
|
814 | if self.ui.debugflag: | |
810 | mnode = ctx.manifestnode() |
|
815 | mnode = ctx.manifestnode() | |
811 | self.ui.write(_("manifest: %d:%s\n") % |
|
816 | self.ui.write(_("manifest: %d:%s\n") % | |
812 | (self.repo.manifest.rev(mnode), hex(mnode)), |
|
817 | (self.repo.manifest.rev(mnode), hex(mnode)), | |
813 | label='ui.debug log.manifest') |
|
818 | label='ui.debug log.manifest') | |
814 | self.ui.write(_("user: %s\n") % ctx.user(), |
|
819 | self.ui.write(_("user: %s\n") % ctx.user(), | |
815 | label='log.user') |
|
820 | label='log.user') | |
816 | self.ui.write(_("date: %s\n") % date, |
|
821 | self.ui.write(_("date: %s\n") % date, | |
817 | label='log.date') |
|
822 | label='log.date') | |
818 |
|
823 | |||
819 | if self.ui.debugflag: |
|
824 | if self.ui.debugflag: | |
820 | files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
|
825 | files = self.repo.status(log.parents(changenode)[0], changenode)[:3] | |
821 | for key, value in zip([_("files:"), _("files+:"), _("files-:")], |
|
826 | for key, value in zip([_("files:"), _("files+:"), _("files-:")], | |
822 | files): |
|
827 | files): | |
823 | if value: |
|
828 | if value: | |
824 | self.ui.write("%-12s %s\n" % (key, " ".join(value)), |
|
829 | self.ui.write("%-12s %s\n" % (key, " ".join(value)), | |
825 | label='ui.debug log.files') |
|
830 | label='ui.debug log.files') | |
826 | elif ctx.files() and self.ui.verbose: |
|
831 | elif ctx.files() and self.ui.verbose: | |
827 | self.ui.write(_("files: %s\n") % " ".join(ctx.files()), |
|
832 | self.ui.write(_("files: %s\n") % " ".join(ctx.files()), | |
828 | label='ui.note log.files') |
|
833 | label='ui.note log.files') | |
829 | if copies and self.ui.verbose: |
|
834 | if copies and self.ui.verbose: | |
830 | copies = ['%s (%s)' % c for c in copies] |
|
835 | copies = ['%s (%s)' % c for c in copies] | |
831 | self.ui.write(_("copies: %s\n") % ' '.join(copies), |
|
836 | self.ui.write(_("copies: %s\n") % ' '.join(copies), | |
832 | label='ui.note log.copies') |
|
837 | label='ui.note log.copies') | |
833 |
|
838 | |||
834 | extra = ctx.extra() |
|
839 | extra = ctx.extra() | |
835 | if extra and self.ui.debugflag: |
|
840 | if extra and self.ui.debugflag: | |
836 | for key, value in sorted(extra.items()): |
|
841 | for key, value in sorted(extra.items()): | |
837 | self.ui.write(_("extra: %s=%s\n") |
|
842 | self.ui.write(_("extra: %s=%s\n") | |
838 | % (key, value.encode('string_escape')), |
|
843 | % (key, value.encode('string_escape')), | |
839 | label='ui.debug log.extra') |
|
844 | label='ui.debug log.extra') | |
840 |
|
845 | |||
841 | description = ctx.description().strip() |
|
846 | description = ctx.description().strip() | |
842 | if description: |
|
847 | if description: | |
843 | if self.ui.verbose: |
|
848 | if self.ui.verbose: | |
844 | self.ui.write(_("description:\n"), |
|
849 | self.ui.write(_("description:\n"), | |
845 | label='ui.note log.description') |
|
850 | label='ui.note log.description') | |
846 | self.ui.write(description, |
|
851 | self.ui.write(description, | |
847 | label='ui.note log.description') |
|
852 | label='ui.note log.description') | |
848 | self.ui.write("\n\n") |
|
853 | self.ui.write("\n\n") | |
849 | else: |
|
854 | else: | |
850 | self.ui.write(_("summary: %s\n") % |
|
855 | self.ui.write(_("summary: %s\n") % | |
851 | description.splitlines()[0], |
|
856 | description.splitlines()[0], | |
852 | label='log.summary') |
|
857 | label='log.summary') | |
853 | self.ui.write("\n") |
|
858 | self.ui.write("\n") | |
854 |
|
859 | |||
855 | self.showpatch(changenode, matchfn) |
|
860 | self.showpatch(changenode, matchfn) | |
856 |
|
861 | |||
857 | def showpatch(self, node, matchfn): |
|
862 | def showpatch(self, node, matchfn): | |
858 | if not matchfn: |
|
863 | if not matchfn: | |
859 | matchfn = self.patch |
|
864 | matchfn = self.patch | |
860 | if matchfn: |
|
865 | if matchfn: | |
861 | stat = self.diffopts.get('stat') |
|
866 | stat = self.diffopts.get('stat') | |
862 | diff = self.diffopts.get('patch') |
|
867 | diff = self.diffopts.get('patch') | |
863 | diffopts = patch.diffopts(self.ui, self.diffopts) |
|
868 | diffopts = patch.diffopts(self.ui, self.diffopts) | |
864 | prev = self.repo.changelog.parents(node)[0] |
|
869 | prev = self.repo.changelog.parents(node)[0] | |
865 | if stat: |
|
870 | if stat: | |
866 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
|
871 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, | |
867 | match=matchfn, stat=True) |
|
872 | match=matchfn, stat=True) | |
868 | if diff: |
|
873 | if diff: | |
869 | if stat: |
|
874 | if stat: | |
870 | self.ui.write("\n") |
|
875 | self.ui.write("\n") | |
871 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
|
876 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, | |
872 | match=matchfn, stat=False) |
|
877 | match=matchfn, stat=False) | |
873 | self.ui.write("\n") |
|
878 | self.ui.write("\n") | |
874 |
|
879 | |||
875 | def _meaningful_parentrevs(self, log, rev): |
|
880 | def _meaningful_parentrevs(self, log, rev): | |
876 | """Return list of meaningful (or all if debug) parentrevs for rev. |
|
881 | """Return list of meaningful (or all if debug) parentrevs for rev. | |
877 |
|
882 | |||
878 | For merges (two non-nullrev revisions) both parents are meaningful. |
|
883 | For merges (two non-nullrev revisions) both parents are meaningful. | |
879 | Otherwise the first parent revision is considered meaningful if it |
|
884 | Otherwise the first parent revision is considered meaningful if it | |
880 | is not the preceding revision. |
|
885 | is not the preceding revision. | |
881 | """ |
|
886 | """ | |
882 | parents = log.parentrevs(rev) |
|
887 | parents = log.parentrevs(rev) | |
883 | if not self.ui.debugflag and parents[1] == nullrev: |
|
888 | if not self.ui.debugflag and parents[1] == nullrev: | |
884 | if parents[0] >= rev - 1: |
|
889 | if parents[0] >= rev - 1: | |
885 | parents = [] |
|
890 | parents = [] | |
886 | else: |
|
891 | else: | |
887 | parents = [parents[0]] |
|
892 | parents = [parents[0]] | |
888 | return parents |
|
893 | return parents | |
889 |
|
894 | |||
890 |
|
895 | |||
891 | class changeset_templater(changeset_printer): |
|
896 | class changeset_templater(changeset_printer): | |
892 | '''format changeset information.''' |
|
897 | '''format changeset information.''' | |
893 |
|
898 | |||
894 | def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): |
|
899 | def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): | |
895 | changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) |
|
900 | changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) | |
896 | formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) |
|
901 | formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) | |
897 | defaulttempl = { |
|
902 | defaulttempl = { | |
898 | 'parent': '{rev}:{node|formatnode} ', |
|
903 | 'parent': '{rev}:{node|formatnode} ', | |
899 | 'manifest': '{rev}:{node|formatnode}', |
|
904 | 'manifest': '{rev}:{node|formatnode}', | |
900 | 'file_copy': '{name} ({source})', |
|
905 | 'file_copy': '{name} ({source})', | |
901 | 'extra': '{key}={value|stringescape}' |
|
906 | 'extra': '{key}={value|stringescape}' | |
902 | } |
|
907 | } | |
903 | # filecopy is preserved for compatibility reasons |
|
908 | # filecopy is preserved for compatibility reasons | |
904 | defaulttempl['filecopy'] = defaulttempl['file_copy'] |
|
909 | defaulttempl['filecopy'] = defaulttempl['file_copy'] | |
905 | self.t = templater.templater(mapfile, {'formatnode': formatnode}, |
|
910 | self.t = templater.templater(mapfile, {'formatnode': formatnode}, | |
906 | cache=defaulttempl) |
|
911 | cache=defaulttempl) | |
907 | self.cache = {} |
|
912 | self.cache = {} | |
908 |
|
913 | |||
909 | def use_template(self, t): |
|
914 | def use_template(self, t): | |
910 | '''set template string to use''' |
|
915 | '''set template string to use''' | |
911 | self.t.cache['changeset'] = t |
|
916 | self.t.cache['changeset'] = t | |
912 |
|
917 | |||
913 | def _meaningful_parentrevs(self, ctx): |
|
918 | def _meaningful_parentrevs(self, ctx): | |
914 | """Return list of meaningful (or all if debug) parentrevs for rev. |
|
919 | """Return list of meaningful (or all if debug) parentrevs for rev. | |
915 | """ |
|
920 | """ | |
916 | parents = ctx.parents() |
|
921 | parents = ctx.parents() | |
917 | if len(parents) > 1: |
|
922 | if len(parents) > 1: | |
918 | return parents |
|
923 | return parents | |
919 | if self.ui.debugflag: |
|
924 | if self.ui.debugflag: | |
920 | return [parents[0], self.repo['null']] |
|
925 | return [parents[0], self.repo['null']] | |
921 | if parents[0].rev() >= ctx.rev() - 1: |
|
926 | if parents[0].rev() >= ctx.rev() - 1: | |
922 | return [] |
|
927 | return [] | |
923 | return parents |
|
928 | return parents | |
924 |
|
929 | |||
925 | def _show(self, ctx, copies, matchfn, props): |
|
930 | def _show(self, ctx, copies, matchfn, props): | |
926 | '''show a single changeset or file revision''' |
|
931 | '''show a single changeset or file revision''' | |
927 |
|
932 | |||
928 | showlist = templatekw.showlist |
|
933 | showlist = templatekw.showlist | |
929 |
|
934 | |||
930 | # showparents() behaviour depends on ui trace level which |
|
935 | # showparents() behaviour depends on ui trace level which | |
931 | # causes unexpected behaviours at templating level and makes |
|
936 | # causes unexpected behaviours at templating level and makes | |
932 | # it harder to extract it in a standalone function. Its |
|
937 | # it harder to extract it in a standalone function. Its | |
933 | # behaviour cannot be changed so leave it here for now. |
|
938 | # behaviour cannot be changed so leave it here for now. | |
934 | def showparents(**args): |
|
939 | def showparents(**args): | |
935 | ctx = args['ctx'] |
|
940 | ctx = args['ctx'] | |
936 | parents = [[('rev', p.rev()), ('node', p.hex())] |
|
941 | parents = [[('rev', p.rev()), ('node', p.hex())] | |
937 | for p in self._meaningful_parentrevs(ctx)] |
|
942 | for p in self._meaningful_parentrevs(ctx)] | |
938 | return showlist('parent', parents, **args) |
|
943 | return showlist('parent', parents, **args) | |
939 |
|
944 | |||
940 | props = props.copy() |
|
945 | props = props.copy() | |
941 | props.update(templatekw.keywords) |
|
946 | props.update(templatekw.keywords) | |
942 | props['parents'] = showparents |
|
947 | props['parents'] = showparents | |
943 | props['templ'] = self.t |
|
948 | props['templ'] = self.t | |
944 | props['ctx'] = ctx |
|
949 | props['ctx'] = ctx | |
945 | props['repo'] = self.repo |
|
950 | props['repo'] = self.repo | |
946 | props['revcache'] = {'copies': copies} |
|
951 | props['revcache'] = {'copies': copies} | |
947 | props['cache'] = self.cache |
|
952 | props['cache'] = self.cache | |
948 |
|
953 | |||
949 | # find correct templates for current mode |
|
954 | # find correct templates for current mode | |
950 |
|
955 | |||
951 | tmplmodes = [ |
|
956 | tmplmodes = [ | |
952 | (True, None), |
|
957 | (True, None), | |
953 | (self.ui.verbose, 'verbose'), |
|
958 | (self.ui.verbose, 'verbose'), | |
954 | (self.ui.quiet, 'quiet'), |
|
959 | (self.ui.quiet, 'quiet'), | |
955 | (self.ui.debugflag, 'debug'), |
|
960 | (self.ui.debugflag, 'debug'), | |
956 | ] |
|
961 | ] | |
957 |
|
962 | |||
958 | types = {'header': '', 'footer':'', 'changeset': 'changeset'} |
|
963 | types = {'header': '', 'footer':'', 'changeset': 'changeset'} | |
959 | for mode, postfix in tmplmodes: |
|
964 | for mode, postfix in tmplmodes: | |
960 | for type in types: |
|
965 | for type in types: | |
961 | cur = postfix and ('%s_%s' % (type, postfix)) or type |
|
966 | cur = postfix and ('%s_%s' % (type, postfix)) or type | |
962 | if mode and cur in self.t: |
|
967 | if mode and cur in self.t: | |
963 | types[type] = cur |
|
968 | types[type] = cur | |
964 |
|
969 | |||
965 | try: |
|
970 | try: | |
966 |
|
971 | |||
967 | # write header |
|
972 | # write header | |
968 | if types['header']: |
|
973 | if types['header']: | |
969 | h = templater.stringify(self.t(types['header'], **props)) |
|
974 | h = templater.stringify(self.t(types['header'], **props)) | |
970 | if self.buffered: |
|
975 | if self.buffered: | |
971 | self.header[ctx.rev()] = h |
|
976 | self.header[ctx.rev()] = h | |
972 | else: |
|
977 | else: | |
973 | if self.lastheader != h: |
|
978 | if self.lastheader != h: | |
974 | self.lastheader = h |
|
979 | self.lastheader = h | |
975 | self.ui.write(h) |
|
980 | self.ui.write(h) | |
976 |
|
981 | |||
977 | # write changeset metadata, then patch if requested |
|
982 | # write changeset metadata, then patch if requested | |
978 | key = types['changeset'] |
|
983 | key = types['changeset'] | |
979 | self.ui.write(templater.stringify(self.t(key, **props))) |
|
984 | self.ui.write(templater.stringify(self.t(key, **props))) | |
980 | self.showpatch(ctx.node(), matchfn) |
|
985 | self.showpatch(ctx.node(), matchfn) | |
981 |
|
986 | |||
982 | if types['footer']: |
|
987 | if types['footer']: | |
983 | if not self.footer: |
|
988 | if not self.footer: | |
984 | self.footer = templater.stringify(self.t(types['footer'], |
|
989 | self.footer = templater.stringify(self.t(types['footer'], | |
985 | **props)) |
|
990 | **props)) | |
986 |
|
991 | |||
987 | except KeyError, inst: |
|
992 | except KeyError, inst: | |
988 | msg = _("%s: no key named '%s'") |
|
993 | msg = _("%s: no key named '%s'") | |
989 | raise util.Abort(msg % (self.t.mapfile, inst.args[0])) |
|
994 | raise util.Abort(msg % (self.t.mapfile, inst.args[0])) | |
990 | except SyntaxError, inst: |
|
995 | except SyntaxError, inst: | |
991 | raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) |
|
996 | raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) | |
992 |
|
997 | |||
993 | def show_changeset(ui, repo, opts, buffered=False): |
|
998 | def show_changeset(ui, repo, opts, buffered=False): | |
994 | """show one changeset using template or regular display. |
|
999 | """show one changeset using template or regular display. | |
995 |
|
1000 | |||
996 | Display format will be the first non-empty hit of: |
|
1001 | Display format will be the first non-empty hit of: | |
997 | 1. option 'template' |
|
1002 | 1. option 'template' | |
998 | 2. option 'style' |
|
1003 | 2. option 'style' | |
999 | 3. [ui] setting 'logtemplate' |
|
1004 | 3. [ui] setting 'logtemplate' | |
1000 | 4. [ui] setting 'style' |
|
1005 | 4. [ui] setting 'style' | |
1001 | If all of these values are either the unset or the empty string, |
|
1006 | If all of these values are either the unset or the empty string, | |
1002 | regular display via changeset_printer() is done. |
|
1007 | regular display via changeset_printer() is done. | |
1003 | """ |
|
1008 | """ | |
1004 | # options |
|
1009 | # options | |
1005 | patch = False |
|
1010 | patch = False | |
1006 | if opts.get('patch') or opts.get('stat'): |
|
1011 | if opts.get('patch') or opts.get('stat'): | |
1007 | patch = matchall(repo) |
|
1012 | patch = matchall(repo) | |
1008 |
|
1013 | |||
1009 | tmpl = opts.get('template') |
|
1014 | tmpl = opts.get('template') | |
1010 | style = None |
|
1015 | style = None | |
1011 | if tmpl: |
|
1016 | if tmpl: | |
1012 | tmpl = templater.parsestring(tmpl, quoted=False) |
|
1017 | tmpl = templater.parsestring(tmpl, quoted=False) | |
1013 | else: |
|
1018 | else: | |
1014 | style = opts.get('style') |
|
1019 | style = opts.get('style') | |
1015 |
|
1020 | |||
1016 | # ui settings |
|
1021 | # ui settings | |
1017 | if not (tmpl or style): |
|
1022 | if not (tmpl or style): | |
1018 | tmpl = ui.config('ui', 'logtemplate') |
|
1023 | tmpl = ui.config('ui', 'logtemplate') | |
1019 | if tmpl: |
|
1024 | if tmpl: | |
1020 | tmpl = templater.parsestring(tmpl) |
|
1025 | tmpl = templater.parsestring(tmpl) | |
1021 | else: |
|
1026 | else: | |
1022 | style = util.expandpath(ui.config('ui', 'style', '')) |
|
1027 | style = util.expandpath(ui.config('ui', 'style', '')) | |
1023 |
|
1028 | |||
1024 | if not (tmpl or style): |
|
1029 | if not (tmpl or style): | |
1025 | return changeset_printer(ui, repo, patch, opts, buffered) |
|
1030 | return changeset_printer(ui, repo, patch, opts, buffered) | |
1026 |
|
1031 | |||
1027 | mapfile = None |
|
1032 | mapfile = None | |
1028 | if style and not tmpl: |
|
1033 | if style and not tmpl: | |
1029 | mapfile = style |
|
1034 | mapfile = style | |
1030 | if not os.path.split(mapfile)[0]: |
|
1035 | if not os.path.split(mapfile)[0]: | |
1031 | mapname = (templater.templatepath('map-cmdline.' + mapfile) |
|
1036 | mapname = (templater.templatepath('map-cmdline.' + mapfile) | |
1032 | or templater.templatepath(mapfile)) |
|
1037 | or templater.templatepath(mapfile)) | |
1033 | if mapname: |
|
1038 | if mapname: | |
1034 | mapfile = mapname |
|
1039 | mapfile = mapname | |
1035 |
|
1040 | |||
1036 | try: |
|
1041 | try: | |
1037 | t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) |
|
1042 | t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) | |
1038 | except SyntaxError, inst: |
|
1043 | except SyntaxError, inst: | |
1039 | raise util.Abort(inst.args[0]) |
|
1044 | raise util.Abort(inst.args[0]) | |
1040 | if tmpl: |
|
1045 | if tmpl: | |
1041 | t.use_template(tmpl) |
|
1046 | t.use_template(tmpl) | |
1042 | return t |
|
1047 | return t | |
1043 |
|
1048 | |||
1044 | def finddate(ui, repo, date): |
|
1049 | def finddate(ui, repo, date): | |
1045 | """Find the tipmost changeset that matches the given date spec""" |
|
1050 | """Find the tipmost changeset that matches the given date spec""" | |
1046 |
|
1051 | |||
1047 | df = util.matchdate(date) |
|
1052 | df = util.matchdate(date) | |
1048 | m = matchall(repo) |
|
1053 | m = matchall(repo) | |
1049 | results = {} |
|
1054 | results = {} | |
1050 |
|
1055 | |||
1051 | def prep(ctx, fns): |
|
1056 | def prep(ctx, fns): | |
1052 | d = ctx.date() |
|
1057 | d = ctx.date() | |
1053 | if df(d[0]): |
|
1058 | if df(d[0]): | |
1054 | results[ctx.rev()] = d |
|
1059 | results[ctx.rev()] = d | |
1055 |
|
1060 | |||
1056 | for ctx in walkchangerevs(repo, m, {'rev': None}, prep): |
|
1061 | for ctx in walkchangerevs(repo, m, {'rev': None}, prep): | |
1057 | rev = ctx.rev() |
|
1062 | rev = ctx.rev() | |
1058 | if rev in results: |
|
1063 | if rev in results: | |
1059 | ui.status(_("Found revision %s from %s\n") % |
|
1064 | ui.status(_("Found revision %s from %s\n") % | |
1060 | (rev, util.datestr(results[rev]))) |
|
1065 | (rev, util.datestr(results[rev]))) | |
1061 | return str(rev) |
|
1066 | return str(rev) | |
1062 |
|
1067 | |||
1063 | raise util.Abort(_("revision matching date not found")) |
|
1068 | raise util.Abort(_("revision matching date not found")) | |
1064 |
|
1069 | |||
1065 | def walkchangerevs(repo, match, opts, prepare): |
|
1070 | def walkchangerevs(repo, match, opts, prepare): | |
1066 | '''Iterate over files and the revs in which they changed. |
|
1071 | '''Iterate over files and the revs in which they changed. | |
1067 |
|
1072 | |||
1068 | Callers most commonly need to iterate backwards over the history |
|
1073 | Callers most commonly need to iterate backwards over the history | |
1069 | in which they are interested. Doing so has awful (quadratic-looking) |
|
1074 | in which they are interested. Doing so has awful (quadratic-looking) | |
1070 | performance, so we use iterators in a "windowed" way. |
|
1075 | performance, so we use iterators in a "windowed" way. | |
1071 |
|
1076 | |||
1072 | We walk a window of revisions in the desired order. Within the |
|
1077 | We walk a window of revisions in the desired order. Within the | |
1073 | window, we first walk forwards to gather data, then in the desired |
|
1078 | window, we first walk forwards to gather data, then in the desired | |
1074 | order (usually backwards) to display it. |
|
1079 | order (usually backwards) to display it. | |
1075 |
|
1080 | |||
1076 | This function returns an iterator yielding contexts. Before |
|
1081 | This function returns an iterator yielding contexts. Before | |
1077 | yielding each context, the iterator will first call the prepare |
|
1082 | yielding each context, the iterator will first call the prepare | |
1078 | function on each context in the window in forward order.''' |
|
1083 | function on each context in the window in forward order.''' | |
1079 |
|
1084 | |||
1080 | def increasing_windows(start, end, windowsize=8, sizelimit=512): |
|
1085 | def increasing_windows(start, end, windowsize=8, sizelimit=512): | |
1081 | if start < end: |
|
1086 | if start < end: | |
1082 | while start < end: |
|
1087 | while start < end: | |
1083 | yield start, min(windowsize, end - start) |
|
1088 | yield start, min(windowsize, end - start) | |
1084 | start += windowsize |
|
1089 | start += windowsize | |
1085 | if windowsize < sizelimit: |
|
1090 | if windowsize < sizelimit: | |
1086 | windowsize *= 2 |
|
1091 | windowsize *= 2 | |
1087 | else: |
|
1092 | else: | |
1088 | while start > end: |
|
1093 | while start > end: | |
1089 | yield start, min(windowsize, start - end - 1) |
|
1094 | yield start, min(windowsize, start - end - 1) | |
1090 | start -= windowsize |
|
1095 | start -= windowsize | |
1091 | if windowsize < sizelimit: |
|
1096 | if windowsize < sizelimit: | |
1092 | windowsize *= 2 |
|
1097 | windowsize *= 2 | |
1093 |
|
1098 | |||
1094 | follow = opts.get('follow') or opts.get('follow_first') |
|
1099 | follow = opts.get('follow') or opts.get('follow_first') | |
1095 |
|
1100 | |||
1096 | if not len(repo): |
|
1101 | if not len(repo): | |
1097 | return [] |
|
1102 | return [] | |
1098 |
|
1103 | |||
1099 | if follow: |
|
1104 | if follow: | |
1100 | defrange = '%s:0' % repo['.'].rev() |
|
1105 | defrange = '%s:0' % repo['.'].rev() | |
1101 | else: |
|
1106 | else: | |
1102 | defrange = '-1:0' |
|
1107 | defrange = '-1:0' | |
1103 | revs = revrange(repo, opts['rev'] or [defrange]) |
|
1108 | revs = revrange(repo, opts['rev'] or [defrange]) | |
1104 | if not revs: |
|
1109 | if not revs: | |
1105 | return [] |
|
1110 | return [] | |
1106 | wanted = set() |
|
1111 | wanted = set() | |
1107 | slowpath = match.anypats() or (match.files() and opts.get('removed')) |
|
1112 | slowpath = match.anypats() or (match.files() and opts.get('removed')) | |
1108 | fncache = {} |
|
1113 | fncache = {} | |
1109 | change = util.cachefunc(repo.changectx) |
|
1114 | change = util.cachefunc(repo.changectx) | |
1110 |
|
1115 | |||
1111 | # First step is to fill wanted, the set of revisions that we want to yield. |
|
1116 | # First step is to fill wanted, the set of revisions that we want to yield. | |
1112 | # When it does not induce extra cost, we also fill fncache for revisions in |
|
1117 | # When it does not induce extra cost, we also fill fncache for revisions in | |
1113 | # wanted: a cache of filenames that were changed (ctx.files()) and that |
|
1118 | # wanted: a cache of filenames that were changed (ctx.files()) and that | |
1114 | # match the file filtering conditions. |
|
1119 | # match the file filtering conditions. | |
1115 |
|
1120 | |||
1116 | if not slowpath and not match.files(): |
|
1121 | if not slowpath and not match.files(): | |
1117 | # No files, no patterns. Display all revs. |
|
1122 | # No files, no patterns. Display all revs. | |
1118 | wanted = set(revs) |
|
1123 | wanted = set(revs) | |
1119 | copies = [] |
|
1124 | copies = [] | |
1120 |
|
1125 | |||
1121 | if not slowpath: |
|
1126 | if not slowpath: | |
1122 | # We only have to read through the filelog to find wanted revisions |
|
1127 | # We only have to read through the filelog to find wanted revisions | |
1123 |
|
1128 | |||
1124 | minrev, maxrev = min(revs), max(revs) |
|
1129 | minrev, maxrev = min(revs), max(revs) | |
1125 | def filerevgen(filelog, last): |
|
1130 | def filerevgen(filelog, last): | |
1126 | """ |
|
1131 | """ | |
1127 | Only files, no patterns. Check the history of each file. |
|
1132 | Only files, no patterns. Check the history of each file. | |
1128 |
|
1133 | |||
1129 | Examines filelog entries within minrev, maxrev linkrev range |
|
1134 | Examines filelog entries within minrev, maxrev linkrev range | |
1130 | Returns an iterator yielding (linkrev, parentlinkrevs, copied) |
|
1135 | Returns an iterator yielding (linkrev, parentlinkrevs, copied) | |
1131 | tuples in backwards order |
|
1136 | tuples in backwards order | |
1132 | """ |
|
1137 | """ | |
1133 | cl_count = len(repo) |
|
1138 | cl_count = len(repo) | |
1134 | revs = [] |
|
1139 | revs = [] | |
1135 | for j in xrange(0, last + 1): |
|
1140 | for j in xrange(0, last + 1): | |
1136 | linkrev = filelog.linkrev(j) |
|
1141 | linkrev = filelog.linkrev(j) | |
1137 | if linkrev < minrev: |
|
1142 | if linkrev < minrev: | |
1138 | continue |
|
1143 | continue | |
1139 | # only yield rev for which we have the changelog, it can |
|
1144 | # only yield rev for which we have the changelog, it can | |
1140 | # happen while doing "hg log" during a pull or commit |
|
1145 | # happen while doing "hg log" during a pull or commit | |
1141 | if linkrev > maxrev or linkrev >= cl_count: |
|
1146 | if linkrev > maxrev or linkrev >= cl_count: | |
1142 | break |
|
1147 | break | |
1143 |
|
1148 | |||
1144 | parentlinkrevs = [] |
|
1149 | parentlinkrevs = [] | |
1145 | for p in filelog.parentrevs(j): |
|
1150 | for p in filelog.parentrevs(j): | |
1146 | if p != nullrev: |
|
1151 | if p != nullrev: | |
1147 | parentlinkrevs.append(filelog.linkrev(p)) |
|
1152 | parentlinkrevs.append(filelog.linkrev(p)) | |
1148 | n = filelog.node(j) |
|
1153 | n = filelog.node(j) | |
1149 | revs.append((linkrev, parentlinkrevs, |
|
1154 | revs.append((linkrev, parentlinkrevs, | |
1150 | follow and filelog.renamed(n))) |
|
1155 | follow and filelog.renamed(n))) | |
1151 |
|
1156 | |||
1152 | return reversed(revs) |
|
1157 | return reversed(revs) | |
1153 | def iterfiles(): |
|
1158 | def iterfiles(): | |
1154 | for filename in match.files(): |
|
1159 | for filename in match.files(): | |
1155 | yield filename, None |
|
1160 | yield filename, None | |
1156 | for filename_node in copies: |
|
1161 | for filename_node in copies: | |
1157 | yield filename_node |
|
1162 | yield filename_node | |
1158 | for file_, node in iterfiles(): |
|
1163 | for file_, node in iterfiles(): | |
1159 | filelog = repo.file(file_) |
|
1164 | filelog = repo.file(file_) | |
1160 | if not len(filelog): |
|
1165 | if not len(filelog): | |
1161 | if node is None: |
|
1166 | if node is None: | |
1162 | # A zero count may be a directory or deleted file, so |
|
1167 | # A zero count may be a directory or deleted file, so | |
1163 | # try to find matching entries on the slow path. |
|
1168 | # try to find matching entries on the slow path. | |
1164 | if follow: |
|
1169 | if follow: | |
1165 | raise util.Abort( |
|
1170 | raise util.Abort( | |
1166 | _('cannot follow nonexistent file: "%s"') % file_) |
|
1171 | _('cannot follow nonexistent file: "%s"') % file_) | |
1167 | slowpath = True |
|
1172 | slowpath = True | |
1168 | break |
|
1173 | break | |
1169 | else: |
|
1174 | else: | |
1170 | continue |
|
1175 | continue | |
1171 |
|
1176 | |||
1172 | if node is None: |
|
1177 | if node is None: | |
1173 | last = len(filelog) - 1 |
|
1178 | last = len(filelog) - 1 | |
1174 | else: |
|
1179 | else: | |
1175 | last = filelog.rev(node) |
|
1180 | last = filelog.rev(node) | |
1176 |
|
1181 | |||
1177 |
|
1182 | |||
1178 | # keep track of all ancestors of the file |
|
1183 | # keep track of all ancestors of the file | |
1179 | ancestors = set([filelog.linkrev(last)]) |
|
1184 | ancestors = set([filelog.linkrev(last)]) | |
1180 |
|
1185 | |||
1181 | # iterate from latest to oldest revision |
|
1186 | # iterate from latest to oldest revision | |
1182 | for rev, flparentlinkrevs, copied in filerevgen(filelog, last): |
|
1187 | for rev, flparentlinkrevs, copied in filerevgen(filelog, last): | |
1183 | if rev not in ancestors: |
|
1188 | if rev not in ancestors: | |
1184 | continue |
|
1189 | continue | |
1185 | # XXX insert 1327 fix here |
|
1190 | # XXX insert 1327 fix here | |
1186 | if flparentlinkrevs: |
|
1191 | if flparentlinkrevs: | |
1187 | ancestors.update(flparentlinkrevs) |
|
1192 | ancestors.update(flparentlinkrevs) | |
1188 |
|
1193 | |||
1189 | fncache.setdefault(rev, []).append(file_) |
|
1194 | fncache.setdefault(rev, []).append(file_) | |
1190 | wanted.add(rev) |
|
1195 | wanted.add(rev) | |
1191 | if copied: |
|
1196 | if copied: | |
1192 | copies.append(copied) |
|
1197 | copies.append(copied) | |
1193 | if slowpath: |
|
1198 | if slowpath: | |
1194 | # We have to read the changelog to match filenames against |
|
1199 | # We have to read the changelog to match filenames against | |
1195 | # changed files |
|
1200 | # changed files | |
1196 |
|
1201 | |||
1197 | if follow: |
|
1202 | if follow: | |
1198 | raise util.Abort(_('can only follow copies/renames for explicit ' |
|
1203 | raise util.Abort(_('can only follow copies/renames for explicit ' | |
1199 | 'filenames')) |
|
1204 | 'filenames')) | |
1200 |
|
1205 | |||
1201 | # The slow path checks files modified in every changeset. |
|
1206 | # The slow path checks files modified in every changeset. | |
1202 | for i in sorted(revs): |
|
1207 | for i in sorted(revs): | |
1203 | ctx = change(i) |
|
1208 | ctx = change(i) | |
1204 | matches = filter(match, ctx.files()) |
|
1209 | matches = filter(match, ctx.files()) | |
1205 | if matches: |
|
1210 | if matches: | |
1206 | fncache[i] = matches |
|
1211 | fncache[i] = matches | |
1207 | wanted.add(i) |
|
1212 | wanted.add(i) | |
1208 |
|
1213 | |||
1209 | class followfilter(object): |
|
1214 | class followfilter(object): | |
1210 | def __init__(self, onlyfirst=False): |
|
1215 | def __init__(self, onlyfirst=False): | |
1211 | self.startrev = nullrev |
|
1216 | self.startrev = nullrev | |
1212 | self.roots = set() |
|
1217 | self.roots = set() | |
1213 | self.onlyfirst = onlyfirst |
|
1218 | self.onlyfirst = onlyfirst | |
1214 |
|
1219 | |||
1215 | def match(self, rev): |
|
1220 | def match(self, rev): | |
1216 | def realparents(rev): |
|
1221 | def realparents(rev): | |
1217 | if self.onlyfirst: |
|
1222 | if self.onlyfirst: | |
1218 | return repo.changelog.parentrevs(rev)[0:1] |
|
1223 | return repo.changelog.parentrevs(rev)[0:1] | |
1219 | else: |
|
1224 | else: | |
1220 | return filter(lambda x: x != nullrev, |
|
1225 | return filter(lambda x: x != nullrev, | |
1221 | repo.changelog.parentrevs(rev)) |
|
1226 | repo.changelog.parentrevs(rev)) | |
1222 |
|
1227 | |||
1223 | if self.startrev == nullrev: |
|
1228 | if self.startrev == nullrev: | |
1224 | self.startrev = rev |
|
1229 | self.startrev = rev | |
1225 | return True |
|
1230 | return True | |
1226 |
|
1231 | |||
1227 | if rev > self.startrev: |
|
1232 | if rev > self.startrev: | |
1228 | # forward: all descendants |
|
1233 | # forward: all descendants | |
1229 | if not self.roots: |
|
1234 | if not self.roots: | |
1230 | self.roots.add(self.startrev) |
|
1235 | self.roots.add(self.startrev) | |
1231 | for parent in realparents(rev): |
|
1236 | for parent in realparents(rev): | |
1232 | if parent in self.roots: |
|
1237 | if parent in self.roots: | |
1233 | self.roots.add(rev) |
|
1238 | self.roots.add(rev) | |
1234 | return True |
|
1239 | return True | |
1235 | else: |
|
1240 | else: | |
1236 | # backwards: all parents |
|
1241 | # backwards: all parents | |
1237 | if not self.roots: |
|
1242 | if not self.roots: | |
1238 | self.roots.update(realparents(self.startrev)) |
|
1243 | self.roots.update(realparents(self.startrev)) | |
1239 | if rev in self.roots: |
|
1244 | if rev in self.roots: | |
1240 | self.roots.remove(rev) |
|
1245 | self.roots.remove(rev) | |
1241 | self.roots.update(realparents(rev)) |
|
1246 | self.roots.update(realparents(rev)) | |
1242 | return True |
|
1247 | return True | |
1243 |
|
1248 | |||
1244 | return False |
|
1249 | return False | |
1245 |
|
1250 | |||
1246 | # it might be worthwhile to do this in the iterator if the rev range |
|
1251 | # it might be worthwhile to do this in the iterator if the rev range | |
1247 | # is descending and the prune args are all within that range |
|
1252 | # is descending and the prune args are all within that range | |
1248 | for rev in opts.get('prune', ()): |
|
1253 | for rev in opts.get('prune', ()): | |
1249 | rev = repo.changelog.rev(repo.lookup(rev)) |
|
1254 | rev = repo.changelog.rev(repo.lookup(rev)) | |
1250 | ff = followfilter() |
|
1255 | ff = followfilter() | |
1251 | stop = min(revs[0], revs[-1]) |
|
1256 | stop = min(revs[0], revs[-1]) | |
1252 | for x in xrange(rev, stop - 1, -1): |
|
1257 | for x in xrange(rev, stop - 1, -1): | |
1253 | if ff.match(x): |
|
1258 | if ff.match(x): | |
1254 | wanted.discard(x) |
|
1259 | wanted.discard(x) | |
1255 |
|
1260 | |||
1256 | # Now that wanted is correctly initialized, we can iterate over the |
|
1261 | # Now that wanted is correctly initialized, we can iterate over the | |
1257 | # revision range, yielding only revisions in wanted. |
|
1262 | # revision range, yielding only revisions in wanted. | |
1258 | def iterate(): |
|
1263 | def iterate(): | |
1259 | if follow and not match.files(): |
|
1264 | if follow and not match.files(): | |
1260 | ff = followfilter(onlyfirst=opts.get('follow_first')) |
|
1265 | ff = followfilter(onlyfirst=opts.get('follow_first')) | |
1261 | def want(rev): |
|
1266 | def want(rev): | |
1262 | return ff.match(rev) and rev in wanted |
|
1267 | return ff.match(rev) and rev in wanted | |
1263 | else: |
|
1268 | else: | |
1264 | def want(rev): |
|
1269 | def want(rev): | |
1265 | return rev in wanted |
|
1270 | return rev in wanted | |
1266 |
|
1271 | |||
1267 | for i, window in increasing_windows(0, len(revs)): |
|
1272 | for i, window in increasing_windows(0, len(revs)): | |
1268 | nrevs = [rev for rev in revs[i:i + window] if want(rev)] |
|
1273 | nrevs = [rev for rev in revs[i:i + window] if want(rev)] | |
1269 | for rev in sorted(nrevs): |
|
1274 | for rev in sorted(nrevs): | |
1270 | fns = fncache.get(rev) |
|
1275 | fns = fncache.get(rev) | |
1271 | ctx = change(rev) |
|
1276 | ctx = change(rev) | |
1272 | if not fns: |
|
1277 | if not fns: | |
1273 | def fns_generator(): |
|
1278 | def fns_generator(): | |
1274 | for f in ctx.files(): |
|
1279 | for f in ctx.files(): | |
1275 | if match(f): |
|
1280 | if match(f): | |
1276 | yield f |
|
1281 | yield f | |
1277 | fns = fns_generator() |
|
1282 | fns = fns_generator() | |
1278 | prepare(ctx, fns) |
|
1283 | prepare(ctx, fns) | |
1279 | for rev in nrevs: |
|
1284 | for rev in nrevs: | |
1280 | yield change(rev) |
|
1285 | yield change(rev) | |
1281 | return iterate() |
|
1286 | return iterate() | |
1282 |
|
1287 | |||
1283 | def add(ui, repo, match, dryrun, listsubrepos, prefix): |
|
1288 | def add(ui, repo, match, dryrun, listsubrepos, prefix): | |
1284 | join = lambda f: os.path.join(prefix, f) |
|
1289 | join = lambda f: os.path.join(prefix, f) | |
1285 | bad = [] |
|
1290 | bad = [] | |
1286 | oldbad = match.bad |
|
1291 | oldbad = match.bad | |
1287 | match.bad = lambda x, y: bad.append(x) or oldbad(x, y) |
|
1292 | match.bad = lambda x, y: bad.append(x) or oldbad(x, y) | |
1288 | names = [] |
|
1293 | names = [] | |
1289 | wctx = repo[None] |
|
1294 | wctx = repo[None] | |
1290 | for f in repo.walk(match): |
|
1295 | for f in repo.walk(match): | |
1291 | exact = match.exact(f) |
|
1296 | exact = match.exact(f) | |
1292 | if exact or f not in repo.dirstate: |
|
1297 | if exact or f not in repo.dirstate: | |
1293 | names.append(f) |
|
1298 | names.append(f) | |
1294 | if ui.verbose or not exact: |
|
1299 | if ui.verbose or not exact: | |
1295 | ui.status(_('adding %s\n') % match.rel(join(f))) |
|
1300 | ui.status(_('adding %s\n') % match.rel(join(f))) | |
1296 |
|
1301 | |||
1297 | if listsubrepos: |
|
1302 | if listsubrepos: | |
1298 | for subpath in wctx.substate: |
|
1303 | for subpath in wctx.substate: | |
1299 | sub = wctx.sub(subpath) |
|
1304 | sub = wctx.sub(subpath) | |
1300 | try: |
|
1305 | try: | |
1301 | submatch = matchmod.narrowmatcher(subpath, match) |
|
1306 | submatch = matchmod.narrowmatcher(subpath, match) | |
1302 | bad.extend(sub.add(ui, submatch, dryrun, prefix)) |
|
1307 | bad.extend(sub.add(ui, submatch, dryrun, prefix)) | |
1303 | except error.LookupError: |
|
1308 | except error.LookupError: | |
1304 | ui.status(_("skipping missing subrepository: %s\n") |
|
1309 | ui.status(_("skipping missing subrepository: %s\n") | |
1305 | % join(subpath)) |
|
1310 | % join(subpath)) | |
1306 |
|
1311 | |||
1307 | if not dryrun: |
|
1312 | if not dryrun: | |
1308 | rejected = wctx.add(names, prefix) |
|
1313 | rejected = wctx.add(names, prefix) | |
1309 | bad.extend(f for f in rejected if f in match.files()) |
|
1314 | bad.extend(f for f in rejected if f in match.files()) | |
1310 | return bad |
|
1315 | return bad | |
1311 |
|
1316 | |||
1312 | def commit(ui, repo, commitfunc, pats, opts): |
|
1317 | def commit(ui, repo, commitfunc, pats, opts): | |
1313 | '''commit the specified files or all outstanding changes''' |
|
1318 | '''commit the specified files or all outstanding changes''' | |
1314 | date = opts.get('date') |
|
1319 | date = opts.get('date') | |
1315 | if date: |
|
1320 | if date: | |
1316 | opts['date'] = util.parsedate(date) |
|
1321 | opts['date'] = util.parsedate(date) | |
1317 | message = logmessage(opts) |
|
1322 | message = logmessage(opts) | |
1318 |
|
1323 | |||
1319 | # extract addremove carefully -- this function can be called from a command |
|
1324 | # extract addremove carefully -- this function can be called from a command | |
1320 | # that doesn't support addremove |
|
1325 | # that doesn't support addremove | |
1321 | if opts.get('addremove'): |
|
1326 | if opts.get('addremove'): | |
1322 | addremove(repo, pats, opts) |
|
1327 | addremove(repo, pats, opts) | |
1323 |
|
1328 | |||
1324 | return commitfunc(ui, repo, message, match(repo, pats, opts), opts) |
|
1329 | return commitfunc(ui, repo, message, match(repo, pats, opts), opts) | |
1325 |
|
1330 | |||
1326 | def commiteditor(repo, ctx, subs): |
|
1331 | def commiteditor(repo, ctx, subs): | |
1327 | if ctx.description(): |
|
1332 | if ctx.description(): | |
1328 | return ctx.description() |
|
1333 | return ctx.description() | |
1329 | return commitforceeditor(repo, ctx, subs) |
|
1334 | return commitforceeditor(repo, ctx, subs) | |
1330 |
|
1335 | |||
1331 | def commitforceeditor(repo, ctx, subs): |
|
1336 | def commitforceeditor(repo, ctx, subs): | |
1332 | edittext = [] |
|
1337 | edittext = [] | |
1333 | modified, added, removed = ctx.modified(), ctx.added(), ctx.removed() |
|
1338 | modified, added, removed = ctx.modified(), ctx.added(), ctx.removed() | |
1334 | if ctx.description(): |
|
1339 | if ctx.description(): | |
1335 | edittext.append(ctx.description()) |
|
1340 | edittext.append(ctx.description()) | |
1336 | edittext.append("") |
|
1341 | edittext.append("") | |
1337 | edittext.append("") # Empty line between message and comments. |
|
1342 | edittext.append("") # Empty line between message and comments. | |
1338 | edittext.append(_("HG: Enter commit message." |
|
1343 | edittext.append(_("HG: Enter commit message." | |
1339 | " Lines beginning with 'HG:' are removed.")) |
|
1344 | " Lines beginning with 'HG:' are removed.")) | |
1340 | edittext.append(_("HG: Leave message empty to abort commit.")) |
|
1345 | edittext.append(_("HG: Leave message empty to abort commit.")) | |
1341 | edittext.append("HG: --") |
|
1346 | edittext.append("HG: --") | |
1342 | edittext.append(_("HG: user: %s") % ctx.user()) |
|
1347 | edittext.append(_("HG: user: %s") % ctx.user()) | |
1343 | if ctx.p2(): |
|
1348 | if ctx.p2(): | |
1344 | edittext.append(_("HG: branch merge")) |
|
1349 | edittext.append(_("HG: branch merge")) | |
1345 | if ctx.branch(): |
|
1350 | if ctx.branch(): | |
1346 | edittext.append(_("HG: branch '%s'") |
|
1351 | edittext.append(_("HG: branch '%s'") | |
1347 | % encoding.tolocal(ctx.branch())) |
|
1352 | % encoding.tolocal(ctx.branch())) | |
1348 | edittext.extend([_("HG: subrepo %s") % s for s in subs]) |
|
1353 | edittext.extend([_("HG: subrepo %s") % s for s in subs]) | |
1349 | edittext.extend([_("HG: added %s") % f for f in added]) |
|
1354 | edittext.extend([_("HG: added %s") % f for f in added]) | |
1350 | edittext.extend([_("HG: changed %s") % f for f in modified]) |
|
1355 | edittext.extend([_("HG: changed %s") % f for f in modified]) | |
1351 | edittext.extend([_("HG: removed %s") % f for f in removed]) |
|
1356 | edittext.extend([_("HG: removed %s") % f for f in removed]) | |
1352 | if not added and not modified and not removed: |
|
1357 | if not added and not modified and not removed: | |
1353 | edittext.append(_("HG: no files changed")) |
|
1358 | edittext.append(_("HG: no files changed")) | |
1354 | edittext.append("") |
|
1359 | edittext.append("") | |
1355 | # run editor in the repository root |
|
1360 | # run editor in the repository root | |
1356 | olddir = os.getcwd() |
|
1361 | olddir = os.getcwd() | |
1357 | os.chdir(repo.root) |
|
1362 | os.chdir(repo.root) | |
1358 | text = repo.ui.edit("\n".join(edittext), ctx.user()) |
|
1363 | text = repo.ui.edit("\n".join(edittext), ctx.user()) | |
1359 | text = re.sub("(?m)^HG:.*(\n|$)", "", text) |
|
1364 | text = re.sub("(?m)^HG:.*(\n|$)", "", text) | |
1360 | os.chdir(olddir) |
|
1365 | os.chdir(olddir) | |
1361 |
|
1366 | |||
1362 | if not text.strip(): |
|
1367 | if not text.strip(): | |
1363 | raise util.Abort(_("empty commit message")) |
|
1368 | raise util.Abort(_("empty commit message")) | |
1364 |
|
1369 | |||
1365 | return text |
|
1370 | return text |
@@ -1,4525 +1,4526 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 of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import hex, nullid, nullrev, short |
|
8 | from node import hex, nullid, nullrev, short | |
9 | from lock import release |
|
9 | from lock import release | |
10 | from i18n import _, gettext |
|
10 | from i18n import _, gettext | |
11 | import os, re, sys, difflib, time, tempfile |
|
11 | import os, re, sys, difflib, time, tempfile | |
12 | import hg, util, revlog, extensions, copies, error |
|
12 | import hg, util, revlog, extensions, copies, error | |
13 | import patch, help, mdiff, url, encoding, templatekw, discovery |
|
13 | import patch, help, mdiff, url, encoding, templatekw, discovery | |
14 | import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server |
|
14 | import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server | |
15 | import merge as mergemod |
|
15 | import merge as mergemod | |
16 | import minirst, revset |
|
16 | import minirst, revset | |
17 | import dagparser |
|
17 | import dagparser | |
18 |
|
18 | |||
19 | # Commands start here, listed alphabetically |
|
19 | # Commands start here, listed alphabetically | |
20 |
|
20 | |||
21 | def add(ui, repo, *pats, **opts): |
|
21 | def add(ui, repo, *pats, **opts): | |
22 | """add the specified files on the next commit |
|
22 | """add the specified files on the next commit | |
23 |
|
23 | |||
24 | Schedule files to be version controlled and added to the |
|
24 | Schedule files to be version controlled and added to the | |
25 | repository. |
|
25 | repository. | |
26 |
|
26 | |||
27 | The files will be added to the repository at the next commit. To |
|
27 | The files will be added to the repository at the next commit. To | |
28 | undo an add before that, see :hg:`forget`. |
|
28 | undo an add before that, see :hg:`forget`. | |
29 |
|
29 | |||
30 | If no names are given, add all files to the repository. |
|
30 | If no names are given, add all files to the repository. | |
31 |
|
31 | |||
32 | .. container:: verbose |
|
32 | .. container:: verbose | |
33 |
|
33 | |||
34 | An example showing how new (unknown) files are added |
|
34 | An example showing how new (unknown) files are added | |
35 | automatically by :hg:`add`:: |
|
35 | automatically by :hg:`add`:: | |
36 |
|
36 | |||
37 | $ ls |
|
37 | $ ls | |
38 | foo.c |
|
38 | foo.c | |
39 | $ hg status |
|
39 | $ hg status | |
40 | ? foo.c |
|
40 | ? foo.c | |
41 | $ hg add |
|
41 | $ hg add | |
42 | adding foo.c |
|
42 | adding foo.c | |
43 | $ hg status |
|
43 | $ hg status | |
44 | A foo.c |
|
44 | A foo.c | |
45 |
|
45 | |||
46 | Returns 0 if all files are successfully added. |
|
46 | Returns 0 if all files are successfully added. | |
47 | """ |
|
47 | """ | |
48 |
|
48 | |||
49 | m = cmdutil.match(repo, pats, opts) |
|
49 | m = cmdutil.match(repo, pats, opts) | |
50 | rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'), |
|
50 | rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'), | |
51 | opts.get('subrepos'), prefix="") |
|
51 | opts.get('subrepos'), prefix="") | |
52 | return rejected and 1 or 0 |
|
52 | return rejected and 1 or 0 | |
53 |
|
53 | |||
54 | def addremove(ui, repo, *pats, **opts): |
|
54 | def addremove(ui, repo, *pats, **opts): | |
55 | """add all new files, delete all missing files |
|
55 | """add all new files, delete all missing files | |
56 |
|
56 | |||
57 | Add all new files and remove all missing files from the |
|
57 | Add all new files and remove all missing files from the | |
58 | repository. |
|
58 | repository. | |
59 |
|
59 | |||
60 | New files are ignored if they match any of the patterns in |
|
60 | New files are ignored if they match any of the patterns in | |
61 | .hgignore. As with add, these changes take effect at the next |
|
61 | .hgignore. As with add, these changes take effect at the next | |
62 | commit. |
|
62 | commit. | |
63 |
|
63 | |||
64 | Use the -s/--similarity option to detect renamed files. With a |
|
64 | Use the -s/--similarity option to detect renamed files. With a | |
65 | parameter greater than 0, this compares every removed file with |
|
65 | parameter greater than 0, this compares every removed file with | |
66 | every added file and records those similar enough as renames. This |
|
66 | every added file and records those similar enough as renames. This | |
67 | option takes a percentage between 0 (disabled) and 100 (files must |
|
67 | option takes a percentage between 0 (disabled) and 100 (files must | |
68 | be identical) as its parameter. Detecting renamed files this way |
|
68 | be identical) as its parameter. Detecting renamed files this way | |
69 | can be expensive. After using this option, :hg:`status -C` can be |
|
69 | can be expensive. After using this option, :hg:`status -C` can be | |
70 | used to check which files were identified as moved or renamed. |
|
70 | used to check which files were identified as moved or renamed. | |
71 |
|
71 | |||
72 | Returns 0 if all files are successfully added. |
|
72 | Returns 0 if all files are successfully added. | |
73 | """ |
|
73 | """ | |
74 | try: |
|
74 | try: | |
75 | sim = float(opts.get('similarity') or 100) |
|
75 | sim = float(opts.get('similarity') or 100) | |
76 | except ValueError: |
|
76 | except ValueError: | |
77 | raise util.Abort(_('similarity must be a number')) |
|
77 | raise util.Abort(_('similarity must be a number')) | |
78 | if sim < 0 or sim > 100: |
|
78 | if sim < 0 or sim > 100: | |
79 | raise util.Abort(_('similarity must be between 0 and 100')) |
|
79 | raise util.Abort(_('similarity must be between 0 and 100')) | |
80 | return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0) |
|
80 | return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0) | |
81 |
|
81 | |||
82 | def annotate(ui, repo, *pats, **opts): |
|
82 | def annotate(ui, repo, *pats, **opts): | |
83 | """show changeset information by line for each file |
|
83 | """show changeset information by line for each file | |
84 |
|
84 | |||
85 | List changes in files, showing the revision id responsible for |
|
85 | List changes in files, showing the revision id responsible for | |
86 | each line |
|
86 | each line | |
87 |
|
87 | |||
88 | This command is useful for discovering when a change was made and |
|
88 | This command is useful for discovering when a change was made and | |
89 | by whom. |
|
89 | by whom. | |
90 |
|
90 | |||
91 | Without the -a/--text option, annotate will avoid processing files |
|
91 | Without the -a/--text option, annotate will avoid processing files | |
92 | it detects as binary. With -a, annotate will annotate the file |
|
92 | it detects as binary. With -a, annotate will annotate the file | |
93 | anyway, although the results will probably be neither useful |
|
93 | anyway, although the results will probably be neither useful | |
94 | nor desirable. |
|
94 | nor desirable. | |
95 |
|
95 | |||
96 | Returns 0 on success. |
|
96 | Returns 0 on success. | |
97 | """ |
|
97 | """ | |
98 | if opts.get('follow'): |
|
98 | if opts.get('follow'): | |
99 | # --follow is deprecated and now just an alias for -f/--file |
|
99 | # --follow is deprecated and now just an alias for -f/--file | |
100 | # to mimic the behavior of Mercurial before version 1.5 |
|
100 | # to mimic the behavior of Mercurial before version 1.5 | |
101 | opts['file'] = 1 |
|
101 | opts['file'] = 1 | |
102 |
|
102 | |||
103 | datefunc = ui.quiet and util.shortdate or util.datestr |
|
103 | datefunc = ui.quiet and util.shortdate or util.datestr | |
104 | getdate = util.cachefunc(lambda x: datefunc(x[0].date())) |
|
104 | getdate = util.cachefunc(lambda x: datefunc(x[0].date())) | |
105 |
|
105 | |||
106 | if not pats: |
|
106 | if not pats: | |
107 | raise util.Abort(_('at least one filename or pattern is required')) |
|
107 | raise util.Abort(_('at least one filename or pattern is required')) | |
108 |
|
108 | |||
109 | opmap = [('user', lambda x: ui.shortuser(x[0].user())), |
|
109 | opmap = [('user', lambda x: ui.shortuser(x[0].user())), | |
110 | ('number', lambda x: str(x[0].rev())), |
|
110 | ('number', lambda x: str(x[0].rev())), | |
111 | ('changeset', lambda x: short(x[0].node())), |
|
111 | ('changeset', lambda x: short(x[0].node())), | |
112 | ('date', getdate), |
|
112 | ('date', getdate), | |
113 | ('file', lambda x: x[0].path()), |
|
113 | ('file', lambda x: x[0].path()), | |
114 | ] |
|
114 | ] | |
115 |
|
115 | |||
116 | if (not opts.get('user') and not opts.get('changeset') |
|
116 | if (not opts.get('user') and not opts.get('changeset') | |
117 | and not opts.get('date') and not opts.get('file')): |
|
117 | and not opts.get('date') and not opts.get('file')): | |
118 | opts['number'] = 1 |
|
118 | opts['number'] = 1 | |
119 |
|
119 | |||
120 | linenumber = opts.get('line_number') is not None |
|
120 | linenumber = opts.get('line_number') is not None | |
121 | if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
|
121 | if linenumber and (not opts.get('changeset')) and (not opts.get('number')): | |
122 | raise util.Abort(_('at least one of -n/-c is required for -l')) |
|
122 | raise util.Abort(_('at least one of -n/-c is required for -l')) | |
123 |
|
123 | |||
124 | funcmap = [func for op, func in opmap if opts.get(op)] |
|
124 | funcmap = [func for op, func in opmap if opts.get(op)] | |
125 | if linenumber: |
|
125 | if linenumber: | |
126 | lastfunc = funcmap[-1] |
|
126 | lastfunc = funcmap[-1] | |
127 | funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) |
|
127 | funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) | |
128 |
|
128 | |||
129 |
ctx = repo |
|
129 | ctx = cmdutil.revsingle(repo, opts.get('rev')) | |
130 | m = cmdutil.match(repo, pats, opts) |
|
130 | m = cmdutil.match(repo, pats, opts) | |
131 | follow = not opts.get('no_follow') |
|
131 | follow = not opts.get('no_follow') | |
132 | for abs in ctx.walk(m): |
|
132 | for abs in ctx.walk(m): | |
133 | fctx = ctx[abs] |
|
133 | fctx = ctx[abs] | |
134 | if not opts.get('text') and util.binary(fctx.data()): |
|
134 | if not opts.get('text') and util.binary(fctx.data()): | |
135 | ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) |
|
135 | ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) | |
136 | continue |
|
136 | continue | |
137 |
|
137 | |||
138 | lines = fctx.annotate(follow=follow, linenumber=linenumber) |
|
138 | lines = fctx.annotate(follow=follow, linenumber=linenumber) | |
139 | pieces = [] |
|
139 | pieces = [] | |
140 |
|
140 | |||
141 | for f in funcmap: |
|
141 | for f in funcmap: | |
142 | l = [f(n) for n, dummy in lines] |
|
142 | l = [f(n) for n, dummy in lines] | |
143 | if l: |
|
143 | if l: | |
144 | sized = [(x, encoding.colwidth(x)) for x in l] |
|
144 | sized = [(x, encoding.colwidth(x)) for x in l] | |
145 | ml = max([w for x, w in sized]) |
|
145 | ml = max([w for x, w in sized]) | |
146 | pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized]) |
|
146 | pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized]) | |
147 |
|
147 | |||
148 | if pieces: |
|
148 | if pieces: | |
149 | for p, l in zip(zip(*pieces), lines): |
|
149 | for p, l in zip(zip(*pieces), lines): | |
150 | ui.write("%s: %s" % (" ".join(p), l[1])) |
|
150 | ui.write("%s: %s" % (" ".join(p), l[1])) | |
151 |
|
151 | |||
152 | def archive(ui, repo, dest, **opts): |
|
152 | def archive(ui, repo, dest, **opts): | |
153 | '''create an unversioned archive of a repository revision |
|
153 | '''create an unversioned archive of a repository revision | |
154 |
|
154 | |||
155 | By default, the revision used is the parent of the working |
|
155 | By default, the revision used is the parent of the working | |
156 | directory; use -r/--rev to specify a different revision. |
|
156 | directory; use -r/--rev to specify a different revision. | |
157 |
|
157 | |||
158 | The archive type is automatically detected based on file |
|
158 | The archive type is automatically detected based on file | |
159 | extension (or override using -t/--type). |
|
159 | extension (or override using -t/--type). | |
160 |
|
160 | |||
161 | Valid types are: |
|
161 | Valid types are: | |
162 |
|
162 | |||
163 | :``files``: a directory full of files (default) |
|
163 | :``files``: a directory full of files (default) | |
164 | :``tar``: tar archive, uncompressed |
|
164 | :``tar``: tar archive, uncompressed | |
165 | :``tbz2``: tar archive, compressed using bzip2 |
|
165 | :``tbz2``: tar archive, compressed using bzip2 | |
166 | :``tgz``: tar archive, compressed using gzip |
|
166 | :``tgz``: tar archive, compressed using gzip | |
167 | :``uzip``: zip archive, uncompressed |
|
167 | :``uzip``: zip archive, uncompressed | |
168 | :``zip``: zip archive, compressed using deflate |
|
168 | :``zip``: zip archive, compressed using deflate | |
169 |
|
169 | |||
170 | The exact name of the destination archive or directory is given |
|
170 | The exact name of the destination archive or directory is given | |
171 | using a format string; see :hg:`help export` for details. |
|
171 | using a format string; see :hg:`help export` for details. | |
172 |
|
172 | |||
173 | Each member added to an archive file has a directory prefix |
|
173 | Each member added to an archive file has a directory prefix | |
174 | prepended. Use -p/--prefix to specify a format string for the |
|
174 | prepended. Use -p/--prefix to specify a format string for the | |
175 | prefix. The default is the basename of the archive, with suffixes |
|
175 | prefix. The default is the basename of the archive, with suffixes | |
176 | removed. |
|
176 | removed. | |
177 |
|
177 | |||
178 | Returns 0 on success. |
|
178 | Returns 0 on success. | |
179 | ''' |
|
179 | ''' | |
180 |
|
180 | |||
181 |
ctx = repo |
|
181 | ctx = cmdutil.revsingle(repo, opts.get('rev')) | |
182 | if not ctx: |
|
182 | if not ctx: | |
183 | raise util.Abort(_('no working directory: please specify a revision')) |
|
183 | raise util.Abort(_('no working directory: please specify a revision')) | |
184 | node = ctx.node() |
|
184 | node = ctx.node() | |
185 | dest = cmdutil.make_filename(repo, dest, node) |
|
185 | dest = cmdutil.make_filename(repo, dest, node) | |
186 | if os.path.realpath(dest) == repo.root: |
|
186 | if os.path.realpath(dest) == repo.root: | |
187 | raise util.Abort(_('repository root cannot be destination')) |
|
187 | raise util.Abort(_('repository root cannot be destination')) | |
188 |
|
188 | |||
189 | kind = opts.get('type') or archival.guesskind(dest) or 'files' |
|
189 | kind = opts.get('type') or archival.guesskind(dest) or 'files' | |
190 | prefix = opts.get('prefix') |
|
190 | prefix = opts.get('prefix') | |
191 |
|
191 | |||
192 | if dest == '-': |
|
192 | if dest == '-': | |
193 | if kind == 'files': |
|
193 | if kind == 'files': | |
194 | raise util.Abort(_('cannot archive plain files to stdout')) |
|
194 | raise util.Abort(_('cannot archive plain files to stdout')) | |
195 | dest = sys.stdout |
|
195 | dest = sys.stdout | |
196 | if not prefix: |
|
196 | if not prefix: | |
197 | prefix = os.path.basename(repo.root) + '-%h' |
|
197 | prefix = os.path.basename(repo.root) + '-%h' | |
198 |
|
198 | |||
199 | prefix = cmdutil.make_filename(repo, prefix, node) |
|
199 | prefix = cmdutil.make_filename(repo, prefix, node) | |
200 | matchfn = cmdutil.match(repo, [], opts) |
|
200 | matchfn = cmdutil.match(repo, [], opts) | |
201 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
|
201 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), | |
202 | matchfn, prefix, subrepos=opts.get('subrepos')) |
|
202 | matchfn, prefix, subrepos=opts.get('subrepos')) | |
203 |
|
203 | |||
204 | def backout(ui, repo, node=None, rev=None, **opts): |
|
204 | def backout(ui, repo, node=None, rev=None, **opts): | |
205 | '''reverse effect of earlier changeset |
|
205 | '''reverse effect of earlier changeset | |
206 |
|
206 | |||
207 | The backout command merges the reverse effect of the reverted |
|
207 | The backout command merges the reverse effect of the reverted | |
208 | changeset into the working directory. |
|
208 | changeset into the working directory. | |
209 |
|
209 | |||
210 | With the --merge option, it first commits the reverted changes |
|
210 | With the --merge option, it first commits the reverted changes | |
211 | as a new changeset. This new changeset is a child of the reverted |
|
211 | as a new changeset. This new changeset is a child of the reverted | |
212 | changeset. |
|
212 | changeset. | |
213 | The --merge option remembers the parent of the working directory |
|
213 | The --merge option remembers the parent of the working directory | |
214 | before starting the backout, then merges the new head with that |
|
214 | before starting the backout, then merges the new head with that | |
215 | changeset afterwards. |
|
215 | changeset afterwards. | |
216 | This will result in an explicit merge in the history. |
|
216 | This will result in an explicit merge in the history. | |
217 |
|
217 | |||
218 | If you backout a changeset other than the original parent of the |
|
218 | If you backout a changeset other than the original parent of the | |
219 | working directory, the result of this merge is not committed, |
|
219 | working directory, the result of this merge is not committed, | |
220 | as with a normal merge. Otherwise, no merge is needed and the |
|
220 | as with a normal merge. Otherwise, no merge is needed and the | |
221 | commit is automatic. |
|
221 | commit is automatic. | |
222 |
|
222 | |||
223 | Note that the default behavior (without --merge) has changed in |
|
223 | Note that the default behavior (without --merge) has changed in | |
224 | version 1.7. To restore the previous default behavior, use |
|
224 | version 1.7. To restore the previous default behavior, use | |
225 | :hg:`backout --merge` and then :hg:`update --clean .` to get rid of |
|
225 | :hg:`backout --merge` and then :hg:`update --clean .` to get rid of | |
226 | the ongoing merge. |
|
226 | the ongoing merge. | |
227 |
|
227 | |||
228 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
228 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
229 |
|
229 | |||
230 | Returns 0 on success. |
|
230 | Returns 0 on success. | |
231 | ''' |
|
231 | ''' | |
232 | if rev and node: |
|
232 | if rev and node: | |
233 | raise util.Abort(_("please specify just one revision")) |
|
233 | raise util.Abort(_("please specify just one revision")) | |
234 |
|
234 | |||
235 | if not rev: |
|
235 | if not rev: | |
236 | rev = node |
|
236 | rev = node | |
237 |
|
237 | |||
238 | if not rev: |
|
238 | if not rev: | |
239 | raise util.Abort(_("please specify a revision to backout")) |
|
239 | raise util.Abort(_("please specify a revision to backout")) | |
240 |
|
240 | |||
241 | date = opts.get('date') |
|
241 | date = opts.get('date') | |
242 | if date: |
|
242 | if date: | |
243 | opts['date'] = util.parsedate(date) |
|
243 | opts['date'] = util.parsedate(date) | |
244 |
|
244 | |||
245 | cmdutil.bail_if_changed(repo) |
|
245 | cmdutil.bail_if_changed(repo) | |
246 | node = repo.lookup(rev) |
|
246 | node = cmdutil.revsingle(repo, rev).node() | |
247 |
|
247 | |||
248 | op1, op2 = repo.dirstate.parents() |
|
248 | op1, op2 = repo.dirstate.parents() | |
249 | a = repo.changelog.ancestor(op1, node) |
|
249 | a = repo.changelog.ancestor(op1, node) | |
250 | if a != node: |
|
250 | if a != node: | |
251 | raise util.Abort(_('cannot backout change on a different branch')) |
|
251 | raise util.Abort(_('cannot backout change on a different branch')) | |
252 |
|
252 | |||
253 | p1, p2 = repo.changelog.parents(node) |
|
253 | p1, p2 = repo.changelog.parents(node) | |
254 | if p1 == nullid: |
|
254 | if p1 == nullid: | |
255 | raise util.Abort(_('cannot backout a change with no parents')) |
|
255 | raise util.Abort(_('cannot backout a change with no parents')) | |
256 | if p2 != nullid: |
|
256 | if p2 != nullid: | |
257 | if not opts.get('parent'): |
|
257 | if not opts.get('parent'): | |
258 | raise util.Abort(_('cannot backout a merge changeset without ' |
|
258 | raise util.Abort(_('cannot backout a merge changeset without ' | |
259 | '--parent')) |
|
259 | '--parent')) | |
260 | p = repo.lookup(opts['parent']) |
|
260 | p = repo.lookup(opts['parent']) | |
261 | if p not in (p1, p2): |
|
261 | if p not in (p1, p2): | |
262 | raise util.Abort(_('%s is not a parent of %s') % |
|
262 | raise util.Abort(_('%s is not a parent of %s') % | |
263 | (short(p), short(node))) |
|
263 | (short(p), short(node))) | |
264 | parent = p |
|
264 | parent = p | |
265 | else: |
|
265 | else: | |
266 | if opts.get('parent'): |
|
266 | if opts.get('parent'): | |
267 | raise util.Abort(_('cannot use --parent on non-merge changeset')) |
|
267 | raise util.Abort(_('cannot use --parent on non-merge changeset')) | |
268 | parent = p1 |
|
268 | parent = p1 | |
269 |
|
269 | |||
270 | # the backout should appear on the same branch |
|
270 | # the backout should appear on the same branch | |
271 | branch = repo.dirstate.branch() |
|
271 | branch = repo.dirstate.branch() | |
272 | hg.clean(repo, node, show_stats=False) |
|
272 | hg.clean(repo, node, show_stats=False) | |
273 | repo.dirstate.setbranch(branch) |
|
273 | repo.dirstate.setbranch(branch) | |
274 | revert_opts = opts.copy() |
|
274 | revert_opts = opts.copy() | |
275 | revert_opts['date'] = None |
|
275 | revert_opts['date'] = None | |
276 | revert_opts['all'] = True |
|
276 | revert_opts['all'] = True | |
277 | revert_opts['rev'] = hex(parent) |
|
277 | revert_opts['rev'] = hex(parent) | |
278 | revert_opts['no_backup'] = None |
|
278 | revert_opts['no_backup'] = None | |
279 | revert(ui, repo, **revert_opts) |
|
279 | revert(ui, repo, **revert_opts) | |
280 | if not opts.get('merge') and op1 != node: |
|
280 | if not opts.get('merge') and op1 != node: | |
281 | try: |
|
281 | try: | |
282 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
|
282 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) | |
283 | return hg.update(repo, op1) |
|
283 | return hg.update(repo, op1) | |
284 | finally: |
|
284 | finally: | |
285 | ui.setconfig('ui', 'forcemerge', '') |
|
285 | ui.setconfig('ui', 'forcemerge', '') | |
286 |
|
286 | |||
287 | commit_opts = opts.copy() |
|
287 | commit_opts = opts.copy() | |
288 | commit_opts['addremove'] = False |
|
288 | commit_opts['addremove'] = False | |
289 | if not commit_opts['message'] and not commit_opts['logfile']: |
|
289 | if not commit_opts['message'] and not commit_opts['logfile']: | |
290 | # we don't translate commit messages |
|
290 | # we don't translate commit messages | |
291 | commit_opts['message'] = "Backed out changeset %s" % short(node) |
|
291 | commit_opts['message'] = "Backed out changeset %s" % short(node) | |
292 | commit_opts['force_editor'] = True |
|
292 | commit_opts['force_editor'] = True | |
293 | commit(ui, repo, **commit_opts) |
|
293 | commit(ui, repo, **commit_opts) | |
294 | def nice(node): |
|
294 | def nice(node): | |
295 | return '%d:%s' % (repo.changelog.rev(node), short(node)) |
|
295 | return '%d:%s' % (repo.changelog.rev(node), short(node)) | |
296 | ui.status(_('changeset %s backs out changeset %s\n') % |
|
296 | ui.status(_('changeset %s backs out changeset %s\n') % | |
297 | (nice(repo.changelog.tip()), nice(node))) |
|
297 | (nice(repo.changelog.tip()), nice(node))) | |
298 | if opts.get('merge') and op1 != node: |
|
298 | if opts.get('merge') and op1 != node: | |
299 | hg.clean(repo, op1, show_stats=False) |
|
299 | hg.clean(repo, op1, show_stats=False) | |
300 | ui.status(_('merging with changeset %s\n') |
|
300 | ui.status(_('merging with changeset %s\n') | |
301 | % nice(repo.changelog.tip())) |
|
301 | % nice(repo.changelog.tip())) | |
302 | try: |
|
302 | try: | |
303 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
|
303 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) | |
304 | return hg.merge(repo, hex(repo.changelog.tip())) |
|
304 | return hg.merge(repo, hex(repo.changelog.tip())) | |
305 | finally: |
|
305 | finally: | |
306 | ui.setconfig('ui', 'forcemerge', '') |
|
306 | ui.setconfig('ui', 'forcemerge', '') | |
307 | return 0 |
|
307 | return 0 | |
308 |
|
308 | |||
309 | def bisect(ui, repo, rev=None, extra=None, command=None, |
|
309 | def bisect(ui, repo, rev=None, extra=None, command=None, | |
310 | reset=None, good=None, bad=None, skip=None, noupdate=None): |
|
310 | reset=None, good=None, bad=None, skip=None, noupdate=None): | |
311 | """subdivision search of changesets |
|
311 | """subdivision search of changesets | |
312 |
|
312 | |||
313 | This command helps to find changesets which introduce problems. To |
|
313 | This command helps to find changesets which introduce problems. To | |
314 | use, mark the earliest changeset you know exhibits the problem as |
|
314 | use, mark the earliest changeset you know exhibits the problem as | |
315 | bad, then mark the latest changeset which is free from the problem |
|
315 | bad, then mark the latest changeset which is free from the problem | |
316 | as good. Bisect will update your working directory to a revision |
|
316 | as good. Bisect will update your working directory to a revision | |
317 | for testing (unless the -U/--noupdate option is specified). Once |
|
317 | for testing (unless the -U/--noupdate option is specified). Once | |
318 | you have performed tests, mark the working directory as good or |
|
318 | you have performed tests, mark the working directory as good or | |
319 | bad, and bisect will either update to another candidate changeset |
|
319 | bad, and bisect will either update to another candidate changeset | |
320 | or announce that it has found the bad revision. |
|
320 | or announce that it has found the bad revision. | |
321 |
|
321 | |||
322 | As a shortcut, you can also use the revision argument to mark a |
|
322 | As a shortcut, you can also use the revision argument to mark a | |
323 | revision as good or bad without checking it out first. |
|
323 | revision as good or bad without checking it out first. | |
324 |
|
324 | |||
325 | If you supply a command, it will be used for automatic bisection. |
|
325 | If you supply a command, it will be used for automatic bisection. | |
326 | Its exit status will be used to mark revisions as good or bad: |
|
326 | Its exit status will be used to mark revisions as good or bad: | |
327 | status 0 means good, 125 means to skip the revision, 127 |
|
327 | status 0 means good, 125 means to skip the revision, 127 | |
328 | (command not found) will abort the bisection, and any other |
|
328 | (command not found) will abort the bisection, and any other | |
329 | non-zero exit status means the revision is bad. |
|
329 | non-zero exit status means the revision is bad. | |
330 |
|
330 | |||
331 | Returns 0 on success. |
|
331 | Returns 0 on success. | |
332 | """ |
|
332 | """ | |
333 | def print_result(nodes, good): |
|
333 | def print_result(nodes, good): | |
334 | displayer = cmdutil.show_changeset(ui, repo, {}) |
|
334 | displayer = cmdutil.show_changeset(ui, repo, {}) | |
335 | if len(nodes) == 1: |
|
335 | if len(nodes) == 1: | |
336 | # narrowed it down to a single revision |
|
336 | # narrowed it down to a single revision | |
337 | if good: |
|
337 | if good: | |
338 | ui.write(_("The first good revision is:\n")) |
|
338 | ui.write(_("The first good revision is:\n")) | |
339 | else: |
|
339 | else: | |
340 | ui.write(_("The first bad revision is:\n")) |
|
340 | ui.write(_("The first bad revision is:\n")) | |
341 | displayer.show(repo[nodes[0]]) |
|
341 | displayer.show(repo[nodes[0]]) | |
342 | parents = repo[nodes[0]].parents() |
|
342 | parents = repo[nodes[0]].parents() | |
343 | if len(parents) > 1: |
|
343 | if len(parents) > 1: | |
344 | side = good and state['bad'] or state['good'] |
|
344 | side = good and state['bad'] or state['good'] | |
345 | num = len(set(i.node() for i in parents) & set(side)) |
|
345 | num = len(set(i.node() for i in parents) & set(side)) | |
346 | if num == 1: |
|
346 | if num == 1: | |
347 | common = parents[0].ancestor(parents[1]) |
|
347 | common = parents[0].ancestor(parents[1]) | |
348 | ui.write(_('Not all ancestors of this changeset have been' |
|
348 | ui.write(_('Not all ancestors of this changeset have been' | |
349 | ' checked.\nTo check the other ancestors, start' |
|
349 | ' checked.\nTo check the other ancestors, start' | |
350 | ' from the common ancestor, %s.\n' % common)) |
|
350 | ' from the common ancestor, %s.\n' % common)) | |
351 | else: |
|
351 | else: | |
352 | # multiple possible revisions |
|
352 | # multiple possible revisions | |
353 | if good: |
|
353 | if good: | |
354 | ui.write(_("Due to skipped revisions, the first " |
|
354 | ui.write(_("Due to skipped revisions, the first " | |
355 | "good revision could be any of:\n")) |
|
355 | "good revision could be any of:\n")) | |
356 | else: |
|
356 | else: | |
357 | ui.write(_("Due to skipped revisions, the first " |
|
357 | ui.write(_("Due to skipped revisions, the first " | |
358 | "bad revision could be any of:\n")) |
|
358 | "bad revision could be any of:\n")) | |
359 | for n in nodes: |
|
359 | for n in nodes: | |
360 | displayer.show(repo[n]) |
|
360 | displayer.show(repo[n]) | |
361 | displayer.close() |
|
361 | displayer.close() | |
362 |
|
362 | |||
363 | def check_state(state, interactive=True): |
|
363 | def check_state(state, interactive=True): | |
364 | if not state['good'] or not state['bad']: |
|
364 | if not state['good'] or not state['bad']: | |
365 | if (good or bad or skip or reset) and interactive: |
|
365 | if (good or bad or skip or reset) and interactive: | |
366 | return |
|
366 | return | |
367 | if not state['good']: |
|
367 | if not state['good']: | |
368 | raise util.Abort(_('cannot bisect (no known good revisions)')) |
|
368 | raise util.Abort(_('cannot bisect (no known good revisions)')) | |
369 | else: |
|
369 | else: | |
370 | raise util.Abort(_('cannot bisect (no known bad revisions)')) |
|
370 | raise util.Abort(_('cannot bisect (no known bad revisions)')) | |
371 | return True |
|
371 | return True | |
372 |
|
372 | |||
373 | # backward compatibility |
|
373 | # backward compatibility | |
374 | if rev in "good bad reset init".split(): |
|
374 | if rev in "good bad reset init".split(): | |
375 | ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) |
|
375 | ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) | |
376 | cmd, rev, extra = rev, extra, None |
|
376 | cmd, rev, extra = rev, extra, None | |
377 | if cmd == "good": |
|
377 | if cmd == "good": | |
378 | good = True |
|
378 | good = True | |
379 | elif cmd == "bad": |
|
379 | elif cmd == "bad": | |
380 | bad = True |
|
380 | bad = True | |
381 | else: |
|
381 | else: | |
382 | reset = True |
|
382 | reset = True | |
383 | elif extra or good + bad + skip + reset + bool(command) > 1: |
|
383 | elif extra or good + bad + skip + reset + bool(command) > 1: | |
384 | raise util.Abort(_('incompatible arguments')) |
|
384 | raise util.Abort(_('incompatible arguments')) | |
385 |
|
385 | |||
386 | if reset: |
|
386 | if reset: | |
387 | p = repo.join("bisect.state") |
|
387 | p = repo.join("bisect.state") | |
388 | if os.path.exists(p): |
|
388 | if os.path.exists(p): | |
389 | os.unlink(p) |
|
389 | os.unlink(p) | |
390 | return |
|
390 | return | |
391 |
|
391 | |||
392 | state = hbisect.load_state(repo) |
|
392 | state = hbisect.load_state(repo) | |
393 |
|
393 | |||
394 | if command: |
|
394 | if command: | |
395 | changesets = 1 |
|
395 | changesets = 1 | |
396 | try: |
|
396 | try: | |
397 | while changesets: |
|
397 | while changesets: | |
398 | # update state |
|
398 | # update state | |
399 | status = util.system(command) |
|
399 | status = util.system(command) | |
400 | if status == 125: |
|
400 | if status == 125: | |
401 | transition = "skip" |
|
401 | transition = "skip" | |
402 | elif status == 0: |
|
402 | elif status == 0: | |
403 | transition = "good" |
|
403 | transition = "good" | |
404 | # status < 0 means process was killed |
|
404 | # status < 0 means process was killed | |
405 | elif status == 127: |
|
405 | elif status == 127: | |
406 | raise util.Abort(_("failed to execute %s") % command) |
|
406 | raise util.Abort(_("failed to execute %s") % command) | |
407 | elif status < 0: |
|
407 | elif status < 0: | |
408 | raise util.Abort(_("%s killed") % command) |
|
408 | raise util.Abort(_("%s killed") % command) | |
409 | else: |
|
409 | else: | |
410 | transition = "bad" |
|
410 | transition = "bad" | |
411 |
ctx = repo |
|
411 | ctx = cmdutil.revsingle(repo, rev) | |
|
412 | rev = None # clear for future iterations | |||
412 | state[transition].append(ctx.node()) |
|
413 | state[transition].append(ctx.node()) | |
413 | ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition)) |
|
414 | ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition)) | |
414 | check_state(state, interactive=False) |
|
415 | check_state(state, interactive=False) | |
415 | # bisect |
|
416 | # bisect | |
416 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
|
417 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) | |
417 | # update to next check |
|
418 | # update to next check | |
418 | cmdutil.bail_if_changed(repo) |
|
419 | cmdutil.bail_if_changed(repo) | |
419 | hg.clean(repo, nodes[0], show_stats=False) |
|
420 | hg.clean(repo, nodes[0], show_stats=False) | |
420 | finally: |
|
421 | finally: | |
421 | hbisect.save_state(repo, state) |
|
422 | hbisect.save_state(repo, state) | |
422 | print_result(nodes, good) |
|
423 | print_result(nodes, good) | |
423 | return |
|
424 | return | |
424 |
|
425 | |||
425 | # update state |
|
426 | # update state | |
426 |
|
427 | |||
427 | if rev: |
|
428 | if rev: | |
428 | nodes = [repo.lookup(i) for i in cmdutil.revrange(repo, [rev])] |
|
429 | nodes = [repo.lookup(i) for i in cmdutil.revrange(repo, [rev])] | |
429 | else: |
|
430 | else: | |
430 | nodes = [repo.lookup('.')] |
|
431 | nodes = [repo.lookup('.')] | |
431 |
|
432 | |||
432 | if good or bad or skip: |
|
433 | if good or bad or skip: | |
433 | if good: |
|
434 | if good: | |
434 | state['good'] += nodes |
|
435 | state['good'] += nodes | |
435 | elif bad: |
|
436 | elif bad: | |
436 | state['bad'] += nodes |
|
437 | state['bad'] += nodes | |
437 | elif skip: |
|
438 | elif skip: | |
438 | state['skip'] += nodes |
|
439 | state['skip'] += nodes | |
439 | hbisect.save_state(repo, state) |
|
440 | hbisect.save_state(repo, state) | |
440 |
|
441 | |||
441 | if not check_state(state): |
|
442 | if not check_state(state): | |
442 | return |
|
443 | return | |
443 |
|
444 | |||
444 | # actually bisect |
|
445 | # actually bisect | |
445 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
|
446 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) | |
446 | if changesets == 0: |
|
447 | if changesets == 0: | |
447 | print_result(nodes, good) |
|
448 | print_result(nodes, good) | |
448 | else: |
|
449 | else: | |
449 | assert len(nodes) == 1 # only a single node can be tested next |
|
450 | assert len(nodes) == 1 # only a single node can be tested next | |
450 | node = nodes[0] |
|
451 | node = nodes[0] | |
451 | # compute the approximate number of remaining tests |
|
452 | # compute the approximate number of remaining tests | |
452 | tests, size = 0, 2 |
|
453 | tests, size = 0, 2 | |
453 | while size <= changesets: |
|
454 | while size <= changesets: | |
454 | tests, size = tests + 1, size * 2 |
|
455 | tests, size = tests + 1, size * 2 | |
455 | rev = repo.changelog.rev(node) |
|
456 | rev = repo.changelog.rev(node) | |
456 | ui.write(_("Testing changeset %d:%s " |
|
457 | ui.write(_("Testing changeset %d:%s " | |
457 | "(%d changesets remaining, ~%d tests)\n") |
|
458 | "(%d changesets remaining, ~%d tests)\n") | |
458 | % (rev, short(node), changesets, tests)) |
|
459 | % (rev, short(node), changesets, tests)) | |
459 | if not noupdate: |
|
460 | if not noupdate: | |
460 | cmdutil.bail_if_changed(repo) |
|
461 | cmdutil.bail_if_changed(repo) | |
461 | return hg.clean(repo, node) |
|
462 | return hg.clean(repo, node) | |
462 |
|
463 | |||
463 | def branch(ui, repo, label=None, **opts): |
|
464 | def branch(ui, repo, label=None, **opts): | |
464 | """set or show the current branch name |
|
465 | """set or show the current branch name | |
465 |
|
466 | |||
466 | With no argument, show the current branch name. With one argument, |
|
467 | With no argument, show the current branch name. With one argument, | |
467 | set the working directory branch name (the branch will not exist |
|
468 | set the working directory branch name (the branch will not exist | |
468 | in the repository until the next commit). Standard practice |
|
469 | in the repository until the next commit). Standard practice | |
469 | recommends that primary development take place on the 'default' |
|
470 | recommends that primary development take place on the 'default' | |
470 | branch. |
|
471 | branch. | |
471 |
|
472 | |||
472 | Unless -f/--force is specified, branch will not let you set a |
|
473 | Unless -f/--force is specified, branch will not let you set a | |
473 | branch name that already exists, even if it's inactive. |
|
474 | branch name that already exists, even if it's inactive. | |
474 |
|
475 | |||
475 | Use -C/--clean to reset the working directory branch to that of |
|
476 | Use -C/--clean to reset the working directory branch to that of | |
476 | the parent of the working directory, negating a previous branch |
|
477 | the parent of the working directory, negating a previous branch | |
477 | change. |
|
478 | change. | |
478 |
|
479 | |||
479 | Use the command :hg:`update` to switch to an existing branch. Use |
|
480 | Use the command :hg:`update` to switch to an existing branch. Use | |
480 | :hg:`commit --close-branch` to mark this branch as closed. |
|
481 | :hg:`commit --close-branch` to mark this branch as closed. | |
481 |
|
482 | |||
482 | Returns 0 on success. |
|
483 | Returns 0 on success. | |
483 | """ |
|
484 | """ | |
484 |
|
485 | |||
485 | if opts.get('clean'): |
|
486 | if opts.get('clean'): | |
486 | label = repo[None].parents()[0].branch() |
|
487 | label = repo[None].parents()[0].branch() | |
487 | repo.dirstate.setbranch(label) |
|
488 | repo.dirstate.setbranch(label) | |
488 | ui.status(_('reset working directory to branch %s\n') % label) |
|
489 | ui.status(_('reset working directory to branch %s\n') % label) | |
489 | elif label: |
|
490 | elif label: | |
490 | utflabel = encoding.fromlocal(label) |
|
491 | utflabel = encoding.fromlocal(label) | |
491 | if not opts.get('force') and utflabel in repo.branchtags(): |
|
492 | if not opts.get('force') and utflabel in repo.branchtags(): | |
492 | if label not in [p.branch() for p in repo.parents()]: |
|
493 | if label not in [p.branch() for p in repo.parents()]: | |
493 | raise util.Abort(_('a branch of the same name already exists' |
|
494 | raise util.Abort(_('a branch of the same name already exists' | |
494 | " (use 'hg update' to switch to it)")) |
|
495 | " (use 'hg update' to switch to it)")) | |
495 | repo.dirstate.setbranch(utflabel) |
|
496 | repo.dirstate.setbranch(utflabel) | |
496 | ui.status(_('marked working directory as branch %s\n') % label) |
|
497 | ui.status(_('marked working directory as branch %s\n') % label) | |
497 | else: |
|
498 | else: | |
498 | ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) |
|
499 | ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) | |
499 |
|
500 | |||
500 | def branches(ui, repo, active=False, closed=False): |
|
501 | def branches(ui, repo, active=False, closed=False): | |
501 | """list repository named branches |
|
502 | """list repository named branches | |
502 |
|
503 | |||
503 | List the repository's named branches, indicating which ones are |
|
504 | List the repository's named branches, indicating which ones are | |
504 | inactive. If -c/--closed is specified, also list branches which have |
|
505 | inactive. If -c/--closed is specified, also list branches which have | |
505 | been marked closed (see :hg:`commit --close-branch`). |
|
506 | been marked closed (see :hg:`commit --close-branch`). | |
506 |
|
507 | |||
507 | If -a/--active is specified, only show active branches. A branch |
|
508 | If -a/--active is specified, only show active branches. A branch | |
508 | is considered active if it contains repository heads. |
|
509 | is considered active if it contains repository heads. | |
509 |
|
510 | |||
510 | Use the command :hg:`update` to switch to an existing branch. |
|
511 | Use the command :hg:`update` to switch to an existing branch. | |
511 |
|
512 | |||
512 | Returns 0. |
|
513 | Returns 0. | |
513 | """ |
|
514 | """ | |
514 |
|
515 | |||
515 | hexfunc = ui.debugflag and hex or short |
|
516 | hexfunc = ui.debugflag and hex or short | |
516 | activebranches = [repo[n].branch() for n in repo.heads()] |
|
517 | activebranches = [repo[n].branch() for n in repo.heads()] | |
517 | def testactive(tag, node): |
|
518 | def testactive(tag, node): | |
518 | realhead = tag in activebranches |
|
519 | realhead = tag in activebranches | |
519 | open = node in repo.branchheads(tag, closed=False) |
|
520 | open = node in repo.branchheads(tag, closed=False) | |
520 | return realhead and open |
|
521 | return realhead and open | |
521 | branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag) |
|
522 | branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag) | |
522 | for tag, node in repo.branchtags().items()], |
|
523 | for tag, node in repo.branchtags().items()], | |
523 | reverse=True) |
|
524 | reverse=True) | |
524 |
|
525 | |||
525 | for isactive, node, tag in branches: |
|
526 | for isactive, node, tag in branches: | |
526 | if (not active) or isactive: |
|
527 | if (not active) or isactive: | |
527 | encodedtag = encoding.tolocal(tag) |
|
528 | encodedtag = encoding.tolocal(tag) | |
528 | if ui.quiet: |
|
529 | if ui.quiet: | |
529 | ui.write("%s\n" % encodedtag) |
|
530 | ui.write("%s\n" % encodedtag) | |
530 | else: |
|
531 | else: | |
531 | hn = repo.lookup(node) |
|
532 | hn = repo.lookup(node) | |
532 | if isactive: |
|
533 | if isactive: | |
533 | label = 'branches.active' |
|
534 | label = 'branches.active' | |
534 | notice = '' |
|
535 | notice = '' | |
535 | elif hn not in repo.branchheads(tag, closed=False): |
|
536 | elif hn not in repo.branchheads(tag, closed=False): | |
536 | if not closed: |
|
537 | if not closed: | |
537 | continue |
|
538 | continue | |
538 | label = 'branches.closed' |
|
539 | label = 'branches.closed' | |
539 | notice = _(' (closed)') |
|
540 | notice = _(' (closed)') | |
540 | else: |
|
541 | else: | |
541 | label = 'branches.inactive' |
|
542 | label = 'branches.inactive' | |
542 | notice = _(' (inactive)') |
|
543 | notice = _(' (inactive)') | |
543 | if tag == repo.dirstate.branch(): |
|
544 | if tag == repo.dirstate.branch(): | |
544 | label = 'branches.current' |
|
545 | label = 'branches.current' | |
545 | rev = str(node).rjust(31 - encoding.colwidth(encodedtag)) |
|
546 | rev = str(node).rjust(31 - encoding.colwidth(encodedtag)) | |
546 | rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset') |
|
547 | rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset') | |
547 | encodedtag = ui.label(encodedtag, label) |
|
548 | encodedtag = ui.label(encodedtag, label) | |
548 | ui.write("%s %s%s\n" % (encodedtag, rev, notice)) |
|
549 | ui.write("%s %s%s\n" % (encodedtag, rev, notice)) | |
549 |
|
550 | |||
550 | def bundle(ui, repo, fname, dest=None, **opts): |
|
551 | def bundle(ui, repo, fname, dest=None, **opts): | |
551 | """create a changegroup file |
|
552 | """create a changegroup file | |
552 |
|
553 | |||
553 | Generate a compressed changegroup file collecting changesets not |
|
554 | Generate a compressed changegroup file collecting changesets not | |
554 | known to be in another repository. |
|
555 | known to be in another repository. | |
555 |
|
556 | |||
556 | If you omit the destination repository, then hg assumes the |
|
557 | If you omit the destination repository, then hg assumes the | |
557 | destination will have all the nodes you specify with --base |
|
558 | destination will have all the nodes you specify with --base | |
558 | parameters. To create a bundle containing all changesets, use |
|
559 | parameters. To create a bundle containing all changesets, use | |
559 | -a/--all (or --base null). |
|
560 | -a/--all (or --base null). | |
560 |
|
561 | |||
561 | You can change compression method with the -t/--type option. |
|
562 | You can change compression method with the -t/--type option. | |
562 | The available compression methods are: none, bzip2, and |
|
563 | The available compression methods are: none, bzip2, and | |
563 | gzip (by default, bundles are compressed using bzip2). |
|
564 | gzip (by default, bundles are compressed using bzip2). | |
564 |
|
565 | |||
565 | The bundle file can then be transferred using conventional means |
|
566 | The bundle file can then be transferred using conventional means | |
566 | and applied to another repository with the unbundle or pull |
|
567 | and applied to another repository with the unbundle or pull | |
567 | command. This is useful when direct push and pull are not |
|
568 | command. This is useful when direct push and pull are not | |
568 | available or when exporting an entire repository is undesirable. |
|
569 | available or when exporting an entire repository is undesirable. | |
569 |
|
570 | |||
570 | Applying bundles preserves all changeset contents including |
|
571 | Applying bundles preserves all changeset contents including | |
571 | permissions, copy/rename information, and revision history. |
|
572 | permissions, copy/rename information, and revision history. | |
572 |
|
573 | |||
573 | Returns 0 on success, 1 if no changes found. |
|
574 | Returns 0 on success, 1 if no changes found. | |
574 | """ |
|
575 | """ | |
575 |
revs = |
|
576 | revs = None | |
|
577 | if 'rev' in opts: | |||
|
578 | revs = cmdutil.revrange(repo, opts['rev']) | |||
|
579 | ||||
576 | if opts.get('all'): |
|
580 | if opts.get('all'): | |
577 | base = ['null'] |
|
581 | base = ['null'] | |
578 | else: |
|
582 | else: | |
579 | base = opts.get('base') |
|
583 | base = cmdutil.revrange(repo, opts.get('base')) | |
580 | if base: |
|
584 | if base: | |
581 | if dest: |
|
585 | if dest: | |
582 | raise util.Abort(_("--base is incompatible with specifying " |
|
586 | raise util.Abort(_("--base is incompatible with specifying " | |
583 | "a destination")) |
|
587 | "a destination")) | |
584 | base = [repo.lookup(rev) for rev in base] |
|
588 | base = [repo.lookup(rev) for rev in base] | |
585 | # create the right base |
|
589 | # create the right base | |
586 | # XXX: nodesbetween / changegroup* should be "fixed" instead |
|
590 | # XXX: nodesbetween / changegroup* should be "fixed" instead | |
587 | o = [] |
|
591 | o = [] | |
588 | has = set((nullid,)) |
|
592 | has = set((nullid,)) | |
589 | for n in base: |
|
593 | for n in base: | |
590 | has.update(repo.changelog.reachable(n)) |
|
594 | has.update(repo.changelog.reachable(n)) | |
591 | if revs: |
|
595 | if revs: | |
592 | revs = [repo.lookup(rev) for rev in revs] |
|
596 | revs = [repo.lookup(rev) for rev in revs] | |
593 | visit = revs[:] |
|
597 | visit = revs[:] | |
594 | has.difference_update(visit) |
|
598 | has.difference_update(visit) | |
595 | else: |
|
599 | else: | |
596 | visit = repo.changelog.heads() |
|
600 | visit = repo.changelog.heads() | |
597 | seen = {} |
|
601 | seen = {} | |
598 | while visit: |
|
602 | while visit: | |
599 | n = visit.pop(0) |
|
603 | n = visit.pop(0) | |
600 | parents = [p for p in repo.changelog.parents(n) if p not in has] |
|
604 | parents = [p for p in repo.changelog.parents(n) if p not in has] | |
601 | if len(parents) == 0: |
|
605 | if len(parents) == 0: | |
602 | if n not in has: |
|
606 | if n not in has: | |
603 | o.append(n) |
|
607 | o.append(n) | |
604 | else: |
|
608 | else: | |
605 | for p in parents: |
|
609 | for p in parents: | |
606 | if p not in seen: |
|
610 | if p not in seen: | |
607 | seen[p] = 1 |
|
611 | seen[p] = 1 | |
608 | visit.append(p) |
|
612 | visit.append(p) | |
609 | else: |
|
613 | else: | |
610 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
614 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
611 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
615 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
612 | other = hg.repository(hg.remoteui(repo, opts), dest) |
|
616 | other = hg.repository(hg.remoteui(repo, opts), dest) | |
613 | revs, checkout = hg.addbranchrevs(repo, other, branches, revs) |
|
617 | revs, checkout = hg.addbranchrevs(repo, other, branches, revs) | |
614 | if revs: |
|
618 | if revs: | |
615 | revs = [repo.lookup(rev) for rev in revs] |
|
619 | revs = [repo.lookup(rev) for rev in revs] | |
616 | o = discovery.findoutgoing(repo, other, force=opts.get('force')) |
|
620 | o = discovery.findoutgoing(repo, other, force=opts.get('force')) | |
617 |
|
621 | |||
618 | if not o: |
|
622 | if not o: | |
619 | ui.status(_("no changes found\n")) |
|
623 | ui.status(_("no changes found\n")) | |
620 | return 1 |
|
624 | return 1 | |
621 |
|
625 | |||
622 | if revs: |
|
626 | if revs: | |
623 | cg = repo.changegroupsubset(o, revs, 'bundle') |
|
627 | cg = repo.changegroupsubset(o, revs, 'bundle') | |
624 | else: |
|
628 | else: | |
625 | cg = repo.changegroup(o, 'bundle') |
|
629 | cg = repo.changegroup(o, 'bundle') | |
626 |
|
630 | |||
627 | bundletype = opts.get('type', 'bzip2').lower() |
|
631 | bundletype = opts.get('type', 'bzip2').lower() | |
628 | btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} |
|
632 | btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} | |
629 | bundletype = btypes.get(bundletype) |
|
633 | bundletype = btypes.get(bundletype) | |
630 | if bundletype not in changegroup.bundletypes: |
|
634 | if bundletype not in changegroup.bundletypes: | |
631 | raise util.Abort(_('unknown bundle type specified with --type')) |
|
635 | raise util.Abort(_('unknown bundle type specified with --type')) | |
632 |
|
636 | |||
633 | changegroup.writebundle(cg, fname, bundletype) |
|
637 | changegroup.writebundle(cg, fname, bundletype) | |
634 |
|
638 | |||
635 | def cat(ui, repo, file1, *pats, **opts): |
|
639 | def cat(ui, repo, file1, *pats, **opts): | |
636 | """output the current or given revision of files |
|
640 | """output the current or given revision of files | |
637 |
|
641 | |||
638 | Print the specified files as they were at the given revision. If |
|
642 | Print the specified files as they were at the given revision. If | |
639 | no revision is given, the parent of the working directory is used, |
|
643 | no revision is given, the parent of the working directory is used, | |
640 | or tip if no revision is checked out. |
|
644 | or tip if no revision is checked out. | |
641 |
|
645 | |||
642 | Output may be to a file, in which case the name of the file is |
|
646 | Output may be to a file, in which case the name of the file is | |
643 | given using a format string. The formatting rules are the same as |
|
647 | given using a format string. The formatting rules are the same as | |
644 | for the export command, with the following additions: |
|
648 | for the export command, with the following additions: | |
645 |
|
649 | |||
646 | :``%s``: basename of file being printed |
|
650 | :``%s``: basename of file being printed | |
647 | :``%d``: dirname of file being printed, or '.' if in repository root |
|
651 | :``%d``: dirname of file being printed, or '.' if in repository root | |
648 | :``%p``: root-relative path name of file being printed |
|
652 | :``%p``: root-relative path name of file being printed | |
649 |
|
653 | |||
650 | Returns 0 on success. |
|
654 | Returns 0 on success. | |
651 | """ |
|
655 | """ | |
652 | ctx = cmdutil.revsingle(repo, opts.get('rev')) |
|
656 | ctx = cmdutil.revsingle(repo, opts.get('rev')) | |
653 | err = 1 |
|
657 | err = 1 | |
654 | m = cmdutil.match(repo, (file1,) + pats, opts) |
|
658 | m = cmdutil.match(repo, (file1,) + pats, opts) | |
655 | for abs in ctx.walk(m): |
|
659 | for abs in ctx.walk(m): | |
656 | fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs) |
|
660 | fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs) | |
657 | data = ctx[abs].data() |
|
661 | data = ctx[abs].data() | |
658 | if opts.get('decode'): |
|
662 | if opts.get('decode'): | |
659 | data = repo.wwritedata(abs, data) |
|
663 | data = repo.wwritedata(abs, data) | |
660 | fp.write(data) |
|
664 | fp.write(data) | |
661 | err = 0 |
|
665 | err = 0 | |
662 | return err |
|
666 | return err | |
663 |
|
667 | |||
664 | def clone(ui, source, dest=None, **opts): |
|
668 | def clone(ui, source, dest=None, **opts): | |
665 | """make a copy of an existing repository |
|
669 | """make a copy of an existing repository | |
666 |
|
670 | |||
667 | Create a copy of an existing repository in a new directory. |
|
671 | Create a copy of an existing repository in a new directory. | |
668 |
|
672 | |||
669 | If no destination directory name is specified, it defaults to the |
|
673 | If no destination directory name is specified, it defaults to the | |
670 | basename of the source. |
|
674 | basename of the source. | |
671 |
|
675 | |||
672 | The location of the source is added to the new repository's |
|
676 | The location of the source is added to the new repository's | |
673 | .hg/hgrc file, as the default to be used for future pulls. |
|
677 | .hg/hgrc file, as the default to be used for future pulls. | |
674 |
|
678 | |||
675 | See :hg:`help urls` for valid source format details. |
|
679 | See :hg:`help urls` for valid source format details. | |
676 |
|
680 | |||
677 | It is possible to specify an ``ssh://`` URL as the destination, but no |
|
681 | It is possible to specify an ``ssh://`` URL as the destination, but no | |
678 | .hg/hgrc and working directory will be created on the remote side. |
|
682 | .hg/hgrc and working directory will be created on the remote side. | |
679 | Please see :hg:`help urls` for important details about ``ssh://`` URLs. |
|
683 | Please see :hg:`help urls` for important details about ``ssh://`` URLs. | |
680 |
|
684 | |||
681 | A set of changesets (tags, or branch names) to pull may be specified |
|
685 | A set of changesets (tags, or branch names) to pull may be specified | |
682 | by listing each changeset (tag, or branch name) with -r/--rev. |
|
686 | by listing each changeset (tag, or branch name) with -r/--rev. | |
683 | If -r/--rev is used, the cloned repository will contain only a subset |
|
687 | If -r/--rev is used, the cloned repository will contain only a subset | |
684 | of the changesets of the source repository. Only the set of changesets |
|
688 | of the changesets of the source repository. Only the set of changesets | |
685 | defined by all -r/--rev options (including all their ancestors) |
|
689 | defined by all -r/--rev options (including all their ancestors) | |
686 | will be pulled into the destination repository. |
|
690 | will be pulled into the destination repository. | |
687 | No subsequent changesets (including subsequent tags) will be present |
|
691 | No subsequent changesets (including subsequent tags) will be present | |
688 | in the destination. |
|
692 | in the destination. | |
689 |
|
693 | |||
690 | Using -r/--rev (or 'clone src#rev dest') implies --pull, even for |
|
694 | Using -r/--rev (or 'clone src#rev dest') implies --pull, even for | |
691 | local source repositories. |
|
695 | local source repositories. | |
692 |
|
696 | |||
693 | For efficiency, hardlinks are used for cloning whenever the source |
|
697 | For efficiency, hardlinks are used for cloning whenever the source | |
694 | and destination are on the same filesystem (note this applies only |
|
698 | and destination are on the same filesystem (note this applies only | |
695 | to the repository data, not to the working directory). Some |
|
699 | to the repository data, not to the working directory). Some | |
696 | filesystems, such as AFS, implement hardlinking incorrectly, but |
|
700 | filesystems, such as AFS, implement hardlinking incorrectly, but | |
697 | do not report errors. In these cases, use the --pull option to |
|
701 | do not report errors. In these cases, use the --pull option to | |
698 | avoid hardlinking. |
|
702 | avoid hardlinking. | |
699 |
|
703 | |||
700 | In some cases, you can clone repositories and the working directory |
|
704 | In some cases, you can clone repositories and the working directory | |
701 | using full hardlinks with :: |
|
705 | using full hardlinks with :: | |
702 |
|
706 | |||
703 | $ cp -al REPO REPOCLONE |
|
707 | $ cp -al REPO REPOCLONE | |
704 |
|
708 | |||
705 | This is the fastest way to clone, but it is not always safe. The |
|
709 | This is the fastest way to clone, but it is not always safe. The | |
706 | operation is not atomic (making sure REPO is not modified during |
|
710 | operation is not atomic (making sure REPO is not modified during | |
707 | the operation is up to you) and you have to make sure your editor |
|
711 | the operation is up to you) and you have to make sure your editor | |
708 | breaks hardlinks (Emacs and most Linux Kernel tools do so). Also, |
|
712 | breaks hardlinks (Emacs and most Linux Kernel tools do so). Also, | |
709 | this is not compatible with certain extensions that place their |
|
713 | this is not compatible with certain extensions that place their | |
710 | metadata under the .hg directory, such as mq. |
|
714 | metadata under the .hg directory, such as mq. | |
711 |
|
715 | |||
712 | Mercurial will update the working directory to the first applicable |
|
716 | Mercurial will update the working directory to the first applicable | |
713 | revision from this list: |
|
717 | revision from this list: | |
714 |
|
718 | |||
715 | a) null if -U or the source repository has no changesets |
|
719 | a) null if -U or the source repository has no changesets | |
716 | b) if -u . and the source repository is local, the first parent of |
|
720 | b) if -u . and the source repository is local, the first parent of | |
717 | the source repository's working directory |
|
721 | the source repository's working directory | |
718 | c) the changeset specified with -u (if a branch name, this means the |
|
722 | c) the changeset specified with -u (if a branch name, this means the | |
719 | latest head of that branch) |
|
723 | latest head of that branch) | |
720 | d) the changeset specified with -r |
|
724 | d) the changeset specified with -r | |
721 | e) the tipmost head specified with -b |
|
725 | e) the tipmost head specified with -b | |
722 | f) the tipmost head specified with the url#branch source syntax |
|
726 | f) the tipmost head specified with the url#branch source syntax | |
723 | g) the tipmost head of the default branch |
|
727 | g) the tipmost head of the default branch | |
724 | h) tip |
|
728 | h) tip | |
725 |
|
729 | |||
726 | Returns 0 on success. |
|
730 | Returns 0 on success. | |
727 | """ |
|
731 | """ | |
728 | if opts.get('noupdate') and opts.get('updaterev'): |
|
732 | if opts.get('noupdate') and opts.get('updaterev'): | |
729 | raise util.Abort(_("cannot specify both --noupdate and --updaterev")) |
|
733 | raise util.Abort(_("cannot specify both --noupdate and --updaterev")) | |
730 |
|
734 | |||
731 | r = hg.clone(hg.remoteui(ui, opts), source, dest, |
|
735 | r = hg.clone(hg.remoteui(ui, opts), source, dest, | |
732 | pull=opts.get('pull'), |
|
736 | pull=opts.get('pull'), | |
733 | stream=opts.get('uncompressed'), |
|
737 | stream=opts.get('uncompressed'), | |
734 | rev=opts.get('rev'), |
|
738 | rev=opts.get('rev'), | |
735 | update=opts.get('updaterev') or not opts.get('noupdate'), |
|
739 | update=opts.get('updaterev') or not opts.get('noupdate'), | |
736 | branch=opts.get('branch')) |
|
740 | branch=opts.get('branch')) | |
737 |
|
741 | |||
738 | return r is None |
|
742 | return r is None | |
739 |
|
743 | |||
740 | def commit(ui, repo, *pats, **opts): |
|
744 | def commit(ui, repo, *pats, **opts): | |
741 | """commit the specified files or all outstanding changes |
|
745 | """commit the specified files or all outstanding changes | |
742 |
|
746 | |||
743 | Commit changes to the given files into the repository. Unlike a |
|
747 | Commit changes to the given files into the repository. Unlike a | |
744 | centralized RCS, this operation is a local operation. See |
|
748 | centralized RCS, this operation is a local operation. See | |
745 | :hg:`push` for a way to actively distribute your changes. |
|
749 | :hg:`push` for a way to actively distribute your changes. | |
746 |
|
750 | |||
747 | If a list of files is omitted, all changes reported by :hg:`status` |
|
751 | If a list of files is omitted, all changes reported by :hg:`status` | |
748 | will be committed. |
|
752 | will be committed. | |
749 |
|
753 | |||
750 | If you are committing the result of a merge, do not provide any |
|
754 | If you are committing the result of a merge, do not provide any | |
751 | filenames or -I/-X filters. |
|
755 | filenames or -I/-X filters. | |
752 |
|
756 | |||
753 | If no commit message is specified, Mercurial starts your |
|
757 | If no commit message is specified, Mercurial starts your | |
754 | configured editor where you can enter a message. In case your |
|
758 | configured editor where you can enter a message. In case your | |
755 | commit fails, you will find a backup of your message in |
|
759 | commit fails, you will find a backup of your message in | |
756 | ``.hg/last-message.txt``. |
|
760 | ``.hg/last-message.txt``. | |
757 |
|
761 | |||
758 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
762 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
759 |
|
763 | |||
760 | Returns 0 on success, 1 if nothing changed. |
|
764 | Returns 0 on success, 1 if nothing changed. | |
761 | """ |
|
765 | """ | |
762 | extra = {} |
|
766 | extra = {} | |
763 | if opts.get('close_branch'): |
|
767 | if opts.get('close_branch'): | |
764 | if repo['.'].node() not in repo.branchheads(): |
|
768 | if repo['.'].node() not in repo.branchheads(): | |
765 | # The topo heads set is included in the branch heads set of the |
|
769 | # The topo heads set is included in the branch heads set of the | |
766 | # current branch, so it's sufficient to test branchheads |
|
770 | # current branch, so it's sufficient to test branchheads | |
767 | raise util.Abort(_('can only close branch heads')) |
|
771 | raise util.Abort(_('can only close branch heads')) | |
768 | extra['close'] = 1 |
|
772 | extra['close'] = 1 | |
769 | e = cmdutil.commiteditor |
|
773 | e = cmdutil.commiteditor | |
770 | if opts.get('force_editor'): |
|
774 | if opts.get('force_editor'): | |
771 | e = cmdutil.commitforceeditor |
|
775 | e = cmdutil.commitforceeditor | |
772 |
|
776 | |||
773 | def commitfunc(ui, repo, message, match, opts): |
|
777 | def commitfunc(ui, repo, message, match, opts): | |
774 | return repo.commit(message, opts.get('user'), opts.get('date'), match, |
|
778 | return repo.commit(message, opts.get('user'), opts.get('date'), match, | |
775 | editor=e, extra=extra) |
|
779 | editor=e, extra=extra) | |
776 |
|
780 | |||
777 | branch = repo[None].branch() |
|
781 | branch = repo[None].branch() | |
778 | bheads = repo.branchheads(branch) |
|
782 | bheads = repo.branchheads(branch) | |
779 |
|
783 | |||
780 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
|
784 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) | |
781 | if not node: |
|
785 | if not node: | |
782 | ui.status(_("nothing changed\n")) |
|
786 | ui.status(_("nothing changed\n")) | |
783 | return 1 |
|
787 | return 1 | |
784 |
|
788 | |||
785 | ctx = repo[node] |
|
789 | ctx = repo[node] | |
786 | parents = ctx.parents() |
|
790 | parents = ctx.parents() | |
787 |
|
791 | |||
788 | if bheads and not [x for x in parents |
|
792 | if bheads and not [x for x in parents | |
789 | if x.node() in bheads and x.branch() == branch]: |
|
793 | if x.node() in bheads and x.branch() == branch]: | |
790 | ui.status(_('created new head\n')) |
|
794 | ui.status(_('created new head\n')) | |
791 | # The message is not printed for initial roots. For the other |
|
795 | # The message is not printed for initial roots. For the other | |
792 | # changesets, it is printed in the following situations: |
|
796 | # changesets, it is printed in the following situations: | |
793 | # |
|
797 | # | |
794 | # Par column: for the 2 parents with ... |
|
798 | # Par column: for the 2 parents with ... | |
795 | # N: null or no parent |
|
799 | # N: null or no parent | |
796 | # B: parent is on another named branch |
|
800 | # B: parent is on another named branch | |
797 | # C: parent is a regular non head changeset |
|
801 | # C: parent is a regular non head changeset | |
798 | # H: parent was a branch head of the current branch |
|
802 | # H: parent was a branch head of the current branch | |
799 | # Msg column: whether we print "created new head" message |
|
803 | # Msg column: whether we print "created new head" message | |
800 | # In the following, it is assumed that there already exists some |
|
804 | # In the following, it is assumed that there already exists some | |
801 | # initial branch heads of the current branch, otherwise nothing is |
|
805 | # initial branch heads of the current branch, otherwise nothing is | |
802 | # printed anyway. |
|
806 | # printed anyway. | |
803 | # |
|
807 | # | |
804 | # Par Msg Comment |
|
808 | # Par Msg Comment | |
805 | # NN y additional topo root |
|
809 | # NN y additional topo root | |
806 | # |
|
810 | # | |
807 | # BN y additional branch root |
|
811 | # BN y additional branch root | |
808 | # CN y additional topo head |
|
812 | # CN y additional topo head | |
809 | # HN n usual case |
|
813 | # HN n usual case | |
810 | # |
|
814 | # | |
811 | # BB y weird additional branch root |
|
815 | # BB y weird additional branch root | |
812 | # CB y branch merge |
|
816 | # CB y branch merge | |
813 | # HB n merge with named branch |
|
817 | # HB n merge with named branch | |
814 | # |
|
818 | # | |
815 | # CC y additional head from merge |
|
819 | # CC y additional head from merge | |
816 | # CH n merge with a head |
|
820 | # CH n merge with a head | |
817 | # |
|
821 | # | |
818 | # HH n head merge: head count decreases |
|
822 | # HH n head merge: head count decreases | |
819 |
|
823 | |||
820 | if not opts.get('close_branch'): |
|
824 | if not opts.get('close_branch'): | |
821 | for r in parents: |
|
825 | for r in parents: | |
822 | if r.extra().get('close') and r.branch() == branch: |
|
826 | if r.extra().get('close') and r.branch() == branch: | |
823 | ui.status(_('reopening closed branch head %d\n') % r) |
|
827 | ui.status(_('reopening closed branch head %d\n') % r) | |
824 |
|
828 | |||
825 | if ui.debugflag: |
|
829 | if ui.debugflag: | |
826 | ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) |
|
830 | ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) | |
827 | elif ui.verbose: |
|
831 | elif ui.verbose: | |
828 | ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) |
|
832 | ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) | |
829 |
|
833 | |||
830 | def copy(ui, repo, *pats, **opts): |
|
834 | def copy(ui, repo, *pats, **opts): | |
831 | """mark files as copied for the next commit |
|
835 | """mark files as copied for the next commit | |
832 |
|
836 | |||
833 | Mark dest as having copies of source files. If dest is a |
|
837 | Mark dest as having copies of source files. If dest is a | |
834 | directory, copies are put in that directory. If dest is a file, |
|
838 | directory, copies are put in that directory. If dest is a file, | |
835 | the source must be a single file. |
|
839 | the source must be a single file. | |
836 |
|
840 | |||
837 | By default, this command copies the contents of files as they |
|
841 | By default, this command copies the contents of files as they | |
838 | exist in the working directory. If invoked with -A/--after, the |
|
842 | exist in the working directory. If invoked with -A/--after, the | |
839 | operation is recorded, but no copying is performed. |
|
843 | operation is recorded, but no copying is performed. | |
840 |
|
844 | |||
841 | This command takes effect with the next commit. To undo a copy |
|
845 | This command takes effect with the next commit. To undo a copy | |
842 | before that, see :hg:`revert`. |
|
846 | before that, see :hg:`revert`. | |
843 |
|
847 | |||
844 | Returns 0 on success, 1 if errors are encountered. |
|
848 | Returns 0 on success, 1 if errors are encountered. | |
845 | """ |
|
849 | """ | |
846 | wlock = repo.wlock(False) |
|
850 | wlock = repo.wlock(False) | |
847 | try: |
|
851 | try: | |
848 | return cmdutil.copy(ui, repo, pats, opts) |
|
852 | return cmdutil.copy(ui, repo, pats, opts) | |
849 | finally: |
|
853 | finally: | |
850 | wlock.release() |
|
854 | wlock.release() | |
851 |
|
855 | |||
852 | def debugancestor(ui, repo, *args): |
|
856 | def debugancestor(ui, repo, *args): | |
853 | """find the ancestor revision of two revisions in a given index""" |
|
857 | """find the ancestor revision of two revisions in a given index""" | |
854 | if len(args) == 3: |
|
858 | if len(args) == 3: | |
855 | index, rev1, rev2 = args |
|
859 | index, rev1, rev2 = args | |
856 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), index) |
|
860 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), index) | |
857 | lookup = r.lookup |
|
861 | lookup = r.lookup | |
858 | elif len(args) == 2: |
|
862 | elif len(args) == 2: | |
859 | if not repo: |
|
863 | if not repo: | |
860 | raise util.Abort(_("there is no Mercurial repository here " |
|
864 | raise util.Abort(_("there is no Mercurial repository here " | |
861 | "(.hg not found)")) |
|
865 | "(.hg not found)")) | |
862 | rev1, rev2 = args |
|
866 | rev1, rev2 = args | |
863 | r = repo.changelog |
|
867 | r = repo.changelog | |
864 | lookup = repo.lookup |
|
868 | lookup = repo.lookup | |
865 | else: |
|
869 | else: | |
866 | raise util.Abort(_('either two or three arguments required')) |
|
870 | raise util.Abort(_('either two or three arguments required')) | |
867 | a = r.ancestor(lookup(rev1), lookup(rev2)) |
|
871 | a = r.ancestor(lookup(rev1), lookup(rev2)) | |
868 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
|
872 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) | |
869 |
|
873 | |||
870 | def debugbuilddag(ui, repo, text, |
|
874 | def debugbuilddag(ui, repo, text, | |
871 | mergeable_file=False, |
|
875 | mergeable_file=False, | |
872 | appended_file=False, |
|
876 | appended_file=False, | |
873 | overwritten_file=False, |
|
877 | overwritten_file=False, | |
874 | new_file=False): |
|
878 | new_file=False): | |
875 | """builds a repo with a given dag from scratch in the current empty repo |
|
879 | """builds a repo with a given dag from scratch in the current empty repo | |
876 |
|
880 | |||
877 | Elements: |
|
881 | Elements: | |
878 |
|
882 | |||
879 | - "+n" is a linear run of n nodes based on the current default parent |
|
883 | - "+n" is a linear run of n nodes based on the current default parent | |
880 | - "." is a single node based on the current default parent |
|
884 | - "." is a single node based on the current default parent | |
881 | - "$" resets the default parent to null (implied at the start); |
|
885 | - "$" resets the default parent to null (implied at the start); | |
882 | otherwise the default parent is always the last node created |
|
886 | otherwise the default parent is always the last node created | |
883 | - "<p" sets the default parent to the backref p |
|
887 | - "<p" sets the default parent to the backref p | |
884 | - "*p" is a fork at parent p, which is a backref |
|
888 | - "*p" is a fork at parent p, which is a backref | |
885 | - "*p1/p2" is a merge of parents p1 and p2, which are backrefs |
|
889 | - "*p1/p2" is a merge of parents p1 and p2, which are backrefs | |
886 | - "/p2" is a merge of the preceding node and p2 |
|
890 | - "/p2" is a merge of the preceding node and p2 | |
887 | - ":tag" defines a local tag for the preceding node |
|
891 | - ":tag" defines a local tag for the preceding node | |
888 | - "@branch" sets the named branch for subsequent nodes |
|
892 | - "@branch" sets the named branch for subsequent nodes | |
889 | - "!command" runs the command using your shell |
|
893 | - "!command" runs the command using your shell | |
890 | - "!!my command\\n" is like "!", but to the end of the line |
|
894 | - "!!my command\\n" is like "!", but to the end of the line | |
891 | - "#...\\n" is a comment up to the end of the line |
|
895 | - "#...\\n" is a comment up to the end of the line | |
892 |
|
896 | |||
893 | Whitespace between the above elements is ignored. |
|
897 | Whitespace between the above elements is ignored. | |
894 |
|
898 | |||
895 | A backref is either |
|
899 | A backref is either | |
896 |
|
900 | |||
897 | - a number n, which references the node curr-n, where curr is the current |
|
901 | - a number n, which references the node curr-n, where curr is the current | |
898 | node, or |
|
902 | node, or | |
899 | - the name of a local tag you placed earlier using ":tag", or |
|
903 | - the name of a local tag you placed earlier using ":tag", or | |
900 | - empty to denote the default parent. |
|
904 | - empty to denote the default parent. | |
901 |
|
905 | |||
902 | All string valued-elements are either strictly alphanumeric, or must |
|
906 | All string valued-elements are either strictly alphanumeric, or must | |
903 | be enclosed in double quotes ("..."), with "\\" as escape character. |
|
907 | be enclosed in double quotes ("..."), with "\\" as escape character. | |
904 |
|
908 | |||
905 | Note that the --overwritten-file and --appended-file options imply the |
|
909 | Note that the --overwritten-file and --appended-file options imply the | |
906 | use of "HGMERGE=internal:local" during DAG buildup. |
|
910 | use of "HGMERGE=internal:local" during DAG buildup. | |
907 | """ |
|
911 | """ | |
908 |
|
912 | |||
909 | if not (mergeable_file or appended_file or overwritten_file or new_file): |
|
913 | if not (mergeable_file or appended_file or overwritten_file or new_file): | |
910 | raise util.Abort(_('need at least one of -m, -a, -o, -n')) |
|
914 | raise util.Abort(_('need at least one of -m, -a, -o, -n')) | |
911 |
|
915 | |||
912 | if len(repo.changelog) > 0: |
|
916 | if len(repo.changelog) > 0: | |
913 | raise util.Abort(_('repository is not empty')) |
|
917 | raise util.Abort(_('repository is not empty')) | |
914 |
|
918 | |||
915 | if overwritten_file or appended_file: |
|
919 | if overwritten_file or appended_file: | |
916 | # we don't want to fail in merges during buildup |
|
920 | # we don't want to fail in merges during buildup | |
917 | os.environ['HGMERGE'] = 'internal:local' |
|
921 | os.environ['HGMERGE'] = 'internal:local' | |
918 |
|
922 | |||
919 | def writefile(fname, text, fmode="wb"): |
|
923 | def writefile(fname, text, fmode="wb"): | |
920 | f = open(fname, fmode) |
|
924 | f = open(fname, fmode) | |
921 | try: |
|
925 | try: | |
922 | f.write(text) |
|
926 | f.write(text) | |
923 | finally: |
|
927 | finally: | |
924 | f.close() |
|
928 | f.close() | |
925 |
|
929 | |||
926 | if mergeable_file: |
|
930 | if mergeable_file: | |
927 | linesperrev = 2 |
|
931 | linesperrev = 2 | |
928 | # determine number of revs in DAG |
|
932 | # determine number of revs in DAG | |
929 | n = 0 |
|
933 | n = 0 | |
930 | for type, data in dagparser.parsedag(text): |
|
934 | for type, data in dagparser.parsedag(text): | |
931 | if type == 'n': |
|
935 | if type == 'n': | |
932 | n += 1 |
|
936 | n += 1 | |
933 | # make a file with k lines per rev |
|
937 | # make a file with k lines per rev | |
934 | writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev)) |
|
938 | writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev)) | |
935 | + "\n") |
|
939 | + "\n") | |
936 |
|
940 | |||
937 | at = -1 |
|
941 | at = -1 | |
938 | atbranch = 'default' |
|
942 | atbranch = 'default' | |
939 | for type, data in dagparser.parsedag(text): |
|
943 | for type, data in dagparser.parsedag(text): | |
940 | if type == 'n': |
|
944 | if type == 'n': | |
941 | ui.status('node %s\n' % str(data)) |
|
945 | ui.status('node %s\n' % str(data)) | |
942 | id, ps = data |
|
946 | id, ps = data | |
943 | p1 = ps[0] |
|
947 | p1 = ps[0] | |
944 | if p1 != at: |
|
948 | if p1 != at: | |
945 | update(ui, repo, node=str(p1), clean=True) |
|
949 | update(ui, repo, node=str(p1), clean=True) | |
946 | at = p1 |
|
950 | at = p1 | |
947 | if repo.dirstate.branch() != atbranch: |
|
951 | if repo.dirstate.branch() != atbranch: | |
948 | branch(ui, repo, atbranch, force=True) |
|
952 | branch(ui, repo, atbranch, force=True) | |
949 | if len(ps) > 1: |
|
953 | if len(ps) > 1: | |
950 | p2 = ps[1] |
|
954 | p2 = ps[1] | |
951 | merge(ui, repo, node=p2) |
|
955 | merge(ui, repo, node=p2) | |
952 |
|
956 | |||
953 | if mergeable_file: |
|
957 | if mergeable_file: | |
954 | f = open("mf", "rb+") |
|
958 | f = open("mf", "rb+") | |
955 | try: |
|
959 | try: | |
956 | lines = f.read().split("\n") |
|
960 | lines = f.read().split("\n") | |
957 | lines[id * linesperrev] += " r%i" % id |
|
961 | lines[id * linesperrev] += " r%i" % id | |
958 | f.seek(0) |
|
962 | f.seek(0) | |
959 | f.write("\n".join(lines)) |
|
963 | f.write("\n".join(lines)) | |
960 | finally: |
|
964 | finally: | |
961 | f.close() |
|
965 | f.close() | |
962 |
|
966 | |||
963 | if appended_file: |
|
967 | if appended_file: | |
964 | writefile("af", "r%i\n" % id, "ab") |
|
968 | writefile("af", "r%i\n" % id, "ab") | |
965 |
|
969 | |||
966 | if overwritten_file: |
|
970 | if overwritten_file: | |
967 | writefile("of", "r%i\n" % id) |
|
971 | writefile("of", "r%i\n" % id) | |
968 |
|
972 | |||
969 | if new_file: |
|
973 | if new_file: | |
970 | writefile("nf%i" % id, "r%i\n" % id) |
|
974 | writefile("nf%i" % id, "r%i\n" % id) | |
971 |
|
975 | |||
972 | commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0)) |
|
976 | commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0)) | |
973 | at = id |
|
977 | at = id | |
974 | elif type == 'l': |
|
978 | elif type == 'l': | |
975 | id, name = data |
|
979 | id, name = data | |
976 | ui.status('tag %s\n' % name) |
|
980 | ui.status('tag %s\n' % name) | |
977 | tag(ui, repo, name, local=True) |
|
981 | tag(ui, repo, name, local=True) | |
978 | elif type == 'a': |
|
982 | elif type == 'a': | |
979 | ui.status('branch %s\n' % data) |
|
983 | ui.status('branch %s\n' % data) | |
980 | atbranch = data |
|
984 | atbranch = data | |
981 | elif type in 'cC': |
|
985 | elif type in 'cC': | |
982 | r = util.system(data, cwd=repo.root) |
|
986 | r = util.system(data, cwd=repo.root) | |
983 | if r: |
|
987 | if r: | |
984 | desc, r = util.explain_exit(r) |
|
988 | desc, r = util.explain_exit(r) | |
985 | raise util.Abort(_('%s command %s') % (data, desc)) |
|
989 | raise util.Abort(_('%s command %s') % (data, desc)) | |
986 |
|
990 | |||
987 | def debugcommands(ui, cmd='', *args): |
|
991 | def debugcommands(ui, cmd='', *args): | |
988 | """list all available commands and options""" |
|
992 | """list all available commands and options""" | |
989 | for cmd, vals in sorted(table.iteritems()): |
|
993 | for cmd, vals in sorted(table.iteritems()): | |
990 | cmd = cmd.split('|')[0].strip('^') |
|
994 | cmd = cmd.split('|')[0].strip('^') | |
991 | opts = ', '.join([i[1] for i in vals[1]]) |
|
995 | opts = ', '.join([i[1] for i in vals[1]]) | |
992 | ui.write('%s: %s\n' % (cmd, opts)) |
|
996 | ui.write('%s: %s\n' % (cmd, opts)) | |
993 |
|
997 | |||
994 | def debugcomplete(ui, cmd='', **opts): |
|
998 | def debugcomplete(ui, cmd='', **opts): | |
995 | """returns the completion list associated with the given command""" |
|
999 | """returns the completion list associated with the given command""" | |
996 |
|
1000 | |||
997 | if opts.get('options'): |
|
1001 | if opts.get('options'): | |
998 | options = [] |
|
1002 | options = [] | |
999 | otables = [globalopts] |
|
1003 | otables = [globalopts] | |
1000 | if cmd: |
|
1004 | if cmd: | |
1001 | aliases, entry = cmdutil.findcmd(cmd, table, False) |
|
1005 | aliases, entry = cmdutil.findcmd(cmd, table, False) | |
1002 | otables.append(entry[1]) |
|
1006 | otables.append(entry[1]) | |
1003 | for t in otables: |
|
1007 | for t in otables: | |
1004 | for o in t: |
|
1008 | for o in t: | |
1005 | if "(DEPRECATED)" in o[3]: |
|
1009 | if "(DEPRECATED)" in o[3]: | |
1006 | continue |
|
1010 | continue | |
1007 | if o[0]: |
|
1011 | if o[0]: | |
1008 | options.append('-%s' % o[0]) |
|
1012 | options.append('-%s' % o[0]) | |
1009 | options.append('--%s' % o[1]) |
|
1013 | options.append('--%s' % o[1]) | |
1010 | ui.write("%s\n" % "\n".join(options)) |
|
1014 | ui.write("%s\n" % "\n".join(options)) | |
1011 | return |
|
1015 | return | |
1012 |
|
1016 | |||
1013 | cmdlist = cmdutil.findpossible(cmd, table) |
|
1017 | cmdlist = cmdutil.findpossible(cmd, table) | |
1014 | if ui.verbose: |
|
1018 | if ui.verbose: | |
1015 | cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
|
1019 | cmdlist = [' '.join(c[0]) for c in cmdlist.values()] | |
1016 | ui.write("%s\n" % "\n".join(sorted(cmdlist))) |
|
1020 | ui.write("%s\n" % "\n".join(sorted(cmdlist))) | |
1017 |
|
1021 | |||
1018 | def debugfsinfo(ui, path = "."): |
|
1022 | def debugfsinfo(ui, path = "."): | |
1019 | """show information detected about current filesystem""" |
|
1023 | """show information detected about current filesystem""" | |
1020 | open('.debugfsinfo', 'w').write('') |
|
1024 | open('.debugfsinfo', 'w').write('') | |
1021 | ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) |
|
1025 | ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) | |
1022 | ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) |
|
1026 | ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) | |
1023 | ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') |
|
1027 | ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') | |
1024 | and 'yes' or 'no')) |
|
1028 | and 'yes' or 'no')) | |
1025 | os.unlink('.debugfsinfo') |
|
1029 | os.unlink('.debugfsinfo') | |
1026 |
|
1030 | |||
1027 | def debugrebuildstate(ui, repo, rev="tip"): |
|
1031 | def debugrebuildstate(ui, repo, rev="tip"): | |
1028 | """rebuild the dirstate as it would look like for the given revision""" |
|
1032 | """rebuild the dirstate as it would look like for the given revision""" | |
1029 |
ctx = repo |
|
1033 | ctx = cmdutil.revsingle(repo, rev) | |
1030 | wlock = repo.wlock() |
|
1034 | wlock = repo.wlock() | |
1031 | try: |
|
1035 | try: | |
1032 | repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
|
1036 | repo.dirstate.rebuild(ctx.node(), ctx.manifest()) | |
1033 | finally: |
|
1037 | finally: | |
1034 | wlock.release() |
|
1038 | wlock.release() | |
1035 |
|
1039 | |||
1036 | def debugcheckstate(ui, repo): |
|
1040 | def debugcheckstate(ui, repo): | |
1037 | """validate the correctness of the current dirstate""" |
|
1041 | """validate the correctness of the current dirstate""" | |
1038 | parent1, parent2 = repo.dirstate.parents() |
|
1042 | parent1, parent2 = repo.dirstate.parents() | |
1039 | m1 = repo[parent1].manifest() |
|
1043 | m1 = repo[parent1].manifest() | |
1040 | m2 = repo[parent2].manifest() |
|
1044 | m2 = repo[parent2].manifest() | |
1041 | errors = 0 |
|
1045 | errors = 0 | |
1042 | for f in repo.dirstate: |
|
1046 | for f in repo.dirstate: | |
1043 | state = repo.dirstate[f] |
|
1047 | state = repo.dirstate[f] | |
1044 | if state in "nr" and f not in m1: |
|
1048 | if state in "nr" and f not in m1: | |
1045 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
|
1049 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) | |
1046 | errors += 1 |
|
1050 | errors += 1 | |
1047 | if state in "a" and f in m1: |
|
1051 | if state in "a" and f in m1: | |
1048 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
|
1052 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) | |
1049 | errors += 1 |
|
1053 | errors += 1 | |
1050 | if state in "m" and f not in m1 and f not in m2: |
|
1054 | if state in "m" and f not in m1 and f not in m2: | |
1051 | ui.warn(_("%s in state %s, but not in either manifest\n") % |
|
1055 | ui.warn(_("%s in state %s, but not in either manifest\n") % | |
1052 | (f, state)) |
|
1056 | (f, state)) | |
1053 | errors += 1 |
|
1057 | errors += 1 | |
1054 | for f in m1: |
|
1058 | for f in m1: | |
1055 | state = repo.dirstate[f] |
|
1059 | state = repo.dirstate[f] | |
1056 | if state not in "nrm": |
|
1060 | if state not in "nrm": | |
1057 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
|
1061 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) | |
1058 | errors += 1 |
|
1062 | errors += 1 | |
1059 | if errors: |
|
1063 | if errors: | |
1060 | error = _(".hg/dirstate inconsistent with current parent's manifest") |
|
1064 | error = _(".hg/dirstate inconsistent with current parent's manifest") | |
1061 | raise util.Abort(error) |
|
1065 | raise util.Abort(error) | |
1062 |
|
1066 | |||
1063 | def showconfig(ui, repo, *values, **opts): |
|
1067 | def showconfig(ui, repo, *values, **opts): | |
1064 | """show combined config settings from all hgrc files |
|
1068 | """show combined config settings from all hgrc files | |
1065 |
|
1069 | |||
1066 | With no arguments, print names and values of all config items. |
|
1070 | With no arguments, print names and values of all config items. | |
1067 |
|
1071 | |||
1068 | With one argument of the form section.name, print just the value |
|
1072 | With one argument of the form section.name, print just the value | |
1069 | of that config item. |
|
1073 | of that config item. | |
1070 |
|
1074 | |||
1071 | With multiple arguments, print names and values of all config |
|
1075 | With multiple arguments, print names and values of all config | |
1072 | items with matching section names. |
|
1076 | items with matching section names. | |
1073 |
|
1077 | |||
1074 | With --debug, the source (filename and line number) is printed |
|
1078 | With --debug, the source (filename and line number) is printed | |
1075 | for each config item. |
|
1079 | for each config item. | |
1076 |
|
1080 | |||
1077 | Returns 0 on success. |
|
1081 | Returns 0 on success. | |
1078 | """ |
|
1082 | """ | |
1079 |
|
1083 | |||
1080 | for f in util.rcpath(): |
|
1084 | for f in util.rcpath(): | |
1081 | ui.debug(_('read config from: %s\n') % f) |
|
1085 | ui.debug(_('read config from: %s\n') % f) | |
1082 | untrusted = bool(opts.get('untrusted')) |
|
1086 | untrusted = bool(opts.get('untrusted')) | |
1083 | if values: |
|
1087 | if values: | |
1084 | sections = [v for v in values if '.' not in v] |
|
1088 | sections = [v for v in values if '.' not in v] | |
1085 | items = [v for v in values if '.' in v] |
|
1089 | items = [v for v in values if '.' in v] | |
1086 | if len(items) > 1 or items and sections: |
|
1090 | if len(items) > 1 or items and sections: | |
1087 | raise util.Abort(_('only one config item permitted')) |
|
1091 | raise util.Abort(_('only one config item permitted')) | |
1088 | for section, name, value in ui.walkconfig(untrusted=untrusted): |
|
1092 | for section, name, value in ui.walkconfig(untrusted=untrusted): | |
1089 | sectname = section + '.' + name |
|
1093 | sectname = section + '.' + name | |
1090 | if values: |
|
1094 | if values: | |
1091 | for v in values: |
|
1095 | for v in values: | |
1092 | if v == section: |
|
1096 | if v == section: | |
1093 | ui.debug('%s: ' % |
|
1097 | ui.debug('%s: ' % | |
1094 | ui.configsource(section, name, untrusted)) |
|
1098 | ui.configsource(section, name, untrusted)) | |
1095 | ui.write('%s=%s\n' % (sectname, value)) |
|
1099 | ui.write('%s=%s\n' % (sectname, value)) | |
1096 | elif v == sectname: |
|
1100 | elif v == sectname: | |
1097 | ui.debug('%s: ' % |
|
1101 | ui.debug('%s: ' % | |
1098 | ui.configsource(section, name, untrusted)) |
|
1102 | ui.configsource(section, name, untrusted)) | |
1099 | ui.write(value, '\n') |
|
1103 | ui.write(value, '\n') | |
1100 | else: |
|
1104 | else: | |
1101 | ui.debug('%s: ' % |
|
1105 | ui.debug('%s: ' % | |
1102 | ui.configsource(section, name, untrusted)) |
|
1106 | ui.configsource(section, name, untrusted)) | |
1103 | ui.write('%s=%s\n' % (sectname, value)) |
|
1107 | ui.write('%s=%s\n' % (sectname, value)) | |
1104 |
|
1108 | |||
1105 | def debugpushkey(ui, repopath, namespace, *keyinfo): |
|
1109 | def debugpushkey(ui, repopath, namespace, *keyinfo): | |
1106 | '''access the pushkey key/value protocol |
|
1110 | '''access the pushkey key/value protocol | |
1107 |
|
1111 | |||
1108 | With two args, list the keys in the given namespace. |
|
1112 | With two args, list the keys in the given namespace. | |
1109 |
|
1113 | |||
1110 | With five args, set a key to new if it currently is set to old. |
|
1114 | With five args, set a key to new if it currently is set to old. | |
1111 | Reports success or failure. |
|
1115 | Reports success or failure. | |
1112 | ''' |
|
1116 | ''' | |
1113 |
|
1117 | |||
1114 | target = hg.repository(ui, repopath) |
|
1118 | target = hg.repository(ui, repopath) | |
1115 | if keyinfo: |
|
1119 | if keyinfo: | |
1116 | key, old, new = keyinfo |
|
1120 | key, old, new = keyinfo | |
1117 | r = target.pushkey(namespace, key, old, new) |
|
1121 | r = target.pushkey(namespace, key, old, new) | |
1118 | ui.status(str(r) + '\n') |
|
1122 | ui.status(str(r) + '\n') | |
1119 | return not(r) |
|
1123 | return not(r) | |
1120 | else: |
|
1124 | else: | |
1121 | for k, v in target.listkeys(namespace).iteritems(): |
|
1125 | for k, v in target.listkeys(namespace).iteritems(): | |
1122 | ui.write("%s\t%s\n" % (k.encode('string-escape'), |
|
1126 | ui.write("%s\t%s\n" % (k.encode('string-escape'), | |
1123 | v.encode('string-escape'))) |
|
1127 | v.encode('string-escape'))) | |
1124 |
|
1128 | |||
1125 | def debugrevspec(ui, repo, expr): |
|
1129 | def debugrevspec(ui, repo, expr): | |
1126 | '''parse and apply a revision specification''' |
|
1130 | '''parse and apply a revision specification''' | |
1127 | if ui.verbose: |
|
1131 | if ui.verbose: | |
1128 | tree = revset.parse(expr) |
|
1132 | tree = revset.parse(expr) | |
1129 | ui.note(tree, "\n") |
|
1133 | ui.note(tree, "\n") | |
1130 | func = revset.match(expr) |
|
1134 | func = revset.match(expr) | |
1131 | for c in func(repo, range(len(repo))): |
|
1135 | for c in func(repo, range(len(repo))): | |
1132 | ui.write("%s\n" % c) |
|
1136 | ui.write("%s\n" % c) | |
1133 |
|
1137 | |||
1134 | def debugsetparents(ui, repo, rev1, rev2=None): |
|
1138 | def debugsetparents(ui, repo, rev1, rev2=None): | |
1135 | """manually set the parents of the current working directory |
|
1139 | """manually set the parents of the current working directory | |
1136 |
|
1140 | |||
1137 | This is useful for writing repository conversion tools, but should |
|
1141 | This is useful for writing repository conversion tools, but should | |
1138 | be used with care. |
|
1142 | be used with care. | |
1139 |
|
1143 | |||
1140 | Returns 0 on success. |
|
1144 | Returns 0 on success. | |
1141 | """ |
|
1145 | """ | |
1142 |
|
1146 | |||
1143 | if not rev2: |
|
1147 | r1 = cmdutil.revsingle(repo, rev1).node() | |
1144 | rev2 = hex(nullid) |
|
1148 | r2 = cmdutil.revsingle(repo, rev2, 'null').node() | |
1145 |
|
1149 | |||
1146 | wlock = repo.wlock() |
|
1150 | wlock = repo.wlock() | |
1147 | try: |
|
1151 | try: | |
1148 |
repo.dirstate.setparents(r |
|
1152 | repo.dirstate.setparents(r1, r2) | |
1149 | finally: |
|
1153 | finally: | |
1150 | wlock.release() |
|
1154 | wlock.release() | |
1151 |
|
1155 | |||
1152 | def debugstate(ui, repo, nodates=None): |
|
1156 | def debugstate(ui, repo, nodates=None): | |
1153 | """show the contents of the current dirstate""" |
|
1157 | """show the contents of the current dirstate""" | |
1154 | timestr = "" |
|
1158 | timestr = "" | |
1155 | showdate = not nodates |
|
1159 | showdate = not nodates | |
1156 | for file_, ent in sorted(repo.dirstate._map.iteritems()): |
|
1160 | for file_, ent in sorted(repo.dirstate._map.iteritems()): | |
1157 | if showdate: |
|
1161 | if showdate: | |
1158 | if ent[3] == -1: |
|
1162 | if ent[3] == -1: | |
1159 | # Pad or slice to locale representation |
|
1163 | # Pad or slice to locale representation | |
1160 | locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", |
|
1164 | locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", | |
1161 | time.localtime(0))) |
|
1165 | time.localtime(0))) | |
1162 | timestr = 'unset' |
|
1166 | timestr = 'unset' | |
1163 | timestr = (timestr[:locale_len] + |
|
1167 | timestr = (timestr[:locale_len] + | |
1164 | ' ' * (locale_len - len(timestr))) |
|
1168 | ' ' * (locale_len - len(timestr))) | |
1165 | else: |
|
1169 | else: | |
1166 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
|
1170 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", | |
1167 | time.localtime(ent[3])) |
|
1171 | time.localtime(ent[3])) | |
1168 | if ent[1] & 020000: |
|
1172 | if ent[1] & 020000: | |
1169 | mode = 'lnk' |
|
1173 | mode = 'lnk' | |
1170 | else: |
|
1174 | else: | |
1171 | mode = '%3o' % (ent[1] & 0777) |
|
1175 | mode = '%3o' % (ent[1] & 0777) | |
1172 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
1176 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | |
1173 | for f in repo.dirstate.copies(): |
|
1177 | for f in repo.dirstate.copies(): | |
1174 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
1178 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) | |
1175 |
|
1179 | |||
1176 | def debugsub(ui, repo, rev=None): |
|
1180 | def debugsub(ui, repo, rev=None): | |
1177 | if rev == '': |
|
1181 | ctx = cmdutil.revsingle(repo, rev, None) | |
1178 | rev = None |
|
1182 | for k, v in sorted(ctx.substate.items()): | |
1179 | for k, v in sorted(repo[rev].substate.items()): |
|
|||
1180 | ui.write('path %s\n' % k) |
|
1183 | ui.write('path %s\n' % k) | |
1181 | ui.write(' source %s\n' % v[0]) |
|
1184 | ui.write(' source %s\n' % v[0]) | |
1182 | ui.write(' revision %s\n' % v[1]) |
|
1185 | ui.write(' revision %s\n' % v[1]) | |
1183 |
|
1186 | |||
1184 | def debugdag(ui, repo, file_=None, *revs, **opts): |
|
1187 | def debugdag(ui, repo, file_=None, *revs, **opts): | |
1185 | """format the changelog or an index DAG as a concise textual description |
|
1188 | """format the changelog or an index DAG as a concise textual description | |
1186 |
|
1189 | |||
1187 | If you pass a revlog index, the revlog's DAG is emitted. If you list |
|
1190 | If you pass a revlog index, the revlog's DAG is emitted. If you list | |
1188 | revision numbers, they get labelled in the output as rN. |
|
1191 | revision numbers, they get labelled in the output as rN. | |
1189 |
|
1192 | |||
1190 | Otherwise, the changelog DAG of the current repo is emitted. |
|
1193 | Otherwise, the changelog DAG of the current repo is emitted. | |
1191 | """ |
|
1194 | """ | |
1192 | spaces = opts.get('spaces') |
|
1195 | spaces = opts.get('spaces') | |
1193 | dots = opts.get('dots') |
|
1196 | dots = opts.get('dots') | |
1194 | if file_: |
|
1197 | if file_: | |
1195 | rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) |
|
1198 | rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | |
1196 | revs = set((int(r) for r in revs)) |
|
1199 | revs = set((int(r) for r in revs)) | |
1197 | def events(): |
|
1200 | def events(): | |
1198 | for r in rlog: |
|
1201 | for r in rlog: | |
1199 | yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) |
|
1202 | yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) | |
1200 | if r in revs: |
|
1203 | if r in revs: | |
1201 | yield 'l', (r, "r%i" % r) |
|
1204 | yield 'l', (r, "r%i" % r) | |
1202 | elif repo: |
|
1205 | elif repo: | |
1203 | cl = repo.changelog |
|
1206 | cl = repo.changelog | |
1204 | tags = opts.get('tags') |
|
1207 | tags = opts.get('tags') | |
1205 | branches = opts.get('branches') |
|
1208 | branches = opts.get('branches') | |
1206 | if tags: |
|
1209 | if tags: | |
1207 | labels = {} |
|
1210 | labels = {} | |
1208 | for l, n in repo.tags().items(): |
|
1211 | for l, n in repo.tags().items(): | |
1209 | labels.setdefault(cl.rev(n), []).append(l) |
|
1212 | labels.setdefault(cl.rev(n), []).append(l) | |
1210 | def events(): |
|
1213 | def events(): | |
1211 | b = "default" |
|
1214 | b = "default" | |
1212 | for r in cl: |
|
1215 | for r in cl: | |
1213 | if branches: |
|
1216 | if branches: | |
1214 | newb = cl.read(cl.node(r))[5]['branch'] |
|
1217 | newb = cl.read(cl.node(r))[5]['branch'] | |
1215 | if newb != b: |
|
1218 | if newb != b: | |
1216 | yield 'a', newb |
|
1219 | yield 'a', newb | |
1217 | b = newb |
|
1220 | b = newb | |
1218 | yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1))) |
|
1221 | yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1))) | |
1219 | if tags: |
|
1222 | if tags: | |
1220 | ls = labels.get(r) |
|
1223 | ls = labels.get(r) | |
1221 | if ls: |
|
1224 | if ls: | |
1222 | for l in ls: |
|
1225 | for l in ls: | |
1223 | yield 'l', (r, l) |
|
1226 | yield 'l', (r, l) | |
1224 | else: |
|
1227 | else: | |
1225 | raise util.Abort(_('need repo for changelog dag')) |
|
1228 | raise util.Abort(_('need repo for changelog dag')) | |
1226 |
|
1229 | |||
1227 | for line in dagparser.dagtextlines(events(), |
|
1230 | for line in dagparser.dagtextlines(events(), | |
1228 | addspaces=spaces, |
|
1231 | addspaces=spaces, | |
1229 | wraplabels=True, |
|
1232 | wraplabels=True, | |
1230 | wrapannotations=True, |
|
1233 | wrapannotations=True, | |
1231 | wrapnonlinear=dots, |
|
1234 | wrapnonlinear=dots, | |
1232 | usedots=dots, |
|
1235 | usedots=dots, | |
1233 | maxlinewidth=70): |
|
1236 | maxlinewidth=70): | |
1234 | ui.write(line) |
|
1237 | ui.write(line) | |
1235 | ui.write("\n") |
|
1238 | ui.write("\n") | |
1236 |
|
1239 | |||
1237 | def debugdata(ui, repo, file_, rev): |
|
1240 | def debugdata(ui, repo, file_, rev): | |
1238 | """dump the contents of a data file revision""" |
|
1241 | """dump the contents of a data file revision""" | |
1239 | r = None |
|
1242 | r = None | |
1240 | if repo: |
|
1243 | if repo: | |
1241 | filelog = repo.file(file_) |
|
1244 | filelog = repo.file(file_) | |
1242 | if len(filelog): |
|
1245 | if len(filelog): | |
1243 | r = filelog |
|
1246 | r = filelog | |
1244 | if not r: |
|
1247 | if not r: | |
1245 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i") |
|
1248 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i") | |
1246 | try: |
|
1249 | try: | |
1247 | ui.write(r.revision(r.lookup(rev))) |
|
1250 | ui.write(r.revision(r.lookup(rev))) | |
1248 | except KeyError: |
|
1251 | except KeyError: | |
1249 | raise util.Abort(_('invalid revision identifier %s') % rev) |
|
1252 | raise util.Abort(_('invalid revision identifier %s') % rev) | |
1250 |
|
1253 | |||
1251 | def debugdate(ui, date, range=None, **opts): |
|
1254 | def debugdate(ui, date, range=None, **opts): | |
1252 | """parse and display a date""" |
|
1255 | """parse and display a date""" | |
1253 | if opts["extended"]: |
|
1256 | if opts["extended"]: | |
1254 | d = util.parsedate(date, util.extendeddateformats) |
|
1257 | d = util.parsedate(date, util.extendeddateformats) | |
1255 | else: |
|
1258 | else: | |
1256 | d = util.parsedate(date) |
|
1259 | d = util.parsedate(date) | |
1257 | ui.write("internal: %s %s\n" % d) |
|
1260 | ui.write("internal: %s %s\n" % d) | |
1258 | ui.write("standard: %s\n" % util.datestr(d)) |
|
1261 | ui.write("standard: %s\n" % util.datestr(d)) | |
1259 | if range: |
|
1262 | if range: | |
1260 | m = util.matchdate(range) |
|
1263 | m = util.matchdate(range) | |
1261 | ui.write("match: %s\n" % m(d[0])) |
|
1264 | ui.write("match: %s\n" % m(d[0])) | |
1262 |
|
1265 | |||
1263 | def debugindex(ui, repo, file_, **opts): |
|
1266 | def debugindex(ui, repo, file_, **opts): | |
1264 | """dump the contents of an index file""" |
|
1267 | """dump the contents of an index file""" | |
1265 | r = None |
|
1268 | r = None | |
1266 | if repo: |
|
1269 | if repo: | |
1267 | filelog = repo.file(file_) |
|
1270 | filelog = repo.file(file_) | |
1268 | if len(filelog): |
|
1271 | if len(filelog): | |
1269 | r = filelog |
|
1272 | r = filelog | |
1270 |
|
1273 | |||
1271 | format = opts.get('format', 0) |
|
1274 | format = opts.get('format', 0) | |
1272 | if format not in (0, 1): |
|
1275 | if format not in (0, 1): | |
1273 | raise util.abort("unknown format %d" % format) |
|
1276 | raise util.abort("unknown format %d" % format) | |
1274 |
|
1277 | |||
1275 | if not r: |
|
1278 | if not r: | |
1276 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) |
|
1279 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | |
1277 |
|
1280 | |||
1278 | if format == 0: |
|
1281 | if format == 0: | |
1279 | ui.write(" rev offset length base linkrev" |
|
1282 | ui.write(" rev offset length base linkrev" | |
1280 | " nodeid p1 p2\n") |
|
1283 | " nodeid p1 p2\n") | |
1281 | elif format == 1: |
|
1284 | elif format == 1: | |
1282 | ui.write(" rev flag offset length" |
|
1285 | ui.write(" rev flag offset length" | |
1283 | " size base link p1 p2 nodeid\n") |
|
1286 | " size base link p1 p2 nodeid\n") | |
1284 |
|
1287 | |||
1285 | for i in r: |
|
1288 | for i in r: | |
1286 | node = r.node(i) |
|
1289 | node = r.node(i) | |
1287 | if format == 0: |
|
1290 | if format == 0: | |
1288 | try: |
|
1291 | try: | |
1289 | pp = r.parents(node) |
|
1292 | pp = r.parents(node) | |
1290 | except: |
|
1293 | except: | |
1291 | pp = [nullid, nullid] |
|
1294 | pp = [nullid, nullid] | |
1292 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
|
1295 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( | |
1293 | i, r.start(i), r.length(i), r.base(i), r.linkrev(i), |
|
1296 | i, r.start(i), r.length(i), r.base(i), r.linkrev(i), | |
1294 | short(node), short(pp[0]), short(pp[1]))) |
|
1297 | short(node), short(pp[0]), short(pp[1]))) | |
1295 | elif format == 1: |
|
1298 | elif format == 1: | |
1296 | pr = r.parentrevs(i) |
|
1299 | pr = r.parentrevs(i) | |
1297 | ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( |
|
1300 | ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( | |
1298 | i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), |
|
1301 | i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), | |
1299 | r.base(i), r.linkrev(i), pr[0], pr[1], short(node))) |
|
1302 | r.base(i), r.linkrev(i), pr[0], pr[1], short(node))) | |
1300 |
|
1303 | |||
1301 | def debugindexdot(ui, repo, file_): |
|
1304 | def debugindexdot(ui, repo, file_): | |
1302 | """dump an index DAG as a graphviz dot file""" |
|
1305 | """dump an index DAG as a graphviz dot file""" | |
1303 | r = None |
|
1306 | r = None | |
1304 | if repo: |
|
1307 | if repo: | |
1305 | filelog = repo.file(file_) |
|
1308 | filelog = repo.file(file_) | |
1306 | if len(filelog): |
|
1309 | if len(filelog): | |
1307 | r = filelog |
|
1310 | r = filelog | |
1308 | if not r: |
|
1311 | if not r: | |
1309 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) |
|
1312 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | |
1310 | ui.write("digraph G {\n") |
|
1313 | ui.write("digraph G {\n") | |
1311 | for i in r: |
|
1314 | for i in r: | |
1312 | node = r.node(i) |
|
1315 | node = r.node(i) | |
1313 | pp = r.parents(node) |
|
1316 | pp = r.parents(node) | |
1314 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
|
1317 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | |
1315 | if pp[1] != nullid: |
|
1318 | if pp[1] != nullid: | |
1316 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
|
1319 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) | |
1317 | ui.write("}\n") |
|
1320 | ui.write("}\n") | |
1318 |
|
1321 | |||
1319 | def debuginstall(ui): |
|
1322 | def debuginstall(ui): | |
1320 | '''test Mercurial installation |
|
1323 | '''test Mercurial installation | |
1321 |
|
1324 | |||
1322 | Returns 0 on success. |
|
1325 | Returns 0 on success. | |
1323 | ''' |
|
1326 | ''' | |
1324 |
|
1327 | |||
1325 | def writetemp(contents): |
|
1328 | def writetemp(contents): | |
1326 | (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
|
1329 | (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") | |
1327 | f = os.fdopen(fd, "wb") |
|
1330 | f = os.fdopen(fd, "wb") | |
1328 | f.write(contents) |
|
1331 | f.write(contents) | |
1329 | f.close() |
|
1332 | f.close() | |
1330 | return name |
|
1333 | return name | |
1331 |
|
1334 | |||
1332 | problems = 0 |
|
1335 | problems = 0 | |
1333 |
|
1336 | |||
1334 | # encoding |
|
1337 | # encoding | |
1335 | ui.status(_("Checking encoding (%s)...\n") % encoding.encoding) |
|
1338 | ui.status(_("Checking encoding (%s)...\n") % encoding.encoding) | |
1336 | try: |
|
1339 | try: | |
1337 | encoding.fromlocal("test") |
|
1340 | encoding.fromlocal("test") | |
1338 | except util.Abort, inst: |
|
1341 | except util.Abort, inst: | |
1339 | ui.write(" %s\n" % inst) |
|
1342 | ui.write(" %s\n" % inst) | |
1340 | ui.write(_(" (check that your locale is properly set)\n")) |
|
1343 | ui.write(_(" (check that your locale is properly set)\n")) | |
1341 | problems += 1 |
|
1344 | problems += 1 | |
1342 |
|
1345 | |||
1343 | # compiled modules |
|
1346 | # compiled modules | |
1344 | ui.status(_("Checking installed modules (%s)...\n") |
|
1347 | ui.status(_("Checking installed modules (%s)...\n") | |
1345 | % os.path.dirname(__file__)) |
|
1348 | % os.path.dirname(__file__)) | |
1346 | try: |
|
1349 | try: | |
1347 | import bdiff, mpatch, base85, osutil |
|
1350 | import bdiff, mpatch, base85, osutil | |
1348 | except Exception, inst: |
|
1351 | except Exception, inst: | |
1349 | ui.write(" %s\n" % inst) |
|
1352 | ui.write(" %s\n" % inst) | |
1350 | ui.write(_(" One or more extensions could not be found")) |
|
1353 | ui.write(_(" One or more extensions could not be found")) | |
1351 | ui.write(_(" (check that you compiled the extensions)\n")) |
|
1354 | ui.write(_(" (check that you compiled the extensions)\n")) | |
1352 | problems += 1 |
|
1355 | problems += 1 | |
1353 |
|
1356 | |||
1354 | # templates |
|
1357 | # templates | |
1355 | ui.status(_("Checking templates...\n")) |
|
1358 | ui.status(_("Checking templates...\n")) | |
1356 | try: |
|
1359 | try: | |
1357 | import templater |
|
1360 | import templater | |
1358 | templater.templater(templater.templatepath("map-cmdline.default")) |
|
1361 | templater.templater(templater.templatepath("map-cmdline.default")) | |
1359 | except Exception, inst: |
|
1362 | except Exception, inst: | |
1360 | ui.write(" %s\n" % inst) |
|
1363 | ui.write(" %s\n" % inst) | |
1361 | ui.write(_(" (templates seem to have been installed incorrectly)\n")) |
|
1364 | ui.write(_(" (templates seem to have been installed incorrectly)\n")) | |
1362 | problems += 1 |
|
1365 | problems += 1 | |
1363 |
|
1366 | |||
1364 | # patch |
|
1367 | # patch | |
1365 | ui.status(_("Checking patch...\n")) |
|
1368 | ui.status(_("Checking patch...\n")) | |
1366 | patchproblems = 0 |
|
1369 | patchproblems = 0 | |
1367 | a = "1\n2\n3\n4\n" |
|
1370 | a = "1\n2\n3\n4\n" | |
1368 | b = "1\n2\n3\ninsert\n4\n" |
|
1371 | b = "1\n2\n3\ninsert\n4\n" | |
1369 | fa = writetemp(a) |
|
1372 | fa = writetemp(a) | |
1370 | d = mdiff.unidiff(a, None, b, None, os.path.basename(fa), |
|
1373 | d = mdiff.unidiff(a, None, b, None, os.path.basename(fa), | |
1371 | os.path.basename(fa)) |
|
1374 | os.path.basename(fa)) | |
1372 | fd = writetemp(d) |
|
1375 | fd = writetemp(d) | |
1373 |
|
1376 | |||
1374 | files = {} |
|
1377 | files = {} | |
1375 | try: |
|
1378 | try: | |
1376 | patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files) |
|
1379 | patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files) | |
1377 | except util.Abort, e: |
|
1380 | except util.Abort, e: | |
1378 | ui.write(_(" patch call failed:\n")) |
|
1381 | ui.write(_(" patch call failed:\n")) | |
1379 | ui.write(" " + str(e) + "\n") |
|
1382 | ui.write(" " + str(e) + "\n") | |
1380 | patchproblems += 1 |
|
1383 | patchproblems += 1 | |
1381 | else: |
|
1384 | else: | |
1382 | if list(files) != [os.path.basename(fa)]: |
|
1385 | if list(files) != [os.path.basename(fa)]: | |
1383 | ui.write(_(" unexpected patch output!\n")) |
|
1386 | ui.write(_(" unexpected patch output!\n")) | |
1384 | patchproblems += 1 |
|
1387 | patchproblems += 1 | |
1385 | a = open(fa).read() |
|
1388 | a = open(fa).read() | |
1386 | if a != b: |
|
1389 | if a != b: | |
1387 | ui.write(_(" patch test failed!\n")) |
|
1390 | ui.write(_(" patch test failed!\n")) | |
1388 | patchproblems += 1 |
|
1391 | patchproblems += 1 | |
1389 |
|
1392 | |||
1390 | if patchproblems: |
|
1393 | if patchproblems: | |
1391 | if ui.config('ui', 'patch'): |
|
1394 | if ui.config('ui', 'patch'): | |
1392 | ui.write(_(" (Current patch tool may be incompatible with patch," |
|
1395 | ui.write(_(" (Current patch tool may be incompatible with patch," | |
1393 | " or misconfigured. Please check your configuration" |
|
1396 | " or misconfigured. Please check your configuration" | |
1394 | " file)\n")) |
|
1397 | " file)\n")) | |
1395 | else: |
|
1398 | else: | |
1396 | ui.write(_(" Internal patcher failure, please report this error" |
|
1399 | ui.write(_(" Internal patcher failure, please report this error" | |
1397 | " to http://mercurial.selenic.com/wiki/BugTracker\n")) |
|
1400 | " to http://mercurial.selenic.com/wiki/BugTracker\n")) | |
1398 | problems += patchproblems |
|
1401 | problems += patchproblems | |
1399 |
|
1402 | |||
1400 | os.unlink(fa) |
|
1403 | os.unlink(fa) | |
1401 | os.unlink(fd) |
|
1404 | os.unlink(fd) | |
1402 |
|
1405 | |||
1403 | # editor |
|
1406 | # editor | |
1404 | ui.status(_("Checking commit editor...\n")) |
|
1407 | ui.status(_("Checking commit editor...\n")) | |
1405 | editor = ui.geteditor() |
|
1408 | editor = ui.geteditor() | |
1406 | cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) |
|
1409 | cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) | |
1407 | if not cmdpath: |
|
1410 | if not cmdpath: | |
1408 | if editor == 'vi': |
|
1411 | if editor == 'vi': | |
1409 | ui.write(_(" No commit editor set and can't find vi in PATH\n")) |
|
1412 | ui.write(_(" No commit editor set and can't find vi in PATH\n")) | |
1410 | ui.write(_(" (specify a commit editor in your configuration" |
|
1413 | ui.write(_(" (specify a commit editor in your configuration" | |
1411 | " file)\n")) |
|
1414 | " file)\n")) | |
1412 | else: |
|
1415 | else: | |
1413 | ui.write(_(" Can't find editor '%s' in PATH\n") % editor) |
|
1416 | ui.write(_(" Can't find editor '%s' in PATH\n") % editor) | |
1414 | ui.write(_(" (specify a commit editor in your configuration" |
|
1417 | ui.write(_(" (specify a commit editor in your configuration" | |
1415 | " file)\n")) |
|
1418 | " file)\n")) | |
1416 | problems += 1 |
|
1419 | problems += 1 | |
1417 |
|
1420 | |||
1418 | # check username |
|
1421 | # check username | |
1419 | ui.status(_("Checking username...\n")) |
|
1422 | ui.status(_("Checking username...\n")) | |
1420 | try: |
|
1423 | try: | |
1421 | ui.username() |
|
1424 | ui.username() | |
1422 | except util.Abort, e: |
|
1425 | except util.Abort, e: | |
1423 | ui.write(" %s\n" % e) |
|
1426 | ui.write(" %s\n" % e) | |
1424 | ui.write(_(" (specify a username in your configuration file)\n")) |
|
1427 | ui.write(_(" (specify a username in your configuration file)\n")) | |
1425 | problems += 1 |
|
1428 | problems += 1 | |
1426 |
|
1429 | |||
1427 | if not problems: |
|
1430 | if not problems: | |
1428 | ui.status(_("No problems detected\n")) |
|
1431 | ui.status(_("No problems detected\n")) | |
1429 | else: |
|
1432 | else: | |
1430 | ui.write(_("%s problems detected," |
|
1433 | ui.write(_("%s problems detected," | |
1431 | " please check your install!\n") % problems) |
|
1434 | " please check your install!\n") % problems) | |
1432 |
|
1435 | |||
1433 | return problems |
|
1436 | return problems | |
1434 |
|
1437 | |||
1435 | def debugrename(ui, repo, file1, *pats, **opts): |
|
1438 | def debugrename(ui, repo, file1, *pats, **opts): | |
1436 | """dump rename information""" |
|
1439 | """dump rename information""" | |
1437 |
|
1440 | |||
1438 |
ctx = repo |
|
1441 | ctx = cmdutil.revsingle(repo, opts.get('rev')) | |
1439 | m = cmdutil.match(repo, (file1,) + pats, opts) |
|
1442 | m = cmdutil.match(repo, (file1,) + pats, opts) | |
1440 | for abs in ctx.walk(m): |
|
1443 | for abs in ctx.walk(m): | |
1441 | fctx = ctx[abs] |
|
1444 | fctx = ctx[abs] | |
1442 | o = fctx.filelog().renamed(fctx.filenode()) |
|
1445 | o = fctx.filelog().renamed(fctx.filenode()) | |
1443 | rel = m.rel(abs) |
|
1446 | rel = m.rel(abs) | |
1444 | if o: |
|
1447 | if o: | |
1445 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
|
1448 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | |
1446 | else: |
|
1449 | else: | |
1447 | ui.write(_("%s not renamed\n") % rel) |
|
1450 | ui.write(_("%s not renamed\n") % rel) | |
1448 |
|
1451 | |||
1449 | def debugwalk(ui, repo, *pats, **opts): |
|
1452 | def debugwalk(ui, repo, *pats, **opts): | |
1450 | """show how files match on given patterns""" |
|
1453 | """show how files match on given patterns""" | |
1451 | m = cmdutil.match(repo, pats, opts) |
|
1454 | m = cmdutil.match(repo, pats, opts) | |
1452 | items = list(repo.walk(m)) |
|
1455 | items = list(repo.walk(m)) | |
1453 | if not items: |
|
1456 | if not items: | |
1454 | return |
|
1457 | return | |
1455 | fmt = 'f %%-%ds %%-%ds %%s' % ( |
|
1458 | fmt = 'f %%-%ds %%-%ds %%s' % ( | |
1456 | max([len(abs) for abs in items]), |
|
1459 | max([len(abs) for abs in items]), | |
1457 | max([len(m.rel(abs)) for abs in items])) |
|
1460 | max([len(m.rel(abs)) for abs in items])) | |
1458 | for abs in items: |
|
1461 | for abs in items: | |
1459 | line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '') |
|
1462 | line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '') | |
1460 | ui.write("%s\n" % line.rstrip()) |
|
1463 | ui.write("%s\n" % line.rstrip()) | |
1461 |
|
1464 | |||
1462 | def diff(ui, repo, *pats, **opts): |
|
1465 | def diff(ui, repo, *pats, **opts): | |
1463 | """diff repository (or selected files) |
|
1466 | """diff repository (or selected files) | |
1464 |
|
1467 | |||
1465 | Show differences between revisions for the specified files. |
|
1468 | Show differences between revisions for the specified files. | |
1466 |
|
1469 | |||
1467 | Differences between files are shown using the unified diff format. |
|
1470 | Differences between files are shown using the unified diff format. | |
1468 |
|
1471 | |||
1469 | .. note:: |
|
1472 | .. note:: | |
1470 | diff may generate unexpected results for merges, as it will |
|
1473 | diff may generate unexpected results for merges, as it will | |
1471 | default to comparing against the working directory's first |
|
1474 | default to comparing against the working directory's first | |
1472 | parent changeset if no revisions are specified. |
|
1475 | parent changeset if no revisions are specified. | |
1473 |
|
1476 | |||
1474 | When two revision arguments are given, then changes are shown |
|
1477 | When two revision arguments are given, then changes are shown | |
1475 | between those revisions. If only one revision is specified then |
|
1478 | between those revisions. If only one revision is specified then | |
1476 | that revision is compared to the working directory, and, when no |
|
1479 | that revision is compared to the working directory, and, when no | |
1477 | revisions are specified, the working directory files are compared |
|
1480 | revisions are specified, the working directory files are compared | |
1478 | to its parent. |
|
1481 | to its parent. | |
1479 |
|
1482 | |||
1480 | Alternatively you can specify -c/--change with a revision to see |
|
1483 | Alternatively you can specify -c/--change with a revision to see | |
1481 | the changes in that changeset relative to its first parent. |
|
1484 | the changes in that changeset relative to its first parent. | |
1482 |
|
1485 | |||
1483 | Without the -a/--text option, diff will avoid generating diffs of |
|
1486 | Without the -a/--text option, diff will avoid generating diffs of | |
1484 | files it detects as binary. With -a, diff will generate a diff |
|
1487 | files it detects as binary. With -a, diff will generate a diff | |
1485 | anyway, probably with undesirable results. |
|
1488 | anyway, probably with undesirable results. | |
1486 |
|
1489 | |||
1487 | Use the -g/--git option to generate diffs in the git extended diff |
|
1490 | Use the -g/--git option to generate diffs in the git extended diff | |
1488 | format. For more information, read :hg:`help diffs`. |
|
1491 | format. For more information, read :hg:`help diffs`. | |
1489 |
|
1492 | |||
1490 | Returns 0 on success. |
|
1493 | Returns 0 on success. | |
1491 | """ |
|
1494 | """ | |
1492 |
|
1495 | |||
1493 | revs = opts.get('rev') |
|
1496 | revs = opts.get('rev') | |
1494 | change = opts.get('change') |
|
1497 | change = opts.get('change') | |
1495 | stat = opts.get('stat') |
|
1498 | stat = opts.get('stat') | |
1496 | reverse = opts.get('reverse') |
|
1499 | reverse = opts.get('reverse') | |
1497 |
|
1500 | |||
1498 | if revs and change: |
|
1501 | if revs and change: | |
1499 | msg = _('cannot specify --rev and --change at the same time') |
|
1502 | msg = _('cannot specify --rev and --change at the same time') | |
1500 | raise util.Abort(msg) |
|
1503 | raise util.Abort(msg) | |
1501 | elif change: |
|
1504 | elif change: | |
1502 | node2 = repo.lookup(change) |
|
1505 | node2 = repo.lookup(change) | |
1503 | node1 = repo[node2].parents()[0].node() |
|
1506 | node1 = repo[node2].parents()[0].node() | |
1504 | else: |
|
1507 | else: | |
1505 | node1, node2 = cmdutil.revpair(repo, revs) |
|
1508 | node1, node2 = cmdutil.revpair(repo, revs) | |
1506 |
|
1509 | |||
1507 | if reverse: |
|
1510 | if reverse: | |
1508 | node1, node2 = node2, node1 |
|
1511 | node1, node2 = node2, node1 | |
1509 |
|
1512 | |||
1510 | diffopts = patch.diffopts(ui, opts) |
|
1513 | diffopts = patch.diffopts(ui, opts) | |
1511 | m = cmdutil.match(repo, pats, opts) |
|
1514 | m = cmdutil.match(repo, pats, opts) | |
1512 | cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, |
|
1515 | cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, | |
1513 | listsubrepos=opts.get('subrepos')) |
|
1516 | listsubrepos=opts.get('subrepos')) | |
1514 |
|
1517 | |||
1515 | def export(ui, repo, *changesets, **opts): |
|
1518 | def export(ui, repo, *changesets, **opts): | |
1516 | """dump the header and diffs for one or more changesets |
|
1519 | """dump the header and diffs for one or more changesets | |
1517 |
|
1520 | |||
1518 | Print the changeset header and diffs for one or more revisions. |
|
1521 | Print the changeset header and diffs for one or more revisions. | |
1519 |
|
1522 | |||
1520 | The information shown in the changeset header is: author, date, |
|
1523 | The information shown in the changeset header is: author, date, | |
1521 | branch name (if non-default), changeset hash, parent(s) and commit |
|
1524 | branch name (if non-default), changeset hash, parent(s) and commit | |
1522 | comment. |
|
1525 | comment. | |
1523 |
|
1526 | |||
1524 | .. note:: |
|
1527 | .. note:: | |
1525 | export may generate unexpected diff output for merge |
|
1528 | export may generate unexpected diff output for merge | |
1526 | changesets, as it will compare the merge changeset against its |
|
1529 | changesets, as it will compare the merge changeset against its | |
1527 | first parent only. |
|
1530 | first parent only. | |
1528 |
|
1531 | |||
1529 | Output may be to a file, in which case the name of the file is |
|
1532 | Output may be to a file, in which case the name of the file is | |
1530 | given using a format string. The formatting rules are as follows: |
|
1533 | given using a format string. The formatting rules are as follows: | |
1531 |
|
1534 | |||
1532 | :``%%``: literal "%" character |
|
1535 | :``%%``: literal "%" character | |
1533 | :``%H``: changeset hash (40 hexadecimal digits) |
|
1536 | :``%H``: changeset hash (40 hexadecimal digits) | |
1534 | :``%N``: number of patches being generated |
|
1537 | :``%N``: number of patches being generated | |
1535 | :``%R``: changeset revision number |
|
1538 | :``%R``: changeset revision number | |
1536 | :``%b``: basename of the exporting repository |
|
1539 | :``%b``: basename of the exporting repository | |
1537 | :``%h``: short-form changeset hash (12 hexadecimal digits) |
|
1540 | :``%h``: short-form changeset hash (12 hexadecimal digits) | |
1538 | :``%n``: zero-padded sequence number, starting at 1 |
|
1541 | :``%n``: zero-padded sequence number, starting at 1 | |
1539 | :``%r``: zero-padded changeset revision number |
|
1542 | :``%r``: zero-padded changeset revision number | |
1540 |
|
1543 | |||
1541 | Without the -a/--text option, export will avoid generating diffs |
|
1544 | Without the -a/--text option, export will avoid generating diffs | |
1542 | of files it detects as binary. With -a, export will generate a |
|
1545 | of files it detects as binary. With -a, export will generate a | |
1543 | diff anyway, probably with undesirable results. |
|
1546 | diff anyway, probably with undesirable results. | |
1544 |
|
1547 | |||
1545 | Use the -g/--git option to generate diffs in the git extended diff |
|
1548 | Use the -g/--git option to generate diffs in the git extended diff | |
1546 | format. See :hg:`help diffs` for more information. |
|
1549 | format. See :hg:`help diffs` for more information. | |
1547 |
|
1550 | |||
1548 | With the --switch-parent option, the diff will be against the |
|
1551 | With the --switch-parent option, the diff will be against the | |
1549 | second parent. It can be useful to review a merge. |
|
1552 | second parent. It can be useful to review a merge. | |
1550 |
|
1553 | |||
1551 | Returns 0 on success. |
|
1554 | Returns 0 on success. | |
1552 | """ |
|
1555 | """ | |
1553 | changesets += tuple(opts.get('rev', [])) |
|
1556 | changesets += tuple(opts.get('rev', [])) | |
1554 | if not changesets: |
|
1557 | if not changesets: | |
1555 | raise util.Abort(_("export requires at least one changeset")) |
|
1558 | raise util.Abort(_("export requires at least one changeset")) | |
1556 | revs = cmdutil.revrange(repo, changesets) |
|
1559 | revs = cmdutil.revrange(repo, changesets) | |
1557 | if len(revs) > 1: |
|
1560 | if len(revs) > 1: | |
1558 | ui.note(_('exporting patches:\n')) |
|
1561 | ui.note(_('exporting patches:\n')) | |
1559 | else: |
|
1562 | else: | |
1560 | ui.note(_('exporting patch:\n')) |
|
1563 | ui.note(_('exporting patch:\n')) | |
1561 | cmdutil.export(repo, revs, template=opts.get('output'), |
|
1564 | cmdutil.export(repo, revs, template=opts.get('output'), | |
1562 | switch_parent=opts.get('switch_parent'), |
|
1565 | switch_parent=opts.get('switch_parent'), | |
1563 | opts=patch.diffopts(ui, opts)) |
|
1566 | opts=patch.diffopts(ui, opts)) | |
1564 |
|
1567 | |||
1565 | def forget(ui, repo, *pats, **opts): |
|
1568 | def forget(ui, repo, *pats, **opts): | |
1566 | """forget the specified files on the next commit |
|
1569 | """forget the specified files on the next commit | |
1567 |
|
1570 | |||
1568 | Mark the specified files so they will no longer be tracked |
|
1571 | Mark the specified files so they will no longer be tracked | |
1569 | after the next commit. |
|
1572 | after the next commit. | |
1570 |
|
1573 | |||
1571 | This only removes files from the current branch, not from the |
|
1574 | This only removes files from the current branch, not from the | |
1572 | entire project history, and it does not delete them from the |
|
1575 | entire project history, and it does not delete them from the | |
1573 | working directory. |
|
1576 | working directory. | |
1574 |
|
1577 | |||
1575 | To undo a forget before the next commit, see :hg:`add`. |
|
1578 | To undo a forget before the next commit, see :hg:`add`. | |
1576 |
|
1579 | |||
1577 | Returns 0 on success. |
|
1580 | Returns 0 on success. | |
1578 | """ |
|
1581 | """ | |
1579 |
|
1582 | |||
1580 | if not pats: |
|
1583 | if not pats: | |
1581 | raise util.Abort(_('no files specified')) |
|
1584 | raise util.Abort(_('no files specified')) | |
1582 |
|
1585 | |||
1583 | m = cmdutil.match(repo, pats, opts) |
|
1586 | m = cmdutil.match(repo, pats, opts) | |
1584 | s = repo.status(match=m, clean=True) |
|
1587 | s = repo.status(match=m, clean=True) | |
1585 | forget = sorted(s[0] + s[1] + s[3] + s[6]) |
|
1588 | forget = sorted(s[0] + s[1] + s[3] + s[6]) | |
1586 | errs = 0 |
|
1589 | errs = 0 | |
1587 |
|
1590 | |||
1588 | for f in m.files(): |
|
1591 | for f in m.files(): | |
1589 | if f not in repo.dirstate and not os.path.isdir(m.rel(f)): |
|
1592 | if f not in repo.dirstate and not os.path.isdir(m.rel(f)): | |
1590 | ui.warn(_('not removing %s: file is already untracked\n') |
|
1593 | ui.warn(_('not removing %s: file is already untracked\n') | |
1591 | % m.rel(f)) |
|
1594 | % m.rel(f)) | |
1592 | errs = 1 |
|
1595 | errs = 1 | |
1593 |
|
1596 | |||
1594 | for f in forget: |
|
1597 | for f in forget: | |
1595 | if ui.verbose or not m.exact(f): |
|
1598 | if ui.verbose or not m.exact(f): | |
1596 | ui.status(_('removing %s\n') % m.rel(f)) |
|
1599 | ui.status(_('removing %s\n') % m.rel(f)) | |
1597 |
|
1600 | |||
1598 | repo[None].remove(forget, unlink=False) |
|
1601 | repo[None].remove(forget, unlink=False) | |
1599 | return errs |
|
1602 | return errs | |
1600 |
|
1603 | |||
1601 | def grep(ui, repo, pattern, *pats, **opts): |
|
1604 | def grep(ui, repo, pattern, *pats, **opts): | |
1602 | """search for a pattern in specified files and revisions |
|
1605 | """search for a pattern in specified files and revisions | |
1603 |
|
1606 | |||
1604 | Search revisions of files for a regular expression. |
|
1607 | Search revisions of files for a regular expression. | |
1605 |
|
1608 | |||
1606 | This command behaves differently than Unix grep. It only accepts |
|
1609 | This command behaves differently than Unix grep. It only accepts | |
1607 | Python/Perl regexps. It searches repository history, not the |
|
1610 | Python/Perl regexps. It searches repository history, not the | |
1608 | working directory. It always prints the revision number in which a |
|
1611 | working directory. It always prints the revision number in which a | |
1609 | match appears. |
|
1612 | match appears. | |
1610 |
|
1613 | |||
1611 | By default, grep only prints output for the first revision of a |
|
1614 | By default, grep only prints output for the first revision of a | |
1612 | file in which it finds a match. To get it to print every revision |
|
1615 | file in which it finds a match. To get it to print every revision | |
1613 | that contains a change in match status ("-" for a match that |
|
1616 | that contains a change in match status ("-" for a match that | |
1614 | becomes a non-match, or "+" for a non-match that becomes a match), |
|
1617 | becomes a non-match, or "+" for a non-match that becomes a match), | |
1615 | use the --all flag. |
|
1618 | use the --all flag. | |
1616 |
|
1619 | |||
1617 | Returns 0 if a match is found, 1 otherwise. |
|
1620 | Returns 0 if a match is found, 1 otherwise. | |
1618 | """ |
|
1621 | """ | |
1619 | reflags = 0 |
|
1622 | reflags = 0 | |
1620 | if opts.get('ignore_case'): |
|
1623 | if opts.get('ignore_case'): | |
1621 | reflags |= re.I |
|
1624 | reflags |= re.I | |
1622 | try: |
|
1625 | try: | |
1623 | regexp = re.compile(pattern, reflags) |
|
1626 | regexp = re.compile(pattern, reflags) | |
1624 | except re.error, inst: |
|
1627 | except re.error, inst: | |
1625 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
|
1628 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) | |
1626 | return 1 |
|
1629 | return 1 | |
1627 | sep, eol = ':', '\n' |
|
1630 | sep, eol = ':', '\n' | |
1628 | if opts.get('print0'): |
|
1631 | if opts.get('print0'): | |
1629 | sep = eol = '\0' |
|
1632 | sep = eol = '\0' | |
1630 |
|
1633 | |||
1631 | getfile = util.lrucachefunc(repo.file) |
|
1634 | getfile = util.lrucachefunc(repo.file) | |
1632 |
|
1635 | |||
1633 | def matchlines(body): |
|
1636 | def matchlines(body): | |
1634 | begin = 0 |
|
1637 | begin = 0 | |
1635 | linenum = 0 |
|
1638 | linenum = 0 | |
1636 | while True: |
|
1639 | while True: | |
1637 | match = regexp.search(body, begin) |
|
1640 | match = regexp.search(body, begin) | |
1638 | if not match: |
|
1641 | if not match: | |
1639 | break |
|
1642 | break | |
1640 | mstart, mend = match.span() |
|
1643 | mstart, mend = match.span() | |
1641 | linenum += body.count('\n', begin, mstart) + 1 |
|
1644 | linenum += body.count('\n', begin, mstart) + 1 | |
1642 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
1645 | lstart = body.rfind('\n', begin, mstart) + 1 or begin | |
1643 | begin = body.find('\n', mend) + 1 or len(body) |
|
1646 | begin = body.find('\n', mend) + 1 or len(body) | |
1644 | lend = begin - 1 |
|
1647 | lend = begin - 1 | |
1645 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
|
1648 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] | |
1646 |
|
1649 | |||
1647 | class linestate(object): |
|
1650 | class linestate(object): | |
1648 | def __init__(self, line, linenum, colstart, colend): |
|
1651 | def __init__(self, line, linenum, colstart, colend): | |
1649 | self.line = line |
|
1652 | self.line = line | |
1650 | self.linenum = linenum |
|
1653 | self.linenum = linenum | |
1651 | self.colstart = colstart |
|
1654 | self.colstart = colstart | |
1652 | self.colend = colend |
|
1655 | self.colend = colend | |
1653 |
|
1656 | |||
1654 | def __hash__(self): |
|
1657 | def __hash__(self): | |
1655 | return hash((self.linenum, self.line)) |
|
1658 | return hash((self.linenum, self.line)) | |
1656 |
|
1659 | |||
1657 | def __eq__(self, other): |
|
1660 | def __eq__(self, other): | |
1658 | return self.line == other.line |
|
1661 | return self.line == other.line | |
1659 |
|
1662 | |||
1660 | matches = {} |
|
1663 | matches = {} | |
1661 | copies = {} |
|
1664 | copies = {} | |
1662 | def grepbody(fn, rev, body): |
|
1665 | def grepbody(fn, rev, body): | |
1663 | matches[rev].setdefault(fn, []) |
|
1666 | matches[rev].setdefault(fn, []) | |
1664 | m = matches[rev][fn] |
|
1667 | m = matches[rev][fn] | |
1665 | for lnum, cstart, cend, line in matchlines(body): |
|
1668 | for lnum, cstart, cend, line in matchlines(body): | |
1666 | s = linestate(line, lnum, cstart, cend) |
|
1669 | s = linestate(line, lnum, cstart, cend) | |
1667 | m.append(s) |
|
1670 | m.append(s) | |
1668 |
|
1671 | |||
1669 | def difflinestates(a, b): |
|
1672 | def difflinestates(a, b): | |
1670 | sm = difflib.SequenceMatcher(None, a, b) |
|
1673 | sm = difflib.SequenceMatcher(None, a, b) | |
1671 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
1674 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): | |
1672 | if tag == 'insert': |
|
1675 | if tag == 'insert': | |
1673 | for i in xrange(blo, bhi): |
|
1676 | for i in xrange(blo, bhi): | |
1674 | yield ('+', b[i]) |
|
1677 | yield ('+', b[i]) | |
1675 | elif tag == 'delete': |
|
1678 | elif tag == 'delete': | |
1676 | for i in xrange(alo, ahi): |
|
1679 | for i in xrange(alo, ahi): | |
1677 | yield ('-', a[i]) |
|
1680 | yield ('-', a[i]) | |
1678 | elif tag == 'replace': |
|
1681 | elif tag == 'replace': | |
1679 | for i in xrange(alo, ahi): |
|
1682 | for i in xrange(alo, ahi): | |
1680 | yield ('-', a[i]) |
|
1683 | yield ('-', a[i]) | |
1681 | for i in xrange(blo, bhi): |
|
1684 | for i in xrange(blo, bhi): | |
1682 | yield ('+', b[i]) |
|
1685 | yield ('+', b[i]) | |
1683 |
|
1686 | |||
1684 | def display(fn, ctx, pstates, states): |
|
1687 | def display(fn, ctx, pstates, states): | |
1685 | rev = ctx.rev() |
|
1688 | rev = ctx.rev() | |
1686 | datefunc = ui.quiet and util.shortdate or util.datestr |
|
1689 | datefunc = ui.quiet and util.shortdate or util.datestr | |
1687 | found = False |
|
1690 | found = False | |
1688 | filerevmatches = {} |
|
1691 | filerevmatches = {} | |
1689 | if opts.get('all'): |
|
1692 | if opts.get('all'): | |
1690 | iter = difflinestates(pstates, states) |
|
1693 | iter = difflinestates(pstates, states) | |
1691 | else: |
|
1694 | else: | |
1692 | iter = [('', l) for l in states] |
|
1695 | iter = [('', l) for l in states] | |
1693 | for change, l in iter: |
|
1696 | for change, l in iter: | |
1694 | cols = [fn, str(rev)] |
|
1697 | cols = [fn, str(rev)] | |
1695 | before, match, after = None, None, None |
|
1698 | before, match, after = None, None, None | |
1696 | if opts.get('line_number'): |
|
1699 | if opts.get('line_number'): | |
1697 | cols.append(str(l.linenum)) |
|
1700 | cols.append(str(l.linenum)) | |
1698 | if opts.get('all'): |
|
1701 | if opts.get('all'): | |
1699 | cols.append(change) |
|
1702 | cols.append(change) | |
1700 | if opts.get('user'): |
|
1703 | if opts.get('user'): | |
1701 | cols.append(ui.shortuser(ctx.user())) |
|
1704 | cols.append(ui.shortuser(ctx.user())) | |
1702 | if opts.get('date'): |
|
1705 | if opts.get('date'): | |
1703 | cols.append(datefunc(ctx.date())) |
|
1706 | cols.append(datefunc(ctx.date())) | |
1704 | if opts.get('files_with_matches'): |
|
1707 | if opts.get('files_with_matches'): | |
1705 | c = (fn, rev) |
|
1708 | c = (fn, rev) | |
1706 | if c in filerevmatches: |
|
1709 | if c in filerevmatches: | |
1707 | continue |
|
1710 | continue | |
1708 | filerevmatches[c] = 1 |
|
1711 | filerevmatches[c] = 1 | |
1709 | else: |
|
1712 | else: | |
1710 | before = l.line[:l.colstart] |
|
1713 | before = l.line[:l.colstart] | |
1711 | match = l.line[l.colstart:l.colend] |
|
1714 | match = l.line[l.colstart:l.colend] | |
1712 | after = l.line[l.colend:] |
|
1715 | after = l.line[l.colend:] | |
1713 | ui.write(sep.join(cols)) |
|
1716 | ui.write(sep.join(cols)) | |
1714 | if before is not None: |
|
1717 | if before is not None: | |
1715 | ui.write(sep + before) |
|
1718 | ui.write(sep + before) | |
1716 | ui.write(match, label='grep.match') |
|
1719 | ui.write(match, label='grep.match') | |
1717 | ui.write(after) |
|
1720 | ui.write(after) | |
1718 | ui.write(eol) |
|
1721 | ui.write(eol) | |
1719 | found = True |
|
1722 | found = True | |
1720 | return found |
|
1723 | return found | |
1721 |
|
1724 | |||
1722 | skip = {} |
|
1725 | skip = {} | |
1723 | revfiles = {} |
|
1726 | revfiles = {} | |
1724 | matchfn = cmdutil.match(repo, pats, opts) |
|
1727 | matchfn = cmdutil.match(repo, pats, opts) | |
1725 | found = False |
|
1728 | found = False | |
1726 | follow = opts.get('follow') |
|
1729 | follow = opts.get('follow') | |
1727 |
|
1730 | |||
1728 | def prep(ctx, fns): |
|
1731 | def prep(ctx, fns): | |
1729 | rev = ctx.rev() |
|
1732 | rev = ctx.rev() | |
1730 | pctx = ctx.parents()[0] |
|
1733 | pctx = ctx.parents()[0] | |
1731 | parent = pctx.rev() |
|
1734 | parent = pctx.rev() | |
1732 | matches.setdefault(rev, {}) |
|
1735 | matches.setdefault(rev, {}) | |
1733 | matches.setdefault(parent, {}) |
|
1736 | matches.setdefault(parent, {}) | |
1734 | files = revfiles.setdefault(rev, []) |
|
1737 | files = revfiles.setdefault(rev, []) | |
1735 | for fn in fns: |
|
1738 | for fn in fns: | |
1736 | flog = getfile(fn) |
|
1739 | flog = getfile(fn) | |
1737 | try: |
|
1740 | try: | |
1738 | fnode = ctx.filenode(fn) |
|
1741 | fnode = ctx.filenode(fn) | |
1739 | except error.LookupError: |
|
1742 | except error.LookupError: | |
1740 | continue |
|
1743 | continue | |
1741 |
|
1744 | |||
1742 | copied = flog.renamed(fnode) |
|
1745 | copied = flog.renamed(fnode) | |
1743 | copy = follow and copied and copied[0] |
|
1746 | copy = follow and copied and copied[0] | |
1744 | if copy: |
|
1747 | if copy: | |
1745 | copies.setdefault(rev, {})[fn] = copy |
|
1748 | copies.setdefault(rev, {})[fn] = copy | |
1746 | if fn in skip: |
|
1749 | if fn in skip: | |
1747 | if copy: |
|
1750 | if copy: | |
1748 | skip[copy] = True |
|
1751 | skip[copy] = True | |
1749 | continue |
|
1752 | continue | |
1750 | files.append(fn) |
|
1753 | files.append(fn) | |
1751 |
|
1754 | |||
1752 | if fn not in matches[rev]: |
|
1755 | if fn not in matches[rev]: | |
1753 | grepbody(fn, rev, flog.read(fnode)) |
|
1756 | grepbody(fn, rev, flog.read(fnode)) | |
1754 |
|
1757 | |||
1755 | pfn = copy or fn |
|
1758 | pfn = copy or fn | |
1756 | if pfn not in matches[parent]: |
|
1759 | if pfn not in matches[parent]: | |
1757 | try: |
|
1760 | try: | |
1758 | fnode = pctx.filenode(pfn) |
|
1761 | fnode = pctx.filenode(pfn) | |
1759 | grepbody(pfn, parent, flog.read(fnode)) |
|
1762 | grepbody(pfn, parent, flog.read(fnode)) | |
1760 | except error.LookupError: |
|
1763 | except error.LookupError: | |
1761 | pass |
|
1764 | pass | |
1762 |
|
1765 | |||
1763 | for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): |
|
1766 | for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): | |
1764 | rev = ctx.rev() |
|
1767 | rev = ctx.rev() | |
1765 | parent = ctx.parents()[0].rev() |
|
1768 | parent = ctx.parents()[0].rev() | |
1766 | for fn in sorted(revfiles.get(rev, [])): |
|
1769 | for fn in sorted(revfiles.get(rev, [])): | |
1767 | states = matches[rev][fn] |
|
1770 | states = matches[rev][fn] | |
1768 | copy = copies.get(rev, {}).get(fn) |
|
1771 | copy = copies.get(rev, {}).get(fn) | |
1769 | if fn in skip: |
|
1772 | if fn in skip: | |
1770 | if copy: |
|
1773 | if copy: | |
1771 | skip[copy] = True |
|
1774 | skip[copy] = True | |
1772 | continue |
|
1775 | continue | |
1773 | pstates = matches.get(parent, {}).get(copy or fn, []) |
|
1776 | pstates = matches.get(parent, {}).get(copy or fn, []) | |
1774 | if pstates or states: |
|
1777 | if pstates or states: | |
1775 | r = display(fn, ctx, pstates, states) |
|
1778 | r = display(fn, ctx, pstates, states) | |
1776 | found = found or r |
|
1779 | found = found or r | |
1777 | if r and not opts.get('all'): |
|
1780 | if r and not opts.get('all'): | |
1778 | skip[fn] = True |
|
1781 | skip[fn] = True | |
1779 | if copy: |
|
1782 | if copy: | |
1780 | skip[copy] = True |
|
1783 | skip[copy] = True | |
1781 | del matches[rev] |
|
1784 | del matches[rev] | |
1782 | del revfiles[rev] |
|
1785 | del revfiles[rev] | |
1783 |
|
1786 | |||
1784 | return not found |
|
1787 | return not found | |
1785 |
|
1788 | |||
1786 | def heads(ui, repo, *branchrevs, **opts): |
|
1789 | def heads(ui, repo, *branchrevs, **opts): | |
1787 | """show current repository heads or show branch heads |
|
1790 | """show current repository heads or show branch heads | |
1788 |
|
1791 | |||
1789 | With no arguments, show all repository branch heads. |
|
1792 | With no arguments, show all repository branch heads. | |
1790 |
|
1793 | |||
1791 | Repository "heads" are changesets with no child changesets. They are |
|
1794 | Repository "heads" are changesets with no child changesets. They are | |
1792 | where development generally takes place and are the usual targets |
|
1795 | where development generally takes place and are the usual targets | |
1793 | for update and merge operations. Branch heads are changesets that have |
|
1796 | for update and merge operations. Branch heads are changesets that have | |
1794 | no child changeset on the same branch. |
|
1797 | no child changeset on the same branch. | |
1795 |
|
1798 | |||
1796 | If one or more REVs are given, only branch heads on the branches |
|
1799 | If one or more REVs are given, only branch heads on the branches | |
1797 | associated with the specified changesets are shown. |
|
1800 | associated with the specified changesets are shown. | |
1798 |
|
1801 | |||
1799 | If -c/--closed is specified, also show branch heads marked closed |
|
1802 | If -c/--closed is specified, also show branch heads marked closed | |
1800 | (see :hg:`commit --close-branch`). |
|
1803 | (see :hg:`commit --close-branch`). | |
1801 |
|
1804 | |||
1802 | If STARTREV is specified, only those heads that are descendants of |
|
1805 | If STARTREV is specified, only those heads that are descendants of | |
1803 | STARTREV will be displayed. |
|
1806 | STARTREV will be displayed. | |
1804 |
|
1807 | |||
1805 | If -t/--topo is specified, named branch mechanics will be ignored and only |
|
1808 | If -t/--topo is specified, named branch mechanics will be ignored and only | |
1806 | changesets without children will be shown. |
|
1809 | changesets without children will be shown. | |
1807 |
|
1810 | |||
1808 | Returns 0 if matching heads are found, 1 if not. |
|
1811 | Returns 0 if matching heads are found, 1 if not. | |
1809 | """ |
|
1812 | """ | |
1810 |
|
1813 | |||
1811 | if opts.get('rev'): |
|
1814 | start = None | |
1812 | start = repo.lookup(opts['rev']) |
|
1815 | if 'rev' in opts: | |
1813 | else: |
|
1816 | start = cmdutil.revsingle(repo, opts['rev'], None).node() | |
1814 | start = None |
|
|||
1815 |
|
1817 | |||
1816 | if opts.get('topo'): |
|
1818 | if opts.get('topo'): | |
1817 | heads = [repo[h] for h in repo.heads(start)] |
|
1819 | heads = [repo[h] for h in repo.heads(start)] | |
1818 | else: |
|
1820 | else: | |
1819 | heads = [] |
|
1821 | heads = [] | |
1820 | for b, ls in repo.branchmap().iteritems(): |
|
1822 | for b, ls in repo.branchmap().iteritems(): | |
1821 | if start is None: |
|
1823 | if start is None: | |
1822 | heads += [repo[h] for h in ls] |
|
1824 | heads += [repo[h] for h in ls] | |
1823 | continue |
|
1825 | continue | |
1824 | startrev = repo.changelog.rev(start) |
|
1826 | startrev = repo.changelog.rev(start) | |
1825 | descendants = set(repo.changelog.descendants(startrev)) |
|
1827 | descendants = set(repo.changelog.descendants(startrev)) | |
1826 | descendants.add(startrev) |
|
1828 | descendants.add(startrev) | |
1827 | rev = repo.changelog.rev |
|
1829 | rev = repo.changelog.rev | |
1828 | heads += [repo[h] for h in ls if rev(h) in descendants] |
|
1830 | heads += [repo[h] for h in ls if rev(h) in descendants] | |
1829 |
|
1831 | |||
1830 | if branchrevs: |
|
1832 | if branchrevs: | |
1831 | decode, encode = encoding.fromlocal, encoding.tolocal |
|
1833 | decode, encode = encoding.fromlocal, encoding.tolocal | |
1832 | branches = set(repo[decode(br)].branch() for br in branchrevs) |
|
1834 | branches = set(repo[decode(br)].branch() for br in branchrevs) | |
1833 | heads = [h for h in heads if h.branch() in branches] |
|
1835 | heads = [h for h in heads if h.branch() in branches] | |
1834 |
|
1836 | |||
1835 | if not opts.get('closed'): |
|
1837 | if not opts.get('closed'): | |
1836 | heads = [h for h in heads if not h.extra().get('close')] |
|
1838 | heads = [h for h in heads if not h.extra().get('close')] | |
1837 |
|
1839 | |||
1838 | if opts.get('active') and branchrevs: |
|
1840 | if opts.get('active') and branchrevs: | |
1839 | dagheads = repo.heads(start) |
|
1841 | dagheads = repo.heads(start) | |
1840 | heads = [h for h in heads if h.node() in dagheads] |
|
1842 | heads = [h for h in heads if h.node() in dagheads] | |
1841 |
|
1843 | |||
1842 | if branchrevs: |
|
1844 | if branchrevs: | |
1843 | haveheads = set(h.branch() for h in heads) |
|
1845 | haveheads = set(h.branch() for h in heads) | |
1844 | if branches - haveheads: |
|
1846 | if branches - haveheads: | |
1845 | headless = ', '.join(encode(b) for b in branches - haveheads) |
|
1847 | headless = ', '.join(encode(b) for b in branches - haveheads) | |
1846 | msg = _('no open branch heads found on branches %s') |
|
1848 | msg = _('no open branch heads found on branches %s') | |
1847 | if opts.get('rev'): |
|
1849 | if opts.get('rev'): | |
1848 | msg += _(' (started at %s)' % opts['rev']) |
|
1850 | msg += _(' (started at %s)' % opts['rev']) | |
1849 | ui.warn((msg + '\n') % headless) |
|
1851 | ui.warn((msg + '\n') % headless) | |
1850 |
|
1852 | |||
1851 | if not heads: |
|
1853 | if not heads: | |
1852 | return 1 |
|
1854 | return 1 | |
1853 |
|
1855 | |||
1854 | heads = sorted(heads, key=lambda x: -x.rev()) |
|
1856 | heads = sorted(heads, key=lambda x: -x.rev()) | |
1855 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
1857 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
1856 | for ctx in heads: |
|
1858 | for ctx in heads: | |
1857 | displayer.show(ctx) |
|
1859 | displayer.show(ctx) | |
1858 | displayer.close() |
|
1860 | displayer.close() | |
1859 |
|
1861 | |||
1860 | def help_(ui, name=None, with_version=False, unknowncmd=False): |
|
1862 | def help_(ui, name=None, with_version=False, unknowncmd=False): | |
1861 | """show help for a given topic or a help overview |
|
1863 | """show help for a given topic or a help overview | |
1862 |
|
1864 | |||
1863 | With no arguments, print a list of commands with short help messages. |
|
1865 | With no arguments, print a list of commands with short help messages. | |
1864 |
|
1866 | |||
1865 | Given a topic, extension, or command name, print help for that |
|
1867 | Given a topic, extension, or command name, print help for that | |
1866 | topic. |
|
1868 | topic. | |
1867 |
|
1869 | |||
1868 | Returns 0 if successful. |
|
1870 | Returns 0 if successful. | |
1869 | """ |
|
1871 | """ | |
1870 | option_lists = [] |
|
1872 | option_lists = [] | |
1871 | textwidth = ui.termwidth() - 2 |
|
1873 | textwidth = ui.termwidth() - 2 | |
1872 |
|
1874 | |||
1873 | def addglobalopts(aliases): |
|
1875 | def addglobalopts(aliases): | |
1874 | if ui.verbose: |
|
1876 | if ui.verbose: | |
1875 | option_lists.append((_("global options:"), globalopts)) |
|
1877 | option_lists.append((_("global options:"), globalopts)) | |
1876 | if name == 'shortlist': |
|
1878 | if name == 'shortlist': | |
1877 | option_lists.append((_('use "hg help" for the full list ' |
|
1879 | option_lists.append((_('use "hg help" for the full list ' | |
1878 | 'of commands'), ())) |
|
1880 | 'of commands'), ())) | |
1879 | else: |
|
1881 | else: | |
1880 | if name == 'shortlist': |
|
1882 | if name == 'shortlist': | |
1881 | msg = _('use "hg help" for the full list of commands ' |
|
1883 | msg = _('use "hg help" for the full list of commands ' | |
1882 | 'or "hg -v" for details') |
|
1884 | 'or "hg -v" for details') | |
1883 | elif aliases: |
|
1885 | elif aliases: | |
1884 | msg = _('use "hg -v help%s" to show aliases and ' |
|
1886 | msg = _('use "hg -v help%s" to show aliases and ' | |
1885 | 'global options') % (name and " " + name or "") |
|
1887 | 'global options') % (name and " " + name or "") | |
1886 | else: |
|
1888 | else: | |
1887 | msg = _('use "hg -v help %s" to show global options') % name |
|
1889 | msg = _('use "hg -v help %s" to show global options') % name | |
1888 | option_lists.append((msg, ())) |
|
1890 | option_lists.append((msg, ())) | |
1889 |
|
1891 | |||
1890 | def helpcmd(name): |
|
1892 | def helpcmd(name): | |
1891 | if with_version: |
|
1893 | if with_version: | |
1892 | version_(ui) |
|
1894 | version_(ui) | |
1893 | ui.write('\n') |
|
1895 | ui.write('\n') | |
1894 |
|
1896 | |||
1895 | try: |
|
1897 | try: | |
1896 | aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) |
|
1898 | aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd) | |
1897 | except error.AmbiguousCommand, inst: |
|
1899 | except error.AmbiguousCommand, inst: | |
1898 | # py3k fix: except vars can't be used outside the scope of the |
|
1900 | # py3k fix: except vars can't be used outside the scope of the | |
1899 | # except block, nor can be used inside a lambda. python issue4617 |
|
1901 | # except block, nor can be used inside a lambda. python issue4617 | |
1900 | prefix = inst.args[0] |
|
1902 | prefix = inst.args[0] | |
1901 | select = lambda c: c.lstrip('^').startswith(prefix) |
|
1903 | select = lambda c: c.lstrip('^').startswith(prefix) | |
1902 | helplist(_('list of commands:\n\n'), select) |
|
1904 | helplist(_('list of commands:\n\n'), select) | |
1903 | return |
|
1905 | return | |
1904 |
|
1906 | |||
1905 | # check if it's an invalid alias and display its error if it is |
|
1907 | # check if it's an invalid alias and display its error if it is | |
1906 | if getattr(entry[0], 'badalias', False): |
|
1908 | if getattr(entry[0], 'badalias', False): | |
1907 | if not unknowncmd: |
|
1909 | if not unknowncmd: | |
1908 | entry[0](ui) |
|
1910 | entry[0](ui) | |
1909 | return |
|
1911 | return | |
1910 |
|
1912 | |||
1911 | # synopsis |
|
1913 | # synopsis | |
1912 | if len(entry) > 2: |
|
1914 | if len(entry) > 2: | |
1913 | if entry[2].startswith('hg'): |
|
1915 | if entry[2].startswith('hg'): | |
1914 | ui.write("%s\n" % entry[2]) |
|
1916 | ui.write("%s\n" % entry[2]) | |
1915 | else: |
|
1917 | else: | |
1916 | ui.write('hg %s %s\n' % (aliases[0], entry[2])) |
|
1918 | ui.write('hg %s %s\n' % (aliases[0], entry[2])) | |
1917 | else: |
|
1919 | else: | |
1918 | ui.write('hg %s\n' % aliases[0]) |
|
1920 | ui.write('hg %s\n' % aliases[0]) | |
1919 |
|
1921 | |||
1920 | # aliases |
|
1922 | # aliases | |
1921 | if not ui.quiet and len(aliases) > 1: |
|
1923 | if not ui.quiet and len(aliases) > 1: | |
1922 | ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
|
1924 | ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) | |
1923 |
|
1925 | |||
1924 | # description |
|
1926 | # description | |
1925 | doc = gettext(entry[0].__doc__) |
|
1927 | doc = gettext(entry[0].__doc__) | |
1926 | if not doc: |
|
1928 | if not doc: | |
1927 | doc = _("(no help text available)") |
|
1929 | doc = _("(no help text available)") | |
1928 | if hasattr(entry[0], 'definition'): # aliased command |
|
1930 | if hasattr(entry[0], 'definition'): # aliased command | |
1929 | if entry[0].definition.startswith('!'): # shell alias |
|
1931 | if entry[0].definition.startswith('!'): # shell alias | |
1930 | doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] |
|
1932 | doc = _('shell alias for::\n\n %s') % entry[0].definition[1:] | |
1931 | else: |
|
1933 | else: | |
1932 | doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) |
|
1934 | doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc) | |
1933 | if ui.quiet: |
|
1935 | if ui.quiet: | |
1934 | doc = doc.splitlines()[0] |
|
1936 | doc = doc.splitlines()[0] | |
1935 | keep = ui.verbose and ['verbose'] or [] |
|
1937 | keep = ui.verbose and ['verbose'] or [] | |
1936 | formatted, pruned = minirst.format(doc, textwidth, keep=keep) |
|
1938 | formatted, pruned = minirst.format(doc, textwidth, keep=keep) | |
1937 | ui.write("\n%s\n" % formatted) |
|
1939 | ui.write("\n%s\n" % formatted) | |
1938 | if pruned: |
|
1940 | if pruned: | |
1939 | ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name) |
|
1941 | ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name) | |
1940 |
|
1942 | |||
1941 | if not ui.quiet: |
|
1943 | if not ui.quiet: | |
1942 | # options |
|
1944 | # options | |
1943 | if entry[1]: |
|
1945 | if entry[1]: | |
1944 | option_lists.append((_("options:\n"), entry[1])) |
|
1946 | option_lists.append((_("options:\n"), entry[1])) | |
1945 |
|
1947 | |||
1946 | addglobalopts(False) |
|
1948 | addglobalopts(False) | |
1947 |
|
1949 | |||
1948 | def helplist(header, select=None): |
|
1950 | def helplist(header, select=None): | |
1949 | h = {} |
|
1951 | h = {} | |
1950 | cmds = {} |
|
1952 | cmds = {} | |
1951 | for c, e in table.iteritems(): |
|
1953 | for c, e in table.iteritems(): | |
1952 | f = c.split("|", 1)[0] |
|
1954 | f = c.split("|", 1)[0] | |
1953 | if select and not select(f): |
|
1955 | if select and not select(f): | |
1954 | continue |
|
1956 | continue | |
1955 | if (not select and name != 'shortlist' and |
|
1957 | if (not select and name != 'shortlist' and | |
1956 | e[0].__module__ != __name__): |
|
1958 | e[0].__module__ != __name__): | |
1957 | continue |
|
1959 | continue | |
1958 | if name == "shortlist" and not f.startswith("^"): |
|
1960 | if name == "shortlist" and not f.startswith("^"): | |
1959 | continue |
|
1961 | continue | |
1960 | f = f.lstrip("^") |
|
1962 | f = f.lstrip("^") | |
1961 | if not ui.debugflag and f.startswith("debug"): |
|
1963 | if not ui.debugflag and f.startswith("debug"): | |
1962 | continue |
|
1964 | continue | |
1963 | doc = e[0].__doc__ |
|
1965 | doc = e[0].__doc__ | |
1964 | if doc and 'DEPRECATED' in doc and not ui.verbose: |
|
1966 | if doc and 'DEPRECATED' in doc and not ui.verbose: | |
1965 | continue |
|
1967 | continue | |
1966 | doc = gettext(doc) |
|
1968 | doc = gettext(doc) | |
1967 | if not doc: |
|
1969 | if not doc: | |
1968 | doc = _("(no help text available)") |
|
1970 | doc = _("(no help text available)") | |
1969 | h[f] = doc.splitlines()[0].rstrip() |
|
1971 | h[f] = doc.splitlines()[0].rstrip() | |
1970 | cmds[f] = c.lstrip("^") |
|
1972 | cmds[f] = c.lstrip("^") | |
1971 |
|
1973 | |||
1972 | if not h: |
|
1974 | if not h: | |
1973 | ui.status(_('no commands defined\n')) |
|
1975 | ui.status(_('no commands defined\n')) | |
1974 | return |
|
1976 | return | |
1975 |
|
1977 | |||
1976 | ui.status(header) |
|
1978 | ui.status(header) | |
1977 | fns = sorted(h) |
|
1979 | fns = sorted(h) | |
1978 | m = max(map(len, fns)) |
|
1980 | m = max(map(len, fns)) | |
1979 | for f in fns: |
|
1981 | for f in fns: | |
1980 | if ui.verbose: |
|
1982 | if ui.verbose: | |
1981 | commands = cmds[f].replace("|",", ") |
|
1983 | commands = cmds[f].replace("|",", ") | |
1982 | ui.write(" %s:\n %s\n"%(commands, h[f])) |
|
1984 | ui.write(" %s:\n %s\n"%(commands, h[f])) | |
1983 | else: |
|
1985 | else: | |
1984 | ui.write('%s\n' % (util.wrap(h[f], textwidth, |
|
1986 | ui.write('%s\n' % (util.wrap(h[f], textwidth, | |
1985 | initindent=' %-*s ' % (m, f), |
|
1987 | initindent=' %-*s ' % (m, f), | |
1986 | hangindent=' ' * (m + 4)))) |
|
1988 | hangindent=' ' * (m + 4)))) | |
1987 |
|
1989 | |||
1988 | if not ui.quiet: |
|
1990 | if not ui.quiet: | |
1989 | addglobalopts(True) |
|
1991 | addglobalopts(True) | |
1990 |
|
1992 | |||
1991 | def helptopic(name): |
|
1993 | def helptopic(name): | |
1992 | for names, header, doc in help.helptable: |
|
1994 | for names, header, doc in help.helptable: | |
1993 | if name in names: |
|
1995 | if name in names: | |
1994 | break |
|
1996 | break | |
1995 | else: |
|
1997 | else: | |
1996 | raise error.UnknownCommand(name) |
|
1998 | raise error.UnknownCommand(name) | |
1997 |
|
1999 | |||
1998 | # description |
|
2000 | # description | |
1999 | if not doc: |
|
2001 | if not doc: | |
2000 | doc = _("(no help text available)") |
|
2002 | doc = _("(no help text available)") | |
2001 | if hasattr(doc, '__call__'): |
|
2003 | if hasattr(doc, '__call__'): | |
2002 | doc = doc() |
|
2004 | doc = doc() | |
2003 |
|
2005 | |||
2004 | ui.write("%s\n\n" % header) |
|
2006 | ui.write("%s\n\n" % header) | |
2005 | ui.write("%s\n" % minirst.format(doc, textwidth, indent=4)) |
|
2007 | ui.write("%s\n" % minirst.format(doc, textwidth, indent=4)) | |
2006 |
|
2008 | |||
2007 | def helpext(name): |
|
2009 | def helpext(name): | |
2008 | try: |
|
2010 | try: | |
2009 | mod = extensions.find(name) |
|
2011 | mod = extensions.find(name) | |
2010 | doc = gettext(mod.__doc__) or _('no help text available') |
|
2012 | doc = gettext(mod.__doc__) or _('no help text available') | |
2011 | except KeyError: |
|
2013 | except KeyError: | |
2012 | mod = None |
|
2014 | mod = None | |
2013 | doc = extensions.disabledext(name) |
|
2015 | doc = extensions.disabledext(name) | |
2014 | if not doc: |
|
2016 | if not doc: | |
2015 | raise error.UnknownCommand(name) |
|
2017 | raise error.UnknownCommand(name) | |
2016 |
|
2018 | |||
2017 | if '\n' not in doc: |
|
2019 | if '\n' not in doc: | |
2018 | head, tail = doc, "" |
|
2020 | head, tail = doc, "" | |
2019 | else: |
|
2021 | else: | |
2020 | head, tail = doc.split('\n', 1) |
|
2022 | head, tail = doc.split('\n', 1) | |
2021 | ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head)) |
|
2023 | ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head)) | |
2022 | if tail: |
|
2024 | if tail: | |
2023 | ui.write(minirst.format(tail, textwidth)) |
|
2025 | ui.write(minirst.format(tail, textwidth)) | |
2024 | ui.status('\n\n') |
|
2026 | ui.status('\n\n') | |
2025 |
|
2027 | |||
2026 | if mod: |
|
2028 | if mod: | |
2027 | try: |
|
2029 | try: | |
2028 | ct = mod.cmdtable |
|
2030 | ct = mod.cmdtable | |
2029 | except AttributeError: |
|
2031 | except AttributeError: | |
2030 | ct = {} |
|
2032 | ct = {} | |
2031 | modcmds = set([c.split('|', 1)[0] for c in ct]) |
|
2033 | modcmds = set([c.split('|', 1)[0] for c in ct]) | |
2032 | helplist(_('list of commands:\n\n'), modcmds.__contains__) |
|
2034 | helplist(_('list of commands:\n\n'), modcmds.__contains__) | |
2033 | else: |
|
2035 | else: | |
2034 | ui.write(_('use "hg help extensions" for information on enabling ' |
|
2036 | ui.write(_('use "hg help extensions" for information on enabling ' | |
2035 | 'extensions\n')) |
|
2037 | 'extensions\n')) | |
2036 |
|
2038 | |||
2037 | def helpextcmd(name): |
|
2039 | def helpextcmd(name): | |
2038 | cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict')) |
|
2040 | cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict')) | |
2039 | doc = gettext(mod.__doc__).splitlines()[0] |
|
2041 | doc = gettext(mod.__doc__).splitlines()[0] | |
2040 |
|
2042 | |||
2041 | msg = help.listexts(_("'%s' is provided by the following " |
|
2043 | msg = help.listexts(_("'%s' is provided by the following " | |
2042 | "extension:") % cmd, {ext: doc}, len(ext), |
|
2044 | "extension:") % cmd, {ext: doc}, len(ext), | |
2043 | indent=4) |
|
2045 | indent=4) | |
2044 | ui.write(minirst.format(msg, textwidth)) |
|
2046 | ui.write(minirst.format(msg, textwidth)) | |
2045 | ui.write('\n\n') |
|
2047 | ui.write('\n\n') | |
2046 | ui.write(_('use "hg help extensions" for information on enabling ' |
|
2048 | ui.write(_('use "hg help extensions" for information on enabling ' | |
2047 | 'extensions\n')) |
|
2049 | 'extensions\n')) | |
2048 |
|
2050 | |||
2049 | help.addtopichook('revsets', revset.makedoc) |
|
2051 | help.addtopichook('revsets', revset.makedoc) | |
2050 |
|
2052 | |||
2051 | if name and name != 'shortlist': |
|
2053 | if name and name != 'shortlist': | |
2052 | i = None |
|
2054 | i = None | |
2053 | if unknowncmd: |
|
2055 | if unknowncmd: | |
2054 | queries = (helpextcmd,) |
|
2056 | queries = (helpextcmd,) | |
2055 | else: |
|
2057 | else: | |
2056 | queries = (helptopic, helpcmd, helpext, helpextcmd) |
|
2058 | queries = (helptopic, helpcmd, helpext, helpextcmd) | |
2057 | for f in queries: |
|
2059 | for f in queries: | |
2058 | try: |
|
2060 | try: | |
2059 | f(name) |
|
2061 | f(name) | |
2060 | i = None |
|
2062 | i = None | |
2061 | break |
|
2063 | break | |
2062 | except error.UnknownCommand, inst: |
|
2064 | except error.UnknownCommand, inst: | |
2063 | i = inst |
|
2065 | i = inst | |
2064 | if i: |
|
2066 | if i: | |
2065 | raise i |
|
2067 | raise i | |
2066 |
|
2068 | |||
2067 | else: |
|
2069 | else: | |
2068 | # program name |
|
2070 | # program name | |
2069 | if ui.verbose or with_version: |
|
2071 | if ui.verbose or with_version: | |
2070 | version_(ui) |
|
2072 | version_(ui) | |
2071 | else: |
|
2073 | else: | |
2072 | ui.status(_("Mercurial Distributed SCM\n")) |
|
2074 | ui.status(_("Mercurial Distributed SCM\n")) | |
2073 | ui.status('\n') |
|
2075 | ui.status('\n') | |
2074 |
|
2076 | |||
2075 | # list of commands |
|
2077 | # list of commands | |
2076 | if name == "shortlist": |
|
2078 | if name == "shortlist": | |
2077 | header = _('basic commands:\n\n') |
|
2079 | header = _('basic commands:\n\n') | |
2078 | else: |
|
2080 | else: | |
2079 | header = _('list of commands:\n\n') |
|
2081 | header = _('list of commands:\n\n') | |
2080 |
|
2082 | |||
2081 | helplist(header) |
|
2083 | helplist(header) | |
2082 | if name != 'shortlist': |
|
2084 | if name != 'shortlist': | |
2083 | exts, maxlength = extensions.enabled() |
|
2085 | exts, maxlength = extensions.enabled() | |
2084 | text = help.listexts(_('enabled extensions:'), exts, maxlength) |
|
2086 | text = help.listexts(_('enabled extensions:'), exts, maxlength) | |
2085 | if text: |
|
2087 | if text: | |
2086 | ui.write("\n%s\n" % minirst.format(text, textwidth)) |
|
2088 | ui.write("\n%s\n" % minirst.format(text, textwidth)) | |
2087 |
|
2089 | |||
2088 | # list all option lists |
|
2090 | # list all option lists | |
2089 | opt_output = [] |
|
2091 | opt_output = [] | |
2090 | multioccur = False |
|
2092 | multioccur = False | |
2091 | for title, options in option_lists: |
|
2093 | for title, options in option_lists: | |
2092 | opt_output.append(("\n%s" % title, None)) |
|
2094 | opt_output.append(("\n%s" % title, None)) | |
2093 | for option in options: |
|
2095 | for option in options: | |
2094 | if len(option) == 5: |
|
2096 | if len(option) == 5: | |
2095 | shortopt, longopt, default, desc, optlabel = option |
|
2097 | shortopt, longopt, default, desc, optlabel = option | |
2096 | else: |
|
2098 | else: | |
2097 | shortopt, longopt, default, desc = option |
|
2099 | shortopt, longopt, default, desc = option | |
2098 | optlabel = _("VALUE") # default label |
|
2100 | optlabel = _("VALUE") # default label | |
2099 |
|
2101 | |||
2100 | if _("DEPRECATED") in desc and not ui.verbose: |
|
2102 | if _("DEPRECATED") in desc and not ui.verbose: | |
2101 | continue |
|
2103 | continue | |
2102 | if isinstance(default, list): |
|
2104 | if isinstance(default, list): | |
2103 | numqualifier = " %s [+]" % optlabel |
|
2105 | numqualifier = " %s [+]" % optlabel | |
2104 | multioccur = True |
|
2106 | multioccur = True | |
2105 | elif (default is not None) and not isinstance(default, bool): |
|
2107 | elif (default is not None) and not isinstance(default, bool): | |
2106 | numqualifier = " %s" % optlabel |
|
2108 | numqualifier = " %s" % optlabel | |
2107 | else: |
|
2109 | else: | |
2108 | numqualifier = "" |
|
2110 | numqualifier = "" | |
2109 | opt_output.append(("%2s%s" % |
|
2111 | opt_output.append(("%2s%s" % | |
2110 | (shortopt and "-%s" % shortopt, |
|
2112 | (shortopt and "-%s" % shortopt, | |
2111 | longopt and " --%s%s" % |
|
2113 | longopt and " --%s%s" % | |
2112 | (longopt, numqualifier)), |
|
2114 | (longopt, numqualifier)), | |
2113 | "%s%s" % (desc, |
|
2115 | "%s%s" % (desc, | |
2114 | default |
|
2116 | default | |
2115 | and _(" (default: %s)") % default |
|
2117 | and _(" (default: %s)") % default | |
2116 | or ""))) |
|
2118 | or ""))) | |
2117 | if multioccur: |
|
2119 | if multioccur: | |
2118 | msg = _("\n[+] marked option can be specified multiple times") |
|
2120 | msg = _("\n[+] marked option can be specified multiple times") | |
2119 | if ui.verbose and name != 'shortlist': |
|
2121 | if ui.verbose and name != 'shortlist': | |
2120 | opt_output.append((msg, None)) |
|
2122 | opt_output.append((msg, None)) | |
2121 | else: |
|
2123 | else: | |
2122 | opt_output.insert(-1, (msg, None)) |
|
2124 | opt_output.insert(-1, (msg, None)) | |
2123 |
|
2125 | |||
2124 | if not name: |
|
2126 | if not name: | |
2125 | ui.write(_("\nadditional help topics:\n\n")) |
|
2127 | ui.write(_("\nadditional help topics:\n\n")) | |
2126 | topics = [] |
|
2128 | topics = [] | |
2127 | for names, header, doc in help.helptable: |
|
2129 | for names, header, doc in help.helptable: | |
2128 | topics.append((sorted(names, key=len, reverse=True)[0], header)) |
|
2130 | topics.append((sorted(names, key=len, reverse=True)[0], header)) | |
2129 | topics_len = max([len(s[0]) for s in topics]) |
|
2131 | topics_len = max([len(s[0]) for s in topics]) | |
2130 | for t, desc in topics: |
|
2132 | for t, desc in topics: | |
2131 | ui.write(" %-*s %s\n" % (topics_len, t, desc)) |
|
2133 | ui.write(" %-*s %s\n" % (topics_len, t, desc)) | |
2132 |
|
2134 | |||
2133 | if opt_output: |
|
2135 | if opt_output: | |
2134 | colwidth = encoding.colwidth |
|
2136 | colwidth = encoding.colwidth | |
2135 | # normalize: (opt or message, desc or None, width of opt) |
|
2137 | # normalize: (opt or message, desc or None, width of opt) | |
2136 | entries = [desc and (opt, desc, colwidth(opt)) or (opt, None, 0) |
|
2138 | entries = [desc and (opt, desc, colwidth(opt)) or (opt, None, 0) | |
2137 | for opt, desc in opt_output] |
|
2139 | for opt, desc in opt_output] | |
2138 | hanging = max([e[2] for e in entries]) |
|
2140 | hanging = max([e[2] for e in entries]) | |
2139 | for opt, desc, width in entries: |
|
2141 | for opt, desc, width in entries: | |
2140 | if desc: |
|
2142 | if desc: | |
2141 | initindent = ' %s%s ' % (opt, ' ' * (hanging - width)) |
|
2143 | initindent = ' %s%s ' % (opt, ' ' * (hanging - width)) | |
2142 | hangindent = ' ' * (hanging + 3) |
|
2144 | hangindent = ' ' * (hanging + 3) | |
2143 | ui.write('%s\n' % (util.wrap(desc, textwidth, |
|
2145 | ui.write('%s\n' % (util.wrap(desc, textwidth, | |
2144 | initindent=initindent, |
|
2146 | initindent=initindent, | |
2145 | hangindent=hangindent))) |
|
2147 | hangindent=hangindent))) | |
2146 | else: |
|
2148 | else: | |
2147 | ui.write("%s\n" % opt) |
|
2149 | ui.write("%s\n" % opt) | |
2148 |
|
2150 | |||
2149 | def identify(ui, repo, source=None, |
|
2151 | def identify(ui, repo, source=None, | |
2150 | rev=None, num=None, id=None, branch=None, tags=None): |
|
2152 | rev=None, num=None, id=None, branch=None, tags=None): | |
2151 | """identify the working copy or specified revision |
|
2153 | """identify the working copy or specified revision | |
2152 |
|
2154 | |||
2153 | With no revision, print a summary of the current state of the |
|
2155 | With no revision, print a summary of the current state of the | |
2154 | repository. |
|
2156 | repository. | |
2155 |
|
2157 | |||
2156 | Specifying a path to a repository root or Mercurial bundle will |
|
2158 | Specifying a path to a repository root or Mercurial bundle will | |
2157 | cause lookup to operate on that repository/bundle. |
|
2159 | cause lookup to operate on that repository/bundle. | |
2158 |
|
2160 | |||
2159 | This summary identifies the repository state using one or two |
|
2161 | This summary identifies the repository state using one or two | |
2160 | parent hash identifiers, followed by a "+" if there are |
|
2162 | parent hash identifiers, followed by a "+" if there are | |
2161 | uncommitted changes in the working directory, a list of tags for |
|
2163 | uncommitted changes in the working directory, a list of tags for | |
2162 | this revision and a branch name for non-default branches. |
|
2164 | this revision and a branch name for non-default branches. | |
2163 |
|
2165 | |||
2164 | Returns 0 if successful. |
|
2166 | Returns 0 if successful. | |
2165 | """ |
|
2167 | """ | |
2166 |
|
2168 | |||
2167 | if not repo and not source: |
|
2169 | if not repo and not source: | |
2168 | raise util.Abort(_("there is no Mercurial repository here " |
|
2170 | raise util.Abort(_("there is no Mercurial repository here " | |
2169 | "(.hg not found)")) |
|
2171 | "(.hg not found)")) | |
2170 |
|
2172 | |||
2171 | hexfunc = ui.debugflag and hex or short |
|
2173 | hexfunc = ui.debugflag and hex or short | |
2172 | default = not (num or id or branch or tags) |
|
2174 | default = not (num or id or branch or tags) | |
2173 | output = [] |
|
2175 | output = [] | |
2174 |
|
2176 | |||
2175 | revs = [] |
|
2177 | revs = [] | |
2176 | if source: |
|
2178 | if source: | |
2177 | source, branches = hg.parseurl(ui.expandpath(source)) |
|
2179 | source, branches = hg.parseurl(ui.expandpath(source)) | |
2178 | repo = hg.repository(ui, source) |
|
2180 | repo = hg.repository(ui, source) | |
2179 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
|
2181 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | |
2180 |
|
2182 | |||
2181 | if not repo.local(): |
|
2183 | if not repo.local(): | |
2182 | if not rev and revs: |
|
2184 | if not rev and revs: | |
2183 | rev = revs[0] |
|
2185 | rev = revs[0] | |
2184 | if not rev: |
|
2186 | if not rev: | |
2185 | rev = "tip" |
|
2187 | rev = "tip" | |
2186 | if num or branch or tags: |
|
2188 | if num or branch or tags: | |
2187 | raise util.Abort( |
|
2189 | raise util.Abort( | |
2188 | "can't query remote revision number, branch, or tags") |
|
2190 | "can't query remote revision number, branch, or tags") | |
2189 | output = [hexfunc(repo.lookup(rev))] |
|
2191 | output = [hexfunc(repo.lookup(rev))] | |
2190 | elif not rev: |
|
2192 | elif not rev: | |
2191 | ctx = repo[None] |
|
2193 | ctx = repo[None] | |
2192 | parents = ctx.parents() |
|
2194 | parents = ctx.parents() | |
2193 | changed = False |
|
2195 | changed = False | |
2194 | if default or id or num: |
|
2196 | if default or id or num: | |
2195 | changed = util.any(repo.status()) |
|
2197 | changed = util.any(repo.status()) | |
2196 | if default or id: |
|
2198 | if default or id: | |
2197 | output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), |
|
2199 | output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), | |
2198 | (changed) and "+" or "")] |
|
2200 | (changed) and "+" or "")] | |
2199 | if num: |
|
2201 | if num: | |
2200 | output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]), |
|
2202 | output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]), | |
2201 | (changed) and "+" or "")) |
|
2203 | (changed) and "+" or "")) | |
2202 | else: |
|
2204 | else: | |
2203 |
ctx = repo |
|
2205 | ctx = cmdutil.revsingle(repo, rev) | |
2204 | if default or id: |
|
2206 | if default or id: | |
2205 | output = [hexfunc(ctx.node())] |
|
2207 | output = [hexfunc(ctx.node())] | |
2206 | if num: |
|
2208 | if num: | |
2207 | output.append(str(ctx.rev())) |
|
2209 | output.append(str(ctx.rev())) | |
2208 |
|
2210 | |||
2209 | if repo.local() and default and not ui.quiet: |
|
2211 | if repo.local() and default and not ui.quiet: | |
2210 | b = encoding.tolocal(ctx.branch()) |
|
2212 | b = encoding.tolocal(ctx.branch()) | |
2211 | if b != 'default': |
|
2213 | if b != 'default': | |
2212 | output.append("(%s)" % b) |
|
2214 | output.append("(%s)" % b) | |
2213 |
|
2215 | |||
2214 | # multiple tags for a single parent separated by '/' |
|
2216 | # multiple tags for a single parent separated by '/' | |
2215 | t = "/".join(ctx.tags()) |
|
2217 | t = "/".join(ctx.tags()) | |
2216 | if t: |
|
2218 | if t: | |
2217 | output.append(t) |
|
2219 | output.append(t) | |
2218 |
|
2220 | |||
2219 | if branch: |
|
2221 | if branch: | |
2220 | output.append(encoding.tolocal(ctx.branch())) |
|
2222 | output.append(encoding.tolocal(ctx.branch())) | |
2221 |
|
2223 | |||
2222 | if tags: |
|
2224 | if tags: | |
2223 | output.extend(ctx.tags()) |
|
2225 | output.extend(ctx.tags()) | |
2224 |
|
2226 | |||
2225 | ui.write("%s\n" % ' '.join(output)) |
|
2227 | ui.write("%s\n" % ' '.join(output)) | |
2226 |
|
2228 | |||
2227 | def import_(ui, repo, patch1, *patches, **opts): |
|
2229 | def import_(ui, repo, patch1, *patches, **opts): | |
2228 | """import an ordered set of patches |
|
2230 | """import an ordered set of patches | |
2229 |
|
2231 | |||
2230 | Import a list of patches and commit them individually (unless |
|
2232 | Import a list of patches and commit them individually (unless | |
2231 | --no-commit is specified). |
|
2233 | --no-commit is specified). | |
2232 |
|
2234 | |||
2233 | If there are outstanding changes in the working directory, import |
|
2235 | If there are outstanding changes in the working directory, import | |
2234 | will abort unless given the -f/--force flag. |
|
2236 | will abort unless given the -f/--force flag. | |
2235 |
|
2237 | |||
2236 | You can import a patch straight from a mail message. Even patches |
|
2238 | You can import a patch straight from a mail message. Even patches | |
2237 | as attachments work (to use the body part, it must have type |
|
2239 | as attachments work (to use the body part, it must have type | |
2238 | text/plain or text/x-patch). From and Subject headers of email |
|
2240 | text/plain or text/x-patch). From and Subject headers of email | |
2239 | message are used as default committer and commit message. All |
|
2241 | message are used as default committer and commit message. All | |
2240 | text/plain body parts before first diff are added to commit |
|
2242 | text/plain body parts before first diff are added to commit | |
2241 | message. |
|
2243 | message. | |
2242 |
|
2244 | |||
2243 | If the imported patch was generated by :hg:`export`, user and |
|
2245 | If the imported patch was generated by :hg:`export`, user and | |
2244 | description from patch override values from message headers and |
|
2246 | description from patch override values from message headers and | |
2245 | body. Values given on command line with -m/--message and -u/--user |
|
2247 | body. Values given on command line with -m/--message and -u/--user | |
2246 | override these. |
|
2248 | override these. | |
2247 |
|
2249 | |||
2248 | If --exact is specified, import will set the working directory to |
|
2250 | If --exact is specified, import will set the working directory to | |
2249 | the parent of each patch before applying it, and will abort if the |
|
2251 | the parent of each patch before applying it, and will abort if the | |
2250 | resulting changeset has a different ID than the one recorded in |
|
2252 | resulting changeset has a different ID than the one recorded in | |
2251 | the patch. This may happen due to character set problems or other |
|
2253 | the patch. This may happen due to character set problems or other | |
2252 | deficiencies in the text patch format. |
|
2254 | deficiencies in the text patch format. | |
2253 |
|
2255 | |||
2254 | With -s/--similarity, hg will attempt to discover renames and |
|
2256 | With -s/--similarity, hg will attempt to discover renames and | |
2255 | copies in the patch in the same way as 'addremove'. |
|
2257 | copies in the patch in the same way as 'addremove'. | |
2256 |
|
2258 | |||
2257 | To read a patch from standard input, use "-" as the patch name. If |
|
2259 | To read a patch from standard input, use "-" as the patch name. If | |
2258 | a URL is specified, the patch will be downloaded from it. |
|
2260 | a URL is specified, the patch will be downloaded from it. | |
2259 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
2261 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
2260 |
|
2262 | |||
2261 | Returns 0 on success. |
|
2263 | Returns 0 on success. | |
2262 | """ |
|
2264 | """ | |
2263 | patches = (patch1,) + patches |
|
2265 | patches = (patch1,) + patches | |
2264 |
|
2266 | |||
2265 | date = opts.get('date') |
|
2267 | date = opts.get('date') | |
2266 | if date: |
|
2268 | if date: | |
2267 | opts['date'] = util.parsedate(date) |
|
2269 | opts['date'] = util.parsedate(date) | |
2268 |
|
2270 | |||
2269 | try: |
|
2271 | try: | |
2270 | sim = float(opts.get('similarity') or 0) |
|
2272 | sim = float(opts.get('similarity') or 0) | |
2271 | except ValueError: |
|
2273 | except ValueError: | |
2272 | raise util.Abort(_('similarity must be a number')) |
|
2274 | raise util.Abort(_('similarity must be a number')) | |
2273 | if sim < 0 or sim > 100: |
|
2275 | if sim < 0 or sim > 100: | |
2274 | raise util.Abort(_('similarity must be between 0 and 100')) |
|
2276 | raise util.Abort(_('similarity must be between 0 and 100')) | |
2275 |
|
2277 | |||
2276 | if opts.get('exact') or not opts.get('force'): |
|
2278 | if opts.get('exact') or not opts.get('force'): | |
2277 | cmdutil.bail_if_changed(repo) |
|
2279 | cmdutil.bail_if_changed(repo) | |
2278 |
|
2280 | |||
2279 | d = opts["base"] |
|
2281 | d = opts["base"] | |
2280 | strip = opts["strip"] |
|
2282 | strip = opts["strip"] | |
2281 | wlock = lock = None |
|
2283 | wlock = lock = None | |
2282 | msgs = [] |
|
2284 | msgs = [] | |
2283 |
|
2285 | |||
2284 | def tryone(ui, hunk): |
|
2286 | def tryone(ui, hunk): | |
2285 | tmpname, message, user, date, branch, nodeid, p1, p2 = \ |
|
2287 | tmpname, message, user, date, branch, nodeid, p1, p2 = \ | |
2286 | patch.extract(ui, hunk) |
|
2288 | patch.extract(ui, hunk) | |
2287 |
|
2289 | |||
2288 | if not tmpname: |
|
2290 | if not tmpname: | |
2289 | return None |
|
2291 | return None | |
2290 | commitid = _('to working directory') |
|
2292 | commitid = _('to working directory') | |
2291 |
|
2293 | |||
2292 | try: |
|
2294 | try: | |
2293 | cmdline_message = cmdutil.logmessage(opts) |
|
2295 | cmdline_message = cmdutil.logmessage(opts) | |
2294 | if cmdline_message: |
|
2296 | if cmdline_message: | |
2295 | # pickup the cmdline msg |
|
2297 | # pickup the cmdline msg | |
2296 | message = cmdline_message |
|
2298 | message = cmdline_message | |
2297 | elif message: |
|
2299 | elif message: | |
2298 | # pickup the patch msg |
|
2300 | # pickup the patch msg | |
2299 | message = message.strip() |
|
2301 | message = message.strip() | |
2300 | else: |
|
2302 | else: | |
2301 | # launch the editor |
|
2303 | # launch the editor | |
2302 | message = None |
|
2304 | message = None | |
2303 | ui.debug('message:\n%s\n' % message) |
|
2305 | ui.debug('message:\n%s\n' % message) | |
2304 |
|
2306 | |||
2305 | wp = repo.parents() |
|
2307 | wp = repo.parents() | |
2306 | if opts.get('exact'): |
|
2308 | if opts.get('exact'): | |
2307 | if not nodeid or not p1: |
|
2309 | if not nodeid or not p1: | |
2308 | raise util.Abort(_('not a Mercurial patch')) |
|
2310 | raise util.Abort(_('not a Mercurial patch')) | |
2309 | p1 = repo.lookup(p1) |
|
2311 | p1 = repo.lookup(p1) | |
2310 | p2 = repo.lookup(p2 or hex(nullid)) |
|
2312 | p2 = repo.lookup(p2 or hex(nullid)) | |
2311 |
|
2313 | |||
2312 | if p1 != wp[0].node(): |
|
2314 | if p1 != wp[0].node(): | |
2313 | hg.clean(repo, p1) |
|
2315 | hg.clean(repo, p1) | |
2314 | repo.dirstate.setparents(p1, p2) |
|
2316 | repo.dirstate.setparents(p1, p2) | |
2315 | elif p2: |
|
2317 | elif p2: | |
2316 | try: |
|
2318 | try: | |
2317 | p1 = repo.lookup(p1) |
|
2319 | p1 = repo.lookup(p1) | |
2318 | p2 = repo.lookup(p2) |
|
2320 | p2 = repo.lookup(p2) | |
2319 | if p1 == wp[0].node(): |
|
2321 | if p1 == wp[0].node(): | |
2320 | repo.dirstate.setparents(p1, p2) |
|
2322 | repo.dirstate.setparents(p1, p2) | |
2321 | except error.RepoError: |
|
2323 | except error.RepoError: | |
2322 | pass |
|
2324 | pass | |
2323 | if opts.get('exact') or opts.get('import_branch'): |
|
2325 | if opts.get('exact') or opts.get('import_branch'): | |
2324 | repo.dirstate.setbranch(branch or 'default') |
|
2326 | repo.dirstate.setbranch(branch or 'default') | |
2325 |
|
2327 | |||
2326 | files = {} |
|
2328 | files = {} | |
2327 | try: |
|
2329 | try: | |
2328 | patch.patch(tmpname, ui, strip=strip, cwd=repo.root, |
|
2330 | patch.patch(tmpname, ui, strip=strip, cwd=repo.root, | |
2329 | files=files, eolmode=None) |
|
2331 | files=files, eolmode=None) | |
2330 | finally: |
|
2332 | finally: | |
2331 | files = cmdutil.updatedir(ui, repo, files, |
|
2333 | files = cmdutil.updatedir(ui, repo, files, | |
2332 | similarity=sim / 100.0) |
|
2334 | similarity=sim / 100.0) | |
2333 | if opts.get('no_commit'): |
|
2335 | if opts.get('no_commit'): | |
2334 | if message: |
|
2336 | if message: | |
2335 | msgs.append(message) |
|
2337 | msgs.append(message) | |
2336 | else: |
|
2338 | else: | |
2337 | if opts.get('exact'): |
|
2339 | if opts.get('exact'): | |
2338 | m = None |
|
2340 | m = None | |
2339 | else: |
|
2341 | else: | |
2340 | m = cmdutil.matchfiles(repo, files or []) |
|
2342 | m = cmdutil.matchfiles(repo, files or []) | |
2341 | n = repo.commit(message, opts.get('user') or user, |
|
2343 | n = repo.commit(message, opts.get('user') or user, | |
2342 | opts.get('date') or date, match=m, |
|
2344 | opts.get('date') or date, match=m, | |
2343 | editor=cmdutil.commiteditor) |
|
2345 | editor=cmdutil.commiteditor) | |
2344 | if opts.get('exact'): |
|
2346 | if opts.get('exact'): | |
2345 | if hex(n) != nodeid: |
|
2347 | if hex(n) != nodeid: | |
2346 | repo.rollback() |
|
2348 | repo.rollback() | |
2347 | raise util.Abort(_('patch is damaged' |
|
2349 | raise util.Abort(_('patch is damaged' | |
2348 | ' or loses information')) |
|
2350 | ' or loses information')) | |
2349 | # Force a dirstate write so that the next transaction |
|
2351 | # Force a dirstate write so that the next transaction | |
2350 | # backups an up-do-date file. |
|
2352 | # backups an up-do-date file. | |
2351 | repo.dirstate.write() |
|
2353 | repo.dirstate.write() | |
2352 | if n: |
|
2354 | if n: | |
2353 | commitid = short(n) |
|
2355 | commitid = short(n) | |
2354 |
|
2356 | |||
2355 | return commitid |
|
2357 | return commitid | |
2356 | finally: |
|
2358 | finally: | |
2357 | os.unlink(tmpname) |
|
2359 | os.unlink(tmpname) | |
2358 |
|
2360 | |||
2359 | try: |
|
2361 | try: | |
2360 | wlock = repo.wlock() |
|
2362 | wlock = repo.wlock() | |
2361 | lock = repo.lock() |
|
2363 | lock = repo.lock() | |
2362 | lastcommit = None |
|
2364 | lastcommit = None | |
2363 | for p in patches: |
|
2365 | for p in patches: | |
2364 | pf = os.path.join(d, p) |
|
2366 | pf = os.path.join(d, p) | |
2365 |
|
2367 | |||
2366 | if pf == '-': |
|
2368 | if pf == '-': | |
2367 | ui.status(_("applying patch from stdin\n")) |
|
2369 | ui.status(_("applying patch from stdin\n")) | |
2368 | pf = sys.stdin |
|
2370 | pf = sys.stdin | |
2369 | else: |
|
2371 | else: | |
2370 | ui.status(_("applying %s\n") % p) |
|
2372 | ui.status(_("applying %s\n") % p) | |
2371 | pf = url.open(ui, pf) |
|
2373 | pf = url.open(ui, pf) | |
2372 |
|
2374 | |||
2373 | haspatch = False |
|
2375 | haspatch = False | |
2374 | for hunk in patch.split(pf): |
|
2376 | for hunk in patch.split(pf): | |
2375 | commitid = tryone(ui, hunk) |
|
2377 | commitid = tryone(ui, hunk) | |
2376 | if commitid: |
|
2378 | if commitid: | |
2377 | haspatch = True |
|
2379 | haspatch = True | |
2378 | if lastcommit: |
|
2380 | if lastcommit: | |
2379 | ui.status(_('applied %s\n') % lastcommit) |
|
2381 | ui.status(_('applied %s\n') % lastcommit) | |
2380 | lastcommit = commitid |
|
2382 | lastcommit = commitid | |
2381 |
|
2383 | |||
2382 | if not haspatch: |
|
2384 | if not haspatch: | |
2383 | raise util.Abort(_('no diffs found')) |
|
2385 | raise util.Abort(_('no diffs found')) | |
2384 |
|
2386 | |||
2385 | if msgs: |
|
2387 | if msgs: | |
2386 | repo.opener('last-message.txt', 'wb').write('\n* * *\n'.join(msgs)) |
|
2388 | repo.opener('last-message.txt', 'wb').write('\n* * *\n'.join(msgs)) | |
2387 | finally: |
|
2389 | finally: | |
2388 | release(lock, wlock) |
|
2390 | release(lock, wlock) | |
2389 |
|
2391 | |||
2390 | def incoming(ui, repo, source="default", **opts): |
|
2392 | def incoming(ui, repo, source="default", **opts): | |
2391 | """show new changesets found in source |
|
2393 | """show new changesets found in source | |
2392 |
|
2394 | |||
2393 | Show new changesets found in the specified path/URL or the default |
|
2395 | Show new changesets found in the specified path/URL or the default | |
2394 | pull location. These are the changesets that would have been pulled |
|
2396 | pull location. These are the changesets that would have been pulled | |
2395 | if a pull at the time you issued this command. |
|
2397 | if a pull at the time you issued this command. | |
2396 |
|
2398 | |||
2397 | For remote repository, using --bundle avoids downloading the |
|
2399 | For remote repository, using --bundle avoids downloading the | |
2398 | changesets twice if the incoming is followed by a pull. |
|
2400 | changesets twice if the incoming is followed by a pull. | |
2399 |
|
2401 | |||
2400 | See pull for valid source format details. |
|
2402 | See pull for valid source format details. | |
2401 |
|
2403 | |||
2402 | Returns 0 if there are incoming changes, 1 otherwise. |
|
2404 | Returns 0 if there are incoming changes, 1 otherwise. | |
2403 | """ |
|
2405 | """ | |
2404 | if opts.get('bundle') and opts.get('subrepos'): |
|
2406 | if opts.get('bundle') and opts.get('subrepos'): | |
2405 | raise util.Abort(_('cannot combine --bundle and --subrepos')) |
|
2407 | raise util.Abort(_('cannot combine --bundle and --subrepos')) | |
2406 |
|
2408 | |||
2407 | ret = hg.incoming(ui, repo, source, opts) |
|
2409 | ret = hg.incoming(ui, repo, source, opts) | |
2408 | return ret |
|
2410 | return ret | |
2409 |
|
2411 | |||
2410 | def init(ui, dest=".", **opts): |
|
2412 | def init(ui, dest=".", **opts): | |
2411 | """create a new repository in the given directory |
|
2413 | """create a new repository in the given directory | |
2412 |
|
2414 | |||
2413 | Initialize a new repository in the given directory. If the given |
|
2415 | Initialize a new repository in the given directory. If the given | |
2414 | directory does not exist, it will be created. |
|
2416 | directory does not exist, it will be created. | |
2415 |
|
2417 | |||
2416 | If no directory is given, the current directory is used. |
|
2418 | If no directory is given, the current directory is used. | |
2417 |
|
2419 | |||
2418 | It is possible to specify an ``ssh://`` URL as the destination. |
|
2420 | It is possible to specify an ``ssh://`` URL as the destination. | |
2419 | See :hg:`help urls` for more information. |
|
2421 | See :hg:`help urls` for more information. | |
2420 |
|
2422 | |||
2421 | Returns 0 on success. |
|
2423 | Returns 0 on success. | |
2422 | """ |
|
2424 | """ | |
2423 | hg.repository(hg.remoteui(ui, opts), ui.expandpath(dest), create=1) |
|
2425 | hg.repository(hg.remoteui(ui, opts), ui.expandpath(dest), create=1) | |
2424 |
|
2426 | |||
2425 | def locate(ui, repo, *pats, **opts): |
|
2427 | def locate(ui, repo, *pats, **opts): | |
2426 | """locate files matching specific patterns |
|
2428 | """locate files matching specific patterns | |
2427 |
|
2429 | |||
2428 | Print files under Mercurial control in the working directory whose |
|
2430 | Print files under Mercurial control in the working directory whose | |
2429 | names match the given patterns. |
|
2431 | names match the given patterns. | |
2430 |
|
2432 | |||
2431 | By default, this command searches all directories in the working |
|
2433 | By default, this command searches all directories in the working | |
2432 | directory. To search just the current directory and its |
|
2434 | directory. To search just the current directory and its | |
2433 | subdirectories, use "--include .". |
|
2435 | subdirectories, use "--include .". | |
2434 |
|
2436 | |||
2435 | If no patterns are given to match, this command prints the names |
|
2437 | If no patterns are given to match, this command prints the names | |
2436 | of all files under Mercurial control in the working directory. |
|
2438 | of all files under Mercurial control in the working directory. | |
2437 |
|
2439 | |||
2438 | If you want to feed the output of this command into the "xargs" |
|
2440 | If you want to feed the output of this command into the "xargs" | |
2439 | command, use the -0 option to both this command and "xargs". This |
|
2441 | command, use the -0 option to both this command and "xargs". This | |
2440 | will avoid the problem of "xargs" treating single filenames that |
|
2442 | will avoid the problem of "xargs" treating single filenames that | |
2441 | contain whitespace as multiple filenames. |
|
2443 | contain whitespace as multiple filenames. | |
2442 |
|
2444 | |||
2443 | Returns 0 if a match is found, 1 otherwise. |
|
2445 | Returns 0 if a match is found, 1 otherwise. | |
2444 | """ |
|
2446 | """ | |
2445 | end = opts.get('print0') and '\0' or '\n' |
|
2447 | end = opts.get('print0') and '\0' or '\n' | |
2446 |
rev = opts.get('rev') |
|
2448 | rev = cmdutil.revsingle(repo, opts.get('rev'), None).node() | |
2447 |
|
2449 | |||
2448 | ret = 1 |
|
2450 | ret = 1 | |
2449 | m = cmdutil.match(repo, pats, opts, default='relglob') |
|
2451 | m = cmdutil.match(repo, pats, opts, default='relglob') | |
2450 | m.bad = lambda x, y: False |
|
2452 | m.bad = lambda x, y: False | |
2451 | for abs in repo[rev].walk(m): |
|
2453 | for abs in repo[rev].walk(m): | |
2452 | if not rev and abs not in repo.dirstate: |
|
2454 | if not rev and abs not in repo.dirstate: | |
2453 | continue |
|
2455 | continue | |
2454 | if opts.get('fullpath'): |
|
2456 | if opts.get('fullpath'): | |
2455 | ui.write(repo.wjoin(abs), end) |
|
2457 | ui.write(repo.wjoin(abs), end) | |
2456 | else: |
|
2458 | else: | |
2457 | ui.write(((pats and m.rel(abs)) or abs), end) |
|
2459 | ui.write(((pats and m.rel(abs)) or abs), end) | |
2458 | ret = 0 |
|
2460 | ret = 0 | |
2459 |
|
2461 | |||
2460 | return ret |
|
2462 | return ret | |
2461 |
|
2463 | |||
2462 | def log(ui, repo, *pats, **opts): |
|
2464 | def log(ui, repo, *pats, **opts): | |
2463 | """show revision history of entire repository or files |
|
2465 | """show revision history of entire repository or files | |
2464 |
|
2466 | |||
2465 | Print the revision history of the specified files or the entire |
|
2467 | Print the revision history of the specified files or the entire | |
2466 | project. |
|
2468 | project. | |
2467 |
|
2469 | |||
2468 | File history is shown without following rename or copy history of |
|
2470 | File history is shown without following rename or copy history of | |
2469 | files. Use -f/--follow with a filename to follow history across |
|
2471 | files. Use -f/--follow with a filename to follow history across | |
2470 | renames and copies. --follow without a filename will only show |
|
2472 | renames and copies. --follow without a filename will only show | |
2471 | ancestors or descendants of the starting revision. --follow-first |
|
2473 | ancestors or descendants of the starting revision. --follow-first | |
2472 | only follows the first parent of merge revisions. |
|
2474 | only follows the first parent of merge revisions. | |
2473 |
|
2475 | |||
2474 | If no revision range is specified, the default is ``tip:0`` unless |
|
2476 | If no revision range is specified, the default is ``tip:0`` unless | |
2475 | --follow is set, in which case the working directory parent is |
|
2477 | --follow is set, in which case the working directory parent is | |
2476 | used as the starting revision. You can specify a revision set for |
|
2478 | used as the starting revision. You can specify a revision set for | |
2477 | log, see :hg:`help revsets` for more information. |
|
2479 | log, see :hg:`help revsets` for more information. | |
2478 |
|
2480 | |||
2479 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
2481 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
2480 |
|
2482 | |||
2481 | By default this command prints revision number and changeset id, |
|
2483 | By default this command prints revision number and changeset id, | |
2482 | tags, non-trivial parents, user, date and time, and a summary for |
|
2484 | tags, non-trivial parents, user, date and time, and a summary for | |
2483 | each commit. When the -v/--verbose switch is used, the list of |
|
2485 | each commit. When the -v/--verbose switch is used, the list of | |
2484 | changed files and full commit message are shown. |
|
2486 | changed files and full commit message are shown. | |
2485 |
|
2487 | |||
2486 | .. note:: |
|
2488 | .. note:: | |
2487 | log -p/--patch may generate unexpected diff output for merge |
|
2489 | log -p/--patch may generate unexpected diff output for merge | |
2488 | changesets, as it will only compare the merge changeset against |
|
2490 | changesets, as it will only compare the merge changeset against | |
2489 | its first parent. Also, only files different from BOTH parents |
|
2491 | its first parent. Also, only files different from BOTH parents | |
2490 | will appear in files:. |
|
2492 | will appear in files:. | |
2491 |
|
2493 | |||
2492 | Returns 0 on success. |
|
2494 | Returns 0 on success. | |
2493 | """ |
|
2495 | """ | |
2494 |
|
2496 | |||
2495 | matchfn = cmdutil.match(repo, pats, opts) |
|
2497 | matchfn = cmdutil.match(repo, pats, opts) | |
2496 | limit = cmdutil.loglimit(opts) |
|
2498 | limit = cmdutil.loglimit(opts) | |
2497 | count = 0 |
|
2499 | count = 0 | |
2498 |
|
2500 | |||
2499 | endrev = None |
|
2501 | endrev = None | |
2500 | if opts.get('copies') and opts.get('rev'): |
|
2502 | if opts.get('copies') and opts.get('rev'): | |
2501 | endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1 |
|
2503 | endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1 | |
2502 |
|
2504 | |||
2503 | df = False |
|
2505 | df = False | |
2504 | if opts["date"]: |
|
2506 | if opts["date"]: | |
2505 | df = util.matchdate(opts["date"]) |
|
2507 | df = util.matchdate(opts["date"]) | |
2506 |
|
2508 | |||
2507 | branches = opts.get('branch', []) + opts.get('only_branch', []) |
|
2509 | branches = opts.get('branch', []) + opts.get('only_branch', []) | |
2508 | opts['branch'] = [repo.lookupbranch(b) for b in branches] |
|
2510 | opts['branch'] = [repo.lookupbranch(b) for b in branches] | |
2509 |
|
2511 | |||
2510 | displayer = cmdutil.show_changeset(ui, repo, opts, True) |
|
2512 | displayer = cmdutil.show_changeset(ui, repo, opts, True) | |
2511 | def prep(ctx, fns): |
|
2513 | def prep(ctx, fns): | |
2512 | rev = ctx.rev() |
|
2514 | rev = ctx.rev() | |
2513 | parents = [p for p in repo.changelog.parentrevs(rev) |
|
2515 | parents = [p for p in repo.changelog.parentrevs(rev) | |
2514 | if p != nullrev] |
|
2516 | if p != nullrev] | |
2515 | if opts.get('no_merges') and len(parents) == 2: |
|
2517 | if opts.get('no_merges') and len(parents) == 2: | |
2516 | return |
|
2518 | return | |
2517 | if opts.get('only_merges') and len(parents) != 2: |
|
2519 | if opts.get('only_merges') and len(parents) != 2: | |
2518 | return |
|
2520 | return | |
2519 | if opts.get('branch') and ctx.branch() not in opts['branch']: |
|
2521 | if opts.get('branch') and ctx.branch() not in opts['branch']: | |
2520 | return |
|
2522 | return | |
2521 | if df and not df(ctx.date()[0]): |
|
2523 | if df and not df(ctx.date()[0]): | |
2522 | return |
|
2524 | return | |
2523 | if opts['user'] and not [k for k in opts['user'] |
|
2525 | if opts['user'] and not [k for k in opts['user'] | |
2524 | if k.lower() in ctx.user().lower()]: |
|
2526 | if k.lower() in ctx.user().lower()]: | |
2525 | return |
|
2527 | return | |
2526 | if opts.get('keyword'): |
|
2528 | if opts.get('keyword'): | |
2527 | for k in [kw.lower() for kw in opts['keyword']]: |
|
2529 | for k in [kw.lower() for kw in opts['keyword']]: | |
2528 | if (k in ctx.user().lower() or |
|
2530 | if (k in ctx.user().lower() or | |
2529 | k in ctx.description().lower() or |
|
2531 | k in ctx.description().lower() or | |
2530 | k in " ".join(ctx.files()).lower()): |
|
2532 | k in " ".join(ctx.files()).lower()): | |
2531 | break |
|
2533 | break | |
2532 | else: |
|
2534 | else: | |
2533 | return |
|
2535 | return | |
2534 |
|
2536 | |||
2535 | copies = None |
|
2537 | copies = None | |
2536 | if opts.get('copies') and rev: |
|
2538 | if opts.get('copies') and rev: | |
2537 | copies = [] |
|
2539 | copies = [] | |
2538 | getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) |
|
2540 | getrenamed = templatekw.getrenamedfn(repo, endrev=endrev) | |
2539 | for fn in ctx.files(): |
|
2541 | for fn in ctx.files(): | |
2540 | rename = getrenamed(fn, rev) |
|
2542 | rename = getrenamed(fn, rev) | |
2541 | if rename: |
|
2543 | if rename: | |
2542 | copies.append((fn, rename[0])) |
|
2544 | copies.append((fn, rename[0])) | |
2543 |
|
2545 | |||
2544 | revmatchfn = None |
|
2546 | revmatchfn = None | |
2545 | if opts.get('patch') or opts.get('stat'): |
|
2547 | if opts.get('patch') or opts.get('stat'): | |
2546 | if opts.get('follow') or opts.get('follow_first'): |
|
2548 | if opts.get('follow') or opts.get('follow_first'): | |
2547 | # note: this might be wrong when following through merges |
|
2549 | # note: this might be wrong when following through merges | |
2548 | revmatchfn = cmdutil.match(repo, fns, default='path') |
|
2550 | revmatchfn = cmdutil.match(repo, fns, default='path') | |
2549 | else: |
|
2551 | else: | |
2550 | revmatchfn = matchfn |
|
2552 | revmatchfn = matchfn | |
2551 |
|
2553 | |||
2552 | displayer.show(ctx, copies=copies, matchfn=revmatchfn) |
|
2554 | displayer.show(ctx, copies=copies, matchfn=revmatchfn) | |
2553 |
|
2555 | |||
2554 | for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): |
|
2556 | for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): | |
2555 | if count == limit: |
|
2557 | if count == limit: | |
2556 | break |
|
2558 | break | |
2557 | if displayer.flush(ctx.rev()): |
|
2559 | if displayer.flush(ctx.rev()): | |
2558 | count += 1 |
|
2560 | count += 1 | |
2559 | displayer.close() |
|
2561 | displayer.close() | |
2560 |
|
2562 | |||
2561 | def manifest(ui, repo, node=None, rev=None): |
|
2563 | def manifest(ui, repo, node=None, rev=None): | |
2562 | """output the current or given revision of the project manifest |
|
2564 | """output the current or given revision of the project manifest | |
2563 |
|
2565 | |||
2564 | Print a list of version controlled files for the given revision. |
|
2566 | Print a list of version controlled files for the given revision. | |
2565 | If no revision is given, the first parent of the working directory |
|
2567 | If no revision is given, the first parent of the working directory | |
2566 | is used, or the null revision if no revision is checked out. |
|
2568 | is used, or the null revision if no revision is checked out. | |
2567 |
|
2569 | |||
2568 | With -v, print file permissions, symlink and executable bits. |
|
2570 | With -v, print file permissions, symlink and executable bits. | |
2569 | With --debug, print file revision hashes. |
|
2571 | With --debug, print file revision hashes. | |
2570 |
|
2572 | |||
2571 | Returns 0 on success. |
|
2573 | Returns 0 on success. | |
2572 | """ |
|
2574 | """ | |
2573 |
|
2575 | |||
2574 | if rev and node: |
|
2576 | if rev and node: | |
2575 | raise util.Abort(_("please specify just one revision")) |
|
2577 | raise util.Abort(_("please specify just one revision")) | |
2576 |
|
2578 | |||
2577 | if not node: |
|
2579 | if not node: | |
2578 | node = rev |
|
2580 | node = rev | |
2579 |
|
2581 | |||
2580 | decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '} |
|
2582 | decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '} | |
2581 |
ctx = repo |
|
2583 | ctx = cmdutil.revsingle(repo, node) | |
2582 | for f in ctx: |
|
2584 | for f in ctx: | |
2583 | if ui.debugflag: |
|
2585 | if ui.debugflag: | |
2584 | ui.write("%40s " % hex(ctx.manifest()[f])) |
|
2586 | ui.write("%40s " % hex(ctx.manifest()[f])) | |
2585 | if ui.verbose: |
|
2587 | if ui.verbose: | |
2586 | ui.write(decor[ctx.flags(f)]) |
|
2588 | ui.write(decor[ctx.flags(f)]) | |
2587 | ui.write("%s\n" % f) |
|
2589 | ui.write("%s\n" % f) | |
2588 |
|
2590 | |||
2589 | def merge(ui, repo, node=None, **opts): |
|
2591 | def merge(ui, repo, node=None, **opts): | |
2590 | """merge working directory with another revision |
|
2592 | """merge working directory with another revision | |
2591 |
|
2593 | |||
2592 | The current working directory is updated with all changes made in |
|
2594 | The current working directory is updated with all changes made in | |
2593 | the requested revision since the last common predecessor revision. |
|
2595 | the requested revision since the last common predecessor revision. | |
2594 |
|
2596 | |||
2595 | Files that changed between either parent are marked as changed for |
|
2597 | Files that changed between either parent are marked as changed for | |
2596 | the next commit and a commit must be performed before any further |
|
2598 | the next commit and a commit must be performed before any further | |
2597 | updates to the repository are allowed. The next commit will have |
|
2599 | updates to the repository are allowed. The next commit will have | |
2598 | two parents. |
|
2600 | two parents. | |
2599 |
|
2601 | |||
2600 | ``--tool`` can be used to specify the merge tool used for file |
|
2602 | ``--tool`` can be used to specify the merge tool used for file | |
2601 | merges. It overrides the HGMERGE environment variable and your |
|
2603 | merges. It overrides the HGMERGE environment variable and your | |
2602 | configuration files. |
|
2604 | configuration files. | |
2603 |
|
2605 | |||
2604 | If no revision is specified, the working directory's parent is a |
|
2606 | If no revision is specified, the working directory's parent is a | |
2605 | head revision, and the current branch contains exactly one other |
|
2607 | head revision, and the current branch contains exactly one other | |
2606 | head, the other head is merged with by default. Otherwise, an |
|
2608 | head, the other head is merged with by default. Otherwise, an | |
2607 | explicit revision with which to merge with must be provided. |
|
2609 | explicit revision with which to merge with must be provided. | |
2608 |
|
2610 | |||
2609 | :hg:`resolve` must be used to resolve unresolved files. |
|
2611 | :hg:`resolve` must be used to resolve unresolved files. | |
2610 |
|
2612 | |||
2611 | To undo an uncommitted merge, use :hg:`update --clean .` which |
|
2613 | To undo an uncommitted merge, use :hg:`update --clean .` which | |
2612 | will check out a clean copy of the original merge parent, losing |
|
2614 | will check out a clean copy of the original merge parent, losing | |
2613 | all changes. |
|
2615 | all changes. | |
2614 |
|
2616 | |||
2615 | Returns 0 on success, 1 if there are unresolved files. |
|
2617 | Returns 0 on success, 1 if there are unresolved files. | |
2616 | """ |
|
2618 | """ | |
2617 |
|
2619 | |||
2618 | if opts.get('rev') and node: |
|
2620 | if opts.get('rev') and node: | |
2619 | raise util.Abort(_("please specify just one revision")) |
|
2621 | raise util.Abort(_("please specify just one revision")) | |
2620 | if not node: |
|
2622 | if not node: | |
2621 | node = opts.get('rev') |
|
2623 | node = opts.get('rev') | |
2622 |
|
2624 | |||
2623 | if not node: |
|
2625 | if not node: | |
2624 | branch = repo.changectx(None).branch() |
|
2626 | branch = repo.changectx(None).branch() | |
2625 | bheads = repo.branchheads(branch) |
|
2627 | bheads = repo.branchheads(branch) | |
2626 | if len(bheads) > 2: |
|
2628 | if len(bheads) > 2: | |
2627 | raise util.Abort(_( |
|
2629 | raise util.Abort(_( | |
2628 | 'branch \'%s\' has %d heads - ' |
|
2630 | 'branch \'%s\' has %d heads - ' | |
2629 | 'please merge with an explicit rev\n' |
|
2631 | 'please merge with an explicit rev\n' | |
2630 | '(run \'hg heads .\' to see heads)') |
|
2632 | '(run \'hg heads .\' to see heads)') | |
2631 | % (branch, len(bheads))) |
|
2633 | % (branch, len(bheads))) | |
2632 |
|
2634 | |||
2633 | parent = repo.dirstate.parents()[0] |
|
2635 | parent = repo.dirstate.parents()[0] | |
2634 | if len(bheads) == 1: |
|
2636 | if len(bheads) == 1: | |
2635 | if len(repo.heads()) > 1: |
|
2637 | if len(repo.heads()) > 1: | |
2636 | raise util.Abort(_( |
|
2638 | raise util.Abort(_( | |
2637 | 'branch \'%s\' has one head - ' |
|
2639 | 'branch \'%s\' has one head - ' | |
2638 | 'please merge with an explicit rev\n' |
|
2640 | 'please merge with an explicit rev\n' | |
2639 | '(run \'hg heads\' to see all heads)') |
|
2641 | '(run \'hg heads\' to see all heads)') | |
2640 | % branch) |
|
2642 | % branch) | |
2641 | msg = _('there is nothing to merge') |
|
2643 | msg = _('there is nothing to merge') | |
2642 | if parent != repo.lookup(repo[None].branch()): |
|
2644 | if parent != repo.lookup(repo[None].branch()): | |
2643 | msg = _('%s - use "hg update" instead') % msg |
|
2645 | msg = _('%s - use "hg update" instead') % msg | |
2644 | raise util.Abort(msg) |
|
2646 | raise util.Abort(msg) | |
2645 |
|
2647 | |||
2646 | if parent not in bheads: |
|
2648 | if parent not in bheads: | |
2647 | raise util.Abort(_('working dir not at a head rev - ' |
|
2649 | raise util.Abort(_('working dir not at a head rev - ' | |
2648 | 'use "hg update" or merge with an explicit rev')) |
|
2650 | 'use "hg update" or merge with an explicit rev')) | |
2649 | node = parent == bheads[0] and bheads[-1] or bheads[0] |
|
2651 | node = parent == bheads[0] and bheads[-1] or bheads[0] | |
|
2652 | else: | |||
|
2653 | node = cmdutil.revsingle(repo, node).node() | |||
2650 |
|
2654 | |||
2651 | if opts.get('preview'): |
|
2655 | if opts.get('preview'): | |
2652 | # find nodes that are ancestors of p2 but not of p1 |
|
2656 | # find nodes that are ancestors of p2 but not of p1 | |
2653 | p1 = repo.lookup('.') |
|
2657 | p1 = repo.lookup('.') | |
2654 | p2 = repo.lookup(node) |
|
2658 | p2 = repo.lookup(node) | |
2655 | nodes = repo.changelog.findmissing(common=[p1], heads=[p2]) |
|
2659 | nodes = repo.changelog.findmissing(common=[p1], heads=[p2]) | |
2656 |
|
2660 | |||
2657 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
2661 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
2658 | for node in nodes: |
|
2662 | for node in nodes: | |
2659 | displayer.show(repo[node]) |
|
2663 | displayer.show(repo[node]) | |
2660 | displayer.close() |
|
2664 | displayer.close() | |
2661 | return 0 |
|
2665 | return 0 | |
2662 |
|
2666 | |||
2663 | try: |
|
2667 | try: | |
2664 | # ui.forcemerge is an internal variable, do not document |
|
2668 | # ui.forcemerge is an internal variable, do not document | |
2665 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
|
2669 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) | |
2666 | return hg.merge(repo, node, force=opts.get('force')) |
|
2670 | return hg.merge(repo, node, force=opts.get('force')) | |
2667 | finally: |
|
2671 | finally: | |
2668 | ui.setconfig('ui', 'forcemerge', '') |
|
2672 | ui.setconfig('ui', 'forcemerge', '') | |
2669 |
|
2673 | |||
2670 | def outgoing(ui, repo, dest=None, **opts): |
|
2674 | def outgoing(ui, repo, dest=None, **opts): | |
2671 | """show changesets not found in the destination |
|
2675 | """show changesets not found in the destination | |
2672 |
|
2676 | |||
2673 | Show changesets not found in the specified destination repository |
|
2677 | Show changesets not found in the specified destination repository | |
2674 | or the default push location. These are the changesets that would |
|
2678 | or the default push location. These are the changesets that would | |
2675 | be pushed if a push was requested. |
|
2679 | be pushed if a push was requested. | |
2676 |
|
2680 | |||
2677 | See pull for details of valid destination formats. |
|
2681 | See pull for details of valid destination formats. | |
2678 |
|
2682 | |||
2679 | Returns 0 if there are outgoing changes, 1 otherwise. |
|
2683 | Returns 0 if there are outgoing changes, 1 otherwise. | |
2680 | """ |
|
2684 | """ | |
2681 | ret = hg.outgoing(ui, repo, dest, opts) |
|
2685 | ret = hg.outgoing(ui, repo, dest, opts) | |
2682 | return ret |
|
2686 | return ret | |
2683 |
|
2687 | |||
2684 | def parents(ui, repo, file_=None, **opts): |
|
2688 | def parents(ui, repo, file_=None, **opts): | |
2685 | """show the parents of the working directory or revision |
|
2689 | """show the parents of the working directory or revision | |
2686 |
|
2690 | |||
2687 | Print the working directory's parent revisions. If a revision is |
|
2691 | Print the working directory's parent revisions. If a revision is | |
2688 | given via -r/--rev, the parent of that revision will be printed. |
|
2692 | given via -r/--rev, the parent of that revision will be printed. | |
2689 | If a file argument is given, the revision in which the file was |
|
2693 | If a file argument is given, the revision in which the file was | |
2690 | last changed (before the working directory revision or the |
|
2694 | last changed (before the working directory revision or the | |
2691 | argument to --rev if given) is printed. |
|
2695 | argument to --rev if given) is printed. | |
2692 |
|
2696 | |||
2693 | Returns 0 on success. |
|
2697 | Returns 0 on success. | |
2694 | """ |
|
2698 | """ | |
2695 | rev = opts.get('rev') |
|
2699 | ||
2696 | if rev: |
|
2700 | ctx = cmdutil.revsingle(repo, opts.get('rev'), None) | |
2697 | ctx = repo[rev] |
|
|||
2698 | else: |
|
|||
2699 | ctx = repo[None] |
|
|||
2700 |
|
2701 | |||
2701 | if file_: |
|
2702 | if file_: | |
2702 | m = cmdutil.match(repo, (file_,), opts) |
|
2703 | m = cmdutil.match(repo, (file_,), opts) | |
2703 | if m.anypats() or len(m.files()) != 1: |
|
2704 | if m.anypats() or len(m.files()) != 1: | |
2704 | raise util.Abort(_('can only specify an explicit filename')) |
|
2705 | raise util.Abort(_('can only specify an explicit filename')) | |
2705 | file_ = m.files()[0] |
|
2706 | file_ = m.files()[0] | |
2706 | filenodes = [] |
|
2707 | filenodes = [] | |
2707 | for cp in ctx.parents(): |
|
2708 | for cp in ctx.parents(): | |
2708 | if not cp: |
|
2709 | if not cp: | |
2709 | continue |
|
2710 | continue | |
2710 | try: |
|
2711 | try: | |
2711 | filenodes.append(cp.filenode(file_)) |
|
2712 | filenodes.append(cp.filenode(file_)) | |
2712 | except error.LookupError: |
|
2713 | except error.LookupError: | |
2713 | pass |
|
2714 | pass | |
2714 | if not filenodes: |
|
2715 | if not filenodes: | |
2715 | raise util.Abort(_("'%s' not found in manifest!") % file_) |
|
2716 | raise util.Abort(_("'%s' not found in manifest!") % file_) | |
2716 | fl = repo.file(file_) |
|
2717 | fl = repo.file(file_) | |
2717 | p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes] |
|
2718 | p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes] | |
2718 | else: |
|
2719 | else: | |
2719 | p = [cp.node() for cp in ctx.parents()] |
|
2720 | p = [cp.node() for cp in ctx.parents()] | |
2720 |
|
2721 | |||
2721 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
2722 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
2722 | for n in p: |
|
2723 | for n in p: | |
2723 | if n != nullid: |
|
2724 | if n != nullid: | |
2724 | displayer.show(repo[n]) |
|
2725 | displayer.show(repo[n]) | |
2725 | displayer.close() |
|
2726 | displayer.close() | |
2726 |
|
2727 | |||
2727 | def paths(ui, repo, search=None): |
|
2728 | def paths(ui, repo, search=None): | |
2728 | """show aliases for remote repositories |
|
2729 | """show aliases for remote repositories | |
2729 |
|
2730 | |||
2730 | Show definition of symbolic path name NAME. If no name is given, |
|
2731 | Show definition of symbolic path name NAME. If no name is given, | |
2731 | show definition of all available names. |
|
2732 | show definition of all available names. | |
2732 |
|
2733 | |||
2733 | Path names are defined in the [paths] section of your |
|
2734 | Path names are defined in the [paths] section of your | |
2734 | configuration file and in ``/etc/mercurial/hgrc``. If run inside a |
|
2735 | configuration file and in ``/etc/mercurial/hgrc``. If run inside a | |
2735 | repository, ``.hg/hgrc`` is used, too. |
|
2736 | repository, ``.hg/hgrc`` is used, too. | |
2736 |
|
2737 | |||
2737 | The path names ``default`` and ``default-push`` have a special |
|
2738 | The path names ``default`` and ``default-push`` have a special | |
2738 | meaning. When performing a push or pull operation, they are used |
|
2739 | meaning. When performing a push or pull operation, they are used | |
2739 | as fallbacks if no location is specified on the command-line. |
|
2740 | as fallbacks if no location is specified on the command-line. | |
2740 | When ``default-push`` is set, it will be used for push and |
|
2741 | When ``default-push`` is set, it will be used for push and | |
2741 | ``default`` will be used for pull; otherwise ``default`` is used |
|
2742 | ``default`` will be used for pull; otherwise ``default`` is used | |
2742 | as the fallback for both. When cloning a repository, the clone |
|
2743 | as the fallback for both. When cloning a repository, the clone | |
2743 | source is written as ``default`` in ``.hg/hgrc``. Note that |
|
2744 | source is written as ``default`` in ``.hg/hgrc``. Note that | |
2744 | ``default`` and ``default-push`` apply to all inbound (e.g. |
|
2745 | ``default`` and ``default-push`` apply to all inbound (e.g. | |
2745 | :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and |
|
2746 | :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and | |
2746 | :hg:`bundle`) operations. |
|
2747 | :hg:`bundle`) operations. | |
2747 |
|
2748 | |||
2748 | See :hg:`help urls` for more information. |
|
2749 | See :hg:`help urls` for more information. | |
2749 |
|
2750 | |||
2750 | Returns 0 on success. |
|
2751 | Returns 0 on success. | |
2751 | """ |
|
2752 | """ | |
2752 | if search: |
|
2753 | if search: | |
2753 | for name, path in ui.configitems("paths"): |
|
2754 | for name, path in ui.configitems("paths"): | |
2754 | if name == search: |
|
2755 | if name == search: | |
2755 | ui.write("%s\n" % url.hidepassword(path)) |
|
2756 | ui.write("%s\n" % url.hidepassword(path)) | |
2756 | return |
|
2757 | return | |
2757 | ui.warn(_("not found!\n")) |
|
2758 | ui.warn(_("not found!\n")) | |
2758 | return 1 |
|
2759 | return 1 | |
2759 | else: |
|
2760 | else: | |
2760 | for name, path in ui.configitems("paths"): |
|
2761 | for name, path in ui.configitems("paths"): | |
2761 | ui.write("%s = %s\n" % (name, url.hidepassword(path))) |
|
2762 | ui.write("%s = %s\n" % (name, url.hidepassword(path))) | |
2762 |
|
2763 | |||
2763 | def postincoming(ui, repo, modheads, optupdate, checkout): |
|
2764 | def postincoming(ui, repo, modheads, optupdate, checkout): | |
2764 | if modheads == 0: |
|
2765 | if modheads == 0: | |
2765 | return |
|
2766 | return | |
2766 | if optupdate: |
|
2767 | if optupdate: | |
2767 | if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout: |
|
2768 | if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout: | |
2768 | return hg.update(repo, checkout) |
|
2769 | return hg.update(repo, checkout) | |
2769 | else: |
|
2770 | else: | |
2770 | ui.status(_("not updating, since new heads added\n")) |
|
2771 | ui.status(_("not updating, since new heads added\n")) | |
2771 | if modheads > 1: |
|
2772 | if modheads > 1: | |
2772 | ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
|
2773 | ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) | |
2773 | else: |
|
2774 | else: | |
2774 | ui.status(_("(run 'hg update' to get a working copy)\n")) |
|
2775 | ui.status(_("(run 'hg update' to get a working copy)\n")) | |
2775 |
|
2776 | |||
2776 | def pull(ui, repo, source="default", **opts): |
|
2777 | def pull(ui, repo, source="default", **opts): | |
2777 | """pull changes from the specified source |
|
2778 | """pull changes from the specified source | |
2778 |
|
2779 | |||
2779 | Pull changes from a remote repository to a local one. |
|
2780 | Pull changes from a remote repository to a local one. | |
2780 |
|
2781 | |||
2781 | This finds all changes from the repository at the specified path |
|
2782 | This finds all changes from the repository at the specified path | |
2782 | or URL and adds them to a local repository (the current one unless |
|
2783 | or URL and adds them to a local repository (the current one unless | |
2783 | -R is specified). By default, this does not update the copy of the |
|
2784 | -R is specified). By default, this does not update the copy of the | |
2784 | project in the working directory. |
|
2785 | project in the working directory. | |
2785 |
|
2786 | |||
2786 | Use :hg:`incoming` if you want to see what would have been added |
|
2787 | Use :hg:`incoming` if you want to see what would have been added | |
2787 | by a pull at the time you issued this command. If you then decide |
|
2788 | by a pull at the time you issued this command. If you then decide | |
2788 | to add those changes to the repository, you should use :hg:`pull |
|
2789 | to add those changes to the repository, you should use :hg:`pull | |
2789 | -r X` where ``X`` is the last changeset listed by :hg:`incoming`. |
|
2790 | -r X` where ``X`` is the last changeset listed by :hg:`incoming`. | |
2790 |
|
2791 | |||
2791 | If SOURCE is omitted, the 'default' path will be used. |
|
2792 | If SOURCE is omitted, the 'default' path will be used. | |
2792 | See :hg:`help urls` for more information. |
|
2793 | See :hg:`help urls` for more information. | |
2793 |
|
2794 | |||
2794 | Returns 0 on success, 1 if an update had unresolved files. |
|
2795 | Returns 0 on success, 1 if an update had unresolved files. | |
2795 | """ |
|
2796 | """ | |
2796 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
|
2797 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
2797 | other = hg.repository(hg.remoteui(repo, opts), source) |
|
2798 | other = hg.repository(hg.remoteui(repo, opts), source) | |
2798 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) |
|
2799 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) | |
2799 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
2800 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
2800 | if revs: |
|
2801 | if revs: | |
2801 | try: |
|
2802 | try: | |
2802 | revs = [other.lookup(rev) for rev in revs] |
|
2803 | revs = [other.lookup(rev) for rev in revs] | |
2803 | except error.CapabilityError: |
|
2804 | except error.CapabilityError: | |
2804 | err = _("other repository doesn't support revision lookup, " |
|
2805 | err = _("other repository doesn't support revision lookup, " | |
2805 | "so a rev cannot be specified.") |
|
2806 | "so a rev cannot be specified.") | |
2806 | raise util.Abort(err) |
|
2807 | raise util.Abort(err) | |
2807 |
|
2808 | |||
2808 | modheads = repo.pull(other, heads=revs, force=opts.get('force')) |
|
2809 | modheads = repo.pull(other, heads=revs, force=opts.get('force')) | |
2809 | if checkout: |
|
2810 | if checkout: | |
2810 | checkout = str(repo.changelog.rev(other.lookup(checkout))) |
|
2811 | checkout = str(repo.changelog.rev(other.lookup(checkout))) | |
2811 | repo._subtoppath = source |
|
2812 | repo._subtoppath = source | |
2812 | try: |
|
2813 | try: | |
2813 | return postincoming(ui, repo, modheads, opts.get('update'), checkout) |
|
2814 | return postincoming(ui, repo, modheads, opts.get('update'), checkout) | |
2814 | finally: |
|
2815 | finally: | |
2815 | del repo._subtoppath |
|
2816 | del repo._subtoppath | |
2816 |
|
2817 | |||
2817 | def push(ui, repo, dest=None, **opts): |
|
2818 | def push(ui, repo, dest=None, **opts): | |
2818 | """push changes to the specified destination |
|
2819 | """push changes to the specified destination | |
2819 |
|
2820 | |||
2820 | Push changesets from the local repository to the specified |
|
2821 | Push changesets from the local repository to the specified | |
2821 | destination. |
|
2822 | destination. | |
2822 |
|
2823 | |||
2823 | This operation is symmetrical to pull: it is identical to a pull |
|
2824 | This operation is symmetrical to pull: it is identical to a pull | |
2824 | in the destination repository from the current one. |
|
2825 | in the destination repository from the current one. | |
2825 |
|
2826 | |||
2826 | By default, push will not allow creation of new heads at the |
|
2827 | By default, push will not allow creation of new heads at the | |
2827 | destination, since multiple heads would make it unclear which head |
|
2828 | destination, since multiple heads would make it unclear which head | |
2828 | to use. In this situation, it is recommended to pull and merge |
|
2829 | to use. In this situation, it is recommended to pull and merge | |
2829 | before pushing. |
|
2830 | before pushing. | |
2830 |
|
2831 | |||
2831 | Use --new-branch if you want to allow push to create a new named |
|
2832 | Use --new-branch if you want to allow push to create a new named | |
2832 | branch that is not present at the destination. This allows you to |
|
2833 | branch that is not present at the destination. This allows you to | |
2833 | only create a new branch without forcing other changes. |
|
2834 | only create a new branch without forcing other changes. | |
2834 |
|
2835 | |||
2835 | Use -f/--force to override the default behavior and push all |
|
2836 | Use -f/--force to override the default behavior and push all | |
2836 | changesets on all branches. |
|
2837 | changesets on all branches. | |
2837 |
|
2838 | |||
2838 | If -r/--rev is used, the specified revision and all its ancestors |
|
2839 | If -r/--rev is used, the specified revision and all its ancestors | |
2839 | will be pushed to the remote repository. |
|
2840 | will be pushed to the remote repository. | |
2840 |
|
2841 | |||
2841 | Please see :hg:`help urls` for important details about ``ssh://`` |
|
2842 | Please see :hg:`help urls` for important details about ``ssh://`` | |
2842 | URLs. If DESTINATION is omitted, a default path will be used. |
|
2843 | URLs. If DESTINATION is omitted, a default path will be used. | |
2843 |
|
2844 | |||
2844 | Returns 0 if push was successful, 1 if nothing to push. |
|
2845 | Returns 0 if push was successful, 1 if nothing to push. | |
2845 | """ |
|
2846 | """ | |
2846 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
2847 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
2847 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
2848 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
2848 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
|
2849 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
2849 | other = hg.repository(hg.remoteui(repo, opts), dest) |
|
2850 | other = hg.repository(hg.remoteui(repo, opts), dest) | |
2850 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) |
|
2851 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) | |
2851 | if revs: |
|
2852 | if revs: | |
2852 | revs = [repo.lookup(rev) for rev in revs] |
|
2853 | revs = [repo.lookup(rev) for rev in revs] | |
2853 |
|
2854 | |||
2854 | repo._subtoppath = dest |
|
2855 | repo._subtoppath = dest | |
2855 | try: |
|
2856 | try: | |
2856 | # push subrepos depth-first for coherent ordering |
|
2857 | # push subrepos depth-first for coherent ordering | |
2857 | c = repo[''] |
|
2858 | c = repo[''] | |
2858 | subs = c.substate # only repos that are committed |
|
2859 | subs = c.substate # only repos that are committed | |
2859 | for s in sorted(subs): |
|
2860 | for s in sorted(subs): | |
2860 | if not c.sub(s).push(opts.get('force')): |
|
2861 | if not c.sub(s).push(opts.get('force')): | |
2861 | return False |
|
2862 | return False | |
2862 | finally: |
|
2863 | finally: | |
2863 | del repo._subtoppath |
|
2864 | del repo._subtoppath | |
2864 | r = repo.push(other, opts.get('force'), revs=revs, |
|
2865 | r = repo.push(other, opts.get('force'), revs=revs, | |
2865 | newbranch=opts.get('new_branch')) |
|
2866 | newbranch=opts.get('new_branch')) | |
2866 | return r == 0 |
|
2867 | return r == 0 | |
2867 |
|
2868 | |||
2868 | def recover(ui, repo): |
|
2869 | def recover(ui, repo): | |
2869 | """roll back an interrupted transaction |
|
2870 | """roll back an interrupted transaction | |
2870 |
|
2871 | |||
2871 | Recover from an interrupted commit or pull. |
|
2872 | Recover from an interrupted commit or pull. | |
2872 |
|
2873 | |||
2873 | This command tries to fix the repository status after an |
|
2874 | This command tries to fix the repository status after an | |
2874 | interrupted operation. It should only be necessary when Mercurial |
|
2875 | interrupted operation. It should only be necessary when Mercurial | |
2875 | suggests it. |
|
2876 | suggests it. | |
2876 |
|
2877 | |||
2877 | Returns 0 if successful, 1 if nothing to recover or verify fails. |
|
2878 | Returns 0 if successful, 1 if nothing to recover or verify fails. | |
2878 | """ |
|
2879 | """ | |
2879 | if repo.recover(): |
|
2880 | if repo.recover(): | |
2880 | return hg.verify(repo) |
|
2881 | return hg.verify(repo) | |
2881 | return 1 |
|
2882 | return 1 | |
2882 |
|
2883 | |||
2883 | def remove(ui, repo, *pats, **opts): |
|
2884 | def remove(ui, repo, *pats, **opts): | |
2884 | """remove the specified files on the next commit |
|
2885 | """remove the specified files on the next commit | |
2885 |
|
2886 | |||
2886 | Schedule the indicated files for removal from the repository. |
|
2887 | Schedule the indicated files for removal from the repository. | |
2887 |
|
2888 | |||
2888 | This only removes files from the current branch, not from the |
|
2889 | This only removes files from the current branch, not from the | |
2889 | entire project history. -A/--after can be used to remove only |
|
2890 | entire project history. -A/--after can be used to remove only | |
2890 | files that have already been deleted, -f/--force can be used to |
|
2891 | files that have already been deleted, -f/--force can be used to | |
2891 | force deletion, and -Af can be used to remove files from the next |
|
2892 | force deletion, and -Af can be used to remove files from the next | |
2892 | revision without deleting them from the working directory. |
|
2893 | revision without deleting them from the working directory. | |
2893 |
|
2894 | |||
2894 | The following table details the behavior of remove for different |
|
2895 | The following table details the behavior of remove for different | |
2895 | file states (columns) and option combinations (rows). The file |
|
2896 | file states (columns) and option combinations (rows). The file | |
2896 | states are Added [A], Clean [C], Modified [M] and Missing [!] (as |
|
2897 | states are Added [A], Clean [C], Modified [M] and Missing [!] (as | |
2897 | reported by :hg:`status`). The actions are Warn, Remove (from |
|
2898 | reported by :hg:`status`). The actions are Warn, Remove (from | |
2898 | branch) and Delete (from disk):: |
|
2899 | branch) and Delete (from disk):: | |
2899 |
|
2900 | |||
2900 | A C M ! |
|
2901 | A C M ! | |
2901 | none W RD W R |
|
2902 | none W RD W R | |
2902 | -f R RD RD R |
|
2903 | -f R RD RD R | |
2903 | -A W W W R |
|
2904 | -A W W W R | |
2904 | -Af R R R R |
|
2905 | -Af R R R R | |
2905 |
|
2906 | |||
2906 | This command schedules the files to be removed at the next commit. |
|
2907 | This command schedules the files to be removed at the next commit. | |
2907 | To undo a remove before that, see :hg:`revert`. |
|
2908 | To undo a remove before that, see :hg:`revert`. | |
2908 |
|
2909 | |||
2909 | Returns 0 on success, 1 if any warnings encountered. |
|
2910 | Returns 0 on success, 1 if any warnings encountered. | |
2910 | """ |
|
2911 | """ | |
2911 |
|
2912 | |||
2912 | ret = 0 |
|
2913 | ret = 0 | |
2913 | after, force = opts.get('after'), opts.get('force') |
|
2914 | after, force = opts.get('after'), opts.get('force') | |
2914 | if not pats and not after: |
|
2915 | if not pats and not after: | |
2915 | raise util.Abort(_('no files specified')) |
|
2916 | raise util.Abort(_('no files specified')) | |
2916 |
|
2917 | |||
2917 | m = cmdutil.match(repo, pats, opts) |
|
2918 | m = cmdutil.match(repo, pats, opts) | |
2918 | s = repo.status(match=m, clean=True) |
|
2919 | s = repo.status(match=m, clean=True) | |
2919 | modified, added, deleted, clean = s[0], s[1], s[3], s[6] |
|
2920 | modified, added, deleted, clean = s[0], s[1], s[3], s[6] | |
2920 |
|
2921 | |||
2921 | for f in m.files(): |
|
2922 | for f in m.files(): | |
2922 | if f not in repo.dirstate and not os.path.isdir(m.rel(f)): |
|
2923 | if f not in repo.dirstate and not os.path.isdir(m.rel(f)): | |
2923 | ui.warn(_('not removing %s: file is untracked\n') % m.rel(f)) |
|
2924 | ui.warn(_('not removing %s: file is untracked\n') % m.rel(f)) | |
2924 | ret = 1 |
|
2925 | ret = 1 | |
2925 |
|
2926 | |||
2926 | if force: |
|
2927 | if force: | |
2927 | remove, forget = modified + deleted + clean, added |
|
2928 | remove, forget = modified + deleted + clean, added | |
2928 | elif after: |
|
2929 | elif after: | |
2929 | remove, forget = deleted, [] |
|
2930 | remove, forget = deleted, [] | |
2930 | for f in modified + added + clean: |
|
2931 | for f in modified + added + clean: | |
2931 | ui.warn(_('not removing %s: file still exists (use -f' |
|
2932 | ui.warn(_('not removing %s: file still exists (use -f' | |
2932 | ' to force removal)\n') % m.rel(f)) |
|
2933 | ' to force removal)\n') % m.rel(f)) | |
2933 | ret = 1 |
|
2934 | ret = 1 | |
2934 | else: |
|
2935 | else: | |
2935 | remove, forget = deleted + clean, [] |
|
2936 | remove, forget = deleted + clean, [] | |
2936 | for f in modified: |
|
2937 | for f in modified: | |
2937 | ui.warn(_('not removing %s: file is modified (use -f' |
|
2938 | ui.warn(_('not removing %s: file is modified (use -f' | |
2938 | ' to force removal)\n') % m.rel(f)) |
|
2939 | ' to force removal)\n') % m.rel(f)) | |
2939 | ret = 1 |
|
2940 | ret = 1 | |
2940 | for f in added: |
|
2941 | for f in added: | |
2941 | ui.warn(_('not removing %s: file has been marked for add (use -f' |
|
2942 | ui.warn(_('not removing %s: file has been marked for add (use -f' | |
2942 | ' to force removal)\n') % m.rel(f)) |
|
2943 | ' to force removal)\n') % m.rel(f)) | |
2943 | ret = 1 |
|
2944 | ret = 1 | |
2944 |
|
2945 | |||
2945 | for f in sorted(remove + forget): |
|
2946 | for f in sorted(remove + forget): | |
2946 | if ui.verbose or not m.exact(f): |
|
2947 | if ui.verbose or not m.exact(f): | |
2947 | ui.status(_('removing %s\n') % m.rel(f)) |
|
2948 | ui.status(_('removing %s\n') % m.rel(f)) | |
2948 |
|
2949 | |||
2949 | repo[None].forget(forget) |
|
2950 | repo[None].forget(forget) | |
2950 | repo[None].remove(remove, unlink=not after) |
|
2951 | repo[None].remove(remove, unlink=not after) | |
2951 | return ret |
|
2952 | return ret | |
2952 |
|
2953 | |||
2953 | def rename(ui, repo, *pats, **opts): |
|
2954 | def rename(ui, repo, *pats, **opts): | |
2954 | """rename files; equivalent of copy + remove |
|
2955 | """rename files; equivalent of copy + remove | |
2955 |
|
2956 | |||
2956 | Mark dest as copies of sources; mark sources for deletion. If dest |
|
2957 | Mark dest as copies of sources; mark sources for deletion. If dest | |
2957 | is a directory, copies are put in that directory. If dest is a |
|
2958 | is a directory, copies are put in that directory. If dest is a | |
2958 | file, there can only be one source. |
|
2959 | file, there can only be one source. | |
2959 |
|
2960 | |||
2960 | By default, this command copies the contents of files as they |
|
2961 | By default, this command copies the contents of files as they | |
2961 | exist in the working directory. If invoked with -A/--after, the |
|
2962 | exist in the working directory. If invoked with -A/--after, the | |
2962 | operation is recorded, but no copying is performed. |
|
2963 | operation is recorded, but no copying is performed. | |
2963 |
|
2964 | |||
2964 | This command takes effect at the next commit. To undo a rename |
|
2965 | This command takes effect at the next commit. To undo a rename | |
2965 | before that, see :hg:`revert`. |
|
2966 | before that, see :hg:`revert`. | |
2966 |
|
2967 | |||
2967 | Returns 0 on success, 1 if errors are encountered. |
|
2968 | Returns 0 on success, 1 if errors are encountered. | |
2968 | """ |
|
2969 | """ | |
2969 | wlock = repo.wlock(False) |
|
2970 | wlock = repo.wlock(False) | |
2970 | try: |
|
2971 | try: | |
2971 | return cmdutil.copy(ui, repo, pats, opts, rename=True) |
|
2972 | return cmdutil.copy(ui, repo, pats, opts, rename=True) | |
2972 | finally: |
|
2973 | finally: | |
2973 | wlock.release() |
|
2974 | wlock.release() | |
2974 |
|
2975 | |||
2975 | def resolve(ui, repo, *pats, **opts): |
|
2976 | def resolve(ui, repo, *pats, **opts): | |
2976 | """redo merges or set/view the merge status of files |
|
2977 | """redo merges or set/view the merge status of files | |
2977 |
|
2978 | |||
2978 | Merges with unresolved conflicts are often the result of |
|
2979 | Merges with unresolved conflicts are often the result of | |
2979 | non-interactive merging using the ``internal:merge`` configuration |
|
2980 | non-interactive merging using the ``internal:merge`` configuration | |
2980 | setting, or a command-line merge tool like ``diff3``. The resolve |
|
2981 | setting, or a command-line merge tool like ``diff3``. The resolve | |
2981 | command is used to manage the files involved in a merge, after |
|
2982 | command is used to manage the files involved in a merge, after | |
2982 | :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the |
|
2983 | :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the | |
2983 | working directory must have two parents). |
|
2984 | working directory must have two parents). | |
2984 |
|
2985 | |||
2985 | The resolve command can be used in the following ways: |
|
2986 | The resolve command can be used in the following ways: | |
2986 |
|
2987 | |||
2987 | - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified |
|
2988 | - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified | |
2988 | files, discarding any previous merge attempts. Re-merging is not |
|
2989 | files, discarding any previous merge attempts. Re-merging is not | |
2989 | performed for files already marked as resolved. Use ``--all/-a`` |
|
2990 | performed for files already marked as resolved. Use ``--all/-a`` | |
2990 | to selects all unresolved files. ``--tool`` can be used to specify |
|
2991 | to selects all unresolved files. ``--tool`` can be used to specify | |
2991 | the merge tool used for the given files. It overrides the HGMERGE |
|
2992 | the merge tool used for the given files. It overrides the HGMERGE | |
2992 | environment variable and your configuration files. |
|
2993 | environment variable and your configuration files. | |
2993 |
|
2994 | |||
2994 | - :hg:`resolve -m [FILE]`: mark a file as having been resolved |
|
2995 | - :hg:`resolve -m [FILE]`: mark a file as having been resolved | |
2995 | (e.g. after having manually fixed-up the files). The default is |
|
2996 | (e.g. after having manually fixed-up the files). The default is | |
2996 | to mark all unresolved files. |
|
2997 | to mark all unresolved files. | |
2997 |
|
2998 | |||
2998 | - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The |
|
2999 | - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The | |
2999 | default is to mark all resolved files. |
|
3000 | default is to mark all resolved files. | |
3000 |
|
3001 | |||
3001 | - :hg:`resolve -l`: list files which had or still have conflicts. |
|
3002 | - :hg:`resolve -l`: list files which had or still have conflicts. | |
3002 | In the printed list, ``U`` = unresolved and ``R`` = resolved. |
|
3003 | In the printed list, ``U`` = unresolved and ``R`` = resolved. | |
3003 |
|
3004 | |||
3004 | Note that Mercurial will not let you commit files with unresolved |
|
3005 | Note that Mercurial will not let you commit files with unresolved | |
3005 | merge conflicts. You must use :hg:`resolve -m ...` before you can |
|
3006 | merge conflicts. You must use :hg:`resolve -m ...` before you can | |
3006 | commit after a conflicting merge. |
|
3007 | commit after a conflicting merge. | |
3007 |
|
3008 | |||
3008 | Returns 0 on success, 1 if any files fail a resolve attempt. |
|
3009 | Returns 0 on success, 1 if any files fail a resolve attempt. | |
3009 | """ |
|
3010 | """ | |
3010 |
|
3011 | |||
3011 | all, mark, unmark, show, nostatus = \ |
|
3012 | all, mark, unmark, show, nostatus = \ | |
3012 | [opts.get(o) for o in 'all mark unmark list no_status'.split()] |
|
3013 | [opts.get(o) for o in 'all mark unmark list no_status'.split()] | |
3013 |
|
3014 | |||
3014 | if (show and (mark or unmark)) or (mark and unmark): |
|
3015 | if (show and (mark or unmark)) or (mark and unmark): | |
3015 | raise util.Abort(_("too many options specified")) |
|
3016 | raise util.Abort(_("too many options specified")) | |
3016 | if pats and all: |
|
3017 | if pats and all: | |
3017 | raise util.Abort(_("can't specify --all and patterns")) |
|
3018 | raise util.Abort(_("can't specify --all and patterns")) | |
3018 | if not (all or pats or show or mark or unmark): |
|
3019 | if not (all or pats or show or mark or unmark): | |
3019 | raise util.Abort(_('no files or directories specified; ' |
|
3020 | raise util.Abort(_('no files or directories specified; ' | |
3020 | 'use --all to remerge all files')) |
|
3021 | 'use --all to remerge all files')) | |
3021 |
|
3022 | |||
3022 | ms = mergemod.mergestate(repo) |
|
3023 | ms = mergemod.mergestate(repo) | |
3023 | m = cmdutil.match(repo, pats, opts) |
|
3024 | m = cmdutil.match(repo, pats, opts) | |
3024 | ret = 0 |
|
3025 | ret = 0 | |
3025 |
|
3026 | |||
3026 | for f in ms: |
|
3027 | for f in ms: | |
3027 | if m(f): |
|
3028 | if m(f): | |
3028 | if show: |
|
3029 | if show: | |
3029 | if nostatus: |
|
3030 | if nostatus: | |
3030 | ui.write("%s\n" % f) |
|
3031 | ui.write("%s\n" % f) | |
3031 | else: |
|
3032 | else: | |
3032 | ui.write("%s %s\n" % (ms[f].upper(), f), |
|
3033 | ui.write("%s %s\n" % (ms[f].upper(), f), | |
3033 | label='resolve.' + |
|
3034 | label='resolve.' + | |
3034 | {'u': 'unresolved', 'r': 'resolved'}[ms[f]]) |
|
3035 | {'u': 'unresolved', 'r': 'resolved'}[ms[f]]) | |
3035 | elif mark: |
|
3036 | elif mark: | |
3036 | ms.mark(f, "r") |
|
3037 | ms.mark(f, "r") | |
3037 | elif unmark: |
|
3038 | elif unmark: | |
3038 | ms.mark(f, "u") |
|
3039 | ms.mark(f, "u") | |
3039 | else: |
|
3040 | else: | |
3040 | wctx = repo[None] |
|
3041 | wctx = repo[None] | |
3041 | mctx = wctx.parents()[-1] |
|
3042 | mctx = wctx.parents()[-1] | |
3042 |
|
3043 | |||
3043 | # backup pre-resolve (merge uses .orig for its own purposes) |
|
3044 | # backup pre-resolve (merge uses .orig for its own purposes) | |
3044 | a = repo.wjoin(f) |
|
3045 | a = repo.wjoin(f) | |
3045 | util.copyfile(a, a + ".resolve") |
|
3046 | util.copyfile(a, a + ".resolve") | |
3046 |
|
3047 | |||
3047 | try: |
|
3048 | try: | |
3048 | # resolve file |
|
3049 | # resolve file | |
3049 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) |
|
3050 | ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) | |
3050 | if ms.resolve(f, wctx, mctx): |
|
3051 | if ms.resolve(f, wctx, mctx): | |
3051 | ret = 1 |
|
3052 | ret = 1 | |
3052 | finally: |
|
3053 | finally: | |
3053 | ui.setconfig('ui', 'forcemerge', '') |
|
3054 | ui.setconfig('ui', 'forcemerge', '') | |
3054 |
|
3055 | |||
3055 | # replace filemerge's .orig file with our resolve file |
|
3056 | # replace filemerge's .orig file with our resolve file | |
3056 | util.rename(a + ".resolve", a + ".orig") |
|
3057 | util.rename(a + ".resolve", a + ".orig") | |
3057 |
|
3058 | |||
3058 | ms.commit() |
|
3059 | ms.commit() | |
3059 | return ret |
|
3060 | return ret | |
3060 |
|
3061 | |||
3061 | def revert(ui, repo, *pats, **opts): |
|
3062 | def revert(ui, repo, *pats, **opts): | |
3062 | """restore individual files or directories to an earlier state |
|
3063 | """restore individual files or directories to an earlier state | |
3063 |
|
3064 | |||
3064 | .. note:: |
|
3065 | .. note:: | |
3065 | This command is most likely not what you are looking for. |
|
3066 | This command is most likely not what you are looking for. | |
3066 | Revert will partially overwrite content in the working |
|
3067 | Revert will partially overwrite content in the working | |
3067 | directory without changing the working directory parents. Use |
|
3068 | directory without changing the working directory parents. Use | |
3068 | :hg:`update -r rev` to check out earlier revisions, or |
|
3069 | :hg:`update -r rev` to check out earlier revisions, or | |
3069 | :hg:`update --clean .` to undo a merge which has added another |
|
3070 | :hg:`update --clean .` to undo a merge which has added another | |
3070 | parent. |
|
3071 | parent. | |
3071 |
|
3072 | |||
3072 | With no revision specified, revert the named files or directories |
|
3073 | With no revision specified, revert the named files or directories | |
3073 | to the contents they had in the parent of the working directory. |
|
3074 | to the contents they had in the parent of the working directory. | |
3074 | This restores the contents of the affected files to an unmodified |
|
3075 | This restores the contents of the affected files to an unmodified | |
3075 | state and unschedules adds, removes, copies, and renames. If the |
|
3076 | state and unschedules adds, removes, copies, and renames. If the | |
3076 | working directory has two parents, you must explicitly specify a |
|
3077 | working directory has two parents, you must explicitly specify a | |
3077 | revision. |
|
3078 | revision. | |
3078 |
|
3079 | |||
3079 | Using the -r/--rev option, revert the given files or directories |
|
3080 | Using the -r/--rev option, revert the given files or directories | |
3080 | to their contents as of a specific revision. This can be helpful |
|
3081 | to their contents as of a specific revision. This can be helpful | |
3081 | to "roll back" some or all of an earlier change. See :hg:`help |
|
3082 | to "roll back" some or all of an earlier change. See :hg:`help | |
3082 | dates` for a list of formats valid for -d/--date. |
|
3083 | dates` for a list of formats valid for -d/--date. | |
3083 |
|
3084 | |||
3084 | Revert modifies the working directory. It does not commit any |
|
3085 | Revert modifies the working directory. It does not commit any | |
3085 | changes, or change the parent of the working directory. If you |
|
3086 | changes, or change the parent of the working directory. If you | |
3086 | revert to a revision other than the parent of the working |
|
3087 | revert to a revision other than the parent of the working | |
3087 | directory, the reverted files will thus appear modified |
|
3088 | directory, the reverted files will thus appear modified | |
3088 | afterwards. |
|
3089 | afterwards. | |
3089 |
|
3090 | |||
3090 | If a file has been deleted, it is restored. If the executable mode |
|
3091 | If a file has been deleted, it is restored. If the executable mode | |
3091 | of a file was changed, it is reset. |
|
3092 | of a file was changed, it is reset. | |
3092 |
|
3093 | |||
3093 | If names are given, all files matching the names are reverted. |
|
3094 | If names are given, all files matching the names are reverted. | |
3094 | If no arguments are given, no files are reverted. |
|
3095 | If no arguments are given, no files are reverted. | |
3095 |
|
3096 | |||
3096 | Modified files are saved with a .orig suffix before reverting. |
|
3097 | Modified files are saved with a .orig suffix before reverting. | |
3097 | To disable these backups, use --no-backup. |
|
3098 | To disable these backups, use --no-backup. | |
3098 |
|
3099 | |||
3099 | Returns 0 on success. |
|
3100 | Returns 0 on success. | |
3100 | """ |
|
3101 | """ | |
3101 |
|
3102 | |||
3102 | if opts.get("date"): |
|
3103 | if opts.get("date"): | |
3103 | if opts.get("rev"): |
|
3104 | if opts.get("rev"): | |
3104 | raise util.Abort(_("you can't specify a revision and a date")) |
|
3105 | raise util.Abort(_("you can't specify a revision and a date")) | |
3105 | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) |
|
3106 | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) | |
3106 |
|
3107 | |||
3107 | if not pats and not opts.get('all'): |
|
3108 | if not pats and not opts.get('all'): | |
3108 | raise util.Abort(_('no files or directories specified; ' |
|
3109 | raise util.Abort(_('no files or directories specified; ' | |
3109 | 'use --all to revert the whole repo')) |
|
3110 | 'use --all to revert the whole repo')) | |
3110 |
|
3111 | |||
3111 | parent, p2 = repo.dirstate.parents() |
|
3112 | parent, p2 = repo.dirstate.parents() | |
3112 | if not opts.get('rev') and p2 != nullid: |
|
3113 | if not opts.get('rev') and p2 != nullid: | |
3113 | raise util.Abort(_('uncommitted merge - please provide a ' |
|
3114 | raise util.Abort(_('uncommitted merge - please provide a ' | |
3114 | 'specific revision')) |
|
3115 | 'specific revision')) | |
3115 |
ctx = repo |
|
3116 | ctx = cmdutil.revsingle(repo, opts.get('rev')) | |
3116 | node = ctx.node() |
|
3117 | node = ctx.node() | |
3117 | mf = ctx.manifest() |
|
3118 | mf = ctx.manifest() | |
3118 | if node == parent: |
|
3119 | if node == parent: | |
3119 | pmf = mf |
|
3120 | pmf = mf | |
3120 | else: |
|
3121 | else: | |
3121 | pmf = None |
|
3122 | pmf = None | |
3122 |
|
3123 | |||
3123 | # need all matching names in dirstate and manifest of target rev, |
|
3124 | # need all matching names in dirstate and manifest of target rev, | |
3124 | # so have to walk both. do not print errors if files exist in one |
|
3125 | # so have to walk both. do not print errors if files exist in one | |
3125 | # but not other. |
|
3126 | # but not other. | |
3126 |
|
3127 | |||
3127 | names = {} |
|
3128 | names = {} | |
3128 |
|
3129 | |||
3129 | wlock = repo.wlock() |
|
3130 | wlock = repo.wlock() | |
3130 | try: |
|
3131 | try: | |
3131 | # walk dirstate. |
|
3132 | # walk dirstate. | |
3132 |
|
3133 | |||
3133 | m = cmdutil.match(repo, pats, opts) |
|
3134 | m = cmdutil.match(repo, pats, opts) | |
3134 | m.bad = lambda x, y: False |
|
3135 | m.bad = lambda x, y: False | |
3135 | for abs in repo.walk(m): |
|
3136 | for abs in repo.walk(m): | |
3136 | names[abs] = m.rel(abs), m.exact(abs) |
|
3137 | names[abs] = m.rel(abs), m.exact(abs) | |
3137 |
|
3138 | |||
3138 | # walk target manifest. |
|
3139 | # walk target manifest. | |
3139 |
|
3140 | |||
3140 | def badfn(path, msg): |
|
3141 | def badfn(path, msg): | |
3141 | if path in names: |
|
3142 | if path in names: | |
3142 | return |
|
3143 | return | |
3143 | path_ = path + '/' |
|
3144 | path_ = path + '/' | |
3144 | for f in names: |
|
3145 | for f in names: | |
3145 | if f.startswith(path_): |
|
3146 | if f.startswith(path_): | |
3146 | return |
|
3147 | return | |
3147 | ui.warn("%s: %s\n" % (m.rel(path), msg)) |
|
3148 | ui.warn("%s: %s\n" % (m.rel(path), msg)) | |
3148 |
|
3149 | |||
3149 | m = cmdutil.match(repo, pats, opts) |
|
3150 | m = cmdutil.match(repo, pats, opts) | |
3150 | m.bad = badfn |
|
3151 | m.bad = badfn | |
3151 | for abs in repo[node].walk(m): |
|
3152 | for abs in repo[node].walk(m): | |
3152 | if abs not in names: |
|
3153 | if abs not in names: | |
3153 | names[abs] = m.rel(abs), m.exact(abs) |
|
3154 | names[abs] = m.rel(abs), m.exact(abs) | |
3154 |
|
3155 | |||
3155 | m = cmdutil.matchfiles(repo, names) |
|
3156 | m = cmdutil.matchfiles(repo, names) | |
3156 | changes = repo.status(match=m)[:4] |
|
3157 | changes = repo.status(match=m)[:4] | |
3157 | modified, added, removed, deleted = map(set, changes) |
|
3158 | modified, added, removed, deleted = map(set, changes) | |
3158 |
|
3159 | |||
3159 | # if f is a rename, also revert the source |
|
3160 | # if f is a rename, also revert the source | |
3160 | cwd = repo.getcwd() |
|
3161 | cwd = repo.getcwd() | |
3161 | for f in added: |
|
3162 | for f in added: | |
3162 | src = repo.dirstate.copied(f) |
|
3163 | src = repo.dirstate.copied(f) | |
3163 | if src and src not in names and repo.dirstate[src] == 'r': |
|
3164 | if src and src not in names and repo.dirstate[src] == 'r': | |
3164 | removed.add(src) |
|
3165 | removed.add(src) | |
3165 | names[src] = (repo.pathto(src, cwd), True) |
|
3166 | names[src] = (repo.pathto(src, cwd), True) | |
3166 |
|
3167 | |||
3167 | def removeforget(abs): |
|
3168 | def removeforget(abs): | |
3168 | if repo.dirstate[abs] == 'a': |
|
3169 | if repo.dirstate[abs] == 'a': | |
3169 | return _('forgetting %s\n') |
|
3170 | return _('forgetting %s\n') | |
3170 | return _('removing %s\n') |
|
3171 | return _('removing %s\n') | |
3171 |
|
3172 | |||
3172 | revert = ([], _('reverting %s\n')) |
|
3173 | revert = ([], _('reverting %s\n')) | |
3173 | add = ([], _('adding %s\n')) |
|
3174 | add = ([], _('adding %s\n')) | |
3174 | remove = ([], removeforget) |
|
3175 | remove = ([], removeforget) | |
3175 | undelete = ([], _('undeleting %s\n')) |
|
3176 | undelete = ([], _('undeleting %s\n')) | |
3176 |
|
3177 | |||
3177 | disptable = ( |
|
3178 | disptable = ( | |
3178 | # dispatch table: |
|
3179 | # dispatch table: | |
3179 | # file state |
|
3180 | # file state | |
3180 | # action if in target manifest |
|
3181 | # action if in target manifest | |
3181 | # action if not in target manifest |
|
3182 | # action if not in target manifest | |
3182 | # make backup if in target manifest |
|
3183 | # make backup if in target manifest | |
3183 | # make backup if not in target manifest |
|
3184 | # make backup if not in target manifest | |
3184 | (modified, revert, remove, True, True), |
|
3185 | (modified, revert, remove, True, True), | |
3185 | (added, revert, remove, True, False), |
|
3186 | (added, revert, remove, True, False), | |
3186 | (removed, undelete, None, False, False), |
|
3187 | (removed, undelete, None, False, False), | |
3187 | (deleted, revert, remove, False, False), |
|
3188 | (deleted, revert, remove, False, False), | |
3188 | ) |
|
3189 | ) | |
3189 |
|
3190 | |||
3190 | for abs, (rel, exact) in sorted(names.items()): |
|
3191 | for abs, (rel, exact) in sorted(names.items()): | |
3191 | mfentry = mf.get(abs) |
|
3192 | mfentry = mf.get(abs) | |
3192 | target = repo.wjoin(abs) |
|
3193 | target = repo.wjoin(abs) | |
3193 | def handle(xlist, dobackup): |
|
3194 | def handle(xlist, dobackup): | |
3194 | xlist[0].append(abs) |
|
3195 | xlist[0].append(abs) | |
3195 | if (dobackup and not opts.get('no_backup') and |
|
3196 | if (dobackup and not opts.get('no_backup') and | |
3196 | os.path.lexists(target)): |
|
3197 | os.path.lexists(target)): | |
3197 | bakname = "%s.orig" % rel |
|
3198 | bakname = "%s.orig" % rel | |
3198 | ui.note(_('saving current version of %s as %s\n') % |
|
3199 | ui.note(_('saving current version of %s as %s\n') % | |
3199 | (rel, bakname)) |
|
3200 | (rel, bakname)) | |
3200 | if not opts.get('dry_run'): |
|
3201 | if not opts.get('dry_run'): | |
3201 | util.rename(target, bakname) |
|
3202 | util.rename(target, bakname) | |
3202 | if ui.verbose or not exact: |
|
3203 | if ui.verbose or not exact: | |
3203 | msg = xlist[1] |
|
3204 | msg = xlist[1] | |
3204 | if not isinstance(msg, basestring): |
|
3205 | if not isinstance(msg, basestring): | |
3205 | msg = msg(abs) |
|
3206 | msg = msg(abs) | |
3206 | ui.status(msg % rel) |
|
3207 | ui.status(msg % rel) | |
3207 | for table, hitlist, misslist, backuphit, backupmiss in disptable: |
|
3208 | for table, hitlist, misslist, backuphit, backupmiss in disptable: | |
3208 | if abs not in table: |
|
3209 | if abs not in table: | |
3209 | continue |
|
3210 | continue | |
3210 | # file has changed in dirstate |
|
3211 | # file has changed in dirstate | |
3211 | if mfentry: |
|
3212 | if mfentry: | |
3212 | handle(hitlist, backuphit) |
|
3213 | handle(hitlist, backuphit) | |
3213 | elif misslist is not None: |
|
3214 | elif misslist is not None: | |
3214 | handle(misslist, backupmiss) |
|
3215 | handle(misslist, backupmiss) | |
3215 | break |
|
3216 | break | |
3216 | else: |
|
3217 | else: | |
3217 | if abs not in repo.dirstate: |
|
3218 | if abs not in repo.dirstate: | |
3218 | if mfentry: |
|
3219 | if mfentry: | |
3219 | handle(add, True) |
|
3220 | handle(add, True) | |
3220 | elif exact: |
|
3221 | elif exact: | |
3221 | ui.warn(_('file not managed: %s\n') % rel) |
|
3222 | ui.warn(_('file not managed: %s\n') % rel) | |
3222 | continue |
|
3223 | continue | |
3223 | # file has not changed in dirstate |
|
3224 | # file has not changed in dirstate | |
3224 | if node == parent: |
|
3225 | if node == parent: | |
3225 | if exact: |
|
3226 | if exact: | |
3226 | ui.warn(_('no changes needed to %s\n') % rel) |
|
3227 | ui.warn(_('no changes needed to %s\n') % rel) | |
3227 | continue |
|
3228 | continue | |
3228 | if pmf is None: |
|
3229 | if pmf is None: | |
3229 | # only need parent manifest in this unlikely case, |
|
3230 | # only need parent manifest in this unlikely case, | |
3230 | # so do not read by default |
|
3231 | # so do not read by default | |
3231 | pmf = repo[parent].manifest() |
|
3232 | pmf = repo[parent].manifest() | |
3232 | if abs in pmf: |
|
3233 | if abs in pmf: | |
3233 | if mfentry: |
|
3234 | if mfentry: | |
3234 | # if version of file is same in parent and target |
|
3235 | # if version of file is same in parent and target | |
3235 | # manifests, do nothing |
|
3236 | # manifests, do nothing | |
3236 | if (pmf[abs] != mfentry or |
|
3237 | if (pmf[abs] != mfentry or | |
3237 | pmf.flags(abs) != mf.flags(abs)): |
|
3238 | pmf.flags(abs) != mf.flags(abs)): | |
3238 | handle(revert, False) |
|
3239 | handle(revert, False) | |
3239 | else: |
|
3240 | else: | |
3240 | handle(remove, False) |
|
3241 | handle(remove, False) | |
3241 |
|
3242 | |||
3242 | if not opts.get('dry_run'): |
|
3243 | if not opts.get('dry_run'): | |
3243 | def checkout(f): |
|
3244 | def checkout(f): | |
3244 | fc = ctx[f] |
|
3245 | fc = ctx[f] | |
3245 | repo.wwrite(f, fc.data(), fc.flags()) |
|
3246 | repo.wwrite(f, fc.data(), fc.flags()) | |
3246 |
|
3247 | |||
3247 | audit_path = util.path_auditor(repo.root) |
|
3248 | audit_path = util.path_auditor(repo.root) | |
3248 | for f in remove[0]: |
|
3249 | for f in remove[0]: | |
3249 | if repo.dirstate[f] == 'a': |
|
3250 | if repo.dirstate[f] == 'a': | |
3250 | repo.dirstate.forget(f) |
|
3251 | repo.dirstate.forget(f) | |
3251 | continue |
|
3252 | continue | |
3252 | audit_path(f) |
|
3253 | audit_path(f) | |
3253 | try: |
|
3254 | try: | |
3254 | util.unlink(repo.wjoin(f)) |
|
3255 | util.unlink(repo.wjoin(f)) | |
3255 | except OSError: |
|
3256 | except OSError: | |
3256 | pass |
|
3257 | pass | |
3257 | repo.dirstate.remove(f) |
|
3258 | repo.dirstate.remove(f) | |
3258 |
|
3259 | |||
3259 | normal = None |
|
3260 | normal = None | |
3260 | if node == parent: |
|
3261 | if node == parent: | |
3261 | # We're reverting to our parent. If possible, we'd like status |
|
3262 | # We're reverting to our parent. If possible, we'd like status | |
3262 | # to report the file as clean. We have to use normallookup for |
|
3263 | # to report the file as clean. We have to use normallookup for | |
3263 | # merges to avoid losing information about merged/dirty files. |
|
3264 | # merges to avoid losing information about merged/dirty files. | |
3264 | if p2 != nullid: |
|
3265 | if p2 != nullid: | |
3265 | normal = repo.dirstate.normallookup |
|
3266 | normal = repo.dirstate.normallookup | |
3266 | else: |
|
3267 | else: | |
3267 | normal = repo.dirstate.normal |
|
3268 | normal = repo.dirstate.normal | |
3268 | for f in revert[0]: |
|
3269 | for f in revert[0]: | |
3269 | checkout(f) |
|
3270 | checkout(f) | |
3270 | if normal: |
|
3271 | if normal: | |
3271 | normal(f) |
|
3272 | normal(f) | |
3272 |
|
3273 | |||
3273 | for f in add[0]: |
|
3274 | for f in add[0]: | |
3274 | checkout(f) |
|
3275 | checkout(f) | |
3275 | repo.dirstate.add(f) |
|
3276 | repo.dirstate.add(f) | |
3276 |
|
3277 | |||
3277 | normal = repo.dirstate.normallookup |
|
3278 | normal = repo.dirstate.normallookup | |
3278 | if node == parent and p2 == nullid: |
|
3279 | if node == parent and p2 == nullid: | |
3279 | normal = repo.dirstate.normal |
|
3280 | normal = repo.dirstate.normal | |
3280 | for f in undelete[0]: |
|
3281 | for f in undelete[0]: | |
3281 | checkout(f) |
|
3282 | checkout(f) | |
3282 | normal(f) |
|
3283 | normal(f) | |
3283 |
|
3284 | |||
3284 | finally: |
|
3285 | finally: | |
3285 | wlock.release() |
|
3286 | wlock.release() | |
3286 |
|
3287 | |||
3287 | def rollback(ui, repo, **opts): |
|
3288 | def rollback(ui, repo, **opts): | |
3288 | """roll back the last transaction (dangerous) |
|
3289 | """roll back the last transaction (dangerous) | |
3289 |
|
3290 | |||
3290 | This command should be used with care. There is only one level of |
|
3291 | This command should be used with care. There is only one level of | |
3291 | rollback, and there is no way to undo a rollback. It will also |
|
3292 | rollback, and there is no way to undo a rollback. It will also | |
3292 | restore the dirstate at the time of the last transaction, losing |
|
3293 | restore the dirstate at the time of the last transaction, losing | |
3293 | any dirstate changes since that time. This command does not alter |
|
3294 | any dirstate changes since that time. This command does not alter | |
3294 | the working directory. |
|
3295 | the working directory. | |
3295 |
|
3296 | |||
3296 | Transactions are used to encapsulate the effects of all commands |
|
3297 | Transactions are used to encapsulate the effects of all commands | |
3297 | that create new changesets or propagate existing changesets into a |
|
3298 | that create new changesets or propagate existing changesets into a | |
3298 | repository. For example, the following commands are transactional, |
|
3299 | repository. For example, the following commands are transactional, | |
3299 | and their effects can be rolled back: |
|
3300 | and their effects can be rolled back: | |
3300 |
|
3301 | |||
3301 | - commit |
|
3302 | - commit | |
3302 | - import |
|
3303 | - import | |
3303 | - pull |
|
3304 | - pull | |
3304 | - push (with this repository as the destination) |
|
3305 | - push (with this repository as the destination) | |
3305 | - unbundle |
|
3306 | - unbundle | |
3306 |
|
3307 | |||
3307 | This command is not intended for use on public repositories. Once |
|
3308 | This command is not intended for use on public repositories. Once | |
3308 | changes are visible for pull by other users, rolling a transaction |
|
3309 | changes are visible for pull by other users, rolling a transaction | |
3309 | back locally is ineffective (someone else may already have pulled |
|
3310 | back locally is ineffective (someone else may already have pulled | |
3310 | the changes). Furthermore, a race is possible with readers of the |
|
3311 | the changes). Furthermore, a race is possible with readers of the | |
3311 | repository; for example an in-progress pull from the repository |
|
3312 | repository; for example an in-progress pull from the repository | |
3312 | may fail if a rollback is performed. |
|
3313 | may fail if a rollback is performed. | |
3313 |
|
3314 | |||
3314 | Returns 0 on success, 1 if no rollback data is available. |
|
3315 | Returns 0 on success, 1 if no rollback data is available. | |
3315 | """ |
|
3316 | """ | |
3316 | return repo.rollback(opts.get('dry_run')) |
|
3317 | return repo.rollback(opts.get('dry_run')) | |
3317 |
|
3318 | |||
3318 | def root(ui, repo): |
|
3319 | def root(ui, repo): | |
3319 | """print the root (top) of the current working directory |
|
3320 | """print the root (top) of the current working directory | |
3320 |
|
3321 | |||
3321 | Print the root directory of the current repository. |
|
3322 | Print the root directory of the current repository. | |
3322 |
|
3323 | |||
3323 | Returns 0 on success. |
|
3324 | Returns 0 on success. | |
3324 | """ |
|
3325 | """ | |
3325 | ui.write(repo.root + "\n") |
|
3326 | ui.write(repo.root + "\n") | |
3326 |
|
3327 | |||
3327 | def serve(ui, repo, **opts): |
|
3328 | def serve(ui, repo, **opts): | |
3328 | """start stand-alone webserver |
|
3329 | """start stand-alone webserver | |
3329 |
|
3330 | |||
3330 | Start a local HTTP repository browser and pull server. You can use |
|
3331 | Start a local HTTP repository browser and pull server. You can use | |
3331 | this for ad-hoc sharing and browing of repositories. It is |
|
3332 | this for ad-hoc sharing and browing of repositories. It is | |
3332 | recommended to use a real web server to serve a repository for |
|
3333 | recommended to use a real web server to serve a repository for | |
3333 | longer periods of time. |
|
3334 | longer periods of time. | |
3334 |
|
3335 | |||
3335 | Please note that the server does not implement access control. |
|
3336 | Please note that the server does not implement access control. | |
3336 | This means that, by default, anybody can read from the server and |
|
3337 | This means that, by default, anybody can read from the server and | |
3337 | nobody can write to it by default. Set the ``web.allow_push`` |
|
3338 | nobody can write to it by default. Set the ``web.allow_push`` | |
3338 | option to ``*`` to allow everybody to push to the server. You |
|
3339 | option to ``*`` to allow everybody to push to the server. You | |
3339 | should use a real web server if you need to authenticate users. |
|
3340 | should use a real web server if you need to authenticate users. | |
3340 |
|
3341 | |||
3341 | By default, the server logs accesses to stdout and errors to |
|
3342 | By default, the server logs accesses to stdout and errors to | |
3342 | stderr. Use the -A/--accesslog and -E/--errorlog options to log to |
|
3343 | stderr. Use the -A/--accesslog and -E/--errorlog options to log to | |
3343 | files. |
|
3344 | files. | |
3344 |
|
3345 | |||
3345 | To have the server choose a free port number to listen on, specify |
|
3346 | To have the server choose a free port number to listen on, specify | |
3346 | a port number of 0; in this case, the server will print the port |
|
3347 | a port number of 0; in this case, the server will print the port | |
3347 | number it uses. |
|
3348 | number it uses. | |
3348 |
|
3349 | |||
3349 | Returns 0 on success. |
|
3350 | Returns 0 on success. | |
3350 | """ |
|
3351 | """ | |
3351 |
|
3352 | |||
3352 | if opts["stdio"]: |
|
3353 | if opts["stdio"]: | |
3353 | if repo is None: |
|
3354 | if repo is None: | |
3354 | raise error.RepoError(_("There is no Mercurial repository here" |
|
3355 | raise error.RepoError(_("There is no Mercurial repository here" | |
3355 | " (.hg not found)")) |
|
3356 | " (.hg not found)")) | |
3356 | s = sshserver.sshserver(ui, repo) |
|
3357 | s = sshserver.sshserver(ui, repo) | |
3357 | s.serve_forever() |
|
3358 | s.serve_forever() | |
3358 |
|
3359 | |||
3359 | # this way we can check if something was given in the command-line |
|
3360 | # this way we can check if something was given in the command-line | |
3360 | if opts.get('port'): |
|
3361 | if opts.get('port'): | |
3361 | opts['port'] = util.getport(opts.get('port')) |
|
3362 | opts['port'] = util.getport(opts.get('port')) | |
3362 |
|
3363 | |||
3363 | baseui = repo and repo.baseui or ui |
|
3364 | baseui = repo and repo.baseui or ui | |
3364 | optlist = ("name templates style address port prefix ipv6" |
|
3365 | optlist = ("name templates style address port prefix ipv6" | |
3365 | " accesslog errorlog certificate encoding") |
|
3366 | " accesslog errorlog certificate encoding") | |
3366 | for o in optlist.split(): |
|
3367 | for o in optlist.split(): | |
3367 | val = opts.get(o, '') |
|
3368 | val = opts.get(o, '') | |
3368 | if val in (None, ''): # should check against default options instead |
|
3369 | if val in (None, ''): # should check against default options instead | |
3369 | continue |
|
3370 | continue | |
3370 | baseui.setconfig("web", o, val) |
|
3371 | baseui.setconfig("web", o, val) | |
3371 | if repo and repo.ui != baseui: |
|
3372 | if repo and repo.ui != baseui: | |
3372 | repo.ui.setconfig("web", o, val) |
|
3373 | repo.ui.setconfig("web", o, val) | |
3373 |
|
3374 | |||
3374 | o = opts.get('web_conf') or opts.get('webdir_conf') |
|
3375 | o = opts.get('web_conf') or opts.get('webdir_conf') | |
3375 | if not o: |
|
3376 | if not o: | |
3376 | if not repo: |
|
3377 | if not repo: | |
3377 | raise error.RepoError(_("There is no Mercurial repository" |
|
3378 | raise error.RepoError(_("There is no Mercurial repository" | |
3378 | " here (.hg not found)")) |
|
3379 | " here (.hg not found)")) | |
3379 | o = repo.root |
|
3380 | o = repo.root | |
3380 |
|
3381 | |||
3381 | app = hgweb.hgweb(o, baseui=ui) |
|
3382 | app = hgweb.hgweb(o, baseui=ui) | |
3382 |
|
3383 | |||
3383 | class service(object): |
|
3384 | class service(object): | |
3384 | def init(self): |
|
3385 | def init(self): | |
3385 | util.set_signal_handler() |
|
3386 | util.set_signal_handler() | |
3386 | self.httpd = hgweb.server.create_server(ui, app) |
|
3387 | self.httpd = hgweb.server.create_server(ui, app) | |
3387 |
|
3388 | |||
3388 | if opts['port'] and not ui.verbose: |
|
3389 | if opts['port'] and not ui.verbose: | |
3389 | return |
|
3390 | return | |
3390 |
|
3391 | |||
3391 | if self.httpd.prefix: |
|
3392 | if self.httpd.prefix: | |
3392 | prefix = self.httpd.prefix.strip('/') + '/' |
|
3393 | prefix = self.httpd.prefix.strip('/') + '/' | |
3393 | else: |
|
3394 | else: | |
3394 | prefix = '' |
|
3395 | prefix = '' | |
3395 |
|
3396 | |||
3396 | port = ':%d' % self.httpd.port |
|
3397 | port = ':%d' % self.httpd.port | |
3397 | if port == ':80': |
|
3398 | if port == ':80': | |
3398 | port = '' |
|
3399 | port = '' | |
3399 |
|
3400 | |||
3400 | bindaddr = self.httpd.addr |
|
3401 | bindaddr = self.httpd.addr | |
3401 | if bindaddr == '0.0.0.0': |
|
3402 | if bindaddr == '0.0.0.0': | |
3402 | bindaddr = '*' |
|
3403 | bindaddr = '*' | |
3403 | elif ':' in bindaddr: # IPv6 |
|
3404 | elif ':' in bindaddr: # IPv6 | |
3404 | bindaddr = '[%s]' % bindaddr |
|
3405 | bindaddr = '[%s]' % bindaddr | |
3405 |
|
3406 | |||
3406 | fqaddr = self.httpd.fqaddr |
|
3407 | fqaddr = self.httpd.fqaddr | |
3407 | if ':' in fqaddr: |
|
3408 | if ':' in fqaddr: | |
3408 | fqaddr = '[%s]' % fqaddr |
|
3409 | fqaddr = '[%s]' % fqaddr | |
3409 | if opts['port']: |
|
3410 | if opts['port']: | |
3410 | write = ui.status |
|
3411 | write = ui.status | |
3411 | else: |
|
3412 | else: | |
3412 | write = ui.write |
|
3413 | write = ui.write | |
3413 | write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % |
|
3414 | write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % | |
3414 | (fqaddr, port, prefix, bindaddr, self.httpd.port)) |
|
3415 | (fqaddr, port, prefix, bindaddr, self.httpd.port)) | |
3415 |
|
3416 | |||
3416 | def run(self): |
|
3417 | def run(self): | |
3417 | self.httpd.serve_forever() |
|
3418 | self.httpd.serve_forever() | |
3418 |
|
3419 | |||
3419 | service = service() |
|
3420 | service = service() | |
3420 |
|
3421 | |||
3421 | cmdutil.service(opts, initfn=service.init, runfn=service.run) |
|
3422 | cmdutil.service(opts, initfn=service.init, runfn=service.run) | |
3422 |
|
3423 | |||
3423 | def status(ui, repo, *pats, **opts): |
|
3424 | def status(ui, repo, *pats, **opts): | |
3424 | """show changed files in the working directory |
|
3425 | """show changed files in the working directory | |
3425 |
|
3426 | |||
3426 | Show status of files in the repository. If names are given, only |
|
3427 | Show status of files in the repository. If names are given, only | |
3427 | files that match are shown. Files that are clean or ignored or |
|
3428 | files that match are shown. Files that are clean or ignored or | |
3428 | the source of a copy/move operation, are not listed unless |
|
3429 | the source of a copy/move operation, are not listed unless | |
3429 | -c/--clean, -i/--ignored, -C/--copies or -A/--all are given. |
|
3430 | -c/--clean, -i/--ignored, -C/--copies or -A/--all are given. | |
3430 | Unless options described with "show only ..." are given, the |
|
3431 | Unless options described with "show only ..." are given, the | |
3431 | options -mardu are used. |
|
3432 | options -mardu are used. | |
3432 |
|
3433 | |||
3433 | Option -q/--quiet hides untracked (unknown and ignored) files |
|
3434 | Option -q/--quiet hides untracked (unknown and ignored) files | |
3434 | unless explicitly requested with -u/--unknown or -i/--ignored. |
|
3435 | unless explicitly requested with -u/--unknown or -i/--ignored. | |
3435 |
|
3436 | |||
3436 | .. note:: |
|
3437 | .. note:: | |
3437 | status may appear to disagree with diff if permissions have |
|
3438 | status may appear to disagree with diff if permissions have | |
3438 | changed or a merge has occurred. The standard diff format does |
|
3439 | changed or a merge has occurred. The standard diff format does | |
3439 | not report permission changes and diff only reports changes |
|
3440 | not report permission changes and diff only reports changes | |
3440 | relative to one merge parent. |
|
3441 | relative to one merge parent. | |
3441 |
|
3442 | |||
3442 | If one revision is given, it is used as the base revision. |
|
3443 | If one revision is given, it is used as the base revision. | |
3443 | If two revisions are given, the differences between them are |
|
3444 | If two revisions are given, the differences between them are | |
3444 | shown. The --change option can also be used as a shortcut to list |
|
3445 | shown. The --change option can also be used as a shortcut to list | |
3445 | the changed files of a revision from its first parent. |
|
3446 | the changed files of a revision from its first parent. | |
3446 |
|
3447 | |||
3447 | The codes used to show the status of files are:: |
|
3448 | The codes used to show the status of files are:: | |
3448 |
|
3449 | |||
3449 | M = modified |
|
3450 | M = modified | |
3450 | A = added |
|
3451 | A = added | |
3451 | R = removed |
|
3452 | R = removed | |
3452 | C = clean |
|
3453 | C = clean | |
3453 | ! = missing (deleted by non-hg command, but still tracked) |
|
3454 | ! = missing (deleted by non-hg command, but still tracked) | |
3454 | ? = not tracked |
|
3455 | ? = not tracked | |
3455 | I = ignored |
|
3456 | I = ignored | |
3456 | = origin of the previous file listed as A (added) |
|
3457 | = origin of the previous file listed as A (added) | |
3457 |
|
3458 | |||
3458 | Returns 0 on success. |
|
3459 | Returns 0 on success. | |
3459 | """ |
|
3460 | """ | |
3460 |
|
3461 | |||
3461 | revs = opts.get('rev') |
|
3462 | revs = opts.get('rev') | |
3462 | change = opts.get('change') |
|
3463 | change = opts.get('change') | |
3463 |
|
3464 | |||
3464 | if revs and change: |
|
3465 | if revs and change: | |
3465 | msg = _('cannot specify --rev and --change at the same time') |
|
3466 | msg = _('cannot specify --rev and --change at the same time') | |
3466 | raise util.Abort(msg) |
|
3467 | raise util.Abort(msg) | |
3467 | elif change: |
|
3468 | elif change: | |
3468 | node2 = repo.lookup(change) |
|
3469 | node2 = repo.lookup(change) | |
3469 | node1 = repo[node2].parents()[0].node() |
|
3470 | node1 = repo[node2].parents()[0].node() | |
3470 | else: |
|
3471 | else: | |
3471 | node1, node2 = cmdutil.revpair(repo, revs) |
|
3472 | node1, node2 = cmdutil.revpair(repo, revs) | |
3472 |
|
3473 | |||
3473 | cwd = (pats and repo.getcwd()) or '' |
|
3474 | cwd = (pats and repo.getcwd()) or '' | |
3474 | end = opts.get('print0') and '\0' or '\n' |
|
3475 | end = opts.get('print0') and '\0' or '\n' | |
3475 | copy = {} |
|
3476 | copy = {} | |
3476 | states = 'modified added removed deleted unknown ignored clean'.split() |
|
3477 | states = 'modified added removed deleted unknown ignored clean'.split() | |
3477 | show = [k for k in states if opts.get(k)] |
|
3478 | show = [k for k in states if opts.get(k)] | |
3478 | if opts.get('all'): |
|
3479 | if opts.get('all'): | |
3479 | show += ui.quiet and (states[:4] + ['clean']) or states |
|
3480 | show += ui.quiet and (states[:4] + ['clean']) or states | |
3480 | if not show: |
|
3481 | if not show: | |
3481 | show = ui.quiet and states[:4] or states[:5] |
|
3482 | show = ui.quiet and states[:4] or states[:5] | |
3482 |
|
3483 | |||
3483 | stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts), |
|
3484 | stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts), | |
3484 | 'ignored' in show, 'clean' in show, 'unknown' in show, |
|
3485 | 'ignored' in show, 'clean' in show, 'unknown' in show, | |
3485 | opts.get('subrepos')) |
|
3486 | opts.get('subrepos')) | |
3486 | changestates = zip(states, 'MAR!?IC', stat) |
|
3487 | changestates = zip(states, 'MAR!?IC', stat) | |
3487 |
|
3488 | |||
3488 | if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): |
|
3489 | if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): | |
3489 | ctxn = repo[nullid] |
|
3490 | ctxn = repo[nullid] | |
3490 | ctx1 = repo[node1] |
|
3491 | ctx1 = repo[node1] | |
3491 | ctx2 = repo[node2] |
|
3492 | ctx2 = repo[node2] | |
3492 | added = stat[1] |
|
3493 | added = stat[1] | |
3493 | if node2 is None: |
|
3494 | if node2 is None: | |
3494 | added = stat[0] + stat[1] # merged? |
|
3495 | added = stat[0] + stat[1] # merged? | |
3495 |
|
3496 | |||
3496 | for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems(): |
|
3497 | for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems(): | |
3497 | if k in added: |
|
3498 | if k in added: | |
3498 | copy[k] = v |
|
3499 | copy[k] = v | |
3499 | elif v in added: |
|
3500 | elif v in added: | |
3500 | copy[v] = k |
|
3501 | copy[v] = k | |
3501 |
|
3502 | |||
3502 | for state, char, files in changestates: |
|
3503 | for state, char, files in changestates: | |
3503 | if state in show: |
|
3504 | if state in show: | |
3504 | format = "%s %%s%s" % (char, end) |
|
3505 | format = "%s %%s%s" % (char, end) | |
3505 | if opts.get('no_status'): |
|
3506 | if opts.get('no_status'): | |
3506 | format = "%%s%s" % end |
|
3507 | format = "%%s%s" % end | |
3507 |
|
3508 | |||
3508 | for f in files: |
|
3509 | for f in files: | |
3509 | ui.write(format % repo.pathto(f, cwd), |
|
3510 | ui.write(format % repo.pathto(f, cwd), | |
3510 | label='status.' + state) |
|
3511 | label='status.' + state) | |
3511 | if f in copy: |
|
3512 | if f in copy: | |
3512 | ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end), |
|
3513 | ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end), | |
3513 | label='status.copied') |
|
3514 | label='status.copied') | |
3514 |
|
3515 | |||
3515 | def summary(ui, repo, **opts): |
|
3516 | def summary(ui, repo, **opts): | |
3516 | """summarize working directory state |
|
3517 | """summarize working directory state | |
3517 |
|
3518 | |||
3518 | This generates a brief summary of the working directory state, |
|
3519 | This generates a brief summary of the working directory state, | |
3519 | including parents, branch, commit status, and available updates. |
|
3520 | including parents, branch, commit status, and available updates. | |
3520 |
|
3521 | |||
3521 | With the --remote option, this will check the default paths for |
|
3522 | With the --remote option, this will check the default paths for | |
3522 | incoming and outgoing changes. This can be time-consuming. |
|
3523 | incoming and outgoing changes. This can be time-consuming. | |
3523 |
|
3524 | |||
3524 | Returns 0 on success. |
|
3525 | Returns 0 on success. | |
3525 | """ |
|
3526 | """ | |
3526 |
|
3527 | |||
3527 | ctx = repo[None] |
|
3528 | ctx = repo[None] | |
3528 | parents = ctx.parents() |
|
3529 | parents = ctx.parents() | |
3529 | pnode = parents[0].node() |
|
3530 | pnode = parents[0].node() | |
3530 |
|
3531 | |||
3531 | for p in parents: |
|
3532 | for p in parents: | |
3532 | # label with log.changeset (instead of log.parent) since this |
|
3533 | # label with log.changeset (instead of log.parent) since this | |
3533 | # shows a working directory parent *changeset*: |
|
3534 | # shows a working directory parent *changeset*: | |
3534 | ui.write(_('parent: %d:%s ') % (p.rev(), str(p)), |
|
3535 | ui.write(_('parent: %d:%s ') % (p.rev(), str(p)), | |
3535 | label='log.changeset') |
|
3536 | label='log.changeset') | |
3536 | ui.write(' '.join(p.tags()), label='log.tag') |
|
3537 | ui.write(' '.join(p.tags()), label='log.tag') | |
3537 | if p.rev() == -1: |
|
3538 | if p.rev() == -1: | |
3538 | if not len(repo): |
|
3539 | if not len(repo): | |
3539 | ui.write(_(' (empty repository)')) |
|
3540 | ui.write(_(' (empty repository)')) | |
3540 | else: |
|
3541 | else: | |
3541 | ui.write(_(' (no revision checked out)')) |
|
3542 | ui.write(_(' (no revision checked out)')) | |
3542 | ui.write('\n') |
|
3543 | ui.write('\n') | |
3543 | if p.description(): |
|
3544 | if p.description(): | |
3544 | ui.status(' ' + p.description().splitlines()[0].strip() + '\n', |
|
3545 | ui.status(' ' + p.description().splitlines()[0].strip() + '\n', | |
3545 | label='log.summary') |
|
3546 | label='log.summary') | |
3546 |
|
3547 | |||
3547 | branch = ctx.branch() |
|
3548 | branch = ctx.branch() | |
3548 | bheads = repo.branchheads(branch) |
|
3549 | bheads = repo.branchheads(branch) | |
3549 | m = _('branch: %s\n') % branch |
|
3550 | m = _('branch: %s\n') % branch | |
3550 | if branch != 'default': |
|
3551 | if branch != 'default': | |
3551 | ui.write(m, label='log.branch') |
|
3552 | ui.write(m, label='log.branch') | |
3552 | else: |
|
3553 | else: | |
3553 | ui.status(m, label='log.branch') |
|
3554 | ui.status(m, label='log.branch') | |
3554 |
|
3555 | |||
3555 | st = list(repo.status(unknown=True))[:6] |
|
3556 | st = list(repo.status(unknown=True))[:6] | |
3556 |
|
3557 | |||
3557 | c = repo.dirstate.copies() |
|
3558 | c = repo.dirstate.copies() | |
3558 | copied, renamed = [], [] |
|
3559 | copied, renamed = [], [] | |
3559 | for d, s in c.iteritems(): |
|
3560 | for d, s in c.iteritems(): | |
3560 | if s in st[2]: |
|
3561 | if s in st[2]: | |
3561 | st[2].remove(s) |
|
3562 | st[2].remove(s) | |
3562 | renamed.append(d) |
|
3563 | renamed.append(d) | |
3563 | else: |
|
3564 | else: | |
3564 | copied.append(d) |
|
3565 | copied.append(d) | |
3565 | if d in st[1]: |
|
3566 | if d in st[1]: | |
3566 | st[1].remove(d) |
|
3567 | st[1].remove(d) | |
3567 | st.insert(3, renamed) |
|
3568 | st.insert(3, renamed) | |
3568 | st.insert(4, copied) |
|
3569 | st.insert(4, copied) | |
3569 |
|
3570 | |||
3570 | ms = mergemod.mergestate(repo) |
|
3571 | ms = mergemod.mergestate(repo) | |
3571 | st.append([f for f in ms if ms[f] == 'u']) |
|
3572 | st.append([f for f in ms if ms[f] == 'u']) | |
3572 |
|
3573 | |||
3573 | subs = [s for s in ctx.substate if ctx.sub(s).dirty()] |
|
3574 | subs = [s for s in ctx.substate if ctx.sub(s).dirty()] | |
3574 | st.append(subs) |
|
3575 | st.append(subs) | |
3575 |
|
3576 | |||
3576 | labels = [ui.label(_('%d modified'), 'status.modified'), |
|
3577 | labels = [ui.label(_('%d modified'), 'status.modified'), | |
3577 | ui.label(_('%d added'), 'status.added'), |
|
3578 | ui.label(_('%d added'), 'status.added'), | |
3578 | ui.label(_('%d removed'), 'status.removed'), |
|
3579 | ui.label(_('%d removed'), 'status.removed'), | |
3579 | ui.label(_('%d renamed'), 'status.copied'), |
|
3580 | ui.label(_('%d renamed'), 'status.copied'), | |
3580 | ui.label(_('%d copied'), 'status.copied'), |
|
3581 | ui.label(_('%d copied'), 'status.copied'), | |
3581 | ui.label(_('%d deleted'), 'status.deleted'), |
|
3582 | ui.label(_('%d deleted'), 'status.deleted'), | |
3582 | ui.label(_('%d unknown'), 'status.unknown'), |
|
3583 | ui.label(_('%d unknown'), 'status.unknown'), | |
3583 | ui.label(_('%d ignored'), 'status.ignored'), |
|
3584 | ui.label(_('%d ignored'), 'status.ignored'), | |
3584 | ui.label(_('%d unresolved'), 'resolve.unresolved'), |
|
3585 | ui.label(_('%d unresolved'), 'resolve.unresolved'), | |
3585 | ui.label(_('%d subrepos'), 'status.modified')] |
|
3586 | ui.label(_('%d subrepos'), 'status.modified')] | |
3586 | t = [] |
|
3587 | t = [] | |
3587 | for s, l in zip(st, labels): |
|
3588 | for s, l in zip(st, labels): | |
3588 | if s: |
|
3589 | if s: | |
3589 | t.append(l % len(s)) |
|
3590 | t.append(l % len(s)) | |
3590 |
|
3591 | |||
3591 | t = ', '.join(t) |
|
3592 | t = ', '.join(t) | |
3592 | cleanworkdir = False |
|
3593 | cleanworkdir = False | |
3593 |
|
3594 | |||
3594 | if len(parents) > 1: |
|
3595 | if len(parents) > 1: | |
3595 | t += _(' (merge)') |
|
3596 | t += _(' (merge)') | |
3596 | elif branch != parents[0].branch(): |
|
3597 | elif branch != parents[0].branch(): | |
3597 | t += _(' (new branch)') |
|
3598 | t += _(' (new branch)') | |
3598 | elif (parents[0].extra().get('close') and |
|
3599 | elif (parents[0].extra().get('close') and | |
3599 | pnode in repo.branchheads(branch, closed=True)): |
|
3600 | pnode in repo.branchheads(branch, closed=True)): | |
3600 | t += _(' (head closed)') |
|
3601 | t += _(' (head closed)') | |
3601 | elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]): |
|
3602 | elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]): | |
3602 | t += _(' (clean)') |
|
3603 | t += _(' (clean)') | |
3603 | cleanworkdir = True |
|
3604 | cleanworkdir = True | |
3604 | elif pnode not in bheads: |
|
3605 | elif pnode not in bheads: | |
3605 | t += _(' (new branch head)') |
|
3606 | t += _(' (new branch head)') | |
3606 |
|
3607 | |||
3607 | if cleanworkdir: |
|
3608 | if cleanworkdir: | |
3608 | ui.status(_('commit: %s\n') % t.strip()) |
|
3609 | ui.status(_('commit: %s\n') % t.strip()) | |
3609 | else: |
|
3610 | else: | |
3610 | ui.write(_('commit: %s\n') % t.strip()) |
|
3611 | ui.write(_('commit: %s\n') % t.strip()) | |
3611 |
|
3612 | |||
3612 | # all ancestors of branch heads - all ancestors of parent = new csets |
|
3613 | # all ancestors of branch heads - all ancestors of parent = new csets | |
3613 | new = [0] * len(repo) |
|
3614 | new = [0] * len(repo) | |
3614 | cl = repo.changelog |
|
3615 | cl = repo.changelog | |
3615 | for a in [cl.rev(n) for n in bheads]: |
|
3616 | for a in [cl.rev(n) for n in bheads]: | |
3616 | new[a] = 1 |
|
3617 | new[a] = 1 | |
3617 | for a in cl.ancestors(*[cl.rev(n) for n in bheads]): |
|
3618 | for a in cl.ancestors(*[cl.rev(n) for n in bheads]): | |
3618 | new[a] = 1 |
|
3619 | new[a] = 1 | |
3619 | for a in [p.rev() for p in parents]: |
|
3620 | for a in [p.rev() for p in parents]: | |
3620 | if a >= 0: |
|
3621 | if a >= 0: | |
3621 | new[a] = 0 |
|
3622 | new[a] = 0 | |
3622 | for a in cl.ancestors(*[p.rev() for p in parents]): |
|
3623 | for a in cl.ancestors(*[p.rev() for p in parents]): | |
3623 | new[a] = 0 |
|
3624 | new[a] = 0 | |
3624 | new = sum(new) |
|
3625 | new = sum(new) | |
3625 |
|
3626 | |||
3626 | if new == 0: |
|
3627 | if new == 0: | |
3627 | ui.status(_('update: (current)\n')) |
|
3628 | ui.status(_('update: (current)\n')) | |
3628 | elif pnode not in bheads: |
|
3629 | elif pnode not in bheads: | |
3629 | ui.write(_('update: %d new changesets (update)\n') % new) |
|
3630 | ui.write(_('update: %d new changesets (update)\n') % new) | |
3630 | else: |
|
3631 | else: | |
3631 | ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % |
|
3632 | ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % | |
3632 | (new, len(bheads))) |
|
3633 | (new, len(bheads))) | |
3633 |
|
3634 | |||
3634 | if opts.get('remote'): |
|
3635 | if opts.get('remote'): | |
3635 | t = [] |
|
3636 | t = [] | |
3636 | source, branches = hg.parseurl(ui.expandpath('default')) |
|
3637 | source, branches = hg.parseurl(ui.expandpath('default')) | |
3637 | other = hg.repository(hg.remoteui(repo, {}), source) |
|
3638 | other = hg.repository(hg.remoteui(repo, {}), source) | |
3638 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
3639 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
3639 | ui.debug('comparing with %s\n' % url.hidepassword(source)) |
|
3640 | ui.debug('comparing with %s\n' % url.hidepassword(source)) | |
3640 | repo.ui.pushbuffer() |
|
3641 | repo.ui.pushbuffer() | |
3641 | common, incoming, rheads = discovery.findcommonincoming(repo, other) |
|
3642 | common, incoming, rheads = discovery.findcommonincoming(repo, other) | |
3642 | repo.ui.popbuffer() |
|
3643 | repo.ui.popbuffer() | |
3643 | if incoming: |
|
3644 | if incoming: | |
3644 | t.append(_('1 or more incoming')) |
|
3645 | t.append(_('1 or more incoming')) | |
3645 |
|
3646 | |||
3646 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) |
|
3647 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) | |
3647 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
|
3648 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | |
3648 | other = hg.repository(hg.remoteui(repo, {}), dest) |
|
3649 | other = hg.repository(hg.remoteui(repo, {}), dest) | |
3649 | ui.debug('comparing with %s\n' % url.hidepassword(dest)) |
|
3650 | ui.debug('comparing with %s\n' % url.hidepassword(dest)) | |
3650 | repo.ui.pushbuffer() |
|
3651 | repo.ui.pushbuffer() | |
3651 | o = discovery.findoutgoing(repo, other) |
|
3652 | o = discovery.findoutgoing(repo, other) | |
3652 | repo.ui.popbuffer() |
|
3653 | repo.ui.popbuffer() | |
3653 | o = repo.changelog.nodesbetween(o, None)[0] |
|
3654 | o = repo.changelog.nodesbetween(o, None)[0] | |
3654 | if o: |
|
3655 | if o: | |
3655 | t.append(_('%d outgoing') % len(o)) |
|
3656 | t.append(_('%d outgoing') % len(o)) | |
3656 |
|
3657 | |||
3657 | if t: |
|
3658 | if t: | |
3658 | ui.write(_('remote: %s\n') % (', '.join(t))) |
|
3659 | ui.write(_('remote: %s\n') % (', '.join(t))) | |
3659 | else: |
|
3660 | else: | |
3660 | ui.status(_('remote: (synced)\n')) |
|
3661 | ui.status(_('remote: (synced)\n')) | |
3661 |
|
3662 | |||
3662 | def tag(ui, repo, name1, *names, **opts): |
|
3663 | def tag(ui, repo, name1, *names, **opts): | |
3663 | """add one or more tags for the current or given revision |
|
3664 | """add one or more tags for the current or given revision | |
3664 |
|
3665 | |||
3665 | Name a particular revision using <name>. |
|
3666 | Name a particular revision using <name>. | |
3666 |
|
3667 | |||
3667 | Tags are used to name particular revisions of the repository and are |
|
3668 | Tags are used to name particular revisions of the repository and are | |
3668 | very useful to compare different revisions, to go back to significant |
|
3669 | very useful to compare different revisions, to go back to significant | |
3669 | earlier versions or to mark branch points as releases, etc. |
|
3670 | earlier versions or to mark branch points as releases, etc. | |
3670 |
|
3671 | |||
3671 | If no revision is given, the parent of the working directory is |
|
3672 | If no revision is given, the parent of the working directory is | |
3672 | used, or tip if no revision is checked out. |
|
3673 | used, or tip if no revision is checked out. | |
3673 |
|
3674 | |||
3674 | To facilitate version control, distribution, and merging of tags, |
|
3675 | To facilitate version control, distribution, and merging of tags, | |
3675 | they are stored as a file named ".hgtags" which is managed |
|
3676 | they are stored as a file named ".hgtags" which is managed | |
3676 | similarly to other project files and can be hand-edited if |
|
3677 | similarly to other project files and can be hand-edited if | |
3677 | necessary. The file '.hg/localtags' is used for local tags (not |
|
3678 | necessary. The file '.hg/localtags' is used for local tags (not | |
3678 | shared among repositories). |
|
3679 | shared among repositories). | |
3679 |
|
3680 | |||
3680 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
3681 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
3681 |
|
3682 | |||
3682 | Since tag names have priority over branch names during revision |
|
3683 | Since tag names have priority over branch names during revision | |
3683 | lookup, using an existing branch name as a tag name is discouraged. |
|
3684 | lookup, using an existing branch name as a tag name is discouraged. | |
3684 |
|
3685 | |||
3685 | Returns 0 on success. |
|
3686 | Returns 0 on success. | |
3686 | """ |
|
3687 | """ | |
3687 |
|
3688 | |||
3688 | rev_ = "." |
|
3689 | rev_ = "." | |
3689 | names = [t.strip() for t in (name1,) + names] |
|
3690 | names = [t.strip() for t in (name1,) + names] | |
3690 | if len(names) != len(set(names)): |
|
3691 | if len(names) != len(set(names)): | |
3691 | raise util.Abort(_('tag names must be unique')) |
|
3692 | raise util.Abort(_('tag names must be unique')) | |
3692 | for n in names: |
|
3693 | for n in names: | |
3693 | if n in ['tip', '.', 'null']: |
|
3694 | if n in ['tip', '.', 'null']: | |
3694 | raise util.Abort(_('the name \'%s\' is reserved') % n) |
|
3695 | raise util.Abort(_('the name \'%s\' is reserved') % n) | |
3695 | if not n: |
|
3696 | if not n: | |
3696 | raise util.Abort(_('tag names cannot consist entirely of whitespace')) |
|
3697 | raise util.Abort(_('tag names cannot consist entirely of whitespace')) | |
3697 | if opts.get('rev') and opts.get('remove'): |
|
3698 | if opts.get('rev') and opts.get('remove'): | |
3698 | raise util.Abort(_("--rev and --remove are incompatible")) |
|
3699 | raise util.Abort(_("--rev and --remove are incompatible")) | |
3699 | if opts.get('rev'): |
|
3700 | if opts.get('rev'): | |
3700 | rev_ = opts['rev'] |
|
3701 | rev_ = opts['rev'] | |
3701 | message = opts.get('message') |
|
3702 | message = opts.get('message') | |
3702 | if opts.get('remove'): |
|
3703 | if opts.get('remove'): | |
3703 | expectedtype = opts.get('local') and 'local' or 'global' |
|
3704 | expectedtype = opts.get('local') and 'local' or 'global' | |
3704 | for n in names: |
|
3705 | for n in names: | |
3705 | if not repo.tagtype(n): |
|
3706 | if not repo.tagtype(n): | |
3706 | raise util.Abort(_('tag \'%s\' does not exist') % n) |
|
3707 | raise util.Abort(_('tag \'%s\' does not exist') % n) | |
3707 | if repo.tagtype(n) != expectedtype: |
|
3708 | if repo.tagtype(n) != expectedtype: | |
3708 | if expectedtype == 'global': |
|
3709 | if expectedtype == 'global': | |
3709 | raise util.Abort(_('tag \'%s\' is not a global tag') % n) |
|
3710 | raise util.Abort(_('tag \'%s\' is not a global tag') % n) | |
3710 | else: |
|
3711 | else: | |
3711 | raise util.Abort(_('tag \'%s\' is not a local tag') % n) |
|
3712 | raise util.Abort(_('tag \'%s\' is not a local tag') % n) | |
3712 | rev_ = nullid |
|
3713 | rev_ = nullid | |
3713 | if not message: |
|
3714 | if not message: | |
3714 | # we don't translate commit messages |
|
3715 | # we don't translate commit messages | |
3715 | message = 'Removed tag %s' % ', '.join(names) |
|
3716 | message = 'Removed tag %s' % ', '.join(names) | |
3716 | elif not opts.get('force'): |
|
3717 | elif not opts.get('force'): | |
3717 | for n in names: |
|
3718 | for n in names: | |
3718 | if n in repo.tags(): |
|
3719 | if n in repo.tags(): | |
3719 | raise util.Abort(_('tag \'%s\' already exists ' |
|
3720 | raise util.Abort(_('tag \'%s\' already exists ' | |
3720 | '(use -f to force)') % n) |
|
3721 | '(use -f to force)') % n) | |
3721 | if not rev_ and repo.dirstate.parents()[1] != nullid: |
|
3722 | if not rev_ and repo.dirstate.parents()[1] != nullid: | |
3722 | raise util.Abort(_('uncommitted merge - please provide a ' |
|
3723 | raise util.Abort(_('uncommitted merge - please provide a ' | |
3723 | 'specific revision')) |
|
3724 | 'specific revision')) | |
3724 |
r = repo |
|
3725 | r = cmdutil.revsingle(repo, rev_).node() | |
3725 |
|
3726 | |||
3726 | if not message: |
|
3727 | if not message: | |
3727 | # we don't translate commit messages |
|
3728 | # we don't translate commit messages | |
3728 | message = ('Added tag %s for changeset %s' % |
|
3729 | message = ('Added tag %s for changeset %s' % | |
3729 | (', '.join(names), short(r))) |
|
3730 | (', '.join(names), short(r))) | |
3730 |
|
3731 | |||
3731 | date = opts.get('date') |
|
3732 | date = opts.get('date') | |
3732 | if date: |
|
3733 | if date: | |
3733 | date = util.parsedate(date) |
|
3734 | date = util.parsedate(date) | |
3734 |
|
3735 | |||
3735 | if opts.get('edit'): |
|
3736 | if opts.get('edit'): | |
3736 | message = ui.edit(message, ui.username()) |
|
3737 | message = ui.edit(message, ui.username()) | |
3737 |
|
3738 | |||
3738 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date) |
|
3739 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date) | |
3739 |
|
3740 | |||
3740 | def tags(ui, repo): |
|
3741 | def tags(ui, repo): | |
3741 | """list repository tags |
|
3742 | """list repository tags | |
3742 |
|
3743 | |||
3743 | This lists both regular and local tags. When the -v/--verbose |
|
3744 | This lists both regular and local tags. When the -v/--verbose | |
3744 | switch is used, a third column "local" is printed for local tags. |
|
3745 | switch is used, a third column "local" is printed for local tags. | |
3745 |
|
3746 | |||
3746 | Returns 0 on success. |
|
3747 | Returns 0 on success. | |
3747 | """ |
|
3748 | """ | |
3748 |
|
3749 | |||
3749 | hexfunc = ui.debugflag and hex or short |
|
3750 | hexfunc = ui.debugflag and hex or short | |
3750 | tagtype = "" |
|
3751 | tagtype = "" | |
3751 |
|
3752 | |||
3752 | for t, n in reversed(repo.tagslist()): |
|
3753 | for t, n in reversed(repo.tagslist()): | |
3753 | if ui.quiet: |
|
3754 | if ui.quiet: | |
3754 | ui.write("%s\n" % t) |
|
3755 | ui.write("%s\n" % t) | |
3755 | continue |
|
3756 | continue | |
3756 |
|
3757 | |||
3757 | try: |
|
3758 | try: | |
3758 | hn = hexfunc(n) |
|
3759 | hn = hexfunc(n) | |
3759 | r = "%5d:%s" % (repo.changelog.rev(n), hn) |
|
3760 | r = "%5d:%s" % (repo.changelog.rev(n), hn) | |
3760 | except error.LookupError: |
|
3761 | except error.LookupError: | |
3761 | r = " ?:%s" % hn |
|
3762 | r = " ?:%s" % hn | |
3762 | else: |
|
3763 | else: | |
3763 | spaces = " " * (30 - encoding.colwidth(t)) |
|
3764 | spaces = " " * (30 - encoding.colwidth(t)) | |
3764 | if ui.verbose: |
|
3765 | if ui.verbose: | |
3765 | if repo.tagtype(t) == 'local': |
|
3766 | if repo.tagtype(t) == 'local': | |
3766 | tagtype = " local" |
|
3767 | tagtype = " local" | |
3767 | else: |
|
3768 | else: | |
3768 | tagtype = "" |
|
3769 | tagtype = "" | |
3769 | ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype)) |
|
3770 | ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype)) | |
3770 |
|
3771 | |||
3771 | def tip(ui, repo, **opts): |
|
3772 | def tip(ui, repo, **opts): | |
3772 | """show the tip revision |
|
3773 | """show the tip revision | |
3773 |
|
3774 | |||
3774 | The tip revision (usually just called the tip) is the changeset |
|
3775 | The tip revision (usually just called the tip) is the changeset | |
3775 | most recently added to the repository (and therefore the most |
|
3776 | most recently added to the repository (and therefore the most | |
3776 | recently changed head). |
|
3777 | recently changed head). | |
3777 |
|
3778 | |||
3778 | If you have just made a commit, that commit will be the tip. If |
|
3779 | If you have just made a commit, that commit will be the tip. If | |
3779 | you have just pulled changes from another repository, the tip of |
|
3780 | you have just pulled changes from another repository, the tip of | |
3780 | that repository becomes the current tip. The "tip" tag is special |
|
3781 | that repository becomes the current tip. The "tip" tag is special | |
3781 | and cannot be renamed or assigned to a different changeset. |
|
3782 | and cannot be renamed or assigned to a different changeset. | |
3782 |
|
3783 | |||
3783 | Returns 0 on success. |
|
3784 | Returns 0 on success. | |
3784 | """ |
|
3785 | """ | |
3785 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
3786 | displayer = cmdutil.show_changeset(ui, repo, opts) | |
3786 | displayer.show(repo[len(repo) - 1]) |
|
3787 | displayer.show(repo[len(repo) - 1]) | |
3787 | displayer.close() |
|
3788 | displayer.close() | |
3788 |
|
3789 | |||
3789 | def unbundle(ui, repo, fname1, *fnames, **opts): |
|
3790 | def unbundle(ui, repo, fname1, *fnames, **opts): | |
3790 | """apply one or more changegroup files |
|
3791 | """apply one or more changegroup files | |
3791 |
|
3792 | |||
3792 | Apply one or more compressed changegroup files generated by the |
|
3793 | Apply one or more compressed changegroup files generated by the | |
3793 | bundle command. |
|
3794 | bundle command. | |
3794 |
|
3795 | |||
3795 | Returns 0 on success, 1 if an update has unresolved files. |
|
3796 | Returns 0 on success, 1 if an update has unresolved files. | |
3796 | """ |
|
3797 | """ | |
3797 | fnames = (fname1,) + fnames |
|
3798 | fnames = (fname1,) + fnames | |
3798 |
|
3799 | |||
3799 | lock = repo.lock() |
|
3800 | lock = repo.lock() | |
3800 | try: |
|
3801 | try: | |
3801 | for fname in fnames: |
|
3802 | for fname in fnames: | |
3802 | f = url.open(ui, fname) |
|
3803 | f = url.open(ui, fname) | |
3803 | gen = changegroup.readbundle(f, fname) |
|
3804 | gen = changegroup.readbundle(f, fname) | |
3804 | modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname, |
|
3805 | modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname, | |
3805 | lock=lock) |
|
3806 | lock=lock) | |
3806 | finally: |
|
3807 | finally: | |
3807 | lock.release() |
|
3808 | lock.release() | |
3808 |
|
3809 | |||
3809 | return postincoming(ui, repo, modheads, opts.get('update'), None) |
|
3810 | return postincoming(ui, repo, modheads, opts.get('update'), None) | |
3810 |
|
3811 | |||
3811 | def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False): |
|
3812 | def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False): | |
3812 | """update working directory (or switch revisions) |
|
3813 | """update working directory (or switch revisions) | |
3813 |
|
3814 | |||
3814 | Update the repository's working directory to the specified |
|
3815 | Update the repository's working directory to the specified | |
3815 | changeset. If no changeset is specified, update to the tip of the |
|
3816 | changeset. If no changeset is specified, update to the tip of the | |
3816 | current named branch. |
|
3817 | current named branch. | |
3817 |
|
3818 | |||
3818 | If the changeset is not a descendant of the working directory's |
|
3819 | If the changeset is not a descendant of the working directory's | |
3819 | parent, the update is aborted. With the -c/--check option, the |
|
3820 | parent, the update is aborted. With the -c/--check option, the | |
3820 | working directory is checked for uncommitted changes; if none are |
|
3821 | working directory is checked for uncommitted changes; if none are | |
3821 | found, the working directory is updated to the specified |
|
3822 | found, the working directory is updated to the specified | |
3822 | changeset. |
|
3823 | changeset. | |
3823 |
|
3824 | |||
3824 | The following rules apply when the working directory contains |
|
3825 | The following rules apply when the working directory contains | |
3825 | uncommitted changes: |
|
3826 | uncommitted changes: | |
3826 |
|
3827 | |||
3827 | 1. If neither -c/--check nor -C/--clean is specified, and if |
|
3828 | 1. If neither -c/--check nor -C/--clean is specified, and if | |
3828 | the requested changeset is an ancestor or descendant of |
|
3829 | the requested changeset is an ancestor or descendant of | |
3829 | the working directory's parent, the uncommitted changes |
|
3830 | the working directory's parent, the uncommitted changes | |
3830 | are merged into the requested changeset and the merged |
|
3831 | are merged into the requested changeset and the merged | |
3831 | result is left uncommitted. If the requested changeset is |
|
3832 | result is left uncommitted. If the requested changeset is | |
3832 | not an ancestor or descendant (that is, it is on another |
|
3833 | not an ancestor or descendant (that is, it is on another | |
3833 | branch), the update is aborted and the uncommitted changes |
|
3834 | branch), the update is aborted and the uncommitted changes | |
3834 | are preserved. |
|
3835 | are preserved. | |
3835 |
|
3836 | |||
3836 | 2. With the -c/--check option, the update is aborted and the |
|
3837 | 2. With the -c/--check option, the update is aborted and the | |
3837 | uncommitted changes are preserved. |
|
3838 | uncommitted changes are preserved. | |
3838 |
|
3839 | |||
3839 | 3. With the -C/--clean option, uncommitted changes are discarded and |
|
3840 | 3. With the -C/--clean option, uncommitted changes are discarded and | |
3840 | the working directory is updated to the requested changeset. |
|
3841 | the working directory is updated to the requested changeset. | |
3841 |
|
3842 | |||
3842 | Use null as the changeset to remove the working directory (like |
|
3843 | Use null as the changeset to remove the working directory (like | |
3843 | :hg:`clone -U`). |
|
3844 | :hg:`clone -U`). | |
3844 |
|
3845 | |||
3845 | If you want to update just one file to an older changeset, use |
|
3846 | If you want to update just one file to an older changeset, use | |
3846 | :hg:`revert`. |
|
3847 | :hg:`revert`. | |
3847 |
|
3848 | |||
3848 | See :hg:`help dates` for a list of formats valid for -d/--date. |
|
3849 | See :hg:`help dates` for a list of formats valid for -d/--date. | |
3849 |
|
3850 | |||
3850 | Returns 0 on success, 1 if there are unresolved files. |
|
3851 | Returns 0 on success, 1 if there are unresolved files. | |
3851 | """ |
|
3852 | """ | |
3852 | if rev and node: |
|
3853 | if rev and node: | |
3853 | raise util.Abort(_("please specify just one revision")) |
|
3854 | raise util.Abort(_("please specify just one revision")) | |
3854 |
|
3855 | |||
3855 | if not rev: |
|
3856 | if not rev: | |
3856 | rev = node |
|
3857 | rev = node | |
3857 |
|
3858 | |||
3858 | rev = cmdutil.revsingle(repo, rev, rev).rev() |
|
3859 | rev = cmdutil.revsingle(repo, rev, rev).rev() | |
3859 |
|
3860 | |||
3860 | if check and clean: |
|
3861 | if check and clean: | |
3861 | raise util.Abort(_("cannot specify both -c/--check and -C/--clean")) |
|
3862 | raise util.Abort(_("cannot specify both -c/--check and -C/--clean")) | |
3862 |
|
3863 | |||
3863 | if check: |
|
3864 | if check: | |
3864 | # we could use dirty() but we can ignore merge and branch trivia |
|
3865 | # we could use dirty() but we can ignore merge and branch trivia | |
3865 | c = repo[None] |
|
3866 | c = repo[None] | |
3866 | if c.modified() or c.added() or c.removed(): |
|
3867 | if c.modified() or c.added() or c.removed(): | |
3867 | raise util.Abort(_("uncommitted local changes")) |
|
3868 | raise util.Abort(_("uncommitted local changes")) | |
3868 |
|
3869 | |||
3869 | if date: |
|
3870 | if date: | |
3870 | if rev: |
|
3871 | if rev: | |
3871 | raise util.Abort(_("you can't specify a revision and a date")) |
|
3872 | raise util.Abort(_("you can't specify a revision and a date")) | |
3872 | rev = cmdutil.finddate(ui, repo, date) |
|
3873 | rev = cmdutil.finddate(ui, repo, date) | |
3873 |
|
3874 | |||
3874 | if clean or check: |
|
3875 | if clean or check: | |
3875 | return hg.clean(repo, rev) |
|
3876 | return hg.clean(repo, rev) | |
3876 | else: |
|
3877 | else: | |
3877 | return hg.update(repo, rev) |
|
3878 | return hg.update(repo, rev) | |
3878 |
|
3879 | |||
3879 | def verify(ui, repo): |
|
3880 | def verify(ui, repo): | |
3880 | """verify the integrity of the repository |
|
3881 | """verify the integrity of the repository | |
3881 |
|
3882 | |||
3882 | Verify the integrity of the current repository. |
|
3883 | Verify the integrity of the current repository. | |
3883 |
|
3884 | |||
3884 | This will perform an extensive check of the repository's |
|
3885 | This will perform an extensive check of the repository's | |
3885 | integrity, validating the hashes and checksums of each entry in |
|
3886 | integrity, validating the hashes and checksums of each entry in | |
3886 | the changelog, manifest, and tracked files, as well as the |
|
3887 | the changelog, manifest, and tracked files, as well as the | |
3887 | integrity of their crosslinks and indices. |
|
3888 | integrity of their crosslinks and indices. | |
3888 |
|
3889 | |||
3889 | Returns 0 on success, 1 if errors are encountered. |
|
3890 | Returns 0 on success, 1 if errors are encountered. | |
3890 | """ |
|
3891 | """ | |
3891 | return hg.verify(repo) |
|
3892 | return hg.verify(repo) | |
3892 |
|
3893 | |||
3893 | def version_(ui): |
|
3894 | def version_(ui): | |
3894 | """output version and copyright information""" |
|
3895 | """output version and copyright information""" | |
3895 | ui.write(_("Mercurial Distributed SCM (version %s)\n") |
|
3896 | ui.write(_("Mercurial Distributed SCM (version %s)\n") | |
3896 | % util.version()) |
|
3897 | % util.version()) | |
3897 | ui.status(_( |
|
3898 | ui.status(_( | |
3898 | "(see http://mercurial.selenic.com for more information)\n" |
|
3899 | "(see http://mercurial.selenic.com for more information)\n" | |
3899 | "\nCopyright (C) 2005-2010 Matt Mackall and others\n" |
|
3900 | "\nCopyright (C) 2005-2010 Matt Mackall and others\n" | |
3900 | "This is free software; see the source for copying conditions. " |
|
3901 | "This is free software; see the source for copying conditions. " | |
3901 | "There is NO\nwarranty; " |
|
3902 | "There is NO\nwarranty; " | |
3902 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
3903 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | |
3903 | )) |
|
3904 | )) | |
3904 |
|
3905 | |||
3905 | # Command options and aliases are listed here, alphabetically |
|
3906 | # Command options and aliases are listed here, alphabetically | |
3906 |
|
3907 | |||
3907 | globalopts = [ |
|
3908 | globalopts = [ | |
3908 | ('R', 'repository', '', |
|
3909 | ('R', 'repository', '', | |
3909 | _('repository root directory or name of overlay bundle file'), |
|
3910 | _('repository root directory or name of overlay bundle file'), | |
3910 | _('REPO')), |
|
3911 | _('REPO')), | |
3911 | ('', 'cwd', '', |
|
3912 | ('', 'cwd', '', | |
3912 | _('change working directory'), _('DIR')), |
|
3913 | _('change working directory'), _('DIR')), | |
3913 | ('y', 'noninteractive', None, |
|
3914 | ('y', 'noninteractive', None, | |
3914 | _('do not prompt, assume \'yes\' for any required answers')), |
|
3915 | _('do not prompt, assume \'yes\' for any required answers')), | |
3915 | ('q', 'quiet', None, _('suppress output')), |
|
3916 | ('q', 'quiet', None, _('suppress output')), | |
3916 | ('v', 'verbose', None, _('enable additional output')), |
|
3917 | ('v', 'verbose', None, _('enable additional output')), | |
3917 | ('', 'config', [], |
|
3918 | ('', 'config', [], | |
3918 | _('set/override config option (use \'section.name=value\')'), |
|
3919 | _('set/override config option (use \'section.name=value\')'), | |
3919 | _('CONFIG')), |
|
3920 | _('CONFIG')), | |
3920 | ('', 'debug', None, _('enable debugging output')), |
|
3921 | ('', 'debug', None, _('enable debugging output')), | |
3921 | ('', 'debugger', None, _('start debugger')), |
|
3922 | ('', 'debugger', None, _('start debugger')), | |
3922 | ('', 'encoding', encoding.encoding, _('set the charset encoding'), |
|
3923 | ('', 'encoding', encoding.encoding, _('set the charset encoding'), | |
3923 | _('ENCODE')), |
|
3924 | _('ENCODE')), | |
3924 | ('', 'encodingmode', encoding.encodingmode, |
|
3925 | ('', 'encodingmode', encoding.encodingmode, | |
3925 | _('set the charset encoding mode'), _('MODE')), |
|
3926 | _('set the charset encoding mode'), _('MODE')), | |
3926 | ('', 'traceback', None, _('always print a traceback on exception')), |
|
3927 | ('', 'traceback', None, _('always print a traceback on exception')), | |
3927 | ('', 'time', None, _('time how long the command takes')), |
|
3928 | ('', 'time', None, _('time how long the command takes')), | |
3928 | ('', 'profile', None, _('print command execution profile')), |
|
3929 | ('', 'profile', None, _('print command execution profile')), | |
3929 | ('', 'version', None, _('output version information and exit')), |
|
3930 | ('', 'version', None, _('output version information and exit')), | |
3930 | ('h', 'help', None, _('display help and exit')), |
|
3931 | ('h', 'help', None, _('display help and exit')), | |
3931 | ] |
|
3932 | ] | |
3932 |
|
3933 | |||
3933 | dryrunopts = [('n', 'dry-run', None, |
|
3934 | dryrunopts = [('n', 'dry-run', None, | |
3934 | _('do not perform actions, just print output'))] |
|
3935 | _('do not perform actions, just print output'))] | |
3935 |
|
3936 | |||
3936 | remoteopts = [ |
|
3937 | remoteopts = [ | |
3937 | ('e', 'ssh', '', |
|
3938 | ('e', 'ssh', '', | |
3938 | _('specify ssh command to use'), _('CMD')), |
|
3939 | _('specify ssh command to use'), _('CMD')), | |
3939 | ('', 'remotecmd', '', |
|
3940 | ('', 'remotecmd', '', | |
3940 | _('specify hg command to run on the remote side'), _('CMD')), |
|
3941 | _('specify hg command to run on the remote side'), _('CMD')), | |
3941 | ] |
|
3942 | ] | |
3942 |
|
3943 | |||
3943 | walkopts = [ |
|
3944 | walkopts = [ | |
3944 | ('I', 'include', [], |
|
3945 | ('I', 'include', [], | |
3945 | _('include names matching the given patterns'), _('PATTERN')), |
|
3946 | _('include names matching the given patterns'), _('PATTERN')), | |
3946 | ('X', 'exclude', [], |
|
3947 | ('X', 'exclude', [], | |
3947 | _('exclude names matching the given patterns'), _('PATTERN')), |
|
3948 | _('exclude names matching the given patterns'), _('PATTERN')), | |
3948 | ] |
|
3949 | ] | |
3949 |
|
3950 | |||
3950 | commitopts = [ |
|
3951 | commitopts = [ | |
3951 | ('m', 'message', '', |
|
3952 | ('m', 'message', '', | |
3952 | _('use text as commit message'), _('TEXT')), |
|
3953 | _('use text as commit message'), _('TEXT')), | |
3953 | ('l', 'logfile', '', |
|
3954 | ('l', 'logfile', '', | |
3954 | _('read commit message from file'), _('FILE')), |
|
3955 | _('read commit message from file'), _('FILE')), | |
3955 | ] |
|
3956 | ] | |
3956 |
|
3957 | |||
3957 | commitopts2 = [ |
|
3958 | commitopts2 = [ | |
3958 | ('d', 'date', '', |
|
3959 | ('d', 'date', '', | |
3959 | _('record datecode as commit date'), _('DATE')), |
|
3960 | _('record datecode as commit date'), _('DATE')), | |
3960 | ('u', 'user', '', |
|
3961 | ('u', 'user', '', | |
3961 | _('record the specified user as committer'), _('USER')), |
|
3962 | _('record the specified user as committer'), _('USER')), | |
3962 | ] |
|
3963 | ] | |
3963 |
|
3964 | |||
3964 | templateopts = [ |
|
3965 | templateopts = [ | |
3965 | ('', 'style', '', |
|
3966 | ('', 'style', '', | |
3966 | _('display using template map file'), _('STYLE')), |
|
3967 | _('display using template map file'), _('STYLE')), | |
3967 | ('', 'template', '', |
|
3968 | ('', 'template', '', | |
3968 | _('display with template'), _('TEMPLATE')), |
|
3969 | _('display with template'), _('TEMPLATE')), | |
3969 | ] |
|
3970 | ] | |
3970 |
|
3971 | |||
3971 | logopts = [ |
|
3972 | logopts = [ | |
3972 | ('p', 'patch', None, _('show patch')), |
|
3973 | ('p', 'patch', None, _('show patch')), | |
3973 | ('g', 'git', None, _('use git extended diff format')), |
|
3974 | ('g', 'git', None, _('use git extended diff format')), | |
3974 | ('l', 'limit', '', |
|
3975 | ('l', 'limit', '', | |
3975 | _('limit number of changes displayed'), _('NUM')), |
|
3976 | _('limit number of changes displayed'), _('NUM')), | |
3976 | ('M', 'no-merges', None, _('do not show merges')), |
|
3977 | ('M', 'no-merges', None, _('do not show merges')), | |
3977 | ('', 'stat', None, _('output diffstat-style summary of changes')), |
|
3978 | ('', 'stat', None, _('output diffstat-style summary of changes')), | |
3978 | ] + templateopts |
|
3979 | ] + templateopts | |
3979 |
|
3980 | |||
3980 | diffopts = [ |
|
3981 | diffopts = [ | |
3981 | ('a', 'text', None, _('treat all files as text')), |
|
3982 | ('a', 'text', None, _('treat all files as text')), | |
3982 | ('g', 'git', None, _('use git extended diff format')), |
|
3983 | ('g', 'git', None, _('use git extended diff format')), | |
3983 | ('', 'nodates', None, _('omit dates from diff headers')) |
|
3984 | ('', 'nodates', None, _('omit dates from diff headers')) | |
3984 | ] |
|
3985 | ] | |
3985 |
|
3986 | |||
3986 | diffopts2 = [ |
|
3987 | diffopts2 = [ | |
3987 | ('p', 'show-function', None, _('show which function each change is in')), |
|
3988 | ('p', 'show-function', None, _('show which function each change is in')), | |
3988 | ('', 'reverse', None, _('produce a diff that undoes the changes')), |
|
3989 | ('', 'reverse', None, _('produce a diff that undoes the changes')), | |
3989 | ('w', 'ignore-all-space', None, |
|
3990 | ('w', 'ignore-all-space', None, | |
3990 | _('ignore white space when comparing lines')), |
|
3991 | _('ignore white space when comparing lines')), | |
3991 | ('b', 'ignore-space-change', None, |
|
3992 | ('b', 'ignore-space-change', None, | |
3992 | _('ignore changes in the amount of white space')), |
|
3993 | _('ignore changes in the amount of white space')), | |
3993 | ('B', 'ignore-blank-lines', None, |
|
3994 | ('B', 'ignore-blank-lines', None, | |
3994 | _('ignore changes whose lines are all blank')), |
|
3995 | _('ignore changes whose lines are all blank')), | |
3995 | ('U', 'unified', '', |
|
3996 | ('U', 'unified', '', | |
3996 | _('number of lines of context to show'), _('NUM')), |
|
3997 | _('number of lines of context to show'), _('NUM')), | |
3997 | ('', 'stat', None, _('output diffstat-style summary of changes')), |
|
3998 | ('', 'stat', None, _('output diffstat-style summary of changes')), | |
3998 | ] |
|
3999 | ] | |
3999 |
|
4000 | |||
4000 | similarityopts = [ |
|
4001 | similarityopts = [ | |
4001 | ('s', 'similarity', '', |
|
4002 | ('s', 'similarity', '', | |
4002 | _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY')) |
|
4003 | _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY')) | |
4003 | ] |
|
4004 | ] | |
4004 |
|
4005 | |||
4005 | subrepoopts = [ |
|
4006 | subrepoopts = [ | |
4006 | ('S', 'subrepos', None, |
|
4007 | ('S', 'subrepos', None, | |
4007 | _('recurse into subrepositories')) |
|
4008 | _('recurse into subrepositories')) | |
4008 | ] |
|
4009 | ] | |
4009 |
|
4010 | |||
4010 | table = { |
|
4011 | table = { | |
4011 | "^add": (add, walkopts + subrepoopts + dryrunopts, |
|
4012 | "^add": (add, walkopts + subrepoopts + dryrunopts, | |
4012 | _('[OPTION]... [FILE]...')), |
|
4013 | _('[OPTION]... [FILE]...')), | |
4013 | "addremove": |
|
4014 | "addremove": | |
4014 | (addremove, similarityopts + walkopts + dryrunopts, |
|
4015 | (addremove, similarityopts + walkopts + dryrunopts, | |
4015 | _('[OPTION]... [FILE]...')), |
|
4016 | _('[OPTION]... [FILE]...')), | |
4016 | "^annotate|blame": |
|
4017 | "^annotate|blame": | |
4017 | (annotate, |
|
4018 | (annotate, | |
4018 | [('r', 'rev', '', |
|
4019 | [('r', 'rev', '', | |
4019 | _('annotate the specified revision'), _('REV')), |
|
4020 | _('annotate the specified revision'), _('REV')), | |
4020 | ('', 'follow', None, |
|
4021 | ('', 'follow', None, | |
4021 | _('follow copies/renames and list the filename (DEPRECATED)')), |
|
4022 | _('follow copies/renames and list the filename (DEPRECATED)')), | |
4022 | ('', 'no-follow', None, _("don't follow copies and renames")), |
|
4023 | ('', 'no-follow', None, _("don't follow copies and renames")), | |
4023 | ('a', 'text', None, _('treat all files as text')), |
|
4024 | ('a', 'text', None, _('treat all files as text')), | |
4024 | ('u', 'user', None, _('list the author (long with -v)')), |
|
4025 | ('u', 'user', None, _('list the author (long with -v)')), | |
4025 | ('f', 'file', None, _('list the filename')), |
|
4026 | ('f', 'file', None, _('list the filename')), | |
4026 | ('d', 'date', None, _('list the date (short with -q)')), |
|
4027 | ('d', 'date', None, _('list the date (short with -q)')), | |
4027 | ('n', 'number', None, _('list the revision number (default)')), |
|
4028 | ('n', 'number', None, _('list the revision number (default)')), | |
4028 | ('c', 'changeset', None, _('list the changeset')), |
|
4029 | ('c', 'changeset', None, _('list the changeset')), | |
4029 | ('l', 'line-number', None, |
|
4030 | ('l', 'line-number', None, | |
4030 | _('show line number at the first appearance')) |
|
4031 | _('show line number at the first appearance')) | |
4031 | ] + walkopts, |
|
4032 | ] + walkopts, | |
4032 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')), |
|
4033 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')), | |
4033 | "archive": |
|
4034 | "archive": | |
4034 | (archive, |
|
4035 | (archive, | |
4035 | [('', 'no-decode', None, _('do not pass files through decoders')), |
|
4036 | [('', 'no-decode', None, _('do not pass files through decoders')), | |
4036 | ('p', 'prefix', '', |
|
4037 | ('p', 'prefix', '', | |
4037 | _('directory prefix for files in archive'), _('PREFIX')), |
|
4038 | _('directory prefix for files in archive'), _('PREFIX')), | |
4038 | ('r', 'rev', '', |
|
4039 | ('r', 'rev', '', | |
4039 | _('revision to distribute'), _('REV')), |
|
4040 | _('revision to distribute'), _('REV')), | |
4040 | ('t', 'type', '', |
|
4041 | ('t', 'type', '', | |
4041 | _('type of distribution to create'), _('TYPE')), |
|
4042 | _('type of distribution to create'), _('TYPE')), | |
4042 | ] + subrepoopts + walkopts, |
|
4043 | ] + subrepoopts + walkopts, | |
4043 | _('[OPTION]... DEST')), |
|
4044 | _('[OPTION]... DEST')), | |
4044 | "backout": |
|
4045 | "backout": | |
4045 | (backout, |
|
4046 | (backout, | |
4046 | [('', 'merge', None, |
|
4047 | [('', 'merge', None, | |
4047 | _('merge with old dirstate parent after backout')), |
|
4048 | _('merge with old dirstate parent after backout')), | |
4048 | ('', 'parent', '', |
|
4049 | ('', 'parent', '', | |
4049 | _('parent to choose when backing out merge'), _('REV')), |
|
4050 | _('parent to choose when backing out merge'), _('REV')), | |
4050 | ('t', 'tool', '', |
|
4051 | ('t', 'tool', '', | |
4051 | _('specify merge tool')), |
|
4052 | _('specify merge tool')), | |
4052 | ('r', 'rev', '', |
|
4053 | ('r', 'rev', '', | |
4053 | _('revision to backout'), _('REV')), |
|
4054 | _('revision to backout'), _('REV')), | |
4054 | ] + walkopts + commitopts + commitopts2, |
|
4055 | ] + walkopts + commitopts + commitopts2, | |
4055 | _('[OPTION]... [-r] REV')), |
|
4056 | _('[OPTION]... [-r] REV')), | |
4056 | "bisect": |
|
4057 | "bisect": | |
4057 | (bisect, |
|
4058 | (bisect, | |
4058 | [('r', 'reset', False, _('reset bisect state')), |
|
4059 | [('r', 'reset', False, _('reset bisect state')), | |
4059 | ('g', 'good', False, _('mark changeset good')), |
|
4060 | ('g', 'good', False, _('mark changeset good')), | |
4060 | ('b', 'bad', False, _('mark changeset bad')), |
|
4061 | ('b', 'bad', False, _('mark changeset bad')), | |
4061 | ('s', 'skip', False, _('skip testing changeset')), |
|
4062 | ('s', 'skip', False, _('skip testing changeset')), | |
4062 | ('c', 'command', '', |
|
4063 | ('c', 'command', '', | |
4063 | _('use command to check changeset state'), _('CMD')), |
|
4064 | _('use command to check changeset state'), _('CMD')), | |
4064 | ('U', 'noupdate', False, _('do not update to target'))], |
|
4065 | ('U', 'noupdate', False, _('do not update to target'))], | |
4065 | _("[-gbsr] [-U] [-c CMD] [REV]")), |
|
4066 | _("[-gbsr] [-U] [-c CMD] [REV]")), | |
4066 | "branch": |
|
4067 | "branch": | |
4067 | (branch, |
|
4068 | (branch, | |
4068 | [('f', 'force', None, |
|
4069 | [('f', 'force', None, | |
4069 | _('set branch name even if it shadows an existing branch')), |
|
4070 | _('set branch name even if it shadows an existing branch')), | |
4070 | ('C', 'clean', None, _('reset branch name to parent branch name'))], |
|
4071 | ('C', 'clean', None, _('reset branch name to parent branch name'))], | |
4071 | _('[-fC] [NAME]')), |
|
4072 | _('[-fC] [NAME]')), | |
4072 | "branches": |
|
4073 | "branches": | |
4073 | (branches, |
|
4074 | (branches, | |
4074 | [('a', 'active', False, |
|
4075 | [('a', 'active', False, | |
4075 | _('show only branches that have unmerged heads')), |
|
4076 | _('show only branches that have unmerged heads')), | |
4076 | ('c', 'closed', False, |
|
4077 | ('c', 'closed', False, | |
4077 | _('show normal and closed branches'))], |
|
4078 | _('show normal and closed branches'))], | |
4078 | _('[-ac]')), |
|
4079 | _('[-ac]')), | |
4079 | "bundle": |
|
4080 | "bundle": | |
4080 | (bundle, |
|
4081 | (bundle, | |
4081 | [('f', 'force', None, |
|
4082 | [('f', 'force', None, | |
4082 | _('run even when the destination is unrelated')), |
|
4083 | _('run even when the destination is unrelated')), | |
4083 | ('r', 'rev', [], |
|
4084 | ('r', 'rev', [], | |
4084 | _('a changeset intended to be added to the destination'), |
|
4085 | _('a changeset intended to be added to the destination'), | |
4085 | _('REV')), |
|
4086 | _('REV')), | |
4086 | ('b', 'branch', [], |
|
4087 | ('b', 'branch', [], | |
4087 | _('a specific branch you would like to bundle'), |
|
4088 | _('a specific branch you would like to bundle'), | |
4088 | _('BRANCH')), |
|
4089 | _('BRANCH')), | |
4089 | ('', 'base', [], |
|
4090 | ('', 'base', [], | |
4090 | _('a base changeset assumed to be available at the destination'), |
|
4091 | _('a base changeset assumed to be available at the destination'), | |
4091 | _('REV')), |
|
4092 | _('REV')), | |
4092 | ('a', 'all', None, _('bundle all changesets in the repository')), |
|
4093 | ('a', 'all', None, _('bundle all changesets in the repository')), | |
4093 | ('t', 'type', 'bzip2', |
|
4094 | ('t', 'type', 'bzip2', | |
4094 | _('bundle compression type to use'), _('TYPE')), |
|
4095 | _('bundle compression type to use'), _('TYPE')), | |
4095 | ] + remoteopts, |
|
4096 | ] + remoteopts, | |
4096 | _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')), |
|
4097 | _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')), | |
4097 | "cat": |
|
4098 | "cat": | |
4098 | (cat, |
|
4099 | (cat, | |
4099 | [('o', 'output', '', |
|
4100 | [('o', 'output', '', | |
4100 | _('print output to file with formatted name'), _('FORMAT')), |
|
4101 | _('print output to file with formatted name'), _('FORMAT')), | |
4101 | ('r', 'rev', '', |
|
4102 | ('r', 'rev', '', | |
4102 | _('print the given revision'), _('REV')), |
|
4103 | _('print the given revision'), _('REV')), | |
4103 | ('', 'decode', None, _('apply any matching decode filter')), |
|
4104 | ('', 'decode', None, _('apply any matching decode filter')), | |
4104 | ] + walkopts, |
|
4105 | ] + walkopts, | |
4105 | _('[OPTION]... FILE...')), |
|
4106 | _('[OPTION]... FILE...')), | |
4106 | "^clone": |
|
4107 | "^clone": | |
4107 | (clone, |
|
4108 | (clone, | |
4108 | [('U', 'noupdate', None, |
|
4109 | [('U', 'noupdate', None, | |
4109 | _('the clone will include an empty working copy (only a repository)')), |
|
4110 | _('the clone will include an empty working copy (only a repository)')), | |
4110 | ('u', 'updaterev', '', |
|
4111 | ('u', 'updaterev', '', | |
4111 | _('revision, tag or branch to check out'), _('REV')), |
|
4112 | _('revision, tag or branch to check out'), _('REV')), | |
4112 | ('r', 'rev', [], |
|
4113 | ('r', 'rev', [], | |
4113 | _('include the specified changeset'), _('REV')), |
|
4114 | _('include the specified changeset'), _('REV')), | |
4114 | ('b', 'branch', [], |
|
4115 | ('b', 'branch', [], | |
4115 | _('clone only the specified branch'), _('BRANCH')), |
|
4116 | _('clone only the specified branch'), _('BRANCH')), | |
4116 | ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
4117 | ('', 'pull', None, _('use pull protocol to copy metadata')), | |
4117 | ('', 'uncompressed', None, |
|
4118 | ('', 'uncompressed', None, | |
4118 | _('use uncompressed transfer (fast over LAN)')), |
|
4119 | _('use uncompressed transfer (fast over LAN)')), | |
4119 | ] + remoteopts, |
|
4120 | ] + remoteopts, | |
4120 | _('[OPTION]... SOURCE [DEST]')), |
|
4121 | _('[OPTION]... SOURCE [DEST]')), | |
4121 | "^commit|ci": |
|
4122 | "^commit|ci": | |
4122 | (commit, |
|
4123 | (commit, | |
4123 | [('A', 'addremove', None, |
|
4124 | [('A', 'addremove', None, | |
4124 | _('mark new/missing files as added/removed before committing')), |
|
4125 | _('mark new/missing files as added/removed before committing')), | |
4125 | ('', 'close-branch', None, |
|
4126 | ('', 'close-branch', None, | |
4126 | _('mark a branch as closed, hiding it from the branch list')), |
|
4127 | _('mark a branch as closed, hiding it from the branch list')), | |
4127 | ] + walkopts + commitopts + commitopts2, |
|
4128 | ] + walkopts + commitopts + commitopts2, | |
4128 | _('[OPTION]... [FILE]...')), |
|
4129 | _('[OPTION]... [FILE]...')), | |
4129 | "copy|cp": |
|
4130 | "copy|cp": | |
4130 | (copy, |
|
4131 | (copy, | |
4131 | [('A', 'after', None, _('record a copy that has already occurred')), |
|
4132 | [('A', 'after', None, _('record a copy that has already occurred')), | |
4132 | ('f', 'force', None, |
|
4133 | ('f', 'force', None, | |
4133 | _('forcibly copy over an existing managed file')), |
|
4134 | _('forcibly copy over an existing managed file')), | |
4134 | ] + walkopts + dryrunopts, |
|
4135 | ] + walkopts + dryrunopts, | |
4135 | _('[OPTION]... [SOURCE]... DEST')), |
|
4136 | _('[OPTION]... [SOURCE]... DEST')), | |
4136 | "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')), |
|
4137 | "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')), | |
4137 | "debugbuilddag": |
|
4138 | "debugbuilddag": | |
4138 | (debugbuilddag, |
|
4139 | (debugbuilddag, | |
4139 | [('m', 'mergeable-file', None, _('add single file mergeable changes')), |
|
4140 | [('m', 'mergeable-file', None, _('add single file mergeable changes')), | |
4140 | ('a', 'appended-file', None, _('add single file all revs append to')), |
|
4141 | ('a', 'appended-file', None, _('add single file all revs append to')), | |
4141 | ('o', 'overwritten-file', None, _('add single file all revs overwrite')), |
|
4142 | ('o', 'overwritten-file', None, _('add single file all revs overwrite')), | |
4142 | ('n', 'new-file', None, _('add new file at each rev')), |
|
4143 | ('n', 'new-file', None, _('add new file at each rev')), | |
4143 | ], |
|
4144 | ], | |
4144 | _('[OPTION]... TEXT')), |
|
4145 | _('[OPTION]... TEXT')), | |
4145 | "debugcheckstate": (debugcheckstate, [], ''), |
|
4146 | "debugcheckstate": (debugcheckstate, [], ''), | |
4146 | "debugcommands": (debugcommands, [], _('[COMMAND]')), |
|
4147 | "debugcommands": (debugcommands, [], _('[COMMAND]')), | |
4147 | "debugcomplete": |
|
4148 | "debugcomplete": | |
4148 | (debugcomplete, |
|
4149 | (debugcomplete, | |
4149 | [('o', 'options', None, _('show the command options'))], |
|
4150 | [('o', 'options', None, _('show the command options'))], | |
4150 | _('[-o] CMD')), |
|
4151 | _('[-o] CMD')), | |
4151 | "debugdag": |
|
4152 | "debugdag": | |
4152 | (debugdag, |
|
4153 | (debugdag, | |
4153 | [('t', 'tags', None, _('use tags as labels')), |
|
4154 | [('t', 'tags', None, _('use tags as labels')), | |
4154 | ('b', 'branches', None, _('annotate with branch names')), |
|
4155 | ('b', 'branches', None, _('annotate with branch names')), | |
4155 | ('', 'dots', None, _('use dots for runs')), |
|
4156 | ('', 'dots', None, _('use dots for runs')), | |
4156 | ('s', 'spaces', None, _('separate elements by spaces')), |
|
4157 | ('s', 'spaces', None, _('separate elements by spaces')), | |
4157 | ], |
|
4158 | ], | |
4158 | _('[OPTION]... [FILE [REV]...]')), |
|
4159 | _('[OPTION]... [FILE [REV]...]')), | |
4159 | "debugdate": |
|
4160 | "debugdate": | |
4160 | (debugdate, |
|
4161 | (debugdate, | |
4161 | [('e', 'extended', None, _('try extended date formats'))], |
|
4162 | [('e', 'extended', None, _('try extended date formats'))], | |
4162 | _('[-e] DATE [RANGE]')), |
|
4163 | _('[-e] DATE [RANGE]')), | |
4163 | "debugdata": (debugdata, [], _('FILE REV')), |
|
4164 | "debugdata": (debugdata, [], _('FILE REV')), | |
4164 | "debugfsinfo": (debugfsinfo, [], _('[PATH]')), |
|
4165 | "debugfsinfo": (debugfsinfo, [], _('[PATH]')), | |
4165 | "debugindex": (debugindex, |
|
4166 | "debugindex": (debugindex, | |
4166 | [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
|
4167 | [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | |
4167 | _('FILE')), |
|
4168 | _('FILE')), | |
4168 | "debugindexdot": (debugindexdot, [], _('FILE')), |
|
4169 | "debugindexdot": (debugindexdot, [], _('FILE')), | |
4169 | "debuginstall": (debuginstall, [], ''), |
|
4170 | "debuginstall": (debuginstall, [], ''), | |
4170 | "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')), |
|
4171 | "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')), | |
4171 | "debugrebuildstate": |
|
4172 | "debugrebuildstate": | |
4172 | (debugrebuildstate, |
|
4173 | (debugrebuildstate, | |
4173 | [('r', 'rev', '', |
|
4174 | [('r', 'rev', '', | |
4174 | _('revision to rebuild to'), _('REV'))], |
|
4175 | _('revision to rebuild to'), _('REV'))], | |
4175 | _('[-r REV] [REV]')), |
|
4176 | _('[-r REV] [REV]')), | |
4176 | "debugrename": |
|
4177 | "debugrename": | |
4177 | (debugrename, |
|
4178 | (debugrename, | |
4178 | [('r', 'rev', '', |
|
4179 | [('r', 'rev', '', | |
4179 | _('revision to debug'), _('REV'))], |
|
4180 | _('revision to debug'), _('REV'))], | |
4180 | _('[-r REV] FILE')), |
|
4181 | _('[-r REV] FILE')), | |
4181 | "debugrevspec": |
|
4182 | "debugrevspec": | |
4182 | (debugrevspec, [], ('REVSPEC')), |
|
4183 | (debugrevspec, [], ('REVSPEC')), | |
4183 | "debugsetparents": |
|
4184 | "debugsetparents": | |
4184 | (debugsetparents, [], _('REV1 [REV2]')), |
|
4185 | (debugsetparents, [], _('REV1 [REV2]')), | |
4185 | "debugstate": |
|
4186 | "debugstate": | |
4186 | (debugstate, |
|
4187 | (debugstate, | |
4187 | [('', 'nodates', None, _('do not display the saved mtime'))], |
|
4188 | [('', 'nodates', None, _('do not display the saved mtime'))], | |
4188 | _('[OPTION]...')), |
|
4189 | _('[OPTION]...')), | |
4189 | "debugsub": |
|
4190 | "debugsub": | |
4190 | (debugsub, |
|
4191 | (debugsub, | |
4191 | [('r', 'rev', '', |
|
4192 | [('r', 'rev', '', | |
4192 | _('revision to check'), _('REV'))], |
|
4193 | _('revision to check'), _('REV'))], | |
4193 | _('[-r REV] [REV]')), |
|
4194 | _('[-r REV] [REV]')), | |
4194 | "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')), |
|
4195 | "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')), | |
4195 | "^diff": |
|
4196 | "^diff": | |
4196 | (diff, |
|
4197 | (diff, | |
4197 | [('r', 'rev', [], |
|
4198 | [('r', 'rev', [], | |
4198 | _('revision'), _('REV')), |
|
4199 | _('revision'), _('REV')), | |
4199 | ('c', 'change', '', |
|
4200 | ('c', 'change', '', | |
4200 | _('change made by revision'), _('REV')) |
|
4201 | _('change made by revision'), _('REV')) | |
4201 | ] + diffopts + diffopts2 + walkopts + subrepoopts, |
|
4202 | ] + diffopts + diffopts2 + walkopts + subrepoopts, | |
4202 | _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')), |
|
4203 | _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')), | |
4203 | "^export": |
|
4204 | "^export": | |
4204 | (export, |
|
4205 | (export, | |
4205 | [('o', 'output', '', |
|
4206 | [('o', 'output', '', | |
4206 | _('print output to file with formatted name'), _('FORMAT')), |
|
4207 | _('print output to file with formatted name'), _('FORMAT')), | |
4207 | ('', 'switch-parent', None, _('diff against the second parent')), |
|
4208 | ('', 'switch-parent', None, _('diff against the second parent')), | |
4208 | ('r', 'rev', [], |
|
4209 | ('r', 'rev', [], | |
4209 | _('revisions to export'), _('REV')), |
|
4210 | _('revisions to export'), _('REV')), | |
4210 | ] + diffopts, |
|
4211 | ] + diffopts, | |
4211 | _('[OPTION]... [-o OUTFILESPEC] REV...')), |
|
4212 | _('[OPTION]... [-o OUTFILESPEC] REV...')), | |
4212 | "^forget": |
|
4213 | "^forget": | |
4213 | (forget, |
|
4214 | (forget, | |
4214 | [] + walkopts, |
|
4215 | [] + walkopts, | |
4215 | _('[OPTION]... FILE...')), |
|
4216 | _('[OPTION]... FILE...')), | |
4216 | "grep": |
|
4217 | "grep": | |
4217 | (grep, |
|
4218 | (grep, | |
4218 | [('0', 'print0', None, _('end fields with NUL')), |
|
4219 | [('0', 'print0', None, _('end fields with NUL')), | |
4219 | ('', 'all', None, _('print all revisions that match')), |
|
4220 | ('', 'all', None, _('print all revisions that match')), | |
4220 | ('f', 'follow', None, |
|
4221 | ('f', 'follow', None, | |
4221 | _('follow changeset history,' |
|
4222 | _('follow changeset history,' | |
4222 | ' or file history across copies and renames')), |
|
4223 | ' or file history across copies and renames')), | |
4223 | ('i', 'ignore-case', None, _('ignore case when matching')), |
|
4224 | ('i', 'ignore-case', None, _('ignore case when matching')), | |
4224 | ('l', 'files-with-matches', None, |
|
4225 | ('l', 'files-with-matches', None, | |
4225 | _('print only filenames and revisions that match')), |
|
4226 | _('print only filenames and revisions that match')), | |
4226 | ('n', 'line-number', None, _('print matching line numbers')), |
|
4227 | ('n', 'line-number', None, _('print matching line numbers')), | |
4227 | ('r', 'rev', [], |
|
4228 | ('r', 'rev', [], | |
4228 | _('only search files changed within revision range'), _('REV')), |
|
4229 | _('only search files changed within revision range'), _('REV')), | |
4229 | ('u', 'user', None, _('list the author (long with -v)')), |
|
4230 | ('u', 'user', None, _('list the author (long with -v)')), | |
4230 | ('d', 'date', None, _('list the date (short with -q)')), |
|
4231 | ('d', 'date', None, _('list the date (short with -q)')), | |
4231 | ] + walkopts, |
|
4232 | ] + walkopts, | |
4232 | _('[OPTION]... PATTERN [FILE]...')), |
|
4233 | _('[OPTION]... PATTERN [FILE]...')), | |
4233 | "heads": |
|
4234 | "heads": | |
4234 | (heads, |
|
4235 | (heads, | |
4235 | [('r', 'rev', '', |
|
4236 | [('r', 'rev', '', | |
4236 | _('show only heads which are descendants of STARTREV'), |
|
4237 | _('show only heads which are descendants of STARTREV'), | |
4237 | _('STARTREV')), |
|
4238 | _('STARTREV')), | |
4238 | ('t', 'topo', False, _('show topological heads only')), |
|
4239 | ('t', 'topo', False, _('show topological heads only')), | |
4239 | ('a', 'active', False, |
|
4240 | ('a', 'active', False, | |
4240 | _('show active branchheads only (DEPRECATED)')), |
|
4241 | _('show active branchheads only (DEPRECATED)')), | |
4241 | ('c', 'closed', False, |
|
4242 | ('c', 'closed', False, | |
4242 | _('show normal and closed branch heads')), |
|
4243 | _('show normal and closed branch heads')), | |
4243 | ] + templateopts, |
|
4244 | ] + templateopts, | |
4244 | _('[-ac] [-r STARTREV] [REV]...')), |
|
4245 | _('[-ac] [-r STARTREV] [REV]...')), | |
4245 | "help": (help_, [], _('[TOPIC]')), |
|
4246 | "help": (help_, [], _('[TOPIC]')), | |
4246 | "identify|id": |
|
4247 | "identify|id": | |
4247 | (identify, |
|
4248 | (identify, | |
4248 | [('r', 'rev', '', |
|
4249 | [('r', 'rev', '', | |
4249 | _('identify the specified revision'), _('REV')), |
|
4250 | _('identify the specified revision'), _('REV')), | |
4250 | ('n', 'num', None, _('show local revision number')), |
|
4251 | ('n', 'num', None, _('show local revision number')), | |
4251 | ('i', 'id', None, _('show global revision id')), |
|
4252 | ('i', 'id', None, _('show global revision id')), | |
4252 | ('b', 'branch', None, _('show branch')), |
|
4253 | ('b', 'branch', None, _('show branch')), | |
4253 | ('t', 'tags', None, _('show tags'))], |
|
4254 | ('t', 'tags', None, _('show tags'))], | |
4254 | _('[-nibt] [-r REV] [SOURCE]')), |
|
4255 | _('[-nibt] [-r REV] [SOURCE]')), | |
4255 | "import|patch": |
|
4256 | "import|patch": | |
4256 | (import_, |
|
4257 | (import_, | |
4257 | [('p', 'strip', 1, |
|
4258 | [('p', 'strip', 1, | |
4258 | _('directory strip option for patch. This has the same ' |
|
4259 | _('directory strip option for patch. This has the same ' | |
4259 | 'meaning as the corresponding patch option'), |
|
4260 | 'meaning as the corresponding patch option'), | |
4260 | _('NUM')), |
|
4261 | _('NUM')), | |
4261 | ('b', 'base', '', |
|
4262 | ('b', 'base', '', | |
4262 | _('base path'), _('PATH')), |
|
4263 | _('base path'), _('PATH')), | |
4263 | ('f', 'force', None, |
|
4264 | ('f', 'force', None, | |
4264 | _('skip check for outstanding uncommitted changes')), |
|
4265 | _('skip check for outstanding uncommitted changes')), | |
4265 | ('', 'no-commit', None, |
|
4266 | ('', 'no-commit', None, | |
4266 | _("don't commit, just update the working directory")), |
|
4267 | _("don't commit, just update the working directory")), | |
4267 | ('', 'exact', None, |
|
4268 | ('', 'exact', None, | |
4268 | _('apply patch to the nodes from which it was generated')), |
|
4269 | _('apply patch to the nodes from which it was generated')), | |
4269 | ('', 'import-branch', None, |
|
4270 | ('', 'import-branch', None, | |
4270 | _('use any branch information in patch (implied by --exact)'))] + |
|
4271 | _('use any branch information in patch (implied by --exact)'))] + | |
4271 | commitopts + commitopts2 + similarityopts, |
|
4272 | commitopts + commitopts2 + similarityopts, | |
4272 | _('[OPTION]... PATCH...')), |
|
4273 | _('[OPTION]... PATCH...')), | |
4273 | "incoming|in": |
|
4274 | "incoming|in": | |
4274 | (incoming, |
|
4275 | (incoming, | |
4275 | [('f', 'force', None, |
|
4276 | [('f', 'force', None, | |
4276 | _('run even if remote repository is unrelated')), |
|
4277 | _('run even if remote repository is unrelated')), | |
4277 | ('n', 'newest-first', None, _('show newest record first')), |
|
4278 | ('n', 'newest-first', None, _('show newest record first')), | |
4278 | ('', 'bundle', '', |
|
4279 | ('', 'bundle', '', | |
4279 | _('file to store the bundles into'), _('FILE')), |
|
4280 | _('file to store the bundles into'), _('FILE')), | |
4280 | ('r', 'rev', [], |
|
4281 | ('r', 'rev', [], | |
4281 | _('a remote changeset intended to be added'), _('REV')), |
|
4282 | _('a remote changeset intended to be added'), _('REV')), | |
4282 | ('b', 'branch', [], |
|
4283 | ('b', 'branch', [], | |
4283 | _('a specific branch you would like to pull'), _('BRANCH')), |
|
4284 | _('a specific branch you would like to pull'), _('BRANCH')), | |
4284 | ] + logopts + remoteopts + subrepoopts, |
|
4285 | ] + logopts + remoteopts + subrepoopts, | |
4285 | _('[-p] [-n] [-M] [-f] [-r REV]...' |
|
4286 | _('[-p] [-n] [-M] [-f] [-r REV]...' | |
4286 | ' [--bundle FILENAME] [SOURCE]')), |
|
4287 | ' [--bundle FILENAME] [SOURCE]')), | |
4287 | "^init": |
|
4288 | "^init": | |
4288 | (init, |
|
4289 | (init, | |
4289 | remoteopts, |
|
4290 | remoteopts, | |
4290 | _('[-e CMD] [--remotecmd CMD] [DEST]')), |
|
4291 | _('[-e CMD] [--remotecmd CMD] [DEST]')), | |
4291 | "locate": |
|
4292 | "locate": | |
4292 | (locate, |
|
4293 | (locate, | |
4293 | [('r', 'rev', '', |
|
4294 | [('r', 'rev', '', | |
4294 | _('search the repository as it is in REV'), _('REV')), |
|
4295 | _('search the repository as it is in REV'), _('REV')), | |
4295 | ('0', 'print0', None, |
|
4296 | ('0', 'print0', None, | |
4296 | _('end filenames with NUL, for use with xargs')), |
|
4297 | _('end filenames with NUL, for use with xargs')), | |
4297 | ('f', 'fullpath', None, |
|
4298 | ('f', 'fullpath', None, | |
4298 | _('print complete paths from the filesystem root')), |
|
4299 | _('print complete paths from the filesystem root')), | |
4299 | ] + walkopts, |
|
4300 | ] + walkopts, | |
4300 | _('[OPTION]... [PATTERN]...')), |
|
4301 | _('[OPTION]... [PATTERN]...')), | |
4301 | "^log|history": |
|
4302 | "^log|history": | |
4302 | (log, |
|
4303 | (log, | |
4303 | [('f', 'follow', None, |
|
4304 | [('f', 'follow', None, | |
4304 | _('follow changeset history,' |
|
4305 | _('follow changeset history,' | |
4305 | ' or file history across copies and renames')), |
|
4306 | ' or file history across copies and renames')), | |
4306 | ('', 'follow-first', None, |
|
4307 | ('', 'follow-first', None, | |
4307 | _('only follow the first parent of merge changesets')), |
|
4308 | _('only follow the first parent of merge changesets')), | |
4308 | ('d', 'date', '', |
|
4309 | ('d', 'date', '', | |
4309 | _('show revisions matching date spec'), _('DATE')), |
|
4310 | _('show revisions matching date spec'), _('DATE')), | |
4310 | ('C', 'copies', None, _('show copied files')), |
|
4311 | ('C', 'copies', None, _('show copied files')), | |
4311 | ('k', 'keyword', [], |
|
4312 | ('k', 'keyword', [], | |
4312 | _('do case-insensitive search for a given text'), _('TEXT')), |
|
4313 | _('do case-insensitive search for a given text'), _('TEXT')), | |
4313 | ('r', 'rev', [], |
|
4314 | ('r', 'rev', [], | |
4314 | _('show the specified revision or range'), _('REV')), |
|
4315 | _('show the specified revision or range'), _('REV')), | |
4315 | ('', 'removed', None, _('include revisions where files were removed')), |
|
4316 | ('', 'removed', None, _('include revisions where files were removed')), | |
4316 | ('m', 'only-merges', None, _('show only merges')), |
|
4317 | ('m', 'only-merges', None, _('show only merges')), | |
4317 | ('u', 'user', [], |
|
4318 | ('u', 'user', [], | |
4318 | _('revisions committed by user'), _('USER')), |
|
4319 | _('revisions committed by user'), _('USER')), | |
4319 | ('', 'only-branch', [], |
|
4320 | ('', 'only-branch', [], | |
4320 | _('show only changesets within the given named branch (DEPRECATED)'), |
|
4321 | _('show only changesets within the given named branch (DEPRECATED)'), | |
4321 | _('BRANCH')), |
|
4322 | _('BRANCH')), | |
4322 | ('b', 'branch', [], |
|
4323 | ('b', 'branch', [], | |
4323 | _('show changesets within the given named branch'), _('BRANCH')), |
|
4324 | _('show changesets within the given named branch'), _('BRANCH')), | |
4324 | ('P', 'prune', [], |
|
4325 | ('P', 'prune', [], | |
4325 | _('do not display revision or any of its ancestors'), _('REV')), |
|
4326 | _('do not display revision or any of its ancestors'), _('REV')), | |
4326 | ] + logopts + walkopts, |
|
4327 | ] + logopts + walkopts, | |
4327 | _('[OPTION]... [FILE]')), |
|
4328 | _('[OPTION]... [FILE]')), | |
4328 | "manifest": |
|
4329 | "manifest": | |
4329 | (manifest, |
|
4330 | (manifest, | |
4330 | [('r', 'rev', '', |
|
4331 | [('r', 'rev', '', | |
4331 | _('revision to display'), _('REV'))], |
|
4332 | _('revision to display'), _('REV'))], | |
4332 | _('[-r REV]')), |
|
4333 | _('[-r REV]')), | |
4333 | "^merge": |
|
4334 | "^merge": | |
4334 | (merge, |
|
4335 | (merge, | |
4335 | [('f', 'force', None, _('force a merge with outstanding changes')), |
|
4336 | [('f', 'force', None, _('force a merge with outstanding changes')), | |
4336 | ('t', 'tool', '', _('specify merge tool')), |
|
4337 | ('t', 'tool', '', _('specify merge tool')), | |
4337 | ('r', 'rev', '', |
|
4338 | ('r', 'rev', '', | |
4338 | _('revision to merge'), _('REV')), |
|
4339 | _('revision to merge'), _('REV')), | |
4339 | ('P', 'preview', None, |
|
4340 | ('P', 'preview', None, | |
4340 | _('review revisions to merge (no merge is performed)'))], |
|
4341 | _('review revisions to merge (no merge is performed)'))], | |
4341 | _('[-P] [-f] [[-r] REV]')), |
|
4342 | _('[-P] [-f] [[-r] REV]')), | |
4342 | "outgoing|out": |
|
4343 | "outgoing|out": | |
4343 | (outgoing, |
|
4344 | (outgoing, | |
4344 | [('f', 'force', None, |
|
4345 | [('f', 'force', None, | |
4345 | _('run even when the destination is unrelated')), |
|
4346 | _('run even when the destination is unrelated')), | |
4346 | ('r', 'rev', [], |
|
4347 | ('r', 'rev', [], | |
4347 | _('a changeset intended to be included in the destination'), |
|
4348 | _('a changeset intended to be included in the destination'), | |
4348 | _('REV')), |
|
4349 | _('REV')), | |
4349 | ('n', 'newest-first', None, _('show newest record first')), |
|
4350 | ('n', 'newest-first', None, _('show newest record first')), | |
4350 | ('b', 'branch', [], |
|
4351 | ('b', 'branch', [], | |
4351 | _('a specific branch you would like to push'), _('BRANCH')), |
|
4352 | _('a specific branch you would like to push'), _('BRANCH')), | |
4352 | ] + logopts + remoteopts + subrepoopts, |
|
4353 | ] + logopts + remoteopts + subrepoopts, | |
4353 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')), |
|
4354 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')), | |
4354 | "parents": |
|
4355 | "parents": | |
4355 | (parents, |
|
4356 | (parents, | |
4356 | [('r', 'rev', '', |
|
4357 | [('r', 'rev', '', | |
4357 | _('show parents of the specified revision'), _('REV')), |
|
4358 | _('show parents of the specified revision'), _('REV')), | |
4358 | ] + templateopts, |
|
4359 | ] + templateopts, | |
4359 | _('[-r REV] [FILE]')), |
|
4360 | _('[-r REV] [FILE]')), | |
4360 | "paths": (paths, [], _('[NAME]')), |
|
4361 | "paths": (paths, [], _('[NAME]')), | |
4361 | "^pull": |
|
4362 | "^pull": | |
4362 | (pull, |
|
4363 | (pull, | |
4363 | [('u', 'update', None, |
|
4364 | [('u', 'update', None, | |
4364 | _('update to new branch head if changesets were pulled')), |
|
4365 | _('update to new branch head if changesets were pulled')), | |
4365 | ('f', 'force', None, |
|
4366 | ('f', 'force', None, | |
4366 | _('run even when remote repository is unrelated')), |
|
4367 | _('run even when remote repository is unrelated')), | |
4367 | ('r', 'rev', [], |
|
4368 | ('r', 'rev', [], | |
4368 | _('a remote changeset intended to be added'), _('REV')), |
|
4369 | _('a remote changeset intended to be added'), _('REV')), | |
4369 | ('b', 'branch', [], |
|
4370 | ('b', 'branch', [], | |
4370 | _('a specific branch you would like to pull'), _('BRANCH')), |
|
4371 | _('a specific branch you would like to pull'), _('BRANCH')), | |
4371 | ] + remoteopts, |
|
4372 | ] + remoteopts, | |
4372 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')), |
|
4373 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')), | |
4373 | "^push": |
|
4374 | "^push": | |
4374 | (push, |
|
4375 | (push, | |
4375 | [('f', 'force', None, _('force push')), |
|
4376 | [('f', 'force', None, _('force push')), | |
4376 | ('r', 'rev', [], |
|
4377 | ('r', 'rev', [], | |
4377 | _('a changeset intended to be included in the destination'), |
|
4378 | _('a changeset intended to be included in the destination'), | |
4378 | _('REV')), |
|
4379 | _('REV')), | |
4379 | ('b', 'branch', [], |
|
4380 | ('b', 'branch', [], | |
4380 | _('a specific branch you would like to push'), _('BRANCH')), |
|
4381 | _('a specific branch you would like to push'), _('BRANCH')), | |
4381 | ('', 'new-branch', False, _('allow pushing a new branch')), |
|
4382 | ('', 'new-branch', False, _('allow pushing a new branch')), | |
4382 | ] + remoteopts, |
|
4383 | ] + remoteopts, | |
4383 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')), |
|
4384 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')), | |
4384 | "recover": (recover, []), |
|
4385 | "recover": (recover, []), | |
4385 | "^remove|rm": |
|
4386 | "^remove|rm": | |
4386 | (remove, |
|
4387 | (remove, | |
4387 | [('A', 'after', None, _('record delete for missing files')), |
|
4388 | [('A', 'after', None, _('record delete for missing files')), | |
4388 | ('f', 'force', None, |
|
4389 | ('f', 'force', None, | |
4389 | _('remove (and delete) file even if added or modified')), |
|
4390 | _('remove (and delete) file even if added or modified')), | |
4390 | ] + walkopts, |
|
4391 | ] + walkopts, | |
4391 | _('[OPTION]... FILE...')), |
|
4392 | _('[OPTION]... FILE...')), | |
4392 | "rename|move|mv": |
|
4393 | "rename|move|mv": | |
4393 | (rename, |
|
4394 | (rename, | |
4394 | [('A', 'after', None, _('record a rename that has already occurred')), |
|
4395 | [('A', 'after', None, _('record a rename that has already occurred')), | |
4395 | ('f', 'force', None, |
|
4396 | ('f', 'force', None, | |
4396 | _('forcibly copy over an existing managed file')), |
|
4397 | _('forcibly copy over an existing managed file')), | |
4397 | ] + walkopts + dryrunopts, |
|
4398 | ] + walkopts + dryrunopts, | |
4398 | _('[OPTION]... SOURCE... DEST')), |
|
4399 | _('[OPTION]... SOURCE... DEST')), | |
4399 | "resolve": |
|
4400 | "resolve": | |
4400 | (resolve, |
|
4401 | (resolve, | |
4401 | [('a', 'all', None, _('select all unresolved files')), |
|
4402 | [('a', 'all', None, _('select all unresolved files')), | |
4402 | ('l', 'list', None, _('list state of files needing merge')), |
|
4403 | ('l', 'list', None, _('list state of files needing merge')), | |
4403 | ('m', 'mark', None, _('mark files as resolved')), |
|
4404 | ('m', 'mark', None, _('mark files as resolved')), | |
4404 | ('u', 'unmark', None, _('mark files as unresolved')), |
|
4405 | ('u', 'unmark', None, _('mark files as unresolved')), | |
4405 | ('t', 'tool', '', _('specify merge tool')), |
|
4406 | ('t', 'tool', '', _('specify merge tool')), | |
4406 | ('n', 'no-status', None, _('hide status prefix'))] |
|
4407 | ('n', 'no-status', None, _('hide status prefix'))] | |
4407 | + walkopts, |
|
4408 | + walkopts, | |
4408 | _('[OPTION]... [FILE]...')), |
|
4409 | _('[OPTION]... [FILE]...')), | |
4409 | "revert": |
|
4410 | "revert": | |
4410 | (revert, |
|
4411 | (revert, | |
4411 | [('a', 'all', None, _('revert all changes when no arguments given')), |
|
4412 | [('a', 'all', None, _('revert all changes when no arguments given')), | |
4412 | ('d', 'date', '', |
|
4413 | ('d', 'date', '', | |
4413 | _('tipmost revision matching date'), _('DATE')), |
|
4414 | _('tipmost revision matching date'), _('DATE')), | |
4414 | ('r', 'rev', '', |
|
4415 | ('r', 'rev', '', | |
4415 | _('revert to the specified revision'), _('REV')), |
|
4416 | _('revert to the specified revision'), _('REV')), | |
4416 | ('', 'no-backup', None, _('do not save backup copies of files')), |
|
4417 | ('', 'no-backup', None, _('do not save backup copies of files')), | |
4417 | ] + walkopts + dryrunopts, |
|
4418 | ] + walkopts + dryrunopts, | |
4418 | _('[OPTION]... [-r REV] [NAME]...')), |
|
4419 | _('[OPTION]... [-r REV] [NAME]...')), | |
4419 | "rollback": (rollback, dryrunopts), |
|
4420 | "rollback": (rollback, dryrunopts), | |
4420 | "root": (root, []), |
|
4421 | "root": (root, []), | |
4421 | "^serve": |
|
4422 | "^serve": | |
4422 | (serve, |
|
4423 | (serve, | |
4423 | [('A', 'accesslog', '', |
|
4424 | [('A', 'accesslog', '', | |
4424 | _('name of access log file to write to'), _('FILE')), |
|
4425 | _('name of access log file to write to'), _('FILE')), | |
4425 | ('d', 'daemon', None, _('run server in background')), |
|
4426 | ('d', 'daemon', None, _('run server in background')), | |
4426 | ('', 'daemon-pipefds', '', |
|
4427 | ('', 'daemon-pipefds', '', | |
4427 | _('used internally by daemon mode'), _('NUM')), |
|
4428 | _('used internally by daemon mode'), _('NUM')), | |
4428 | ('E', 'errorlog', '', |
|
4429 | ('E', 'errorlog', '', | |
4429 | _('name of error log file to write to'), _('FILE')), |
|
4430 | _('name of error log file to write to'), _('FILE')), | |
4430 | # use string type, then we can check if something was passed |
|
4431 | # use string type, then we can check if something was passed | |
4431 | ('p', 'port', '', |
|
4432 | ('p', 'port', '', | |
4432 | _('port to listen on (default: 8000)'), _('PORT')), |
|
4433 | _('port to listen on (default: 8000)'), _('PORT')), | |
4433 | ('a', 'address', '', |
|
4434 | ('a', 'address', '', | |
4434 | _('address to listen on (default: all interfaces)'), _('ADDR')), |
|
4435 | _('address to listen on (default: all interfaces)'), _('ADDR')), | |
4435 | ('', 'prefix', '', |
|
4436 | ('', 'prefix', '', | |
4436 | _('prefix path to serve from (default: server root)'), _('PREFIX')), |
|
4437 | _('prefix path to serve from (default: server root)'), _('PREFIX')), | |
4437 | ('n', 'name', '', |
|
4438 | ('n', 'name', '', | |
4438 | _('name to show in web pages (default: working directory)'), |
|
4439 | _('name to show in web pages (default: working directory)'), | |
4439 | _('NAME')), |
|
4440 | _('NAME')), | |
4440 | ('', 'web-conf', '', |
|
4441 | ('', 'web-conf', '', | |
4441 | _('name of the hgweb config file (see "hg help hgweb")'), |
|
4442 | _('name of the hgweb config file (see "hg help hgweb")'), | |
4442 | _('FILE')), |
|
4443 | _('FILE')), | |
4443 | ('', 'webdir-conf', '', |
|
4444 | ('', 'webdir-conf', '', | |
4444 | _('name of the hgweb config file (DEPRECATED)'), _('FILE')), |
|
4445 | _('name of the hgweb config file (DEPRECATED)'), _('FILE')), | |
4445 | ('', 'pid-file', '', |
|
4446 | ('', 'pid-file', '', | |
4446 | _('name of file to write process ID to'), _('FILE')), |
|
4447 | _('name of file to write process ID to'), _('FILE')), | |
4447 | ('', 'stdio', None, _('for remote clients')), |
|
4448 | ('', 'stdio', None, _('for remote clients')), | |
4448 | ('t', 'templates', '', |
|
4449 | ('t', 'templates', '', | |
4449 | _('web templates to use'), _('TEMPLATE')), |
|
4450 | _('web templates to use'), _('TEMPLATE')), | |
4450 | ('', 'style', '', |
|
4451 | ('', 'style', '', | |
4451 | _('template style to use'), _('STYLE')), |
|
4452 | _('template style to use'), _('STYLE')), | |
4452 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), |
|
4453 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), | |
4453 | ('', 'certificate', '', |
|
4454 | ('', 'certificate', '', | |
4454 | _('SSL certificate file'), _('FILE'))], |
|
4455 | _('SSL certificate file'), _('FILE'))], | |
4455 | _('[OPTION]...')), |
|
4456 | _('[OPTION]...')), | |
4456 | "showconfig|debugconfig": |
|
4457 | "showconfig|debugconfig": | |
4457 | (showconfig, |
|
4458 | (showconfig, | |
4458 | [('u', 'untrusted', None, _('show untrusted configuration options'))], |
|
4459 | [('u', 'untrusted', None, _('show untrusted configuration options'))], | |
4459 | _('[-u] [NAME]...')), |
|
4460 | _('[-u] [NAME]...')), | |
4460 | "^summary|sum": |
|
4461 | "^summary|sum": | |
4461 | (summary, |
|
4462 | (summary, | |
4462 | [('', 'remote', None, _('check for push and pull'))], '[--remote]'), |
|
4463 | [('', 'remote', None, _('check for push and pull'))], '[--remote]'), | |
4463 | "^status|st": |
|
4464 | "^status|st": | |
4464 | (status, |
|
4465 | (status, | |
4465 | [('A', 'all', None, _('show status of all files')), |
|
4466 | [('A', 'all', None, _('show status of all files')), | |
4466 | ('m', 'modified', None, _('show only modified files')), |
|
4467 | ('m', 'modified', None, _('show only modified files')), | |
4467 | ('a', 'added', None, _('show only added files')), |
|
4468 | ('a', 'added', None, _('show only added files')), | |
4468 | ('r', 'removed', None, _('show only removed files')), |
|
4469 | ('r', 'removed', None, _('show only removed files')), | |
4469 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), |
|
4470 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), | |
4470 | ('c', 'clean', None, _('show only files without changes')), |
|
4471 | ('c', 'clean', None, _('show only files without changes')), | |
4471 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), |
|
4472 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), | |
4472 | ('i', 'ignored', None, _('show only ignored files')), |
|
4473 | ('i', 'ignored', None, _('show only ignored files')), | |
4473 | ('n', 'no-status', None, _('hide status prefix')), |
|
4474 | ('n', 'no-status', None, _('hide status prefix')), | |
4474 | ('C', 'copies', None, _('show source of copied files')), |
|
4475 | ('C', 'copies', None, _('show source of copied files')), | |
4475 | ('0', 'print0', None, |
|
4476 | ('0', 'print0', None, | |
4476 | _('end filenames with NUL, for use with xargs')), |
|
4477 | _('end filenames with NUL, for use with xargs')), | |
4477 | ('', 'rev', [], |
|
4478 | ('', 'rev', [], | |
4478 | _('show difference from revision'), _('REV')), |
|
4479 | _('show difference from revision'), _('REV')), | |
4479 | ('', 'change', '', |
|
4480 | ('', 'change', '', | |
4480 | _('list the changed files of a revision'), _('REV')), |
|
4481 | _('list the changed files of a revision'), _('REV')), | |
4481 | ] + walkopts + subrepoopts, |
|
4482 | ] + walkopts + subrepoopts, | |
4482 | _('[OPTION]... [FILE]...')), |
|
4483 | _('[OPTION]... [FILE]...')), | |
4483 | "tag": |
|
4484 | "tag": | |
4484 | (tag, |
|
4485 | (tag, | |
4485 | [('f', 'force', None, _('replace existing tag')), |
|
4486 | [('f', 'force', None, _('replace existing tag')), | |
4486 | ('l', 'local', None, _('make the tag local')), |
|
4487 | ('l', 'local', None, _('make the tag local')), | |
4487 | ('r', 'rev', '', |
|
4488 | ('r', 'rev', '', | |
4488 | _('revision to tag'), _('REV')), |
|
4489 | _('revision to tag'), _('REV')), | |
4489 | ('', 'remove', None, _('remove a tag')), |
|
4490 | ('', 'remove', None, _('remove a tag')), | |
4490 | # -l/--local is already there, commitopts cannot be used |
|
4491 | # -l/--local is already there, commitopts cannot be used | |
4491 | ('e', 'edit', None, _('edit commit message')), |
|
4492 | ('e', 'edit', None, _('edit commit message')), | |
4492 | ('m', 'message', '', |
|
4493 | ('m', 'message', '', | |
4493 | _('use <text> as commit message'), _('TEXT')), |
|
4494 | _('use <text> as commit message'), _('TEXT')), | |
4494 | ] + commitopts2, |
|
4495 | ] + commitopts2, | |
4495 | _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')), |
|
4496 | _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')), | |
4496 | "tags": (tags, [], ''), |
|
4497 | "tags": (tags, [], ''), | |
4497 | "tip": |
|
4498 | "tip": | |
4498 | (tip, |
|
4499 | (tip, | |
4499 | [('p', 'patch', None, _('show patch')), |
|
4500 | [('p', 'patch', None, _('show patch')), | |
4500 | ('g', 'git', None, _('use git extended diff format')), |
|
4501 | ('g', 'git', None, _('use git extended diff format')), | |
4501 | ] + templateopts, |
|
4502 | ] + templateopts, | |
4502 | _('[-p] [-g]')), |
|
4503 | _('[-p] [-g]')), | |
4503 | "unbundle": |
|
4504 | "unbundle": | |
4504 | (unbundle, |
|
4505 | (unbundle, | |
4505 | [('u', 'update', None, |
|
4506 | [('u', 'update', None, | |
4506 | _('update to new branch head if changesets were unbundled'))], |
|
4507 | _('update to new branch head if changesets were unbundled'))], | |
4507 | _('[-u] FILE...')), |
|
4508 | _('[-u] FILE...')), | |
4508 | "^update|up|checkout|co": |
|
4509 | "^update|up|checkout|co": | |
4509 | (update, |
|
4510 | (update, | |
4510 | [('C', 'clean', None, _('discard uncommitted changes (no backup)')), |
|
4511 | [('C', 'clean', None, _('discard uncommitted changes (no backup)')), | |
4511 | ('c', 'check', None, |
|
4512 | ('c', 'check', None, | |
4512 | _('update across branches if no uncommitted changes')), |
|
4513 | _('update across branches if no uncommitted changes')), | |
4513 | ('d', 'date', '', |
|
4514 | ('d', 'date', '', | |
4514 | _('tipmost revision matching date'), _('DATE')), |
|
4515 | _('tipmost revision matching date'), _('DATE')), | |
4515 | ('r', 'rev', '', |
|
4516 | ('r', 'rev', '', | |
4516 | _('revision'), _('REV'))], |
|
4517 | _('revision'), _('REV'))], | |
4517 | _('[-c] [-C] [-d DATE] [[-r] REV]')), |
|
4518 | _('[-c] [-C] [-d DATE] [[-r] REV]')), | |
4518 | "verify": (verify, []), |
|
4519 | "verify": (verify, []), | |
4519 | "version": (version_, []), |
|
4520 | "version": (version_, []), | |
4520 | } |
|
4521 | } | |
4521 |
|
4522 | |||
4522 | norepo = ("clone init version help debugcommands debugcomplete" |
|
4523 | norepo = ("clone init version help debugcommands debugcomplete" | |
4523 | " debugdate debuginstall debugfsinfo debugpushkey") |
|
4524 | " debugdate debuginstall debugfsinfo debugpushkey") | |
4524 | optionalrepo = ("identify paths serve showconfig debugancestor debugdag" |
|
4525 | optionalrepo = ("identify paths serve showconfig debugancestor debugdag" | |
4525 | " debugdata debugindex debugindexdot") |
|
4526 | " debugdata debugindex debugindexdot") |
@@ -1,105 +1,105 b'' | |||||
1 |
|
1 | |||
2 | $ commit() |
|
2 | $ commit() | |
3 | > { |
|
3 | > { | |
4 | > msg=$1 |
|
4 | > msg=$1 | |
5 | > p1=$2 |
|
5 | > p1=$2 | |
6 | > p2=$3 |
|
6 | > p2=$3 | |
7 | > |
|
7 | > | |
8 | > if [ "$p1" ]; then |
|
8 | > if [ "$p1" ]; then | |
9 | > hg up -qC $p1 |
|
9 | > hg up -qC $p1 | |
10 | > fi |
|
10 | > fi | |
11 | > |
|
11 | > | |
12 | > if [ "$p2" ]; then |
|
12 | > if [ "$p2" ]; then | |
13 | > HGMERGE=true hg merge -q $p2 |
|
13 | > HGMERGE=true hg merge -q $p2 | |
14 | > fi |
|
14 | > fi | |
15 | > |
|
15 | > | |
16 | > echo >> foo |
|
16 | > echo >> foo | |
17 | > |
|
17 | > | |
18 | > hg commit -qAm "$msg" |
|
18 | > hg commit -qAm "$msg" | |
19 | > } |
|
19 | > } | |
20 | $ hg init repo |
|
20 | $ hg init repo | |
21 | $ cd repo |
|
21 | $ cd repo | |
22 | $ echo '[extensions]' > .hg/hgrc |
|
22 | $ echo '[extensions]' > .hg/hgrc | |
23 | $ echo 'parentrevspec =' >> .hg/hgrc |
|
23 | $ echo 'parentrevspec =' >> .hg/hgrc | |
24 | $ commit '0: add foo' |
|
24 | $ commit '0: add foo' | |
25 | $ commit '1: change foo 1' |
|
25 | $ commit '1: change foo 1' | |
26 | $ commit '2: change foo 2a' |
|
26 | $ commit '2: change foo 2a' | |
27 | $ commit '3: change foo 3a' |
|
27 | $ commit '3: change foo 3a' | |
28 | $ commit '4: change foo 2b' 1 |
|
28 | $ commit '4: change foo 2b' 1 | |
29 | $ commit '5: merge' 3 4 |
|
29 | $ commit '5: merge' 3 4 | |
30 | $ commit '6: change foo again' |
|
30 | $ commit '6: change foo again' | |
31 | $ hg log --template '{rev}:{node|short} {parents}\n' |
|
31 | $ hg log --template '{rev}:{node|short} {parents}\n' | |
32 | 6:755d1e0d79e9 |
|
32 | 6:755d1e0d79e9 | |
33 | 5:9ce2ce29723a 3:a3e00c7dbf11 4:bb4475edb621 |
|
33 | 5:9ce2ce29723a 3:a3e00c7dbf11 4:bb4475edb621 | |
34 | 4:bb4475edb621 1:5d953a1917d1 |
|
34 | 4:bb4475edb621 1:5d953a1917d1 | |
35 | 3:a3e00c7dbf11 |
|
35 | 3:a3e00c7dbf11 | |
36 | 2:befc7d89d081 |
|
36 | 2:befc7d89d081 | |
37 | 1:5d953a1917d1 |
|
37 | 1:5d953a1917d1 | |
38 | 0:837088b6e1d9 |
|
38 | 0:837088b6e1d9 | |
39 | $ echo |
|
39 | $ echo | |
40 |
|
40 | |||
41 | $ lookup() |
|
41 | $ lookup() | |
42 | > { |
|
42 | > { | |
43 | > for rev in "$@"; do |
|
43 | > for rev in "$@"; do | |
44 | > printf "$rev: " |
|
44 | > printf "$rev: " | |
45 | > hg id -nr $rev |
|
45 | > hg id -nr $rev | |
46 | > done |
|
46 | > done | |
47 | > true |
|
47 | > true | |
48 | > } |
|
48 | > } | |
49 | $ tipnode=`hg id -ir tip` |
|
49 | $ tipnode=`hg id -ir tip` | |
50 |
|
50 | |||
51 | should work with tag/branch/node/rev |
|
51 | should work with tag/branch/node/rev | |
52 |
|
52 | |||
53 | $ for r in tip default $tipnode 6; do |
|
53 | $ for r in tip default $tipnode 6; do | |
54 | > lookup "$r^" |
|
54 | > lookup "$r^" | |
55 | > done |
|
55 | > done | |
56 | tip^: 5 |
|
56 | tip^: 5 | |
57 | default^: 5 |
|
57 | default^: 5 | |
58 | 755d1e0d79e9^: 5 |
|
58 | 755d1e0d79e9^: 5 | |
59 | 6^: 5 |
|
59 | 6^: 5 | |
60 | $ echo |
|
60 | $ echo | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | some random lookups |
|
63 | some random lookups | |
64 |
|
64 | |||
65 | $ lookup "6^^" "6^^^" "6^^^^" "6^^^^^" "6^^^^^^" "6^1" "6^2" "6^^2" "6^1^2" "6^^3" |
|
65 | $ lookup "6^^" "6^^^" "6^^^^" "6^^^^^" "6^^^^^^" "6^1" "6^2" "6^^2" "6^1^2" "6^^3" | |
66 | 6^^: 3 |
|
66 | 6^^: 3 | |
67 | 6^^^: 2 |
|
67 | 6^^^: 2 | |
68 | 6^^^^: 1 |
|
68 | 6^^^^: 1 | |
69 | 6^^^^^: 0 |
|
69 | 6^^^^^: 0 | |
70 | 6^^^^^^: -1 |
|
70 | 6^^^^^^: -1 | |
71 | 6^1: 5 |
|
71 | 6^1: 5 | |
72 | 6^2: abort: unknown revision '6^2'! |
|
72 | 6^2: hg: parse error at 1: syntax error | |
73 | 6^^2: 4 |
|
73 | 6^^2: 4 | |
74 | 6^1^2: 4 |
|
74 | 6^1^2: 4 | |
75 | 6^^3: abort: unknown revision '6^^3'! |
|
75 | 6^^3: hg: parse error at 1: syntax error | |
76 | $ lookup "6~" "6~1" "6~2" "6~3" "6~4" "6~5" "6~42" "6~1^2" "6~1^2~2" |
|
76 | $ lookup "6~" "6~1" "6~2" "6~3" "6~4" "6~5" "6~42" "6~1^2" "6~1^2~2" | |
77 | 6~: abort: unknown revision '6~'! |
|
77 | 6~: hg: parse error at 1: syntax error | |
78 | 6~1: 5 |
|
78 | 6~1: 5 | |
79 | 6~2: 3 |
|
79 | 6~2: 3 | |
80 | 6~3: 2 |
|
80 | 6~3: 2 | |
81 | 6~4: 1 |
|
81 | 6~4: 1 | |
82 | 6~5: 0 |
|
82 | 6~5: 0 | |
83 | 6~42: -1 |
|
83 | 6~42: -1 | |
84 | 6~1^2: 4 |
|
84 | 6~1^2: 4 | |
85 | 6~1^2~2: 0 |
|
85 | 6~1^2~2: 0 | |
86 | $ echo |
|
86 | $ echo | |
87 |
|
87 | |||
88 |
|
88 | |||
89 | with a tag "6^" pointing to rev 1 |
|
89 | with a tag "6^" pointing to rev 1 | |
90 |
|
90 | |||
91 | $ hg tag -l -r 1 "6^" |
|
91 | $ hg tag -l -r 1 "6^" | |
92 | $ lookup "6^" "6^1" "6~1" "6^^" |
|
92 | $ lookup "6^" "6^1" "6~1" "6^^" | |
93 | 6^: 1 |
|
93 | 6^: 1 | |
94 | 6^1: 5 |
|
94 | 6^1: 5 | |
95 | 6~1: 5 |
|
95 | 6~1: 5 | |
96 | 6^^: 3 |
|
96 | 6^^: 3 | |
97 | $ echo |
|
97 | $ echo | |
98 |
|
98 | |||
99 |
|
99 | |||
100 | with a tag "foo^bar" pointing to rev 2 |
|
100 | with a tag "foo^bar" pointing to rev 2 | |
101 |
|
101 | |||
102 | $ hg tag -l -r 2 "foo^bar" |
|
102 | $ hg tag -l -r 2 "foo^bar" | |
103 | $ lookup "foo^bar" "foo^bar^" |
|
103 | $ lookup "foo^bar" "foo^bar^" | |
104 | foo^bar: 2 |
|
104 | foo^bar: 2 | |
105 | foo^bar^: abort: unknown revision 'foo^bar^'! |
|
105 | foo^bar^: hg: parse error at 3: syntax error |
General Comments 0
You need to be logged in to leave comments.
Login now