Show More
@@ -1,1389 +1,1391 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.p2() != nullid: |
|
75 | if repo.dirstate.p2() != 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.p1(), None |
|
125 | return repo.dirstate.p1(), 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.p1(), None |
|
130 | return repo.dirstate.p1(), 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): |
|
150 | if isinstance(spec, int): | |
151 | seen.add(spec) |
|
151 | seen.add(spec) | |
152 | l.append(spec) |
|
152 | l.append(spec) | |
153 | continue |
|
153 | continue | |
154 |
|
154 | |||
155 | if revrangesep in spec: |
|
155 | if revrangesep in spec: | |
156 | start, end = spec.split(revrangesep, 1) |
|
156 | start, end = spec.split(revrangesep, 1) | |
157 | start = revfix(repo, start, 0) |
|
157 | start = revfix(repo, start, 0) | |
158 | end = revfix(repo, end, len(repo) - 1) |
|
158 | end = revfix(repo, end, len(repo) - 1) | |
159 | step = start > end and -1 or 1 |
|
159 | step = start > end and -1 or 1 | |
160 | for rev in xrange(start, end + step, step): |
|
160 | for rev in xrange(start, end + step, step): | |
161 | if rev in seen: |
|
161 | if rev in seen: | |
162 | continue |
|
162 | continue | |
163 | seen.add(rev) |
|
163 | seen.add(rev) | |
164 | l.append(rev) |
|
164 | l.append(rev) | |
165 | continue |
|
165 | continue | |
166 | elif spec and spec in repo: # single unquoted rev |
|
166 | elif spec and spec in repo: # single unquoted rev | |
167 | rev = revfix(repo, spec, None) |
|
167 | rev = revfix(repo, spec, None) | |
168 | if rev in seen: |
|
168 | if rev in seen: | |
169 | continue |
|
169 | continue | |
170 | seen.add(rev) |
|
170 | seen.add(rev) | |
171 | l.append(rev) |
|
171 | l.append(rev) | |
172 | continue |
|
172 | continue | |
173 | except error.RepoLookupError: |
|
173 | except error.RepoLookupError: | |
174 | pass |
|
174 | pass | |
175 |
|
175 | |||
176 | # fall through to new-style queries if old-style fails |
|
176 | # fall through to new-style queries if old-style fails | |
177 | m = revset.match(spec) |
|
177 | m = revset.match(spec) | |
178 | for r in m(repo, range(len(repo))): |
|
178 | for r in m(repo, range(len(repo))): | |
179 | if r not in seen: |
|
179 | if r not in seen: | |
180 | l.append(r) |
|
180 | l.append(r) | |
181 | seen.update(l) |
|
181 | seen.update(l) | |
182 |
|
182 | |||
183 | return l |
|
183 | return l | |
184 |
|
184 | |||
185 | def make_filename(repo, pat, node, |
|
185 | def make_filename(repo, pat, node, | |
186 | total=None, seqno=None, revwidth=None, pathname=None): |
|
186 | total=None, seqno=None, revwidth=None, pathname=None): | |
187 | node_expander = { |
|
187 | node_expander = { | |
188 | 'H': lambda: hex(node), |
|
188 | 'H': lambda: hex(node), | |
189 | 'R': lambda: str(repo.changelog.rev(node)), |
|
189 | 'R': lambda: str(repo.changelog.rev(node)), | |
190 | 'h': lambda: short(node), |
|
190 | 'h': lambda: short(node), | |
191 | } |
|
191 | } | |
192 | expander = { |
|
192 | expander = { | |
193 | '%': lambda: '%', |
|
193 | '%': lambda: '%', | |
194 | 'b': lambda: os.path.basename(repo.root), |
|
194 | 'b': lambda: os.path.basename(repo.root), | |
195 | } |
|
195 | } | |
196 |
|
196 | |||
197 | try: |
|
197 | try: | |
198 | if node: |
|
198 | if node: | |
199 | expander.update(node_expander) |
|
199 | expander.update(node_expander) | |
200 | if node: |
|
200 | if node: | |
201 | expander['r'] = (lambda: |
|
201 | expander['r'] = (lambda: | |
202 | str(repo.changelog.rev(node)).zfill(revwidth or 0)) |
|
202 | str(repo.changelog.rev(node)).zfill(revwidth or 0)) | |
203 | if total is not None: |
|
203 | if total is not None: | |
204 | expander['N'] = lambda: str(total) |
|
204 | expander['N'] = lambda: str(total) | |
205 | if seqno is not None: |
|
205 | if seqno is not None: | |
206 | expander['n'] = lambda: str(seqno) |
|
206 | expander['n'] = lambda: str(seqno) | |
207 | if total is not None and seqno is not None: |
|
207 | if total is not None and seqno is not None: | |
208 | expander['n'] = lambda: str(seqno).zfill(len(str(total))) |
|
208 | expander['n'] = lambda: str(seqno).zfill(len(str(total))) | |
209 | if pathname is not None: |
|
209 | if pathname is not None: | |
210 | expander['s'] = lambda: os.path.basename(pathname) |
|
210 | expander['s'] = lambda: os.path.basename(pathname) | |
211 | expander['d'] = lambda: os.path.dirname(pathname) or '.' |
|
211 | expander['d'] = lambda: os.path.dirname(pathname) or '.' | |
212 | expander['p'] = lambda: pathname |
|
212 | expander['p'] = lambda: pathname | |
213 |
|
213 | |||
214 | newname = [] |
|
214 | newname = [] | |
215 | patlen = len(pat) |
|
215 | patlen = len(pat) | |
216 | i = 0 |
|
216 | i = 0 | |
217 | while i < patlen: |
|
217 | while i < patlen: | |
218 | c = pat[i] |
|
218 | c = pat[i] | |
219 | if c == '%': |
|
219 | if c == '%': | |
220 | i += 1 |
|
220 | i += 1 | |
221 | c = pat[i] |
|
221 | c = pat[i] | |
222 | c = expander[c]() |
|
222 | c = expander[c]() | |
223 | newname.append(c) |
|
223 | newname.append(c) | |
224 | i += 1 |
|
224 | i += 1 | |
225 | return ''.join(newname) |
|
225 | return ''.join(newname) | |
226 | except KeyError, inst: |
|
226 | except KeyError, inst: | |
227 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % |
|
227 | raise util.Abort(_("invalid format spec '%%%s' in output filename") % | |
228 | inst.args[0]) |
|
228 | inst.args[0]) | |
229 |
|
229 | |||
230 | def make_file(repo, pat, node=None, |
|
230 | def make_file(repo, pat, node=None, | |
231 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): |
|
231 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): | |
232 |
|
232 | |||
233 | writable = mode not in ('r', 'rb') |
|
233 | writable = mode not in ('r', 'rb') | |
234 |
|
234 | |||
235 | if not pat or pat == '-': |
|
235 | if not pat or pat == '-': | |
236 | fp = writable and sys.stdout or sys.stdin |
|
236 | fp = writable and sys.stdout or sys.stdin | |
237 | return os.fdopen(os.dup(fp.fileno()), mode) |
|
237 | return os.fdopen(os.dup(fp.fileno()), mode) | |
238 | if hasattr(pat, 'write') and writable: |
|
238 | if hasattr(pat, 'write') and writable: | |
239 | return pat |
|
239 | return pat | |
240 | if hasattr(pat, 'read') and 'r' in mode: |
|
240 | if hasattr(pat, 'read') and 'r' in mode: | |
241 | return pat |
|
241 | return pat | |
242 | return open(make_filename(repo, pat, node, total, seqno, revwidth, |
|
242 | return open(make_filename(repo, pat, node, total, seqno, revwidth, | |
243 | pathname), |
|
243 | pathname), | |
244 | mode) |
|
244 | mode) | |
245 |
|
245 | |||
246 | def expandpats(pats): |
|
246 | def expandpats(pats): | |
247 | if not util.expandglobs: |
|
247 | if not util.expandglobs: | |
248 | return list(pats) |
|
248 | return list(pats) | |
249 | ret = [] |
|
249 | ret = [] | |
250 | for p in pats: |
|
250 | for p in pats: | |
251 | kind, name = matchmod._patsplit(p, None) |
|
251 | kind, name = matchmod._patsplit(p, None) | |
252 | if kind is None: |
|
252 | if kind is None: | |
253 | try: |
|
253 | try: | |
254 | globbed = glob.glob(name) |
|
254 | globbed = glob.glob(name) | |
255 | except re.error: |
|
255 | except re.error: | |
256 | globbed = [name] |
|
256 | globbed = [name] | |
257 | if globbed: |
|
257 | if globbed: | |
258 | ret.extend(globbed) |
|
258 | ret.extend(globbed) | |
259 | continue |
|
259 | continue | |
260 | ret.append(p) |
|
260 | ret.append(p) | |
261 | return ret |
|
261 | return ret | |
262 |
|
262 | |||
263 | def match(repo, pats=[], opts={}, globbed=False, default='relpath'): |
|
263 | def match(repo, pats=[], opts={}, globbed=False, default='relpath'): | |
264 | if pats == ("",): |
|
264 | if pats == ("",): | |
265 | pats = [] |
|
265 | pats = [] | |
266 | if not globbed and default == 'relpath': |
|
266 | if not globbed and default == 'relpath': | |
267 | pats = expandpats(pats or []) |
|
267 | pats = expandpats(pats or []) | |
268 | m = matchmod.match(repo.root, repo.getcwd(), pats, |
|
268 | m = matchmod.match(repo.root, repo.getcwd(), pats, | |
269 | opts.get('include'), opts.get('exclude'), default, |
|
269 | opts.get('include'), opts.get('exclude'), default, | |
270 | auditor=repo.auditor) |
|
270 | auditor=repo.auditor) | |
271 | def badfn(f, msg): |
|
271 | def badfn(f, msg): | |
272 | repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) |
|
272 | repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) | |
273 | m.bad = badfn |
|
273 | m.bad = badfn | |
274 | return m |
|
274 | return m | |
275 |
|
275 | |||
276 | def matchall(repo): |
|
276 | def matchall(repo): | |
277 | return matchmod.always(repo.root, repo.getcwd()) |
|
277 | return matchmod.always(repo.root, repo.getcwd()) | |
278 |
|
278 | |||
279 | def matchfiles(repo, files): |
|
279 | def matchfiles(repo, files): | |
280 | return matchmod.exact(repo.root, repo.getcwd(), files) |
|
280 | return matchmod.exact(repo.root, repo.getcwd(), files) | |
281 |
|
281 | |||
282 | def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): |
|
282 | def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None): | |
283 | if dry_run is None: |
|
283 | if dry_run is None: | |
284 | dry_run = opts.get('dry_run') |
|
284 | dry_run = opts.get('dry_run') | |
285 | if similarity is None: |
|
285 | if similarity is None: | |
286 | similarity = float(opts.get('similarity') or 0) |
|
286 | similarity = float(opts.get('similarity') or 0) | |
287 | # we'd use status here, except handling of symlinks and ignore is tricky |
|
287 | # we'd use status here, except handling of symlinks and ignore is tricky | |
288 | added, unknown, deleted, removed = [], [], [], [] |
|
288 | added, unknown, deleted, removed = [], [], [], [] | |
289 | audit_path = util.path_auditor(repo.root) |
|
289 | audit_path = util.path_auditor(repo.root) | |
290 | m = match(repo, pats, opts) |
|
290 | m = match(repo, pats, opts) | |
291 | for abs in repo.walk(m): |
|
291 | for abs in repo.walk(m): | |
292 | target = repo.wjoin(abs) |
|
292 | target = repo.wjoin(abs) | |
293 | good = True |
|
293 | good = True | |
294 | try: |
|
294 | try: | |
295 | audit_path(abs) |
|
295 | audit_path(abs) | |
296 | except: |
|
296 | except: | |
297 | good = False |
|
297 | good = False | |
298 | rel = m.rel(abs) |
|
298 | rel = m.rel(abs) | |
299 | exact = m.exact(abs) |
|
299 | exact = m.exact(abs) | |
300 | if good and abs not in repo.dirstate: |
|
300 | if good and abs not in repo.dirstate: | |
301 | unknown.append(abs) |
|
301 | unknown.append(abs) | |
302 | if repo.ui.verbose or not exact: |
|
302 | if repo.ui.verbose or not exact: | |
303 | repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
|
303 | repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) | |
304 | elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) |
|
304 | elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) | |
305 | or (os.path.isdir(target) and not os.path.islink(target))): |
|
305 | or (os.path.isdir(target) and not os.path.islink(target))): | |
306 | deleted.append(abs) |
|
306 | deleted.append(abs) | |
307 | if repo.ui.verbose or not exact: |
|
307 | if repo.ui.verbose or not exact: | |
308 | repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) |
|
308 | repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) | |
309 | # for finding renames |
|
309 | # for finding renames | |
310 | elif repo.dirstate[abs] == 'r': |
|
310 | elif repo.dirstate[abs] == 'r': | |
311 | removed.append(abs) |
|
311 | removed.append(abs) | |
312 | elif repo.dirstate[abs] == 'a': |
|
312 | elif repo.dirstate[abs] == 'a': | |
313 | added.append(abs) |
|
313 | added.append(abs) | |
314 | copies = {} |
|
314 | copies = {} | |
315 | if similarity > 0: |
|
315 | if similarity > 0: | |
316 | for old, new, score in similar.findrenames(repo, |
|
316 | for old, new, score in similar.findrenames(repo, | |
317 | added + unknown, removed + deleted, similarity): |
|
317 | added + unknown, removed + deleted, similarity): | |
318 | if repo.ui.verbose or not m.exact(old) or not m.exact(new): |
|
318 | if repo.ui.verbose or not m.exact(old) or not m.exact(new): | |
319 | repo.ui.status(_('recording removal of %s as rename to %s ' |
|
319 | repo.ui.status(_('recording removal of %s as rename to %s ' | |
320 | '(%d%% similar)\n') % |
|
320 | '(%d%% similar)\n') % | |
321 | (m.rel(old), m.rel(new), score * 100)) |
|
321 | (m.rel(old), m.rel(new), score * 100)) | |
322 | copies[new] = old |
|
322 | copies[new] = old | |
323 |
|
323 | |||
324 | if not dry_run: |
|
324 | if not dry_run: | |
325 | wctx = repo[None] |
|
325 | wctx = repo[None] | |
326 | wlock = repo.wlock() |
|
326 | wlock = repo.wlock() | |
327 | try: |
|
327 | try: | |
328 | wctx.remove(deleted) |
|
328 | wctx.remove(deleted) | |
329 | wctx.add(unknown) |
|
329 | wctx.add(unknown) | |
330 | for new, old in copies.iteritems(): |
|
330 | for new, old in copies.iteritems(): | |
331 | wctx.copy(old, new) |
|
331 | wctx.copy(old, new) | |
332 | finally: |
|
332 | finally: | |
333 | wlock.release() |
|
333 | wlock.release() | |
334 |
|
334 | |||
335 | def updatedir(ui, repo, patches, similarity=0): |
|
335 | def updatedir(ui, repo, patches, similarity=0): | |
336 | '''Update dirstate after patch application according to metadata''' |
|
336 | '''Update dirstate after patch application according to metadata''' | |
337 | if not patches: |
|
337 | if not patches: | |
338 | return |
|
338 | return | |
339 | copies = [] |
|
339 | copies = [] | |
340 | removes = set() |
|
340 | removes = set() | |
341 | cfiles = patches.keys() |
|
341 | cfiles = patches.keys() | |
342 | cwd = repo.getcwd() |
|
342 | cwd = repo.getcwd() | |
343 | if cwd: |
|
343 | if cwd: | |
344 | cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] |
|
344 | cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] | |
345 | for f in patches: |
|
345 | for f in patches: | |
346 | gp = patches[f] |
|
346 | gp = patches[f] | |
347 | if not gp: |
|
347 | if not gp: | |
348 | continue |
|
348 | continue | |
349 | if gp.op == 'RENAME': |
|
349 | if gp.op == 'RENAME': | |
350 | copies.append((gp.oldpath, gp.path)) |
|
350 | copies.append((gp.oldpath, gp.path)) | |
351 | removes.add(gp.oldpath) |
|
351 | removes.add(gp.oldpath) | |
352 | elif gp.op == 'COPY': |
|
352 | elif gp.op == 'COPY': | |
353 | copies.append((gp.oldpath, gp.path)) |
|
353 | copies.append((gp.oldpath, gp.path)) | |
354 | elif gp.op == 'DELETE': |
|
354 | elif gp.op == 'DELETE': | |
355 | removes.add(gp.path) |
|
355 | removes.add(gp.path) | |
356 |
|
356 | |||
357 | wctx = repo[None] |
|
357 | wctx = repo[None] | |
358 | for src, dst in copies: |
|
358 | for src, dst in copies: | |
359 | dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd) |
|
359 | dirstatecopy(ui, repo, wctx, src, dst, cwd=cwd) | |
360 | if (not similarity) and removes: |
|
360 | if (not similarity) and removes: | |
361 | wctx.remove(sorted(removes), True) |
|
361 | wctx.remove(sorted(removes), True) | |
362 |
|
362 | |||
363 | for f in patches: |
|
363 | for f in patches: | |
364 | gp = patches[f] |
|
364 | gp = patches[f] | |
365 | if gp and gp.mode: |
|
365 | if gp and gp.mode: | |
366 | islink, isexec = gp.mode |
|
366 | islink, isexec = gp.mode | |
367 | dst = repo.wjoin(gp.path) |
|
367 | dst = repo.wjoin(gp.path) | |
368 | # patch won't create empty files |
|
368 | # patch won't create empty files | |
369 | if gp.op == 'ADD' and not os.path.lexists(dst): |
|
369 | if gp.op == 'ADD' and not os.path.lexists(dst): | |
370 | flags = (isexec and 'x' or '') + (islink and 'l' or '') |
|
370 | flags = (isexec and 'x' or '') + (islink and 'l' or '') | |
371 | repo.wwrite(gp.path, '', flags) |
|
371 | repo.wwrite(gp.path, '', flags) | |
372 | util.set_flags(dst, islink, isexec) |
|
372 | util.set_flags(dst, islink, isexec) | |
373 | addremove(repo, cfiles, similarity=similarity) |
|
373 | addremove(repo, cfiles, similarity=similarity) | |
374 | files = patches.keys() |
|
374 | files = patches.keys() | |
375 | files.extend([r for r in removes if r not in files]) |
|
375 | files.extend([r for r in removes if r not in files]) | |
376 | return sorted(files) |
|
376 | return sorted(files) | |
377 |
|
377 | |||
378 | def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): |
|
378 | def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): | |
379 | """Update the dirstate to reflect the intent of copying src to dst. For |
|
379 | """Update the dirstate to reflect the intent of copying src to dst. For | |
380 | different reasons it might not end with dst being marked as copied from src. |
|
380 | different reasons it might not end with dst being marked as copied from src. | |
381 | """ |
|
381 | """ | |
382 | origsrc = repo.dirstate.copied(src) or src |
|
382 | origsrc = repo.dirstate.copied(src) or src | |
383 | if dst == origsrc: # copying back a copy? |
|
383 | if dst == origsrc: # copying back a copy? | |
384 | if repo.dirstate[dst] not in 'mn' and not dryrun: |
|
384 | if repo.dirstate[dst] not in 'mn' and not dryrun: | |
385 | repo.dirstate.normallookup(dst) |
|
385 | repo.dirstate.normallookup(dst) | |
386 | else: |
|
386 | else: | |
387 | if repo.dirstate[origsrc] == 'a' and origsrc == src: |
|
387 | if repo.dirstate[origsrc] == 'a' and origsrc == src: | |
388 | if not ui.quiet: |
|
388 | if not ui.quiet: | |
389 | ui.warn(_("%s has not been committed yet, so no copy " |
|
389 | ui.warn(_("%s has not been committed yet, so no copy " | |
390 | "data will be stored for %s.\n") |
|
390 | "data will be stored for %s.\n") | |
391 | % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd))) |
|
391 | % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd))) | |
392 | if repo.dirstate[dst] in '?r' and not dryrun: |
|
392 | if repo.dirstate[dst] in '?r' and not dryrun: | |
393 | wctx.add([dst]) |
|
393 | wctx.add([dst]) | |
394 | elif not dryrun: |
|
394 | elif not dryrun: | |
395 | wctx.copy(origsrc, dst) |
|
395 | wctx.copy(origsrc, dst) | |
396 |
|
396 | |||
397 | def copy(ui, repo, pats, opts, rename=False): |
|
397 | def copy(ui, repo, pats, opts, rename=False): | |
398 | # called with the repo lock held |
|
398 | # called with the repo lock held | |
399 | # |
|
399 | # | |
400 | # hgsep => pathname that uses "/" to separate directories |
|
400 | # hgsep => pathname that uses "/" to separate directories | |
401 | # ossep => pathname that uses os.sep to separate directories |
|
401 | # ossep => pathname that uses os.sep to separate directories | |
402 | cwd = repo.getcwd() |
|
402 | cwd = repo.getcwd() | |
403 | targets = {} |
|
403 | targets = {} | |
404 | after = opts.get("after") |
|
404 | after = opts.get("after") | |
405 | dryrun = opts.get("dry_run") |
|
405 | dryrun = opts.get("dry_run") | |
406 | wctx = repo[None] |
|
406 | wctx = repo[None] | |
407 |
|
407 | |||
408 | def walkpat(pat): |
|
408 | def walkpat(pat): | |
409 | srcs = [] |
|
409 | srcs = [] | |
410 | badstates = after and '?' or '?r' |
|
410 | badstates = after and '?' or '?r' | |
411 | m = match(repo, [pat], opts, globbed=True) |
|
411 | m = match(repo, [pat], opts, globbed=True) | |
412 | for abs in repo.walk(m): |
|
412 | for abs in repo.walk(m): | |
413 | state = repo.dirstate[abs] |
|
413 | state = repo.dirstate[abs] | |
414 | rel = m.rel(abs) |
|
414 | rel = m.rel(abs) | |
415 | exact = m.exact(abs) |
|
415 | exact = m.exact(abs) | |
416 | if state in badstates: |
|
416 | if state in badstates: | |
417 | if exact and state == '?': |
|
417 | if exact and state == '?': | |
418 | ui.warn(_('%s: not copying - file is not managed\n') % rel) |
|
418 | ui.warn(_('%s: not copying - file is not managed\n') % rel) | |
419 | if exact and state == 'r': |
|
419 | if exact and state == 'r': | |
420 | ui.warn(_('%s: not copying - file has been marked for' |
|
420 | ui.warn(_('%s: not copying - file has been marked for' | |
421 | ' remove\n') % rel) |
|
421 | ' remove\n') % rel) | |
422 | continue |
|
422 | continue | |
423 | # abs: hgsep |
|
423 | # abs: hgsep | |
424 | # rel: ossep |
|
424 | # rel: ossep | |
425 | srcs.append((abs, rel, exact)) |
|
425 | srcs.append((abs, rel, exact)) | |
426 | return srcs |
|
426 | return srcs | |
427 |
|
427 | |||
428 | # abssrc: hgsep |
|
428 | # abssrc: hgsep | |
429 | # relsrc: ossep |
|
429 | # relsrc: ossep | |
430 | # otarget: ossep |
|
430 | # otarget: ossep | |
431 | def copyfile(abssrc, relsrc, otarget, exact): |
|
431 | def copyfile(abssrc, relsrc, otarget, exact): | |
432 | abstarget = util.canonpath(repo.root, cwd, otarget) |
|
432 | abstarget = util.canonpath(repo.root, cwd, otarget) | |
433 | reltarget = repo.pathto(abstarget, cwd) |
|
433 | reltarget = repo.pathto(abstarget, cwd) | |
434 | target = repo.wjoin(abstarget) |
|
434 | target = repo.wjoin(abstarget) | |
435 | src = repo.wjoin(abssrc) |
|
435 | src = repo.wjoin(abssrc) | |
436 | state = repo.dirstate[abstarget] |
|
436 | state = repo.dirstate[abstarget] | |
437 |
|
437 | |||
|
438 | util.checkfilename(abstarget) | |||
|
439 | ||||
438 | # check for collisions |
|
440 | # check for collisions | |
439 | prevsrc = targets.get(abstarget) |
|
441 | prevsrc = targets.get(abstarget) | |
440 | if prevsrc is not None: |
|
442 | if prevsrc is not None: | |
441 | ui.warn(_('%s: not overwriting - %s collides with %s\n') % |
|
443 | ui.warn(_('%s: not overwriting - %s collides with %s\n') % | |
442 | (reltarget, repo.pathto(abssrc, cwd), |
|
444 | (reltarget, repo.pathto(abssrc, cwd), | |
443 | repo.pathto(prevsrc, cwd))) |
|
445 | repo.pathto(prevsrc, cwd))) | |
444 | return |
|
446 | return | |
445 |
|
447 | |||
446 | # check for overwrites |
|
448 | # check for overwrites | |
447 | exists = os.path.lexists(target) |
|
449 | exists = os.path.lexists(target) | |
448 | if not after and exists or after and state in 'mn': |
|
450 | if not after and exists or after and state in 'mn': | |
449 | if not opts['force']: |
|
451 | if not opts['force']: | |
450 | ui.warn(_('%s: not overwriting - file exists\n') % |
|
452 | ui.warn(_('%s: not overwriting - file exists\n') % | |
451 | reltarget) |
|
453 | reltarget) | |
452 | return |
|
454 | return | |
453 |
|
455 | |||
454 | if after: |
|
456 | if after: | |
455 | if not exists: |
|
457 | if not exists: | |
456 | if rename: |
|
458 | if rename: | |
457 | ui.warn(_('%s: not recording move - %s does not exist\n') % |
|
459 | ui.warn(_('%s: not recording move - %s does not exist\n') % | |
458 | (relsrc, reltarget)) |
|
460 | (relsrc, reltarget)) | |
459 | else: |
|
461 | else: | |
460 | ui.warn(_('%s: not recording copy - %s does not exist\n') % |
|
462 | ui.warn(_('%s: not recording copy - %s does not exist\n') % | |
461 | (relsrc, reltarget)) |
|
463 | (relsrc, reltarget)) | |
462 | return |
|
464 | return | |
463 | elif not dryrun: |
|
465 | elif not dryrun: | |
464 | try: |
|
466 | try: | |
465 | if exists: |
|
467 | if exists: | |
466 | os.unlink(target) |
|
468 | os.unlink(target) | |
467 | targetdir = os.path.dirname(target) or '.' |
|
469 | targetdir = os.path.dirname(target) or '.' | |
468 | if not os.path.isdir(targetdir): |
|
470 | if not os.path.isdir(targetdir): | |
469 | os.makedirs(targetdir) |
|
471 | os.makedirs(targetdir) | |
470 | util.copyfile(src, target) |
|
472 | util.copyfile(src, target) | |
471 | except IOError, inst: |
|
473 | except IOError, inst: | |
472 | if inst.errno == errno.ENOENT: |
|
474 | if inst.errno == errno.ENOENT: | |
473 | ui.warn(_('%s: deleted in working copy\n') % relsrc) |
|
475 | ui.warn(_('%s: deleted in working copy\n') % relsrc) | |
474 | else: |
|
476 | else: | |
475 | ui.warn(_('%s: cannot copy - %s\n') % |
|
477 | ui.warn(_('%s: cannot copy - %s\n') % | |
476 | (relsrc, inst.strerror)) |
|
478 | (relsrc, inst.strerror)) | |
477 | return True # report a failure |
|
479 | return True # report a failure | |
478 |
|
480 | |||
479 | if ui.verbose or not exact: |
|
481 | if ui.verbose or not exact: | |
480 | if rename: |
|
482 | if rename: | |
481 | ui.status(_('moving %s to %s\n') % (relsrc, reltarget)) |
|
483 | ui.status(_('moving %s to %s\n') % (relsrc, reltarget)) | |
482 | else: |
|
484 | else: | |
483 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
|
485 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | |
484 |
|
486 | |||
485 | targets[abstarget] = abssrc |
|
487 | targets[abstarget] = abssrc | |
486 |
|
488 | |||
487 | # fix up dirstate |
|
489 | # fix up dirstate | |
488 | dirstatecopy(ui, repo, wctx, abssrc, abstarget, dryrun=dryrun, cwd=cwd) |
|
490 | dirstatecopy(ui, repo, wctx, abssrc, abstarget, dryrun=dryrun, cwd=cwd) | |
489 | if rename and not dryrun: |
|
491 | if rename and not dryrun: | |
490 | wctx.remove([abssrc], not after) |
|
492 | wctx.remove([abssrc], not after) | |
491 |
|
493 | |||
492 | # pat: ossep |
|
494 | # pat: ossep | |
493 | # dest ossep |
|
495 | # dest ossep | |
494 | # srcs: list of (hgsep, hgsep, ossep, bool) |
|
496 | # srcs: list of (hgsep, hgsep, ossep, bool) | |
495 | # return: function that takes hgsep and returns ossep |
|
497 | # return: function that takes hgsep and returns ossep | |
496 | def targetpathfn(pat, dest, srcs): |
|
498 | def targetpathfn(pat, dest, srcs): | |
497 | if os.path.isdir(pat): |
|
499 | if os.path.isdir(pat): | |
498 | abspfx = util.canonpath(repo.root, cwd, pat) |
|
500 | abspfx = util.canonpath(repo.root, cwd, pat) | |
499 | abspfx = util.localpath(abspfx) |
|
501 | abspfx = util.localpath(abspfx) | |
500 | if destdirexists: |
|
502 | if destdirexists: | |
501 | striplen = len(os.path.split(abspfx)[0]) |
|
503 | striplen = len(os.path.split(abspfx)[0]) | |
502 | else: |
|
504 | else: | |
503 | striplen = len(abspfx) |
|
505 | striplen = len(abspfx) | |
504 | if striplen: |
|
506 | if striplen: | |
505 | striplen += len(os.sep) |
|
507 | striplen += len(os.sep) | |
506 | res = lambda p: os.path.join(dest, util.localpath(p)[striplen:]) |
|
508 | res = lambda p: os.path.join(dest, util.localpath(p)[striplen:]) | |
507 | elif destdirexists: |
|
509 | elif destdirexists: | |
508 | res = lambda p: os.path.join(dest, |
|
510 | res = lambda p: os.path.join(dest, | |
509 | os.path.basename(util.localpath(p))) |
|
511 | os.path.basename(util.localpath(p))) | |
510 | else: |
|
512 | else: | |
511 | res = lambda p: dest |
|
513 | res = lambda p: dest | |
512 | return res |
|
514 | return res | |
513 |
|
515 | |||
514 | # pat: ossep |
|
516 | # pat: ossep | |
515 | # dest ossep |
|
517 | # dest ossep | |
516 | # srcs: list of (hgsep, hgsep, ossep, bool) |
|
518 | # srcs: list of (hgsep, hgsep, ossep, bool) | |
517 | # return: function that takes hgsep and returns ossep |
|
519 | # return: function that takes hgsep and returns ossep | |
518 | def targetpathafterfn(pat, dest, srcs): |
|
520 | def targetpathafterfn(pat, dest, srcs): | |
519 | if matchmod.patkind(pat): |
|
521 | if matchmod.patkind(pat): | |
520 | # a mercurial pattern |
|
522 | # a mercurial pattern | |
521 | res = lambda p: os.path.join(dest, |
|
523 | res = lambda p: os.path.join(dest, | |
522 | os.path.basename(util.localpath(p))) |
|
524 | os.path.basename(util.localpath(p))) | |
523 | else: |
|
525 | else: | |
524 | abspfx = util.canonpath(repo.root, cwd, pat) |
|
526 | abspfx = util.canonpath(repo.root, cwd, pat) | |
525 | if len(abspfx) < len(srcs[0][0]): |
|
527 | if len(abspfx) < len(srcs[0][0]): | |
526 | # A directory. Either the target path contains the last |
|
528 | # A directory. Either the target path contains the last | |
527 | # component of the source path or it does not. |
|
529 | # component of the source path or it does not. | |
528 | def evalpath(striplen): |
|
530 | def evalpath(striplen): | |
529 | score = 0 |
|
531 | score = 0 | |
530 | for s in srcs: |
|
532 | for s in srcs: | |
531 | t = os.path.join(dest, util.localpath(s[0])[striplen:]) |
|
533 | t = os.path.join(dest, util.localpath(s[0])[striplen:]) | |
532 | if os.path.lexists(t): |
|
534 | if os.path.lexists(t): | |
533 | score += 1 |
|
535 | score += 1 | |
534 | return score |
|
536 | return score | |
535 |
|
537 | |||
536 | abspfx = util.localpath(abspfx) |
|
538 | abspfx = util.localpath(abspfx) | |
537 | striplen = len(abspfx) |
|
539 | striplen = len(abspfx) | |
538 | if striplen: |
|
540 | if striplen: | |
539 | striplen += len(os.sep) |
|
541 | striplen += len(os.sep) | |
540 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): |
|
542 | if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): | |
541 | score = evalpath(striplen) |
|
543 | score = evalpath(striplen) | |
542 | striplen1 = len(os.path.split(abspfx)[0]) |
|
544 | striplen1 = len(os.path.split(abspfx)[0]) | |
543 | if striplen1: |
|
545 | if striplen1: | |
544 | striplen1 += len(os.sep) |
|
546 | striplen1 += len(os.sep) | |
545 | if evalpath(striplen1) > score: |
|
547 | if evalpath(striplen1) > score: | |
546 | striplen = striplen1 |
|
548 | striplen = striplen1 | |
547 | res = lambda p: os.path.join(dest, |
|
549 | res = lambda p: os.path.join(dest, | |
548 | util.localpath(p)[striplen:]) |
|
550 | util.localpath(p)[striplen:]) | |
549 | else: |
|
551 | else: | |
550 | # a file |
|
552 | # a file | |
551 | if destdirexists: |
|
553 | if destdirexists: | |
552 | res = lambda p: os.path.join(dest, |
|
554 | res = lambda p: os.path.join(dest, | |
553 | os.path.basename(util.localpath(p))) |
|
555 | os.path.basename(util.localpath(p))) | |
554 | else: |
|
556 | else: | |
555 | res = lambda p: dest |
|
557 | res = lambda p: dest | |
556 | return res |
|
558 | return res | |
557 |
|
559 | |||
558 |
|
560 | |||
559 | pats = expandpats(pats) |
|
561 | pats = expandpats(pats) | |
560 | if not pats: |
|
562 | if not pats: | |
561 | raise util.Abort(_('no source or destination specified')) |
|
563 | raise util.Abort(_('no source or destination specified')) | |
562 | if len(pats) == 1: |
|
564 | if len(pats) == 1: | |
563 | raise util.Abort(_('no destination specified')) |
|
565 | raise util.Abort(_('no destination specified')) | |
564 | dest = pats.pop() |
|
566 | dest = pats.pop() | |
565 | destdirexists = os.path.isdir(dest) and not os.path.islink(dest) |
|
567 | destdirexists = os.path.isdir(dest) and not os.path.islink(dest) | |
566 | if not destdirexists: |
|
568 | if not destdirexists: | |
567 | if len(pats) > 1 or matchmod.patkind(pats[0]): |
|
569 | if len(pats) > 1 or matchmod.patkind(pats[0]): | |
568 | raise util.Abort(_('with multiple sources, destination must be an ' |
|
570 | raise util.Abort(_('with multiple sources, destination must be an ' | |
569 | 'existing directory')) |
|
571 | 'existing directory')) | |
570 | if util.endswithsep(dest): |
|
572 | if util.endswithsep(dest): | |
571 | raise util.Abort(_('destination %s is not a directory') % dest) |
|
573 | raise util.Abort(_('destination %s is not a directory') % dest) | |
572 |
|
574 | |||
573 | tfn = targetpathfn |
|
575 | tfn = targetpathfn | |
574 | if after: |
|
576 | if after: | |
575 | tfn = targetpathafterfn |
|
577 | tfn = targetpathafterfn | |
576 | copylist = [] |
|
578 | copylist = [] | |
577 | for pat in pats: |
|
579 | for pat in pats: | |
578 | srcs = walkpat(pat) |
|
580 | srcs = walkpat(pat) | |
579 | if not srcs: |
|
581 | if not srcs: | |
580 | continue |
|
582 | continue | |
581 | copylist.append((tfn(pat, dest, srcs), srcs)) |
|
583 | copylist.append((tfn(pat, dest, srcs), srcs)) | |
582 | if not copylist: |
|
584 | if not copylist: | |
583 | raise util.Abort(_('no files to copy')) |
|
585 | raise util.Abort(_('no files to copy')) | |
584 |
|
586 | |||
585 | errors = 0 |
|
587 | errors = 0 | |
586 | for targetpath, srcs in copylist: |
|
588 | for targetpath, srcs in copylist: | |
587 | for abssrc, relsrc, exact in srcs: |
|
589 | for abssrc, relsrc, exact in srcs: | |
588 | if copyfile(abssrc, relsrc, targetpath(abssrc), exact): |
|
590 | if copyfile(abssrc, relsrc, targetpath(abssrc), exact): | |
589 | errors += 1 |
|
591 | errors += 1 | |
590 |
|
592 | |||
591 | if errors: |
|
593 | if errors: | |
592 | ui.warn(_('(consider using --after)\n')) |
|
594 | ui.warn(_('(consider using --after)\n')) | |
593 |
|
595 | |||
594 | return errors != 0 |
|
596 | return errors != 0 | |
595 |
|
597 | |||
596 | def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, |
|
598 | def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, | |
597 | runargs=None, appendpid=False): |
|
599 | runargs=None, appendpid=False): | |
598 | '''Run a command as a service.''' |
|
600 | '''Run a command as a service.''' | |
599 |
|
601 | |||
600 | if opts['daemon'] and not opts['daemon_pipefds']: |
|
602 | if opts['daemon'] and not opts['daemon_pipefds']: | |
601 | # Signal child process startup with file removal |
|
603 | # Signal child process startup with file removal | |
602 | lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') |
|
604 | lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-') | |
603 | os.close(lockfd) |
|
605 | os.close(lockfd) | |
604 | try: |
|
606 | try: | |
605 | if not runargs: |
|
607 | if not runargs: | |
606 | runargs = util.hgcmd() + sys.argv[1:] |
|
608 | runargs = util.hgcmd() + sys.argv[1:] | |
607 | runargs.append('--daemon-pipefds=%s' % lockpath) |
|
609 | runargs.append('--daemon-pipefds=%s' % lockpath) | |
608 | # Don't pass --cwd to the child process, because we've already |
|
610 | # Don't pass --cwd to the child process, because we've already | |
609 | # changed directory. |
|
611 | # changed directory. | |
610 | for i in xrange(1, len(runargs)): |
|
612 | for i in xrange(1, len(runargs)): | |
611 | if runargs[i].startswith('--cwd='): |
|
613 | if runargs[i].startswith('--cwd='): | |
612 | del runargs[i] |
|
614 | del runargs[i] | |
613 | break |
|
615 | break | |
614 | elif runargs[i].startswith('--cwd'): |
|
616 | elif runargs[i].startswith('--cwd'): | |
615 | del runargs[i:i + 2] |
|
617 | del runargs[i:i + 2] | |
616 | break |
|
618 | break | |
617 | def condfn(): |
|
619 | def condfn(): | |
618 | return not os.path.exists(lockpath) |
|
620 | return not os.path.exists(lockpath) | |
619 | pid = util.rundetached(runargs, condfn) |
|
621 | pid = util.rundetached(runargs, condfn) | |
620 | if pid < 0: |
|
622 | if pid < 0: | |
621 | raise util.Abort(_('child process failed to start')) |
|
623 | raise util.Abort(_('child process failed to start')) | |
622 | finally: |
|
624 | finally: | |
623 | try: |
|
625 | try: | |
624 | os.unlink(lockpath) |
|
626 | os.unlink(lockpath) | |
625 | except OSError, e: |
|
627 | except OSError, e: | |
626 | if e.errno != errno.ENOENT: |
|
628 | if e.errno != errno.ENOENT: | |
627 | raise |
|
629 | raise | |
628 | if parentfn: |
|
630 | if parentfn: | |
629 | return parentfn(pid) |
|
631 | return parentfn(pid) | |
630 | else: |
|
632 | else: | |
631 | return |
|
633 | return | |
632 |
|
634 | |||
633 | if initfn: |
|
635 | if initfn: | |
634 | initfn() |
|
636 | initfn() | |
635 |
|
637 | |||
636 | if opts['pid_file']: |
|
638 | if opts['pid_file']: | |
637 | mode = appendpid and 'a' or 'w' |
|
639 | mode = appendpid and 'a' or 'w' | |
638 | fp = open(opts['pid_file'], mode) |
|
640 | fp = open(opts['pid_file'], mode) | |
639 | fp.write(str(os.getpid()) + '\n') |
|
641 | fp.write(str(os.getpid()) + '\n') | |
640 | fp.close() |
|
642 | fp.close() | |
641 |
|
643 | |||
642 | if opts['daemon_pipefds']: |
|
644 | if opts['daemon_pipefds']: | |
643 | lockpath = opts['daemon_pipefds'] |
|
645 | lockpath = opts['daemon_pipefds'] | |
644 | try: |
|
646 | try: | |
645 | os.setsid() |
|
647 | os.setsid() | |
646 | except AttributeError: |
|
648 | except AttributeError: | |
647 | pass |
|
649 | pass | |
648 | os.unlink(lockpath) |
|
650 | os.unlink(lockpath) | |
649 | util.hidewindow() |
|
651 | util.hidewindow() | |
650 | sys.stdout.flush() |
|
652 | sys.stdout.flush() | |
651 | sys.stderr.flush() |
|
653 | sys.stderr.flush() | |
652 |
|
654 | |||
653 | nullfd = os.open(util.nulldev, os.O_RDWR) |
|
655 | nullfd = os.open(util.nulldev, os.O_RDWR) | |
654 | logfilefd = nullfd |
|
656 | logfilefd = nullfd | |
655 | if logfile: |
|
657 | if logfile: | |
656 | logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND) |
|
658 | logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND) | |
657 | os.dup2(nullfd, 0) |
|
659 | os.dup2(nullfd, 0) | |
658 | os.dup2(logfilefd, 1) |
|
660 | os.dup2(logfilefd, 1) | |
659 | os.dup2(logfilefd, 2) |
|
661 | os.dup2(logfilefd, 2) | |
660 | if nullfd not in (0, 1, 2): |
|
662 | if nullfd not in (0, 1, 2): | |
661 | os.close(nullfd) |
|
663 | os.close(nullfd) | |
662 | if logfile and logfilefd not in (0, 1, 2): |
|
664 | if logfile and logfilefd not in (0, 1, 2): | |
663 | os.close(logfilefd) |
|
665 | os.close(logfilefd) | |
664 |
|
666 | |||
665 | if runfn: |
|
667 | if runfn: | |
666 | return runfn() |
|
668 | return runfn() | |
667 |
|
669 | |||
668 | def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, |
|
670 | def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, | |
669 | opts=None): |
|
671 | opts=None): | |
670 | '''export changesets as hg patches.''' |
|
672 | '''export changesets as hg patches.''' | |
671 |
|
673 | |||
672 | total = len(revs) |
|
674 | total = len(revs) | |
673 | revwidth = max([len(str(rev)) for rev in revs]) |
|
675 | revwidth = max([len(str(rev)) for rev in revs]) | |
674 |
|
676 | |||
675 | def single(rev, seqno, fp): |
|
677 | def single(rev, seqno, fp): | |
676 | ctx = repo[rev] |
|
678 | ctx = repo[rev] | |
677 | node = ctx.node() |
|
679 | node = ctx.node() | |
678 | parents = [p.node() for p in ctx.parents() if p] |
|
680 | parents = [p.node() for p in ctx.parents() if p] | |
679 | branch = ctx.branch() |
|
681 | branch = ctx.branch() | |
680 | if switch_parent: |
|
682 | if switch_parent: | |
681 | parents.reverse() |
|
683 | parents.reverse() | |
682 | prev = (parents and parents[0]) or nullid |
|
684 | prev = (parents and parents[0]) or nullid | |
683 |
|
685 | |||
684 | shouldclose = False |
|
686 | shouldclose = False | |
685 | if not fp: |
|
687 | if not fp: | |
686 | fp = make_file(repo, template, node, total=total, seqno=seqno, |
|
688 | fp = make_file(repo, template, node, total=total, seqno=seqno, | |
687 | revwidth=revwidth, mode='ab') |
|
689 | revwidth=revwidth, mode='ab') | |
688 | if fp != template: |
|
690 | if fp != template: | |
689 | shouldclose = True |
|
691 | shouldclose = True | |
690 | if fp != sys.stdout and hasattr(fp, 'name'): |
|
692 | if fp != sys.stdout and hasattr(fp, 'name'): | |
691 | repo.ui.note("%s\n" % fp.name) |
|
693 | repo.ui.note("%s\n" % fp.name) | |
692 |
|
694 | |||
693 | fp.write("# HG changeset patch\n") |
|
695 | fp.write("# HG changeset patch\n") | |
694 | fp.write("# User %s\n" % ctx.user()) |
|
696 | fp.write("# User %s\n" % ctx.user()) | |
695 | fp.write("# Date %d %d\n" % ctx.date()) |
|
697 | fp.write("# Date %d %d\n" % ctx.date()) | |
696 | if branch and branch != 'default': |
|
698 | if branch and branch != 'default': | |
697 | fp.write("# Branch %s\n" % branch) |
|
699 | fp.write("# Branch %s\n" % branch) | |
698 | fp.write("# Node ID %s\n" % hex(node)) |
|
700 | fp.write("# Node ID %s\n" % hex(node)) | |
699 | fp.write("# Parent %s\n" % hex(prev)) |
|
701 | fp.write("# Parent %s\n" % hex(prev)) | |
700 | if len(parents) > 1: |
|
702 | if len(parents) > 1: | |
701 | fp.write("# Parent %s\n" % hex(parents[1])) |
|
703 | fp.write("# Parent %s\n" % hex(parents[1])) | |
702 | fp.write(ctx.description().rstrip()) |
|
704 | fp.write(ctx.description().rstrip()) | |
703 | fp.write("\n\n") |
|
705 | fp.write("\n\n") | |
704 |
|
706 | |||
705 | for chunk in patch.diff(repo, prev, node, opts=opts): |
|
707 | for chunk in patch.diff(repo, prev, node, opts=opts): | |
706 | fp.write(chunk) |
|
708 | fp.write(chunk) | |
707 |
|
709 | |||
708 | if shouldclose: |
|
710 | if shouldclose: | |
709 | fp.close() |
|
711 | fp.close() | |
710 |
|
712 | |||
711 | for seqno, rev in enumerate(revs): |
|
713 | for seqno, rev in enumerate(revs): | |
712 | single(rev, seqno + 1, fp) |
|
714 | single(rev, seqno + 1, fp) | |
713 |
|
715 | |||
714 | def diffordiffstat(ui, repo, diffopts, node1, node2, match, |
|
716 | def diffordiffstat(ui, repo, diffopts, node1, node2, match, | |
715 | changes=None, stat=False, fp=None, prefix='', |
|
717 | changes=None, stat=False, fp=None, prefix='', | |
716 | listsubrepos=False): |
|
718 | listsubrepos=False): | |
717 | '''show diff or diffstat.''' |
|
719 | '''show diff or diffstat.''' | |
718 | if fp is None: |
|
720 | if fp is None: | |
719 | write = ui.write |
|
721 | write = ui.write | |
720 | else: |
|
722 | else: | |
721 | def write(s, **kw): |
|
723 | def write(s, **kw): | |
722 | fp.write(s) |
|
724 | fp.write(s) | |
723 |
|
725 | |||
724 | if stat: |
|
726 | if stat: | |
725 | diffopts = diffopts.copy(context=0) |
|
727 | diffopts = diffopts.copy(context=0) | |
726 | width = 80 |
|
728 | width = 80 | |
727 | if not ui.plain(): |
|
729 | if not ui.plain(): | |
728 | width = ui.termwidth() |
|
730 | width = ui.termwidth() | |
729 | chunks = patch.diff(repo, node1, node2, match, changes, diffopts, |
|
731 | chunks = patch.diff(repo, node1, node2, match, changes, diffopts, | |
730 | prefix=prefix) |
|
732 | prefix=prefix) | |
731 | for chunk, label in patch.diffstatui(util.iterlines(chunks), |
|
733 | for chunk, label in patch.diffstatui(util.iterlines(chunks), | |
732 | width=width, |
|
734 | width=width, | |
733 | git=diffopts.git): |
|
735 | git=diffopts.git): | |
734 | write(chunk, label=label) |
|
736 | write(chunk, label=label) | |
735 | else: |
|
737 | else: | |
736 | for chunk, label in patch.diffui(repo, node1, node2, match, |
|
738 | for chunk, label in patch.diffui(repo, node1, node2, match, | |
737 | changes, diffopts, prefix=prefix): |
|
739 | changes, diffopts, prefix=prefix): | |
738 | write(chunk, label=label) |
|
740 | write(chunk, label=label) | |
739 |
|
741 | |||
740 | if listsubrepos: |
|
742 | if listsubrepos: | |
741 | ctx1 = repo[node1] |
|
743 | ctx1 = repo[node1] | |
742 | ctx2 = repo[node2] |
|
744 | ctx2 = repo[node2] | |
743 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): |
|
745 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): | |
744 | if node2 is not None: |
|
746 | if node2 is not None: | |
745 | node2 = ctx2.substate[subpath][1] |
|
747 | node2 = ctx2.substate[subpath][1] | |
746 | submatch = matchmod.narrowmatcher(subpath, match) |
|
748 | submatch = matchmod.narrowmatcher(subpath, match) | |
747 | sub.diff(diffopts, node2, submatch, changes=changes, |
|
749 | sub.diff(diffopts, node2, submatch, changes=changes, | |
748 | stat=stat, fp=fp, prefix=prefix) |
|
750 | stat=stat, fp=fp, prefix=prefix) | |
749 |
|
751 | |||
750 | class changeset_printer(object): |
|
752 | class changeset_printer(object): | |
751 | '''show changeset information when templating not requested.''' |
|
753 | '''show changeset information when templating not requested.''' | |
752 |
|
754 | |||
753 | def __init__(self, ui, repo, patch, diffopts, buffered): |
|
755 | def __init__(self, ui, repo, patch, diffopts, buffered): | |
754 | self.ui = ui |
|
756 | self.ui = ui | |
755 | self.repo = repo |
|
757 | self.repo = repo | |
756 | self.buffered = buffered |
|
758 | self.buffered = buffered | |
757 | self.patch = patch |
|
759 | self.patch = patch | |
758 | self.diffopts = diffopts |
|
760 | self.diffopts = diffopts | |
759 | self.header = {} |
|
761 | self.header = {} | |
760 | self.hunk = {} |
|
762 | self.hunk = {} | |
761 | self.lastheader = None |
|
763 | self.lastheader = None | |
762 | self.footer = None |
|
764 | self.footer = None | |
763 |
|
765 | |||
764 | def flush(self, rev): |
|
766 | def flush(self, rev): | |
765 | if rev in self.header: |
|
767 | if rev in self.header: | |
766 | h = self.header[rev] |
|
768 | h = self.header[rev] | |
767 | if h != self.lastheader: |
|
769 | if h != self.lastheader: | |
768 | self.lastheader = h |
|
770 | self.lastheader = h | |
769 | self.ui.write(h) |
|
771 | self.ui.write(h) | |
770 | del self.header[rev] |
|
772 | del self.header[rev] | |
771 | if rev in self.hunk: |
|
773 | if rev in self.hunk: | |
772 | self.ui.write(self.hunk[rev]) |
|
774 | self.ui.write(self.hunk[rev]) | |
773 | del self.hunk[rev] |
|
775 | del self.hunk[rev] | |
774 | return 1 |
|
776 | return 1 | |
775 | return 0 |
|
777 | return 0 | |
776 |
|
778 | |||
777 | def close(self): |
|
779 | def close(self): | |
778 | if self.footer: |
|
780 | if self.footer: | |
779 | self.ui.write(self.footer) |
|
781 | self.ui.write(self.footer) | |
780 |
|
782 | |||
781 | def show(self, ctx, copies=None, matchfn=None, **props): |
|
783 | def show(self, ctx, copies=None, matchfn=None, **props): | |
782 | if self.buffered: |
|
784 | if self.buffered: | |
783 | self.ui.pushbuffer() |
|
785 | self.ui.pushbuffer() | |
784 | self._show(ctx, copies, matchfn, props) |
|
786 | self._show(ctx, copies, matchfn, props) | |
785 | self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True) |
|
787 | self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True) | |
786 | else: |
|
788 | else: | |
787 | self._show(ctx, copies, matchfn, props) |
|
789 | self._show(ctx, copies, matchfn, props) | |
788 |
|
790 | |||
789 | def _show(self, ctx, copies, matchfn, props): |
|
791 | def _show(self, ctx, copies, matchfn, props): | |
790 | '''show a single changeset or file revision''' |
|
792 | '''show a single changeset or file revision''' | |
791 | changenode = ctx.node() |
|
793 | changenode = ctx.node() | |
792 | rev = ctx.rev() |
|
794 | rev = ctx.rev() | |
793 |
|
795 | |||
794 | if self.ui.quiet: |
|
796 | if self.ui.quiet: | |
795 | self.ui.write("%d:%s\n" % (rev, short(changenode)), |
|
797 | self.ui.write("%d:%s\n" % (rev, short(changenode)), | |
796 | label='log.node') |
|
798 | label='log.node') | |
797 | return |
|
799 | return | |
798 |
|
800 | |||
799 | log = self.repo.changelog |
|
801 | log = self.repo.changelog | |
800 | date = util.datestr(ctx.date()) |
|
802 | date = util.datestr(ctx.date()) | |
801 |
|
803 | |||
802 | hexfunc = self.ui.debugflag and hex or short |
|
804 | hexfunc = self.ui.debugflag and hex or short | |
803 |
|
805 | |||
804 | parents = [(p, hexfunc(log.node(p))) |
|
806 | parents = [(p, hexfunc(log.node(p))) | |
805 | for p in self._meaningful_parentrevs(log, rev)] |
|
807 | for p in self._meaningful_parentrevs(log, rev)] | |
806 |
|
808 | |||
807 | self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), |
|
809 | self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), | |
808 | label='log.changeset') |
|
810 | label='log.changeset') | |
809 |
|
811 | |||
810 | branch = ctx.branch() |
|
812 | branch = ctx.branch() | |
811 | # don't show the default branch name |
|
813 | # don't show the default branch name | |
812 | if branch != 'default': |
|
814 | if branch != 'default': | |
813 | self.ui.write(_("branch: %s\n") % branch, |
|
815 | self.ui.write(_("branch: %s\n") % branch, | |
814 | label='log.branch') |
|
816 | label='log.branch') | |
815 | for bookmark in self.repo.nodebookmarks(changenode): |
|
817 | for bookmark in self.repo.nodebookmarks(changenode): | |
816 | self.ui.write(_("bookmark: %s\n") % bookmark, |
|
818 | self.ui.write(_("bookmark: %s\n") % bookmark, | |
817 | label='log.bookmark') |
|
819 | label='log.bookmark') | |
818 | for tag in self.repo.nodetags(changenode): |
|
820 | for tag in self.repo.nodetags(changenode): | |
819 | self.ui.write(_("tag: %s\n") % tag, |
|
821 | self.ui.write(_("tag: %s\n") % tag, | |
820 | label='log.tag') |
|
822 | label='log.tag') | |
821 | for parent in parents: |
|
823 | for parent in parents: | |
822 | self.ui.write(_("parent: %d:%s\n") % parent, |
|
824 | self.ui.write(_("parent: %d:%s\n") % parent, | |
823 | label='log.parent') |
|
825 | label='log.parent') | |
824 |
|
826 | |||
825 | if self.ui.debugflag: |
|
827 | if self.ui.debugflag: | |
826 | mnode = ctx.manifestnode() |
|
828 | mnode = ctx.manifestnode() | |
827 | self.ui.write(_("manifest: %d:%s\n") % |
|
829 | self.ui.write(_("manifest: %d:%s\n") % | |
828 | (self.repo.manifest.rev(mnode), hex(mnode)), |
|
830 | (self.repo.manifest.rev(mnode), hex(mnode)), | |
829 | label='ui.debug log.manifest') |
|
831 | label='ui.debug log.manifest') | |
830 | self.ui.write(_("user: %s\n") % ctx.user(), |
|
832 | self.ui.write(_("user: %s\n") % ctx.user(), | |
831 | label='log.user') |
|
833 | label='log.user') | |
832 | self.ui.write(_("date: %s\n") % date, |
|
834 | self.ui.write(_("date: %s\n") % date, | |
833 | label='log.date') |
|
835 | label='log.date') | |
834 |
|
836 | |||
835 | if self.ui.debugflag: |
|
837 | if self.ui.debugflag: | |
836 | files = self.repo.status(log.parents(changenode)[0], changenode)[:3] |
|
838 | files = self.repo.status(log.parents(changenode)[0], changenode)[:3] | |
837 | for key, value in zip([_("files:"), _("files+:"), _("files-:")], |
|
839 | for key, value in zip([_("files:"), _("files+:"), _("files-:")], | |
838 | files): |
|
840 | files): | |
839 | if value: |
|
841 | if value: | |
840 | self.ui.write("%-12s %s\n" % (key, " ".join(value)), |
|
842 | self.ui.write("%-12s %s\n" % (key, " ".join(value)), | |
841 | label='ui.debug log.files') |
|
843 | label='ui.debug log.files') | |
842 | elif ctx.files() and self.ui.verbose: |
|
844 | elif ctx.files() and self.ui.verbose: | |
843 | self.ui.write(_("files: %s\n") % " ".join(ctx.files()), |
|
845 | self.ui.write(_("files: %s\n") % " ".join(ctx.files()), | |
844 | label='ui.note log.files') |
|
846 | label='ui.note log.files') | |
845 | if copies and self.ui.verbose: |
|
847 | if copies and self.ui.verbose: | |
846 | copies = ['%s (%s)' % c for c in copies] |
|
848 | copies = ['%s (%s)' % c for c in copies] | |
847 | self.ui.write(_("copies: %s\n") % ' '.join(copies), |
|
849 | self.ui.write(_("copies: %s\n") % ' '.join(copies), | |
848 | label='ui.note log.copies') |
|
850 | label='ui.note log.copies') | |
849 |
|
851 | |||
850 | extra = ctx.extra() |
|
852 | extra = ctx.extra() | |
851 | if extra and self.ui.debugflag: |
|
853 | if extra and self.ui.debugflag: | |
852 | for key, value in sorted(extra.items()): |
|
854 | for key, value in sorted(extra.items()): | |
853 | self.ui.write(_("extra: %s=%s\n") |
|
855 | self.ui.write(_("extra: %s=%s\n") | |
854 | % (key, value.encode('string_escape')), |
|
856 | % (key, value.encode('string_escape')), | |
855 | label='ui.debug log.extra') |
|
857 | label='ui.debug log.extra') | |
856 |
|
858 | |||
857 | description = ctx.description().strip() |
|
859 | description = ctx.description().strip() | |
858 | if description: |
|
860 | if description: | |
859 | if self.ui.verbose: |
|
861 | if self.ui.verbose: | |
860 | self.ui.write(_("description:\n"), |
|
862 | self.ui.write(_("description:\n"), | |
861 | label='ui.note log.description') |
|
863 | label='ui.note log.description') | |
862 | self.ui.write(description, |
|
864 | self.ui.write(description, | |
863 | label='ui.note log.description') |
|
865 | label='ui.note log.description') | |
864 | self.ui.write("\n\n") |
|
866 | self.ui.write("\n\n") | |
865 | else: |
|
867 | else: | |
866 | self.ui.write(_("summary: %s\n") % |
|
868 | self.ui.write(_("summary: %s\n") % | |
867 | description.splitlines()[0], |
|
869 | description.splitlines()[0], | |
868 | label='log.summary') |
|
870 | label='log.summary') | |
869 | self.ui.write("\n") |
|
871 | self.ui.write("\n") | |
870 |
|
872 | |||
871 | self.showpatch(changenode, matchfn) |
|
873 | self.showpatch(changenode, matchfn) | |
872 |
|
874 | |||
873 | def showpatch(self, node, matchfn): |
|
875 | def showpatch(self, node, matchfn): | |
874 | if not matchfn: |
|
876 | if not matchfn: | |
875 | matchfn = self.patch |
|
877 | matchfn = self.patch | |
876 | if matchfn: |
|
878 | if matchfn: | |
877 | stat = self.diffopts.get('stat') |
|
879 | stat = self.diffopts.get('stat') | |
878 | diff = self.diffopts.get('patch') |
|
880 | diff = self.diffopts.get('patch') | |
879 | diffopts = patch.diffopts(self.ui, self.diffopts) |
|
881 | diffopts = patch.diffopts(self.ui, self.diffopts) | |
880 | prev = self.repo.changelog.parents(node)[0] |
|
882 | prev = self.repo.changelog.parents(node)[0] | |
881 | if stat: |
|
883 | if stat: | |
882 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
|
884 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, | |
883 | match=matchfn, stat=True) |
|
885 | match=matchfn, stat=True) | |
884 | if diff: |
|
886 | if diff: | |
885 | if stat: |
|
887 | if stat: | |
886 | self.ui.write("\n") |
|
888 | self.ui.write("\n") | |
887 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
|
889 | diffordiffstat(self.ui, self.repo, diffopts, prev, node, | |
888 | match=matchfn, stat=False) |
|
890 | match=matchfn, stat=False) | |
889 | self.ui.write("\n") |
|
891 | self.ui.write("\n") | |
890 |
|
892 | |||
891 | def _meaningful_parentrevs(self, log, rev): |
|
893 | def _meaningful_parentrevs(self, log, rev): | |
892 | """Return list of meaningful (or all if debug) parentrevs for rev. |
|
894 | """Return list of meaningful (or all if debug) parentrevs for rev. | |
893 |
|
895 | |||
894 | For merges (two non-nullrev revisions) both parents are meaningful. |
|
896 | For merges (two non-nullrev revisions) both parents are meaningful. | |
895 | Otherwise the first parent revision is considered meaningful if it |
|
897 | Otherwise the first parent revision is considered meaningful if it | |
896 | is not the preceding revision. |
|
898 | is not the preceding revision. | |
897 | """ |
|
899 | """ | |
898 | parents = log.parentrevs(rev) |
|
900 | parents = log.parentrevs(rev) | |
899 | if not self.ui.debugflag and parents[1] == nullrev: |
|
901 | if not self.ui.debugflag and parents[1] == nullrev: | |
900 | if parents[0] >= rev - 1: |
|
902 | if parents[0] >= rev - 1: | |
901 | parents = [] |
|
903 | parents = [] | |
902 | else: |
|
904 | else: | |
903 | parents = [parents[0]] |
|
905 | parents = [parents[0]] | |
904 | return parents |
|
906 | return parents | |
905 |
|
907 | |||
906 |
|
908 | |||
907 | class changeset_templater(changeset_printer): |
|
909 | class changeset_templater(changeset_printer): | |
908 | '''format changeset information.''' |
|
910 | '''format changeset information.''' | |
909 |
|
911 | |||
910 | def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): |
|
912 | def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): | |
911 | changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) |
|
913 | changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) | |
912 | formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) |
|
914 | formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) | |
913 | defaulttempl = { |
|
915 | defaulttempl = { | |
914 | 'parent': '{rev}:{node|formatnode} ', |
|
916 | 'parent': '{rev}:{node|formatnode} ', | |
915 | 'manifest': '{rev}:{node|formatnode}', |
|
917 | 'manifest': '{rev}:{node|formatnode}', | |
916 | 'file_copy': '{name} ({source})', |
|
918 | 'file_copy': '{name} ({source})', | |
917 | 'extra': '{key}={value|stringescape}' |
|
919 | 'extra': '{key}={value|stringescape}' | |
918 | } |
|
920 | } | |
919 | # filecopy is preserved for compatibility reasons |
|
921 | # filecopy is preserved for compatibility reasons | |
920 | defaulttempl['filecopy'] = defaulttempl['file_copy'] |
|
922 | defaulttempl['filecopy'] = defaulttempl['file_copy'] | |
921 | self.t = templater.templater(mapfile, {'formatnode': formatnode}, |
|
923 | self.t = templater.templater(mapfile, {'formatnode': formatnode}, | |
922 | cache=defaulttempl) |
|
924 | cache=defaulttempl) | |
923 | self.cache = {} |
|
925 | self.cache = {} | |
924 |
|
926 | |||
925 | def use_template(self, t): |
|
927 | def use_template(self, t): | |
926 | '''set template string to use''' |
|
928 | '''set template string to use''' | |
927 | self.t.cache['changeset'] = t |
|
929 | self.t.cache['changeset'] = t | |
928 |
|
930 | |||
929 | def _meaningful_parentrevs(self, ctx): |
|
931 | def _meaningful_parentrevs(self, ctx): | |
930 | """Return list of meaningful (or all if debug) parentrevs for rev. |
|
932 | """Return list of meaningful (or all if debug) parentrevs for rev. | |
931 | """ |
|
933 | """ | |
932 | parents = ctx.parents() |
|
934 | parents = ctx.parents() | |
933 | if len(parents) > 1: |
|
935 | if len(parents) > 1: | |
934 | return parents |
|
936 | return parents | |
935 | if self.ui.debugflag: |
|
937 | if self.ui.debugflag: | |
936 | return [parents[0], self.repo['null']] |
|
938 | return [parents[0], self.repo['null']] | |
937 | if parents[0].rev() >= ctx.rev() - 1: |
|
939 | if parents[0].rev() >= ctx.rev() - 1: | |
938 | return [] |
|
940 | return [] | |
939 | return parents |
|
941 | return parents | |
940 |
|
942 | |||
941 | def _show(self, ctx, copies, matchfn, props): |
|
943 | def _show(self, ctx, copies, matchfn, props): | |
942 | '''show a single changeset or file revision''' |
|
944 | '''show a single changeset or file revision''' | |
943 |
|
945 | |||
944 | showlist = templatekw.showlist |
|
946 | showlist = templatekw.showlist | |
945 |
|
947 | |||
946 | # showparents() behaviour depends on ui trace level which |
|
948 | # showparents() behaviour depends on ui trace level which | |
947 | # causes unexpected behaviours at templating level and makes |
|
949 | # causes unexpected behaviours at templating level and makes | |
948 | # it harder to extract it in a standalone function. Its |
|
950 | # it harder to extract it in a standalone function. Its | |
949 | # behaviour cannot be changed so leave it here for now. |
|
951 | # behaviour cannot be changed so leave it here for now. | |
950 | def showparents(**args): |
|
952 | def showparents(**args): | |
951 | ctx = args['ctx'] |
|
953 | ctx = args['ctx'] | |
952 | parents = [[('rev', p.rev()), ('node', p.hex())] |
|
954 | parents = [[('rev', p.rev()), ('node', p.hex())] | |
953 | for p in self._meaningful_parentrevs(ctx)] |
|
955 | for p in self._meaningful_parentrevs(ctx)] | |
954 | return showlist('parent', parents, **args) |
|
956 | return showlist('parent', parents, **args) | |
955 |
|
957 | |||
956 | props = props.copy() |
|
958 | props = props.copy() | |
957 | props.update(templatekw.keywords) |
|
959 | props.update(templatekw.keywords) | |
958 | props['parents'] = showparents |
|
960 | props['parents'] = showparents | |
959 | props['templ'] = self.t |
|
961 | props['templ'] = self.t | |
960 | props['ctx'] = ctx |
|
962 | props['ctx'] = ctx | |
961 | props['repo'] = self.repo |
|
963 | props['repo'] = self.repo | |
962 | props['revcache'] = {'copies': copies} |
|
964 | props['revcache'] = {'copies': copies} | |
963 | props['cache'] = self.cache |
|
965 | props['cache'] = self.cache | |
964 |
|
966 | |||
965 | # find correct templates for current mode |
|
967 | # find correct templates for current mode | |
966 |
|
968 | |||
967 | tmplmodes = [ |
|
969 | tmplmodes = [ | |
968 | (True, None), |
|
970 | (True, None), | |
969 | (self.ui.verbose, 'verbose'), |
|
971 | (self.ui.verbose, 'verbose'), | |
970 | (self.ui.quiet, 'quiet'), |
|
972 | (self.ui.quiet, 'quiet'), | |
971 | (self.ui.debugflag, 'debug'), |
|
973 | (self.ui.debugflag, 'debug'), | |
972 | ] |
|
974 | ] | |
973 |
|
975 | |||
974 | types = {'header': '', 'footer':'', 'changeset': 'changeset'} |
|
976 | types = {'header': '', 'footer':'', 'changeset': 'changeset'} | |
975 | for mode, postfix in tmplmodes: |
|
977 | for mode, postfix in tmplmodes: | |
976 | for type in types: |
|
978 | for type in types: | |
977 | cur = postfix and ('%s_%s' % (type, postfix)) or type |
|
979 | cur = postfix and ('%s_%s' % (type, postfix)) or type | |
978 | if mode and cur in self.t: |
|
980 | if mode and cur in self.t: | |
979 | types[type] = cur |
|
981 | types[type] = cur | |
980 |
|
982 | |||
981 | try: |
|
983 | try: | |
982 |
|
984 | |||
983 | # write header |
|
985 | # write header | |
984 | if types['header']: |
|
986 | if types['header']: | |
985 | h = templater.stringify(self.t(types['header'], **props)) |
|
987 | h = templater.stringify(self.t(types['header'], **props)) | |
986 | if self.buffered: |
|
988 | if self.buffered: | |
987 | self.header[ctx.rev()] = h |
|
989 | self.header[ctx.rev()] = h | |
988 | else: |
|
990 | else: | |
989 | if self.lastheader != h: |
|
991 | if self.lastheader != h: | |
990 | self.lastheader = h |
|
992 | self.lastheader = h | |
991 | self.ui.write(h) |
|
993 | self.ui.write(h) | |
992 |
|
994 | |||
993 | # write changeset metadata, then patch if requested |
|
995 | # write changeset metadata, then patch if requested | |
994 | key = types['changeset'] |
|
996 | key = types['changeset'] | |
995 | self.ui.write(templater.stringify(self.t(key, **props))) |
|
997 | self.ui.write(templater.stringify(self.t(key, **props))) | |
996 | self.showpatch(ctx.node(), matchfn) |
|
998 | self.showpatch(ctx.node(), matchfn) | |
997 |
|
999 | |||
998 | if types['footer']: |
|
1000 | if types['footer']: | |
999 | if not self.footer: |
|
1001 | if not self.footer: | |
1000 | self.footer = templater.stringify(self.t(types['footer'], |
|
1002 | self.footer = templater.stringify(self.t(types['footer'], | |
1001 | **props)) |
|
1003 | **props)) | |
1002 |
|
1004 | |||
1003 | except KeyError, inst: |
|
1005 | except KeyError, inst: | |
1004 | msg = _("%s: no key named '%s'") |
|
1006 | msg = _("%s: no key named '%s'") | |
1005 | raise util.Abort(msg % (self.t.mapfile, inst.args[0])) |
|
1007 | raise util.Abort(msg % (self.t.mapfile, inst.args[0])) | |
1006 | except SyntaxError, inst: |
|
1008 | except SyntaxError, inst: | |
1007 | raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) |
|
1009 | raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0])) | |
1008 |
|
1010 | |||
1009 | def show_changeset(ui, repo, opts, buffered=False): |
|
1011 | def show_changeset(ui, repo, opts, buffered=False): | |
1010 | """show one changeset using template or regular display. |
|
1012 | """show one changeset using template or regular display. | |
1011 |
|
1013 | |||
1012 | Display format will be the first non-empty hit of: |
|
1014 | Display format will be the first non-empty hit of: | |
1013 | 1. option 'template' |
|
1015 | 1. option 'template' | |
1014 | 2. option 'style' |
|
1016 | 2. option 'style' | |
1015 | 3. [ui] setting 'logtemplate' |
|
1017 | 3. [ui] setting 'logtemplate' | |
1016 | 4. [ui] setting 'style' |
|
1018 | 4. [ui] setting 'style' | |
1017 | If all of these values are either the unset or the empty string, |
|
1019 | If all of these values are either the unset or the empty string, | |
1018 | regular display via changeset_printer() is done. |
|
1020 | regular display via changeset_printer() is done. | |
1019 | """ |
|
1021 | """ | |
1020 | # options |
|
1022 | # options | |
1021 | patch = False |
|
1023 | patch = False | |
1022 | if opts.get('patch') or opts.get('stat'): |
|
1024 | if opts.get('patch') or opts.get('stat'): | |
1023 | patch = matchall(repo) |
|
1025 | patch = matchall(repo) | |
1024 |
|
1026 | |||
1025 | tmpl = opts.get('template') |
|
1027 | tmpl = opts.get('template') | |
1026 | style = None |
|
1028 | style = None | |
1027 | if tmpl: |
|
1029 | if tmpl: | |
1028 | tmpl = templater.parsestring(tmpl, quoted=False) |
|
1030 | tmpl = templater.parsestring(tmpl, quoted=False) | |
1029 | else: |
|
1031 | else: | |
1030 | style = opts.get('style') |
|
1032 | style = opts.get('style') | |
1031 |
|
1033 | |||
1032 | # ui settings |
|
1034 | # ui settings | |
1033 | if not (tmpl or style): |
|
1035 | if not (tmpl or style): | |
1034 | tmpl = ui.config('ui', 'logtemplate') |
|
1036 | tmpl = ui.config('ui', 'logtemplate') | |
1035 | if tmpl: |
|
1037 | if tmpl: | |
1036 | tmpl = templater.parsestring(tmpl) |
|
1038 | tmpl = templater.parsestring(tmpl) | |
1037 | else: |
|
1039 | else: | |
1038 | style = util.expandpath(ui.config('ui', 'style', '')) |
|
1040 | style = util.expandpath(ui.config('ui', 'style', '')) | |
1039 |
|
1041 | |||
1040 | if not (tmpl or style): |
|
1042 | if not (tmpl or style): | |
1041 | return changeset_printer(ui, repo, patch, opts, buffered) |
|
1043 | return changeset_printer(ui, repo, patch, opts, buffered) | |
1042 |
|
1044 | |||
1043 | mapfile = None |
|
1045 | mapfile = None | |
1044 | if style and not tmpl: |
|
1046 | if style and not tmpl: | |
1045 | mapfile = style |
|
1047 | mapfile = style | |
1046 | if not os.path.split(mapfile)[0]: |
|
1048 | if not os.path.split(mapfile)[0]: | |
1047 | mapname = (templater.templatepath('map-cmdline.' + mapfile) |
|
1049 | mapname = (templater.templatepath('map-cmdline.' + mapfile) | |
1048 | or templater.templatepath(mapfile)) |
|
1050 | or templater.templatepath(mapfile)) | |
1049 | if mapname: |
|
1051 | if mapname: | |
1050 | mapfile = mapname |
|
1052 | mapfile = mapname | |
1051 |
|
1053 | |||
1052 | try: |
|
1054 | try: | |
1053 | t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) |
|
1055 | t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) | |
1054 | except SyntaxError, inst: |
|
1056 | except SyntaxError, inst: | |
1055 | raise util.Abort(inst.args[0]) |
|
1057 | raise util.Abort(inst.args[0]) | |
1056 | if tmpl: |
|
1058 | if tmpl: | |
1057 | t.use_template(tmpl) |
|
1059 | t.use_template(tmpl) | |
1058 | return t |
|
1060 | return t | |
1059 |
|
1061 | |||
1060 | def finddate(ui, repo, date): |
|
1062 | def finddate(ui, repo, date): | |
1061 | """Find the tipmost changeset that matches the given date spec""" |
|
1063 | """Find the tipmost changeset that matches the given date spec""" | |
1062 |
|
1064 | |||
1063 | df = util.matchdate(date) |
|
1065 | df = util.matchdate(date) | |
1064 | m = matchall(repo) |
|
1066 | m = matchall(repo) | |
1065 | results = {} |
|
1067 | results = {} | |
1066 |
|
1068 | |||
1067 | def prep(ctx, fns): |
|
1069 | def prep(ctx, fns): | |
1068 | d = ctx.date() |
|
1070 | d = ctx.date() | |
1069 | if df(d[0]): |
|
1071 | if df(d[0]): | |
1070 | results[ctx.rev()] = d |
|
1072 | results[ctx.rev()] = d | |
1071 |
|
1073 | |||
1072 | for ctx in walkchangerevs(repo, m, {'rev': None}, prep): |
|
1074 | for ctx in walkchangerevs(repo, m, {'rev': None}, prep): | |
1073 | rev = ctx.rev() |
|
1075 | rev = ctx.rev() | |
1074 | if rev in results: |
|
1076 | if rev in results: | |
1075 | ui.status(_("Found revision %s from %s\n") % |
|
1077 | ui.status(_("Found revision %s from %s\n") % | |
1076 | (rev, util.datestr(results[rev]))) |
|
1078 | (rev, util.datestr(results[rev]))) | |
1077 | return str(rev) |
|
1079 | return str(rev) | |
1078 |
|
1080 | |||
1079 | raise util.Abort(_("revision matching date not found")) |
|
1081 | raise util.Abort(_("revision matching date not found")) | |
1080 |
|
1082 | |||
1081 | def walkchangerevs(repo, match, opts, prepare): |
|
1083 | def walkchangerevs(repo, match, opts, prepare): | |
1082 | '''Iterate over files and the revs in which they changed. |
|
1084 | '''Iterate over files and the revs in which they changed. | |
1083 |
|
1085 | |||
1084 | Callers most commonly need to iterate backwards over the history |
|
1086 | Callers most commonly need to iterate backwards over the history | |
1085 | in which they are interested. Doing so has awful (quadratic-looking) |
|
1087 | in which they are interested. Doing so has awful (quadratic-looking) | |
1086 | performance, so we use iterators in a "windowed" way. |
|
1088 | performance, so we use iterators in a "windowed" way. | |
1087 |
|
1089 | |||
1088 | We walk a window of revisions in the desired order. Within the |
|
1090 | We walk a window of revisions in the desired order. Within the | |
1089 | window, we first walk forwards to gather data, then in the desired |
|
1091 | window, we first walk forwards to gather data, then in the desired | |
1090 | order (usually backwards) to display it. |
|
1092 | order (usually backwards) to display it. | |
1091 |
|
1093 | |||
1092 | This function returns an iterator yielding contexts. Before |
|
1094 | This function returns an iterator yielding contexts. Before | |
1093 | yielding each context, the iterator will first call the prepare |
|
1095 | yielding each context, the iterator will first call the prepare | |
1094 | function on each context in the window in forward order.''' |
|
1096 | function on each context in the window in forward order.''' | |
1095 |
|
1097 | |||
1096 | def increasing_windows(start, end, windowsize=8, sizelimit=512): |
|
1098 | def increasing_windows(start, end, windowsize=8, sizelimit=512): | |
1097 | if start < end: |
|
1099 | if start < end: | |
1098 | while start < end: |
|
1100 | while start < end: | |
1099 | yield start, min(windowsize, end - start) |
|
1101 | yield start, min(windowsize, end - start) | |
1100 | start += windowsize |
|
1102 | start += windowsize | |
1101 | if windowsize < sizelimit: |
|
1103 | if windowsize < sizelimit: | |
1102 | windowsize *= 2 |
|
1104 | windowsize *= 2 | |
1103 | else: |
|
1105 | else: | |
1104 | while start > end: |
|
1106 | while start > end: | |
1105 | yield start, min(windowsize, start - end - 1) |
|
1107 | yield start, min(windowsize, start - end - 1) | |
1106 | start -= windowsize |
|
1108 | start -= windowsize | |
1107 | if windowsize < sizelimit: |
|
1109 | if windowsize < sizelimit: | |
1108 | windowsize *= 2 |
|
1110 | windowsize *= 2 | |
1109 |
|
1111 | |||
1110 | follow = opts.get('follow') or opts.get('follow_first') |
|
1112 | follow = opts.get('follow') or opts.get('follow_first') | |
1111 |
|
1113 | |||
1112 | if not len(repo): |
|
1114 | if not len(repo): | |
1113 | return [] |
|
1115 | return [] | |
1114 |
|
1116 | |||
1115 | if follow: |
|
1117 | if follow: | |
1116 | defrange = '%s:0' % repo['.'].rev() |
|
1118 | defrange = '%s:0' % repo['.'].rev() | |
1117 | else: |
|
1119 | else: | |
1118 | defrange = '-1:0' |
|
1120 | defrange = '-1:0' | |
1119 | revs = revrange(repo, opts['rev'] or [defrange]) |
|
1121 | revs = revrange(repo, opts['rev'] or [defrange]) | |
1120 | if not revs: |
|
1122 | if not revs: | |
1121 | return [] |
|
1123 | return [] | |
1122 | wanted = set() |
|
1124 | wanted = set() | |
1123 | slowpath = match.anypats() or (match.files() and opts.get('removed')) |
|
1125 | slowpath = match.anypats() or (match.files() and opts.get('removed')) | |
1124 | fncache = {} |
|
1126 | fncache = {} | |
1125 | change = util.cachefunc(repo.changectx) |
|
1127 | change = util.cachefunc(repo.changectx) | |
1126 |
|
1128 | |||
1127 | # First step is to fill wanted, the set of revisions that we want to yield. |
|
1129 | # First step is to fill wanted, the set of revisions that we want to yield. | |
1128 | # When it does not induce extra cost, we also fill fncache for revisions in |
|
1130 | # When it does not induce extra cost, we also fill fncache for revisions in | |
1129 | # wanted: a cache of filenames that were changed (ctx.files()) and that |
|
1131 | # wanted: a cache of filenames that were changed (ctx.files()) and that | |
1130 | # match the file filtering conditions. |
|
1132 | # match the file filtering conditions. | |
1131 |
|
1133 | |||
1132 | if not slowpath and not match.files(): |
|
1134 | if not slowpath and not match.files(): | |
1133 | # No files, no patterns. Display all revs. |
|
1135 | # No files, no patterns. Display all revs. | |
1134 | wanted = set(revs) |
|
1136 | wanted = set(revs) | |
1135 | copies = [] |
|
1137 | copies = [] | |
1136 |
|
1138 | |||
1137 | if not slowpath: |
|
1139 | if not slowpath: | |
1138 | # We only have to read through the filelog to find wanted revisions |
|
1140 | # We only have to read through the filelog to find wanted revisions | |
1139 |
|
1141 | |||
1140 | minrev, maxrev = min(revs), max(revs) |
|
1142 | minrev, maxrev = min(revs), max(revs) | |
1141 | def filerevgen(filelog, last): |
|
1143 | def filerevgen(filelog, last): | |
1142 | """ |
|
1144 | """ | |
1143 | Only files, no patterns. Check the history of each file. |
|
1145 | Only files, no patterns. Check the history of each file. | |
1144 |
|
1146 | |||
1145 | Examines filelog entries within minrev, maxrev linkrev range |
|
1147 | Examines filelog entries within minrev, maxrev linkrev range | |
1146 | Returns an iterator yielding (linkrev, parentlinkrevs, copied) |
|
1148 | Returns an iterator yielding (linkrev, parentlinkrevs, copied) | |
1147 | tuples in backwards order |
|
1149 | tuples in backwards order | |
1148 | """ |
|
1150 | """ | |
1149 | cl_count = len(repo) |
|
1151 | cl_count = len(repo) | |
1150 | revs = [] |
|
1152 | revs = [] | |
1151 | for j in xrange(0, last + 1): |
|
1153 | for j in xrange(0, last + 1): | |
1152 | linkrev = filelog.linkrev(j) |
|
1154 | linkrev = filelog.linkrev(j) | |
1153 | if linkrev < minrev: |
|
1155 | if linkrev < minrev: | |
1154 | continue |
|
1156 | continue | |
1155 | # only yield rev for which we have the changelog, it can |
|
1157 | # only yield rev for which we have the changelog, it can | |
1156 | # happen while doing "hg log" during a pull or commit |
|
1158 | # happen while doing "hg log" during a pull or commit | |
1157 | if linkrev >= cl_count: |
|
1159 | if linkrev >= cl_count: | |
1158 | break |
|
1160 | break | |
1159 |
|
1161 | |||
1160 | parentlinkrevs = [] |
|
1162 | parentlinkrevs = [] | |
1161 | for p in filelog.parentrevs(j): |
|
1163 | for p in filelog.parentrevs(j): | |
1162 | if p != nullrev: |
|
1164 | if p != nullrev: | |
1163 | parentlinkrevs.append(filelog.linkrev(p)) |
|
1165 | parentlinkrevs.append(filelog.linkrev(p)) | |
1164 | n = filelog.node(j) |
|
1166 | n = filelog.node(j) | |
1165 | revs.append((linkrev, parentlinkrevs, |
|
1167 | revs.append((linkrev, parentlinkrevs, | |
1166 | follow and filelog.renamed(n))) |
|
1168 | follow and filelog.renamed(n))) | |
1167 |
|
1169 | |||
1168 | return reversed(revs) |
|
1170 | return reversed(revs) | |
1169 | def iterfiles(): |
|
1171 | def iterfiles(): | |
1170 | for filename in match.files(): |
|
1172 | for filename in match.files(): | |
1171 | yield filename, None |
|
1173 | yield filename, None | |
1172 | for filename_node in copies: |
|
1174 | for filename_node in copies: | |
1173 | yield filename_node |
|
1175 | yield filename_node | |
1174 | for file_, node in iterfiles(): |
|
1176 | for file_, node in iterfiles(): | |
1175 | filelog = repo.file(file_) |
|
1177 | filelog = repo.file(file_) | |
1176 | if not len(filelog): |
|
1178 | if not len(filelog): | |
1177 | if node is None: |
|
1179 | if node is None: | |
1178 | # A zero count may be a directory or deleted file, so |
|
1180 | # A zero count may be a directory or deleted file, so | |
1179 | # try to find matching entries on the slow path. |
|
1181 | # try to find matching entries on the slow path. | |
1180 | if follow: |
|
1182 | if follow: | |
1181 | raise util.Abort( |
|
1183 | raise util.Abort( | |
1182 | _('cannot follow nonexistent file: "%s"') % file_) |
|
1184 | _('cannot follow nonexistent file: "%s"') % file_) | |
1183 | slowpath = True |
|
1185 | slowpath = True | |
1184 | break |
|
1186 | break | |
1185 | else: |
|
1187 | else: | |
1186 | continue |
|
1188 | continue | |
1187 |
|
1189 | |||
1188 | if node is None: |
|
1190 | if node is None: | |
1189 | last = len(filelog) - 1 |
|
1191 | last = len(filelog) - 1 | |
1190 | else: |
|
1192 | else: | |
1191 | last = filelog.rev(node) |
|
1193 | last = filelog.rev(node) | |
1192 |
|
1194 | |||
1193 |
|
1195 | |||
1194 | # keep track of all ancestors of the file |
|
1196 | # keep track of all ancestors of the file | |
1195 | ancestors = set([filelog.linkrev(last)]) |
|
1197 | ancestors = set([filelog.linkrev(last)]) | |
1196 |
|
1198 | |||
1197 | # iterate from latest to oldest revision |
|
1199 | # iterate from latest to oldest revision | |
1198 | for rev, flparentlinkrevs, copied in filerevgen(filelog, last): |
|
1200 | for rev, flparentlinkrevs, copied in filerevgen(filelog, last): | |
1199 | if not follow: |
|
1201 | if not follow: | |
1200 | if rev > maxrev: |
|
1202 | if rev > maxrev: | |
1201 | continue |
|
1203 | continue | |
1202 | else: |
|
1204 | else: | |
1203 | # Note that last might not be the first interesting |
|
1205 | # Note that last might not be the first interesting | |
1204 | # rev to us: |
|
1206 | # rev to us: | |
1205 | # if the file has been changed after maxrev, we'll |
|
1207 | # if the file has been changed after maxrev, we'll | |
1206 | # have linkrev(last) > maxrev, and we still need |
|
1208 | # have linkrev(last) > maxrev, and we still need | |
1207 | # to explore the file graph |
|
1209 | # to explore the file graph | |
1208 | if rev not in ancestors: |
|
1210 | if rev not in ancestors: | |
1209 | continue |
|
1211 | continue | |
1210 | # XXX insert 1327 fix here |
|
1212 | # XXX insert 1327 fix here | |
1211 | if flparentlinkrevs: |
|
1213 | if flparentlinkrevs: | |
1212 | ancestors.update(flparentlinkrevs) |
|
1214 | ancestors.update(flparentlinkrevs) | |
1213 |
|
1215 | |||
1214 | fncache.setdefault(rev, []).append(file_) |
|
1216 | fncache.setdefault(rev, []).append(file_) | |
1215 | wanted.add(rev) |
|
1217 | wanted.add(rev) | |
1216 | if copied: |
|
1218 | if copied: | |
1217 | copies.append(copied) |
|
1219 | copies.append(copied) | |
1218 | if slowpath: |
|
1220 | if slowpath: | |
1219 | # We have to read the changelog to match filenames against |
|
1221 | # We have to read the changelog to match filenames against | |
1220 | # changed files |
|
1222 | # changed files | |
1221 |
|
1223 | |||
1222 | if follow: |
|
1224 | if follow: | |
1223 | raise util.Abort(_('can only follow copies/renames for explicit ' |
|
1225 | raise util.Abort(_('can only follow copies/renames for explicit ' | |
1224 | 'filenames')) |
|
1226 | 'filenames')) | |
1225 |
|
1227 | |||
1226 | # The slow path checks files modified in every changeset. |
|
1228 | # The slow path checks files modified in every changeset. | |
1227 | for i in sorted(revs): |
|
1229 | for i in sorted(revs): | |
1228 | ctx = change(i) |
|
1230 | ctx = change(i) | |
1229 | matches = filter(match, ctx.files()) |
|
1231 | matches = filter(match, ctx.files()) | |
1230 | if matches: |
|
1232 | if matches: | |
1231 | fncache[i] = matches |
|
1233 | fncache[i] = matches | |
1232 | wanted.add(i) |
|
1234 | wanted.add(i) | |
1233 |
|
1235 | |||
1234 | class followfilter(object): |
|
1236 | class followfilter(object): | |
1235 | def __init__(self, onlyfirst=False): |
|
1237 | def __init__(self, onlyfirst=False): | |
1236 | self.startrev = nullrev |
|
1238 | self.startrev = nullrev | |
1237 | self.roots = set() |
|
1239 | self.roots = set() | |
1238 | self.onlyfirst = onlyfirst |
|
1240 | self.onlyfirst = onlyfirst | |
1239 |
|
1241 | |||
1240 | def match(self, rev): |
|
1242 | def match(self, rev): | |
1241 | def realparents(rev): |
|
1243 | def realparents(rev): | |
1242 | if self.onlyfirst: |
|
1244 | if self.onlyfirst: | |
1243 | return repo.changelog.parentrevs(rev)[0:1] |
|
1245 | return repo.changelog.parentrevs(rev)[0:1] | |
1244 | else: |
|
1246 | else: | |
1245 | return filter(lambda x: x != nullrev, |
|
1247 | return filter(lambda x: x != nullrev, | |
1246 | repo.changelog.parentrevs(rev)) |
|
1248 | repo.changelog.parentrevs(rev)) | |
1247 |
|
1249 | |||
1248 | if self.startrev == nullrev: |
|
1250 | if self.startrev == nullrev: | |
1249 | self.startrev = rev |
|
1251 | self.startrev = rev | |
1250 | return True |
|
1252 | return True | |
1251 |
|
1253 | |||
1252 | if rev > self.startrev: |
|
1254 | if rev > self.startrev: | |
1253 | # forward: all descendants |
|
1255 | # forward: all descendants | |
1254 | if not self.roots: |
|
1256 | if not self.roots: | |
1255 | self.roots.add(self.startrev) |
|
1257 | self.roots.add(self.startrev) | |
1256 | for parent in realparents(rev): |
|
1258 | for parent in realparents(rev): | |
1257 | if parent in self.roots: |
|
1259 | if parent in self.roots: | |
1258 | self.roots.add(rev) |
|
1260 | self.roots.add(rev) | |
1259 | return True |
|
1261 | return True | |
1260 | else: |
|
1262 | else: | |
1261 | # backwards: all parents |
|
1263 | # backwards: all parents | |
1262 | if not self.roots: |
|
1264 | if not self.roots: | |
1263 | self.roots.update(realparents(self.startrev)) |
|
1265 | self.roots.update(realparents(self.startrev)) | |
1264 | if rev in self.roots: |
|
1266 | if rev in self.roots: | |
1265 | self.roots.remove(rev) |
|
1267 | self.roots.remove(rev) | |
1266 | self.roots.update(realparents(rev)) |
|
1268 | self.roots.update(realparents(rev)) | |
1267 | return True |
|
1269 | return True | |
1268 |
|
1270 | |||
1269 | return False |
|
1271 | return False | |
1270 |
|
1272 | |||
1271 | # it might be worthwhile to do this in the iterator if the rev range |
|
1273 | # it might be worthwhile to do this in the iterator if the rev range | |
1272 | # is descending and the prune args are all within that range |
|
1274 | # is descending and the prune args are all within that range | |
1273 | for rev in opts.get('prune', ()): |
|
1275 | for rev in opts.get('prune', ()): | |
1274 | rev = repo.changelog.rev(repo.lookup(rev)) |
|
1276 | rev = repo.changelog.rev(repo.lookup(rev)) | |
1275 | ff = followfilter() |
|
1277 | ff = followfilter() | |
1276 | stop = min(revs[0], revs[-1]) |
|
1278 | stop = min(revs[0], revs[-1]) | |
1277 | for x in xrange(rev, stop - 1, -1): |
|
1279 | for x in xrange(rev, stop - 1, -1): | |
1278 | if ff.match(x): |
|
1280 | if ff.match(x): | |
1279 | wanted.discard(x) |
|
1281 | wanted.discard(x) | |
1280 |
|
1282 | |||
1281 | # Now that wanted is correctly initialized, we can iterate over the |
|
1283 | # Now that wanted is correctly initialized, we can iterate over the | |
1282 | # revision range, yielding only revisions in wanted. |
|
1284 | # revision range, yielding only revisions in wanted. | |
1283 | def iterate(): |
|
1285 | def iterate(): | |
1284 | if follow and not match.files(): |
|
1286 | if follow and not match.files(): | |
1285 | ff = followfilter(onlyfirst=opts.get('follow_first')) |
|
1287 | ff = followfilter(onlyfirst=opts.get('follow_first')) | |
1286 | def want(rev): |
|
1288 | def want(rev): | |
1287 | return ff.match(rev) and rev in wanted |
|
1289 | return ff.match(rev) and rev in wanted | |
1288 | else: |
|
1290 | else: | |
1289 | def want(rev): |
|
1291 | def want(rev): | |
1290 | return rev in wanted |
|
1292 | return rev in wanted | |
1291 |
|
1293 | |||
1292 | for i, window in increasing_windows(0, len(revs)): |
|
1294 | for i, window in increasing_windows(0, len(revs)): | |
1293 | nrevs = [rev for rev in revs[i:i + window] if want(rev)] |
|
1295 | nrevs = [rev for rev in revs[i:i + window] if want(rev)] | |
1294 | for rev in sorted(nrevs): |
|
1296 | for rev in sorted(nrevs): | |
1295 | fns = fncache.get(rev) |
|
1297 | fns = fncache.get(rev) | |
1296 | ctx = change(rev) |
|
1298 | ctx = change(rev) | |
1297 | if not fns: |
|
1299 | if not fns: | |
1298 | def fns_generator(): |
|
1300 | def fns_generator(): | |
1299 | for f in ctx.files(): |
|
1301 | for f in ctx.files(): | |
1300 | if match(f): |
|
1302 | if match(f): | |
1301 | yield f |
|
1303 | yield f | |
1302 | fns = fns_generator() |
|
1304 | fns = fns_generator() | |
1303 | prepare(ctx, fns) |
|
1305 | prepare(ctx, fns) | |
1304 | for rev in nrevs: |
|
1306 | for rev in nrevs: | |
1305 | yield change(rev) |
|
1307 | yield change(rev) | |
1306 | return iterate() |
|
1308 | return iterate() | |
1307 |
|
1309 | |||
1308 | def add(ui, repo, match, dryrun, listsubrepos, prefix): |
|
1310 | def add(ui, repo, match, dryrun, listsubrepos, prefix): | |
1309 | join = lambda f: os.path.join(prefix, f) |
|
1311 | join = lambda f: os.path.join(prefix, f) | |
1310 | bad = [] |
|
1312 | bad = [] | |
1311 | oldbad = match.bad |
|
1313 | oldbad = match.bad | |
1312 | match.bad = lambda x, y: bad.append(x) or oldbad(x, y) |
|
1314 | match.bad = lambda x, y: bad.append(x) or oldbad(x, y) | |
1313 | names = [] |
|
1315 | names = [] | |
1314 | wctx = repo[None] |
|
1316 | wctx = repo[None] | |
1315 | for f in repo.walk(match): |
|
1317 | for f in repo.walk(match): | |
1316 | exact = match.exact(f) |
|
1318 | exact = match.exact(f) | |
1317 | if exact or f not in repo.dirstate: |
|
1319 | if exact or f not in repo.dirstate: | |
1318 | names.append(f) |
|
1320 | names.append(f) | |
1319 | if ui.verbose or not exact: |
|
1321 | if ui.verbose or not exact: | |
1320 | ui.status(_('adding %s\n') % match.rel(join(f))) |
|
1322 | ui.status(_('adding %s\n') % match.rel(join(f))) | |
1321 |
|
1323 | |||
1322 | if listsubrepos: |
|
1324 | if listsubrepos: | |
1323 | for subpath in wctx.substate: |
|
1325 | for subpath in wctx.substate: | |
1324 | sub = wctx.sub(subpath) |
|
1326 | sub = wctx.sub(subpath) | |
1325 | try: |
|
1327 | try: | |
1326 | submatch = matchmod.narrowmatcher(subpath, match) |
|
1328 | submatch = matchmod.narrowmatcher(subpath, match) | |
1327 | bad.extend(sub.add(ui, submatch, dryrun, prefix)) |
|
1329 | bad.extend(sub.add(ui, submatch, dryrun, prefix)) | |
1328 | except error.LookupError: |
|
1330 | except error.LookupError: | |
1329 | ui.status(_("skipping missing subrepository: %s\n") |
|
1331 | ui.status(_("skipping missing subrepository: %s\n") | |
1330 | % join(subpath)) |
|
1332 | % join(subpath)) | |
1331 |
|
1333 | |||
1332 | if not dryrun: |
|
1334 | if not dryrun: | |
1333 | rejected = wctx.add(names, prefix) |
|
1335 | rejected = wctx.add(names, prefix) | |
1334 | bad.extend(f for f in rejected if f in match.files()) |
|
1336 | bad.extend(f for f in rejected if f in match.files()) | |
1335 | return bad |
|
1337 | return bad | |
1336 |
|
1338 | |||
1337 | def commit(ui, repo, commitfunc, pats, opts): |
|
1339 | def commit(ui, repo, commitfunc, pats, opts): | |
1338 | '''commit the specified files or all outstanding changes''' |
|
1340 | '''commit the specified files or all outstanding changes''' | |
1339 | date = opts.get('date') |
|
1341 | date = opts.get('date') | |
1340 | if date: |
|
1342 | if date: | |
1341 | opts['date'] = util.parsedate(date) |
|
1343 | opts['date'] = util.parsedate(date) | |
1342 | message = logmessage(opts) |
|
1344 | message = logmessage(opts) | |
1343 |
|
1345 | |||
1344 | # extract addremove carefully -- this function can be called from a command |
|
1346 | # extract addremove carefully -- this function can be called from a command | |
1345 | # that doesn't support addremove |
|
1347 | # that doesn't support addremove | |
1346 | if opts.get('addremove'): |
|
1348 | if opts.get('addremove'): | |
1347 | addremove(repo, pats, opts) |
|
1349 | addremove(repo, pats, opts) | |
1348 |
|
1350 | |||
1349 | return commitfunc(ui, repo, message, match(repo, pats, opts), opts) |
|
1351 | return commitfunc(ui, repo, message, match(repo, pats, opts), opts) | |
1350 |
|
1352 | |||
1351 | def commiteditor(repo, ctx, subs): |
|
1353 | def commiteditor(repo, ctx, subs): | |
1352 | if ctx.description(): |
|
1354 | if ctx.description(): | |
1353 | return ctx.description() |
|
1355 | return ctx.description() | |
1354 | return commitforceeditor(repo, ctx, subs) |
|
1356 | return commitforceeditor(repo, ctx, subs) | |
1355 |
|
1357 | |||
1356 | def commitforceeditor(repo, ctx, subs): |
|
1358 | def commitforceeditor(repo, ctx, subs): | |
1357 | edittext = [] |
|
1359 | edittext = [] | |
1358 | modified, added, removed = ctx.modified(), ctx.added(), ctx.removed() |
|
1360 | modified, added, removed = ctx.modified(), ctx.added(), ctx.removed() | |
1359 | if ctx.description(): |
|
1361 | if ctx.description(): | |
1360 | edittext.append(ctx.description()) |
|
1362 | edittext.append(ctx.description()) | |
1361 | edittext.append("") |
|
1363 | edittext.append("") | |
1362 | edittext.append("") # Empty line between message and comments. |
|
1364 | edittext.append("") # Empty line between message and comments. | |
1363 | edittext.append(_("HG: Enter commit message." |
|
1365 | edittext.append(_("HG: Enter commit message." | |
1364 | " Lines beginning with 'HG:' are removed.")) |
|
1366 | " Lines beginning with 'HG:' are removed.")) | |
1365 | edittext.append(_("HG: Leave message empty to abort commit.")) |
|
1367 | edittext.append(_("HG: Leave message empty to abort commit.")) | |
1366 | edittext.append("HG: --") |
|
1368 | edittext.append("HG: --") | |
1367 | edittext.append(_("HG: user: %s") % ctx.user()) |
|
1369 | edittext.append(_("HG: user: %s") % ctx.user()) | |
1368 | if ctx.p2(): |
|
1370 | if ctx.p2(): | |
1369 | edittext.append(_("HG: branch merge")) |
|
1371 | edittext.append(_("HG: branch merge")) | |
1370 | if ctx.branch(): |
|
1372 | if ctx.branch(): | |
1371 | edittext.append(_("HG: branch '%s'") % ctx.branch()) |
|
1373 | edittext.append(_("HG: branch '%s'") % ctx.branch()) | |
1372 | edittext.extend([_("HG: subrepo %s") % s for s in subs]) |
|
1374 | edittext.extend([_("HG: subrepo %s") % s for s in subs]) | |
1373 | edittext.extend([_("HG: added %s") % f for f in added]) |
|
1375 | edittext.extend([_("HG: added %s") % f for f in added]) | |
1374 | edittext.extend([_("HG: changed %s") % f for f in modified]) |
|
1376 | edittext.extend([_("HG: changed %s") % f for f in modified]) | |
1375 | edittext.extend([_("HG: removed %s") % f for f in removed]) |
|
1377 | edittext.extend([_("HG: removed %s") % f for f in removed]) | |
1376 | if not added and not modified and not removed: |
|
1378 | if not added and not modified and not removed: | |
1377 | edittext.append(_("HG: no files changed")) |
|
1379 | edittext.append(_("HG: no files changed")) | |
1378 | edittext.append("") |
|
1380 | edittext.append("") | |
1379 | # run editor in the repository root |
|
1381 | # run editor in the repository root | |
1380 | olddir = os.getcwd() |
|
1382 | olddir = os.getcwd() | |
1381 | os.chdir(repo.root) |
|
1383 | os.chdir(repo.root) | |
1382 | text = repo.ui.edit("\n".join(edittext), ctx.user()) |
|
1384 | text = repo.ui.edit("\n".join(edittext), ctx.user()) | |
1383 | text = re.sub("(?m)^HG:.*(\n|$)", "", text) |
|
1385 | text = re.sub("(?m)^HG:.*(\n|$)", "", text) | |
1384 | os.chdir(olddir) |
|
1386 | os.chdir(olddir) | |
1385 |
|
1387 | |||
1386 | if not text.strip(): |
|
1388 | if not text.strip(): | |
1387 | raise util.Abort(_("empty commit message")) |
|
1389 | raise util.Abort(_("empty commit message")) | |
1388 |
|
1390 | |||
1389 | return text |
|
1391 | return text |
@@ -1,57 +1,68 b'' | |||||
1 | http://mercurial.selenic.com/bts/issue352 |
|
1 | http://mercurial.selenic.com/bts/issue352 | |
2 |
|
2 | |||
3 | $ "$TESTDIR/hghave" eol-in-paths || exit 80 |
|
3 | $ "$TESTDIR/hghave" eol-in-paths || exit 80 | |
4 |
|
4 | |||
5 | test issue352 |
|
5 | test issue352 | |
6 |
|
6 | |||
7 | $ hg init foo |
|
7 | $ hg init foo | |
8 | $ cd foo |
|
8 | $ cd foo | |
9 | $ A=`printf 'he\rllo'` |
|
9 | $ A=`printf 'he\rllo'` | |
10 | $ echo foo > "$A" |
|
10 | $ echo foo > "$A" | |
11 | $ hg add |
|
11 | $ hg add | |
12 | adding he\rllo (esc) |
|
12 | adding he\rllo (esc) | |
13 | abort: '\n' and '\r' disallowed in filenames: 'he\rllo' |
|
13 | abort: '\n' and '\r' disallowed in filenames: 'he\rllo' | |
14 | [255] |
|
14 | [255] | |
15 | $ hg ci -A -m m |
|
15 | $ hg ci -A -m m | |
16 | adding he\rllo (esc) |
|
16 | adding he\rllo (esc) | |
17 | abort: '\n' and '\r' disallowed in filenames: 'he\rllo' |
|
17 | abort: '\n' and '\r' disallowed in filenames: 'he\rllo' | |
18 | [255] |
|
18 | [255] | |
19 | $ rm "$A" |
|
19 | $ rm "$A" | |
20 | $ echo foo > "hell |
|
20 | $ echo foo > "hell | |
21 | > o" |
|
21 | > o" | |
22 | $ hg add |
|
22 | $ hg add | |
23 | adding hell |
|
23 | adding hell | |
24 | o |
|
24 | o | |
25 | abort: '\n' and '\r' disallowed in filenames: 'hell\no' |
|
25 | abort: '\n' and '\r' disallowed in filenames: 'hell\no' | |
26 | [255] |
|
26 | [255] | |
27 | $ hg ci -A -m m |
|
27 | $ hg ci -A -m m | |
28 | adding hell |
|
28 | adding hell | |
29 | o |
|
29 | o | |
30 | abort: '\n' and '\r' disallowed in filenames: 'hell\no' |
|
30 | abort: '\n' and '\r' disallowed in filenames: 'hell\no' | |
31 | [255] |
|
31 | [255] | |
32 | $ echo foo > "$A" |
|
32 | $ echo foo > "$A" | |
33 | $ hg debugwalk |
|
33 | $ hg debugwalk | |
34 | f he\rllo he\rllo (esc) |
|
34 | f he\rllo he\rllo (esc) | |
35 | f hell |
|
35 | f hell | |
36 | o hell |
|
36 | o hell | |
37 | o |
|
37 | o | |
38 |
|
38 | |||
|
39 | $ echo bla > quickfox | |||
|
40 | $ hg add quickfox | |||
|
41 | $ hg ci -m 2 | |||
|
42 | $ A=`printf 'quick\rfox'` | |||
|
43 | $ hg cp quickfox "$A" | |||
|
44 | abort: '\n' and '\r' disallowed in filenames: 'quick\rfox' | |||
|
45 | [255] | |||
|
46 | $ hg mv quickfox "$A" | |||
|
47 | abort: '\n' and '\r' disallowed in filenames: 'quick\rfox' | |||
|
48 | [255] | |||
|
49 | ||||
39 | http://mercurial.selenic.com/bts/issue2036 |
|
50 | http://mercurial.selenic.com/bts/issue2036 | |
40 |
|
51 | |||
41 | $ cd .. |
|
52 | $ cd .. | |
42 |
|
53 | |||
43 | test issue2039 |
|
54 | test issue2039 | |
44 |
|
55 | |||
45 | $ hg init bar |
|
56 | $ hg init bar | |
46 | $ cd bar |
|
57 | $ cd bar | |
47 | $ echo "[extensions]" >> $HGRCPATH |
|
58 | $ echo "[extensions]" >> $HGRCPATH | |
48 | $ echo "color=" >> $HGRCPATH |
|
59 | $ echo "color=" >> $HGRCPATH | |
49 | $ A=`printf 'foo\nbar'` |
|
60 | $ A=`printf 'foo\nbar'` | |
50 | $ B=`printf 'foo\nbar.baz'` |
|
61 | $ B=`printf 'foo\nbar.baz'` | |
51 | $ touch "$A" |
|
62 | $ touch "$A" | |
52 | $ touch "$B" |
|
63 | $ touch "$B" | |
53 | $ hg status --color=always |
|
64 | $ hg status --color=always | |
54 | \x1b[0;35;1;4m? foo\x1b[0m (esc) |
|
65 | \x1b[0;35;1;4m? foo\x1b[0m (esc) | |
55 | \x1b[0;35;1;4mbar\x1b[0m (esc) |
|
66 | \x1b[0;35;1;4mbar\x1b[0m (esc) | |
56 | \x1b[0;35;1;4m? foo\x1b[0m (esc) |
|
67 | \x1b[0;35;1;4m? foo\x1b[0m (esc) | |
57 | \x1b[0;35;1;4mbar.baz\x1b[0m (esc) |
|
68 | \x1b[0;35;1;4mbar.baz\x1b[0m (esc) |
General Comments 0
You need to be logged in to leave comments.
Login now