Show More
@@ -1,2850 +1,2850 b'' | |||||
1 | # patch.py - patch file parsing routines |
|
1 | # patch.py - patch file parsing routines | |
2 | # |
|
2 | # | |
3 | # Copyright 2006 Brendan Cully <brendan@kublai.com> |
|
3 | # Copyright 2006 Brendan Cully <brendan@kublai.com> | |
4 | # Copyright 2007 Chris Mason <chris.mason@oracle.com> |
|
4 | # Copyright 2007 Chris Mason <chris.mason@oracle.com> | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | from __future__ import absolute_import, print_function |
|
9 | from __future__ import absolute_import, print_function | |
10 |
|
10 | |||
11 | import collections |
|
11 | import collections | |
12 | import contextlib |
|
12 | import contextlib | |
13 | import copy |
|
13 | import copy | |
14 | import email |
|
14 | import email | |
15 | import errno |
|
15 | import errno | |
16 | import hashlib |
|
16 | import hashlib | |
17 | import os |
|
17 | import os | |
18 | import re |
|
18 | import re | |
19 | import shutil |
|
19 | import shutil | |
20 | import zlib |
|
20 | import zlib | |
21 |
|
21 | |||
22 | from .i18n import _ |
|
22 | from .i18n import _ | |
23 | from .node import ( |
|
23 | from .node import ( | |
24 | hex, |
|
24 | hex, | |
25 | short, |
|
25 | short, | |
26 | ) |
|
26 | ) | |
27 | from . import ( |
|
27 | from . import ( | |
28 | copies, |
|
28 | copies, | |
29 | diffhelper, |
|
29 | diffhelper, | |
30 | diffutil, |
|
30 | diffutil, | |
31 | encoding, |
|
31 | encoding, | |
32 | error, |
|
32 | error, | |
33 | mail, |
|
33 | mail, | |
34 | mdiff, |
|
34 | mdiff, | |
35 | pathutil, |
|
35 | pathutil, | |
36 | pycompat, |
|
36 | pycompat, | |
37 | scmutil, |
|
37 | scmutil, | |
38 | similar, |
|
38 | similar, | |
39 | util, |
|
39 | util, | |
40 | vfs as vfsmod, |
|
40 | vfs as vfsmod, | |
41 | ) |
|
41 | ) | |
42 | from .utils import ( |
|
42 | from .utils import ( | |
43 | dateutil, |
|
43 | dateutil, | |
44 | procutil, |
|
44 | procutil, | |
45 | stringutil, |
|
45 | stringutil, | |
46 | ) |
|
46 | ) | |
47 |
|
47 | |||
48 | stringio = util.stringio |
|
48 | stringio = util.stringio | |
49 |
|
49 | |||
50 | gitre = re.compile(br'diff --git a/(.*) b/(.*)') |
|
50 | gitre = re.compile(br'diff --git a/(.*) b/(.*)') | |
51 | tabsplitter = re.compile(br'(\t+|[^\t]+)') |
|
51 | tabsplitter = re.compile(br'(\t+|[^\t]+)') | |
52 | wordsplitter = re.compile(br'(\t+| +|[a-zA-Z0-9_\x80-\xff]+|' |
|
52 | wordsplitter = re.compile(br'(\t+| +|[a-zA-Z0-9_\x80-\xff]+|' | |
53 | b'[^ \ta-zA-Z0-9_\x80-\xff])') |
|
53 | b'[^ \ta-zA-Z0-9_\x80-\xff])') | |
54 |
|
54 | |||
55 | PatchError = error.PatchError |
|
55 | PatchError = error.PatchError | |
56 |
|
56 | |||
57 | # public functions |
|
57 | # public functions | |
58 |
|
58 | |||
59 | def split(stream): |
|
59 | def split(stream): | |
60 | '''return an iterator of individual patches from a stream''' |
|
60 | '''return an iterator of individual patches from a stream''' | |
61 | def isheader(line, inheader): |
|
61 | def isheader(line, inheader): | |
62 | if inheader and line.startswith((' ', '\t')): |
|
62 | if inheader and line.startswith((' ', '\t')): | |
63 | # continuation |
|
63 | # continuation | |
64 | return True |
|
64 | return True | |
65 | if line.startswith((' ', '-', '+')): |
|
65 | if line.startswith((' ', '-', '+')): | |
66 | # diff line - don't check for header pattern in there |
|
66 | # diff line - don't check for header pattern in there | |
67 | return False |
|
67 | return False | |
68 | l = line.split(': ', 1) |
|
68 | l = line.split(': ', 1) | |
69 | return len(l) == 2 and ' ' not in l[0] |
|
69 | return len(l) == 2 and ' ' not in l[0] | |
70 |
|
70 | |||
71 | def chunk(lines): |
|
71 | def chunk(lines): | |
72 | return stringio(''.join(lines)) |
|
72 | return stringio(''.join(lines)) | |
73 |
|
73 | |||
74 | def hgsplit(stream, cur): |
|
74 | def hgsplit(stream, cur): | |
75 | inheader = True |
|
75 | inheader = True | |
76 |
|
76 | |||
77 | for line in stream: |
|
77 | for line in stream: | |
78 | if not line.strip(): |
|
78 | if not line.strip(): | |
79 | inheader = False |
|
79 | inheader = False | |
80 | if not inheader and line.startswith('# HG changeset patch'): |
|
80 | if not inheader and line.startswith('# HG changeset patch'): | |
81 | yield chunk(cur) |
|
81 | yield chunk(cur) | |
82 | cur = [] |
|
82 | cur = [] | |
83 | inheader = True |
|
83 | inheader = True | |
84 |
|
84 | |||
85 | cur.append(line) |
|
85 | cur.append(line) | |
86 |
|
86 | |||
87 | if cur: |
|
87 | if cur: | |
88 | yield chunk(cur) |
|
88 | yield chunk(cur) | |
89 |
|
89 | |||
90 | def mboxsplit(stream, cur): |
|
90 | def mboxsplit(stream, cur): | |
91 | for line in stream: |
|
91 | for line in stream: | |
92 | if line.startswith('From '): |
|
92 | if line.startswith('From '): | |
93 | for c in split(chunk(cur[1:])): |
|
93 | for c in split(chunk(cur[1:])): | |
94 | yield c |
|
94 | yield c | |
95 | cur = [] |
|
95 | cur = [] | |
96 |
|
96 | |||
97 | cur.append(line) |
|
97 | cur.append(line) | |
98 |
|
98 | |||
99 | if cur: |
|
99 | if cur: | |
100 | for c in split(chunk(cur[1:])): |
|
100 | for c in split(chunk(cur[1:])): | |
101 | yield c |
|
101 | yield c | |
102 |
|
102 | |||
103 | def mimesplit(stream, cur): |
|
103 | def mimesplit(stream, cur): | |
104 | def msgfp(m): |
|
104 | def msgfp(m): | |
105 | fp = stringio() |
|
105 | fp = stringio() | |
106 | g = email.Generator.Generator(fp, mangle_from_=False) |
|
106 | g = email.Generator.Generator(fp, mangle_from_=False) | |
107 | g.flatten(m) |
|
107 | g.flatten(m) | |
108 | fp.seek(0) |
|
108 | fp.seek(0) | |
109 | return fp |
|
109 | return fp | |
110 |
|
110 | |||
111 | for line in stream: |
|
111 | for line in stream: | |
112 | cur.append(line) |
|
112 | cur.append(line) | |
113 | c = chunk(cur) |
|
113 | c = chunk(cur) | |
114 |
|
114 | |||
115 | m = mail.parse(c) |
|
115 | m = mail.parse(c) | |
116 | if not m.is_multipart(): |
|
116 | if not m.is_multipart(): | |
117 | yield msgfp(m) |
|
117 | yield msgfp(m) | |
118 | else: |
|
118 | else: | |
119 | ok_types = ('text/plain', 'text/x-diff', 'text/x-patch') |
|
119 | ok_types = ('text/plain', 'text/x-diff', 'text/x-patch') | |
120 | for part in m.walk(): |
|
120 | for part in m.walk(): | |
121 | ct = part.get_content_type() |
|
121 | ct = part.get_content_type() | |
122 | if ct not in ok_types: |
|
122 | if ct not in ok_types: | |
123 | continue |
|
123 | continue | |
124 | yield msgfp(part) |
|
124 | yield msgfp(part) | |
125 |
|
125 | |||
126 | def headersplit(stream, cur): |
|
126 | def headersplit(stream, cur): | |
127 | inheader = False |
|
127 | inheader = False | |
128 |
|
128 | |||
129 | for line in stream: |
|
129 | for line in stream: | |
130 | if not inheader and isheader(line, inheader): |
|
130 | if not inheader and isheader(line, inheader): | |
131 | yield chunk(cur) |
|
131 | yield chunk(cur) | |
132 | cur = [] |
|
132 | cur = [] | |
133 | inheader = True |
|
133 | inheader = True | |
134 | if inheader and not isheader(line, inheader): |
|
134 | if inheader and not isheader(line, inheader): | |
135 | inheader = False |
|
135 | inheader = False | |
136 |
|
136 | |||
137 | cur.append(line) |
|
137 | cur.append(line) | |
138 |
|
138 | |||
139 | if cur: |
|
139 | if cur: | |
140 | yield chunk(cur) |
|
140 | yield chunk(cur) | |
141 |
|
141 | |||
142 | def remainder(cur): |
|
142 | def remainder(cur): | |
143 | yield chunk(cur) |
|
143 | yield chunk(cur) | |
144 |
|
144 | |||
145 | class fiter(object): |
|
145 | class fiter(object): | |
146 | def __init__(self, fp): |
|
146 | def __init__(self, fp): | |
147 | self.fp = fp |
|
147 | self.fp = fp | |
148 |
|
148 | |||
149 | def __iter__(self): |
|
149 | def __iter__(self): | |
150 | return self |
|
150 | return self | |
151 |
|
151 | |||
152 | def next(self): |
|
152 | def next(self): | |
153 | l = self.fp.readline() |
|
153 | l = self.fp.readline() | |
154 | if not l: |
|
154 | if not l: | |
155 | raise StopIteration |
|
155 | raise StopIteration | |
156 | return l |
|
156 | return l | |
157 |
|
157 | |||
158 | __next__ = next |
|
158 | __next__ = next | |
159 |
|
159 | |||
160 | inheader = False |
|
160 | inheader = False | |
161 | cur = [] |
|
161 | cur = [] | |
162 |
|
162 | |||
163 | mimeheaders = ['content-type'] |
|
163 | mimeheaders = ['content-type'] | |
164 |
|
164 | |||
165 | if not util.safehasattr(stream, 'next'): |
|
165 | if not util.safehasattr(stream, 'next'): | |
166 | # http responses, for example, have readline but not next |
|
166 | # http responses, for example, have readline but not next | |
167 | stream = fiter(stream) |
|
167 | stream = fiter(stream) | |
168 |
|
168 | |||
169 | for line in stream: |
|
169 | for line in stream: | |
170 | cur.append(line) |
|
170 | cur.append(line) | |
171 | if line.startswith('# HG changeset patch'): |
|
171 | if line.startswith('# HG changeset patch'): | |
172 | return hgsplit(stream, cur) |
|
172 | return hgsplit(stream, cur) | |
173 | elif line.startswith('From '): |
|
173 | elif line.startswith('From '): | |
174 | return mboxsplit(stream, cur) |
|
174 | return mboxsplit(stream, cur) | |
175 | elif isheader(line, inheader): |
|
175 | elif isheader(line, inheader): | |
176 | inheader = True |
|
176 | inheader = True | |
177 | if line.split(':', 1)[0].lower() in mimeheaders: |
|
177 | if line.split(':', 1)[0].lower() in mimeheaders: | |
178 | # let email parser handle this |
|
178 | # let email parser handle this | |
179 | return mimesplit(stream, cur) |
|
179 | return mimesplit(stream, cur) | |
180 | elif line.startswith('--- ') and inheader: |
|
180 | elif line.startswith('--- ') and inheader: | |
181 | # No evil headers seen by diff start, split by hand |
|
181 | # No evil headers seen by diff start, split by hand | |
182 | return headersplit(stream, cur) |
|
182 | return headersplit(stream, cur) | |
183 | # Not enough info, keep reading |
|
183 | # Not enough info, keep reading | |
184 |
|
184 | |||
185 | # if we are here, we have a very plain patch |
|
185 | # if we are here, we have a very plain patch | |
186 | return remainder(cur) |
|
186 | return remainder(cur) | |
187 |
|
187 | |||
188 | ## Some facility for extensible patch parsing: |
|
188 | ## Some facility for extensible patch parsing: | |
189 | # list of pairs ("header to match", "data key") |
|
189 | # list of pairs ("header to match", "data key") | |
190 | patchheadermap = [('Date', 'date'), |
|
190 | patchheadermap = [('Date', 'date'), | |
191 | ('Branch', 'branch'), |
|
191 | ('Branch', 'branch'), | |
192 | ('Node ID', 'nodeid'), |
|
192 | ('Node ID', 'nodeid'), | |
193 | ] |
|
193 | ] | |
194 |
|
194 | |||
195 | @contextlib.contextmanager |
|
195 | @contextlib.contextmanager | |
196 | def extract(ui, fileobj): |
|
196 | def extract(ui, fileobj): | |
197 | '''extract patch from data read from fileobj. |
|
197 | '''extract patch from data read from fileobj. | |
198 |
|
198 | |||
199 | patch can be a normal patch or contained in an email message. |
|
199 | patch can be a normal patch or contained in an email message. | |
200 |
|
200 | |||
201 | return a dictionary. Standard keys are: |
|
201 | return a dictionary. Standard keys are: | |
202 | - filename, |
|
202 | - filename, | |
203 | - message, |
|
203 | - message, | |
204 | - user, |
|
204 | - user, | |
205 | - date, |
|
205 | - date, | |
206 | - branch, |
|
206 | - branch, | |
207 | - node, |
|
207 | - node, | |
208 | - p1, |
|
208 | - p1, | |
209 | - p2. |
|
209 | - p2. | |
210 | Any item can be missing from the dictionary. If filename is missing, |
|
210 | Any item can be missing from the dictionary. If filename is missing, | |
211 | fileobj did not contain a patch. Caller must unlink filename when done.''' |
|
211 | fileobj did not contain a patch. Caller must unlink filename when done.''' | |
212 |
|
212 | |||
213 | fd, tmpname = pycompat.mkstemp(prefix='hg-patch-') |
|
213 | fd, tmpname = pycompat.mkstemp(prefix='hg-patch-') | |
214 | tmpfp = os.fdopen(fd, r'wb') |
|
214 | tmpfp = os.fdopen(fd, r'wb') | |
215 | try: |
|
215 | try: | |
216 | yield _extract(ui, fileobj, tmpname, tmpfp) |
|
216 | yield _extract(ui, fileobj, tmpname, tmpfp) | |
217 | finally: |
|
217 | finally: | |
218 | tmpfp.close() |
|
218 | tmpfp.close() | |
219 | os.unlink(tmpname) |
|
219 | os.unlink(tmpname) | |
220 |
|
220 | |||
221 | def _extract(ui, fileobj, tmpname, tmpfp): |
|
221 | def _extract(ui, fileobj, tmpname, tmpfp): | |
222 |
|
222 | |||
223 | # attempt to detect the start of a patch |
|
223 | # attempt to detect the start of a patch | |
224 | # (this heuristic is borrowed from quilt) |
|
224 | # (this heuristic is borrowed from quilt) | |
225 | diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]-|RCS file: |' |
|
225 | diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]-|RCS file: |' | |
226 | br'retrieving revision [0-9]+(\.[0-9]+)*$|' |
|
226 | br'retrieving revision [0-9]+(\.[0-9]+)*$|' | |
227 | br'---[ \t].*?^\+\+\+[ \t]|' |
|
227 | br'---[ \t].*?^\+\+\+[ \t]|' | |
228 | br'\*\*\*[ \t].*?^---[ \t])', |
|
228 | br'\*\*\*[ \t].*?^---[ \t])', | |
229 | re.MULTILINE | re.DOTALL) |
|
229 | re.MULTILINE | re.DOTALL) | |
230 |
|
230 | |||
231 | data = {} |
|
231 | data = {} | |
232 |
|
232 | |||
233 | msg = mail.parse(fileobj) |
|
233 | msg = mail.parse(fileobj) | |
234 |
|
234 | |||
235 | subject = msg[r'Subject'] and mail.headdecode(msg[r'Subject']) |
|
235 | subject = msg[r'Subject'] and mail.headdecode(msg[r'Subject']) | |
236 | data['user'] = msg[r'From'] and mail.headdecode(msg[r'From']) |
|
236 | data['user'] = msg[r'From'] and mail.headdecode(msg[r'From']) | |
237 | if not subject and not data['user']: |
|
237 | if not subject and not data['user']: | |
238 | # Not an email, restore parsed headers if any |
|
238 | # Not an email, restore parsed headers if any | |
239 | subject = '\n'.join(': '.join(map(encoding.strtolocal, h)) |
|
239 | subject = '\n'.join(': '.join(map(encoding.strtolocal, h)) | |
240 | for h in msg.items()) + '\n' |
|
240 | for h in msg.items()) + '\n' | |
241 |
|
241 | |||
242 | # should try to parse msg['Date'] |
|
242 | # should try to parse msg['Date'] | |
243 | parents = [] |
|
243 | parents = [] | |
244 |
|
244 | |||
245 | if subject: |
|
245 | if subject: | |
246 | if subject.startswith('[PATCH'): |
|
246 | if subject.startswith('[PATCH'): | |
247 | pend = subject.find(']') |
|
247 | pend = subject.find(']') | |
248 | if pend >= 0: |
|
248 | if pend >= 0: | |
249 | subject = subject[pend + 1:].lstrip() |
|
249 | subject = subject[pend + 1:].lstrip() | |
250 | subject = re.sub(br'\n[ \t]+', ' ', subject) |
|
250 | subject = re.sub(br'\n[ \t]+', ' ', subject) | |
251 | ui.debug('Subject: %s\n' % subject) |
|
251 | ui.debug('Subject: %s\n' % subject) | |
252 | if data['user']: |
|
252 | if data['user']: | |
253 | ui.debug('From: %s\n' % data['user']) |
|
253 | ui.debug('From: %s\n' % data['user']) | |
254 | diffs_seen = 0 |
|
254 | diffs_seen = 0 | |
255 | ok_types = ('text/plain', 'text/x-diff', 'text/x-patch') |
|
255 | ok_types = ('text/plain', 'text/x-diff', 'text/x-patch') | |
256 | message = '' |
|
256 | message = '' | |
257 | for part in msg.walk(): |
|
257 | for part in msg.walk(): | |
258 | content_type = pycompat.bytestr(part.get_content_type()) |
|
258 | content_type = pycompat.bytestr(part.get_content_type()) | |
259 | ui.debug('Content-Type: %s\n' % content_type) |
|
259 | ui.debug('Content-Type: %s\n' % content_type) | |
260 | if content_type not in ok_types: |
|
260 | if content_type not in ok_types: | |
261 | continue |
|
261 | continue | |
262 | payload = part.get_payload(decode=True) |
|
262 | payload = part.get_payload(decode=True) | |
263 | m = diffre.search(payload) |
|
263 | m = diffre.search(payload) | |
264 | if m: |
|
264 | if m: | |
265 | hgpatch = False |
|
265 | hgpatch = False | |
266 | hgpatchheader = False |
|
266 | hgpatchheader = False | |
267 | ignoretext = False |
|
267 | ignoretext = False | |
268 |
|
268 | |||
269 | ui.debug('found patch at byte %d\n' % m.start(0)) |
|
269 | ui.debug('found patch at byte %d\n' % m.start(0)) | |
270 | diffs_seen += 1 |
|
270 | diffs_seen += 1 | |
271 | cfp = stringio() |
|
271 | cfp = stringio() | |
272 | for line in payload[:m.start(0)].splitlines(): |
|
272 | for line in payload[:m.start(0)].splitlines(): | |
273 | if line.startswith('# HG changeset patch') and not hgpatch: |
|
273 | if line.startswith('# HG changeset patch') and not hgpatch: | |
274 | ui.debug('patch generated by hg export\n') |
|
274 | ui.debug('patch generated by hg export\n') | |
275 | hgpatch = True |
|
275 | hgpatch = True | |
276 | hgpatchheader = True |
|
276 | hgpatchheader = True | |
277 | # drop earlier commit message content |
|
277 | # drop earlier commit message content | |
278 | cfp.seek(0) |
|
278 | cfp.seek(0) | |
279 | cfp.truncate() |
|
279 | cfp.truncate() | |
280 | subject = None |
|
280 | subject = None | |
281 | elif hgpatchheader: |
|
281 | elif hgpatchheader: | |
282 | if line.startswith('# User '): |
|
282 | if line.startswith('# User '): | |
283 | data['user'] = line[7:] |
|
283 | data['user'] = line[7:] | |
284 | ui.debug('From: %s\n' % data['user']) |
|
284 | ui.debug('From: %s\n' % data['user']) | |
285 | elif line.startswith("# Parent "): |
|
285 | elif line.startswith("# Parent "): | |
286 | parents.append(line[9:].lstrip()) |
|
286 | parents.append(line[9:].lstrip()) | |
287 | elif line.startswith("# "): |
|
287 | elif line.startswith("# "): | |
288 | for header, key in patchheadermap: |
|
288 | for header, key in patchheadermap: | |
289 | prefix = '# %s ' % header |
|
289 | prefix = '# %s ' % header | |
290 | if line.startswith(prefix): |
|
290 | if line.startswith(prefix): | |
291 | data[key] = line[len(prefix):] |
|
291 | data[key] = line[len(prefix):] | |
292 | else: |
|
292 | else: | |
293 | hgpatchheader = False |
|
293 | hgpatchheader = False | |
294 | elif line == '---': |
|
294 | elif line == '---': | |
295 | ignoretext = True |
|
295 | ignoretext = True | |
296 | if not hgpatchheader and not ignoretext: |
|
296 | if not hgpatchheader and not ignoretext: | |
297 | cfp.write(line) |
|
297 | cfp.write(line) | |
298 | cfp.write('\n') |
|
298 | cfp.write('\n') | |
299 | message = cfp.getvalue() |
|
299 | message = cfp.getvalue() | |
300 | if tmpfp: |
|
300 | if tmpfp: | |
301 | tmpfp.write(payload) |
|
301 | tmpfp.write(payload) | |
302 | if not payload.endswith('\n'): |
|
302 | if not payload.endswith('\n'): | |
303 | tmpfp.write('\n') |
|
303 | tmpfp.write('\n') | |
304 | elif not diffs_seen and message and content_type == 'text/plain': |
|
304 | elif not diffs_seen and message and content_type == 'text/plain': | |
305 | message += '\n' + payload |
|
305 | message += '\n' + payload | |
306 |
|
306 | |||
307 | if subject and not message.startswith(subject): |
|
307 | if subject and not message.startswith(subject): | |
308 | message = '%s\n%s' % (subject, message) |
|
308 | message = '%s\n%s' % (subject, message) | |
309 | data['message'] = message |
|
309 | data['message'] = message | |
310 | tmpfp.close() |
|
310 | tmpfp.close() | |
311 | if parents: |
|
311 | if parents: | |
312 | data['p1'] = parents.pop(0) |
|
312 | data['p1'] = parents.pop(0) | |
313 | if parents: |
|
313 | if parents: | |
314 | data['p2'] = parents.pop(0) |
|
314 | data['p2'] = parents.pop(0) | |
315 |
|
315 | |||
316 | if diffs_seen: |
|
316 | if diffs_seen: | |
317 | data['filename'] = tmpname |
|
317 | data['filename'] = tmpname | |
318 |
|
318 | |||
319 | return data |
|
319 | return data | |
320 |
|
320 | |||
321 | class patchmeta(object): |
|
321 | class patchmeta(object): | |
322 | """Patched file metadata |
|
322 | """Patched file metadata | |
323 |
|
323 | |||
324 | 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY |
|
324 | 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY | |
325 | or COPY. 'path' is patched file path. 'oldpath' is set to the |
|
325 | or COPY. 'path' is patched file path. 'oldpath' is set to the | |
326 | origin file when 'op' is either COPY or RENAME, None otherwise. If |
|
326 | origin file when 'op' is either COPY or RENAME, None otherwise. If | |
327 | file mode is changed, 'mode' is a tuple (islink, isexec) where |
|
327 | file mode is changed, 'mode' is a tuple (islink, isexec) where | |
328 | 'islink' is True if the file is a symlink and 'isexec' is True if |
|
328 | 'islink' is True if the file is a symlink and 'isexec' is True if | |
329 | the file is executable. Otherwise, 'mode' is None. |
|
329 | the file is executable. Otherwise, 'mode' is None. | |
330 | """ |
|
330 | """ | |
331 | def __init__(self, path): |
|
331 | def __init__(self, path): | |
332 | self.path = path |
|
332 | self.path = path | |
333 | self.oldpath = None |
|
333 | self.oldpath = None | |
334 | self.mode = None |
|
334 | self.mode = None | |
335 | self.op = 'MODIFY' |
|
335 | self.op = 'MODIFY' | |
336 | self.binary = False |
|
336 | self.binary = False | |
337 |
|
337 | |||
338 | def setmode(self, mode): |
|
338 | def setmode(self, mode): | |
339 | islink = mode & 0o20000 |
|
339 | islink = mode & 0o20000 | |
340 | isexec = mode & 0o100 |
|
340 | isexec = mode & 0o100 | |
341 | self.mode = (islink, isexec) |
|
341 | self.mode = (islink, isexec) | |
342 |
|
342 | |||
343 | def copy(self): |
|
343 | def copy(self): | |
344 | other = patchmeta(self.path) |
|
344 | other = patchmeta(self.path) | |
345 | other.oldpath = self.oldpath |
|
345 | other.oldpath = self.oldpath | |
346 | other.mode = self.mode |
|
346 | other.mode = self.mode | |
347 | other.op = self.op |
|
347 | other.op = self.op | |
348 | other.binary = self.binary |
|
348 | other.binary = self.binary | |
349 | return other |
|
349 | return other | |
350 |
|
350 | |||
351 | def _ispatchinga(self, afile): |
|
351 | def _ispatchinga(self, afile): | |
352 | if afile == '/dev/null': |
|
352 | if afile == '/dev/null': | |
353 | return self.op == 'ADD' |
|
353 | return self.op == 'ADD' | |
354 | return afile == 'a/' + (self.oldpath or self.path) |
|
354 | return afile == 'a/' + (self.oldpath or self.path) | |
355 |
|
355 | |||
356 | def _ispatchingb(self, bfile): |
|
356 | def _ispatchingb(self, bfile): | |
357 | if bfile == '/dev/null': |
|
357 | if bfile == '/dev/null': | |
358 | return self.op == 'DELETE' |
|
358 | return self.op == 'DELETE' | |
359 | return bfile == 'b/' + self.path |
|
359 | return bfile == 'b/' + self.path | |
360 |
|
360 | |||
361 | def ispatching(self, afile, bfile): |
|
361 | def ispatching(self, afile, bfile): | |
362 | return self._ispatchinga(afile) and self._ispatchingb(bfile) |
|
362 | return self._ispatchinga(afile) and self._ispatchingb(bfile) | |
363 |
|
363 | |||
364 | def __repr__(self): |
|
364 | def __repr__(self): | |
365 | return r"<patchmeta %s %r>" % (self.op, self.path) |
|
365 | return r"<patchmeta %s %r>" % (self.op, self.path) | |
366 |
|
366 | |||
367 | def readgitpatch(lr): |
|
367 | def readgitpatch(lr): | |
368 | """extract git-style metadata about patches from <patchname>""" |
|
368 | """extract git-style metadata about patches from <patchname>""" | |
369 |
|
369 | |||
370 | # Filter patch for git information |
|
370 | # Filter patch for git information | |
371 | gp = None |
|
371 | gp = None | |
372 | gitpatches = [] |
|
372 | gitpatches = [] | |
373 | for line in lr: |
|
373 | for line in lr: | |
374 | line = line.rstrip(' \r\n') |
|
374 | line = line.rstrip(' \r\n') | |
375 | if line.startswith('diff --git a/'): |
|
375 | if line.startswith('diff --git a/'): | |
376 | m = gitre.match(line) |
|
376 | m = gitre.match(line) | |
377 | if m: |
|
377 | if m: | |
378 | if gp: |
|
378 | if gp: | |
379 | gitpatches.append(gp) |
|
379 | gitpatches.append(gp) | |
380 | dst = m.group(2) |
|
380 | dst = m.group(2) | |
381 | gp = patchmeta(dst) |
|
381 | gp = patchmeta(dst) | |
382 | elif gp: |
|
382 | elif gp: | |
383 | if line.startswith('--- '): |
|
383 | if line.startswith('--- '): | |
384 | gitpatches.append(gp) |
|
384 | gitpatches.append(gp) | |
385 | gp = None |
|
385 | gp = None | |
386 | continue |
|
386 | continue | |
387 | if line.startswith('rename from '): |
|
387 | if line.startswith('rename from '): | |
388 | gp.op = 'RENAME' |
|
388 | gp.op = 'RENAME' | |
389 | gp.oldpath = line[12:] |
|
389 | gp.oldpath = line[12:] | |
390 | elif line.startswith('rename to '): |
|
390 | elif line.startswith('rename to '): | |
391 | gp.path = line[10:] |
|
391 | gp.path = line[10:] | |
392 | elif line.startswith('copy from '): |
|
392 | elif line.startswith('copy from '): | |
393 | gp.op = 'COPY' |
|
393 | gp.op = 'COPY' | |
394 | gp.oldpath = line[10:] |
|
394 | gp.oldpath = line[10:] | |
395 | elif line.startswith('copy to '): |
|
395 | elif line.startswith('copy to '): | |
396 | gp.path = line[8:] |
|
396 | gp.path = line[8:] | |
397 | elif line.startswith('deleted file'): |
|
397 | elif line.startswith('deleted file'): | |
398 | gp.op = 'DELETE' |
|
398 | gp.op = 'DELETE' | |
399 | elif line.startswith('new file mode '): |
|
399 | elif line.startswith('new file mode '): | |
400 | gp.op = 'ADD' |
|
400 | gp.op = 'ADD' | |
401 | gp.setmode(int(line[-6:], 8)) |
|
401 | gp.setmode(int(line[-6:], 8)) | |
402 | elif line.startswith('new mode '): |
|
402 | elif line.startswith('new mode '): | |
403 | gp.setmode(int(line[-6:], 8)) |
|
403 | gp.setmode(int(line[-6:], 8)) | |
404 | elif line.startswith('GIT binary patch'): |
|
404 | elif line.startswith('GIT binary patch'): | |
405 | gp.binary = True |
|
405 | gp.binary = True | |
406 | if gp: |
|
406 | if gp: | |
407 | gitpatches.append(gp) |
|
407 | gitpatches.append(gp) | |
408 |
|
408 | |||
409 | return gitpatches |
|
409 | return gitpatches | |
410 |
|
410 | |||
411 | class linereader(object): |
|
411 | class linereader(object): | |
412 | # simple class to allow pushing lines back into the input stream |
|
412 | # simple class to allow pushing lines back into the input stream | |
413 | def __init__(self, fp): |
|
413 | def __init__(self, fp): | |
414 | self.fp = fp |
|
414 | self.fp = fp | |
415 | self.buf = [] |
|
415 | self.buf = [] | |
416 |
|
416 | |||
417 | def push(self, line): |
|
417 | def push(self, line): | |
418 | if line is not None: |
|
418 | if line is not None: | |
419 | self.buf.append(line) |
|
419 | self.buf.append(line) | |
420 |
|
420 | |||
421 | def readline(self): |
|
421 | def readline(self): | |
422 | if self.buf: |
|
422 | if self.buf: | |
423 | l = self.buf[0] |
|
423 | l = self.buf[0] | |
424 | del self.buf[0] |
|
424 | del self.buf[0] | |
425 | return l |
|
425 | return l | |
426 | return self.fp.readline() |
|
426 | return self.fp.readline() | |
427 |
|
427 | |||
428 | def __iter__(self): |
|
428 | def __iter__(self): | |
429 | return iter(self.readline, '') |
|
429 | return iter(self.readline, '') | |
430 |
|
430 | |||
431 | class abstractbackend(object): |
|
431 | class abstractbackend(object): | |
432 | def __init__(self, ui): |
|
432 | def __init__(self, ui): | |
433 | self.ui = ui |
|
433 | self.ui = ui | |
434 |
|
434 | |||
435 | def getfile(self, fname): |
|
435 | def getfile(self, fname): | |
436 | """Return target file data and flags as a (data, (islink, |
|
436 | """Return target file data and flags as a (data, (islink, | |
437 | isexec)) tuple. Data is None if file is missing/deleted. |
|
437 | isexec)) tuple. Data is None if file is missing/deleted. | |
438 | """ |
|
438 | """ | |
439 | raise NotImplementedError |
|
439 | raise NotImplementedError | |
440 |
|
440 | |||
441 | def setfile(self, fname, data, mode, copysource): |
|
441 | def setfile(self, fname, data, mode, copysource): | |
442 | """Write data to target file fname and set its mode. mode is a |
|
442 | """Write data to target file fname and set its mode. mode is a | |
443 | (islink, isexec) tuple. If data is None, the file content should |
|
443 | (islink, isexec) tuple. If data is None, the file content should | |
444 | be left unchanged. If the file is modified after being copied, |
|
444 | be left unchanged. If the file is modified after being copied, | |
445 | copysource is set to the original file name. |
|
445 | copysource is set to the original file name. | |
446 | """ |
|
446 | """ | |
447 | raise NotImplementedError |
|
447 | raise NotImplementedError | |
448 |
|
448 | |||
449 | def unlink(self, fname): |
|
449 | def unlink(self, fname): | |
450 | """Unlink target file.""" |
|
450 | """Unlink target file.""" | |
451 | raise NotImplementedError |
|
451 | raise NotImplementedError | |
452 |
|
452 | |||
453 | def writerej(self, fname, failed, total, lines): |
|
453 | def writerej(self, fname, failed, total, lines): | |
454 | """Write rejected lines for fname. total is the number of hunks |
|
454 | """Write rejected lines for fname. total is the number of hunks | |
455 | which failed to apply and total the total number of hunks for this |
|
455 | which failed to apply and total the total number of hunks for this | |
456 | files. |
|
456 | files. | |
457 | """ |
|
457 | """ | |
458 |
|
458 | |||
459 | def exists(self, fname): |
|
459 | def exists(self, fname): | |
460 | raise NotImplementedError |
|
460 | raise NotImplementedError | |
461 |
|
461 | |||
462 | def close(self): |
|
462 | def close(self): | |
463 | raise NotImplementedError |
|
463 | raise NotImplementedError | |
464 |
|
464 | |||
465 | class fsbackend(abstractbackend): |
|
465 | class fsbackend(abstractbackend): | |
466 | def __init__(self, ui, basedir): |
|
466 | def __init__(self, ui, basedir): | |
467 | super(fsbackend, self).__init__(ui) |
|
467 | super(fsbackend, self).__init__(ui) | |
468 | self.opener = vfsmod.vfs(basedir) |
|
468 | self.opener = vfsmod.vfs(basedir) | |
469 |
|
469 | |||
470 | def getfile(self, fname): |
|
470 | def getfile(self, fname): | |
471 | if self.opener.islink(fname): |
|
471 | if self.opener.islink(fname): | |
472 | return (self.opener.readlink(fname), (True, False)) |
|
472 | return (self.opener.readlink(fname), (True, False)) | |
473 |
|
473 | |||
474 | isexec = False |
|
474 | isexec = False | |
475 | try: |
|
475 | try: | |
476 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 |
|
476 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 | |
477 | except OSError as e: |
|
477 | except OSError as e: | |
478 | if e.errno != errno.ENOENT: |
|
478 | if e.errno != errno.ENOENT: | |
479 | raise |
|
479 | raise | |
480 | try: |
|
480 | try: | |
481 | return (self.opener.read(fname), (False, isexec)) |
|
481 | return (self.opener.read(fname), (False, isexec)) | |
482 | except IOError as e: |
|
482 | except IOError as e: | |
483 | if e.errno != errno.ENOENT: |
|
483 | if e.errno != errno.ENOENT: | |
484 | raise |
|
484 | raise | |
485 | return None, None |
|
485 | return None, None | |
486 |
|
486 | |||
487 | def setfile(self, fname, data, mode, copysource): |
|
487 | def setfile(self, fname, data, mode, copysource): | |
488 | islink, isexec = mode |
|
488 | islink, isexec = mode | |
489 | if data is None: |
|
489 | if data is None: | |
490 | self.opener.setflags(fname, islink, isexec) |
|
490 | self.opener.setflags(fname, islink, isexec) | |
491 | return |
|
491 | return | |
492 | if islink: |
|
492 | if islink: | |
493 | self.opener.symlink(data, fname) |
|
493 | self.opener.symlink(data, fname) | |
494 | else: |
|
494 | else: | |
495 | self.opener.write(fname, data) |
|
495 | self.opener.write(fname, data) | |
496 | if isexec: |
|
496 | if isexec: | |
497 | self.opener.setflags(fname, False, True) |
|
497 | self.opener.setflags(fname, False, True) | |
498 |
|
498 | |||
499 | def unlink(self, fname): |
|
499 | def unlink(self, fname): | |
500 | rmdir = self.ui.configbool('experimental', 'removeemptydirs') |
|
500 | rmdir = self.ui.configbool('experimental', 'removeemptydirs') | |
501 | self.opener.unlinkpath(fname, ignoremissing=True, rmdir=rmdir) |
|
501 | self.opener.unlinkpath(fname, ignoremissing=True, rmdir=rmdir) | |
502 |
|
502 | |||
503 | def writerej(self, fname, failed, total, lines): |
|
503 | def writerej(self, fname, failed, total, lines): | |
504 | fname = fname + ".rej" |
|
504 | fname = fname + ".rej" | |
505 | self.ui.warn( |
|
505 | self.ui.warn( | |
506 | _("%d out of %d hunks FAILED -- saving rejects to file %s\n") % |
|
506 | _("%d out of %d hunks FAILED -- saving rejects to file %s\n") % | |
507 | (failed, total, fname)) |
|
507 | (failed, total, fname)) | |
508 | fp = self.opener(fname, 'w') |
|
508 | fp = self.opener(fname, 'w') | |
509 | fp.writelines(lines) |
|
509 | fp.writelines(lines) | |
510 | fp.close() |
|
510 | fp.close() | |
511 |
|
511 | |||
512 | def exists(self, fname): |
|
512 | def exists(self, fname): | |
513 | return self.opener.lexists(fname) |
|
513 | return self.opener.lexists(fname) | |
514 |
|
514 | |||
515 | class workingbackend(fsbackend): |
|
515 | class workingbackend(fsbackend): | |
516 | def __init__(self, ui, repo, similarity): |
|
516 | def __init__(self, ui, repo, similarity): | |
517 | super(workingbackend, self).__init__(ui, repo.root) |
|
517 | super(workingbackend, self).__init__(ui, repo.root) | |
518 | self.repo = repo |
|
518 | self.repo = repo | |
519 | self.similarity = similarity |
|
519 | self.similarity = similarity | |
520 | self.removed = set() |
|
520 | self.removed = set() | |
521 | self.changed = set() |
|
521 | self.changed = set() | |
522 | self.copied = [] |
|
522 | self.copied = [] | |
523 |
|
523 | |||
524 | def _checkknown(self, fname): |
|
524 | def _checkknown(self, fname): | |
525 | if self.repo.dirstate[fname] == '?' and self.exists(fname): |
|
525 | if self.repo.dirstate[fname] == '?' and self.exists(fname): | |
526 | raise PatchError(_('cannot patch %s: file is not tracked') % fname) |
|
526 | raise PatchError(_('cannot patch %s: file is not tracked') % fname) | |
527 |
|
527 | |||
528 | def setfile(self, fname, data, mode, copysource): |
|
528 | def setfile(self, fname, data, mode, copysource): | |
529 | self._checkknown(fname) |
|
529 | self._checkknown(fname) | |
530 | super(workingbackend, self).setfile(fname, data, mode, copysource) |
|
530 | super(workingbackend, self).setfile(fname, data, mode, copysource) | |
531 | if copysource is not None: |
|
531 | if copysource is not None: | |
532 | self.copied.append((copysource, fname)) |
|
532 | self.copied.append((copysource, fname)) | |
533 | self.changed.add(fname) |
|
533 | self.changed.add(fname) | |
534 |
|
534 | |||
535 | def unlink(self, fname): |
|
535 | def unlink(self, fname): | |
536 | self._checkknown(fname) |
|
536 | self._checkknown(fname) | |
537 | super(workingbackend, self).unlink(fname) |
|
537 | super(workingbackend, self).unlink(fname) | |
538 | self.removed.add(fname) |
|
538 | self.removed.add(fname) | |
539 | self.changed.add(fname) |
|
539 | self.changed.add(fname) | |
540 |
|
540 | |||
541 | def close(self): |
|
541 | def close(self): | |
542 | wctx = self.repo[None] |
|
542 | wctx = self.repo[None] | |
543 | changed = set(self.changed) |
|
543 | changed = set(self.changed) | |
544 | for src, dst in self.copied: |
|
544 | for src, dst in self.copied: | |
545 | scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst) |
|
545 | scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst) | |
546 | if self.removed: |
|
546 | if self.removed: | |
547 | wctx.forget(sorted(self.removed)) |
|
547 | wctx.forget(sorted(self.removed)) | |
548 | for f in self.removed: |
|
548 | for f in self.removed: | |
549 | if f not in self.repo.dirstate: |
|
549 | if f not in self.repo.dirstate: | |
550 | # File was deleted and no longer belongs to the |
|
550 | # File was deleted and no longer belongs to the | |
551 | # dirstate, it was probably marked added then |
|
551 | # dirstate, it was probably marked added then | |
552 | # deleted, and should not be considered by |
|
552 | # deleted, and should not be considered by | |
553 | # marktouched(). |
|
553 | # marktouched(). | |
554 | changed.discard(f) |
|
554 | changed.discard(f) | |
555 | if changed: |
|
555 | if changed: | |
556 | scmutil.marktouched(self.repo, changed, self.similarity) |
|
556 | scmutil.marktouched(self.repo, changed, self.similarity) | |
557 | return sorted(self.changed) |
|
557 | return sorted(self.changed) | |
558 |
|
558 | |||
559 | class filestore(object): |
|
559 | class filestore(object): | |
560 | def __init__(self, maxsize=None): |
|
560 | def __init__(self, maxsize=None): | |
561 | self.opener = None |
|
561 | self.opener = None | |
562 | self.files = {} |
|
562 | self.files = {} | |
563 | self.created = 0 |
|
563 | self.created = 0 | |
564 | self.maxsize = maxsize |
|
564 | self.maxsize = maxsize | |
565 | if self.maxsize is None: |
|
565 | if self.maxsize is None: | |
566 | self.maxsize = 4*(2**20) |
|
566 | self.maxsize = 4*(2**20) | |
567 | self.size = 0 |
|
567 | self.size = 0 | |
568 | self.data = {} |
|
568 | self.data = {} | |
569 |
|
569 | |||
570 | def setfile(self, fname, data, mode, copied=None): |
|
570 | def setfile(self, fname, data, mode, copied=None): | |
571 | if self.maxsize < 0 or (len(data) + self.size) <= self.maxsize: |
|
571 | if self.maxsize < 0 or (len(data) + self.size) <= self.maxsize: | |
572 | self.data[fname] = (data, mode, copied) |
|
572 | self.data[fname] = (data, mode, copied) | |
573 | self.size += len(data) |
|
573 | self.size += len(data) | |
574 | else: |
|
574 | else: | |
575 | if self.opener is None: |
|
575 | if self.opener is None: | |
576 | root = pycompat.mkdtemp(prefix='hg-patch-') |
|
576 | root = pycompat.mkdtemp(prefix='hg-patch-') | |
577 | self.opener = vfsmod.vfs(root) |
|
577 | self.opener = vfsmod.vfs(root) | |
578 | # Avoid filename issues with these simple names |
|
578 | # Avoid filename issues with these simple names | |
579 | fn = '%d' % self.created |
|
579 | fn = '%d' % self.created | |
580 | self.opener.write(fn, data) |
|
580 | self.opener.write(fn, data) | |
581 | self.created += 1 |
|
581 | self.created += 1 | |
582 | self.files[fname] = (fn, mode, copied) |
|
582 | self.files[fname] = (fn, mode, copied) | |
583 |
|
583 | |||
584 | def getfile(self, fname): |
|
584 | def getfile(self, fname): | |
585 | if fname in self.data: |
|
585 | if fname in self.data: | |
586 | return self.data[fname] |
|
586 | return self.data[fname] | |
587 | if not self.opener or fname not in self.files: |
|
587 | if not self.opener or fname not in self.files: | |
588 | return None, None, None |
|
588 | return None, None, None | |
589 | fn, mode, copied = self.files[fname] |
|
589 | fn, mode, copied = self.files[fname] | |
590 | return self.opener.read(fn), mode, copied |
|
590 | return self.opener.read(fn), mode, copied | |
591 |
|
591 | |||
592 | def close(self): |
|
592 | def close(self): | |
593 | if self.opener: |
|
593 | if self.opener: | |
594 | shutil.rmtree(self.opener.base) |
|
594 | shutil.rmtree(self.opener.base) | |
595 |
|
595 | |||
596 | class repobackend(abstractbackend): |
|
596 | class repobackend(abstractbackend): | |
597 | def __init__(self, ui, repo, ctx, store): |
|
597 | def __init__(self, ui, repo, ctx, store): | |
598 | super(repobackend, self).__init__(ui) |
|
598 | super(repobackend, self).__init__(ui) | |
599 | self.repo = repo |
|
599 | self.repo = repo | |
600 | self.ctx = ctx |
|
600 | self.ctx = ctx | |
601 | self.store = store |
|
601 | self.store = store | |
602 | self.changed = set() |
|
602 | self.changed = set() | |
603 | self.removed = set() |
|
603 | self.removed = set() | |
604 | self.copied = {} |
|
604 | self.copied = {} | |
605 |
|
605 | |||
606 | def _checkknown(self, fname): |
|
606 | def _checkknown(self, fname): | |
607 | if fname not in self.ctx: |
|
607 | if fname not in self.ctx: | |
608 | raise PatchError(_('cannot patch %s: file is not tracked') % fname) |
|
608 | raise PatchError(_('cannot patch %s: file is not tracked') % fname) | |
609 |
|
609 | |||
610 | def getfile(self, fname): |
|
610 | def getfile(self, fname): | |
611 | try: |
|
611 | try: | |
612 | fctx = self.ctx[fname] |
|
612 | fctx = self.ctx[fname] | |
613 | except error.LookupError: |
|
613 | except error.LookupError: | |
614 | return None, None |
|
614 | return None, None | |
615 | flags = fctx.flags() |
|
615 | flags = fctx.flags() | |
616 | return fctx.data(), ('l' in flags, 'x' in flags) |
|
616 | return fctx.data(), ('l' in flags, 'x' in flags) | |
617 |
|
617 | |||
618 | def setfile(self, fname, data, mode, copysource): |
|
618 | def setfile(self, fname, data, mode, copysource): | |
619 | if copysource: |
|
619 | if copysource: | |
620 | self._checkknown(copysource) |
|
620 | self._checkknown(copysource) | |
621 | if data is None: |
|
621 | if data is None: | |
622 | data = self.ctx[fname].data() |
|
622 | data = self.ctx[fname].data() | |
623 | self.store.setfile(fname, data, mode, copysource) |
|
623 | self.store.setfile(fname, data, mode, copysource) | |
624 | self.changed.add(fname) |
|
624 | self.changed.add(fname) | |
625 | if copysource: |
|
625 | if copysource: | |
626 | self.copied[fname] = copysource |
|
626 | self.copied[fname] = copysource | |
627 |
|
627 | |||
628 | def unlink(self, fname): |
|
628 | def unlink(self, fname): | |
629 | self._checkknown(fname) |
|
629 | self._checkknown(fname) | |
630 | self.removed.add(fname) |
|
630 | self.removed.add(fname) | |
631 |
|
631 | |||
632 | def exists(self, fname): |
|
632 | def exists(self, fname): | |
633 | return fname in self.ctx |
|
633 | return fname in self.ctx | |
634 |
|
634 | |||
635 | def close(self): |
|
635 | def close(self): | |
636 | return self.changed | self.removed |
|
636 | return self.changed | self.removed | |
637 |
|
637 | |||
638 | # @@ -start,len +start,len @@ or @@ -start +start @@ if len is 1 |
|
638 | # @@ -start,len +start,len @@ or @@ -start +start @@ if len is 1 | |
639 | unidesc = re.compile(br'@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@') |
|
639 | unidesc = re.compile(br'@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@') | |
640 | contextdesc = re.compile(br'(?:---|\*\*\*) (\d+)(?:,(\d+))? (?:---|\*\*\*)') |
|
640 | contextdesc = re.compile(br'(?:---|\*\*\*) (\d+)(?:,(\d+))? (?:---|\*\*\*)') | |
641 | eolmodes = ['strict', 'crlf', 'lf', 'auto'] |
|
641 | eolmodes = ['strict', 'crlf', 'lf', 'auto'] | |
642 |
|
642 | |||
643 | class patchfile(object): |
|
643 | class patchfile(object): | |
644 | def __init__(self, ui, gp, backend, store, eolmode='strict'): |
|
644 | def __init__(self, ui, gp, backend, store, eolmode='strict'): | |
645 | self.fname = gp.path |
|
645 | self.fname = gp.path | |
646 | self.eolmode = eolmode |
|
646 | self.eolmode = eolmode | |
647 | self.eol = None |
|
647 | self.eol = None | |
648 | self.backend = backend |
|
648 | self.backend = backend | |
649 | self.ui = ui |
|
649 | self.ui = ui | |
650 | self.lines = [] |
|
650 | self.lines = [] | |
651 | self.exists = False |
|
651 | self.exists = False | |
652 | self.missing = True |
|
652 | self.missing = True | |
653 | self.mode = gp.mode |
|
653 | self.mode = gp.mode | |
654 | self.copysource = gp.oldpath |
|
654 | self.copysource = gp.oldpath | |
655 | self.create = gp.op in ('ADD', 'COPY', 'RENAME') |
|
655 | self.create = gp.op in ('ADD', 'COPY', 'RENAME') | |
656 | self.remove = gp.op == 'DELETE' |
|
656 | self.remove = gp.op == 'DELETE' | |
657 | if self.copysource is None: |
|
657 | if self.copysource is None: | |
658 | data, mode = backend.getfile(self.fname) |
|
658 | data, mode = backend.getfile(self.fname) | |
659 | else: |
|
659 | else: | |
660 | data, mode = store.getfile(self.copysource)[:2] |
|
660 | data, mode = store.getfile(self.copysource)[:2] | |
661 | if data is not None: |
|
661 | if data is not None: | |
662 | self.exists = self.copysource is None or backend.exists(self.fname) |
|
662 | self.exists = self.copysource is None or backend.exists(self.fname) | |
663 | self.missing = False |
|
663 | self.missing = False | |
664 | if data: |
|
664 | if data: | |
665 | self.lines = mdiff.splitnewlines(data) |
|
665 | self.lines = mdiff.splitnewlines(data) | |
666 | if self.mode is None: |
|
666 | if self.mode is None: | |
667 | self.mode = mode |
|
667 | self.mode = mode | |
668 | if self.lines: |
|
668 | if self.lines: | |
669 | # Normalize line endings |
|
669 | # Normalize line endings | |
670 | if self.lines[0].endswith('\r\n'): |
|
670 | if self.lines[0].endswith('\r\n'): | |
671 | self.eol = '\r\n' |
|
671 | self.eol = '\r\n' | |
672 | elif self.lines[0].endswith('\n'): |
|
672 | elif self.lines[0].endswith('\n'): | |
673 | self.eol = '\n' |
|
673 | self.eol = '\n' | |
674 | if eolmode != 'strict': |
|
674 | if eolmode != 'strict': | |
675 | nlines = [] |
|
675 | nlines = [] | |
676 | for l in self.lines: |
|
676 | for l in self.lines: | |
677 | if l.endswith('\r\n'): |
|
677 | if l.endswith('\r\n'): | |
678 | l = l[:-2] + '\n' |
|
678 | l = l[:-2] + '\n' | |
679 | nlines.append(l) |
|
679 | nlines.append(l) | |
680 | self.lines = nlines |
|
680 | self.lines = nlines | |
681 | else: |
|
681 | else: | |
682 | if self.create: |
|
682 | if self.create: | |
683 | self.missing = False |
|
683 | self.missing = False | |
684 | if self.mode is None: |
|
684 | if self.mode is None: | |
685 | self.mode = (False, False) |
|
685 | self.mode = (False, False) | |
686 | if self.missing: |
|
686 | if self.missing: | |
687 | self.ui.warn(_("unable to find '%s' for patching\n") % self.fname) |
|
687 | self.ui.warn(_("unable to find '%s' for patching\n") % self.fname) | |
688 | self.ui.warn(_("(use '--prefix' to apply patch relative to the " |
|
688 | self.ui.warn(_("(use '--prefix' to apply patch relative to the " | |
689 | "current directory)\n")) |
|
689 | "current directory)\n")) | |
690 |
|
690 | |||
691 | self.hash = {} |
|
691 | self.hash = {} | |
692 | self.dirty = 0 |
|
692 | self.dirty = 0 | |
693 | self.offset = 0 |
|
693 | self.offset = 0 | |
694 | self.skew = 0 |
|
694 | self.skew = 0 | |
695 | self.rej = [] |
|
695 | self.rej = [] | |
696 | self.fileprinted = False |
|
696 | self.fileprinted = False | |
697 | self.printfile(False) |
|
697 | self.printfile(False) | |
698 | self.hunks = 0 |
|
698 | self.hunks = 0 | |
699 |
|
699 | |||
700 | def writelines(self, fname, lines, mode): |
|
700 | def writelines(self, fname, lines, mode): | |
701 | if self.eolmode == 'auto': |
|
701 | if self.eolmode == 'auto': | |
702 | eol = self.eol |
|
702 | eol = self.eol | |
703 | elif self.eolmode == 'crlf': |
|
703 | elif self.eolmode == 'crlf': | |
704 | eol = '\r\n' |
|
704 | eol = '\r\n' | |
705 | else: |
|
705 | else: | |
706 | eol = '\n' |
|
706 | eol = '\n' | |
707 |
|
707 | |||
708 | if self.eolmode != 'strict' and eol and eol != '\n': |
|
708 | if self.eolmode != 'strict' and eol and eol != '\n': | |
709 | rawlines = [] |
|
709 | rawlines = [] | |
710 | for l in lines: |
|
710 | for l in lines: | |
711 | if l and l.endswith('\n'): |
|
711 | if l and l.endswith('\n'): | |
712 | l = l[:-1] + eol |
|
712 | l = l[:-1] + eol | |
713 | rawlines.append(l) |
|
713 | rawlines.append(l) | |
714 | lines = rawlines |
|
714 | lines = rawlines | |
715 |
|
715 | |||
716 | self.backend.setfile(fname, ''.join(lines), mode, self.copysource) |
|
716 | self.backend.setfile(fname, ''.join(lines), mode, self.copysource) | |
717 |
|
717 | |||
718 | def printfile(self, warn): |
|
718 | def printfile(self, warn): | |
719 | if self.fileprinted: |
|
719 | if self.fileprinted: | |
720 | return |
|
720 | return | |
721 | if warn or self.ui.verbose: |
|
721 | if warn or self.ui.verbose: | |
722 | self.fileprinted = True |
|
722 | self.fileprinted = True | |
723 | s = _("patching file %s\n") % self.fname |
|
723 | s = _("patching file %s\n") % self.fname | |
724 | if warn: |
|
724 | if warn: | |
725 | self.ui.warn(s) |
|
725 | self.ui.warn(s) | |
726 | else: |
|
726 | else: | |
727 | self.ui.note(s) |
|
727 | self.ui.note(s) | |
728 |
|
728 | |||
729 |
|
729 | |||
730 | def findlines(self, l, linenum): |
|
730 | def findlines(self, l, linenum): | |
731 | # looks through the hash and finds candidate lines. The |
|
731 | # looks through the hash and finds candidate lines. The | |
732 | # result is a list of line numbers sorted based on distance |
|
732 | # result is a list of line numbers sorted based on distance | |
733 | # from linenum |
|
733 | # from linenum | |
734 |
|
734 | |||
735 | cand = self.hash.get(l, []) |
|
735 | cand = self.hash.get(l, []) | |
736 | if len(cand) > 1: |
|
736 | if len(cand) > 1: | |
737 | # resort our list of potentials forward then back. |
|
737 | # resort our list of potentials forward then back. | |
738 | cand.sort(key=lambda x: abs(x - linenum)) |
|
738 | cand.sort(key=lambda x: abs(x - linenum)) | |
739 | return cand |
|
739 | return cand | |
740 |
|
740 | |||
741 | def write_rej(self): |
|
741 | def write_rej(self): | |
742 | # our rejects are a little different from patch(1). This always |
|
742 | # our rejects are a little different from patch(1). This always | |
743 | # creates rejects in the same form as the original patch. A file |
|
743 | # creates rejects in the same form as the original patch. A file | |
744 | # header is inserted so that you can run the reject through patch again |
|
744 | # header is inserted so that you can run the reject through patch again | |
745 | # without having to type the filename. |
|
745 | # without having to type the filename. | |
746 | if not self.rej: |
|
746 | if not self.rej: | |
747 | return |
|
747 | return | |
748 | base = os.path.basename(self.fname) |
|
748 | base = os.path.basename(self.fname) | |
749 | lines = ["--- %s\n+++ %s\n" % (base, base)] |
|
749 | lines = ["--- %s\n+++ %s\n" % (base, base)] | |
750 | for x in self.rej: |
|
750 | for x in self.rej: | |
751 | for l in x.hunk: |
|
751 | for l in x.hunk: | |
752 | lines.append(l) |
|
752 | lines.append(l) | |
753 | if l[-1:] != '\n': |
|
753 | if l[-1:] != '\n': | |
754 | lines.append("\n\\ No newline at end of file\n") |
|
754 | lines.append("\n\\ No newline at end of file\n") | |
755 | self.backend.writerej(self.fname, len(self.rej), self.hunks, lines) |
|
755 | self.backend.writerej(self.fname, len(self.rej), self.hunks, lines) | |
756 |
|
756 | |||
757 | def apply(self, h): |
|
757 | def apply(self, h): | |
758 | if not h.complete(): |
|
758 | if not h.complete(): | |
759 | raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") % |
|
759 | raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") % | |
760 | (h.number, h.desc, len(h.a), h.lena, len(h.b), |
|
760 | (h.number, h.desc, len(h.a), h.lena, len(h.b), | |
761 | h.lenb)) |
|
761 | h.lenb)) | |
762 |
|
762 | |||
763 | self.hunks += 1 |
|
763 | self.hunks += 1 | |
764 |
|
764 | |||
765 | if self.missing: |
|
765 | if self.missing: | |
766 | self.rej.append(h) |
|
766 | self.rej.append(h) | |
767 | return -1 |
|
767 | return -1 | |
768 |
|
768 | |||
769 | if self.exists and self.create: |
|
769 | if self.exists and self.create: | |
770 | if self.copysource: |
|
770 | if self.copysource: | |
771 | self.ui.warn(_("cannot create %s: destination already " |
|
771 | self.ui.warn(_("cannot create %s: destination already " | |
772 | "exists\n") % self.fname) |
|
772 | "exists\n") % self.fname) | |
773 | else: |
|
773 | else: | |
774 | self.ui.warn(_("file %s already exists\n") % self.fname) |
|
774 | self.ui.warn(_("file %s already exists\n") % self.fname) | |
775 | self.rej.append(h) |
|
775 | self.rej.append(h) | |
776 | return -1 |
|
776 | return -1 | |
777 |
|
777 | |||
778 | if isinstance(h, binhunk): |
|
778 | if isinstance(h, binhunk): | |
779 | if self.remove: |
|
779 | if self.remove: | |
780 | self.backend.unlink(self.fname) |
|
780 | self.backend.unlink(self.fname) | |
781 | else: |
|
781 | else: | |
782 | l = h.new(self.lines) |
|
782 | l = h.new(self.lines) | |
783 | self.lines[:] = l |
|
783 | self.lines[:] = l | |
784 | self.offset += len(l) |
|
784 | self.offset += len(l) | |
785 | self.dirty = True |
|
785 | self.dirty = True | |
786 | return 0 |
|
786 | return 0 | |
787 |
|
787 | |||
788 | horig = h |
|
788 | horig = h | |
789 | if (self.eolmode in ('crlf', 'lf') |
|
789 | if (self.eolmode in ('crlf', 'lf') | |
790 | or self.eolmode == 'auto' and self.eol): |
|
790 | or self.eolmode == 'auto' and self.eol): | |
791 | # If new eols are going to be normalized, then normalize |
|
791 | # If new eols are going to be normalized, then normalize | |
792 | # hunk data before patching. Otherwise, preserve input |
|
792 | # hunk data before patching. Otherwise, preserve input | |
793 | # line-endings. |
|
793 | # line-endings. | |
794 | h = h.getnormalized() |
|
794 | h = h.getnormalized() | |
795 |
|
795 | |||
796 | # fast case first, no offsets, no fuzz |
|
796 | # fast case first, no offsets, no fuzz | |
797 | old, oldstart, new, newstart = h.fuzzit(0, False) |
|
797 | old, oldstart, new, newstart = h.fuzzit(0, False) | |
798 | oldstart += self.offset |
|
798 | oldstart += self.offset | |
799 | orig_start = oldstart |
|
799 | orig_start = oldstart | |
800 | # if there's skew we want to emit the "(offset %d lines)" even |
|
800 | # if there's skew we want to emit the "(offset %d lines)" even | |
801 | # when the hunk cleanly applies at start + skew, so skip the |
|
801 | # when the hunk cleanly applies at start + skew, so skip the | |
802 | # fast case code |
|
802 | # fast case code | |
803 | if self.skew == 0 and diffhelper.testhunk(old, self.lines, oldstart): |
|
803 | if self.skew == 0 and diffhelper.testhunk(old, self.lines, oldstart): | |
804 | if self.remove: |
|
804 | if self.remove: | |
805 | self.backend.unlink(self.fname) |
|
805 | self.backend.unlink(self.fname) | |
806 | else: |
|
806 | else: | |
807 | self.lines[oldstart:oldstart + len(old)] = new |
|
807 | self.lines[oldstart:oldstart + len(old)] = new | |
808 | self.offset += len(new) - len(old) |
|
808 | self.offset += len(new) - len(old) | |
809 | self.dirty = True |
|
809 | self.dirty = True | |
810 | return 0 |
|
810 | return 0 | |
811 |
|
811 | |||
812 | # ok, we couldn't match the hunk. Lets look for offsets and fuzz it |
|
812 | # ok, we couldn't match the hunk. Lets look for offsets and fuzz it | |
813 | self.hash = {} |
|
813 | self.hash = {} | |
814 | for x, s in enumerate(self.lines): |
|
814 | for x, s in enumerate(self.lines): | |
815 | self.hash.setdefault(s, []).append(x) |
|
815 | self.hash.setdefault(s, []).append(x) | |
816 |
|
816 | |||
817 | for fuzzlen in pycompat.xrange(self.ui.configint("patch", "fuzz") + 1): |
|
817 | for fuzzlen in pycompat.xrange(self.ui.configint("patch", "fuzz") + 1): | |
818 | for toponly in [True, False]: |
|
818 | for toponly in [True, False]: | |
819 | old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) |
|
819 | old, oldstart, new, newstart = h.fuzzit(fuzzlen, toponly) | |
820 | oldstart = oldstart + self.offset + self.skew |
|
820 | oldstart = oldstart + self.offset + self.skew | |
821 | oldstart = min(oldstart, len(self.lines)) |
|
821 | oldstart = min(oldstart, len(self.lines)) | |
822 | if old: |
|
822 | if old: | |
823 | cand = self.findlines(old[0][1:], oldstart) |
|
823 | cand = self.findlines(old[0][1:], oldstart) | |
824 | else: |
|
824 | else: | |
825 | # Only adding lines with no or fuzzed context, just |
|
825 | # Only adding lines with no or fuzzed context, just | |
826 | # take the skew in account |
|
826 | # take the skew in account | |
827 | cand = [oldstart] |
|
827 | cand = [oldstart] | |
828 |
|
828 | |||
829 | for l in cand: |
|
829 | for l in cand: | |
830 | if not old or diffhelper.testhunk(old, self.lines, l): |
|
830 | if not old or diffhelper.testhunk(old, self.lines, l): | |
831 | self.lines[l : l + len(old)] = new |
|
831 | self.lines[l : l + len(old)] = new | |
832 | self.offset += len(new) - len(old) |
|
832 | self.offset += len(new) - len(old) | |
833 | self.skew = l - orig_start |
|
833 | self.skew = l - orig_start | |
834 | self.dirty = True |
|
834 | self.dirty = True | |
835 | offset = l - orig_start - fuzzlen |
|
835 | offset = l - orig_start - fuzzlen | |
836 | if fuzzlen: |
|
836 | if fuzzlen: | |
837 | msg = _("Hunk #%d succeeded at %d " |
|
837 | msg = _("Hunk #%d succeeded at %d " | |
838 | "with fuzz %d " |
|
838 | "with fuzz %d " | |
839 | "(offset %d lines).\n") |
|
839 | "(offset %d lines).\n") | |
840 | self.printfile(True) |
|
840 | self.printfile(True) | |
841 | self.ui.warn(msg % |
|
841 | self.ui.warn(msg % | |
842 | (h.number, l + 1, fuzzlen, offset)) |
|
842 | (h.number, l + 1, fuzzlen, offset)) | |
843 | else: |
|
843 | else: | |
844 | msg = _("Hunk #%d succeeded at %d " |
|
844 | msg = _("Hunk #%d succeeded at %d " | |
845 | "(offset %d lines).\n") |
|
845 | "(offset %d lines).\n") | |
846 | self.ui.note(msg % (h.number, l + 1, offset)) |
|
846 | self.ui.note(msg % (h.number, l + 1, offset)) | |
847 | return fuzzlen |
|
847 | return fuzzlen | |
848 | self.printfile(True) |
|
848 | self.printfile(True) | |
849 | self.ui.warn(_("Hunk #%d FAILED at %d\n") % (h.number, orig_start)) |
|
849 | self.ui.warn(_("Hunk #%d FAILED at %d\n") % (h.number, orig_start)) | |
850 | self.rej.append(horig) |
|
850 | self.rej.append(horig) | |
851 | return -1 |
|
851 | return -1 | |
852 |
|
852 | |||
853 | def close(self): |
|
853 | def close(self): | |
854 | if self.dirty: |
|
854 | if self.dirty: | |
855 | self.writelines(self.fname, self.lines, self.mode) |
|
855 | self.writelines(self.fname, self.lines, self.mode) | |
856 | self.write_rej() |
|
856 | self.write_rej() | |
857 | return len(self.rej) |
|
857 | return len(self.rej) | |
858 |
|
858 | |||
859 | class header(object): |
|
859 | class header(object): | |
860 | """patch header |
|
860 | """patch header | |
861 | """ |
|
861 | """ | |
862 | diffgit_re = re.compile('diff --git a/(.*) b/(.*)$') |
|
862 | diffgit_re = re.compile('diff --git a/(.*) b/(.*)$') | |
863 | diff_re = re.compile('diff -r .* (.*)$') |
|
863 | diff_re = re.compile('diff -r .* (.*)$') | |
864 | allhunks_re = re.compile('(?:index|deleted file) ') |
|
864 | allhunks_re = re.compile('(?:index|deleted file) ') | |
865 | pretty_re = re.compile('(?:new file|deleted file) ') |
|
865 | pretty_re = re.compile('(?:new file|deleted file) ') | |
866 | special_re = re.compile('(?:index|deleted|copy|rename) ') |
|
866 | special_re = re.compile('(?:index|deleted|copy|rename) ') | |
867 | newfile_re = re.compile('(?:new file)') |
|
867 | newfile_re = re.compile('(?:new file)') | |
868 |
|
868 | |||
869 | def __init__(self, header): |
|
869 | def __init__(self, header): | |
870 | self.header = header |
|
870 | self.header = header | |
871 | self.hunks = [] |
|
871 | self.hunks = [] | |
872 |
|
872 | |||
873 | def binary(self): |
|
873 | def binary(self): | |
874 | return any(h.startswith('index ') for h in self.header) |
|
874 | return any(h.startswith('index ') for h in self.header) | |
875 |
|
875 | |||
876 | def pretty(self, fp): |
|
876 | def pretty(self, fp): | |
877 | for h in self.header: |
|
877 | for h in self.header: | |
878 | if h.startswith('index '): |
|
878 | if h.startswith('index '): | |
879 | fp.write(_('this modifies a binary file (all or nothing)\n')) |
|
879 | fp.write(_('this modifies a binary file (all or nothing)\n')) | |
880 | break |
|
880 | break | |
881 | if self.pretty_re.match(h): |
|
881 | if self.pretty_re.match(h): | |
882 | fp.write(h) |
|
882 | fp.write(h) | |
883 | if self.binary(): |
|
883 | if self.binary(): | |
884 | fp.write(_('this is a binary file\n')) |
|
884 | fp.write(_('this is a binary file\n')) | |
885 | break |
|
885 | break | |
886 | if h.startswith('---'): |
|
886 | if h.startswith('---'): | |
887 | fp.write(_('%d hunks, %d lines changed\n') % |
|
887 | fp.write(_('%d hunks, %d lines changed\n') % | |
888 | (len(self.hunks), |
|
888 | (len(self.hunks), | |
889 | sum([max(h.added, h.removed) for h in self.hunks]))) |
|
889 | sum([max(h.added, h.removed) for h in self.hunks]))) | |
890 | break |
|
890 | break | |
891 | fp.write(h) |
|
891 | fp.write(h) | |
892 |
|
892 | |||
893 | def write(self, fp): |
|
893 | def write(self, fp): | |
894 | fp.write(''.join(self.header)) |
|
894 | fp.write(''.join(self.header)) | |
895 |
|
895 | |||
896 | def allhunks(self): |
|
896 | def allhunks(self): | |
897 | return any(self.allhunks_re.match(h) for h in self.header) |
|
897 | return any(self.allhunks_re.match(h) for h in self.header) | |
898 |
|
898 | |||
899 | def files(self): |
|
899 | def files(self): | |
900 | match = self.diffgit_re.match(self.header[0]) |
|
900 | match = self.diffgit_re.match(self.header[0]) | |
901 | if match: |
|
901 | if match: | |
902 | fromfile, tofile = match.groups() |
|
902 | fromfile, tofile = match.groups() | |
903 | if fromfile == tofile: |
|
903 | if fromfile == tofile: | |
904 | return [fromfile] |
|
904 | return [fromfile] | |
905 | return [fromfile, tofile] |
|
905 | return [fromfile, tofile] | |
906 | else: |
|
906 | else: | |
907 | return self.diff_re.match(self.header[0]).groups() |
|
907 | return self.diff_re.match(self.header[0]).groups() | |
908 |
|
908 | |||
909 | def filename(self): |
|
909 | def filename(self): | |
910 | return self.files()[-1] |
|
910 | return self.files()[-1] | |
911 |
|
911 | |||
912 | def __repr__(self): |
|
912 | def __repr__(self): | |
913 | return '<header %s>' % (' '.join(map(repr, self.files()))) |
|
913 | return '<header %s>' % (' '.join(map(repr, self.files()))) | |
914 |
|
914 | |||
915 | def isnewfile(self): |
|
915 | def isnewfile(self): | |
916 | return any(self.newfile_re.match(h) for h in self.header) |
|
916 | return any(self.newfile_re.match(h) for h in self.header) | |
917 |
|
917 | |||
918 | def special(self): |
|
918 | def special(self): | |
919 | # Special files are shown only at the header level and not at the hunk |
|
919 | # Special files are shown only at the header level and not at the hunk | |
920 | # level for example a file that has been deleted is a special file. |
|
920 | # level for example a file that has been deleted is a special file. | |
921 | # The user cannot change the content of the operation, in the case of |
|
921 | # The user cannot change the content of the operation, in the case of | |
922 | # the deleted file he has to take the deletion or not take it, he |
|
922 | # the deleted file he has to take the deletion or not take it, he | |
923 | # cannot take some of it. |
|
923 | # cannot take some of it. | |
924 | # Newly added files are special if they are empty, they are not special |
|
924 | # Newly added files are special if they are empty, they are not special | |
925 | # if they have some content as we want to be able to change it |
|
925 | # if they have some content as we want to be able to change it | |
926 | nocontent = len(self.header) == 2 |
|
926 | nocontent = len(self.header) == 2 | |
927 | emptynewfile = self.isnewfile() and nocontent |
|
927 | emptynewfile = self.isnewfile() and nocontent | |
928 | return (emptynewfile |
|
928 | return (emptynewfile | |
929 | or any(self.special_re.match(h) for h in self.header)) |
|
929 | or any(self.special_re.match(h) for h in self.header)) | |
930 |
|
930 | |||
931 | class recordhunk(object): |
|
931 | class recordhunk(object): | |
932 | """patch hunk |
|
932 | """patch hunk | |
933 |
|
933 | |||
934 | XXX shouldn't we merge this with the other hunk class? |
|
934 | XXX shouldn't we merge this with the other hunk class? | |
935 | """ |
|
935 | """ | |
936 |
|
936 | |||
937 | def __init__(self, header, fromline, toline, proc, before, hunk, after, |
|
937 | def __init__(self, header, fromline, toline, proc, before, hunk, after, | |
938 | maxcontext=None): |
|
938 | maxcontext=None): | |
939 | def trimcontext(lines, reverse=False): |
|
939 | def trimcontext(lines, reverse=False): | |
940 | if maxcontext is not None: |
|
940 | if maxcontext is not None: | |
941 | delta = len(lines) - maxcontext |
|
941 | delta = len(lines) - maxcontext | |
942 | if delta > 0: |
|
942 | if delta > 0: | |
943 | if reverse: |
|
943 | if reverse: | |
944 | return delta, lines[delta:] |
|
944 | return delta, lines[delta:] | |
945 | else: |
|
945 | else: | |
946 | return delta, lines[:maxcontext] |
|
946 | return delta, lines[:maxcontext] | |
947 | return 0, lines |
|
947 | return 0, lines | |
948 |
|
948 | |||
949 | self.header = header |
|
949 | self.header = header | |
950 | trimedbefore, self.before = trimcontext(before, True) |
|
950 | trimedbefore, self.before = trimcontext(before, True) | |
951 | self.fromline = fromline + trimedbefore |
|
951 | self.fromline = fromline + trimedbefore | |
952 | self.toline = toline + trimedbefore |
|
952 | self.toline = toline + trimedbefore | |
953 | _trimedafter, self.after = trimcontext(after, False) |
|
953 | _trimedafter, self.after = trimcontext(after, False) | |
954 | self.proc = proc |
|
954 | self.proc = proc | |
955 | self.hunk = hunk |
|
955 | self.hunk = hunk | |
956 | self.added, self.removed = self.countchanges(self.hunk) |
|
956 | self.added, self.removed = self.countchanges(self.hunk) | |
957 |
|
957 | |||
958 | def __eq__(self, v): |
|
958 | def __eq__(self, v): | |
959 | if not isinstance(v, recordhunk): |
|
959 | if not isinstance(v, recordhunk): | |
960 | return False |
|
960 | return False | |
961 |
|
961 | |||
962 | return ((v.hunk == self.hunk) and |
|
962 | return ((v.hunk == self.hunk) and | |
963 | (v.proc == self.proc) and |
|
963 | (v.proc == self.proc) and | |
964 | (self.fromline == v.fromline) and |
|
964 | (self.fromline == v.fromline) and | |
965 | (self.header.files() == v.header.files())) |
|
965 | (self.header.files() == v.header.files())) | |
966 |
|
966 | |||
967 | def __hash__(self): |
|
967 | def __hash__(self): | |
968 | return hash((tuple(self.hunk), |
|
968 | return hash((tuple(self.hunk), | |
969 | tuple(self.header.files()), |
|
969 | tuple(self.header.files()), | |
970 | self.fromline, |
|
970 | self.fromline, | |
971 | self.proc)) |
|
971 | self.proc)) | |
972 |
|
972 | |||
973 | def countchanges(self, hunk): |
|
973 | def countchanges(self, hunk): | |
974 | """hunk -> (n+,n-)""" |
|
974 | """hunk -> (n+,n-)""" | |
975 | add = len([h for h in hunk if h.startswith('+')]) |
|
975 | add = len([h for h in hunk if h.startswith('+')]) | |
976 | rem = len([h for h in hunk if h.startswith('-')]) |
|
976 | rem = len([h for h in hunk if h.startswith('-')]) | |
977 | return add, rem |
|
977 | return add, rem | |
978 |
|
978 | |||
979 | def reversehunk(self): |
|
979 | def reversehunk(self): | |
980 | """return another recordhunk which is the reverse of the hunk |
|
980 | """return another recordhunk which is the reverse of the hunk | |
981 |
|
981 | |||
982 | If this hunk is diff(A, B), the returned hunk is diff(B, A). To do |
|
982 | If this hunk is diff(A, B), the returned hunk is diff(B, A). To do | |
983 | that, swap fromline/toline and +/- signs while keep other things |
|
983 | that, swap fromline/toline and +/- signs while keep other things | |
984 | unchanged. |
|
984 | unchanged. | |
985 | """ |
|
985 | """ | |
986 | m = {'+': '-', '-': '+', '\\': '\\'} |
|
986 | m = {'+': '-', '-': '+', '\\': '\\'} | |
987 | hunk = ['%s%s' % (m[l[0:1]], l[1:]) for l in self.hunk] |
|
987 | hunk = ['%s%s' % (m[l[0:1]], l[1:]) for l in self.hunk] | |
988 | return recordhunk(self.header, self.toline, self.fromline, self.proc, |
|
988 | return recordhunk(self.header, self.toline, self.fromline, self.proc, | |
989 | self.before, hunk, self.after) |
|
989 | self.before, hunk, self.after) | |
990 |
|
990 | |||
991 | def write(self, fp): |
|
991 | def write(self, fp): | |
992 | delta = len(self.before) + len(self.after) |
|
992 | delta = len(self.before) + len(self.after) | |
993 | if self.after and self.after[-1] == '\\ No newline at end of file\n': |
|
993 | if self.after and self.after[-1] == '\\ No newline at end of file\n': | |
994 | delta -= 1 |
|
994 | delta -= 1 | |
995 | fromlen = delta + self.removed |
|
995 | fromlen = delta + self.removed | |
996 | tolen = delta + self.added |
|
996 | tolen = delta + self.added | |
997 | fp.write('@@ -%d,%d +%d,%d @@%s\n' % |
|
997 | fp.write('@@ -%d,%d +%d,%d @@%s\n' % | |
998 | (self.fromline, fromlen, self.toline, tolen, |
|
998 | (self.fromline, fromlen, self.toline, tolen, | |
999 | self.proc and (' ' + self.proc))) |
|
999 | self.proc and (' ' + self.proc))) | |
1000 | fp.write(''.join(self.before + self.hunk + self.after)) |
|
1000 | fp.write(''.join(self.before + self.hunk + self.after)) | |
1001 |
|
1001 | |||
1002 | pretty = write |
|
1002 | pretty = write | |
1003 |
|
1003 | |||
1004 | def filename(self): |
|
1004 | def filename(self): | |
1005 | return self.header.filename() |
|
1005 | return self.header.filename() | |
1006 |
|
1006 | |||
1007 | def __repr__(self): |
|
1007 | def __repr__(self): | |
1008 | return '<hunk %r@%d>' % (self.filename(), self.fromline) |
|
1008 | return '<hunk %r@%d>' % (self.filename(), self.fromline) | |
1009 |
|
1009 | |||
1010 | def getmessages(): |
|
1010 | def getmessages(): | |
1011 | return { |
|
1011 | return { | |
1012 | 'multiple': { |
|
1012 | 'multiple': { | |
1013 | 'apply': _("apply change %d/%d to '%s'?"), |
|
1013 | 'apply': _("apply change %d/%d to '%s'?"), | |
1014 | 'discard': _("discard change %d/%d to '%s'?"), |
|
1014 | 'discard': _("discard change %d/%d to '%s'?"), | |
1015 | 'record': _("record change %d/%d to '%s'?"), |
|
1015 | 'record': _("record change %d/%d to '%s'?"), | |
1016 | }, |
|
1016 | }, | |
1017 | 'single': { |
|
1017 | 'single': { | |
1018 | 'apply': _("apply this change to '%s'?"), |
|
1018 | 'apply': _("apply this change to '%s'?"), | |
1019 | 'discard': _("discard this change to '%s'?"), |
|
1019 | 'discard': _("discard this change to '%s'?"), | |
1020 | 'record': _("record this change to '%s'?"), |
|
1020 | 'record': _("record this change to '%s'?"), | |
1021 | }, |
|
1021 | }, | |
1022 | 'help': { |
|
1022 | 'help': { | |
1023 | 'apply': _('[Ynesfdaq?]' |
|
1023 | 'apply': _('[Ynesfdaq?]' | |
1024 | '$$ &Yes, apply this change' |
|
1024 | '$$ &Yes, apply this change' | |
1025 | '$$ &No, skip this change' |
|
1025 | '$$ &No, skip this change' | |
1026 | '$$ &Edit this change manually' |
|
1026 | '$$ &Edit this change manually' | |
1027 | '$$ &Skip remaining changes to this file' |
|
1027 | '$$ &Skip remaining changes to this file' | |
1028 | '$$ Apply remaining changes to this &file' |
|
1028 | '$$ Apply remaining changes to this &file' | |
1029 | '$$ &Done, skip remaining changes and files' |
|
1029 | '$$ &Done, skip remaining changes and files' | |
1030 | '$$ Apply &all changes to all remaining files' |
|
1030 | '$$ Apply &all changes to all remaining files' | |
1031 | '$$ &Quit, applying no changes' |
|
1031 | '$$ &Quit, applying no changes' | |
1032 | '$$ &? (display help)'), |
|
1032 | '$$ &? (display help)'), | |
1033 | 'discard': _('[Ynesfdaq?]' |
|
1033 | 'discard': _('[Ynesfdaq?]' | |
1034 | '$$ &Yes, discard this change' |
|
1034 | '$$ &Yes, discard this change' | |
1035 | '$$ &No, skip this change' |
|
1035 | '$$ &No, skip this change' | |
1036 | '$$ &Edit this change manually' |
|
1036 | '$$ &Edit this change manually' | |
1037 | '$$ &Skip remaining changes to this file' |
|
1037 | '$$ &Skip remaining changes to this file' | |
1038 | '$$ Discard remaining changes to this &file' |
|
1038 | '$$ Discard remaining changes to this &file' | |
1039 | '$$ &Done, skip remaining changes and files' |
|
1039 | '$$ &Done, skip remaining changes and files' | |
1040 | '$$ Discard &all changes to all remaining files' |
|
1040 | '$$ Discard &all changes to all remaining files' | |
1041 | '$$ &Quit, discarding no changes' |
|
1041 | '$$ &Quit, discarding no changes' | |
1042 | '$$ &? (display help)'), |
|
1042 | '$$ &? (display help)'), | |
1043 | 'record': _('[Ynesfdaq?]' |
|
1043 | 'record': _('[Ynesfdaq?]' | |
1044 | '$$ &Yes, record this change' |
|
1044 | '$$ &Yes, record this change' | |
1045 | '$$ &No, skip this change' |
|
1045 | '$$ &No, skip this change' | |
1046 | '$$ &Edit this change manually' |
|
1046 | '$$ &Edit this change manually' | |
1047 | '$$ &Skip remaining changes to this file' |
|
1047 | '$$ &Skip remaining changes to this file' | |
1048 | '$$ Record remaining changes to this &file' |
|
1048 | '$$ Record remaining changes to this &file' | |
1049 | '$$ &Done, skip remaining changes and files' |
|
1049 | '$$ &Done, skip remaining changes and files' | |
1050 | '$$ Record &all changes to all remaining files' |
|
1050 | '$$ Record &all changes to all remaining files' | |
1051 | '$$ &Quit, recording no changes' |
|
1051 | '$$ &Quit, recording no changes' | |
1052 | '$$ &? (display help)'), |
|
1052 | '$$ &? (display help)'), | |
1053 | } |
|
1053 | } | |
1054 | } |
|
1054 | } | |
1055 |
|
1055 | |||
1056 | def filterpatch(ui, headers, operation=None): |
|
1056 | def filterpatch(ui, headers, operation=None): | |
1057 | """Interactively filter patch chunks into applied-only chunks""" |
|
1057 | """Interactively filter patch chunks into applied-only chunks""" | |
1058 | messages = getmessages() |
|
1058 | messages = getmessages() | |
1059 |
|
1059 | |||
1060 | if operation is None: |
|
1060 | if operation is None: | |
1061 | operation = 'record' |
|
1061 | operation = 'record' | |
1062 |
|
1062 | |||
1063 | def prompt(skipfile, skipall, query, chunk): |
|
1063 | def prompt(skipfile, skipall, query, chunk): | |
1064 | """prompt query, and process base inputs |
|
1064 | """prompt query, and process base inputs | |
1065 |
|
1065 | |||
1066 | - y/n for the rest of file |
|
1066 | - y/n for the rest of file | |
1067 | - y/n for the rest |
|
1067 | - y/n for the rest | |
1068 | - ? (help) |
|
1068 | - ? (help) | |
1069 | - q (quit) |
|
1069 | - q (quit) | |
1070 |
|
1070 | |||
1071 | Return True/False and possibly updated skipfile and skipall. |
|
1071 | Return True/False and possibly updated skipfile and skipall. | |
1072 | """ |
|
1072 | """ | |
1073 | newpatches = None |
|
1073 | newpatches = None | |
1074 | if skipall is not None: |
|
1074 | if skipall is not None: | |
1075 | return skipall, skipfile, skipall, newpatches |
|
1075 | return skipall, skipfile, skipall, newpatches | |
1076 | if skipfile is not None: |
|
1076 | if skipfile is not None: | |
1077 | return skipfile, skipfile, skipall, newpatches |
|
1077 | return skipfile, skipfile, skipall, newpatches | |
1078 | while True: |
|
1078 | while True: | |
1079 | resps = messages['help'][operation] |
|
1079 | resps = messages['help'][operation] | |
1080 | r = ui.promptchoice("%s %s" % (query, resps)) |
|
1080 | r = ui.promptchoice("%s %s" % (query, resps)) | |
1081 | ui.write("\n") |
|
1081 | ui.write("\n") | |
1082 | if r == 8: # ? |
|
1082 | if r == 8: # ? | |
1083 | for c, t in ui.extractchoices(resps)[1]: |
|
1083 | for c, t in ui.extractchoices(resps)[1]: | |
1084 | ui.write('%s - %s\n' % (c, encoding.lower(t))) |
|
1084 | ui.write('%s - %s\n' % (c, encoding.lower(t))) | |
1085 | continue |
|
1085 | continue | |
1086 | elif r == 0: # yes |
|
1086 | elif r == 0: # yes | |
1087 | ret = True |
|
1087 | ret = True | |
1088 | elif r == 1: # no |
|
1088 | elif r == 1: # no | |
1089 | ret = False |
|
1089 | ret = False | |
1090 | elif r == 2: # Edit patch |
|
1090 | elif r == 2: # Edit patch | |
1091 | if chunk is None: |
|
1091 | if chunk is None: | |
1092 | ui.write(_('cannot edit patch for whole file')) |
|
1092 | ui.write(_('cannot edit patch for whole file')) | |
1093 | ui.write("\n") |
|
1093 | ui.write("\n") | |
1094 | continue |
|
1094 | continue | |
1095 | if chunk.header.binary(): |
|
1095 | if chunk.header.binary(): | |
1096 | ui.write(_('cannot edit patch for binary file')) |
|
1096 | ui.write(_('cannot edit patch for binary file')) | |
1097 | ui.write("\n") |
|
1097 | ui.write("\n") | |
1098 | continue |
|
1098 | continue | |
1099 | # Patch comment based on the Git one (based on comment at end of |
|
1099 | # Patch comment based on the Git one (based on comment at end of | |
1100 | # https://mercurial-scm.org/wiki/RecordExtension) |
|
1100 | # https://mercurial-scm.org/wiki/RecordExtension) | |
1101 | phelp = '---' + _(""" |
|
1101 | phelp = '---' + _(""" | |
1102 | To remove '-' lines, make them ' ' lines (context). |
|
1102 | To remove '-' lines, make them ' ' lines (context). | |
1103 | To remove '+' lines, delete them. |
|
1103 | To remove '+' lines, delete them. | |
1104 | Lines starting with # will be removed from the patch. |
|
1104 | Lines starting with # will be removed from the patch. | |
1105 |
|
1105 | |||
1106 | If the patch applies cleanly, the edited hunk will immediately be |
|
1106 | If the patch applies cleanly, the edited hunk will immediately be | |
1107 | added to the record list. If it does not apply cleanly, a rejects |
|
1107 | added to the record list. If it does not apply cleanly, a rejects | |
1108 | file will be generated: you can use that when you try again. If |
|
1108 | file will be generated: you can use that when you try again. If | |
1109 | all lines of the hunk are removed, then the edit is aborted and |
|
1109 | all lines of the hunk are removed, then the edit is aborted and | |
1110 | the hunk is left unchanged. |
|
1110 | the hunk is left unchanged. | |
1111 | """) |
|
1111 | """) | |
1112 | (patchfd, patchfn) = pycompat.mkstemp(prefix="hg-editor-", |
|
1112 | (patchfd, patchfn) = pycompat.mkstemp(prefix="hg-editor-", | |
1113 | suffix=".diff") |
|
1113 | suffix=".diff") | |
1114 | ncpatchfp = None |
|
1114 | ncpatchfp = None | |
1115 | try: |
|
1115 | try: | |
1116 | # Write the initial patch |
|
1116 | # Write the initial patch | |
1117 | f = util.nativeeolwriter(os.fdopen(patchfd, r'wb')) |
|
1117 | f = util.nativeeolwriter(os.fdopen(patchfd, r'wb')) | |
1118 | chunk.header.write(f) |
|
1118 | chunk.header.write(f) | |
1119 | chunk.write(f) |
|
1119 | chunk.write(f) | |
1120 | f.write('\n'.join(['# ' + i for i in phelp.splitlines()])) |
|
1120 | f.write('\n'.join(['# ' + i for i in phelp.splitlines()])) | |
1121 | f.close() |
|
1121 | f.close() | |
1122 | # Start the editor and wait for it to complete |
|
1122 | # Start the editor and wait for it to complete | |
1123 | editor = ui.geteditor() |
|
1123 | editor = ui.geteditor() | |
1124 | ret = ui.system("%s \"%s\"" % (editor, patchfn), |
|
1124 | ret = ui.system("%s \"%s\"" % (editor, patchfn), | |
1125 | environ={'HGUSER': ui.username()}, |
|
1125 | environ={'HGUSER': ui.username()}, | |
1126 | blockedtag='filterpatch') |
|
1126 | blockedtag='filterpatch') | |
1127 | if ret != 0: |
|
1127 | if ret != 0: | |
1128 | ui.warn(_("editor exited with exit code %d\n") % ret) |
|
1128 | ui.warn(_("editor exited with exit code %d\n") % ret) | |
1129 | continue |
|
1129 | continue | |
1130 | # Remove comment lines |
|
1130 | # Remove comment lines | |
1131 | patchfp = open(patchfn, r'rb') |
|
1131 | patchfp = open(patchfn, r'rb') | |
1132 | ncpatchfp = stringio() |
|
1132 | ncpatchfp = stringio() | |
1133 | for line in util.iterfile(patchfp): |
|
1133 | for line in util.iterfile(patchfp): | |
1134 | line = util.fromnativeeol(line) |
|
1134 | line = util.fromnativeeol(line) | |
1135 | if not line.startswith('#'): |
|
1135 | if not line.startswith('#'): | |
1136 | ncpatchfp.write(line) |
|
1136 | ncpatchfp.write(line) | |
1137 | patchfp.close() |
|
1137 | patchfp.close() | |
1138 | ncpatchfp.seek(0) |
|
1138 | ncpatchfp.seek(0) | |
1139 | newpatches = parsepatch(ncpatchfp) |
|
1139 | newpatches = parsepatch(ncpatchfp) | |
1140 | finally: |
|
1140 | finally: | |
1141 | os.unlink(patchfn) |
|
1141 | os.unlink(patchfn) | |
1142 | del ncpatchfp |
|
1142 | del ncpatchfp | |
1143 | # Signal that the chunk shouldn't be applied as-is, but |
|
1143 | # Signal that the chunk shouldn't be applied as-is, but | |
1144 | # provide the new patch to be used instead. |
|
1144 | # provide the new patch to be used instead. | |
1145 | ret = False |
|
1145 | ret = False | |
1146 | elif r == 3: # Skip |
|
1146 | elif r == 3: # Skip | |
1147 | ret = skipfile = False |
|
1147 | ret = skipfile = False | |
1148 | elif r == 4: # file (Record remaining) |
|
1148 | elif r == 4: # file (Record remaining) | |
1149 | ret = skipfile = True |
|
1149 | ret = skipfile = True | |
1150 | elif r == 5: # done, skip remaining |
|
1150 | elif r == 5: # done, skip remaining | |
1151 | ret = skipall = False |
|
1151 | ret = skipall = False | |
1152 | elif r == 6: # all |
|
1152 | elif r == 6: # all | |
1153 | ret = skipall = True |
|
1153 | ret = skipall = True | |
1154 | elif r == 7: # quit |
|
1154 | elif r == 7: # quit | |
1155 | raise error.Abort(_('user quit')) |
|
1155 | raise error.Abort(_('user quit')) | |
1156 | return ret, skipfile, skipall, newpatches |
|
1156 | return ret, skipfile, skipall, newpatches | |
1157 |
|
1157 | |||
1158 | seen = set() |
|
1158 | seen = set() | |
1159 | applied = {} # 'filename' -> [] of chunks |
|
1159 | applied = {} # 'filename' -> [] of chunks | |
1160 | skipfile, skipall = None, None |
|
1160 | skipfile, skipall = None, None | |
1161 | pos, total = 1, sum(len(h.hunks) for h in headers) |
|
1161 | pos, total = 1, sum(len(h.hunks) for h in headers) | |
1162 | for h in headers: |
|
1162 | for h in headers: | |
1163 | pos += len(h.hunks) |
|
1163 | pos += len(h.hunks) | |
1164 | skipfile = None |
|
1164 | skipfile = None | |
1165 | fixoffset = 0 |
|
1165 | fixoffset = 0 | |
1166 | hdr = ''.join(h.header) |
|
1166 | hdr = ''.join(h.header) | |
1167 | if hdr in seen: |
|
1167 | if hdr in seen: | |
1168 | continue |
|
1168 | continue | |
1169 | seen.add(hdr) |
|
1169 | seen.add(hdr) | |
1170 | if skipall is None: |
|
1170 | if skipall is None: | |
1171 | h.pretty(ui) |
|
1171 | h.pretty(ui) | |
1172 | msg = (_('examine changes to %s?') % |
|
1172 | msg = (_('examine changes to %s?') % | |
1173 | _(' and ').join("'%s'" % f for f in h.files())) |
|
1173 | _(' and ').join("'%s'" % f for f in h.files())) | |
1174 | r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None) |
|
1174 | r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None) | |
1175 | if not r: |
|
1175 | if not r: | |
1176 | continue |
|
1176 | continue | |
1177 | applied[h.filename()] = [h] |
|
1177 | applied[h.filename()] = [h] | |
1178 | if h.allhunks(): |
|
1178 | if h.allhunks(): | |
1179 | applied[h.filename()] += h.hunks |
|
1179 | applied[h.filename()] += h.hunks | |
1180 | continue |
|
1180 | continue | |
1181 | for i, chunk in enumerate(h.hunks): |
|
1181 | for i, chunk in enumerate(h.hunks): | |
1182 | if skipfile is None and skipall is None: |
|
1182 | if skipfile is None and skipall is None: | |
1183 | chunk.pretty(ui) |
|
1183 | chunk.pretty(ui) | |
1184 | if total == 1: |
|
1184 | if total == 1: | |
1185 | msg = messages['single'][operation] % chunk.filename() |
|
1185 | msg = messages['single'][operation] % chunk.filename() | |
1186 | else: |
|
1186 | else: | |
1187 | idx = pos - len(h.hunks) + i |
|
1187 | idx = pos - len(h.hunks) + i | |
1188 | msg = messages['multiple'][operation] % (idx, total, |
|
1188 | msg = messages['multiple'][operation] % (idx, total, | |
1189 | chunk.filename()) |
|
1189 | chunk.filename()) | |
1190 | r, skipfile, skipall, newpatches = prompt(skipfile, |
|
1190 | r, skipfile, skipall, newpatches = prompt(skipfile, | |
1191 | skipall, msg, chunk) |
|
1191 | skipall, msg, chunk) | |
1192 | if r: |
|
1192 | if r: | |
1193 | if fixoffset: |
|
1193 | if fixoffset: | |
1194 | chunk = copy.copy(chunk) |
|
1194 | chunk = copy.copy(chunk) | |
1195 | chunk.toline += fixoffset |
|
1195 | chunk.toline += fixoffset | |
1196 | applied[chunk.filename()].append(chunk) |
|
1196 | applied[chunk.filename()].append(chunk) | |
1197 | elif newpatches is not None: |
|
1197 | elif newpatches is not None: | |
1198 | for newpatch in newpatches: |
|
1198 | for newpatch in newpatches: | |
1199 | for newhunk in newpatch.hunks: |
|
1199 | for newhunk in newpatch.hunks: | |
1200 | if fixoffset: |
|
1200 | if fixoffset: | |
1201 | newhunk.toline += fixoffset |
|
1201 | newhunk.toline += fixoffset | |
1202 | applied[newhunk.filename()].append(newhunk) |
|
1202 | applied[newhunk.filename()].append(newhunk) | |
1203 | else: |
|
1203 | else: | |
1204 | fixoffset += chunk.removed - chunk.added |
|
1204 | fixoffset += chunk.removed - chunk.added | |
1205 | return (sum([h for h in applied.itervalues() |
|
1205 | return (sum([h for h in applied.itervalues() | |
1206 | if h[0].special() or len(h) > 1], []), {}) |
|
1206 | if h[0].special() or len(h) > 1], []), {}) | |
1207 | class hunk(object): |
|
1207 | class hunk(object): | |
1208 | def __init__(self, desc, num, lr, context): |
|
1208 | def __init__(self, desc, num, lr, context): | |
1209 | self.number = num |
|
1209 | self.number = num | |
1210 | self.desc = desc |
|
1210 | self.desc = desc | |
1211 | self.hunk = [desc] |
|
1211 | self.hunk = [desc] | |
1212 | self.a = [] |
|
1212 | self.a = [] | |
1213 | self.b = [] |
|
1213 | self.b = [] | |
1214 | self.starta = self.lena = None |
|
1214 | self.starta = self.lena = None | |
1215 | self.startb = self.lenb = None |
|
1215 | self.startb = self.lenb = None | |
1216 | if lr is not None: |
|
1216 | if lr is not None: | |
1217 | if context: |
|
1217 | if context: | |
1218 | self.read_context_hunk(lr) |
|
1218 | self.read_context_hunk(lr) | |
1219 | else: |
|
1219 | else: | |
1220 | self.read_unified_hunk(lr) |
|
1220 | self.read_unified_hunk(lr) | |
1221 |
|
1221 | |||
1222 | def getnormalized(self): |
|
1222 | def getnormalized(self): | |
1223 | """Return a copy with line endings normalized to LF.""" |
|
1223 | """Return a copy with line endings normalized to LF.""" | |
1224 |
|
1224 | |||
1225 | def normalize(lines): |
|
1225 | def normalize(lines): | |
1226 | nlines = [] |
|
1226 | nlines = [] | |
1227 | for line in lines: |
|
1227 | for line in lines: | |
1228 | if line.endswith('\r\n'): |
|
1228 | if line.endswith('\r\n'): | |
1229 | line = line[:-2] + '\n' |
|
1229 | line = line[:-2] + '\n' | |
1230 | nlines.append(line) |
|
1230 | nlines.append(line) | |
1231 | return nlines |
|
1231 | return nlines | |
1232 |
|
1232 | |||
1233 | # Dummy object, it is rebuilt manually |
|
1233 | # Dummy object, it is rebuilt manually | |
1234 | nh = hunk(self.desc, self.number, None, None) |
|
1234 | nh = hunk(self.desc, self.number, None, None) | |
1235 | nh.number = self.number |
|
1235 | nh.number = self.number | |
1236 | nh.desc = self.desc |
|
1236 | nh.desc = self.desc | |
1237 | nh.hunk = self.hunk |
|
1237 | nh.hunk = self.hunk | |
1238 | nh.a = normalize(self.a) |
|
1238 | nh.a = normalize(self.a) | |
1239 | nh.b = normalize(self.b) |
|
1239 | nh.b = normalize(self.b) | |
1240 | nh.starta = self.starta |
|
1240 | nh.starta = self.starta | |
1241 | nh.startb = self.startb |
|
1241 | nh.startb = self.startb | |
1242 | nh.lena = self.lena |
|
1242 | nh.lena = self.lena | |
1243 | nh.lenb = self.lenb |
|
1243 | nh.lenb = self.lenb | |
1244 | return nh |
|
1244 | return nh | |
1245 |
|
1245 | |||
1246 | def read_unified_hunk(self, lr): |
|
1246 | def read_unified_hunk(self, lr): | |
1247 | m = unidesc.match(self.desc) |
|
1247 | m = unidesc.match(self.desc) | |
1248 | if not m: |
|
1248 | if not m: | |
1249 | raise PatchError(_("bad hunk #%d") % self.number) |
|
1249 | raise PatchError(_("bad hunk #%d") % self.number) | |
1250 | self.starta, self.lena, self.startb, self.lenb = m.groups() |
|
1250 | self.starta, self.lena, self.startb, self.lenb = m.groups() | |
1251 | if self.lena is None: |
|
1251 | if self.lena is None: | |
1252 | self.lena = 1 |
|
1252 | self.lena = 1 | |
1253 | else: |
|
1253 | else: | |
1254 | self.lena = int(self.lena) |
|
1254 | self.lena = int(self.lena) | |
1255 | if self.lenb is None: |
|
1255 | if self.lenb is None: | |
1256 | self.lenb = 1 |
|
1256 | self.lenb = 1 | |
1257 | else: |
|
1257 | else: | |
1258 | self.lenb = int(self.lenb) |
|
1258 | self.lenb = int(self.lenb) | |
1259 | self.starta = int(self.starta) |
|
1259 | self.starta = int(self.starta) | |
1260 | self.startb = int(self.startb) |
|
1260 | self.startb = int(self.startb) | |
1261 | try: |
|
1261 | try: | |
1262 | diffhelper.addlines(lr, self.hunk, self.lena, self.lenb, |
|
1262 | diffhelper.addlines(lr, self.hunk, self.lena, self.lenb, | |
1263 | self.a, self.b) |
|
1263 | self.a, self.b) | |
1264 | except error.ParseError as e: |
|
1264 | except error.ParseError as e: | |
1265 | raise PatchError(_("bad hunk #%d: %s") % (self.number, e)) |
|
1265 | raise PatchError(_("bad hunk #%d: %s") % (self.number, e)) | |
1266 | # if we hit eof before finishing out the hunk, the last line will |
|
1266 | # if we hit eof before finishing out the hunk, the last line will | |
1267 | # be zero length. Lets try to fix it up. |
|
1267 | # be zero length. Lets try to fix it up. | |
1268 | while len(self.hunk[-1]) == 0: |
|
1268 | while len(self.hunk[-1]) == 0: | |
1269 | del self.hunk[-1] |
|
1269 | del self.hunk[-1] | |
1270 | del self.a[-1] |
|
1270 | del self.a[-1] | |
1271 | del self.b[-1] |
|
1271 | del self.b[-1] | |
1272 | self.lena -= 1 |
|
1272 | self.lena -= 1 | |
1273 | self.lenb -= 1 |
|
1273 | self.lenb -= 1 | |
1274 | self._fixnewline(lr) |
|
1274 | self._fixnewline(lr) | |
1275 |
|
1275 | |||
1276 | def read_context_hunk(self, lr): |
|
1276 | def read_context_hunk(self, lr): | |
1277 | self.desc = lr.readline() |
|
1277 | self.desc = lr.readline() | |
1278 | m = contextdesc.match(self.desc) |
|
1278 | m = contextdesc.match(self.desc) | |
1279 | if not m: |
|
1279 | if not m: | |
1280 | raise PatchError(_("bad hunk #%d") % self.number) |
|
1280 | raise PatchError(_("bad hunk #%d") % self.number) | |
1281 | self.starta, aend = m.groups() |
|
1281 | self.starta, aend = m.groups() | |
1282 | self.starta = int(self.starta) |
|
1282 | self.starta = int(self.starta) | |
1283 | if aend is None: |
|
1283 | if aend is None: | |
1284 | aend = self.starta |
|
1284 | aend = self.starta | |
1285 | self.lena = int(aend) - self.starta |
|
1285 | self.lena = int(aend) - self.starta | |
1286 | if self.starta: |
|
1286 | if self.starta: | |
1287 | self.lena += 1 |
|
1287 | self.lena += 1 | |
1288 | for x in pycompat.xrange(self.lena): |
|
1288 | for x in pycompat.xrange(self.lena): | |
1289 | l = lr.readline() |
|
1289 | l = lr.readline() | |
1290 | if l.startswith('---'): |
|
1290 | if l.startswith('---'): | |
1291 | # lines addition, old block is empty |
|
1291 | # lines addition, old block is empty | |
1292 | lr.push(l) |
|
1292 | lr.push(l) | |
1293 | break |
|
1293 | break | |
1294 | s = l[2:] |
|
1294 | s = l[2:] | |
1295 | if l.startswith('- ') or l.startswith('! '): |
|
1295 | if l.startswith('- ') or l.startswith('! '): | |
1296 | u = '-' + s |
|
1296 | u = '-' + s | |
1297 | elif l.startswith(' '): |
|
1297 | elif l.startswith(' '): | |
1298 | u = ' ' + s |
|
1298 | u = ' ' + s | |
1299 | else: |
|
1299 | else: | |
1300 | raise PatchError(_("bad hunk #%d old text line %d") % |
|
1300 | raise PatchError(_("bad hunk #%d old text line %d") % | |
1301 | (self.number, x)) |
|
1301 | (self.number, x)) | |
1302 | self.a.append(u) |
|
1302 | self.a.append(u) | |
1303 | self.hunk.append(u) |
|
1303 | self.hunk.append(u) | |
1304 |
|
1304 | |||
1305 | l = lr.readline() |
|
1305 | l = lr.readline() | |
1306 | if l.startswith(br'\ '): |
|
1306 | if l.startswith(br'\ '): | |
1307 | s = self.a[-1][:-1] |
|
1307 | s = self.a[-1][:-1] | |
1308 | self.a[-1] = s |
|
1308 | self.a[-1] = s | |
1309 | self.hunk[-1] = s |
|
1309 | self.hunk[-1] = s | |
1310 | l = lr.readline() |
|
1310 | l = lr.readline() | |
1311 | m = contextdesc.match(l) |
|
1311 | m = contextdesc.match(l) | |
1312 | if not m: |
|
1312 | if not m: | |
1313 | raise PatchError(_("bad hunk #%d") % self.number) |
|
1313 | raise PatchError(_("bad hunk #%d") % self.number) | |
1314 | self.startb, bend = m.groups() |
|
1314 | self.startb, bend = m.groups() | |
1315 | self.startb = int(self.startb) |
|
1315 | self.startb = int(self.startb) | |
1316 | if bend is None: |
|
1316 | if bend is None: | |
1317 | bend = self.startb |
|
1317 | bend = self.startb | |
1318 | self.lenb = int(bend) - self.startb |
|
1318 | self.lenb = int(bend) - self.startb | |
1319 | if self.startb: |
|
1319 | if self.startb: | |
1320 | self.lenb += 1 |
|
1320 | self.lenb += 1 | |
1321 | hunki = 1 |
|
1321 | hunki = 1 | |
1322 | for x in pycompat.xrange(self.lenb): |
|
1322 | for x in pycompat.xrange(self.lenb): | |
1323 | l = lr.readline() |
|
1323 | l = lr.readline() | |
1324 | if l.startswith(br'\ '): |
|
1324 | if l.startswith(br'\ '): | |
1325 | # XXX: the only way to hit this is with an invalid line range. |
|
1325 | # XXX: the only way to hit this is with an invalid line range. | |
1326 | # The no-eol marker is not counted in the line range, but I |
|
1326 | # The no-eol marker is not counted in the line range, but I | |
1327 | # guess there are diff(1) out there which behave differently. |
|
1327 | # guess there are diff(1) out there which behave differently. | |
1328 | s = self.b[-1][:-1] |
|
1328 | s = self.b[-1][:-1] | |
1329 | self.b[-1] = s |
|
1329 | self.b[-1] = s | |
1330 | self.hunk[hunki - 1] = s |
|
1330 | self.hunk[hunki - 1] = s | |
1331 | continue |
|
1331 | continue | |
1332 | if not l: |
|
1332 | if not l: | |
1333 | # line deletions, new block is empty and we hit EOF |
|
1333 | # line deletions, new block is empty and we hit EOF | |
1334 | lr.push(l) |
|
1334 | lr.push(l) | |
1335 | break |
|
1335 | break | |
1336 | s = l[2:] |
|
1336 | s = l[2:] | |
1337 | if l.startswith('+ ') or l.startswith('! '): |
|
1337 | if l.startswith('+ ') or l.startswith('! '): | |
1338 | u = '+' + s |
|
1338 | u = '+' + s | |
1339 | elif l.startswith(' '): |
|
1339 | elif l.startswith(' '): | |
1340 | u = ' ' + s |
|
1340 | u = ' ' + s | |
1341 | elif len(self.b) == 0: |
|
1341 | elif len(self.b) == 0: | |
1342 | # line deletions, new block is empty |
|
1342 | # line deletions, new block is empty | |
1343 | lr.push(l) |
|
1343 | lr.push(l) | |
1344 | break |
|
1344 | break | |
1345 | else: |
|
1345 | else: | |
1346 | raise PatchError(_("bad hunk #%d old text line %d") % |
|
1346 | raise PatchError(_("bad hunk #%d old text line %d") % | |
1347 | (self.number, x)) |
|
1347 | (self.number, x)) | |
1348 | self.b.append(s) |
|
1348 | self.b.append(s) | |
1349 | while True: |
|
1349 | while True: | |
1350 | if hunki >= len(self.hunk): |
|
1350 | if hunki >= len(self.hunk): | |
1351 | h = "" |
|
1351 | h = "" | |
1352 | else: |
|
1352 | else: | |
1353 | h = self.hunk[hunki] |
|
1353 | h = self.hunk[hunki] | |
1354 | hunki += 1 |
|
1354 | hunki += 1 | |
1355 | if h == u: |
|
1355 | if h == u: | |
1356 | break |
|
1356 | break | |
1357 | elif h.startswith('-'): |
|
1357 | elif h.startswith('-'): | |
1358 | continue |
|
1358 | continue | |
1359 | else: |
|
1359 | else: | |
1360 | self.hunk.insert(hunki - 1, u) |
|
1360 | self.hunk.insert(hunki - 1, u) | |
1361 | break |
|
1361 | break | |
1362 |
|
1362 | |||
1363 | if not self.a: |
|
1363 | if not self.a: | |
1364 | # this happens when lines were only added to the hunk |
|
1364 | # this happens when lines were only added to the hunk | |
1365 | for x in self.hunk: |
|
1365 | for x in self.hunk: | |
1366 | if x.startswith('-') or x.startswith(' '): |
|
1366 | if x.startswith('-') or x.startswith(' '): | |
1367 | self.a.append(x) |
|
1367 | self.a.append(x) | |
1368 | if not self.b: |
|
1368 | if not self.b: | |
1369 | # this happens when lines were only deleted from the hunk |
|
1369 | # this happens when lines were only deleted from the hunk | |
1370 | for x in self.hunk: |
|
1370 | for x in self.hunk: | |
1371 | if x.startswith('+') or x.startswith(' '): |
|
1371 | if x.startswith('+') or x.startswith(' '): | |
1372 | self.b.append(x[1:]) |
|
1372 | self.b.append(x[1:]) | |
1373 | # @@ -start,len +start,len @@ |
|
1373 | # @@ -start,len +start,len @@ | |
1374 | self.desc = "@@ -%d,%d +%d,%d @@\n" % (self.starta, self.lena, |
|
1374 | self.desc = "@@ -%d,%d +%d,%d @@\n" % (self.starta, self.lena, | |
1375 | self.startb, self.lenb) |
|
1375 | self.startb, self.lenb) | |
1376 | self.hunk[0] = self.desc |
|
1376 | self.hunk[0] = self.desc | |
1377 | self._fixnewline(lr) |
|
1377 | self._fixnewline(lr) | |
1378 |
|
1378 | |||
1379 | def _fixnewline(self, lr): |
|
1379 | def _fixnewline(self, lr): | |
1380 | l = lr.readline() |
|
1380 | l = lr.readline() | |
1381 | if l.startswith(br'\ '): |
|
1381 | if l.startswith(br'\ '): | |
1382 | diffhelper.fixnewline(self.hunk, self.a, self.b) |
|
1382 | diffhelper.fixnewline(self.hunk, self.a, self.b) | |
1383 | else: |
|
1383 | else: | |
1384 | lr.push(l) |
|
1384 | lr.push(l) | |
1385 |
|
1385 | |||
1386 | def complete(self): |
|
1386 | def complete(self): | |
1387 | return len(self.a) == self.lena and len(self.b) == self.lenb |
|
1387 | return len(self.a) == self.lena and len(self.b) == self.lenb | |
1388 |
|
1388 | |||
1389 | def _fuzzit(self, old, new, fuzz, toponly): |
|
1389 | def _fuzzit(self, old, new, fuzz, toponly): | |
1390 | # this removes context lines from the top and bottom of list 'l'. It |
|
1390 | # this removes context lines from the top and bottom of list 'l'. It | |
1391 | # checks the hunk to make sure only context lines are removed, and then |
|
1391 | # checks the hunk to make sure only context lines are removed, and then | |
1392 | # returns a new shortened list of lines. |
|
1392 | # returns a new shortened list of lines. | |
1393 | fuzz = min(fuzz, len(old)) |
|
1393 | fuzz = min(fuzz, len(old)) | |
1394 | if fuzz: |
|
1394 | if fuzz: | |
1395 | top = 0 |
|
1395 | top = 0 | |
1396 | bot = 0 |
|
1396 | bot = 0 | |
1397 | hlen = len(self.hunk) |
|
1397 | hlen = len(self.hunk) | |
1398 | for x in pycompat.xrange(hlen - 1): |
|
1398 | for x in pycompat.xrange(hlen - 1): | |
1399 | # the hunk starts with the @@ line, so use x+1 |
|
1399 | # the hunk starts with the @@ line, so use x+1 | |
1400 | if self.hunk[x + 1].startswith(' '): |
|
1400 | if self.hunk[x + 1].startswith(' '): | |
1401 | top += 1 |
|
1401 | top += 1 | |
1402 | else: |
|
1402 | else: | |
1403 | break |
|
1403 | break | |
1404 | if not toponly: |
|
1404 | if not toponly: | |
1405 | for x in pycompat.xrange(hlen - 1): |
|
1405 | for x in pycompat.xrange(hlen - 1): | |
1406 | if self.hunk[hlen - bot - 1].startswith(' '): |
|
1406 | if self.hunk[hlen - bot - 1].startswith(' '): | |
1407 | bot += 1 |
|
1407 | bot += 1 | |
1408 | else: |
|
1408 | else: | |
1409 | break |
|
1409 | break | |
1410 |
|
1410 | |||
1411 | bot = min(fuzz, bot) |
|
1411 | bot = min(fuzz, bot) | |
1412 | top = min(fuzz, top) |
|
1412 | top = min(fuzz, top) | |
1413 | return old[top:len(old) - bot], new[top:len(new) - bot], top |
|
1413 | return old[top:len(old) - bot], new[top:len(new) - bot], top | |
1414 | return old, new, 0 |
|
1414 | return old, new, 0 | |
1415 |
|
1415 | |||
1416 | def fuzzit(self, fuzz, toponly): |
|
1416 | def fuzzit(self, fuzz, toponly): | |
1417 | old, new, top = self._fuzzit(self.a, self.b, fuzz, toponly) |
|
1417 | old, new, top = self._fuzzit(self.a, self.b, fuzz, toponly) | |
1418 | oldstart = self.starta + top |
|
1418 | oldstart = self.starta + top | |
1419 | newstart = self.startb + top |
|
1419 | newstart = self.startb + top | |
1420 | # zero length hunk ranges already have their start decremented |
|
1420 | # zero length hunk ranges already have their start decremented | |
1421 | if self.lena and oldstart > 0: |
|
1421 | if self.lena and oldstart > 0: | |
1422 | oldstart -= 1 |
|
1422 | oldstart -= 1 | |
1423 | if self.lenb and newstart > 0: |
|
1423 | if self.lenb and newstart > 0: | |
1424 | newstart -= 1 |
|
1424 | newstart -= 1 | |
1425 | return old, oldstart, new, newstart |
|
1425 | return old, oldstart, new, newstart | |
1426 |
|
1426 | |||
1427 | class binhunk(object): |
|
1427 | class binhunk(object): | |
1428 | 'A binary patch file.' |
|
1428 | 'A binary patch file.' | |
1429 | def __init__(self, lr, fname): |
|
1429 | def __init__(self, lr, fname): | |
1430 | self.text = None |
|
1430 | self.text = None | |
1431 | self.delta = False |
|
1431 | self.delta = False | |
1432 | self.hunk = ['GIT binary patch\n'] |
|
1432 | self.hunk = ['GIT binary patch\n'] | |
1433 | self._fname = fname |
|
1433 | self._fname = fname | |
1434 | self._read(lr) |
|
1434 | self._read(lr) | |
1435 |
|
1435 | |||
1436 | def complete(self): |
|
1436 | def complete(self): | |
1437 | return self.text is not None |
|
1437 | return self.text is not None | |
1438 |
|
1438 | |||
1439 | def new(self, lines): |
|
1439 | def new(self, lines): | |
1440 | if self.delta: |
|
1440 | if self.delta: | |
1441 | return [applybindelta(self.text, ''.join(lines))] |
|
1441 | return [applybindelta(self.text, ''.join(lines))] | |
1442 | return [self.text] |
|
1442 | return [self.text] | |
1443 |
|
1443 | |||
1444 | def _read(self, lr): |
|
1444 | def _read(self, lr): | |
1445 | def getline(lr, hunk): |
|
1445 | def getline(lr, hunk): | |
1446 | l = lr.readline() |
|
1446 | l = lr.readline() | |
1447 | hunk.append(l) |
|
1447 | hunk.append(l) | |
1448 | return l.rstrip('\r\n') |
|
1448 | return l.rstrip('\r\n') | |
1449 |
|
1449 | |||
1450 | while True: |
|
1450 | while True: | |
1451 | line = getline(lr, self.hunk) |
|
1451 | line = getline(lr, self.hunk) | |
1452 | if not line: |
|
1452 | if not line: | |
1453 | raise PatchError(_('could not extract "%s" binary data') |
|
1453 | raise PatchError(_('could not extract "%s" binary data') | |
1454 | % self._fname) |
|
1454 | % self._fname) | |
1455 | if line.startswith('literal '): |
|
1455 | if line.startswith('literal '): | |
1456 | size = int(line[8:].rstrip()) |
|
1456 | size = int(line[8:].rstrip()) | |
1457 | break |
|
1457 | break | |
1458 | if line.startswith('delta '): |
|
1458 | if line.startswith('delta '): | |
1459 | size = int(line[6:].rstrip()) |
|
1459 | size = int(line[6:].rstrip()) | |
1460 | self.delta = True |
|
1460 | self.delta = True | |
1461 | break |
|
1461 | break | |
1462 | dec = [] |
|
1462 | dec = [] | |
1463 | line = getline(lr, self.hunk) |
|
1463 | line = getline(lr, self.hunk) | |
1464 | while len(line) > 1: |
|
1464 | while len(line) > 1: | |
1465 | l = line[0:1] |
|
1465 | l = line[0:1] | |
1466 | if l <= 'Z' and l >= 'A': |
|
1466 | if l <= 'Z' and l >= 'A': | |
1467 | l = ord(l) - ord('A') + 1 |
|
1467 | l = ord(l) - ord('A') + 1 | |
1468 | else: |
|
1468 | else: | |
1469 | l = ord(l) - ord('a') + 27 |
|
1469 | l = ord(l) - ord('a') + 27 | |
1470 | try: |
|
1470 | try: | |
1471 | dec.append(util.b85decode(line[1:])[:l]) |
|
1471 | dec.append(util.b85decode(line[1:])[:l]) | |
1472 | except ValueError as e: |
|
1472 | except ValueError as e: | |
1473 | raise PatchError(_('could not decode "%s" binary patch: %s') |
|
1473 | raise PatchError(_('could not decode "%s" binary patch: %s') | |
1474 | % (self._fname, stringutil.forcebytestr(e))) |
|
1474 | % (self._fname, stringutil.forcebytestr(e))) | |
1475 | line = getline(lr, self.hunk) |
|
1475 | line = getline(lr, self.hunk) | |
1476 | text = zlib.decompress(''.join(dec)) |
|
1476 | text = zlib.decompress(''.join(dec)) | |
1477 | if len(text) != size: |
|
1477 | if len(text) != size: | |
1478 | raise PatchError(_('"%s" length is %d bytes, should be %d') |
|
1478 | raise PatchError(_('"%s" length is %d bytes, should be %d') | |
1479 | % (self._fname, len(text), size)) |
|
1479 | % (self._fname, len(text), size)) | |
1480 | self.text = text |
|
1480 | self.text = text | |
1481 |
|
1481 | |||
1482 | def parsefilename(str): |
|
1482 | def parsefilename(str): | |
1483 | # --- filename \t|space stuff |
|
1483 | # --- filename \t|space stuff | |
1484 | s = str[4:].rstrip('\r\n') |
|
1484 | s = str[4:].rstrip('\r\n') | |
1485 | i = s.find('\t') |
|
1485 | i = s.find('\t') | |
1486 | if i < 0: |
|
1486 | if i < 0: | |
1487 | i = s.find(' ') |
|
1487 | i = s.find(' ') | |
1488 | if i < 0: |
|
1488 | if i < 0: | |
1489 | return s |
|
1489 | return s | |
1490 | return s[:i] |
|
1490 | return s[:i] | |
1491 |
|
1491 | |||
1492 | def reversehunks(hunks): |
|
1492 | def reversehunks(hunks): | |
1493 | '''reverse the signs in the hunks given as argument |
|
1493 | '''reverse the signs in the hunks given as argument | |
1494 |
|
1494 | |||
1495 | This function operates on hunks coming out of patch.filterpatch, that is |
|
1495 | This function operates on hunks coming out of patch.filterpatch, that is | |
1496 | a list of the form: [header1, hunk1, hunk2, header2...]. Example usage: |
|
1496 | a list of the form: [header1, hunk1, hunk2, header2...]. Example usage: | |
1497 |
|
1497 | |||
1498 | >>> rawpatch = b"""diff --git a/folder1/g b/folder1/g |
|
1498 | >>> rawpatch = b"""diff --git a/folder1/g b/folder1/g | |
1499 | ... --- a/folder1/g |
|
1499 | ... --- a/folder1/g | |
1500 | ... +++ b/folder1/g |
|
1500 | ... +++ b/folder1/g | |
1501 | ... @@ -1,7 +1,7 @@ |
|
1501 | ... @@ -1,7 +1,7 @@ | |
1502 | ... +firstline |
|
1502 | ... +firstline | |
1503 | ... c |
|
1503 | ... c | |
1504 | ... 1 |
|
1504 | ... 1 | |
1505 | ... 2 |
|
1505 | ... 2 | |
1506 | ... + 3 |
|
1506 | ... + 3 | |
1507 | ... -4 |
|
1507 | ... -4 | |
1508 | ... 5 |
|
1508 | ... 5 | |
1509 | ... d |
|
1509 | ... d | |
1510 | ... +lastline""" |
|
1510 | ... +lastline""" | |
1511 | >>> hunks = parsepatch([rawpatch]) |
|
1511 | >>> hunks = parsepatch([rawpatch]) | |
1512 | >>> hunkscomingfromfilterpatch = [] |
|
1512 | >>> hunkscomingfromfilterpatch = [] | |
1513 | >>> for h in hunks: |
|
1513 | >>> for h in hunks: | |
1514 | ... hunkscomingfromfilterpatch.append(h) |
|
1514 | ... hunkscomingfromfilterpatch.append(h) | |
1515 | ... hunkscomingfromfilterpatch.extend(h.hunks) |
|
1515 | ... hunkscomingfromfilterpatch.extend(h.hunks) | |
1516 |
|
1516 | |||
1517 | >>> reversedhunks = reversehunks(hunkscomingfromfilterpatch) |
|
1517 | >>> reversedhunks = reversehunks(hunkscomingfromfilterpatch) | |
1518 | >>> from . import util |
|
1518 | >>> from . import util | |
1519 | >>> fp = util.stringio() |
|
1519 | >>> fp = util.stringio() | |
1520 | >>> for c in reversedhunks: |
|
1520 | >>> for c in reversedhunks: | |
1521 | ... c.write(fp) |
|
1521 | ... c.write(fp) | |
1522 | >>> fp.seek(0) or None |
|
1522 | >>> fp.seek(0) or None | |
1523 | >>> reversedpatch = fp.read() |
|
1523 | >>> reversedpatch = fp.read() | |
1524 | >>> print(pycompat.sysstr(reversedpatch)) |
|
1524 | >>> print(pycompat.sysstr(reversedpatch)) | |
1525 | diff --git a/folder1/g b/folder1/g |
|
1525 | diff --git a/folder1/g b/folder1/g | |
1526 | --- a/folder1/g |
|
1526 | --- a/folder1/g | |
1527 | +++ b/folder1/g |
|
1527 | +++ b/folder1/g | |
1528 | @@ -1,4 +1,3 @@ |
|
1528 | @@ -1,4 +1,3 @@ | |
1529 | -firstline |
|
1529 | -firstline | |
1530 | c |
|
1530 | c | |
1531 | 1 |
|
1531 | 1 | |
1532 | 2 |
|
1532 | 2 | |
1533 | @@ -2,6 +1,6 @@ |
|
1533 | @@ -2,6 +1,6 @@ | |
1534 | c |
|
1534 | c | |
1535 | 1 |
|
1535 | 1 | |
1536 | 2 |
|
1536 | 2 | |
1537 | - 3 |
|
1537 | - 3 | |
1538 | +4 |
|
1538 | +4 | |
1539 | 5 |
|
1539 | 5 | |
1540 | d |
|
1540 | d | |
1541 | @@ -6,3 +5,2 @@ |
|
1541 | @@ -6,3 +5,2 @@ | |
1542 | 5 |
|
1542 | 5 | |
1543 | d |
|
1543 | d | |
1544 | -lastline |
|
1544 | -lastline | |
1545 |
|
1545 | |||
1546 | ''' |
|
1546 | ''' | |
1547 |
|
1547 | |||
1548 | newhunks = [] |
|
1548 | newhunks = [] | |
1549 | for c in hunks: |
|
1549 | for c in hunks: | |
1550 | if util.safehasattr(c, 'reversehunk'): |
|
1550 | if util.safehasattr(c, 'reversehunk'): | |
1551 | c = c.reversehunk() |
|
1551 | c = c.reversehunk() | |
1552 | newhunks.append(c) |
|
1552 | newhunks.append(c) | |
1553 | return newhunks |
|
1553 | return newhunks | |
1554 |
|
1554 | |||
1555 | def parsepatch(originalchunks, maxcontext=None): |
|
1555 | def parsepatch(originalchunks, maxcontext=None): | |
1556 | """patch -> [] of headers -> [] of hunks |
|
1556 | """patch -> [] of headers -> [] of hunks | |
1557 |
|
1557 | |||
1558 | If maxcontext is not None, trim context lines if necessary. |
|
1558 | If maxcontext is not None, trim context lines if necessary. | |
1559 |
|
1559 | |||
1560 | >>> rawpatch = b'''diff --git a/folder1/g b/folder1/g |
|
1560 | >>> rawpatch = b'''diff --git a/folder1/g b/folder1/g | |
1561 | ... --- a/folder1/g |
|
1561 | ... --- a/folder1/g | |
1562 | ... +++ b/folder1/g |
|
1562 | ... +++ b/folder1/g | |
1563 | ... @@ -1,8 +1,10 @@ |
|
1563 | ... @@ -1,8 +1,10 @@ | |
1564 | ... 1 |
|
1564 | ... 1 | |
1565 | ... 2 |
|
1565 | ... 2 | |
1566 | ... -3 |
|
1566 | ... -3 | |
1567 | ... 4 |
|
1567 | ... 4 | |
1568 | ... 5 |
|
1568 | ... 5 | |
1569 | ... 6 |
|
1569 | ... 6 | |
1570 | ... +6.1 |
|
1570 | ... +6.1 | |
1571 | ... +6.2 |
|
1571 | ... +6.2 | |
1572 | ... 7 |
|
1572 | ... 7 | |
1573 | ... 8 |
|
1573 | ... 8 | |
1574 | ... +9''' |
|
1574 | ... +9''' | |
1575 | >>> out = util.stringio() |
|
1575 | >>> out = util.stringio() | |
1576 | >>> headers = parsepatch([rawpatch], maxcontext=1) |
|
1576 | >>> headers = parsepatch([rawpatch], maxcontext=1) | |
1577 | >>> for header in headers: |
|
1577 | >>> for header in headers: | |
1578 | ... header.write(out) |
|
1578 | ... header.write(out) | |
1579 | ... for hunk in header.hunks: |
|
1579 | ... for hunk in header.hunks: | |
1580 | ... hunk.write(out) |
|
1580 | ... hunk.write(out) | |
1581 | >>> print(pycompat.sysstr(out.getvalue())) |
|
1581 | >>> print(pycompat.sysstr(out.getvalue())) | |
1582 | diff --git a/folder1/g b/folder1/g |
|
1582 | diff --git a/folder1/g b/folder1/g | |
1583 | --- a/folder1/g |
|
1583 | --- a/folder1/g | |
1584 | +++ b/folder1/g |
|
1584 | +++ b/folder1/g | |
1585 | @@ -2,3 +2,2 @@ |
|
1585 | @@ -2,3 +2,2 @@ | |
1586 | 2 |
|
1586 | 2 | |
1587 | -3 |
|
1587 | -3 | |
1588 | 4 |
|
1588 | 4 | |
1589 | @@ -6,2 +5,4 @@ |
|
1589 | @@ -6,2 +5,4 @@ | |
1590 | 6 |
|
1590 | 6 | |
1591 | +6.1 |
|
1591 | +6.1 | |
1592 | +6.2 |
|
1592 | +6.2 | |
1593 | 7 |
|
1593 | 7 | |
1594 | @@ -8,1 +9,2 @@ |
|
1594 | @@ -8,1 +9,2 @@ | |
1595 | 8 |
|
1595 | 8 | |
1596 | +9 |
|
1596 | +9 | |
1597 | """ |
|
1597 | """ | |
1598 | class parser(object): |
|
1598 | class parser(object): | |
1599 | """patch parsing state machine""" |
|
1599 | """patch parsing state machine""" | |
1600 | def __init__(self): |
|
1600 | def __init__(self): | |
1601 | self.fromline = 0 |
|
1601 | self.fromline = 0 | |
1602 | self.toline = 0 |
|
1602 | self.toline = 0 | |
1603 | self.proc = '' |
|
1603 | self.proc = '' | |
1604 | self.header = None |
|
1604 | self.header = None | |
1605 | self.context = [] |
|
1605 | self.context = [] | |
1606 | self.before = [] |
|
1606 | self.before = [] | |
1607 | self.hunk = [] |
|
1607 | self.hunk = [] | |
1608 | self.headers = [] |
|
1608 | self.headers = [] | |
1609 |
|
1609 | |||
1610 | def addrange(self, limits): |
|
1610 | def addrange(self, limits): | |
1611 | self.addcontext([]) |
|
1611 | self.addcontext([]) | |
1612 | fromstart, fromend, tostart, toend, proc = limits |
|
1612 | fromstart, fromend, tostart, toend, proc = limits | |
1613 | self.fromline = int(fromstart) |
|
1613 | self.fromline = int(fromstart) | |
1614 | self.toline = int(tostart) |
|
1614 | self.toline = int(tostart) | |
1615 | self.proc = proc |
|
1615 | self.proc = proc | |
1616 |
|
1616 | |||
1617 | def addcontext(self, context): |
|
1617 | def addcontext(self, context): | |
1618 | if self.hunk: |
|
1618 | if self.hunk: | |
1619 | h = recordhunk(self.header, self.fromline, self.toline, |
|
1619 | h = recordhunk(self.header, self.fromline, self.toline, | |
1620 | self.proc, self.before, self.hunk, context, maxcontext) |
|
1620 | self.proc, self.before, self.hunk, context, maxcontext) | |
1621 | self.header.hunks.append(h) |
|
1621 | self.header.hunks.append(h) | |
1622 | self.fromline += len(self.before) + h.removed |
|
1622 | self.fromline += len(self.before) + h.removed | |
1623 | self.toline += len(self.before) + h.added |
|
1623 | self.toline += len(self.before) + h.added | |
1624 | self.before = [] |
|
1624 | self.before = [] | |
1625 | self.hunk = [] |
|
1625 | self.hunk = [] | |
1626 | self.context = context |
|
1626 | self.context = context | |
1627 |
|
1627 | |||
1628 | def addhunk(self, hunk): |
|
1628 | def addhunk(self, hunk): | |
1629 | if self.context: |
|
1629 | if self.context: | |
1630 | self.before = self.context |
|
1630 | self.before = self.context | |
1631 | self.context = [] |
|
1631 | self.context = [] | |
1632 | if self.hunk: |
|
1632 | if self.hunk: | |
1633 | self.addcontext([]) |
|
1633 | self.addcontext([]) | |
1634 | self.hunk = hunk |
|
1634 | self.hunk = hunk | |
1635 |
|
1635 | |||
1636 | def newfile(self, hdr): |
|
1636 | def newfile(self, hdr): | |
1637 | self.addcontext([]) |
|
1637 | self.addcontext([]) | |
1638 | h = header(hdr) |
|
1638 | h = header(hdr) | |
1639 | self.headers.append(h) |
|
1639 | self.headers.append(h) | |
1640 | self.header = h |
|
1640 | self.header = h | |
1641 |
|
1641 | |||
1642 | def addother(self, line): |
|
1642 | def addother(self, line): | |
1643 | pass # 'other' lines are ignored |
|
1643 | pass # 'other' lines are ignored | |
1644 |
|
1644 | |||
1645 | def finished(self): |
|
1645 | def finished(self): | |
1646 | self.addcontext([]) |
|
1646 | self.addcontext([]) | |
1647 | return self.headers |
|
1647 | return self.headers | |
1648 |
|
1648 | |||
1649 | transitions = { |
|
1649 | transitions = { | |
1650 | 'file': {'context': addcontext, |
|
1650 | 'file': {'context': addcontext, | |
1651 | 'file': newfile, |
|
1651 | 'file': newfile, | |
1652 | 'hunk': addhunk, |
|
1652 | 'hunk': addhunk, | |
1653 | 'range': addrange}, |
|
1653 | 'range': addrange}, | |
1654 | 'context': {'file': newfile, |
|
1654 | 'context': {'file': newfile, | |
1655 | 'hunk': addhunk, |
|
1655 | 'hunk': addhunk, | |
1656 | 'range': addrange, |
|
1656 | 'range': addrange, | |
1657 | 'other': addother}, |
|
1657 | 'other': addother}, | |
1658 | 'hunk': {'context': addcontext, |
|
1658 | 'hunk': {'context': addcontext, | |
1659 | 'file': newfile, |
|
1659 | 'file': newfile, | |
1660 | 'range': addrange}, |
|
1660 | 'range': addrange}, | |
1661 | 'range': {'context': addcontext, |
|
1661 | 'range': {'context': addcontext, | |
1662 | 'hunk': addhunk}, |
|
1662 | 'hunk': addhunk}, | |
1663 | 'other': {'other': addother}, |
|
1663 | 'other': {'other': addother}, | |
1664 | } |
|
1664 | } | |
1665 |
|
1665 | |||
1666 | p = parser() |
|
1666 | p = parser() | |
1667 | fp = stringio() |
|
1667 | fp = stringio() | |
1668 | fp.write(''.join(originalchunks)) |
|
1668 | fp.write(''.join(originalchunks)) | |
1669 | fp.seek(0) |
|
1669 | fp.seek(0) | |
1670 |
|
1670 | |||
1671 | state = 'context' |
|
1671 | state = 'context' | |
1672 | for newstate, data in scanpatch(fp): |
|
1672 | for newstate, data in scanpatch(fp): | |
1673 | try: |
|
1673 | try: | |
1674 | p.transitions[state][newstate](p, data) |
|
1674 | p.transitions[state][newstate](p, data) | |
1675 | except KeyError: |
|
1675 | except KeyError: | |
1676 | raise PatchError('unhandled transition: %s -> %s' % |
|
1676 | raise PatchError('unhandled transition: %s -> %s' % | |
1677 | (state, newstate)) |
|
1677 | (state, newstate)) | |
1678 | state = newstate |
|
1678 | state = newstate | |
1679 | del fp |
|
1679 | del fp | |
1680 | return p.finished() |
|
1680 | return p.finished() | |
1681 |
|
1681 | |||
1682 | def pathtransform(path, strip, prefix): |
|
1682 | def pathtransform(path, strip, prefix): | |
1683 | '''turn a path from a patch into a path suitable for the repository |
|
1683 | '''turn a path from a patch into a path suitable for the repository | |
1684 |
|
1684 | |||
1685 | prefix, if not empty, is expected to be normalized with a / at the end. |
|
1685 | prefix, if not empty, is expected to be normalized with a / at the end. | |
1686 |
|
1686 | |||
1687 | Returns (stripped components, path in repository). |
|
1687 | Returns (stripped components, path in repository). | |
1688 |
|
1688 | |||
1689 | >>> pathtransform(b'a/b/c', 0, b'') |
|
1689 | >>> pathtransform(b'a/b/c', 0, b'') | |
1690 | ('', 'a/b/c') |
|
1690 | ('', 'a/b/c') | |
1691 | >>> pathtransform(b' a/b/c ', 0, b'') |
|
1691 | >>> pathtransform(b' a/b/c ', 0, b'') | |
1692 | ('', ' a/b/c') |
|
1692 | ('', ' a/b/c') | |
1693 | >>> pathtransform(b' a/b/c ', 2, b'') |
|
1693 | >>> pathtransform(b' a/b/c ', 2, b'') | |
1694 | ('a/b/', 'c') |
|
1694 | ('a/b/', 'c') | |
1695 | >>> pathtransform(b'a/b/c', 0, b'd/e/') |
|
1695 | >>> pathtransform(b'a/b/c', 0, b'd/e/') | |
1696 | ('', 'd/e/a/b/c') |
|
1696 | ('', 'd/e/a/b/c') | |
1697 | >>> pathtransform(b' a//b/c ', 2, b'd/e/') |
|
1697 | >>> pathtransform(b' a//b/c ', 2, b'd/e/') | |
1698 | ('a//b/', 'd/e/c') |
|
1698 | ('a//b/', 'd/e/c') | |
1699 | >>> pathtransform(b'a/b/c', 3, b'') |
|
1699 | >>> pathtransform(b'a/b/c', 3, b'') | |
1700 | Traceback (most recent call last): |
|
1700 | Traceback (most recent call last): | |
1701 | PatchError: unable to strip away 1 of 3 dirs from a/b/c |
|
1701 | PatchError: unable to strip away 1 of 3 dirs from a/b/c | |
1702 | ''' |
|
1702 | ''' | |
1703 | pathlen = len(path) |
|
1703 | pathlen = len(path) | |
1704 | i = 0 |
|
1704 | i = 0 | |
1705 | if strip == 0: |
|
1705 | if strip == 0: | |
1706 | return '', prefix + path.rstrip() |
|
1706 | return '', prefix + path.rstrip() | |
1707 | count = strip |
|
1707 | count = strip | |
1708 | while count > 0: |
|
1708 | while count > 0: | |
1709 | i = path.find('/', i) |
|
1709 | i = path.find('/', i) | |
1710 | if i == -1: |
|
1710 | if i == -1: | |
1711 | raise PatchError(_("unable to strip away %d of %d dirs from %s") % |
|
1711 | raise PatchError(_("unable to strip away %d of %d dirs from %s") % | |
1712 | (count, strip, path)) |
|
1712 | (count, strip, path)) | |
1713 | i += 1 |
|
1713 | i += 1 | |
1714 | # consume '//' in the path |
|
1714 | # consume '//' in the path | |
1715 | while i < pathlen - 1 and path[i:i + 1] == '/': |
|
1715 | while i < pathlen - 1 and path[i:i + 1] == '/': | |
1716 | i += 1 |
|
1716 | i += 1 | |
1717 | count -= 1 |
|
1717 | count -= 1 | |
1718 | return path[:i].lstrip(), prefix + path[i:].rstrip() |
|
1718 | return path[:i].lstrip(), prefix + path[i:].rstrip() | |
1719 |
|
1719 | |||
1720 | def makepatchmeta(backend, afile_orig, bfile_orig, hunk, strip, prefix): |
|
1720 | def makepatchmeta(backend, afile_orig, bfile_orig, hunk, strip, prefix): | |
1721 | nulla = afile_orig == "/dev/null" |
|
1721 | nulla = afile_orig == "/dev/null" | |
1722 | nullb = bfile_orig == "/dev/null" |
|
1722 | nullb = bfile_orig == "/dev/null" | |
1723 | create = nulla and hunk.starta == 0 and hunk.lena == 0 |
|
1723 | create = nulla and hunk.starta == 0 and hunk.lena == 0 | |
1724 | remove = nullb and hunk.startb == 0 and hunk.lenb == 0 |
|
1724 | remove = nullb and hunk.startb == 0 and hunk.lenb == 0 | |
1725 | abase, afile = pathtransform(afile_orig, strip, prefix) |
|
1725 | abase, afile = pathtransform(afile_orig, strip, prefix) | |
1726 | gooda = not nulla and backend.exists(afile) |
|
1726 | gooda = not nulla and backend.exists(afile) | |
1727 | bbase, bfile = pathtransform(bfile_orig, strip, prefix) |
|
1727 | bbase, bfile = pathtransform(bfile_orig, strip, prefix) | |
1728 | if afile == bfile: |
|
1728 | if afile == bfile: | |
1729 | goodb = gooda |
|
1729 | goodb = gooda | |
1730 | else: |
|
1730 | else: | |
1731 | goodb = not nullb and backend.exists(bfile) |
|
1731 | goodb = not nullb and backend.exists(bfile) | |
1732 | missing = not goodb and not gooda and not create |
|
1732 | missing = not goodb and not gooda and not create | |
1733 |
|
1733 | |||
1734 | # some diff programs apparently produce patches where the afile is |
|
1734 | # some diff programs apparently produce patches where the afile is | |
1735 | # not /dev/null, but afile starts with bfile |
|
1735 | # not /dev/null, but afile starts with bfile | |
1736 | abasedir = afile[:afile.rfind('/') + 1] |
|
1736 | abasedir = afile[:afile.rfind('/') + 1] | |
1737 | bbasedir = bfile[:bfile.rfind('/') + 1] |
|
1737 | bbasedir = bfile[:bfile.rfind('/') + 1] | |
1738 | if (missing and abasedir == bbasedir and afile.startswith(bfile) |
|
1738 | if (missing and abasedir == bbasedir and afile.startswith(bfile) | |
1739 | and hunk.starta == 0 and hunk.lena == 0): |
|
1739 | and hunk.starta == 0 and hunk.lena == 0): | |
1740 | create = True |
|
1740 | create = True | |
1741 | missing = False |
|
1741 | missing = False | |
1742 |
|
1742 | |||
1743 | # If afile is "a/b/foo" and bfile is "a/b/foo.orig" we assume the |
|
1743 | # If afile is "a/b/foo" and bfile is "a/b/foo.orig" we assume the | |
1744 | # diff is between a file and its backup. In this case, the original |
|
1744 | # diff is between a file and its backup. In this case, the original | |
1745 | # file should be patched (see original mpatch code). |
|
1745 | # file should be patched (see original mpatch code). | |
1746 | isbackup = (abase == bbase and bfile.startswith(afile)) |
|
1746 | isbackup = (abase == bbase and bfile.startswith(afile)) | |
1747 | fname = None |
|
1747 | fname = None | |
1748 | if not missing: |
|
1748 | if not missing: | |
1749 | if gooda and goodb: |
|
1749 | if gooda and goodb: | |
1750 | if isbackup: |
|
1750 | if isbackup: | |
1751 | fname = afile |
|
1751 | fname = afile | |
1752 | else: |
|
1752 | else: | |
1753 | fname = bfile |
|
1753 | fname = bfile | |
1754 | elif gooda: |
|
1754 | elif gooda: | |
1755 | fname = afile |
|
1755 | fname = afile | |
1756 |
|
1756 | |||
1757 | if not fname: |
|
1757 | if not fname: | |
1758 | if not nullb: |
|
1758 | if not nullb: | |
1759 | if isbackup: |
|
1759 | if isbackup: | |
1760 | fname = afile |
|
1760 | fname = afile | |
1761 | else: |
|
1761 | else: | |
1762 | fname = bfile |
|
1762 | fname = bfile | |
1763 | elif not nulla: |
|
1763 | elif not nulla: | |
1764 | fname = afile |
|
1764 | fname = afile | |
1765 | else: |
|
1765 | else: | |
1766 | raise PatchError(_("undefined source and destination files")) |
|
1766 | raise PatchError(_("undefined source and destination files")) | |
1767 |
|
1767 | |||
1768 | gp = patchmeta(fname) |
|
1768 | gp = patchmeta(fname) | |
1769 | if create: |
|
1769 | if create: | |
1770 | gp.op = 'ADD' |
|
1770 | gp.op = 'ADD' | |
1771 | elif remove: |
|
1771 | elif remove: | |
1772 | gp.op = 'DELETE' |
|
1772 | gp.op = 'DELETE' | |
1773 | return gp |
|
1773 | return gp | |
1774 |
|
1774 | |||
1775 | def scanpatch(fp): |
|
1775 | def scanpatch(fp): | |
1776 | """like patch.iterhunks, but yield different events |
|
1776 | """like patch.iterhunks, but yield different events | |
1777 |
|
1777 | |||
1778 | - ('file', [header_lines + fromfile + tofile]) |
|
1778 | - ('file', [header_lines + fromfile + tofile]) | |
1779 | - ('context', [context_lines]) |
|
1779 | - ('context', [context_lines]) | |
1780 | - ('hunk', [hunk_lines]) |
|
1780 | - ('hunk', [hunk_lines]) | |
1781 | - ('range', (-start,len, +start,len, proc)) |
|
1781 | - ('range', (-start,len, +start,len, proc)) | |
1782 | """ |
|
1782 | """ | |
1783 | lines_re = re.compile(br'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') |
|
1783 | lines_re = re.compile(br'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') | |
1784 | lr = linereader(fp) |
|
1784 | lr = linereader(fp) | |
1785 |
|
1785 | |||
1786 | def scanwhile(first, p): |
|
1786 | def scanwhile(first, p): | |
1787 | """scan lr while predicate holds""" |
|
1787 | """scan lr while predicate holds""" | |
1788 | lines = [first] |
|
1788 | lines = [first] | |
1789 | for line in iter(lr.readline, ''): |
|
1789 | for line in iter(lr.readline, ''): | |
1790 | if p(line): |
|
1790 | if p(line): | |
1791 | lines.append(line) |
|
1791 | lines.append(line) | |
1792 | else: |
|
1792 | else: | |
1793 | lr.push(line) |
|
1793 | lr.push(line) | |
1794 | break |
|
1794 | break | |
1795 | return lines |
|
1795 | return lines | |
1796 |
|
1796 | |||
1797 | for line in iter(lr.readline, ''): |
|
1797 | for line in iter(lr.readline, ''): | |
1798 | if line.startswith('diff --git a/') or line.startswith('diff -r '): |
|
1798 | if line.startswith('diff --git a/') or line.startswith('diff -r '): | |
1799 | def notheader(line): |
|
1799 | def notheader(line): | |
1800 | s = line.split(None, 1) |
|
1800 | s = line.split(None, 1) | |
1801 | return not s or s[0] not in ('---', 'diff') |
|
1801 | return not s or s[0] not in ('---', 'diff') | |
1802 | header = scanwhile(line, notheader) |
|
1802 | header = scanwhile(line, notheader) | |
1803 | fromfile = lr.readline() |
|
1803 | fromfile = lr.readline() | |
1804 | if fromfile.startswith('---'): |
|
1804 | if fromfile.startswith('---'): | |
1805 | tofile = lr.readline() |
|
1805 | tofile = lr.readline() | |
1806 | header += [fromfile, tofile] |
|
1806 | header += [fromfile, tofile] | |
1807 | else: |
|
1807 | else: | |
1808 | lr.push(fromfile) |
|
1808 | lr.push(fromfile) | |
1809 | yield 'file', header |
|
1809 | yield 'file', header | |
1810 | elif line.startswith(' '): |
|
1810 | elif line.startswith(' '): | |
1811 | cs = (' ', '\\') |
|
1811 | cs = (' ', '\\') | |
1812 | yield 'context', scanwhile(line, lambda l: l.startswith(cs)) |
|
1812 | yield 'context', scanwhile(line, lambda l: l.startswith(cs)) | |
1813 | elif line.startswith(('-', '+')): |
|
1813 | elif line.startswith(('-', '+')): | |
1814 | cs = ('-', '+', '\\') |
|
1814 | cs = ('-', '+', '\\') | |
1815 | yield 'hunk', scanwhile(line, lambda l: l.startswith(cs)) |
|
1815 | yield 'hunk', scanwhile(line, lambda l: l.startswith(cs)) | |
1816 | else: |
|
1816 | else: | |
1817 | m = lines_re.match(line) |
|
1817 | m = lines_re.match(line) | |
1818 | if m: |
|
1818 | if m: | |
1819 | yield 'range', m.groups() |
|
1819 | yield 'range', m.groups() | |
1820 | else: |
|
1820 | else: | |
1821 | yield 'other', line |
|
1821 | yield 'other', line | |
1822 |
|
1822 | |||
1823 | def scangitpatch(lr, firstline): |
|
1823 | def scangitpatch(lr, firstline): | |
1824 | """ |
|
1824 | """ | |
1825 | Git patches can emit: |
|
1825 | Git patches can emit: | |
1826 | - rename a to b |
|
1826 | - rename a to b | |
1827 | - change b |
|
1827 | - change b | |
1828 | - copy a to c |
|
1828 | - copy a to c | |
1829 | - change c |
|
1829 | - change c | |
1830 |
|
1830 | |||
1831 | We cannot apply this sequence as-is, the renamed 'a' could not be |
|
1831 | We cannot apply this sequence as-is, the renamed 'a' could not be | |
1832 | found for it would have been renamed already. And we cannot copy |
|
1832 | found for it would have been renamed already. And we cannot copy | |
1833 | from 'b' instead because 'b' would have been changed already. So |
|
1833 | from 'b' instead because 'b' would have been changed already. So | |
1834 | we scan the git patch for copy and rename commands so we can |
|
1834 | we scan the git patch for copy and rename commands so we can | |
1835 | perform the copies ahead of time. |
|
1835 | perform the copies ahead of time. | |
1836 | """ |
|
1836 | """ | |
1837 | pos = 0 |
|
1837 | pos = 0 | |
1838 | try: |
|
1838 | try: | |
1839 | pos = lr.fp.tell() |
|
1839 | pos = lr.fp.tell() | |
1840 | fp = lr.fp |
|
1840 | fp = lr.fp | |
1841 | except IOError: |
|
1841 | except IOError: | |
1842 | fp = stringio(lr.fp.read()) |
|
1842 | fp = stringio(lr.fp.read()) | |
1843 | gitlr = linereader(fp) |
|
1843 | gitlr = linereader(fp) | |
1844 | gitlr.push(firstline) |
|
1844 | gitlr.push(firstline) | |
1845 | gitpatches = readgitpatch(gitlr) |
|
1845 | gitpatches = readgitpatch(gitlr) | |
1846 | fp.seek(pos) |
|
1846 | fp.seek(pos) | |
1847 | return gitpatches |
|
1847 | return gitpatches | |
1848 |
|
1848 | |||
1849 | def iterhunks(fp): |
|
1849 | def iterhunks(fp): | |
1850 | """Read a patch and yield the following events: |
|
1850 | """Read a patch and yield the following events: | |
1851 | - ("file", afile, bfile, firsthunk): select a new target file. |
|
1851 | - ("file", afile, bfile, firsthunk): select a new target file. | |
1852 | - ("hunk", hunk): a new hunk is ready to be applied, follows a |
|
1852 | - ("hunk", hunk): a new hunk is ready to be applied, follows a | |
1853 | "file" event. |
|
1853 | "file" event. | |
1854 | - ("git", gitchanges): current diff is in git format, gitchanges |
|
1854 | - ("git", gitchanges): current diff is in git format, gitchanges | |
1855 | maps filenames to gitpatch records. Unique event. |
|
1855 | maps filenames to gitpatch records. Unique event. | |
1856 | """ |
|
1856 | """ | |
1857 | afile = "" |
|
1857 | afile = "" | |
1858 | bfile = "" |
|
1858 | bfile = "" | |
1859 | state = None |
|
1859 | state = None | |
1860 | hunknum = 0 |
|
1860 | hunknum = 0 | |
1861 | emitfile = newfile = False |
|
1861 | emitfile = newfile = False | |
1862 | gitpatches = None |
|
1862 | gitpatches = None | |
1863 |
|
1863 | |||
1864 | # our states |
|
1864 | # our states | |
1865 | BFILE = 1 |
|
1865 | BFILE = 1 | |
1866 | context = None |
|
1866 | context = None | |
1867 | lr = linereader(fp) |
|
1867 | lr = linereader(fp) | |
1868 |
|
1868 | |||
1869 | for x in iter(lr.readline, ''): |
|
1869 | for x in iter(lr.readline, ''): | |
1870 | if state == BFILE and ( |
|
1870 | if state == BFILE and ( | |
1871 | (not context and x.startswith('@')) |
|
1871 | (not context and x.startswith('@')) | |
1872 | or (context is not False and x.startswith('***************')) |
|
1872 | or (context is not False and x.startswith('***************')) | |
1873 | or x.startswith('GIT binary patch')): |
|
1873 | or x.startswith('GIT binary patch')): | |
1874 | gp = None |
|
1874 | gp = None | |
1875 | if (gitpatches and |
|
1875 | if (gitpatches and | |
1876 | gitpatches[-1].ispatching(afile, bfile)): |
|
1876 | gitpatches[-1].ispatching(afile, bfile)): | |
1877 | gp = gitpatches.pop() |
|
1877 | gp = gitpatches.pop() | |
1878 | if x.startswith('GIT binary patch'): |
|
1878 | if x.startswith('GIT binary patch'): | |
1879 | h = binhunk(lr, gp.path) |
|
1879 | h = binhunk(lr, gp.path) | |
1880 | else: |
|
1880 | else: | |
1881 | if context is None and x.startswith('***************'): |
|
1881 | if context is None and x.startswith('***************'): | |
1882 | context = True |
|
1882 | context = True | |
1883 | h = hunk(x, hunknum + 1, lr, context) |
|
1883 | h = hunk(x, hunknum + 1, lr, context) | |
1884 | hunknum += 1 |
|
1884 | hunknum += 1 | |
1885 | if emitfile: |
|
1885 | if emitfile: | |
1886 | emitfile = False |
|
1886 | emitfile = False | |
1887 | yield 'file', (afile, bfile, h, gp and gp.copy() or None) |
|
1887 | yield 'file', (afile, bfile, h, gp and gp.copy() or None) | |
1888 | yield 'hunk', h |
|
1888 | yield 'hunk', h | |
1889 | elif x.startswith('diff --git a/'): |
|
1889 | elif x.startswith('diff --git a/'): | |
1890 | m = gitre.match(x.rstrip(' \r\n')) |
|
1890 | m = gitre.match(x.rstrip(' \r\n')) | |
1891 | if not m: |
|
1891 | if not m: | |
1892 | continue |
|
1892 | continue | |
1893 | if gitpatches is None: |
|
1893 | if gitpatches is None: | |
1894 | # scan whole input for git metadata |
|
1894 | # scan whole input for git metadata | |
1895 | gitpatches = scangitpatch(lr, x) |
|
1895 | gitpatches = scangitpatch(lr, x) | |
1896 | yield 'git', [g.copy() for g in gitpatches |
|
1896 | yield 'git', [g.copy() for g in gitpatches | |
1897 | if g.op in ('COPY', 'RENAME')] |
|
1897 | if g.op in ('COPY', 'RENAME')] | |
1898 | gitpatches.reverse() |
|
1898 | gitpatches.reverse() | |
1899 | afile = 'a/' + m.group(1) |
|
1899 | afile = 'a/' + m.group(1) | |
1900 | bfile = 'b/' + m.group(2) |
|
1900 | bfile = 'b/' + m.group(2) | |
1901 | while gitpatches and not gitpatches[-1].ispatching(afile, bfile): |
|
1901 | while gitpatches and not gitpatches[-1].ispatching(afile, bfile): | |
1902 | gp = gitpatches.pop() |
|
1902 | gp = gitpatches.pop() | |
1903 | yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy()) |
|
1903 | yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy()) | |
1904 | if not gitpatches: |
|
1904 | if not gitpatches: | |
1905 | raise PatchError(_('failed to synchronize metadata for "%s"') |
|
1905 | raise PatchError(_('failed to synchronize metadata for "%s"') | |
1906 | % afile[2:]) |
|
1906 | % afile[2:]) | |
1907 | newfile = True |
|
1907 | newfile = True | |
1908 | elif x.startswith('---'): |
|
1908 | elif x.startswith('---'): | |
1909 | # check for a unified diff |
|
1909 | # check for a unified diff | |
1910 | l2 = lr.readline() |
|
1910 | l2 = lr.readline() | |
1911 | if not l2.startswith('+++'): |
|
1911 | if not l2.startswith('+++'): | |
1912 | lr.push(l2) |
|
1912 | lr.push(l2) | |
1913 | continue |
|
1913 | continue | |
1914 | newfile = True |
|
1914 | newfile = True | |
1915 | context = False |
|
1915 | context = False | |
1916 | afile = parsefilename(x) |
|
1916 | afile = parsefilename(x) | |
1917 | bfile = parsefilename(l2) |
|
1917 | bfile = parsefilename(l2) | |
1918 | elif x.startswith('***'): |
|
1918 | elif x.startswith('***'): | |
1919 | # check for a context diff |
|
1919 | # check for a context diff | |
1920 | l2 = lr.readline() |
|
1920 | l2 = lr.readline() | |
1921 | if not l2.startswith('---'): |
|
1921 | if not l2.startswith('---'): | |
1922 | lr.push(l2) |
|
1922 | lr.push(l2) | |
1923 | continue |
|
1923 | continue | |
1924 | l3 = lr.readline() |
|
1924 | l3 = lr.readline() | |
1925 | lr.push(l3) |
|
1925 | lr.push(l3) | |
1926 | if not l3.startswith("***************"): |
|
1926 | if not l3.startswith("***************"): | |
1927 | lr.push(l2) |
|
1927 | lr.push(l2) | |
1928 | continue |
|
1928 | continue | |
1929 | newfile = True |
|
1929 | newfile = True | |
1930 | context = True |
|
1930 | context = True | |
1931 | afile = parsefilename(x) |
|
1931 | afile = parsefilename(x) | |
1932 | bfile = parsefilename(l2) |
|
1932 | bfile = parsefilename(l2) | |
1933 |
|
1933 | |||
1934 | if newfile: |
|
1934 | if newfile: | |
1935 | newfile = False |
|
1935 | newfile = False | |
1936 | emitfile = True |
|
1936 | emitfile = True | |
1937 | state = BFILE |
|
1937 | state = BFILE | |
1938 | hunknum = 0 |
|
1938 | hunknum = 0 | |
1939 |
|
1939 | |||
1940 | while gitpatches: |
|
1940 | while gitpatches: | |
1941 | gp = gitpatches.pop() |
|
1941 | gp = gitpatches.pop() | |
1942 | yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy()) |
|
1942 | yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp.copy()) | |
1943 |
|
1943 | |||
1944 | def applybindelta(binchunk, data): |
|
1944 | def applybindelta(binchunk, data): | |
1945 | """Apply a binary delta hunk |
|
1945 | """Apply a binary delta hunk | |
1946 | The algorithm used is the algorithm from git's patch-delta.c |
|
1946 | The algorithm used is the algorithm from git's patch-delta.c | |
1947 | """ |
|
1947 | """ | |
1948 | def deltahead(binchunk): |
|
1948 | def deltahead(binchunk): | |
1949 | i = 0 |
|
1949 | i = 0 | |
1950 | for c in pycompat.bytestr(binchunk): |
|
1950 | for c in pycompat.bytestr(binchunk): | |
1951 | i += 1 |
|
1951 | i += 1 | |
1952 | if not (ord(c) & 0x80): |
|
1952 | if not (ord(c) & 0x80): | |
1953 | return i |
|
1953 | return i | |
1954 | return i |
|
1954 | return i | |
1955 | out = "" |
|
1955 | out = "" | |
1956 | s = deltahead(binchunk) |
|
1956 | s = deltahead(binchunk) | |
1957 | binchunk = binchunk[s:] |
|
1957 | binchunk = binchunk[s:] | |
1958 | s = deltahead(binchunk) |
|
1958 | s = deltahead(binchunk) | |
1959 | binchunk = binchunk[s:] |
|
1959 | binchunk = binchunk[s:] | |
1960 | i = 0 |
|
1960 | i = 0 | |
1961 | while i < len(binchunk): |
|
1961 | while i < len(binchunk): | |
1962 | cmd = ord(binchunk[i:i + 1]) |
|
1962 | cmd = ord(binchunk[i:i + 1]) | |
1963 | i += 1 |
|
1963 | i += 1 | |
1964 | if (cmd & 0x80): |
|
1964 | if (cmd & 0x80): | |
1965 | offset = 0 |
|
1965 | offset = 0 | |
1966 | size = 0 |
|
1966 | size = 0 | |
1967 | if (cmd & 0x01): |
|
1967 | if (cmd & 0x01): | |
1968 | offset = ord(binchunk[i:i + 1]) |
|
1968 | offset = ord(binchunk[i:i + 1]) | |
1969 | i += 1 |
|
1969 | i += 1 | |
1970 | if (cmd & 0x02): |
|
1970 | if (cmd & 0x02): | |
1971 | offset |= ord(binchunk[i:i + 1]) << 8 |
|
1971 | offset |= ord(binchunk[i:i + 1]) << 8 | |
1972 | i += 1 |
|
1972 | i += 1 | |
1973 | if (cmd & 0x04): |
|
1973 | if (cmd & 0x04): | |
1974 | offset |= ord(binchunk[i:i + 1]) << 16 |
|
1974 | offset |= ord(binchunk[i:i + 1]) << 16 | |
1975 | i += 1 |
|
1975 | i += 1 | |
1976 | if (cmd & 0x08): |
|
1976 | if (cmd & 0x08): | |
1977 | offset |= ord(binchunk[i:i + 1]) << 24 |
|
1977 | offset |= ord(binchunk[i:i + 1]) << 24 | |
1978 | i += 1 |
|
1978 | i += 1 | |
1979 | if (cmd & 0x10): |
|
1979 | if (cmd & 0x10): | |
1980 | size = ord(binchunk[i:i + 1]) |
|
1980 | size = ord(binchunk[i:i + 1]) | |
1981 | i += 1 |
|
1981 | i += 1 | |
1982 | if (cmd & 0x20): |
|
1982 | if (cmd & 0x20): | |
1983 | size |= ord(binchunk[i:i + 1]) << 8 |
|
1983 | size |= ord(binchunk[i:i + 1]) << 8 | |
1984 | i += 1 |
|
1984 | i += 1 | |
1985 | if (cmd & 0x40): |
|
1985 | if (cmd & 0x40): | |
1986 | size |= ord(binchunk[i:i + 1]) << 16 |
|
1986 | size |= ord(binchunk[i:i + 1]) << 16 | |
1987 | i += 1 |
|
1987 | i += 1 | |
1988 | if size == 0: |
|
1988 | if size == 0: | |
1989 | size = 0x10000 |
|
1989 | size = 0x10000 | |
1990 | offset_end = offset + size |
|
1990 | offset_end = offset + size | |
1991 | out += data[offset:offset_end] |
|
1991 | out += data[offset:offset_end] | |
1992 | elif cmd != 0: |
|
1992 | elif cmd != 0: | |
1993 | offset_end = i + cmd |
|
1993 | offset_end = i + cmd | |
1994 | out += binchunk[i:offset_end] |
|
1994 | out += binchunk[i:offset_end] | |
1995 | i += cmd |
|
1995 | i += cmd | |
1996 | else: |
|
1996 | else: | |
1997 | raise PatchError(_('unexpected delta opcode 0')) |
|
1997 | raise PatchError(_('unexpected delta opcode 0')) | |
1998 | return out |
|
1998 | return out | |
1999 |
|
1999 | |||
2000 | def applydiff(ui, fp, backend, store, strip=1, prefix='', eolmode='strict'): |
|
2000 | def applydiff(ui, fp, backend, store, strip=1, prefix='', eolmode='strict'): | |
2001 | """Reads a patch from fp and tries to apply it. |
|
2001 | """Reads a patch from fp and tries to apply it. | |
2002 |
|
2002 | |||
2003 | Returns 0 for a clean patch, -1 if any rejects were found and 1 if |
|
2003 | Returns 0 for a clean patch, -1 if any rejects were found and 1 if | |
2004 | there was any fuzz. |
|
2004 | there was any fuzz. | |
2005 |
|
2005 | |||
2006 | If 'eolmode' is 'strict', the patch content and patched file are |
|
2006 | If 'eolmode' is 'strict', the patch content and patched file are | |
2007 | read in binary mode. Otherwise, line endings are ignored when |
|
2007 | read in binary mode. Otherwise, line endings are ignored when | |
2008 | patching then normalized according to 'eolmode'. |
|
2008 | patching then normalized according to 'eolmode'. | |
2009 | """ |
|
2009 | """ | |
2010 | return _applydiff(ui, fp, patchfile, backend, store, strip=strip, |
|
2010 | return _applydiff(ui, fp, patchfile, backend, store, strip=strip, | |
2011 | prefix=prefix, eolmode=eolmode) |
|
2011 | prefix=prefix, eolmode=eolmode) | |
2012 |
|
2012 | |||
2013 | def _canonprefix(repo, prefix): |
|
2013 | def _canonprefix(repo, prefix): | |
2014 | if prefix: |
|
2014 | if prefix: | |
2015 | prefix = pathutil.canonpath(repo.root, repo.getcwd(), prefix) |
|
2015 | prefix = pathutil.canonpath(repo.root, repo.getcwd(), prefix) | |
2016 | if prefix != '': |
|
2016 | if prefix != '': | |
2017 | prefix += '/' |
|
2017 | prefix += '/' | |
2018 | return prefix |
|
2018 | return prefix | |
2019 |
|
2019 | |||
2020 | def _applydiff(ui, fp, patcher, backend, store, strip=1, prefix='', |
|
2020 | def _applydiff(ui, fp, patcher, backend, store, strip=1, prefix='', | |
2021 | eolmode='strict'): |
|
2021 | eolmode='strict'): | |
2022 | prefix = _canonprefix(backend.repo, prefix) |
|
2022 | prefix = _canonprefix(backend.repo, prefix) | |
2023 | def pstrip(p): |
|
2023 | def pstrip(p): | |
2024 | return pathtransform(p, strip - 1, prefix)[1] |
|
2024 | return pathtransform(p, strip - 1, prefix)[1] | |
2025 |
|
2025 | |||
2026 | rejects = 0 |
|
2026 | rejects = 0 | |
2027 | err = 0 |
|
2027 | err = 0 | |
2028 | current_file = None |
|
2028 | current_file = None | |
2029 |
|
2029 | |||
2030 | for state, values in iterhunks(fp): |
|
2030 | for state, values in iterhunks(fp): | |
2031 | if state == 'hunk': |
|
2031 | if state == 'hunk': | |
2032 | if not current_file: |
|
2032 | if not current_file: | |
2033 | continue |
|
2033 | continue | |
2034 | ret = current_file.apply(values) |
|
2034 | ret = current_file.apply(values) | |
2035 | if ret > 0: |
|
2035 | if ret > 0: | |
2036 | err = 1 |
|
2036 | err = 1 | |
2037 | elif state == 'file': |
|
2037 | elif state == 'file': | |
2038 | if current_file: |
|
2038 | if current_file: | |
2039 | rejects += current_file.close() |
|
2039 | rejects += current_file.close() | |
2040 | current_file = None |
|
2040 | current_file = None | |
2041 | afile, bfile, first_hunk, gp = values |
|
2041 | afile, bfile, first_hunk, gp = values | |
2042 | if gp: |
|
2042 | if gp: | |
2043 | gp.path = pstrip(gp.path) |
|
2043 | gp.path = pstrip(gp.path) | |
2044 | if gp.oldpath: |
|
2044 | if gp.oldpath: | |
2045 | gp.oldpath = pstrip(gp.oldpath) |
|
2045 | gp.oldpath = pstrip(gp.oldpath) | |
2046 | else: |
|
2046 | else: | |
2047 | gp = makepatchmeta(backend, afile, bfile, first_hunk, strip, |
|
2047 | gp = makepatchmeta(backend, afile, bfile, first_hunk, strip, | |
2048 | prefix) |
|
2048 | prefix) | |
2049 | if gp.op == 'RENAME': |
|
2049 | if gp.op == 'RENAME': | |
2050 | backend.unlink(gp.oldpath) |
|
2050 | backend.unlink(gp.oldpath) | |
2051 | if not first_hunk: |
|
2051 | if not first_hunk: | |
2052 | if gp.op == 'DELETE': |
|
2052 | if gp.op == 'DELETE': | |
2053 | backend.unlink(gp.path) |
|
2053 | backend.unlink(gp.path) | |
2054 | continue |
|
2054 | continue | |
2055 | data, mode = None, None |
|
2055 | data, mode = None, None | |
2056 | if gp.op in ('RENAME', 'COPY'): |
|
2056 | if gp.op in ('RENAME', 'COPY'): | |
2057 | data, mode = store.getfile(gp.oldpath)[:2] |
|
2057 | data, mode = store.getfile(gp.oldpath)[:2] | |
2058 | if data is None: |
|
2058 | if data is None: | |
2059 | # This means that the old path does not exist |
|
2059 | # This means that the old path does not exist | |
2060 | raise PatchError(_("source file '%s' does not exist") |
|
2060 | raise PatchError(_("source file '%s' does not exist") | |
2061 | % gp.oldpath) |
|
2061 | % gp.oldpath) | |
2062 | if gp.mode: |
|
2062 | if gp.mode: | |
2063 | mode = gp.mode |
|
2063 | mode = gp.mode | |
2064 | if gp.op == 'ADD': |
|
2064 | if gp.op == 'ADD': | |
2065 | # Added files without content have no hunk and |
|
2065 | # Added files without content have no hunk and | |
2066 | # must be created |
|
2066 | # must be created | |
2067 | data = '' |
|
2067 | data = '' | |
2068 | if data or mode: |
|
2068 | if data or mode: | |
2069 | if (gp.op in ('ADD', 'RENAME', 'COPY') |
|
2069 | if (gp.op in ('ADD', 'RENAME', 'COPY') | |
2070 | and backend.exists(gp.path)): |
|
2070 | and backend.exists(gp.path)): | |
2071 | raise PatchError(_("cannot create %s: destination " |
|
2071 | raise PatchError(_("cannot create %s: destination " | |
2072 | "already exists") % gp.path) |
|
2072 | "already exists") % gp.path) | |
2073 | backend.setfile(gp.path, data, mode, gp.oldpath) |
|
2073 | backend.setfile(gp.path, data, mode, gp.oldpath) | |
2074 | continue |
|
2074 | continue | |
2075 | try: |
|
2075 | try: | |
2076 | current_file = patcher(ui, gp, backend, store, |
|
2076 | current_file = patcher(ui, gp, backend, store, | |
2077 | eolmode=eolmode) |
|
2077 | eolmode=eolmode) | |
2078 | except PatchError as inst: |
|
2078 | except PatchError as inst: | |
2079 | ui.warn(str(inst) + '\n') |
|
2079 | ui.warn(str(inst) + '\n') | |
2080 | current_file = None |
|
2080 | current_file = None | |
2081 | rejects += 1 |
|
2081 | rejects += 1 | |
2082 | continue |
|
2082 | continue | |
2083 | elif state == 'git': |
|
2083 | elif state == 'git': | |
2084 | for gp in values: |
|
2084 | for gp in values: | |
2085 | path = pstrip(gp.oldpath) |
|
2085 | path = pstrip(gp.oldpath) | |
2086 | data, mode = backend.getfile(path) |
|
2086 | data, mode = backend.getfile(path) | |
2087 | if data is None: |
|
2087 | if data is None: | |
2088 | # The error ignored here will trigger a getfile() |
|
2088 | # The error ignored here will trigger a getfile() | |
2089 | # error in a place more appropriate for error |
|
2089 | # error in a place more appropriate for error | |
2090 | # handling, and will not interrupt the patching |
|
2090 | # handling, and will not interrupt the patching | |
2091 | # process. |
|
2091 | # process. | |
2092 | pass |
|
2092 | pass | |
2093 | else: |
|
2093 | else: | |
2094 | store.setfile(path, data, mode) |
|
2094 | store.setfile(path, data, mode) | |
2095 | else: |
|
2095 | else: | |
2096 | raise error.Abort(_('unsupported parser state: %s') % state) |
|
2096 | raise error.Abort(_('unsupported parser state: %s') % state) | |
2097 |
|
2097 | |||
2098 | if current_file: |
|
2098 | if current_file: | |
2099 | rejects += current_file.close() |
|
2099 | rejects += current_file.close() | |
2100 |
|
2100 | |||
2101 | if rejects: |
|
2101 | if rejects: | |
2102 | return -1 |
|
2102 | return -1 | |
2103 | return err |
|
2103 | return err | |
2104 |
|
2104 | |||
2105 | def _externalpatch(ui, repo, patcher, patchname, strip, files, |
|
2105 | def _externalpatch(ui, repo, patcher, patchname, strip, files, | |
2106 | similarity): |
|
2106 | similarity): | |
2107 | """use <patcher> to apply <patchname> to the working directory. |
|
2107 | """use <patcher> to apply <patchname> to the working directory. | |
2108 | returns whether patch was applied with fuzz factor.""" |
|
2108 | returns whether patch was applied with fuzz factor.""" | |
2109 |
|
2109 | |||
2110 | fuzz = False |
|
2110 | fuzz = False | |
2111 | args = [] |
|
2111 | args = [] | |
2112 | cwd = repo.root |
|
2112 | cwd = repo.root | |
2113 | if cwd: |
|
2113 | if cwd: | |
2114 | args.append('-d %s' % procutil.shellquote(cwd)) |
|
2114 | args.append('-d %s' % procutil.shellquote(cwd)) | |
2115 | cmd = ('%s %s -p%d < %s' |
|
2115 | cmd = ('%s %s -p%d < %s' | |
2116 | % (patcher, ' '.join(args), strip, procutil.shellquote(patchname))) |
|
2116 | % (patcher, ' '.join(args), strip, procutil.shellquote(patchname))) | |
2117 | ui.debug('Using external patch tool: %s\n' % cmd) |
|
2117 | ui.debug('Using external patch tool: %s\n' % cmd) | |
2118 | fp = procutil.popen(cmd, 'rb') |
|
2118 | fp = procutil.popen(cmd, 'rb') | |
2119 | try: |
|
2119 | try: | |
2120 | for line in util.iterfile(fp): |
|
2120 | for line in util.iterfile(fp): | |
2121 | line = line.rstrip() |
|
2121 | line = line.rstrip() | |
2122 | ui.note(line + '\n') |
|
2122 | ui.note(line + '\n') | |
2123 | if line.startswith('patching file '): |
|
2123 | if line.startswith('patching file '): | |
2124 | pf = util.parsepatchoutput(line) |
|
2124 | pf = util.parsepatchoutput(line) | |
2125 | printed_file = False |
|
2125 | printed_file = False | |
2126 | files.add(pf) |
|
2126 | files.add(pf) | |
2127 | elif line.find('with fuzz') >= 0: |
|
2127 | elif line.find('with fuzz') >= 0: | |
2128 | fuzz = True |
|
2128 | fuzz = True | |
2129 | if not printed_file: |
|
2129 | if not printed_file: | |
2130 | ui.warn(pf + '\n') |
|
2130 | ui.warn(pf + '\n') | |
2131 | printed_file = True |
|
2131 | printed_file = True | |
2132 | ui.warn(line + '\n') |
|
2132 | ui.warn(line + '\n') | |
2133 | elif line.find('saving rejects to file') >= 0: |
|
2133 | elif line.find('saving rejects to file') >= 0: | |
2134 | ui.warn(line + '\n') |
|
2134 | ui.warn(line + '\n') | |
2135 | elif line.find('FAILED') >= 0: |
|
2135 | elif line.find('FAILED') >= 0: | |
2136 | if not printed_file: |
|
2136 | if not printed_file: | |
2137 | ui.warn(pf + '\n') |
|
2137 | ui.warn(pf + '\n') | |
2138 | printed_file = True |
|
2138 | printed_file = True | |
2139 | ui.warn(line + '\n') |
|
2139 | ui.warn(line + '\n') | |
2140 | finally: |
|
2140 | finally: | |
2141 | if files: |
|
2141 | if files: | |
2142 | scmutil.marktouched(repo, files, similarity) |
|
2142 | scmutil.marktouched(repo, files, similarity) | |
2143 | code = fp.close() |
|
2143 | code = fp.close() | |
2144 | if code: |
|
2144 | if code: | |
2145 | raise PatchError(_("patch command failed: %s") % |
|
2145 | raise PatchError(_("patch command failed: %s") % | |
2146 | procutil.explainexit(code)) |
|
2146 | procutil.explainexit(code)) | |
2147 | return fuzz |
|
2147 | return fuzz | |
2148 |
|
2148 | |||
2149 | def patchbackend(ui, backend, patchobj, strip, prefix, files=None, |
|
2149 | def patchbackend(ui, backend, patchobj, strip, prefix, files=None, | |
2150 | eolmode='strict'): |
|
2150 | eolmode='strict'): | |
2151 | if files is None: |
|
2151 | if files is None: | |
2152 | files = set() |
|
2152 | files = set() | |
2153 | if eolmode is None: |
|
2153 | if eolmode is None: | |
2154 | eolmode = ui.config('patch', 'eol') |
|
2154 | eolmode = ui.config('patch', 'eol') | |
2155 | if eolmode.lower() not in eolmodes: |
|
2155 | if eolmode.lower() not in eolmodes: | |
2156 | raise error.Abort(_('unsupported line endings type: %s') % eolmode) |
|
2156 | raise error.Abort(_('unsupported line endings type: %s') % eolmode) | |
2157 | eolmode = eolmode.lower() |
|
2157 | eolmode = eolmode.lower() | |
2158 |
|
2158 | |||
2159 | store = filestore() |
|
2159 | store = filestore() | |
2160 | try: |
|
2160 | try: | |
2161 | fp = open(patchobj, 'rb') |
|
2161 | fp = open(patchobj, 'rb') | |
2162 | except TypeError: |
|
2162 | except TypeError: | |
2163 | fp = patchobj |
|
2163 | fp = patchobj | |
2164 | try: |
|
2164 | try: | |
2165 | ret = applydiff(ui, fp, backend, store, strip=strip, prefix=prefix, |
|
2165 | ret = applydiff(ui, fp, backend, store, strip=strip, prefix=prefix, | |
2166 | eolmode=eolmode) |
|
2166 | eolmode=eolmode) | |
2167 | finally: |
|
2167 | finally: | |
2168 | if fp != patchobj: |
|
2168 | if fp != patchobj: | |
2169 | fp.close() |
|
2169 | fp.close() | |
2170 | files.update(backend.close()) |
|
2170 | files.update(backend.close()) | |
2171 | store.close() |
|
2171 | store.close() | |
2172 | if ret < 0: |
|
2172 | if ret < 0: | |
2173 | raise PatchError(_('patch failed to apply')) |
|
2173 | raise PatchError(_('patch failed to apply')) | |
2174 | return ret > 0 |
|
2174 | return ret > 0 | |
2175 |
|
2175 | |||
2176 | def internalpatch(ui, repo, patchobj, strip, prefix='', files=None, |
|
2176 | def internalpatch(ui, repo, patchobj, strip, prefix='', files=None, | |
2177 | eolmode='strict', similarity=0): |
|
2177 | eolmode='strict', similarity=0): | |
2178 | """use builtin patch to apply <patchobj> to the working directory. |
|
2178 | """use builtin patch to apply <patchobj> to the working directory. | |
2179 | returns whether patch was applied with fuzz factor.""" |
|
2179 | returns whether patch was applied with fuzz factor.""" | |
2180 | backend = workingbackend(ui, repo, similarity) |
|
2180 | backend = workingbackend(ui, repo, similarity) | |
2181 | return patchbackend(ui, backend, patchobj, strip, prefix, files, eolmode) |
|
2181 | return patchbackend(ui, backend, patchobj, strip, prefix, files, eolmode) | |
2182 |
|
2182 | |||
2183 | def patchrepo(ui, repo, ctx, store, patchobj, strip, prefix, files=None, |
|
2183 | def patchrepo(ui, repo, ctx, store, patchobj, strip, prefix, files=None, | |
2184 | eolmode='strict'): |
|
2184 | eolmode='strict'): | |
2185 | backend = repobackend(ui, repo, ctx, store) |
|
2185 | backend = repobackend(ui, repo, ctx, store) | |
2186 | return patchbackend(ui, backend, patchobj, strip, prefix, files, eolmode) |
|
2186 | return patchbackend(ui, backend, patchobj, strip, prefix, files, eolmode) | |
2187 |
|
2187 | |||
2188 | def patch(ui, repo, patchname, strip=1, prefix='', files=None, eolmode='strict', |
|
2188 | def patch(ui, repo, patchname, strip=1, prefix='', files=None, eolmode='strict', | |
2189 | similarity=0): |
|
2189 | similarity=0): | |
2190 | """Apply <patchname> to the working directory. |
|
2190 | """Apply <patchname> to the working directory. | |
2191 |
|
2191 | |||
2192 | 'eolmode' specifies how end of lines should be handled. It can be: |
|
2192 | 'eolmode' specifies how end of lines should be handled. It can be: | |
2193 | - 'strict': inputs are read in binary mode, EOLs are preserved |
|
2193 | - 'strict': inputs are read in binary mode, EOLs are preserved | |
2194 | - 'crlf': EOLs are ignored when patching and reset to CRLF |
|
2194 | - 'crlf': EOLs are ignored when patching and reset to CRLF | |
2195 | - 'lf': EOLs are ignored when patching and reset to LF |
|
2195 | - 'lf': EOLs are ignored when patching and reset to LF | |
2196 | - None: get it from user settings, default to 'strict' |
|
2196 | - None: get it from user settings, default to 'strict' | |
2197 | 'eolmode' is ignored when using an external patcher program. |
|
2197 | 'eolmode' is ignored when using an external patcher program. | |
2198 |
|
2198 | |||
2199 | Returns whether patch was applied with fuzz factor. |
|
2199 | Returns whether patch was applied with fuzz factor. | |
2200 | """ |
|
2200 | """ | |
2201 | patcher = ui.config('ui', 'patch') |
|
2201 | patcher = ui.config('ui', 'patch') | |
2202 | if files is None: |
|
2202 | if files is None: | |
2203 | files = set() |
|
2203 | files = set() | |
2204 | if patcher: |
|
2204 | if patcher: | |
2205 | return _externalpatch(ui, repo, patcher, patchname, strip, |
|
2205 | return _externalpatch(ui, repo, patcher, patchname, strip, | |
2206 | files, similarity) |
|
2206 | files, similarity) | |
2207 | return internalpatch(ui, repo, patchname, strip, prefix, files, eolmode, |
|
2207 | return internalpatch(ui, repo, patchname, strip, prefix, files, eolmode, | |
2208 | similarity) |
|
2208 | similarity) | |
2209 |
|
2209 | |||
2210 | def changedfiles(ui, repo, patchpath, strip=1, prefix=''): |
|
2210 | def changedfiles(ui, repo, patchpath, strip=1, prefix=''): | |
2211 | backend = fsbackend(ui, repo.root) |
|
2211 | backend = fsbackend(ui, repo.root) | |
2212 | prefix = _canonprefix(repo, prefix) |
|
2212 | prefix = _canonprefix(repo, prefix) | |
2213 | with open(patchpath, 'rb') as fp: |
|
2213 | with open(patchpath, 'rb') as fp: | |
2214 | changed = set() |
|
2214 | changed = set() | |
2215 | for state, values in iterhunks(fp): |
|
2215 | for state, values in iterhunks(fp): | |
2216 | if state == 'file': |
|
2216 | if state == 'file': | |
2217 | afile, bfile, first_hunk, gp = values |
|
2217 | afile, bfile, first_hunk, gp = values | |
2218 | if gp: |
|
2218 | if gp: | |
2219 | gp.path = pathtransform(gp.path, strip - 1, prefix)[1] |
|
2219 | gp.path = pathtransform(gp.path, strip - 1, prefix)[1] | |
2220 | if gp.oldpath: |
|
2220 | if gp.oldpath: | |
2221 | gp.oldpath = pathtransform(gp.oldpath, strip - 1, |
|
2221 | gp.oldpath = pathtransform(gp.oldpath, strip - 1, | |
2222 | prefix)[1] |
|
2222 | prefix)[1] | |
2223 | else: |
|
2223 | else: | |
2224 | gp = makepatchmeta(backend, afile, bfile, first_hunk, strip, |
|
2224 | gp = makepatchmeta(backend, afile, bfile, first_hunk, strip, | |
2225 | prefix) |
|
2225 | prefix) | |
2226 | changed.add(gp.path) |
|
2226 | changed.add(gp.path) | |
2227 | if gp.op == 'RENAME': |
|
2227 | if gp.op == 'RENAME': | |
2228 | changed.add(gp.oldpath) |
|
2228 | changed.add(gp.oldpath) | |
2229 | elif state not in ('hunk', 'git'): |
|
2229 | elif state not in ('hunk', 'git'): | |
2230 | raise error.Abort(_('unsupported parser state: %s') % state) |
|
2230 | raise error.Abort(_('unsupported parser state: %s') % state) | |
2231 | return changed |
|
2231 | return changed | |
2232 |
|
2232 | |||
2233 | class GitDiffRequired(Exception): |
|
2233 | class GitDiffRequired(Exception): | |
2234 | pass |
|
2234 | pass | |
2235 |
|
2235 | |||
2236 | diffopts = diffutil.diffallopts |
|
2236 | diffopts = diffutil.diffallopts | |
2237 | diffallopts = diffutil.diffallopts |
|
2237 | diffallopts = diffutil.diffallopts | |
2238 | difffeatureopts = diffutil.difffeatureopts |
|
2238 | difffeatureopts = diffutil.difffeatureopts | |
2239 |
|
2239 | |||
2240 | def diff(repo, node1=None, node2=None, match=None, changes=None, |
|
2240 | def diff(repo, node1=None, node2=None, match=None, changes=None, | |
2241 | opts=None, losedatafn=None, pathfn=None, copy=None, |
|
2241 | opts=None, losedatafn=None, pathfn=None, copy=None, | |
2242 | copysourcematch=None, hunksfilterfn=None): |
|
2242 | copysourcematch=None, hunksfilterfn=None): | |
2243 | '''yields diff of changes to files between two nodes, or node and |
|
2243 | '''yields diff of changes to files between two nodes, or node and | |
2244 | working directory. |
|
2244 | working directory. | |
2245 |
|
2245 | |||
2246 | if node1 is None, use first dirstate parent instead. |
|
2246 | if node1 is None, use first dirstate parent instead. | |
2247 | if node2 is None, compare node1 with working directory. |
|
2247 | if node2 is None, compare node1 with working directory. | |
2248 |
|
2248 | |||
2249 | losedatafn(**kwarg) is a callable run when opts.upgrade=True and |
|
2249 | losedatafn(**kwarg) is a callable run when opts.upgrade=True and | |
2250 | every time some change cannot be represented with the current |
|
2250 | every time some change cannot be represented with the current | |
2251 | patch format. Return False to upgrade to git patch format, True to |
|
2251 | patch format. Return False to upgrade to git patch format, True to | |
2252 | accept the loss or raise an exception to abort the diff. It is |
|
2252 | accept the loss or raise an exception to abort the diff. It is | |
2253 | called with the name of current file being diffed as 'fn'. If set |
|
2253 | called with the name of current file being diffed as 'fn'. If set | |
2254 | to None, patches will always be upgraded to git format when |
|
2254 | to None, patches will always be upgraded to git format when | |
2255 | necessary. |
|
2255 | necessary. | |
2256 |
|
2256 | |||
2257 | prefix is a filename prefix that is prepended to all filenames on |
|
2257 | prefix is a filename prefix that is prepended to all filenames on | |
2258 | display (used for subrepos). |
|
2258 | display (used for subrepos). | |
2259 |
|
2259 | |||
2260 | relroot, if not empty, must be normalized with a trailing /. Any match |
|
2260 | relroot, if not empty, must be normalized with a trailing /. Any match | |
2261 | patterns that fall outside it will be ignored. |
|
2261 | patterns that fall outside it will be ignored. | |
2262 |
|
2262 | |||
2263 | copy, if not empty, should contain mappings {dst@y: src@x} of copy |
|
2263 | copy, if not empty, should contain mappings {dst@y: src@x} of copy | |
2264 | information. |
|
2264 | information. | |
2265 |
|
2265 | |||
2266 | if copysourcematch is not None, then copy sources will be filtered by this |
|
2266 | if copysourcematch is not None, then copy sources will be filtered by this | |
2267 | matcher |
|
2267 | matcher | |
2268 |
|
2268 | |||
2269 | hunksfilterfn, if not None, should be a function taking a filectx and |
|
2269 | hunksfilterfn, if not None, should be a function taking a filectx and | |
2270 | hunks generator that may yield filtered hunks. |
|
2270 | hunks generator that may yield filtered hunks. | |
2271 | ''' |
|
2271 | ''' | |
2272 | if not node1 and not node2: |
|
2272 | if not node1 and not node2: | |
2273 | node1 = repo.dirstate.p1() |
|
2273 | node1 = repo.dirstate.p1() | |
2274 |
|
2274 | |||
2275 | ctx1 = repo[node1] |
|
2275 | ctx1 = repo[node1] | |
2276 | ctx2 = repo[node2] |
|
2276 | ctx2 = repo[node2] | |
2277 |
|
2277 | |||
2278 | for fctx1, fctx2, hdr, hunks in diffhunks( |
|
2278 | for fctx1, fctx2, hdr, hunks in diffhunks( | |
2279 | repo, ctx1=ctx1, ctx2=ctx2, match=match, changes=changes, opts=opts, |
|
2279 | repo, ctx1=ctx1, ctx2=ctx2, match=match, changes=changes, opts=opts, | |
2280 | losedatafn=losedatafn, pathfn=pathfn, copy=copy, |
|
2280 | losedatafn=losedatafn, pathfn=pathfn, copy=copy, | |
2281 | copysourcematch=copysourcematch): |
|
2281 | copysourcematch=copysourcematch): | |
2282 | if hunksfilterfn is not None: |
|
2282 | if hunksfilterfn is not None: | |
2283 | # If the file has been removed, fctx2 is None; but this should |
|
2283 | # If the file has been removed, fctx2 is None; but this should | |
2284 | # not occur here since we catch removed files early in |
|
2284 | # not occur here since we catch removed files early in | |
2285 | # logcmdutil.getlinerangerevs() for 'hg log -L'. |
|
2285 | # logcmdutil.getlinerangerevs() for 'hg log -L'. | |
2286 | assert fctx2 is not None, ( |
|
2286 | assert fctx2 is not None, ( | |
2287 | 'fctx2 unexpectly None in diff hunks filtering') |
|
2287 | 'fctx2 unexpectly None in diff hunks filtering') | |
2288 | hunks = hunksfilterfn(fctx2, hunks) |
|
2288 | hunks = hunksfilterfn(fctx2, hunks) | |
2289 | text = ''.join(sum((list(hlines) for hrange, hlines in hunks), [])) |
|
2289 | text = ''.join(sum((list(hlines) for hrange, hlines in hunks), [])) | |
2290 | if hdr and (text or len(hdr) > 1): |
|
2290 | if hdr and (text or len(hdr) > 1): | |
2291 | yield '\n'.join(hdr) + '\n' |
|
2291 | yield '\n'.join(hdr) + '\n' | |
2292 | if text: |
|
2292 | if text: | |
2293 | yield text |
|
2293 | yield text | |
2294 |
|
2294 | |||
2295 | def diffhunks(repo, ctx1, ctx2, match=None, changes=None, opts=None, |
|
2295 | def diffhunks(repo, ctx1, ctx2, match=None, changes=None, opts=None, | |
2296 | losedatafn=None, pathfn=None, copy=None, copysourcematch=None): |
|
2296 | losedatafn=None, pathfn=None, copy=None, copysourcematch=None): | |
2297 | """Yield diff of changes to files in the form of (`header`, `hunks`) tuples |
|
2297 | """Yield diff of changes to files in the form of (`header`, `hunks`) tuples | |
2298 | where `header` is a list of diff headers and `hunks` is an iterable of |
|
2298 | where `header` is a list of diff headers and `hunks` is an iterable of | |
2299 | (`hunkrange`, `hunklines`) tuples. |
|
2299 | (`hunkrange`, `hunklines`) tuples. | |
2300 |
|
2300 | |||
2301 | See diff() for the meaning of parameters. |
|
2301 | See diff() for the meaning of parameters. | |
2302 | """ |
|
2302 | """ | |
2303 |
|
2303 | |||
2304 | if opts is None: |
|
2304 | if opts is None: | |
2305 | opts = mdiff.defaultopts |
|
2305 | opts = mdiff.defaultopts | |
2306 |
|
2306 | |||
2307 | def lrugetfilectx(): |
|
2307 | def lrugetfilectx(): | |
2308 | cache = {} |
|
2308 | cache = {} | |
2309 | order = collections.deque() |
|
2309 | order = collections.deque() | |
2310 | def getfilectx(f, ctx): |
|
2310 | def getfilectx(f, ctx): | |
2311 | fctx = ctx.filectx(f, filelog=cache.get(f)) |
|
2311 | fctx = ctx.filectx(f, filelog=cache.get(f)) | |
2312 | if f not in cache: |
|
2312 | if f not in cache: | |
2313 | if len(cache) > 20: |
|
2313 | if len(cache) > 20: | |
2314 | del cache[order.popleft()] |
|
2314 | del cache[order.popleft()] | |
2315 | cache[f] = fctx.filelog() |
|
2315 | cache[f] = fctx.filelog() | |
2316 | else: |
|
2316 | else: | |
2317 | order.remove(f) |
|
2317 | order.remove(f) | |
2318 | order.append(f) |
|
2318 | order.append(f) | |
2319 | return fctx |
|
2319 | return fctx | |
2320 | return getfilectx |
|
2320 | return getfilectx | |
2321 | getfilectx = lrugetfilectx() |
|
2321 | getfilectx = lrugetfilectx() | |
2322 |
|
2322 | |||
2323 | if not changes: |
|
2323 | if not changes: | |
2324 | changes = ctx1.status(ctx2, match=match) |
|
2324 | changes = ctx1.status(ctx2, match=match) | |
2325 | modified, added, removed = changes[:3] |
|
2325 | modified, added, removed = changes[:3] | |
2326 |
|
2326 | |||
2327 | if not modified and not added and not removed: |
|
2327 | if not modified and not added and not removed: | |
2328 | return [] |
|
2328 | return [] | |
2329 |
|
2329 | |||
2330 | if repo.ui.debugflag: |
|
2330 | if repo.ui.debugflag: | |
2331 | hexfunc = hex |
|
2331 | hexfunc = hex | |
2332 | else: |
|
2332 | else: | |
2333 | hexfunc = short |
|
2333 | hexfunc = short | |
2334 | revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node] |
|
2334 | revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node] | |
2335 |
|
2335 | |||
2336 | if copy is None: |
|
2336 | if copy is None: | |
2337 | copy = {} |
|
2337 | copy = {} | |
2338 | if opts.git or opts.upgrade: |
|
2338 | if opts.git or opts.upgrade: | |
2339 | copy = copies.pathcopies(ctx1, ctx2, match=match) |
|
2339 | copy = copies.pathcopies(ctx1, ctx2, match=match) | |
2340 |
|
2340 | |||
2341 | if copysourcematch: |
|
2341 | if copysourcematch: | |
2342 | # filter out copies where source side isn't inside the matcher |
|
2342 | # filter out copies where source side isn't inside the matcher | |
2343 | # (copies.pathcopies() already filtered out the destination) |
|
2343 | # (copies.pathcopies() already filtered out the destination) | |
2344 | copy = {dst: src for dst, src in copy.iteritems() |
|
2344 | copy = {dst: src for dst, src in copy.iteritems() | |
2345 | if copysourcematch(src)} |
|
2345 | if copysourcematch(src)} | |
2346 |
|
2346 | |||
2347 | modifiedset = set(modified) |
|
2347 | modifiedset = set(modified) | |
2348 | addedset = set(added) |
|
2348 | addedset = set(added) | |
2349 | removedset = set(removed) |
|
2349 | removedset = set(removed) | |
2350 | for f in modified: |
|
2350 | for f in modified: | |
2351 | if f not in ctx1: |
|
2351 | if f not in ctx1: | |
2352 | # Fix up added, since merged-in additions appear as |
|
2352 | # Fix up added, since merged-in additions appear as | |
2353 | # modifications during merges |
|
2353 | # modifications during merges | |
2354 | modifiedset.remove(f) |
|
2354 | modifiedset.remove(f) | |
2355 | addedset.add(f) |
|
2355 | addedset.add(f) | |
2356 | for f in removed: |
|
2356 | for f in removed: | |
2357 | if f not in ctx1: |
|
2357 | if f not in ctx1: | |
2358 | # Merged-in additions that are then removed are reported as removed. |
|
2358 | # Merged-in additions that are then removed are reported as removed. | |
2359 | # They are not in ctx1, so We don't want to show them in the diff. |
|
2359 | # They are not in ctx1, so We don't want to show them in the diff. | |
2360 | removedset.remove(f) |
|
2360 | removedset.remove(f) | |
2361 | modified = sorted(modifiedset) |
|
2361 | modified = sorted(modifiedset) | |
2362 | added = sorted(addedset) |
|
2362 | added = sorted(addedset) | |
2363 | removed = sorted(removedset) |
|
2363 | removed = sorted(removedset) | |
2364 | for dst, src in list(copy.items()): |
|
2364 | for dst, src in list(copy.items()): | |
2365 | if src not in ctx1: |
|
2365 | if src not in ctx1: | |
2366 | # Files merged in during a merge and then copied/renamed are |
|
2366 | # Files merged in during a merge and then copied/renamed are | |
2367 | # reported as copies. We want to show them in the diff as additions. |
|
2367 | # reported as copies. We want to show them in the diff as additions. | |
2368 | del copy[dst] |
|
2368 | del copy[dst] | |
2369 |
|
2369 | |||
2370 | prefetchmatch = scmutil.matchfiles( |
|
2370 | prefetchmatch = scmutil.matchfiles( | |
2371 | repo, list(modifiedset | addedset | removedset)) |
|
2371 | repo, list(modifiedset | addedset | removedset)) | |
2372 | scmutil.prefetchfiles(repo, [ctx1.rev(), ctx2.rev()], prefetchmatch) |
|
2372 | scmutil.prefetchfiles(repo, [ctx1.rev(), ctx2.rev()], prefetchmatch) | |
2373 |
|
2373 | |||
2374 | def difffn(opts, losedata): |
|
2374 | def difffn(opts, losedata): | |
2375 | return trydiff(repo, revs, ctx1, ctx2, modified, added, removed, |
|
2375 | return trydiff(repo, revs, ctx1, ctx2, modified, added, removed, | |
2376 | copy, getfilectx, opts, losedata, pathfn) |
|
2376 | copy, getfilectx, opts, losedata, pathfn) | |
2377 | if opts.upgrade and not opts.git: |
|
2377 | if opts.upgrade and not opts.git: | |
2378 | try: |
|
2378 | try: | |
2379 | def losedata(fn): |
|
2379 | def losedata(fn): | |
2380 | if not losedatafn or not losedatafn(fn=fn): |
|
2380 | if not losedatafn or not losedatafn(fn=fn): | |
2381 | raise GitDiffRequired |
|
2381 | raise GitDiffRequired | |
2382 | # Buffer the whole output until we are sure it can be generated |
|
2382 | # Buffer the whole output until we are sure it can be generated | |
2383 | return list(difffn(opts.copy(git=False), losedata)) |
|
2383 | return list(difffn(opts.copy(git=False), losedata)) | |
2384 | except GitDiffRequired: |
|
2384 | except GitDiffRequired: | |
2385 | return difffn(opts.copy(git=True), None) |
|
2385 | return difffn(opts.copy(git=True), None) | |
2386 | else: |
|
2386 | else: | |
2387 | return difffn(opts, None) |
|
2387 | return difffn(opts, None) | |
2388 |
|
2388 | |||
2389 | def diffsinglehunk(hunklines): |
|
2389 | def diffsinglehunk(hunklines): | |
2390 | """yield tokens for a list of lines in a single hunk""" |
|
2390 | """yield tokens for a list of lines in a single hunk""" | |
2391 | for line in hunklines: |
|
2391 | for line in hunklines: | |
2392 | # chomp |
|
2392 | # chomp | |
2393 | chompline = line.rstrip('\r\n') |
|
2393 | chompline = line.rstrip('\r\n') | |
2394 | # highlight tabs and trailing whitespace |
|
2394 | # highlight tabs and trailing whitespace | |
2395 | stripline = chompline.rstrip() |
|
2395 | stripline = chompline.rstrip() | |
2396 | if line.startswith('-'): |
|
2396 | if line.startswith('-'): | |
2397 | label = 'diff.deleted' |
|
2397 | label = 'diff.deleted' | |
2398 | elif line.startswith('+'): |
|
2398 | elif line.startswith('+'): | |
2399 | label = 'diff.inserted' |
|
2399 | label = 'diff.inserted' | |
2400 | else: |
|
2400 | else: | |
2401 | raise error.ProgrammingError('unexpected hunk line: %s' % line) |
|
2401 | raise error.ProgrammingError('unexpected hunk line: %s' % line) | |
2402 | for token in tabsplitter.findall(stripline): |
|
2402 | for token in tabsplitter.findall(stripline): | |
2403 | if token.startswith('\t'): |
|
2403 | if token.startswith('\t'): | |
2404 | yield (token, 'diff.tab') |
|
2404 | yield (token, 'diff.tab') | |
2405 | else: |
|
2405 | else: | |
2406 | yield (token, label) |
|
2406 | yield (token, label) | |
2407 |
|
2407 | |||
2408 | if chompline != stripline: |
|
2408 | if chompline != stripline: | |
2409 | yield (chompline[len(stripline):], 'diff.trailingwhitespace') |
|
2409 | yield (chompline[len(stripline):], 'diff.trailingwhitespace') | |
2410 | if chompline != line: |
|
2410 | if chompline != line: | |
2411 | yield (line[len(chompline):], '') |
|
2411 | yield (line[len(chompline):], '') | |
2412 |
|
2412 | |||
2413 | def diffsinglehunkinline(hunklines): |
|
2413 | def diffsinglehunkinline(hunklines): | |
2414 | """yield tokens for a list of lines in a single hunk, with inline colors""" |
|
2414 | """yield tokens for a list of lines in a single hunk, with inline colors""" | |
2415 | # prepare deleted, and inserted content |
|
2415 | # prepare deleted, and inserted content | |
2416 | a = '' |
|
2416 | a = '' | |
2417 | b = '' |
|
2417 | b = '' | |
2418 | for line in hunklines: |
|
2418 | for line in hunklines: | |
2419 | if line[0:1] == '-': |
|
2419 | if line[0:1] == '-': | |
2420 | a += line[1:] |
|
2420 | a += line[1:] | |
2421 | elif line[0:1] == '+': |
|
2421 | elif line[0:1] == '+': | |
2422 | b += line[1:] |
|
2422 | b += line[1:] | |
2423 | else: |
|
2423 | else: | |
2424 | raise error.ProgrammingError('unexpected hunk line: %s' % line) |
|
2424 | raise error.ProgrammingError('unexpected hunk line: %s' % line) | |
2425 | # fast path: if either side is empty, use diffsinglehunk |
|
2425 | # fast path: if either side is empty, use diffsinglehunk | |
2426 | if not a or not b: |
|
2426 | if not a or not b: | |
2427 | for t in diffsinglehunk(hunklines): |
|
2427 | for t in diffsinglehunk(hunklines): | |
2428 | yield t |
|
2428 | yield t | |
2429 | return |
|
2429 | return | |
2430 | # re-split the content into words |
|
2430 | # re-split the content into words | |
2431 | al = wordsplitter.findall(a) |
|
2431 | al = wordsplitter.findall(a) | |
2432 | bl = wordsplitter.findall(b) |
|
2432 | bl = wordsplitter.findall(b) | |
2433 | # re-arrange the words to lines since the diff algorithm is line-based |
|
2433 | # re-arrange the words to lines since the diff algorithm is line-based | |
2434 | aln = [s if s == '\n' else s + '\n' for s in al] |
|
2434 | aln = [s if s == '\n' else s + '\n' for s in al] | |
2435 | bln = [s if s == '\n' else s + '\n' for s in bl] |
|
2435 | bln = [s if s == '\n' else s + '\n' for s in bl] | |
2436 | an = ''.join(aln) |
|
2436 | an = ''.join(aln) | |
2437 | bn = ''.join(bln) |
|
2437 | bn = ''.join(bln) | |
2438 | # run the diff algorithm, prepare atokens and btokens |
|
2438 | # run the diff algorithm, prepare atokens and btokens | |
2439 | atokens = [] |
|
2439 | atokens = [] | |
2440 | btokens = [] |
|
2440 | btokens = [] | |
2441 | blocks = mdiff.allblocks(an, bn, lines1=aln, lines2=bln) |
|
2441 | blocks = mdiff.allblocks(an, bn, lines1=aln, lines2=bln) | |
2442 | for (a1, a2, b1, b2), btype in blocks: |
|
2442 | for (a1, a2, b1, b2), btype in blocks: | |
2443 | changed = btype == '!' |
|
2443 | changed = btype == '!' | |
2444 | for token in mdiff.splitnewlines(''.join(al[a1:a2])): |
|
2444 | for token in mdiff.splitnewlines(''.join(al[a1:a2])): | |
2445 | atokens.append((changed, token)) |
|
2445 | atokens.append((changed, token)) | |
2446 | for token in mdiff.splitnewlines(''.join(bl[b1:b2])): |
|
2446 | for token in mdiff.splitnewlines(''.join(bl[b1:b2])): | |
2447 | btokens.append((changed, token)) |
|
2447 | btokens.append((changed, token)) | |
2448 |
|
2448 | |||
2449 | # yield deleted tokens, then inserted ones |
|
2449 | # yield deleted tokens, then inserted ones | |
2450 | for prefix, label, tokens in [('-', 'diff.deleted', atokens), |
|
2450 | for prefix, label, tokens in [('-', 'diff.deleted', atokens), | |
2451 | ('+', 'diff.inserted', btokens)]: |
|
2451 | ('+', 'diff.inserted', btokens)]: | |
2452 | nextisnewline = True |
|
2452 | nextisnewline = True | |
2453 | for changed, token in tokens: |
|
2453 | for changed, token in tokens: | |
2454 | if nextisnewline: |
|
2454 | if nextisnewline: | |
2455 | yield (prefix, label) |
|
2455 | yield (prefix, label) | |
2456 | nextisnewline = False |
|
2456 | nextisnewline = False | |
2457 | # special handling line end |
|
2457 | # special handling line end | |
2458 | isendofline = token.endswith('\n') |
|
2458 | isendofline = token.endswith('\n') | |
2459 | if isendofline: |
|
2459 | if isendofline: | |
2460 | chomp = token[:-1] # chomp |
|
2460 | chomp = token[:-1] # chomp | |
2461 | if chomp.endswith('\r'): |
|
2461 | if chomp.endswith('\r'): | |
2462 | chomp = chomp[:-1] |
|
2462 | chomp = chomp[:-1] | |
2463 | endofline = token[len(chomp):] |
|
2463 | endofline = token[len(chomp):] | |
2464 | token = chomp.rstrip() # detect spaces at the end |
|
2464 | token = chomp.rstrip() # detect spaces at the end | |
2465 | endspaces = chomp[len(token):] |
|
2465 | endspaces = chomp[len(token):] | |
2466 | # scan tabs |
|
2466 | # scan tabs | |
2467 | for maybetab in tabsplitter.findall(token): |
|
2467 | for maybetab in tabsplitter.findall(token): | |
2468 | if b'\t' == maybetab[0:1]: |
|
2468 | if b'\t' == maybetab[0:1]: | |
2469 | currentlabel = 'diff.tab' |
|
2469 | currentlabel = 'diff.tab' | |
2470 | else: |
|
2470 | else: | |
2471 | if changed: |
|
2471 | if changed: | |
2472 | currentlabel = label + '.changed' |
|
2472 | currentlabel = label + '.changed' | |
2473 | else: |
|
2473 | else: | |
2474 | currentlabel = label + '.unchanged' |
|
2474 | currentlabel = label + '.unchanged' | |
2475 | yield (maybetab, currentlabel) |
|
2475 | yield (maybetab, currentlabel) | |
2476 | if isendofline: |
|
2476 | if isendofline: | |
2477 | if endspaces: |
|
2477 | if endspaces: | |
2478 | yield (endspaces, 'diff.trailingwhitespace') |
|
2478 | yield (endspaces, 'diff.trailingwhitespace') | |
2479 | yield (endofline, '') |
|
2479 | yield (endofline, '') | |
2480 | nextisnewline = True |
|
2480 | nextisnewline = True | |
2481 |
|
2481 | |||
2482 | def difflabel(func, *args, **kw): |
|
2482 | def difflabel(func, *args, **kw): | |
2483 | '''yields 2-tuples of (output, label) based on the output of func()''' |
|
2483 | '''yields 2-tuples of (output, label) based on the output of func()''' | |
2484 | if kw.get(r'opts') and kw[r'opts'].worddiff: |
|
2484 | if kw.get(r'opts') and kw[r'opts'].worddiff: | |
2485 | dodiffhunk = diffsinglehunkinline |
|
2485 | dodiffhunk = diffsinglehunkinline | |
2486 | else: |
|
2486 | else: | |
2487 | dodiffhunk = diffsinglehunk |
|
2487 | dodiffhunk = diffsinglehunk | |
2488 | headprefixes = [('diff', 'diff.diffline'), |
|
2488 | headprefixes = [('diff', 'diff.diffline'), | |
2489 | ('copy', 'diff.extended'), |
|
2489 | ('copy', 'diff.extended'), | |
2490 | ('rename', 'diff.extended'), |
|
2490 | ('rename', 'diff.extended'), | |
2491 | ('old', 'diff.extended'), |
|
2491 | ('old', 'diff.extended'), | |
2492 | ('new', 'diff.extended'), |
|
2492 | ('new', 'diff.extended'), | |
2493 | ('deleted', 'diff.extended'), |
|
2493 | ('deleted', 'diff.extended'), | |
2494 | ('index', 'diff.extended'), |
|
2494 | ('index', 'diff.extended'), | |
2495 | ('similarity', 'diff.extended'), |
|
2495 | ('similarity', 'diff.extended'), | |
2496 | ('---', 'diff.file_a'), |
|
2496 | ('---', 'diff.file_a'), | |
2497 | ('+++', 'diff.file_b')] |
|
2497 | ('+++', 'diff.file_b')] | |
2498 | textprefixes = [('@', 'diff.hunk'), |
|
2498 | textprefixes = [('@', 'diff.hunk'), | |
2499 | # - and + are handled by diffsinglehunk |
|
2499 | # - and + are handled by diffsinglehunk | |
2500 | ] |
|
2500 | ] | |
2501 | head = False |
|
2501 | head = False | |
2502 |
|
2502 | |||
2503 | # buffers a hunk, i.e. adjacent "-", "+" lines without other changes. |
|
2503 | # buffers a hunk, i.e. adjacent "-", "+" lines without other changes. | |
2504 | hunkbuffer = [] |
|
2504 | hunkbuffer = [] | |
2505 | def consumehunkbuffer(): |
|
2505 | def consumehunkbuffer(): | |
2506 | if hunkbuffer: |
|
2506 | if hunkbuffer: | |
2507 | for token in dodiffhunk(hunkbuffer): |
|
2507 | for token in dodiffhunk(hunkbuffer): | |
2508 | yield token |
|
2508 | yield token | |
2509 | hunkbuffer[:] = [] |
|
2509 | hunkbuffer[:] = [] | |
2510 |
|
2510 | |||
2511 | for chunk in func(*args, **kw): |
|
2511 | for chunk in func(*args, **kw): | |
2512 | lines = chunk.split('\n') |
|
2512 | lines = chunk.split('\n') | |
2513 | linecount = len(lines) |
|
2513 | linecount = len(lines) | |
2514 | for i, line in enumerate(lines): |
|
2514 | for i, line in enumerate(lines): | |
2515 | if head: |
|
2515 | if head: | |
2516 | if line.startswith('@'): |
|
2516 | if line.startswith('@'): | |
2517 | head = False |
|
2517 | head = False | |
2518 | else: |
|
2518 | else: | |
2519 | if line and not line.startswith((' ', '+', '-', '@', '\\')): |
|
2519 | if line and not line.startswith((' ', '+', '-', '@', '\\')): | |
2520 | head = True |
|
2520 | head = True | |
2521 | diffline = False |
|
2521 | diffline = False | |
2522 | if not head and line and line.startswith(('+', '-')): |
|
2522 | if not head and line and line.startswith(('+', '-')): | |
2523 | diffline = True |
|
2523 | diffline = True | |
2524 |
|
2524 | |||
2525 | prefixes = textprefixes |
|
2525 | prefixes = textprefixes | |
2526 | if head: |
|
2526 | if head: | |
2527 | prefixes = headprefixes |
|
2527 | prefixes = headprefixes | |
2528 | if diffline: |
|
2528 | if diffline: | |
2529 | # buffered |
|
2529 | # buffered | |
2530 | bufferedline = line |
|
2530 | bufferedline = line | |
2531 | if i + 1 < linecount: |
|
2531 | if i + 1 < linecount: | |
2532 | bufferedline += "\n" |
|
2532 | bufferedline += "\n" | |
2533 | hunkbuffer.append(bufferedline) |
|
2533 | hunkbuffer.append(bufferedline) | |
2534 | else: |
|
2534 | else: | |
2535 | # unbuffered |
|
2535 | # unbuffered | |
2536 | for token in consumehunkbuffer(): |
|
2536 | for token in consumehunkbuffer(): | |
2537 | yield token |
|
2537 | yield token | |
2538 | stripline = line.rstrip() |
|
2538 | stripline = line.rstrip() | |
2539 | for prefix, label in prefixes: |
|
2539 | for prefix, label in prefixes: | |
2540 | if stripline.startswith(prefix): |
|
2540 | if stripline.startswith(prefix): | |
2541 | yield (stripline, label) |
|
2541 | yield (stripline, label) | |
2542 | if line != stripline: |
|
2542 | if line != stripline: | |
2543 | yield (line[len(stripline):], |
|
2543 | yield (line[len(stripline):], | |
2544 | 'diff.trailingwhitespace') |
|
2544 | 'diff.trailingwhitespace') | |
2545 | break |
|
2545 | break | |
2546 | else: |
|
2546 | else: | |
2547 | yield (line, '') |
|
2547 | yield (line, '') | |
2548 | if i + 1 < linecount: |
|
2548 | if i + 1 < linecount: | |
2549 | yield ('\n', '') |
|
2549 | yield ('\n', '') | |
2550 | for token in consumehunkbuffer(): |
|
2550 | for token in consumehunkbuffer(): | |
2551 | yield token |
|
2551 | yield token | |
2552 |
|
2552 | |||
2553 | def diffui(*args, **kw): |
|
2553 | def diffui(*args, **kw): | |
2554 | '''like diff(), but yields 2-tuples of (output, label) for ui.write()''' |
|
2554 | '''like diff(), but yields 2-tuples of (output, label) for ui.write()''' | |
2555 | return difflabel(diff, *args, **kw) |
|
2555 | return difflabel(diff, *args, **kw) | |
2556 |
|
2556 | |||
2557 | def _filepairs(modified, added, removed, copy, opts): |
|
2557 | def _filepairs(modified, added, removed, copy, opts): | |
2558 | '''generates tuples (f1, f2, copyop), where f1 is the name of the file |
|
2558 | '''generates tuples (f1, f2, copyop), where f1 is the name of the file | |
2559 | before and f2 is the the name after. For added files, f1 will be None, |
|
2559 | before and f2 is the the name after. For added files, f1 will be None, | |
2560 | and for removed files, f2 will be None. copyop may be set to None, 'copy' |
|
2560 | and for removed files, f2 will be None. copyop may be set to None, 'copy' | |
2561 | or 'rename' (the latter two only if opts.git is set).''' |
|
2561 | or 'rename' (the latter two only if opts.git is set).''' | |
2562 | gone = set() |
|
2562 | gone = set() | |
2563 |
|
2563 | |||
2564 | copyto = dict([(v, k) for k, v in copy.items()]) |
|
2564 | copyto = dict([(v, k) for k, v in copy.items()]) | |
2565 |
|
2565 | |||
2566 | addedset, removedset = set(added), set(removed) |
|
2566 | addedset, removedset = set(added), set(removed) | |
2567 |
|
2567 | |||
2568 | for f in sorted(modified + added + removed): |
|
2568 | for f in sorted(modified + added + removed): | |
2569 | copyop = None |
|
2569 | copyop = None | |
2570 | f1, f2 = f, f |
|
2570 | f1, f2 = f, f | |
2571 | if f in addedset: |
|
2571 | if f in addedset: | |
2572 | f1 = None |
|
2572 | f1 = None | |
2573 | if f in copy: |
|
2573 | if f in copy: | |
2574 | if opts.git: |
|
2574 | if opts.git: | |
2575 | f1 = copy[f] |
|
2575 | f1 = copy[f] | |
2576 | if f1 in removedset and f1 not in gone: |
|
2576 | if f1 in removedset and f1 not in gone: | |
2577 | copyop = 'rename' |
|
2577 | copyop = 'rename' | |
2578 | gone.add(f1) |
|
2578 | gone.add(f1) | |
2579 | else: |
|
2579 | else: | |
2580 | copyop = 'copy' |
|
2580 | copyop = 'copy' | |
2581 | elif f in removedset: |
|
2581 | elif f in removedset: | |
2582 | f2 = None |
|
2582 | f2 = None | |
2583 | if opts.git: |
|
2583 | if opts.git: | |
2584 | # have we already reported a copy above? |
|
2584 | # have we already reported a copy above? | |
2585 | if (f in copyto and copyto[f] in addedset |
|
2585 | if (f in copyto and copyto[f] in addedset | |
2586 | and copy[copyto[f]] == f): |
|
2586 | and copy[copyto[f]] == f): | |
2587 | continue |
|
2587 | continue | |
2588 | yield f1, f2, copyop |
|
2588 | yield f1, f2, copyop | |
2589 |
|
2589 | |||
2590 | def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, |
|
2590 | def trydiff(repo, revs, ctx1, ctx2, modified, added, removed, | |
2591 | copy, getfilectx, opts, losedatafn, pathfn): |
|
2591 | copy, getfilectx, opts, losedatafn, pathfn): | |
2592 | '''given input data, generate a diff and yield it in blocks |
|
2592 | '''given input data, generate a diff and yield it in blocks | |
2593 |
|
2593 | |||
2594 | If generating a diff would lose data like flags or binary data and |
|
2594 | If generating a diff would lose data like flags or binary data and | |
2595 | losedatafn is not None, it will be called. |
|
2595 | losedatafn is not None, it will be called. | |
2596 |
|
2596 | |||
2597 | pathfn is applied to every path in the diff output. |
|
2597 | pathfn is applied to every path in the diff output. | |
2598 | ''' |
|
2598 | ''' | |
2599 |
|
2599 | |||
2600 | def gitindex(text): |
|
2600 | def gitindex(text): | |
2601 | if not text: |
|
2601 | if not text: | |
2602 | text = "" |
|
2602 | text = "" | |
2603 | l = len(text) |
|
2603 | l = len(text) | |
2604 | s = hashlib.sha1('blob %d\0' % l) |
|
2604 | s = hashlib.sha1('blob %d\0' % l) | |
2605 | s.update(text) |
|
2605 | s.update(text) | |
2606 | return hex(s.digest()) |
|
2606 | return hex(s.digest()) | |
2607 |
|
2607 | |||
2608 | if opts.noprefix: |
|
2608 | if opts.noprefix: | |
2609 | aprefix = bprefix = '' |
|
2609 | aprefix = bprefix = '' | |
2610 | else: |
|
2610 | else: | |
2611 | aprefix = 'a/' |
|
2611 | aprefix = 'a/' | |
2612 | bprefix = 'b/' |
|
2612 | bprefix = 'b/' | |
2613 |
|
2613 | |||
2614 | def diffline(f, revs): |
|
2614 | def diffline(f, revs): | |
2615 | revinfo = ' '.join(["-r %s" % rev for rev in revs]) |
|
2615 | revinfo = ' '.join(["-r %s" % rev for rev in revs]) | |
2616 | return 'diff %s %s' % (revinfo, f) |
|
2616 | return 'diff %s %s' % (revinfo, f) | |
2617 |
|
2617 | |||
2618 | def isempty(fctx): |
|
2618 | def isempty(fctx): | |
2619 | return fctx is None or fctx.size() == 0 |
|
2619 | return fctx is None or fctx.size() == 0 | |
2620 |
|
2620 | |||
2621 | date1 = dateutil.datestr(ctx1.date()) |
|
2621 | date1 = dateutil.datestr(ctx1.date()) | |
2622 | date2 = dateutil.datestr(ctx2.date()) |
|
2622 | date2 = dateutil.datestr(ctx2.date()) | |
2623 |
|
2623 | |||
2624 | gitmode = {'l': '120000', 'x': '100755', '': '100644'} |
|
2624 | gitmode = {'l': '120000', 'x': '100755', '': '100644'} | |
2625 |
|
2625 | |||
2626 | if not pathfn: |
|
2626 | if not pathfn: | |
2627 | pathfn = lambda f: f |
|
2627 | pathfn = lambda f: f | |
2628 |
|
2628 | |||
2629 | for f1, f2, copyop in _filepairs(modified, added, removed, copy, opts): |
|
2629 | for f1, f2, copyop in _filepairs(modified, added, removed, copy, opts): | |
2630 | content1 = None |
|
2630 | content1 = None | |
2631 | content2 = None |
|
2631 | content2 = None | |
2632 | fctx1 = None |
|
2632 | fctx1 = None | |
2633 | fctx2 = None |
|
2633 | fctx2 = None | |
2634 | flag1 = None |
|
2634 | flag1 = None | |
2635 | flag2 = None |
|
2635 | flag2 = None | |
2636 | if f1: |
|
2636 | if f1: | |
2637 | fctx1 = getfilectx(f1, ctx1) |
|
2637 | fctx1 = getfilectx(f1, ctx1) | |
2638 | if opts.git or losedatafn: |
|
2638 | if opts.git or losedatafn: | |
2639 | flag1 = ctx1.flags(f1) |
|
2639 | flag1 = ctx1.flags(f1) | |
2640 | if f2: |
|
2640 | if f2: | |
2641 | fctx2 = getfilectx(f2, ctx2) |
|
2641 | fctx2 = getfilectx(f2, ctx2) | |
2642 | if opts.git or losedatafn: |
|
2642 | if opts.git or losedatafn: | |
2643 | flag2 = ctx2.flags(f2) |
|
2643 | flag2 = ctx2.flags(f2) | |
2644 | # if binary is True, output "summary" or "base85", but not "text diff" |
|
2644 | # if binary is True, output "summary" or "base85", but not "text diff" | |
2645 | if opts.text: |
|
2645 | if opts.text: | |
2646 | binary = False |
|
2646 | binary = False | |
2647 | else: |
|
2647 | else: | |
2648 | binary = any(f.isbinary() for f in [fctx1, fctx2] if f is not None) |
|
2648 | binary = any(f.isbinary() for f in [fctx1, fctx2] if f is not None) | |
2649 |
|
2649 | |||
2650 | if losedatafn and not opts.git: |
|
2650 | if losedatafn and not opts.git: | |
2651 | if (binary or |
|
2651 | if (binary or | |
2652 | # copy/rename |
|
2652 | # copy/rename | |
2653 | f2 in copy or |
|
2653 | f2 in copy or | |
2654 | # empty file creation |
|
2654 | # empty file creation | |
2655 | (not f1 and isempty(fctx2)) or |
|
2655 | (not f1 and isempty(fctx2)) or | |
2656 | # empty file deletion |
|
2656 | # empty file deletion | |
2657 | (isempty(fctx1) and not f2) or |
|
2657 | (isempty(fctx1) and not f2) or | |
2658 | # create with flags |
|
2658 | # create with flags | |
2659 | (not f1 and flag2) or |
|
2659 | (not f1 and flag2) or | |
2660 | # change flags |
|
2660 | # change flags | |
2661 | (f1 and f2 and flag1 != flag2)): |
|
2661 | (f1 and f2 and flag1 != flag2)): | |
2662 | losedatafn(f2 or f1) |
|
2662 | losedatafn(f2 or f1) | |
2663 |
|
2663 | |||
2664 | path1 = pathfn(f1 or f2) |
|
2664 | path1 = pathfn(f1 or f2) | |
2665 | path2 = pathfn(f2 or f1) |
|
2665 | path2 = pathfn(f2 or f1) | |
2666 | header = [] |
|
2666 | header = [] | |
2667 | if opts.git: |
|
2667 | if opts.git: | |
2668 | header.append('diff --git %s%s %s%s' % |
|
2668 | header.append('diff --git %s%s %s%s' % | |
2669 | (aprefix, path1, bprefix, path2)) |
|
2669 | (aprefix, path1, bprefix, path2)) | |
2670 | if not f1: # added |
|
2670 | if not f1: # added | |
2671 | header.append('new file mode %s' % gitmode[flag2]) |
|
2671 | header.append('new file mode %s' % gitmode[flag2]) | |
2672 | elif not f2: # removed |
|
2672 | elif not f2: # removed | |
2673 | header.append('deleted file mode %s' % gitmode[flag1]) |
|
2673 | header.append('deleted file mode %s' % gitmode[flag1]) | |
2674 | else: # modified/copied/renamed |
|
2674 | else: # modified/copied/renamed | |
2675 | mode1, mode2 = gitmode[flag1], gitmode[flag2] |
|
2675 | mode1, mode2 = gitmode[flag1], gitmode[flag2] | |
2676 | if mode1 != mode2: |
|
2676 | if mode1 != mode2: | |
2677 | header.append('old mode %s' % mode1) |
|
2677 | header.append('old mode %s' % mode1) | |
2678 | header.append('new mode %s' % mode2) |
|
2678 | header.append('new mode %s' % mode2) | |
2679 | if copyop is not None: |
|
2679 | if copyop is not None: | |
2680 | if opts.showsimilarity: |
|
2680 | if opts.showsimilarity: | |
2681 | sim = similar.score(ctx1[path1], ctx2[path2]) * 100 |
|
2681 | sim = similar.score(ctx1[path1], ctx2[path2]) * 100 | |
2682 | header.append('similarity index %d%%' % sim) |
|
2682 | header.append('similarity index %d%%' % sim) | |
2683 | header.append('%s from %s' % (copyop, path1)) |
|
2683 | header.append('%s from %s' % (copyop, path1)) | |
2684 | header.append('%s to %s' % (copyop, path2)) |
|
2684 | header.append('%s to %s' % (copyop, path2)) | |
2685 |
elif revs |
|
2685 | elif revs: | |
2686 | header.append(diffline(path1, revs)) |
|
2686 | header.append(diffline(path1, revs)) | |
2687 |
|
2687 | |||
2688 | # fctx.is | diffopts | what to | is fctx.data() |
|
2688 | # fctx.is | diffopts | what to | is fctx.data() | |
2689 | # binary() | text nobinary git index | output? | outputted? |
|
2689 | # binary() | text nobinary git index | output? | outputted? | |
2690 | # ------------------------------------|---------------------------- |
|
2690 | # ------------------------------------|---------------------------- | |
2691 | # yes | no no no * | summary | no |
|
2691 | # yes | no no no * | summary | no | |
2692 | # yes | no no yes * | base85 | yes |
|
2692 | # yes | no no yes * | base85 | yes | |
2693 | # yes | no yes no * | summary | no |
|
2693 | # yes | no yes no * | summary | no | |
2694 | # yes | no yes yes 0 | summary | no |
|
2694 | # yes | no yes yes 0 | summary | no | |
2695 | # yes | no yes yes >0 | summary | semi [1] |
|
2695 | # yes | no yes yes >0 | summary | semi [1] | |
2696 | # yes | yes * * * | text diff | yes |
|
2696 | # yes | yes * * * | text diff | yes | |
2697 | # no | * * * * | text diff | yes |
|
2697 | # no | * * * * | text diff | yes | |
2698 | # [1]: hash(fctx.data()) is outputted. so fctx.data() cannot be faked |
|
2698 | # [1]: hash(fctx.data()) is outputted. so fctx.data() cannot be faked | |
2699 | if binary and (not opts.git or (opts.git and opts.nobinary and not |
|
2699 | if binary and (not opts.git or (opts.git and opts.nobinary and not | |
2700 | opts.index)): |
|
2700 | opts.index)): | |
2701 | # fast path: no binary content will be displayed, content1 and |
|
2701 | # fast path: no binary content will be displayed, content1 and | |
2702 | # content2 are only used for equivalent test. cmp() could have a |
|
2702 | # content2 are only used for equivalent test. cmp() could have a | |
2703 | # fast path. |
|
2703 | # fast path. | |
2704 | if fctx1 is not None: |
|
2704 | if fctx1 is not None: | |
2705 | content1 = b'\0' |
|
2705 | content1 = b'\0' | |
2706 | if fctx2 is not None: |
|
2706 | if fctx2 is not None: | |
2707 | if fctx1 is not None and not fctx1.cmp(fctx2): |
|
2707 | if fctx1 is not None and not fctx1.cmp(fctx2): | |
2708 | content2 = b'\0' # not different |
|
2708 | content2 = b'\0' # not different | |
2709 | else: |
|
2709 | else: | |
2710 | content2 = b'\0\0' |
|
2710 | content2 = b'\0\0' | |
2711 | else: |
|
2711 | else: | |
2712 | # normal path: load contents |
|
2712 | # normal path: load contents | |
2713 | if fctx1 is not None: |
|
2713 | if fctx1 is not None: | |
2714 | content1 = fctx1.data() |
|
2714 | content1 = fctx1.data() | |
2715 | if fctx2 is not None: |
|
2715 | if fctx2 is not None: | |
2716 | content2 = fctx2.data() |
|
2716 | content2 = fctx2.data() | |
2717 |
|
2717 | |||
2718 | if binary and opts.git and not opts.nobinary: |
|
2718 | if binary and opts.git and not opts.nobinary: | |
2719 | text = mdiff.b85diff(content1, content2) |
|
2719 | text = mdiff.b85diff(content1, content2) | |
2720 | if text: |
|
2720 | if text: | |
2721 | header.append('index %s..%s' % |
|
2721 | header.append('index %s..%s' % | |
2722 | (gitindex(content1), gitindex(content2))) |
|
2722 | (gitindex(content1), gitindex(content2))) | |
2723 | hunks = (None, [text]), |
|
2723 | hunks = (None, [text]), | |
2724 | else: |
|
2724 | else: | |
2725 | if opts.git and opts.index > 0: |
|
2725 | if opts.git and opts.index > 0: | |
2726 | flag = flag1 |
|
2726 | flag = flag1 | |
2727 | if flag is None: |
|
2727 | if flag is None: | |
2728 | flag = flag2 |
|
2728 | flag = flag2 | |
2729 | header.append('index %s..%s %s' % |
|
2729 | header.append('index %s..%s %s' % | |
2730 | (gitindex(content1)[0:opts.index], |
|
2730 | (gitindex(content1)[0:opts.index], | |
2731 | gitindex(content2)[0:opts.index], |
|
2731 | gitindex(content2)[0:opts.index], | |
2732 | gitmode[flag])) |
|
2732 | gitmode[flag])) | |
2733 |
|
2733 | |||
2734 | uheaders, hunks = mdiff.unidiff(content1, date1, |
|
2734 | uheaders, hunks = mdiff.unidiff(content1, date1, | |
2735 | content2, date2, |
|
2735 | content2, date2, | |
2736 | path1, path2, |
|
2736 | path1, path2, | |
2737 | binary=binary, opts=opts) |
|
2737 | binary=binary, opts=opts) | |
2738 | header.extend(uheaders) |
|
2738 | header.extend(uheaders) | |
2739 | yield fctx1, fctx2, header, hunks |
|
2739 | yield fctx1, fctx2, header, hunks | |
2740 |
|
2740 | |||
2741 | def diffstatsum(stats): |
|
2741 | def diffstatsum(stats): | |
2742 | maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False |
|
2742 | maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False | |
2743 | for f, a, r, b in stats: |
|
2743 | for f, a, r, b in stats: | |
2744 | maxfile = max(maxfile, encoding.colwidth(f)) |
|
2744 | maxfile = max(maxfile, encoding.colwidth(f)) | |
2745 | maxtotal = max(maxtotal, a + r) |
|
2745 | maxtotal = max(maxtotal, a + r) | |
2746 | addtotal += a |
|
2746 | addtotal += a | |
2747 | removetotal += r |
|
2747 | removetotal += r | |
2748 | binary = binary or b |
|
2748 | binary = binary or b | |
2749 |
|
2749 | |||
2750 | return maxfile, maxtotal, addtotal, removetotal, binary |
|
2750 | return maxfile, maxtotal, addtotal, removetotal, binary | |
2751 |
|
2751 | |||
2752 | def diffstatdata(lines): |
|
2752 | def diffstatdata(lines): | |
2753 | diffre = re.compile(br'^diff .*-r [a-z0-9]+\s(.*)$') |
|
2753 | diffre = re.compile(br'^diff .*-r [a-z0-9]+\s(.*)$') | |
2754 |
|
2754 | |||
2755 | results = [] |
|
2755 | results = [] | |
2756 | filename, adds, removes, isbinary = None, 0, 0, False |
|
2756 | filename, adds, removes, isbinary = None, 0, 0, False | |
2757 |
|
2757 | |||
2758 | def addresult(): |
|
2758 | def addresult(): | |
2759 | if filename: |
|
2759 | if filename: | |
2760 | results.append((filename, adds, removes, isbinary)) |
|
2760 | results.append((filename, adds, removes, isbinary)) | |
2761 |
|
2761 | |||
2762 | # inheader is used to track if a line is in the |
|
2762 | # inheader is used to track if a line is in the | |
2763 | # header portion of the diff. This helps properly account |
|
2763 | # header portion of the diff. This helps properly account | |
2764 | # for lines that start with '--' or '++' |
|
2764 | # for lines that start with '--' or '++' | |
2765 | inheader = False |
|
2765 | inheader = False | |
2766 |
|
2766 | |||
2767 | for line in lines: |
|
2767 | for line in lines: | |
2768 | if line.startswith('diff'): |
|
2768 | if line.startswith('diff'): | |
2769 | addresult() |
|
2769 | addresult() | |
2770 | # starting a new file diff |
|
2770 | # starting a new file diff | |
2771 | # set numbers to 0 and reset inheader |
|
2771 | # set numbers to 0 and reset inheader | |
2772 | inheader = True |
|
2772 | inheader = True | |
2773 | adds, removes, isbinary = 0, 0, False |
|
2773 | adds, removes, isbinary = 0, 0, False | |
2774 | if line.startswith('diff --git a/'): |
|
2774 | if line.startswith('diff --git a/'): | |
2775 | filename = gitre.search(line).group(2) |
|
2775 | filename = gitre.search(line).group(2) | |
2776 | elif line.startswith('diff -r'): |
|
2776 | elif line.startswith('diff -r'): | |
2777 | # format: "diff -r ... -r ... filename" |
|
2777 | # format: "diff -r ... -r ... filename" | |
2778 | filename = diffre.search(line).group(1) |
|
2778 | filename = diffre.search(line).group(1) | |
2779 | elif line.startswith('@@'): |
|
2779 | elif line.startswith('@@'): | |
2780 | inheader = False |
|
2780 | inheader = False | |
2781 | elif line.startswith('+') and not inheader: |
|
2781 | elif line.startswith('+') and not inheader: | |
2782 | adds += 1 |
|
2782 | adds += 1 | |
2783 | elif line.startswith('-') and not inheader: |
|
2783 | elif line.startswith('-') and not inheader: | |
2784 | removes += 1 |
|
2784 | removes += 1 | |
2785 | elif (line.startswith('GIT binary patch') or |
|
2785 | elif (line.startswith('GIT binary patch') or | |
2786 | line.startswith('Binary file')): |
|
2786 | line.startswith('Binary file')): | |
2787 | isbinary = True |
|
2787 | isbinary = True | |
2788 | elif line.startswith('rename from'): |
|
2788 | elif line.startswith('rename from'): | |
2789 | filename = line[12:] |
|
2789 | filename = line[12:] | |
2790 | elif line.startswith('rename to'): |
|
2790 | elif line.startswith('rename to'): | |
2791 | filename += ' => %s' % line[10:] |
|
2791 | filename += ' => %s' % line[10:] | |
2792 | addresult() |
|
2792 | addresult() | |
2793 | return results |
|
2793 | return results | |
2794 |
|
2794 | |||
2795 | def diffstat(lines, width=80): |
|
2795 | def diffstat(lines, width=80): | |
2796 | output = [] |
|
2796 | output = [] | |
2797 | stats = diffstatdata(lines) |
|
2797 | stats = diffstatdata(lines) | |
2798 | maxname, maxtotal, totaladds, totalremoves, hasbinary = diffstatsum(stats) |
|
2798 | maxname, maxtotal, totaladds, totalremoves, hasbinary = diffstatsum(stats) | |
2799 |
|
2799 | |||
2800 | countwidth = len(str(maxtotal)) |
|
2800 | countwidth = len(str(maxtotal)) | |
2801 | if hasbinary and countwidth < 3: |
|
2801 | if hasbinary and countwidth < 3: | |
2802 | countwidth = 3 |
|
2802 | countwidth = 3 | |
2803 | graphwidth = width - countwidth - maxname - 6 |
|
2803 | graphwidth = width - countwidth - maxname - 6 | |
2804 | if graphwidth < 10: |
|
2804 | if graphwidth < 10: | |
2805 | graphwidth = 10 |
|
2805 | graphwidth = 10 | |
2806 |
|
2806 | |||
2807 | def scale(i): |
|
2807 | def scale(i): | |
2808 | if maxtotal <= graphwidth: |
|
2808 | if maxtotal <= graphwidth: | |
2809 | return i |
|
2809 | return i | |
2810 | # If diffstat runs out of room it doesn't print anything, |
|
2810 | # If diffstat runs out of room it doesn't print anything, | |
2811 | # which isn't very useful, so always print at least one + or - |
|
2811 | # which isn't very useful, so always print at least one + or - | |
2812 | # if there were at least some changes. |
|
2812 | # if there were at least some changes. | |
2813 | return max(i * graphwidth // maxtotal, int(bool(i))) |
|
2813 | return max(i * graphwidth // maxtotal, int(bool(i))) | |
2814 |
|
2814 | |||
2815 | for filename, adds, removes, isbinary in stats: |
|
2815 | for filename, adds, removes, isbinary in stats: | |
2816 | if isbinary: |
|
2816 | if isbinary: | |
2817 | count = 'Bin' |
|
2817 | count = 'Bin' | |
2818 | else: |
|
2818 | else: | |
2819 | count = '%d' % (adds + removes) |
|
2819 | count = '%d' % (adds + removes) | |
2820 | pluses = '+' * scale(adds) |
|
2820 | pluses = '+' * scale(adds) | |
2821 | minuses = '-' * scale(removes) |
|
2821 | minuses = '-' * scale(removes) | |
2822 | output.append(' %s%s | %*s %s%s\n' % |
|
2822 | output.append(' %s%s | %*s %s%s\n' % | |
2823 | (filename, ' ' * (maxname - encoding.colwidth(filename)), |
|
2823 | (filename, ' ' * (maxname - encoding.colwidth(filename)), | |
2824 | countwidth, count, pluses, minuses)) |
|
2824 | countwidth, count, pluses, minuses)) | |
2825 |
|
2825 | |||
2826 | if stats: |
|
2826 | if stats: | |
2827 | output.append(_(' %d files changed, %d insertions(+), ' |
|
2827 | output.append(_(' %d files changed, %d insertions(+), ' | |
2828 | '%d deletions(-)\n') |
|
2828 | '%d deletions(-)\n') | |
2829 | % (len(stats), totaladds, totalremoves)) |
|
2829 | % (len(stats), totaladds, totalremoves)) | |
2830 |
|
2830 | |||
2831 | return ''.join(output) |
|
2831 | return ''.join(output) | |
2832 |
|
2832 | |||
2833 | def diffstatui(*args, **kw): |
|
2833 | def diffstatui(*args, **kw): | |
2834 | '''like diffstat(), but yields 2-tuples of (output, label) for |
|
2834 | '''like diffstat(), but yields 2-tuples of (output, label) for | |
2835 | ui.write() |
|
2835 | ui.write() | |
2836 | ''' |
|
2836 | ''' | |
2837 |
|
2837 | |||
2838 | for line in diffstat(*args, **kw).splitlines(): |
|
2838 | for line in diffstat(*args, **kw).splitlines(): | |
2839 | if line and line[-1] in '+-': |
|
2839 | if line and line[-1] in '+-': | |
2840 | name, graph = line.rsplit(' ', 1) |
|
2840 | name, graph = line.rsplit(' ', 1) | |
2841 | yield (name + ' ', '') |
|
2841 | yield (name + ' ', '') | |
2842 | m = re.search(br'\++', graph) |
|
2842 | m = re.search(br'\++', graph) | |
2843 | if m: |
|
2843 | if m: | |
2844 | yield (m.group(0), 'diffstat.inserted') |
|
2844 | yield (m.group(0), 'diffstat.inserted') | |
2845 | m = re.search(br'-+', graph) |
|
2845 | m = re.search(br'-+', graph) | |
2846 | if m: |
|
2846 | if m: | |
2847 | yield (m.group(0), 'diffstat.deleted') |
|
2847 | yield (m.group(0), 'diffstat.deleted') | |
2848 | else: |
|
2848 | else: | |
2849 | yield (line, '') |
|
2849 | yield (line, '') | |
2850 | yield ('\n', '') |
|
2850 | yield ('\n', '') |
@@ -1,833 +1,836 b'' | |||||
1 | commit date test |
|
1 | commit date test | |
2 |
|
2 | |||
3 | $ hg init test |
|
3 | $ hg init test | |
4 | $ cd test |
|
4 | $ cd test | |
5 | $ echo foo > foo |
|
5 | $ echo foo > foo | |
6 | $ hg add foo |
|
6 | $ hg add foo | |
7 | $ cat > $TESTTMP/checkeditform.sh <<EOF |
|
7 | $ cat > $TESTTMP/checkeditform.sh <<EOF | |
8 | > env | grep HGEDITFORM |
|
8 | > env | grep HGEDITFORM | |
9 | > true |
|
9 | > true | |
10 | > EOF |
|
10 | > EOF | |
11 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg commit -m "" |
|
11 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg commit -m "" | |
12 | HGEDITFORM=commit.normal.normal |
|
12 | HGEDITFORM=commit.normal.normal | |
13 | abort: empty commit message |
|
13 | abort: empty commit message | |
14 | [255] |
|
14 | [255] | |
15 | $ hg commit -d '0 0' -m commit-1 |
|
15 | $ hg commit -d '0 0' -m commit-1 | |
16 | $ echo foo >> foo |
|
16 | $ echo foo >> foo | |
17 | $ hg commit -d '1 4444444' -m commit-3 |
|
17 | $ hg commit -d '1 4444444' -m commit-3 | |
18 | hg: parse error: impossible time zone offset: 4444444 |
|
18 | hg: parse error: impossible time zone offset: 4444444 | |
19 | [255] |
|
19 | [255] | |
20 | $ hg commit -d '1 15.1' -m commit-4 |
|
20 | $ hg commit -d '1 15.1' -m commit-4 | |
21 | hg: parse error: invalid date: '1\t15.1' |
|
21 | hg: parse error: invalid date: '1\t15.1' | |
22 | [255] |
|
22 | [255] | |
23 | $ hg commit -d 'foo bar' -m commit-5 |
|
23 | $ hg commit -d 'foo bar' -m commit-5 | |
24 | hg: parse error: invalid date: 'foo bar' |
|
24 | hg: parse error: invalid date: 'foo bar' | |
25 | [255] |
|
25 | [255] | |
26 | $ hg commit -d ' 1 4444' -m commit-6 |
|
26 | $ hg commit -d ' 1 4444' -m commit-6 | |
27 | $ hg commit -d '111111111111 0' -m commit-7 |
|
27 | $ hg commit -d '111111111111 0' -m commit-7 | |
28 | hg: parse error: date exceeds 32 bits: 111111111111 |
|
28 | hg: parse error: date exceeds 32 bits: 111111111111 | |
29 | [255] |
|
29 | [255] | |
30 | $ hg commit -d '-111111111111 0' -m commit-7 |
|
30 | $ hg commit -d '-111111111111 0' -m commit-7 | |
31 | hg: parse error: date exceeds 32 bits: -111111111111 |
|
31 | hg: parse error: date exceeds 32 bits: -111111111111 | |
32 | [255] |
|
32 | [255] | |
33 | $ echo foo >> foo |
|
33 | $ echo foo >> foo | |
34 | $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2 |
|
34 | $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2 | |
35 | $ echo foo >> foo |
|
35 | $ echo foo >> foo | |
36 | $ hg commit -d '-2147483648 0' -m commit-7-3 |
|
36 | $ hg commit -d '-2147483648 0' -m commit-7-3 | |
37 | $ hg log -T '{rev} {date|isodatesec}\n' -l2 |
|
37 | $ hg log -T '{rev} {date|isodatesec}\n' -l2 | |
38 | 3 1901-12-13 20:45:52 +0000 |
|
38 | 3 1901-12-13 20:45:52 +0000 | |
39 | 2 1901-12-13 20:45:52 +0000 |
|
39 | 2 1901-12-13 20:45:52 +0000 | |
40 | $ hg commit -d '1901-12-13 20:45:51 +0000' -m commit-7 |
|
40 | $ hg commit -d '1901-12-13 20:45:51 +0000' -m commit-7 | |
41 | hg: parse error: date exceeds 32 bits: -2147483649 |
|
41 | hg: parse error: date exceeds 32 bits: -2147483649 | |
42 | [255] |
|
42 | [255] | |
43 | $ hg commit -d '-2147483649 0' -m commit-7 |
|
43 | $ hg commit -d '-2147483649 0' -m commit-7 | |
44 | hg: parse error: date exceeds 32 bits: -2147483649 |
|
44 | hg: parse error: date exceeds 32 bits: -2147483649 | |
45 | [255] |
|
45 | [255] | |
46 |
|
46 | |||
47 | commit added file that has been deleted |
|
47 | commit added file that has been deleted | |
48 |
|
48 | |||
49 | $ echo bar > bar |
|
49 | $ echo bar > bar | |
50 | $ hg add bar |
|
50 | $ hg add bar | |
51 | $ rm bar |
|
51 | $ rm bar | |
52 | $ hg commit -m commit-8 |
|
52 | $ hg commit -m commit-8 | |
53 | nothing changed (1 missing files, see 'hg status') |
|
53 | nothing changed (1 missing files, see 'hg status') | |
54 | [1] |
|
54 | [1] | |
55 | $ hg commit -m commit-8-2 bar |
|
55 | $ hg commit -m commit-8-2 bar | |
56 | abort: bar: file not found! |
|
56 | abort: bar: file not found! | |
57 | [255] |
|
57 | [255] | |
58 |
|
58 | |||
59 | $ hg -q revert -a --no-backup |
|
59 | $ hg -q revert -a --no-backup | |
60 |
|
60 | |||
61 | $ mkdir dir |
|
61 | $ mkdir dir | |
62 | $ echo boo > dir/file |
|
62 | $ echo boo > dir/file | |
63 | $ hg add |
|
63 | $ hg add | |
64 | adding dir/file |
|
64 | adding dir/file | |
65 | $ hg -v commit -m commit-9 dir |
|
65 | $ hg -v commit -m commit-9 dir | |
66 | committing files: |
|
66 | committing files: | |
67 | dir/file |
|
67 | dir/file | |
68 | committing manifest |
|
68 | committing manifest | |
69 | committing changelog |
|
69 | committing changelog | |
70 | committed changeset 4:1957363f1ced |
|
70 | committed changeset 4:1957363f1ced | |
71 |
|
71 | |||
72 | $ echo > dir.file |
|
72 | $ echo > dir.file | |
73 | $ hg add |
|
73 | $ hg add | |
74 | adding dir.file |
|
74 | adding dir.file | |
75 | $ hg commit -m commit-10 dir dir.file |
|
75 | $ hg commit -m commit-10 dir dir.file | |
76 | abort: dir: no match under directory! |
|
76 | abort: dir: no match under directory! | |
77 | [255] |
|
77 | [255] | |
78 |
|
78 | |||
79 | $ echo >> dir/file |
|
79 | $ echo >> dir/file | |
80 | $ mkdir bleh |
|
80 | $ mkdir bleh | |
81 | $ mkdir dir2 |
|
81 | $ mkdir dir2 | |
82 | $ cd bleh |
|
82 | $ cd bleh | |
83 | $ hg commit -m commit-11 . |
|
83 | $ hg commit -m commit-11 . | |
84 | abort: bleh: no match under directory! |
|
84 | abort: bleh: no match under directory! | |
85 | [255] |
|
85 | [255] | |
86 | $ hg commit -m commit-12 ../dir ../dir2 |
|
86 | $ hg commit -m commit-12 ../dir ../dir2 | |
87 | abort: dir2: no match under directory! |
|
87 | abort: dir2: no match under directory! | |
88 | [255] |
|
88 | [255] | |
89 | $ hg -v commit -m commit-13 ../dir |
|
89 | $ hg -v commit -m commit-13 ../dir | |
90 | committing files: |
|
90 | committing files: | |
91 | dir/file |
|
91 | dir/file | |
92 | committing manifest |
|
92 | committing manifest | |
93 | committing changelog |
|
93 | committing changelog | |
94 | committed changeset 5:a31d8f87544a |
|
94 | committed changeset 5:a31d8f87544a | |
95 | $ cd .. |
|
95 | $ cd .. | |
96 |
|
96 | |||
97 | $ hg commit -m commit-14 does-not-exist |
|
97 | $ hg commit -m commit-14 does-not-exist | |
98 | abort: does-not-exist: * (glob) |
|
98 | abort: does-not-exist: * (glob) | |
99 | [255] |
|
99 | [255] | |
100 |
|
100 | |||
101 | #if symlink |
|
101 | #if symlink | |
102 | $ ln -s foo baz |
|
102 | $ ln -s foo baz | |
103 | $ hg commit -m commit-15 baz |
|
103 | $ hg commit -m commit-15 baz | |
104 | abort: baz: file not tracked! |
|
104 | abort: baz: file not tracked! | |
105 | [255] |
|
105 | [255] | |
106 | $ rm baz |
|
106 | $ rm baz | |
107 | #endif |
|
107 | #endif | |
108 |
|
108 | |||
109 | $ touch quux |
|
109 | $ touch quux | |
110 | $ hg commit -m commit-16 quux |
|
110 | $ hg commit -m commit-16 quux | |
111 | abort: quux: file not tracked! |
|
111 | abort: quux: file not tracked! | |
112 | [255] |
|
112 | [255] | |
113 | $ echo >> dir/file |
|
113 | $ echo >> dir/file | |
114 | $ hg -v commit -m commit-17 dir/file |
|
114 | $ hg -v commit -m commit-17 dir/file | |
115 | committing files: |
|
115 | committing files: | |
116 | dir/file |
|
116 | dir/file | |
117 | committing manifest |
|
117 | committing manifest | |
118 | committing changelog |
|
118 | committing changelog | |
119 | committed changeset 6:32d054c9d085 |
|
119 | committed changeset 6:32d054c9d085 | |
120 |
|
120 | |||
121 | An empty date was interpreted as epoch origin |
|
121 | An empty date was interpreted as epoch origin | |
122 |
|
122 | |||
123 | $ echo foo >> foo |
|
123 | $ echo foo >> foo | |
124 | $ hg commit -d '' -m commit-no-date --config devel.default-date= |
|
124 | $ hg commit -d '' -m commit-no-date --config devel.default-date= | |
125 | $ hg tip --template '{date|isodate}\n' | grep '1970' |
|
125 | $ hg tip --template '{date|isodate}\n' | grep '1970' | |
126 | [1] |
|
126 | [1] | |
127 |
|
127 | |||
128 | Using the advanced --extra flag |
|
128 | Using the advanced --extra flag | |
129 |
|
129 | |||
130 | $ echo "[extensions]" >> $HGRCPATH |
|
130 | $ echo "[extensions]" >> $HGRCPATH | |
131 | $ echo "commitextras=" >> $HGRCPATH |
|
131 | $ echo "commitextras=" >> $HGRCPATH | |
132 | $ hg status |
|
132 | $ hg status | |
133 | ? quux |
|
133 | ? quux | |
134 | $ hg add quux |
|
134 | $ hg add quux | |
135 | $ hg commit -m "adding internal used extras" --extra amend_source=hash |
|
135 | $ hg commit -m "adding internal used extras" --extra amend_source=hash | |
136 | abort: key 'amend_source' is used internally, can't be set manually |
|
136 | abort: key 'amend_source' is used internally, can't be set manually | |
137 | [255] |
|
137 | [255] | |
138 | $ hg commit -m "special chars in extra" --extra id@phab=214 |
|
138 | $ hg commit -m "special chars in extra" --extra id@phab=214 | |
139 | abort: keys can only contain ascii letters, digits, '_' and '-' |
|
139 | abort: keys can only contain ascii letters, digits, '_' and '-' | |
140 | [255] |
|
140 | [255] | |
141 | $ hg commit -m "empty key" --extra =value |
|
141 | $ hg commit -m "empty key" --extra =value | |
142 | abort: unable to parse '=value', keys can't be empty |
|
142 | abort: unable to parse '=value', keys can't be empty | |
143 | [255] |
|
143 | [255] | |
144 | $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar |
|
144 | $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar | |
145 | $ hg log -r . -T '{extras % "{extra}\n"}' |
|
145 | $ hg log -r . -T '{extras % "{extra}\n"}' | |
146 | branch=default |
|
146 | branch=default | |
147 | oldhash=bar |
|
147 | oldhash=bar | |
148 | sourcehash=foo |
|
148 | sourcehash=foo | |
149 |
|
149 | |||
150 | Failed commit with --addremove should not update dirstate |
|
150 | Failed commit with --addremove should not update dirstate | |
151 |
|
151 | |||
152 | $ echo foo > newfile |
|
152 | $ echo foo > newfile | |
153 | $ hg status |
|
153 | $ hg status | |
154 | ? newfile |
|
154 | ? newfile | |
155 | $ HGEDITOR=false hg ci --addremove |
|
155 | $ HGEDITOR=false hg ci --addremove | |
156 | adding newfile |
|
156 | adding newfile | |
157 | abort: edit failed: false exited with status 1 |
|
157 | abort: edit failed: false exited with status 1 | |
158 | [255] |
|
158 | [255] | |
159 | $ hg status |
|
159 | $ hg status | |
160 | ? newfile |
|
160 | ? newfile | |
161 |
|
161 | |||
162 | Make sure we do not obscure unknown requires file entries (issue2649) |
|
162 | Make sure we do not obscure unknown requires file entries (issue2649) | |
163 |
|
163 | |||
164 | $ echo foo >> foo |
|
164 | $ echo foo >> foo | |
165 | $ echo fake >> .hg/requires |
|
165 | $ echo fake >> .hg/requires | |
166 | $ hg commit -m bla |
|
166 | $ hg commit -m bla | |
167 | abort: repository requires features unknown to this Mercurial: fake! |
|
167 | abort: repository requires features unknown to this Mercurial: fake! | |
168 | (see https://mercurial-scm.org/wiki/MissingRequirement for more information) |
|
168 | (see https://mercurial-scm.org/wiki/MissingRequirement for more information) | |
169 | [255] |
|
169 | [255] | |
170 |
|
170 | |||
171 | $ cd .. |
|
171 | $ cd .. | |
172 |
|
172 | |||
173 |
|
173 | |||
174 | partial subdir commit test |
|
174 | partial subdir commit test | |
175 |
|
175 | |||
176 | $ hg init test2 |
|
176 | $ hg init test2 | |
177 | $ cd test2 |
|
177 | $ cd test2 | |
178 | $ mkdir foo |
|
178 | $ mkdir foo | |
179 | $ echo foo > foo/foo |
|
179 | $ echo foo > foo/foo | |
180 | $ mkdir bar |
|
180 | $ mkdir bar | |
181 | $ echo bar > bar/bar |
|
181 | $ echo bar > bar/bar | |
182 | $ hg add |
|
182 | $ hg add | |
183 | adding bar/bar |
|
183 | adding bar/bar | |
184 | adding foo/foo |
|
184 | adding foo/foo | |
185 | $ HGEDITOR=cat hg ci -e -m commit-subdir-1 foo |
|
185 | $ HGEDITOR=cat hg ci -e -m commit-subdir-1 foo | |
186 | commit-subdir-1 |
|
186 | commit-subdir-1 | |
187 |
|
187 | |||
188 |
|
188 | |||
189 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
189 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
190 | HG: Leave message empty to abort commit. |
|
190 | HG: Leave message empty to abort commit. | |
191 | HG: -- |
|
191 | HG: -- | |
192 | HG: user: test |
|
192 | HG: user: test | |
193 | HG: branch 'default' |
|
193 | HG: branch 'default' | |
194 | HG: added foo/foo |
|
194 | HG: added foo/foo | |
195 |
|
195 | |||
196 |
|
196 | |||
197 | $ hg ci -m commit-subdir-2 bar |
|
197 | $ hg ci -m commit-subdir-2 bar | |
198 |
|
198 | |||
199 | subdir log 1 |
|
199 | subdir log 1 | |
200 |
|
200 | |||
201 | $ hg log -v foo |
|
201 | $ hg log -v foo | |
202 | changeset: 0:f97e73a25882 |
|
202 | changeset: 0:f97e73a25882 | |
203 | user: test |
|
203 | user: test | |
204 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
204 | date: Thu Jan 01 00:00:00 1970 +0000 | |
205 | files: foo/foo |
|
205 | files: foo/foo | |
206 | description: |
|
206 | description: | |
207 | commit-subdir-1 |
|
207 | commit-subdir-1 | |
208 |
|
208 | |||
209 |
|
209 | |||
210 |
|
210 | |||
211 | subdir log 2 |
|
211 | subdir log 2 | |
212 |
|
212 | |||
213 | $ hg log -v bar |
|
213 | $ hg log -v bar | |
214 | changeset: 1:aa809156d50d |
|
214 | changeset: 1:aa809156d50d | |
215 | tag: tip |
|
215 | tag: tip | |
216 | user: test |
|
216 | user: test | |
217 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
217 | date: Thu Jan 01 00:00:00 1970 +0000 | |
218 | files: bar/bar |
|
218 | files: bar/bar | |
219 | description: |
|
219 | description: | |
220 | commit-subdir-2 |
|
220 | commit-subdir-2 | |
221 |
|
221 | |||
222 |
|
222 | |||
223 |
|
223 | |||
224 | full log |
|
224 | full log | |
225 |
|
225 | |||
226 | $ hg log -v |
|
226 | $ hg log -v | |
227 | changeset: 1:aa809156d50d |
|
227 | changeset: 1:aa809156d50d | |
228 | tag: tip |
|
228 | tag: tip | |
229 | user: test |
|
229 | user: test | |
230 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
230 | date: Thu Jan 01 00:00:00 1970 +0000 | |
231 | files: bar/bar |
|
231 | files: bar/bar | |
232 | description: |
|
232 | description: | |
233 | commit-subdir-2 |
|
233 | commit-subdir-2 | |
234 |
|
234 | |||
235 |
|
235 | |||
236 | changeset: 0:f97e73a25882 |
|
236 | changeset: 0:f97e73a25882 | |
237 | user: test |
|
237 | user: test | |
238 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
238 | date: Thu Jan 01 00:00:00 1970 +0000 | |
239 | files: foo/foo |
|
239 | files: foo/foo | |
240 | description: |
|
240 | description: | |
241 | commit-subdir-1 |
|
241 | commit-subdir-1 | |
242 |
|
242 | |||
243 |
|
243 | |||
244 | $ cd .. |
|
244 | $ cd .. | |
245 |
|
245 | |||
246 |
|
246 | |||
247 | dot and subdir commit test |
|
247 | dot and subdir commit test | |
248 |
|
248 | |||
249 | $ hg init test3 |
|
249 | $ hg init test3 | |
250 | $ echo commit-foo-subdir > commit-log-test |
|
250 | $ echo commit-foo-subdir > commit-log-test | |
251 | $ cd test3 |
|
251 | $ cd test3 | |
252 | $ mkdir foo |
|
252 | $ mkdir foo | |
253 | $ echo foo content > foo/plain-file |
|
253 | $ echo foo content > foo/plain-file | |
254 | $ hg add foo/plain-file |
|
254 | $ hg add foo/plain-file | |
255 | $ HGEDITOR=cat hg ci --edit -l ../commit-log-test foo |
|
255 | $ HGEDITOR=cat hg ci --edit -l ../commit-log-test foo | |
256 | commit-foo-subdir |
|
256 | commit-foo-subdir | |
257 |
|
257 | |||
258 |
|
258 | |||
259 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
259 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
260 | HG: Leave message empty to abort commit. |
|
260 | HG: Leave message empty to abort commit. | |
261 | HG: -- |
|
261 | HG: -- | |
262 | HG: user: test |
|
262 | HG: user: test | |
263 | HG: branch 'default' |
|
263 | HG: branch 'default' | |
264 | HG: added foo/plain-file |
|
264 | HG: added foo/plain-file | |
265 |
|
265 | |||
266 |
|
266 | |||
267 | $ echo modified foo content > foo/plain-file |
|
267 | $ echo modified foo content > foo/plain-file | |
268 | $ hg ci -m commit-foo-dot . |
|
268 | $ hg ci -m commit-foo-dot . | |
269 |
|
269 | |||
270 | full log |
|
270 | full log | |
271 |
|
271 | |||
272 | $ hg log -v |
|
272 | $ hg log -v | |
273 | changeset: 1:95b38e3a5b2e |
|
273 | changeset: 1:95b38e3a5b2e | |
274 | tag: tip |
|
274 | tag: tip | |
275 | user: test |
|
275 | user: test | |
276 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
276 | date: Thu Jan 01 00:00:00 1970 +0000 | |
277 | files: foo/plain-file |
|
277 | files: foo/plain-file | |
278 | description: |
|
278 | description: | |
279 | commit-foo-dot |
|
279 | commit-foo-dot | |
280 |
|
280 | |||
281 |
|
281 | |||
282 | changeset: 0:65d4e9386227 |
|
282 | changeset: 0:65d4e9386227 | |
283 | user: test |
|
283 | user: test | |
284 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
284 | date: Thu Jan 01 00:00:00 1970 +0000 | |
285 | files: foo/plain-file |
|
285 | files: foo/plain-file | |
286 | description: |
|
286 | description: | |
287 | commit-foo-subdir |
|
287 | commit-foo-subdir | |
288 |
|
288 | |||
289 |
|
289 | |||
290 |
|
290 | |||
291 | subdir log |
|
291 | subdir log | |
292 |
|
292 | |||
293 | $ cd foo |
|
293 | $ cd foo | |
294 | $ hg log . |
|
294 | $ hg log . | |
295 | changeset: 1:95b38e3a5b2e |
|
295 | changeset: 1:95b38e3a5b2e | |
296 | tag: tip |
|
296 | tag: tip | |
297 | user: test |
|
297 | user: test | |
298 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
298 | date: Thu Jan 01 00:00:00 1970 +0000 | |
299 | summary: commit-foo-dot |
|
299 | summary: commit-foo-dot | |
300 |
|
300 | |||
301 | changeset: 0:65d4e9386227 |
|
301 | changeset: 0:65d4e9386227 | |
302 | user: test |
|
302 | user: test | |
303 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
303 | date: Thu Jan 01 00:00:00 1970 +0000 | |
304 | summary: commit-foo-subdir |
|
304 | summary: commit-foo-subdir | |
305 |
|
305 | |||
306 | $ cd .. |
|
306 | $ cd .. | |
307 | $ cd .. |
|
307 | $ cd .. | |
308 |
|
308 | |||
309 | Issue1049: Hg permits partial commit of merge without warning |
|
309 | Issue1049: Hg permits partial commit of merge without warning | |
310 |
|
310 | |||
311 | $ hg init issue1049 |
|
311 | $ hg init issue1049 | |
312 | $ cd issue1049 |
|
312 | $ cd issue1049 | |
313 | $ echo a > a |
|
313 | $ echo a > a | |
314 | $ hg ci -Ama |
|
314 | $ hg ci -Ama | |
315 | adding a |
|
315 | adding a | |
316 | $ echo a >> a |
|
316 | $ echo a >> a | |
317 | $ hg ci -mb |
|
317 | $ hg ci -mb | |
318 | $ hg up 0 |
|
318 | $ hg up 0 | |
319 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
319 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
320 | $ echo b >> a |
|
320 | $ echo b >> a | |
321 | $ hg ci -mc |
|
321 | $ hg ci -mc | |
322 | created new head |
|
322 | created new head | |
323 | $ HGMERGE=true hg merge |
|
323 | $ HGMERGE=true hg merge | |
324 | merging a |
|
324 | merging a | |
325 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
325 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
326 | (branch merge, don't forget to commit) |
|
326 | (branch merge, don't forget to commit) | |
327 |
|
327 | |||
328 | should fail because we are specifying a file name |
|
328 | should fail because we are specifying a file name | |
329 |
|
329 | |||
330 | $ hg ci -mmerge a |
|
330 | $ hg ci -mmerge a | |
331 | abort: cannot partially commit a merge (do not specify files or patterns) |
|
331 | abort: cannot partially commit a merge (do not specify files or patterns) | |
332 | [255] |
|
332 | [255] | |
333 |
|
333 | |||
334 | should fail because we are specifying a pattern |
|
334 | should fail because we are specifying a pattern | |
335 |
|
335 | |||
336 | $ hg ci -mmerge -I a |
|
336 | $ hg ci -mmerge -I a | |
337 | abort: cannot partially commit a merge (do not specify files or patterns) |
|
337 | abort: cannot partially commit a merge (do not specify files or patterns) | |
338 | [255] |
|
338 | [255] | |
339 |
|
339 | |||
340 | should succeed |
|
340 | should succeed | |
341 |
|
341 | |||
342 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg ci -mmerge --edit |
|
342 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg ci -mmerge --edit | |
343 | HGEDITFORM=commit.normal.merge |
|
343 | HGEDITFORM=commit.normal.merge | |
344 | $ cd .. |
|
344 | $ cd .. | |
345 |
|
345 | |||
346 |
|
346 | |||
347 | test commit message content |
|
347 | test commit message content | |
348 |
|
348 | |||
349 | $ hg init commitmsg |
|
349 | $ hg init commitmsg | |
350 | $ cd commitmsg |
|
350 | $ cd commitmsg | |
351 | $ echo changed > changed |
|
351 | $ echo changed > changed | |
352 | $ echo removed > removed |
|
352 | $ echo removed > removed | |
353 | $ hg book activebookmark |
|
353 | $ hg book activebookmark | |
354 | $ hg ci -qAm init |
|
354 | $ hg ci -qAm init | |
355 |
|
355 | |||
356 | $ hg rm removed |
|
356 | $ hg rm removed | |
357 | $ echo changed >> changed |
|
357 | $ echo changed >> changed | |
358 | $ echo added > added |
|
358 | $ echo added > added | |
359 | $ hg add added |
|
359 | $ hg add added | |
360 | $ HGEDITOR=cat hg ci -A |
|
360 | $ HGEDITOR=cat hg ci -A | |
361 |
|
361 | |||
362 |
|
362 | |||
363 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
363 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
364 | HG: Leave message empty to abort commit. |
|
364 | HG: Leave message empty to abort commit. | |
365 | HG: -- |
|
365 | HG: -- | |
366 | HG: user: test |
|
366 | HG: user: test | |
367 | HG: branch 'default' |
|
367 | HG: branch 'default' | |
368 | HG: bookmark 'activebookmark' |
|
368 | HG: bookmark 'activebookmark' | |
369 | HG: added added |
|
369 | HG: added added | |
370 | HG: changed changed |
|
370 | HG: changed changed | |
371 | HG: removed removed |
|
371 | HG: removed removed | |
372 | abort: empty commit message |
|
372 | abort: empty commit message | |
373 | [255] |
|
373 | [255] | |
374 |
|
374 | |||
375 | test saving last-message.txt |
|
375 | test saving last-message.txt | |
376 |
|
376 | |||
377 | $ hg init sub |
|
377 | $ hg init sub | |
378 | $ echo a > sub/a |
|
378 | $ echo a > sub/a | |
379 | $ hg -R sub add sub/a |
|
379 | $ hg -R sub add sub/a | |
380 | $ cat > sub/.hg/hgrc <<EOF |
|
380 | $ cat > sub/.hg/hgrc <<EOF | |
381 | > [hooks] |
|
381 | > [hooks] | |
382 | > precommit.test-saving-last-message = false |
|
382 | > precommit.test-saving-last-message = false | |
383 | > EOF |
|
383 | > EOF | |
384 |
|
384 | |||
385 | $ echo 'sub = sub' > .hgsub |
|
385 | $ echo 'sub = sub' > .hgsub | |
386 | $ hg add .hgsub |
|
386 | $ hg add .hgsub | |
387 |
|
387 | |||
388 | $ cat > $TESTTMP/editor.sh <<EOF |
|
388 | $ cat > $TESTTMP/editor.sh <<EOF | |
389 | > echo "==== before editing:" |
|
389 | > echo "==== before editing:" | |
390 | > cat \$1 |
|
390 | > cat \$1 | |
391 | > echo "====" |
|
391 | > echo "====" | |
392 | > echo "test saving last-message.txt" >> \$1 |
|
392 | > echo "test saving last-message.txt" >> \$1 | |
393 | > EOF |
|
393 | > EOF | |
394 |
|
394 | |||
395 | $ rm -f .hg/last-message.txt |
|
395 | $ rm -f .hg/last-message.txt | |
396 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg commit -S -q |
|
396 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg commit -S -q | |
397 | ==== before editing: |
|
397 | ==== before editing: | |
398 |
|
398 | |||
399 |
|
399 | |||
400 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
400 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
401 | HG: Leave message empty to abort commit. |
|
401 | HG: Leave message empty to abort commit. | |
402 | HG: -- |
|
402 | HG: -- | |
403 | HG: user: test |
|
403 | HG: user: test | |
404 | HG: branch 'default' |
|
404 | HG: branch 'default' | |
405 | HG: bookmark 'activebookmark' |
|
405 | HG: bookmark 'activebookmark' | |
406 | HG: subrepo sub |
|
406 | HG: subrepo sub | |
407 | HG: added .hgsub |
|
407 | HG: added .hgsub | |
408 | HG: added added |
|
408 | HG: added added | |
409 | HG: changed .hgsubstate |
|
409 | HG: changed .hgsubstate | |
410 | HG: changed changed |
|
410 | HG: changed changed | |
411 | HG: removed removed |
|
411 | HG: removed removed | |
412 | ==== |
|
412 | ==== | |
413 | abort: precommit.test-saving-last-message hook exited with status 1 (in subrepository "sub") |
|
413 | abort: precommit.test-saving-last-message hook exited with status 1 (in subrepository "sub") | |
414 | [255] |
|
414 | [255] | |
415 | $ cat .hg/last-message.txt |
|
415 | $ cat .hg/last-message.txt | |
416 |
|
416 | |||
417 |
|
417 | |||
418 | test saving last-message.txt |
|
418 | test saving last-message.txt | |
419 |
|
419 | |||
420 | test that '[committemplate] changeset' definition and commit log |
|
420 | test that '[committemplate] changeset' definition and commit log | |
421 | specific template keywords work well |
|
421 | specific template keywords work well | |
422 |
|
422 | |||
423 | $ cat >> .hg/hgrc <<EOF |
|
423 | $ cat >> .hg/hgrc <<EOF | |
424 | > [committemplate] |
|
424 | > [committemplate] | |
425 | > changeset.commit.normal = 'HG: this is "commit.normal" template |
|
425 | > changeset.commit.normal = 'HG: this is "commit.normal" template | |
426 | > HG: {extramsg} |
|
426 | > HG: {extramsg} | |
427 | > {if(activebookmark, |
|
427 | > {if(activebookmark, | |
428 | > "HG: bookmark '{activebookmark}' is activated\n", |
|
428 | > "HG: bookmark '{activebookmark}' is activated\n", | |
429 | > "HG: no bookmark is activated\n")}{subrepos % |
|
429 | > "HG: no bookmark is activated\n")}{subrepos % | |
430 | > "HG: subrepo '{subrepo}' is changed\n"}' |
|
430 | > "HG: subrepo '{subrepo}' is changed\n"}' | |
431 | > |
|
431 | > | |
432 | > changeset.commit = HG: this is "commit" template |
|
432 | > changeset.commit = HG: this is "commit" template | |
433 | > HG: {extramsg} |
|
433 | > HG: {extramsg} | |
434 | > {if(activebookmark, |
|
434 | > {if(activebookmark, | |
435 | > "HG: bookmark '{activebookmark}' is activated\n", |
|
435 | > "HG: bookmark '{activebookmark}' is activated\n", | |
436 | > "HG: no bookmark is activated\n")}{subrepos % |
|
436 | > "HG: no bookmark is activated\n")}{subrepos % | |
437 | > "HG: subrepo '{subrepo}' is changed\n"} |
|
437 | > "HG: subrepo '{subrepo}' is changed\n"} | |
438 | > |
|
438 | > | |
439 | > changeset = HG: this is customized commit template |
|
439 | > changeset = HG: this is customized commit template | |
440 | > HG: {extramsg} |
|
440 | > HG: {extramsg} | |
441 | > {if(activebookmark, |
|
441 | > {if(activebookmark, | |
442 | > "HG: bookmark '{activebookmark}' is activated\n", |
|
442 | > "HG: bookmark '{activebookmark}' is activated\n", | |
443 | > "HG: no bookmark is activated\n")}{subrepos % |
|
443 | > "HG: no bookmark is activated\n")}{subrepos % | |
444 | > "HG: subrepo '{subrepo}' is changed\n"} |
|
444 | > "HG: subrepo '{subrepo}' is changed\n"} | |
445 | > EOF |
|
445 | > EOF | |
446 |
|
446 | |||
447 | $ hg init sub2 |
|
447 | $ hg init sub2 | |
448 | $ echo a > sub2/a |
|
448 | $ echo a > sub2/a | |
449 | $ hg -R sub2 add sub2/a |
|
449 | $ hg -R sub2 add sub2/a | |
450 | $ echo 'sub2 = sub2' >> .hgsub |
|
450 | $ echo 'sub2 = sub2' >> .hgsub | |
451 |
|
451 | |||
452 | $ HGEDITOR=cat hg commit -S -q |
|
452 | $ HGEDITOR=cat hg commit -S -q | |
453 | HG: this is "commit.normal" template |
|
453 | HG: this is "commit.normal" template | |
454 | HG: Leave message empty to abort commit. |
|
454 | HG: Leave message empty to abort commit. | |
455 | HG: bookmark 'activebookmark' is activated |
|
455 | HG: bookmark 'activebookmark' is activated | |
456 | HG: subrepo 'sub' is changed |
|
456 | HG: subrepo 'sub' is changed | |
457 | HG: subrepo 'sub2' is changed |
|
457 | HG: subrepo 'sub2' is changed | |
458 | abort: empty commit message |
|
458 | abort: empty commit message | |
459 | [255] |
|
459 | [255] | |
460 |
|
460 | |||
461 | $ cat >> .hg/hgrc <<EOF |
|
461 | $ cat >> .hg/hgrc <<EOF | |
462 | > [committemplate] |
|
462 | > [committemplate] | |
463 | > changeset.commit.normal = |
|
463 | > changeset.commit.normal = | |
464 | > # now, "changeset.commit" should be chosen for "hg commit" |
|
464 | > # now, "changeset.commit" should be chosen for "hg commit" | |
465 | > EOF |
|
465 | > EOF | |
466 |
|
466 | |||
467 | $ hg bookmark --inactive activebookmark |
|
467 | $ hg bookmark --inactive activebookmark | |
468 | $ hg forget .hgsub |
|
468 | $ hg forget .hgsub | |
469 | $ HGEDITOR=cat hg commit -q |
|
469 | $ HGEDITOR=cat hg commit -q | |
470 | HG: this is "commit" template |
|
470 | HG: this is "commit" template | |
471 | HG: Leave message empty to abort commit. |
|
471 | HG: Leave message empty to abort commit. | |
472 | HG: no bookmark is activated |
|
472 | HG: no bookmark is activated | |
473 | abort: empty commit message |
|
473 | abort: empty commit message | |
474 | [255] |
|
474 | [255] | |
475 |
|
475 | |||
476 | $ cat >> .hg/hgrc <<EOF |
|
476 | $ cat >> .hg/hgrc <<EOF | |
477 | > [committemplate] |
|
477 | > [committemplate] | |
478 | > changeset.commit = |
|
478 | > changeset.commit = | |
479 | > # now, "changeset" should be chosen for "hg commit" |
|
479 | > # now, "changeset" should be chosen for "hg commit" | |
480 | > EOF |
|
480 | > EOF | |
481 |
|
481 | |||
482 | $ HGEDITOR=cat hg commit -q |
|
482 | $ HGEDITOR=cat hg commit -q | |
483 | HG: this is customized commit template |
|
483 | HG: this is customized commit template | |
484 | HG: Leave message empty to abort commit. |
|
484 | HG: Leave message empty to abort commit. | |
485 | HG: no bookmark is activated |
|
485 | HG: no bookmark is activated | |
486 | abort: empty commit message |
|
486 | abort: empty commit message | |
487 | [255] |
|
487 | [255] | |
488 |
|
488 | |||
489 | $ cat >> .hg/hgrc <<EOF |
|
489 | $ cat >> .hg/hgrc <<EOF | |
490 | > [committemplate] |
|
490 | > [committemplate] | |
491 | > changeset = {desc} |
|
491 | > changeset = {desc} | |
492 | > HG: mods={file_mods} |
|
492 | > HG: mods={file_mods} | |
493 | > HG: adds={file_adds} |
|
493 | > HG: adds={file_adds} | |
494 | > HG: dels={file_dels} |
|
494 | > HG: dels={file_dels} | |
495 | > HG: files={files} |
|
495 | > HG: files={files} | |
496 | > HG: |
|
496 | > HG: | |
497 | > {splitlines(diff()) % 'HG: {line}\n' |
|
497 | > {splitlines(diff()) % 'HG: {line}\n' | |
498 | > }HG: |
|
498 | > }HG: | |
499 | > HG: mods={file_mods} |
|
499 | > HG: mods={file_mods} | |
500 | > HG: adds={file_adds} |
|
500 | > HG: adds={file_adds} | |
501 | > HG: dels={file_dels} |
|
501 | > HG: dels={file_dels} | |
502 | > HG: files={files}\n |
|
502 | > HG: files={files}\n | |
503 | > EOF |
|
503 | > EOF | |
504 | $ hg status -amr |
|
504 | $ hg status -amr | |
505 | M changed |
|
505 | M changed | |
506 | A added |
|
506 | A added | |
507 | R removed |
|
507 | R removed | |
508 | $ HGEDITOR=cat hg commit -q -e -m "foo bar" changed |
|
508 | $ HGEDITOR=cat hg commit -q -e -m "foo bar" changed | |
509 | foo bar |
|
509 | foo bar | |
510 | HG: mods=changed |
|
510 | HG: mods=changed | |
511 | HG: adds= |
|
511 | HG: adds= | |
512 | HG: dels= |
|
512 | HG: dels= | |
513 | HG: files=changed |
|
513 | HG: files=changed | |
514 | HG: |
|
514 | HG: | |
|
515 | HG: diff -r d2313f97106f changed | |||
515 | HG: --- a/changed Thu Jan 01 00:00:00 1970 +0000 |
|
516 | HG: --- a/changed Thu Jan 01 00:00:00 1970 +0000 | |
516 | HG: +++ b/changed Thu Jan 01 00:00:00 1970 +0000 |
|
517 | HG: +++ b/changed Thu Jan 01 00:00:00 1970 +0000 | |
517 | HG: @@ -1,1 +1,2 @@ |
|
518 | HG: @@ -1,1 +1,2 @@ | |
518 | HG: changed |
|
519 | HG: changed | |
519 | HG: +changed |
|
520 | HG: +changed | |
520 | HG: |
|
521 | HG: | |
521 | HG: mods=changed |
|
522 | HG: mods=changed | |
522 | HG: adds= |
|
523 | HG: adds= | |
523 | HG: dels= |
|
524 | HG: dels= | |
524 | HG: files=changed |
|
525 | HG: files=changed | |
525 | $ hg status -amr |
|
526 | $ hg status -amr | |
526 | A added |
|
527 | A added | |
527 | R removed |
|
528 | R removed | |
528 | $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n" |
|
529 | $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n" | |
529 | M changed |
|
530 | M changed | |
530 | A |
|
531 | A | |
531 | R |
|
532 | R | |
532 | $ hg rollback -q |
|
533 | $ hg rollback -q | |
533 |
|
534 | |||
534 | $ cat >> .hg/hgrc <<EOF |
|
535 | $ cat >> .hg/hgrc <<EOF | |
535 | > [committemplate] |
|
536 | > [committemplate] | |
536 | > changeset = {desc} |
|
537 | > changeset = {desc} | |
537 | > HG: mods={file_mods} |
|
538 | > HG: mods={file_mods} | |
538 | > HG: adds={file_adds} |
|
539 | > HG: adds={file_adds} | |
539 | > HG: dels={file_dels} |
|
540 | > HG: dels={file_dels} | |
540 | > HG: files={files} |
|
541 | > HG: files={files} | |
541 | > HG: |
|
542 | > HG: | |
542 | > {splitlines(diff("changed")) % 'HG: {line}\n' |
|
543 | > {splitlines(diff("changed")) % 'HG: {line}\n' | |
543 | > }HG: |
|
544 | > }HG: | |
544 | > HG: mods={file_mods} |
|
545 | > HG: mods={file_mods} | |
545 | > HG: adds={file_adds} |
|
546 | > HG: adds={file_adds} | |
546 | > HG: dels={file_dels} |
|
547 | > HG: dels={file_dels} | |
547 | > HG: files={files} |
|
548 | > HG: files={files} | |
548 | > HG: |
|
549 | > HG: | |
549 | > {splitlines(diff("added")) % 'HG: {line}\n' |
|
550 | > {splitlines(diff("added")) % 'HG: {line}\n' | |
550 | > }HG: |
|
551 | > }HG: | |
551 | > HG: mods={file_mods} |
|
552 | > HG: mods={file_mods} | |
552 | > HG: adds={file_adds} |
|
553 | > HG: adds={file_adds} | |
553 | > HG: dels={file_dels} |
|
554 | > HG: dels={file_dels} | |
554 | > HG: files={files} |
|
555 | > HG: files={files} | |
555 | > HG: |
|
556 | > HG: | |
556 | > {splitlines(diff("removed")) % 'HG: {line}\n' |
|
557 | > {splitlines(diff("removed")) % 'HG: {line}\n' | |
557 | > }HG: |
|
558 | > }HG: | |
558 | > HG: mods={file_mods} |
|
559 | > HG: mods={file_mods} | |
559 | > HG: adds={file_adds} |
|
560 | > HG: adds={file_adds} | |
560 | > HG: dels={file_dels} |
|
561 | > HG: dels={file_dels} | |
561 | > HG: files={files}\n |
|
562 | > HG: files={files}\n | |
562 | > EOF |
|
563 | > EOF | |
563 | $ HGEDITOR=cat hg commit -q -e -m "foo bar" added removed |
|
564 | $ HGEDITOR=cat hg commit -q -e -m "foo bar" added removed | |
564 | foo bar |
|
565 | foo bar | |
565 | HG: mods= |
|
566 | HG: mods= | |
566 | HG: adds=added |
|
567 | HG: adds=added | |
567 | HG: dels=removed |
|
568 | HG: dels=removed | |
568 | HG: files=added removed |
|
569 | HG: files=added removed | |
569 | HG: |
|
570 | HG: | |
570 | HG: |
|
571 | HG: | |
571 | HG: mods= |
|
572 | HG: mods= | |
572 | HG: adds=added |
|
573 | HG: adds=added | |
573 | HG: dels=removed |
|
574 | HG: dels=removed | |
574 | HG: files=added removed |
|
575 | HG: files=added removed | |
575 | HG: |
|
576 | HG: | |
|
577 | HG: diff -r d2313f97106f added | |||
576 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
578 | HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
577 | HG: +++ b/added Thu Jan 01 00:00:00 1970 +0000 |
|
579 | HG: +++ b/added Thu Jan 01 00:00:00 1970 +0000 | |
578 | HG: @@ -0,0 +1,1 @@ |
|
580 | HG: @@ -0,0 +1,1 @@ | |
579 | HG: +added |
|
581 | HG: +added | |
580 | HG: |
|
582 | HG: | |
581 | HG: mods= |
|
583 | HG: mods= | |
582 | HG: adds=added |
|
584 | HG: adds=added | |
583 | HG: dels=removed |
|
585 | HG: dels=removed | |
584 | HG: files=added removed |
|
586 | HG: files=added removed | |
585 | HG: |
|
587 | HG: | |
|
588 | HG: diff -r d2313f97106f removed | |||
586 | HG: --- a/removed Thu Jan 01 00:00:00 1970 +0000 |
|
589 | HG: --- a/removed Thu Jan 01 00:00:00 1970 +0000 | |
587 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
590 | HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
588 | HG: @@ -1,1 +0,0 @@ |
|
591 | HG: @@ -1,1 +0,0 @@ | |
589 | HG: -removed |
|
592 | HG: -removed | |
590 | HG: |
|
593 | HG: | |
591 | HG: mods= |
|
594 | HG: mods= | |
592 | HG: adds=added |
|
595 | HG: adds=added | |
593 | HG: dels=removed |
|
596 | HG: dels=removed | |
594 | HG: files=added removed |
|
597 | HG: files=added removed | |
595 | $ hg status -amr |
|
598 | $ hg status -amr | |
596 | M changed |
|
599 | M changed | |
597 | $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n" |
|
600 | $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n" | |
598 | M |
|
601 | M | |
599 | A added |
|
602 | A added | |
600 | R removed |
|
603 | R removed | |
601 | $ hg rollback -q |
|
604 | $ hg rollback -q | |
602 |
|
605 | |||
603 | $ cat >> .hg/hgrc <<EOF |
|
606 | $ cat >> .hg/hgrc <<EOF | |
604 | > # disable customizing for subsequent tests |
|
607 | > # disable customizing for subsequent tests | |
605 | > [committemplate] |
|
608 | > [committemplate] | |
606 | > changeset = |
|
609 | > changeset = | |
607 | > EOF |
|
610 | > EOF | |
608 |
|
611 | |||
609 | $ cd .. |
|
612 | $ cd .. | |
610 |
|
613 | |||
611 |
|
614 | |||
612 | commit copy |
|
615 | commit copy | |
613 |
|
616 | |||
614 | $ hg init dir2 |
|
617 | $ hg init dir2 | |
615 | $ cd dir2 |
|
618 | $ cd dir2 | |
616 | $ echo bleh > bar |
|
619 | $ echo bleh > bar | |
617 | $ hg add bar |
|
620 | $ hg add bar | |
618 | $ hg ci -m 'add bar' |
|
621 | $ hg ci -m 'add bar' | |
619 |
|
622 | |||
620 | $ hg cp bar foo |
|
623 | $ hg cp bar foo | |
621 | $ echo >> bar |
|
624 | $ echo >> bar | |
622 | $ hg ci -m 'cp bar foo; change bar' |
|
625 | $ hg ci -m 'cp bar foo; change bar' | |
623 |
|
626 | |||
624 | $ hg debugrename foo |
|
627 | $ hg debugrename foo | |
625 | foo renamed from bar:26d3ca0dfd18e44d796b564e38dd173c9668d3a9 |
|
628 | foo renamed from bar:26d3ca0dfd18e44d796b564e38dd173c9668d3a9 | |
626 | $ hg debugindex bar |
|
629 | $ hg debugindex bar | |
627 | rev linkrev nodeid p1 p2 |
|
630 | rev linkrev nodeid p1 p2 | |
628 | 0 0 26d3ca0dfd18 000000000000 000000000000 |
|
631 | 0 0 26d3ca0dfd18 000000000000 000000000000 | |
629 | 1 1 d267bddd54f7 26d3ca0dfd18 000000000000 |
|
632 | 1 1 d267bddd54f7 26d3ca0dfd18 000000000000 | |
630 |
|
633 | |||
631 | Test making empty commits |
|
634 | Test making empty commits | |
632 | $ hg commit --config ui.allowemptycommit=True -m "empty commit" |
|
635 | $ hg commit --config ui.allowemptycommit=True -m "empty commit" | |
633 | $ hg log -r . -v --stat |
|
636 | $ hg log -r . -v --stat | |
634 | changeset: 2:d809f3644287 |
|
637 | changeset: 2:d809f3644287 | |
635 | tag: tip |
|
638 | tag: tip | |
636 | user: test |
|
639 | user: test | |
637 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
640 | date: Thu Jan 01 00:00:00 1970 +0000 | |
638 | description: |
|
641 | description: | |
639 | empty commit |
|
642 | empty commit | |
640 |
|
643 | |||
641 |
|
644 | |||
642 |
|
645 | |||
643 | verify pathauditor blocks evil filepaths |
|
646 | verify pathauditor blocks evil filepaths | |
644 | $ cat > evil-commit.py <<EOF |
|
647 | $ cat > evil-commit.py <<EOF | |
645 | > from __future__ import absolute_import |
|
648 | > from __future__ import absolute_import | |
646 | > from mercurial import context, hg, node, ui as uimod |
|
649 | > from mercurial import context, hg, node, ui as uimod | |
647 | > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc' |
|
650 | > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc' | |
648 | > u = uimod.ui.load() |
|
651 | > u = uimod.ui.load() | |
649 | > r = hg.repository(u, b'.') |
|
652 | > r = hg.repository(u, b'.') | |
650 | > def filectxfn(repo, memctx, path): |
|
653 | > def filectxfn(repo, memctx, path): | |
651 | > return context.memfilectx(repo, memctx, path, |
|
654 | > return context.memfilectx(repo, memctx, path, | |
652 | > b'[hooks]\nupdate = echo owned') |
|
655 | > b'[hooks]\nupdate = echo owned') | |
653 | > c = context.memctx(r, [r.changelog.tip(), node.nullid], |
|
656 | > c = context.memctx(r, [r.changelog.tip(), node.nullid], | |
654 | > b'evil', [notrc], filectxfn, 0) |
|
657 | > b'evil', [notrc], filectxfn, 0) | |
655 | > r.commitctx(c) |
|
658 | > r.commitctx(c) | |
656 | > EOF |
|
659 | > EOF | |
657 | $ "$PYTHON" evil-commit.py |
|
660 | $ "$PYTHON" evil-commit.py | |
658 | #if windows |
|
661 | #if windows | |
659 | $ hg co --clean tip |
|
662 | $ hg co --clean tip | |
660 | abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc) |
|
663 | abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc) | |
661 | [255] |
|
664 | [255] | |
662 | #else |
|
665 | #else | |
663 | $ hg co --clean tip |
|
666 | $ hg co --clean tip | |
664 | abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc) |
|
667 | abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc) | |
665 | [255] |
|
668 | [255] | |
666 | #endif |
|
669 | #endif | |
667 |
|
670 | |||
668 | $ hg rollback -f |
|
671 | $ hg rollback -f | |
669 | repository tip rolled back to revision 2 (undo commit) |
|
672 | repository tip rolled back to revision 2 (undo commit) | |
670 | $ cat > evil-commit.py <<EOF |
|
673 | $ cat > evil-commit.py <<EOF | |
671 | > from __future__ import absolute_import |
|
674 | > from __future__ import absolute_import | |
672 | > from mercurial import context, hg, node, ui as uimod |
|
675 | > from mercurial import context, hg, node, ui as uimod | |
673 | > notrc = b"HG~1/hgrc" |
|
676 | > notrc = b"HG~1/hgrc" | |
674 | > u = uimod.ui.load() |
|
677 | > u = uimod.ui.load() | |
675 | > r = hg.repository(u, b'.') |
|
678 | > r = hg.repository(u, b'.') | |
676 | > def filectxfn(repo, memctx, path): |
|
679 | > def filectxfn(repo, memctx, path): | |
677 | > return context.memfilectx(repo, memctx, path, |
|
680 | > return context.memfilectx(repo, memctx, path, | |
678 | > b'[hooks]\nupdate = echo owned') |
|
681 | > b'[hooks]\nupdate = echo owned') | |
679 | > c = context.memctx(r, [r[b'tip'].node(), node.nullid], |
|
682 | > c = context.memctx(r, [r[b'tip'].node(), node.nullid], | |
680 | > b'evil', [notrc], filectxfn, 0) |
|
683 | > b'evil', [notrc], filectxfn, 0) | |
681 | > r.commitctx(c) |
|
684 | > r.commitctx(c) | |
682 | > EOF |
|
685 | > EOF | |
683 | $ "$PYTHON" evil-commit.py |
|
686 | $ "$PYTHON" evil-commit.py | |
684 | $ hg co --clean tip |
|
687 | $ hg co --clean tip | |
685 | abort: path contains illegal component: HG~1/hgrc |
|
688 | abort: path contains illegal component: HG~1/hgrc | |
686 | [255] |
|
689 | [255] | |
687 |
|
690 | |||
688 | $ hg rollback -f |
|
691 | $ hg rollback -f | |
689 | repository tip rolled back to revision 2 (undo commit) |
|
692 | repository tip rolled back to revision 2 (undo commit) | |
690 | $ cat > evil-commit.py <<EOF |
|
693 | $ cat > evil-commit.py <<EOF | |
691 | > from __future__ import absolute_import |
|
694 | > from __future__ import absolute_import | |
692 | > from mercurial import context, hg, node, ui as uimod |
|
695 | > from mercurial import context, hg, node, ui as uimod | |
693 | > notrc = b"HG8B6C~2/hgrc" |
|
696 | > notrc = b"HG8B6C~2/hgrc" | |
694 | > u = uimod.ui.load() |
|
697 | > u = uimod.ui.load() | |
695 | > r = hg.repository(u, b'.') |
|
698 | > r = hg.repository(u, b'.') | |
696 | > def filectxfn(repo, memctx, path): |
|
699 | > def filectxfn(repo, memctx, path): | |
697 | > return context.memfilectx(repo, memctx, path, |
|
700 | > return context.memfilectx(repo, memctx, path, | |
698 | > b'[hooks]\nupdate = echo owned') |
|
701 | > b'[hooks]\nupdate = echo owned') | |
699 | > c = context.memctx(r, [r[b'tip'].node(), node.nullid], |
|
702 | > c = context.memctx(r, [r[b'tip'].node(), node.nullid], | |
700 | > b'evil', [notrc], filectxfn, 0) |
|
703 | > b'evil', [notrc], filectxfn, 0) | |
701 | > r.commitctx(c) |
|
704 | > r.commitctx(c) | |
702 | > EOF |
|
705 | > EOF | |
703 | $ "$PYTHON" evil-commit.py |
|
706 | $ "$PYTHON" evil-commit.py | |
704 | $ hg co --clean tip |
|
707 | $ hg co --clean tip | |
705 | abort: path contains illegal component: HG8B6C~2/hgrc |
|
708 | abort: path contains illegal component: HG8B6C~2/hgrc | |
706 | [255] |
|
709 | [255] | |
707 |
|
710 | |||
708 | # test that an unmodified commit template message aborts |
|
711 | # test that an unmodified commit template message aborts | |
709 |
|
712 | |||
710 | $ hg init unmodified_commit_template |
|
713 | $ hg init unmodified_commit_template | |
711 | $ cd unmodified_commit_template |
|
714 | $ cd unmodified_commit_template | |
712 | $ echo foo > foo |
|
715 | $ echo foo > foo | |
713 | $ hg add foo |
|
716 | $ hg add foo | |
714 | $ hg commit -m "foo" |
|
717 | $ hg commit -m "foo" | |
715 | $ cat >> .hg/hgrc <<EOF |
|
718 | $ cat >> .hg/hgrc <<EOF | |
716 | > [committemplate] |
|
719 | > [committemplate] | |
717 | > changeset.commit = HI THIS IS NOT STRIPPED |
|
720 | > changeset.commit = HI THIS IS NOT STRIPPED | |
718 | > HG: this is customized commit template |
|
721 | > HG: this is customized commit template | |
719 | > HG: {extramsg} |
|
722 | > HG: {extramsg} | |
720 | > {if(activebookmark, |
|
723 | > {if(activebookmark, | |
721 | > "HG: bookmark '{activebookmark}' is activated\n", |
|
724 | > "HG: bookmark '{activebookmark}' is activated\n", | |
722 | > "HG: no bookmark is activated\n")}{subrepos % |
|
725 | > "HG: no bookmark is activated\n")}{subrepos % | |
723 | > "HG: subrepo '{subrepo}' is changed\n"} |
|
726 | > "HG: subrepo '{subrepo}' is changed\n"} | |
724 | > EOF |
|
727 | > EOF | |
725 | $ cat > $TESTTMP/notouching.sh <<EOF |
|
728 | $ cat > $TESTTMP/notouching.sh <<EOF | |
726 | > true |
|
729 | > true | |
727 | > EOF |
|
730 | > EOF | |
728 | $ echo foo2 > foo2 |
|
731 | $ echo foo2 > foo2 | |
729 | $ hg add foo2 |
|
732 | $ hg add foo2 | |
730 | $ HGEDITOR="sh $TESTTMP/notouching.sh" hg commit |
|
733 | $ HGEDITOR="sh $TESTTMP/notouching.sh" hg commit | |
731 | abort: commit message unchanged |
|
734 | abort: commit message unchanged | |
732 | [255] |
|
735 | [255] | |
733 |
|
736 | |||
734 | test that text below the --- >8 --- special string is ignored |
|
737 | test that text below the --- >8 --- special string is ignored | |
735 |
|
738 | |||
736 | $ cat <<'EOF' > $TESTTMP/lowercaseline.sh |
|
739 | $ cat <<'EOF' > $TESTTMP/lowercaseline.sh | |
737 | > cat $1 | sed s/LINE/line/ | tee $1.new |
|
740 | > cat $1 | sed s/LINE/line/ | tee $1.new | |
738 | > mv $1.new $1 |
|
741 | > mv $1.new $1 | |
739 | > EOF |
|
742 | > EOF | |
740 |
|
743 | |||
741 | $ hg init ignore_below_special_string |
|
744 | $ hg init ignore_below_special_string | |
742 | $ cd ignore_below_special_string |
|
745 | $ cd ignore_below_special_string | |
743 | $ echo foo > foo |
|
746 | $ echo foo > foo | |
744 | $ hg add foo |
|
747 | $ hg add foo | |
745 | $ hg commit -m "foo" |
|
748 | $ hg commit -m "foo" | |
746 | $ cat >> .hg/hgrc <<EOF |
|
749 | $ cat >> .hg/hgrc <<EOF | |
747 | > [committemplate] |
|
750 | > [committemplate] | |
748 | > changeset.commit = first LINE |
|
751 | > changeset.commit = first LINE | |
749 | > HG: this is customized commit template |
|
752 | > HG: this is customized commit template | |
750 | > HG: {extramsg} |
|
753 | > HG: {extramsg} | |
751 | > HG: ------------------------ >8 ------------------------ |
|
754 | > HG: ------------------------ >8 ------------------------ | |
752 | > {diff()} |
|
755 | > {diff()} | |
753 | > EOF |
|
756 | > EOF | |
754 | $ echo foo2 > foo2 |
|
757 | $ echo foo2 > foo2 | |
755 | $ hg add foo2 |
|
758 | $ hg add foo2 | |
756 | $ HGEDITOR="sh $TESTTMP/notouching.sh" hg ci |
|
759 | $ HGEDITOR="sh $TESTTMP/notouching.sh" hg ci | |
757 | abort: commit message unchanged |
|
760 | abort: commit message unchanged | |
758 | [255] |
|
761 | [255] | |
759 | $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci |
|
762 | $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci | |
760 | first line |
|
763 | first line | |
761 | HG: this is customized commit template |
|
764 | HG: this is customized commit template | |
762 | HG: Leave message empty to abort commit. |
|
765 | HG: Leave message empty to abort commit. | |
763 | HG: ------------------------ >8 ------------------------ |
|
766 | HG: ------------------------ >8 ------------------------ | |
764 | diff -r e63c23eaa88a foo2 |
|
767 | diff -r e63c23eaa88a foo2 | |
765 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
768 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
766 | +++ b/foo2 Thu Jan 01 00:00:00 1970 +0000 |
|
769 | +++ b/foo2 Thu Jan 01 00:00:00 1970 +0000 | |
767 | @@ -0,0 +1,1 @@ |
|
770 | @@ -0,0 +1,1 @@ | |
768 | +foo2 |
|
771 | +foo2 | |
769 | $ hg log -T '{desc}\n' -r . |
|
772 | $ hg log -T '{desc}\n' -r . | |
770 | first line |
|
773 | first line | |
771 |
|
774 | |||
772 | test that the special string --- >8 --- isn't used when not at the beginning of |
|
775 | test that the special string --- >8 --- isn't used when not at the beginning of | |
773 | a line |
|
776 | a line | |
774 |
|
777 | |||
775 | $ cat >> .hg/hgrc <<EOF |
|
778 | $ cat >> .hg/hgrc <<EOF | |
776 | > [committemplate] |
|
779 | > [committemplate] | |
777 | > changeset.commit = first LINE2 |
|
780 | > changeset.commit = first LINE2 | |
778 | > another line HG: ------------------------ >8 ------------------------ |
|
781 | > another line HG: ------------------------ >8 ------------------------ | |
779 | > HG: this is customized commit template |
|
782 | > HG: this is customized commit template | |
780 | > HG: {extramsg} |
|
783 | > HG: {extramsg} | |
781 | > HG: ------------------------ >8 ------------------------ |
|
784 | > HG: ------------------------ >8 ------------------------ | |
782 | > {diff()} |
|
785 | > {diff()} | |
783 | > EOF |
|
786 | > EOF | |
784 | $ echo foo >> foo |
|
787 | $ echo foo >> foo | |
785 | $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci |
|
788 | $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci | |
786 | first line2 |
|
789 | first line2 | |
787 | another line HG: ------------------------ >8 ------------------------ |
|
790 | another line HG: ------------------------ >8 ------------------------ | |
788 | HG: this is customized commit template |
|
791 | HG: this is customized commit template | |
789 | HG: Leave message empty to abort commit. |
|
792 | HG: Leave message empty to abort commit. | |
790 | HG: ------------------------ >8 ------------------------ |
|
793 | HG: ------------------------ >8 ------------------------ | |
791 | diff -r 3661b22b0702 foo |
|
794 | diff -r 3661b22b0702 foo | |
792 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 |
|
795 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 | |
793 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
796 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 | |
794 | @@ -1,1 +1,2 @@ |
|
797 | @@ -1,1 +1,2 @@ | |
795 | foo |
|
798 | foo | |
796 | +foo |
|
799 | +foo | |
797 | $ hg log -T '{desc}\n' -r . |
|
800 | $ hg log -T '{desc}\n' -r . | |
798 | first line2 |
|
801 | first line2 | |
799 | another line HG: ------------------------ >8 ------------------------ |
|
802 | another line HG: ------------------------ >8 ------------------------ | |
800 |
|
803 | |||
801 | also test that this special string isn't accepted when there is some extra text |
|
804 | also test that this special string isn't accepted when there is some extra text | |
802 | at the end |
|
805 | at the end | |
803 |
|
806 | |||
804 | $ cat >> .hg/hgrc <<EOF |
|
807 | $ cat >> .hg/hgrc <<EOF | |
805 | > [committemplate] |
|
808 | > [committemplate] | |
806 | > changeset.commit = first LINE3 |
|
809 | > changeset.commit = first LINE3 | |
807 | > HG: ------------------------ >8 ------------------------foobar |
|
810 | > HG: ------------------------ >8 ------------------------foobar | |
808 | > second line |
|
811 | > second line | |
809 | > HG: this is customized commit template |
|
812 | > HG: this is customized commit template | |
810 | > HG: {extramsg} |
|
813 | > HG: {extramsg} | |
811 | > HG: ------------------------ >8 ------------------------ |
|
814 | > HG: ------------------------ >8 ------------------------ | |
812 | > {diff()} |
|
815 | > {diff()} | |
813 | > EOF |
|
816 | > EOF | |
814 | $ echo foo >> foo |
|
817 | $ echo foo >> foo | |
815 | $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci |
|
818 | $ HGEDITOR="sh $TESTTMP/lowercaseline.sh" hg ci | |
816 | first line3 |
|
819 | first line3 | |
817 | HG: ------------------------ >8 ------------------------foobar |
|
820 | HG: ------------------------ >8 ------------------------foobar | |
818 | second line |
|
821 | second line | |
819 | HG: this is customized commit template |
|
822 | HG: this is customized commit template | |
820 | HG: Leave message empty to abort commit. |
|
823 | HG: Leave message empty to abort commit. | |
821 | HG: ------------------------ >8 ------------------------ |
|
824 | HG: ------------------------ >8 ------------------------ | |
822 | diff -r ce648f5f066f foo |
|
825 | diff -r ce648f5f066f foo | |
823 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 |
|
826 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 | |
824 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
827 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 | |
825 | @@ -1,2 +1,3 @@ |
|
828 | @@ -1,2 +1,3 @@ | |
826 | foo |
|
829 | foo | |
827 | foo |
|
830 | foo | |
828 | +foo |
|
831 | +foo | |
829 | $ hg log -T '{desc}\n' -r . |
|
832 | $ hg log -T '{desc}\n' -r . | |
830 | first line3 |
|
833 | first line3 | |
831 | second line |
|
834 | second line | |
832 |
|
835 | |||
833 | $ cd .. |
|
836 | $ cd .. |
@@ -1,46 +1,47 b'' | |||||
1 | $ hg init a |
|
1 | $ hg init a | |
2 | $ cd a |
|
2 | $ cd a | |
3 |
|
3 | |||
4 | $ hg diff inexistent1 inexistent2 |
|
4 | $ hg diff inexistent1 inexistent2 | |
5 | inexistent1: * (glob) |
|
5 | inexistent1: * (glob) | |
6 | inexistent2: * (glob) |
|
6 | inexistent2: * (glob) | |
7 |
|
7 | |||
8 | $ echo bar > foo |
|
8 | $ echo bar > foo | |
9 | $ hg add foo |
|
9 | $ hg add foo | |
10 | $ hg ci -m 'add foo' |
|
10 | $ hg ci -m 'add foo' | |
11 |
|
11 | |||
12 | $ echo foobar > foo |
|
12 | $ echo foobar > foo | |
13 | $ hg ci -m 'change foo' |
|
13 | $ hg ci -m 'change foo' | |
14 |
|
14 | |||
15 | $ hg --quiet diff -r 0 -r 1 |
|
15 | $ hg --quiet diff -r 0 -r 1 | |
|
16 | diff -r a99fb63adac3 -r 9b8568d3af2f foo | |||
16 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 |
|
17 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 | |
17 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
18 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 | |
18 | @@ -1,1 +1,1 @@ |
|
19 | @@ -1,1 +1,1 @@ | |
19 | -bar |
|
20 | -bar | |
20 | +foobar |
|
21 | +foobar | |
21 |
|
22 | |||
22 | $ hg diff -r 0 -r 1 |
|
23 | $ hg diff -r 0 -r 1 | |
23 | diff -r a99fb63adac3 -r 9b8568d3af2f foo |
|
24 | diff -r a99fb63adac3 -r 9b8568d3af2f foo | |
24 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 |
|
25 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 | |
25 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
26 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 | |
26 | @@ -1,1 +1,1 @@ |
|
27 | @@ -1,1 +1,1 @@ | |
27 | -bar |
|
28 | -bar | |
28 | +foobar |
|
29 | +foobar | |
29 |
|
30 | |||
30 | $ hg --verbose diff -r 0 -r 1 |
|
31 | $ hg --verbose diff -r 0 -r 1 | |
31 | diff -r a99fb63adac3 -r 9b8568d3af2f foo |
|
32 | diff -r a99fb63adac3 -r 9b8568d3af2f foo | |
32 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 |
|
33 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 | |
33 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
34 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 | |
34 | @@ -1,1 +1,1 @@ |
|
35 | @@ -1,1 +1,1 @@ | |
35 | -bar |
|
36 | -bar | |
36 | +foobar |
|
37 | +foobar | |
37 |
|
38 | |||
38 | $ hg --debug diff -r 0 -r 1 |
|
39 | $ hg --debug diff -r 0 -r 1 | |
39 | diff -r a99fb63adac3f31816a22f665bc3b7a7655b30f4 -r 9b8568d3af2f1749445eef03aede868a6f39f210 foo |
|
40 | diff -r a99fb63adac3f31816a22f665bc3b7a7655b30f4 -r 9b8568d3af2f1749445eef03aede868a6f39f210 foo | |
40 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 |
|
41 | --- a/foo Thu Jan 01 00:00:00 1970 +0000 | |
41 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 |
|
42 | +++ b/foo Thu Jan 01 00:00:00 1970 +0000 | |
42 | @@ -1,1 +1,1 @@ |
|
43 | @@ -1,1 +1,1 @@ | |
43 | -bar |
|
44 | -bar | |
44 | +foobar |
|
45 | +foobar | |
45 |
|
46 | |||
46 | $ cd .. |
|
47 | $ cd .. |
@@ -1,291 +1,294 b'' | |||||
1 | $ hg init repo |
|
1 | $ hg init repo | |
2 | $ cd repo |
|
2 | $ cd repo | |
3 | $ i=0; while [ "$i" -lt 213 ]; do echo a >> a; i=`expr $i + 1`; done |
|
3 | $ i=0; while [ "$i" -lt 213 ]; do echo a >> a; i=`expr $i + 1`; done | |
4 | $ hg add a |
|
4 | $ hg add a | |
5 | $ cp a b |
|
5 | $ cp a b | |
6 | $ hg add b |
|
6 | $ hg add b | |
7 |
|
7 | |||
8 | Wide diffstat: |
|
8 | Wide diffstat: | |
9 |
|
9 | |||
10 | $ hg diff --stat |
|
10 | $ hg diff --stat | |
11 | a | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
11 | a | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
12 | b | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
12 | b | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
13 | 2 files changed, 426 insertions(+), 0 deletions(-) |
|
13 | 2 files changed, 426 insertions(+), 0 deletions(-) | |
14 |
|
14 | |||
15 | diffstat width: |
|
15 | diffstat width: | |
16 |
|
16 | |||
17 | $ COLUMNS=24 hg diff --config ui.interactive=true --stat |
|
17 | $ COLUMNS=24 hg diff --config ui.interactive=true --stat | |
18 | a | 213 ++++++++++++++ |
|
18 | a | 213 ++++++++++++++ | |
19 | b | 213 ++++++++++++++ |
|
19 | b | 213 ++++++++++++++ | |
20 | 2 files changed, 426 insertions(+), 0 deletions(-) |
|
20 | 2 files changed, 426 insertions(+), 0 deletions(-) | |
21 |
|
21 | |||
22 | $ hg ci -m adda |
|
22 | $ hg ci -m adda | |
23 |
|
23 | |||
24 | $ cat >> a <<EOF |
|
24 | $ cat >> a <<EOF | |
25 | > a |
|
25 | > a | |
26 | > a |
|
26 | > a | |
27 | > a |
|
27 | > a | |
28 | > EOF |
|
28 | > EOF | |
29 |
|
29 | |||
30 | Narrow diffstat: |
|
30 | Narrow diffstat: | |
31 |
|
31 | |||
32 | $ hg diff --stat |
|
32 | $ hg diff --stat | |
33 | a | 3 +++ |
|
33 | a | 3 +++ | |
34 | 1 files changed, 3 insertions(+), 0 deletions(-) |
|
34 | 1 files changed, 3 insertions(+), 0 deletions(-) | |
35 |
|
35 | |||
36 | $ hg ci -m appenda |
|
36 | $ hg ci -m appenda | |
37 |
|
37 | |||
38 | >>> open("c", "wb").write(b"\0") and None |
|
38 | >>> open("c", "wb").write(b"\0") and None | |
39 | $ touch d |
|
39 | $ touch d | |
40 | $ hg add c d |
|
40 | $ hg add c d | |
41 |
|
41 | |||
42 | Binary diffstat: |
|
42 | Binary diffstat: | |
43 |
|
43 | |||
44 | $ hg diff --stat |
|
44 | $ hg diff --stat | |
45 | c | Bin |
|
45 | c | Bin | |
46 | 1 files changed, 0 insertions(+), 0 deletions(-) |
|
46 | 1 files changed, 0 insertions(+), 0 deletions(-) | |
47 |
|
47 | |||
48 | Binary git diffstat: |
|
48 | Binary git diffstat: | |
49 |
|
49 | |||
50 | $ hg diff --stat --git |
|
50 | $ hg diff --stat --git | |
51 | c | Bin |
|
51 | c | Bin | |
52 | d | 0 |
|
52 | d | 0 | |
53 | 2 files changed, 0 insertions(+), 0 deletions(-) |
|
53 | 2 files changed, 0 insertions(+), 0 deletions(-) | |
54 |
|
54 | |||
55 | $ hg ci -m createb |
|
55 | $ hg ci -m createb | |
56 |
|
56 | |||
57 | >>> open("file with spaces", "wb").write(b"\0") and None |
|
57 | >>> open("file with spaces", "wb").write(b"\0") and None | |
58 | $ hg add "file with spaces" |
|
58 | $ hg add "file with spaces" | |
59 |
|
59 | |||
60 | Filename with spaces diffstat: |
|
60 | Filename with spaces diffstat: | |
61 |
|
61 | |||
62 | $ hg diff --stat |
|
62 | $ hg diff --stat | |
63 | file with spaces | Bin |
|
63 | file with spaces | Bin | |
64 | 1 files changed, 0 insertions(+), 0 deletions(-) |
|
64 | 1 files changed, 0 insertions(+), 0 deletions(-) | |
65 |
|
65 | |||
66 | Filename with spaces git diffstat: |
|
66 | Filename with spaces git diffstat: | |
67 |
|
67 | |||
68 | $ hg diff --stat --git |
|
68 | $ hg diff --stat --git | |
69 | file with spaces | Bin |
|
69 | file with spaces | Bin | |
70 | 1 files changed, 0 insertions(+), 0 deletions(-) |
|
70 | 1 files changed, 0 insertions(+), 0 deletions(-) | |
71 |
|
71 | |||
72 | Filename without "a/" or "b/" (issue5759): |
|
72 | Filename without "a/" or "b/" (issue5759): | |
73 |
|
73 | |||
74 | $ hg diff --config 'diff.noprefix=1' -c1 --stat --git |
|
74 | $ hg diff --config 'diff.noprefix=1' -c1 --stat --git | |
75 | a | 3 +++ |
|
75 | a | 3 +++ | |
76 | 1 files changed, 3 insertions(+), 0 deletions(-) |
|
76 | 1 files changed, 3 insertions(+), 0 deletions(-) | |
77 | $ hg diff --config 'diff.noprefix=1' -c2 --stat --git |
|
77 | $ hg diff --config 'diff.noprefix=1' -c2 --stat --git | |
78 | c | Bin |
|
78 | c | Bin | |
79 | d | 0 |
|
79 | d | 0 | |
80 | 2 files changed, 0 insertions(+), 0 deletions(-) |
|
80 | 2 files changed, 0 insertions(+), 0 deletions(-) | |
81 |
|
81 | |||
82 | $ hg log --config 'diff.noprefix=1' -r '1:' -p --stat --git |
|
82 | $ hg log --config 'diff.noprefix=1' -r '1:' -p --stat --git | |
83 | changeset: 1:3a95b07bb77f |
|
83 | changeset: 1:3a95b07bb77f | |
84 | user: test |
|
84 | user: test | |
85 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
85 | date: Thu Jan 01 00:00:00 1970 +0000 | |
86 | summary: appenda |
|
86 | summary: appenda | |
87 |
|
87 | |||
88 | a | 3 +++ |
|
88 | a | 3 +++ | |
89 | 1 files changed, 3 insertions(+), 0 deletions(-) |
|
89 | 1 files changed, 3 insertions(+), 0 deletions(-) | |
90 |
|
90 | |||
91 | diff --git a a |
|
91 | diff --git a a | |
92 | --- a |
|
92 | --- a | |
93 | +++ a |
|
93 | +++ a | |
94 | @@ -211,3 +211,6 @@ |
|
94 | @@ -211,3 +211,6 @@ | |
95 | a |
|
95 | a | |
96 | a |
|
96 | a | |
97 | a |
|
97 | a | |
98 | +a |
|
98 | +a | |
99 | +a |
|
99 | +a | |
100 | +a |
|
100 | +a | |
101 |
|
101 | |||
102 | changeset: 2:c60a6c753773 |
|
102 | changeset: 2:c60a6c753773 | |
103 | tag: tip |
|
103 | tag: tip | |
104 | user: test |
|
104 | user: test | |
105 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
105 | date: Thu Jan 01 00:00:00 1970 +0000 | |
106 | summary: createb |
|
106 | summary: createb | |
107 |
|
107 | |||
108 | c | Bin |
|
108 | c | Bin | |
109 | d | 0 |
|
109 | d | 0 | |
110 | 2 files changed, 0 insertions(+), 0 deletions(-) |
|
110 | 2 files changed, 0 insertions(+), 0 deletions(-) | |
111 |
|
111 | |||
112 | diff --git c c |
|
112 | diff --git c c | |
113 | new file mode 100644 |
|
113 | new file mode 100644 | |
114 | index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f76dd238ade08917e6712764a16a22005a50573d |
|
114 | index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f76dd238ade08917e6712764a16a22005a50573d | |
115 | GIT binary patch |
|
115 | GIT binary patch | |
116 | literal 1 |
|
116 | literal 1 | |
117 | Ic${MZ000310RR91 |
|
117 | Ic${MZ000310RR91 | |
118 |
|
118 | |||
119 | diff --git d d |
|
119 | diff --git d d | |
120 | new file mode 100644 |
|
120 | new file mode 100644 | |
121 |
|
121 | |||
122 |
|
122 | |||
123 | diffstat within directories: |
|
123 | diffstat within directories: | |
124 |
|
124 | |||
125 | $ hg rm -f 'file with spaces' |
|
125 | $ hg rm -f 'file with spaces' | |
126 |
|
126 | |||
127 | $ mkdir dir1 dir2 |
|
127 | $ mkdir dir1 dir2 | |
128 | $ echo new1 > dir1/new |
|
128 | $ echo new1 > dir1/new | |
129 | $ echo new2 > dir2/new |
|
129 | $ echo new2 > dir2/new | |
130 | $ hg add dir1/new dir2/new |
|
130 | $ hg add dir1/new dir2/new | |
131 | $ hg diff --stat |
|
131 | $ hg diff --stat | |
132 | dir1/new | 1 + |
|
132 | dir1/new | 1 + | |
133 | dir2/new | 1 + |
|
133 | dir2/new | 1 + | |
134 | 2 files changed, 2 insertions(+), 0 deletions(-) |
|
134 | 2 files changed, 2 insertions(+), 0 deletions(-) | |
135 |
|
135 | |||
136 | $ hg diff --stat --root dir1 |
|
136 | $ hg diff --stat --root dir1 | |
137 | new | 1 + |
|
137 | new | 1 + | |
138 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
138 | 1 files changed, 1 insertions(+), 0 deletions(-) | |
139 |
|
139 | |||
140 | $ hg diff --stat --root dir1 dir2 |
|
140 | $ hg diff --stat --root dir1 dir2 | |
141 | warning: dir2 not inside relative root dir1 |
|
141 | warning: dir2 not inside relative root dir1 | |
142 |
|
142 | |||
143 | $ hg diff --stat --root dir1 -I dir1/old |
|
143 | $ hg diff --stat --root dir1 -I dir1/old | |
144 |
|
144 | |||
145 | $ cd dir1 |
|
145 | $ cd dir1 | |
146 | $ hg diff --stat . |
|
146 | $ hg diff --stat . | |
147 | dir1/new | 1 + |
|
147 | dir1/new | 1 + | |
148 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
148 | 1 files changed, 1 insertions(+), 0 deletions(-) | |
149 | $ hg diff --stat . --config ui.relative-paths=yes |
|
149 | $ hg diff --stat . --config ui.relative-paths=yes | |
150 | new | 1 + |
|
150 | new | 1 + | |
151 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
151 | 1 files changed, 1 insertions(+), 0 deletions(-) | |
152 | $ hg diff --stat --root . |
|
152 | $ hg diff --stat --root . | |
153 | new | 1 + |
|
153 | new | 1 + | |
154 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
154 | 1 files changed, 1 insertions(+), 0 deletions(-) | |
155 |
|
155 | |||
156 | $ hg diff --stat --root . --config ui.relative-paths=yes |
|
156 | $ hg diff --stat --root . --config ui.relative-paths=yes | |
157 | new | 1 + |
|
157 | new | 1 + | |
158 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
158 | 1 files changed, 1 insertions(+), 0 deletions(-) | |
159 | --root trumps ui.relative-paths |
|
159 | --root trumps ui.relative-paths | |
160 | $ hg diff --stat --root .. --config ui.relative-paths=yes |
|
160 | $ hg diff --stat --root .. --config ui.relative-paths=yes | |
161 | new | 1 + |
|
161 | new | 1 + | |
162 | ../dir2/new | 1 + |
|
162 | ../dir2/new | 1 + | |
163 | 2 files changed, 2 insertions(+), 0 deletions(-) |
|
163 | 2 files changed, 2 insertions(+), 0 deletions(-) | |
164 | $ hg diff --stat --root ../dir1 ../dir2 |
|
164 | $ hg diff --stat --root ../dir1 ../dir2 | |
165 | warning: ../dir2 not inside relative root . |
|
165 | warning: ../dir2 not inside relative root . | |
166 |
|
166 | |||
167 | $ hg diff --stat --root . -I old |
|
167 | $ hg diff --stat --root . -I old | |
168 |
|
168 | |||
169 | $ cd .. |
|
169 | $ cd .. | |
170 |
|
170 | |||
171 | Files with lines beginning with '--' or '++' should be properly counted in diffstat |
|
171 | Files with lines beginning with '--' or '++' should be properly counted in diffstat | |
172 |
|
172 | |||
173 | $ hg up -Cr tip |
|
173 | $ hg up -Cr tip | |
174 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
174 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
175 | $ rm dir1/new |
|
175 | $ rm dir1/new | |
176 | $ rm dir2/new |
|
176 | $ rm dir2/new | |
177 | $ rm "file with spaces" |
|
177 | $ rm "file with spaces" | |
178 | $ cat > file << EOF |
|
178 | $ cat > file << EOF | |
179 | > line 1 |
|
179 | > line 1 | |
180 | > line 2 |
|
180 | > line 2 | |
181 | > line 3 |
|
181 | > line 3 | |
182 | > EOF |
|
182 | > EOF | |
183 | $ hg commit -Am file |
|
183 | $ hg commit -Am file | |
184 | adding file |
|
184 | adding file | |
185 |
|
185 | |||
186 | Lines added starting with '--' should count as additions |
|
186 | Lines added starting with '--' should count as additions | |
187 | $ cat > file << EOF |
|
187 | $ cat > file << EOF | |
188 | > line 1 |
|
188 | > line 1 | |
189 | > -- line 2, with dashes |
|
189 | > -- line 2, with dashes | |
190 | > line 3 |
|
190 | > line 3 | |
191 | > EOF |
|
191 | > EOF | |
192 |
|
192 | |||
193 | $ hg diff --root . |
|
193 | $ hg diff --root . | |
194 | diff -r be1569354b24 file |
|
194 | diff -r be1569354b24 file | |
195 | --- a/file Thu Jan 01 00:00:00 1970 +0000 |
|
195 | --- a/file Thu Jan 01 00:00:00 1970 +0000 | |
196 | +++ b/file * (glob) |
|
196 | +++ b/file * (glob) | |
197 | @@ -1,3 +1,3 @@ |
|
197 | @@ -1,3 +1,3 @@ | |
198 | line 1 |
|
198 | line 1 | |
199 | -line 2 |
|
199 | -line 2 | |
200 | +-- line 2, with dashes |
|
200 | +-- line 2, with dashes | |
201 | line 3 |
|
201 | line 3 | |
202 |
|
202 | |||
203 | $ hg diff --root . --stat |
|
203 | $ hg diff --root . --stat | |
204 | file | 2 +- |
|
204 | file | 2 +- | |
205 | 1 files changed, 1 insertions(+), 1 deletions(-) |
|
205 | 1 files changed, 1 insertions(+), 1 deletions(-) | |
206 |
|
206 | |||
207 | Lines changed starting with '--' should count as deletions |
|
207 | Lines changed starting with '--' should count as deletions | |
208 | $ hg commit -m filev2 |
|
208 | $ hg commit -m filev2 | |
209 | $ cat > file << EOF |
|
209 | $ cat > file << EOF | |
210 | > line 1 |
|
210 | > line 1 | |
211 | > -- line 2, with dashes, changed again |
|
211 | > -- line 2, with dashes, changed again | |
212 | > line 3 |
|
212 | > line 3 | |
213 | > EOF |
|
213 | > EOF | |
214 |
|
214 | |||
215 | $ hg diff --root . |
|
215 | $ hg diff --root . | |
216 | diff -r 160f7c034df6 file |
|
216 | diff -r 160f7c034df6 file | |
217 | --- a/file Thu Jan 01 00:00:00 1970 +0000 |
|
217 | --- a/file Thu Jan 01 00:00:00 1970 +0000 | |
218 | +++ b/file * (glob) |
|
218 | +++ b/file * (glob) | |
219 | @@ -1,3 +1,3 @@ |
|
219 | @@ -1,3 +1,3 @@ | |
220 | line 1 |
|
220 | line 1 | |
221 | --- line 2, with dashes |
|
221 | --- line 2, with dashes | |
222 | +-- line 2, with dashes, changed again |
|
222 | +-- line 2, with dashes, changed again | |
223 | line 3 |
|
223 | line 3 | |
224 |
|
224 | |||
225 | $ hg diff --root . --stat |
|
225 | $ hg diff --root . --stat | |
226 | file | 2 +- |
|
226 | file | 2 +- | |
227 | 1 files changed, 1 insertions(+), 1 deletions(-) |
|
227 | 1 files changed, 1 insertions(+), 1 deletions(-) | |
228 |
|
228 | |||
229 | Lines changed starting with '--' should count as deletions |
|
229 | Lines changed starting with '--' should count as deletions | |
230 | and starting with '++' should count as additions |
|
230 | and starting with '++' should count as additions | |
231 | $ cat > file << EOF |
|
231 | $ cat > file << EOF | |
232 | > line 1 |
|
232 | > line 1 | |
233 | > ++ line 2, switched dashes to plusses |
|
233 | > ++ line 2, switched dashes to plusses | |
234 | > line 3 |
|
234 | > line 3 | |
235 | > EOF |
|
235 | > EOF | |
236 |
|
236 | |||
237 | $ hg diff --root . |
|
237 | $ hg diff --root . | |
238 | diff -r 160f7c034df6 file |
|
238 | diff -r 160f7c034df6 file | |
239 | --- a/file Thu Jan 01 00:00:00 1970 +0000 |
|
239 | --- a/file Thu Jan 01 00:00:00 1970 +0000 | |
240 | +++ b/file * (glob) |
|
240 | +++ b/file * (glob) | |
241 | @@ -1,3 +1,3 @@ |
|
241 | @@ -1,3 +1,3 @@ | |
242 | line 1 |
|
242 | line 1 | |
243 | --- line 2, with dashes |
|
243 | --- line 2, with dashes | |
244 | +++ line 2, switched dashes to plusses |
|
244 | +++ line 2, switched dashes to plusses | |
245 | line 3 |
|
245 | line 3 | |
246 |
|
246 | |||
247 | $ hg diff --root . --stat |
|
247 | $ hg diff --root . --stat | |
248 | file | 2 +- |
|
248 | file | 2 +- | |
249 | 1 files changed, 1 insertions(+), 1 deletions(-) |
|
249 | 1 files changed, 1 insertions(+), 1 deletions(-) | |
250 |
|
250 | |||
251 | When a file is renamed, --git shouldn't loss the info about old file |
|
251 | When a file is renamed, --git shouldn't loss the info about old file | |
252 | $ hg init issue6025 |
|
252 | $ hg init issue6025 | |
253 | $ cd issue6025 |
|
253 | $ cd issue6025 | |
254 | $ echo > a |
|
254 | $ echo > a | |
255 | $ hg ci -Am 'add a' |
|
255 | $ hg ci -Am 'add a' | |
256 | adding a |
|
256 | adding a | |
257 | $ hg mv a b |
|
257 | $ hg mv a b | |
258 | $ hg diff --git |
|
258 | $ hg diff --git | |
259 | diff --git a/a b/b |
|
259 | diff --git a/a b/b | |
260 | rename from a |
|
260 | rename from a | |
261 | rename to b |
|
261 | rename to b | |
262 | $ hg diff --stat |
|
262 | $ hg diff --stat | |
263 | a | 1 - |
|
263 | a | 1 - | |
264 | b | 1 + |
|
264 | b | 1 + | |
265 | 2 files changed, 1 insertions(+), 1 deletions(-) |
|
265 | 2 files changed, 1 insertions(+), 1 deletions(-) | |
266 | $ hg diff --stat --git |
|
266 | $ hg diff --stat --git | |
267 | a => b | 0 |
|
267 | a => b | 0 | |
268 | 1 files changed, 0 insertions(+), 0 deletions(-) |
|
268 | 1 files changed, 0 insertions(+), 0 deletions(-) | |
269 | -- filename may contain whitespaces |
|
269 | -- filename may contain whitespaces | |
270 | $ echo > c |
|
270 | $ echo > c | |
271 | $ hg ci -Am 'add c' |
|
271 | $ hg ci -Am 'add c' | |
272 | adding c |
|
272 | adding c | |
273 | $ hg mv c 'new c' |
|
273 | $ hg mv c 'new c' | |
274 | $ hg diff --git |
|
274 | $ hg diff --git | |
275 | diff --git a/c b/new c |
|
275 | diff --git a/c b/new c | |
276 | rename from c |
|
276 | rename from c | |
277 | rename to new c |
|
277 | rename to new c | |
278 | $ hg diff --stat |
|
278 | $ hg diff --stat | |
279 | c | 1 - |
|
279 | c | 1 - | |
280 | new c | 1 + |
|
280 | new c | 1 + | |
281 | 2 files changed, 1 insertions(+), 1 deletions(-) |
|
281 | 2 files changed, 1 insertions(+), 1 deletions(-) | |
282 | $ hg diff --stat --git |
|
282 | $ hg diff --stat --git | |
283 | c => new c | 0 |
|
283 | c => new c | 0 | |
284 | 1 files changed, 0 insertions(+), 0 deletions(-) |
|
284 | 1 files changed, 0 insertions(+), 0 deletions(-) | |
285 |
|
285 | |||
286 | Make sure `diff --stat -q --config diff.git-0` shows stat (issue4037) |
|
286 | Make sure `diff --stat -q --config diff.git-0` shows stat (issue4037) | |
287 |
|
287 | |||
288 | $ hg status |
|
288 | $ hg status | |
289 | A new c |
|
289 | A new c | |
290 | R c |
|
290 | R c | |
291 | $ hg diff --stat -q |
|
291 | $ hg diff --stat -q | |
|
292 | c | 1 - | |||
|
293 | new c | 1 + | |||
|
294 | 2 files changed, 1 insertions(+), 1 deletions(-) |
@@ -1,1621 +1,1622 b'' | |||||
1 | $ checkundo() |
|
1 | $ checkundo() | |
2 | > { |
|
2 | > { | |
3 | > if [ -f .hg/store/undo ]; then |
|
3 | > if [ -f .hg/store/undo ]; then | |
4 | > echo ".hg/store/undo still exists after $1" |
|
4 | > echo ".hg/store/undo still exists after $1" | |
5 | > fi |
|
5 | > fi | |
6 | > } |
|
6 | > } | |
7 |
|
7 | |||
8 | $ cat <<EOF >> $HGRCPATH |
|
8 | $ cat <<EOF >> $HGRCPATH | |
9 | > [extensions] |
|
9 | > [extensions] | |
10 | > mq = |
|
10 | > mq = | |
11 | > [mq] |
|
11 | > [mq] | |
12 | > plain = true |
|
12 | > plain = true | |
13 | > EOF |
|
13 | > EOF | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | help |
|
16 | help | |
17 |
|
17 | |||
18 | $ hg help mq |
|
18 | $ hg help mq | |
19 | mq extension - manage a stack of patches |
|
19 | mq extension - manage a stack of patches | |
20 |
|
20 | |||
21 | This extension lets you work with a stack of patches in a Mercurial |
|
21 | This extension lets you work with a stack of patches in a Mercurial | |
22 | repository. It manages two stacks of patches - all known patches, and applied |
|
22 | repository. It manages two stacks of patches - all known patches, and applied | |
23 | patches (subset of known patches). |
|
23 | patches (subset of known patches). | |
24 |
|
24 | |||
25 | Known patches are represented as patch files in the .hg/patches directory. |
|
25 | Known patches are represented as patch files in the .hg/patches directory. | |
26 | Applied patches are both patch files and changesets. |
|
26 | Applied patches are both patch files and changesets. | |
27 |
|
27 | |||
28 | Common tasks (use 'hg help COMMAND' for more details): |
|
28 | Common tasks (use 'hg help COMMAND' for more details): | |
29 |
|
29 | |||
30 | create new patch qnew |
|
30 | create new patch qnew | |
31 | import existing patch qimport |
|
31 | import existing patch qimport | |
32 |
|
32 | |||
33 | print patch series qseries |
|
33 | print patch series qseries | |
34 | print applied patches qapplied |
|
34 | print applied patches qapplied | |
35 |
|
35 | |||
36 | add known patch to applied stack qpush |
|
36 | add known patch to applied stack qpush | |
37 | remove patch from applied stack qpop |
|
37 | remove patch from applied stack qpop | |
38 | refresh contents of top applied patch qrefresh |
|
38 | refresh contents of top applied patch qrefresh | |
39 |
|
39 | |||
40 | By default, mq will automatically use git patches when required to avoid |
|
40 | By default, mq will automatically use git patches when required to avoid | |
41 | losing file mode changes, copy records, binary files or empty files creations |
|
41 | losing file mode changes, copy records, binary files or empty files creations | |
42 | or deletions. This behavior can be configured with: |
|
42 | or deletions. This behavior can be configured with: | |
43 |
|
43 | |||
44 | [mq] |
|
44 | [mq] | |
45 | git = auto/keep/yes/no |
|
45 | git = auto/keep/yes/no | |
46 |
|
46 | |||
47 | If set to 'keep', mq will obey the [diff] section configuration while |
|
47 | If set to 'keep', mq will obey the [diff] section configuration while | |
48 | preserving existing git patches upon qrefresh. If set to 'yes' or 'no', mq |
|
48 | preserving existing git patches upon qrefresh. If set to 'yes' or 'no', mq | |
49 | will override the [diff] section and always generate git or regular patches, |
|
49 | will override the [diff] section and always generate git or regular patches, | |
50 | possibly losing data in the second case. |
|
50 | possibly losing data in the second case. | |
51 |
|
51 | |||
52 | It may be desirable for mq changesets to be kept in the secret phase (see 'hg |
|
52 | It may be desirable for mq changesets to be kept in the secret phase (see 'hg | |
53 | help phases'), which can be enabled with the following setting: |
|
53 | help phases'), which can be enabled with the following setting: | |
54 |
|
54 | |||
55 | [mq] |
|
55 | [mq] | |
56 | secret = True |
|
56 | secret = True | |
57 |
|
57 | |||
58 | You will by default be managing a patch queue named "patches". You can create |
|
58 | You will by default be managing a patch queue named "patches". You can create | |
59 | other, independent patch queues with the 'hg qqueue' command. |
|
59 | other, independent patch queues with the 'hg qqueue' command. | |
60 |
|
60 | |||
61 | If the working directory contains uncommitted files, qpush, qpop and qgoto |
|
61 | If the working directory contains uncommitted files, qpush, qpop and qgoto | |
62 | abort immediately. If -f/--force is used, the changes are discarded. Setting: |
|
62 | abort immediately. If -f/--force is used, the changes are discarded. Setting: | |
63 |
|
63 | |||
64 | [mq] |
|
64 | [mq] | |
65 | keepchanges = True |
|
65 | keepchanges = True | |
66 |
|
66 | |||
67 | make them behave as if --keep-changes were passed, and non-conflicting local |
|
67 | make them behave as if --keep-changes were passed, and non-conflicting local | |
68 | changes will be tolerated and preserved. If incompatible options such as |
|
68 | changes will be tolerated and preserved. If incompatible options such as | |
69 | -f/--force or --exact are passed, this setting is ignored. |
|
69 | -f/--force or --exact are passed, this setting is ignored. | |
70 |
|
70 | |||
71 | This extension used to provide a strip command. This command now lives in the |
|
71 | This extension used to provide a strip command. This command now lives in the | |
72 | strip extension. |
|
72 | strip extension. | |
73 |
|
73 | |||
74 | list of commands: |
|
74 | list of commands: | |
75 |
|
75 | |||
76 | Repository creation: |
|
76 | Repository creation: | |
77 |
|
77 | |||
78 | qclone clone main and patch repository at same time |
|
78 | qclone clone main and patch repository at same time | |
79 |
|
79 | |||
80 | Change creation: |
|
80 | Change creation: | |
81 |
|
81 | |||
82 | qnew create a new patch |
|
82 | qnew create a new patch | |
83 | qrefresh update the current patch |
|
83 | qrefresh update the current patch | |
84 |
|
84 | |||
85 | Change manipulation: |
|
85 | Change manipulation: | |
86 |
|
86 | |||
87 | qfold fold the named patches into the current patch |
|
87 | qfold fold the named patches into the current patch | |
88 |
|
88 | |||
89 | Change organization: |
|
89 | Change organization: | |
90 |
|
90 | |||
91 | qapplied print the patches already applied |
|
91 | qapplied print the patches already applied | |
92 | qdelete remove patches from queue |
|
92 | qdelete remove patches from queue | |
93 | qfinish move applied patches into repository history |
|
93 | qfinish move applied patches into repository history | |
94 | qgoto push or pop patches until named patch is at top of stack |
|
94 | qgoto push or pop patches until named patch is at top of stack | |
95 | qguard set or print guards for a patch |
|
95 | qguard set or print guards for a patch | |
96 | qheader print the header of the topmost or specified patch |
|
96 | qheader print the header of the topmost or specified patch | |
97 | qnext print the name of the next pushable patch |
|
97 | qnext print the name of the next pushable patch | |
98 | qpop pop the current patch off the stack |
|
98 | qpop pop the current patch off the stack | |
99 | qprev print the name of the preceding applied patch |
|
99 | qprev print the name of the preceding applied patch | |
100 | qpush push the next patch onto the stack |
|
100 | qpush push the next patch onto the stack | |
101 | qqueue manage multiple patch queues |
|
101 | qqueue manage multiple patch queues | |
102 | qrename rename a patch |
|
102 | qrename rename a patch | |
103 | qselect set or print guarded patches to push |
|
103 | qselect set or print guarded patches to push | |
104 | qseries print the entire series file |
|
104 | qseries print the entire series file | |
105 | qtop print the name of the current patch |
|
105 | qtop print the name of the current patch | |
106 | qunapplied print the patches not yet applied |
|
106 | qunapplied print the patches not yet applied | |
107 |
|
107 | |||
108 | File content management: |
|
108 | File content management: | |
109 |
|
109 | |||
110 | qdiff diff of the current patch and subsequent modifications |
|
110 | qdiff diff of the current patch and subsequent modifications | |
111 |
|
111 | |||
112 | Change import/export: |
|
112 | Change import/export: | |
113 |
|
113 | |||
114 | qimport import a patch or existing changeset |
|
114 | qimport import a patch or existing changeset | |
115 |
|
115 | |||
116 | (use 'hg help -v mq' to show built-in aliases and global options) |
|
116 | (use 'hg help -v mq' to show built-in aliases and global options) | |
117 |
|
117 | |||
118 | $ hg init a |
|
118 | $ hg init a | |
119 | $ cd a |
|
119 | $ cd a | |
120 | $ echo a > a |
|
120 | $ echo a > a | |
121 | $ hg ci -Ama |
|
121 | $ hg ci -Ama | |
122 | adding a |
|
122 | adding a | |
123 |
|
123 | |||
124 | $ hg clone . ../k |
|
124 | $ hg clone . ../k | |
125 | updating to branch default |
|
125 | updating to branch default | |
126 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
126 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
127 |
|
127 | |||
128 | $ mkdir b |
|
128 | $ mkdir b | |
129 | $ echo z > b/z |
|
129 | $ echo z > b/z | |
130 | $ hg ci -Ama |
|
130 | $ hg ci -Ama | |
131 | adding b/z |
|
131 | adding b/z | |
132 |
|
132 | |||
133 |
|
133 | |||
134 | qinit |
|
134 | qinit | |
135 |
|
135 | |||
136 | $ hg qinit |
|
136 | $ hg qinit | |
137 |
|
137 | |||
138 | $ cd .. |
|
138 | $ cd .. | |
139 | $ hg init b |
|
139 | $ hg init b | |
140 |
|
140 | |||
141 |
|
141 | |||
142 | -R qinit |
|
142 | -R qinit | |
143 |
|
143 | |||
144 | $ hg -R b qinit |
|
144 | $ hg -R b qinit | |
145 |
|
145 | |||
146 | $ hg init c |
|
146 | $ hg init c | |
147 |
|
147 | |||
148 |
|
148 | |||
149 | qinit -c |
|
149 | qinit -c | |
150 |
|
150 | |||
151 | $ hg --cwd c qinit -c |
|
151 | $ hg --cwd c qinit -c | |
152 | $ hg -R c/.hg/patches st |
|
152 | $ hg -R c/.hg/patches st | |
153 | A .hgignore |
|
153 | A .hgignore | |
154 | A series |
|
154 | A series | |
155 |
|
155 | |||
156 |
|
156 | |||
157 | qinit; qinit -c |
|
157 | qinit; qinit -c | |
158 |
|
158 | |||
159 | $ hg init d |
|
159 | $ hg init d | |
160 | $ cd d |
|
160 | $ cd d | |
161 | $ hg qinit |
|
161 | $ hg qinit | |
162 | $ hg qinit -c |
|
162 | $ hg qinit -c | |
163 |
|
163 | |||
164 | qinit -c should create both files if they don't exist |
|
164 | qinit -c should create both files if they don't exist | |
165 |
|
165 | |||
166 | $ cat .hg/patches/.hgignore |
|
166 | $ cat .hg/patches/.hgignore | |
167 | ^\.hg |
|
167 | ^\.hg | |
168 | ^\.mq |
|
168 | ^\.mq | |
169 | syntax: glob |
|
169 | syntax: glob | |
170 | status |
|
170 | status | |
171 | guards |
|
171 | guards | |
172 | $ cat .hg/patches/series |
|
172 | $ cat .hg/patches/series | |
173 | $ hg qinit -c |
|
173 | $ hg qinit -c | |
174 | abort: repository $TESTTMP/d/.hg/patches already exists! |
|
174 | abort: repository $TESTTMP/d/.hg/patches already exists! | |
175 | [255] |
|
175 | [255] | |
176 | $ cd .. |
|
176 | $ cd .. | |
177 |
|
177 | |||
178 | $ echo '% qinit; <stuff>; qinit -c' |
|
178 | $ echo '% qinit; <stuff>; qinit -c' | |
179 | % qinit; <stuff>; qinit -c |
|
179 | % qinit; <stuff>; qinit -c | |
180 | $ hg init e |
|
180 | $ hg init e | |
181 | $ cd e |
|
181 | $ cd e | |
182 | $ hg qnew A |
|
182 | $ hg qnew A | |
183 | $ checkundo qnew |
|
183 | $ checkundo qnew | |
184 | $ echo foo > foo |
|
184 | $ echo foo > foo | |
185 | $ hg phase -r qbase |
|
185 | $ hg phase -r qbase | |
186 | 0: draft |
|
186 | 0: draft | |
187 | $ hg add foo |
|
187 | $ hg add foo | |
188 | $ hg qrefresh |
|
188 | $ hg qrefresh | |
189 | $ hg phase -r qbase |
|
189 | $ hg phase -r qbase | |
190 | 0: draft |
|
190 | 0: draft | |
191 | $ hg qnew B |
|
191 | $ hg qnew B | |
192 | $ echo >> foo |
|
192 | $ echo >> foo | |
193 | $ hg qrefresh |
|
193 | $ hg qrefresh | |
194 | $ echo status >> .hg/patches/.hgignore |
|
194 | $ echo status >> .hg/patches/.hgignore | |
195 | $ echo bleh >> .hg/patches/.hgignore |
|
195 | $ echo bleh >> .hg/patches/.hgignore | |
196 | $ hg qinit -c |
|
196 | $ hg qinit -c | |
197 | adding .hg/patches/A |
|
197 | adding .hg/patches/A | |
198 | adding .hg/patches/B |
|
198 | adding .hg/patches/B | |
199 | $ hg -R .hg/patches status |
|
199 | $ hg -R .hg/patches status | |
200 | A .hgignore |
|
200 | A .hgignore | |
201 | A A |
|
201 | A A | |
202 | A B |
|
202 | A B | |
203 | A series |
|
203 | A series | |
204 |
|
204 | |||
205 | qinit -c shouldn't touch these files if they already exist |
|
205 | qinit -c shouldn't touch these files if they already exist | |
206 |
|
206 | |||
207 | $ cat .hg/patches/.hgignore |
|
207 | $ cat .hg/patches/.hgignore | |
208 | status |
|
208 | status | |
209 | bleh |
|
209 | bleh | |
210 | $ cat .hg/patches/series |
|
210 | $ cat .hg/patches/series | |
211 | A |
|
211 | A | |
212 | B |
|
212 | B | |
213 |
|
213 | |||
214 | add an untracked file |
|
214 | add an untracked file | |
215 |
|
215 | |||
216 | $ echo >> .hg/patches/flaf |
|
216 | $ echo >> .hg/patches/flaf | |
217 |
|
217 | |||
218 | status --mq with color (issue2096) |
|
218 | status --mq with color (issue2096) | |
219 |
|
219 | |||
220 | $ hg status --mq --config extensions.color= --config color.mode=ansi --color=always |
|
220 | $ hg status --mq --config extensions.color= --config color.mode=ansi --color=always | |
221 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1m.hgignore\x1b[0m (esc) |
|
221 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1m.hgignore\x1b[0m (esc) | |
222 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mA\x1b[0m (esc) |
|
222 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mA\x1b[0m (esc) | |
223 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mB\x1b[0m (esc) |
|
223 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mB\x1b[0m (esc) | |
224 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mseries\x1b[0m (esc) |
|
224 | \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mseries\x1b[0m (esc) | |
225 | \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mflaf\x1b[0m (esc) |
|
225 | \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mflaf\x1b[0m (esc) | |
226 |
|
226 | |||
227 | try the --mq option on a command provided by an extension |
|
227 | try the --mq option on a command provided by an extension | |
228 |
|
228 | |||
229 | $ hg purge --mq --verbose --config extensions.purge= |
|
229 | $ hg purge --mq --verbose --config extensions.purge= | |
230 | removing file flaf |
|
230 | removing file flaf | |
231 |
|
231 | |||
232 | $ cd .. |
|
232 | $ cd .. | |
233 |
|
233 | |||
234 | #if no-outer-repo |
|
234 | #if no-outer-repo | |
235 |
|
235 | |||
236 | init --mq without repo |
|
236 | init --mq without repo | |
237 |
|
237 | |||
238 | $ mkdir f |
|
238 | $ mkdir f | |
239 | $ cd f |
|
239 | $ cd f | |
240 | $ hg init --mq |
|
240 | $ hg init --mq | |
241 | abort: there is no Mercurial repository here (.hg not found) |
|
241 | abort: there is no Mercurial repository here (.hg not found) | |
242 | [255] |
|
242 | [255] | |
243 | $ cd .. |
|
243 | $ cd .. | |
244 |
|
244 | |||
245 | #endif |
|
245 | #endif | |
246 |
|
246 | |||
247 | init --mq with repo path |
|
247 | init --mq with repo path | |
248 |
|
248 | |||
249 | $ hg init g |
|
249 | $ hg init g | |
250 | $ hg init --mq g |
|
250 | $ hg init --mq g | |
251 | $ test -d g/.hg/patches/.hg |
|
251 | $ test -d g/.hg/patches/.hg | |
252 |
|
252 | |||
253 | init --mq with nonexistent directory |
|
253 | init --mq with nonexistent directory | |
254 |
|
254 | |||
255 | $ hg init --mq nonexistentdir |
|
255 | $ hg init --mq nonexistentdir | |
256 | abort: repository nonexistentdir not found! |
|
256 | abort: repository nonexistentdir not found! | |
257 | [255] |
|
257 | [255] | |
258 |
|
258 | |||
259 |
|
259 | |||
260 | init --mq with bundle (non "local") |
|
260 | init --mq with bundle (non "local") | |
261 |
|
261 | |||
262 | $ hg -R a bundle --all a.bundle >/dev/null |
|
262 | $ hg -R a bundle --all a.bundle >/dev/null | |
263 | $ hg init --mq a.bundle |
|
263 | $ hg init --mq a.bundle | |
264 | abort: only a local queue repository may be initialized |
|
264 | abort: only a local queue repository may be initialized | |
265 | [255] |
|
265 | [255] | |
266 |
|
266 | |||
267 | $ cd a |
|
267 | $ cd a | |
268 |
|
268 | |||
269 | $ hg qnew -m 'foo bar' test.patch |
|
269 | $ hg qnew -m 'foo bar' test.patch | |
270 |
|
270 | |||
271 | $ echo '# comment' > .hg/patches/series.tmp |
|
271 | $ echo '# comment' > .hg/patches/series.tmp | |
272 | $ echo >> .hg/patches/series.tmp # empty line |
|
272 | $ echo >> .hg/patches/series.tmp # empty line | |
273 | $ cat .hg/patches/series >> .hg/patches/series.tmp |
|
273 | $ cat .hg/patches/series >> .hg/patches/series.tmp | |
274 | $ mv .hg/patches/series.tmp .hg/patches/series |
|
274 | $ mv .hg/patches/series.tmp .hg/patches/series | |
275 |
|
275 | |||
276 |
|
276 | |||
277 | qrefresh |
|
277 | qrefresh | |
278 |
|
278 | |||
279 | $ echo a >> a |
|
279 | $ echo a >> a | |
280 | $ hg qrefresh |
|
280 | $ hg qrefresh | |
281 | $ cat .hg/patches/test.patch |
|
281 | $ cat .hg/patches/test.patch | |
282 | foo bar |
|
282 | foo bar | |
283 |
|
283 | |||
284 | diff -r [a-f0-9]* a (re) |
|
284 | diff -r [a-f0-9]* a (re) | |
285 | --- a/a\t(?P<date>.*) (re) |
|
285 | --- a/a\t(?P<date>.*) (re) | |
286 | \+\+\+ b/a\t(?P<date2>.*) (re) |
|
286 | \+\+\+ b/a\t(?P<date2>.*) (re) | |
287 | @@ -1,1 +1,2 @@ |
|
287 | @@ -1,1 +1,2 @@ | |
288 | a |
|
288 | a | |
289 | +a |
|
289 | +a | |
290 |
|
290 | |||
291 | empty qrefresh |
|
291 | empty qrefresh | |
292 |
|
292 | |||
293 | $ hg qrefresh -X a |
|
293 | $ hg qrefresh -X a | |
294 |
|
294 | |||
295 | revision: |
|
295 | revision: | |
296 |
|
296 | |||
297 | $ hg diff -r -2 -r -1 |
|
297 | $ hg diff -r -2 -r -1 | |
298 |
|
298 | |||
299 | patch: |
|
299 | patch: | |
300 |
|
300 | |||
301 | $ cat .hg/patches/test.patch |
|
301 | $ cat .hg/patches/test.patch | |
302 | foo bar |
|
302 | foo bar | |
303 |
|
303 | |||
304 |
|
304 | |||
305 | working dir diff: |
|
305 | working dir diff: | |
306 |
|
306 | |||
307 | $ hg diff --nodates -q |
|
307 | $ hg diff --nodates -q | |
|
308 | diff -r dde259bd5934 a | |||
308 | --- a/a |
|
309 | --- a/a | |
309 | +++ b/a |
|
310 | +++ b/a | |
310 | @@ -1,1 +1,2 @@ |
|
311 | @@ -1,1 +1,2 @@ | |
311 | a |
|
312 | a | |
312 | +a |
|
313 | +a | |
313 |
|
314 | |||
314 | restore things |
|
315 | restore things | |
315 |
|
316 | |||
316 | $ hg qrefresh |
|
317 | $ hg qrefresh | |
317 | $ checkundo qrefresh |
|
318 | $ checkundo qrefresh | |
318 |
|
319 | |||
319 |
|
320 | |||
320 | qpop |
|
321 | qpop | |
321 |
|
322 | |||
322 | $ hg qpop |
|
323 | $ hg qpop | |
323 | popping test.patch |
|
324 | popping test.patch | |
324 | patch queue now empty |
|
325 | patch queue now empty | |
325 | $ checkundo qpop |
|
326 | $ checkundo qpop | |
326 |
|
327 | |||
327 |
|
328 | |||
328 | qpush with dump of tag cache |
|
329 | qpush with dump of tag cache | |
329 | Dump the tag cache to ensure that it has exactly one head after qpush. |
|
330 | Dump the tag cache to ensure that it has exactly one head after qpush. | |
330 |
|
331 | |||
331 | $ rm -f .hg/cache/tags2-visible |
|
332 | $ rm -f .hg/cache/tags2-visible | |
332 | $ hg tags > /dev/null |
|
333 | $ hg tags > /dev/null | |
333 |
|
334 | |||
334 | .hg/cache/tags2-visible (pre qpush): |
|
335 | .hg/cache/tags2-visible (pre qpush): | |
335 |
|
336 | |||
336 | $ cat .hg/cache/tags2-visible |
|
337 | $ cat .hg/cache/tags2-visible | |
337 | 1 [\da-f]{40} (re) |
|
338 | 1 [\da-f]{40} (re) | |
338 | $ hg qpush |
|
339 | $ hg qpush | |
339 | applying test.patch |
|
340 | applying test.patch | |
340 | now at: test.patch |
|
341 | now at: test.patch | |
341 | $ hg phase -r qbase |
|
342 | $ hg phase -r qbase | |
342 | 2: draft |
|
343 | 2: draft | |
343 | $ hg tags > /dev/null |
|
344 | $ hg tags > /dev/null | |
344 |
|
345 | |||
345 | .hg/cache/tags2-visible (post qpush): |
|
346 | .hg/cache/tags2-visible (post qpush): | |
346 |
|
347 | |||
347 | $ cat .hg/cache/tags2-visible |
|
348 | $ cat .hg/cache/tags2-visible | |
348 | 2 [\da-f]{40} (re) |
|
349 | 2 [\da-f]{40} (re) | |
349 | $ checkundo qpush |
|
350 | $ checkundo qpush | |
350 | $ cd .. |
|
351 | $ cd .. | |
351 |
|
352 | |||
352 |
|
353 | |||
353 | pop/push outside repo |
|
354 | pop/push outside repo | |
354 | $ hg -R a qpop |
|
355 | $ hg -R a qpop | |
355 | popping test.patch |
|
356 | popping test.patch | |
356 | patch queue now empty |
|
357 | patch queue now empty | |
357 | $ hg -R a qpush |
|
358 | $ hg -R a qpush | |
358 | applying test.patch |
|
359 | applying test.patch | |
359 | now at: test.patch |
|
360 | now at: test.patch | |
360 |
|
361 | |||
361 | $ cd a |
|
362 | $ cd a | |
362 | $ hg qnew test2.patch |
|
363 | $ hg qnew test2.patch | |
363 |
|
364 | |||
364 | qrefresh in subdir |
|
365 | qrefresh in subdir | |
365 |
|
366 | |||
366 | $ cd b |
|
367 | $ cd b | |
367 | $ echo a > a |
|
368 | $ echo a > a | |
368 | $ hg add a |
|
369 | $ hg add a | |
369 | $ hg qrefresh |
|
370 | $ hg qrefresh | |
370 |
|
371 | |||
371 | pop/push -a in subdir |
|
372 | pop/push -a in subdir | |
372 |
|
373 | |||
373 | $ hg qpop -a |
|
374 | $ hg qpop -a | |
374 | popping test2.patch |
|
375 | popping test2.patch | |
375 | popping test.patch |
|
376 | popping test.patch | |
376 | patch queue now empty |
|
377 | patch queue now empty | |
377 | $ hg --traceback qpush -a |
|
378 | $ hg --traceback qpush -a | |
378 | applying test.patch |
|
379 | applying test.patch | |
379 | applying test2.patch |
|
380 | applying test2.patch | |
380 | now at: test2.patch |
|
381 | now at: test2.patch | |
381 |
|
382 | |||
382 |
|
383 | |||
383 | setting columns & formatted tests truncating (issue1912) |
|
384 | setting columns & formatted tests truncating (issue1912) | |
384 |
|
385 | |||
385 | $ COLUMNS=4 hg qseries --config ui.formatted=true --color=no |
|
386 | $ COLUMNS=4 hg qseries --config ui.formatted=true --color=no | |
386 | test.patch |
|
387 | test.patch | |
387 | test2.patch |
|
388 | test2.patch | |
388 | $ COLUMNS=20 hg qseries --config ui.formatted=true -vs --color=no |
|
389 | $ COLUMNS=20 hg qseries --config ui.formatted=true -vs --color=no | |
389 | 0 A test.patch: f... |
|
390 | 0 A test.patch: f... | |
390 | 1 A test2.patch: |
|
391 | 1 A test2.patch: | |
391 | $ hg qpop |
|
392 | $ hg qpop | |
392 | popping test2.patch |
|
393 | popping test2.patch | |
393 | now at: test.patch |
|
394 | now at: test.patch | |
394 | $ hg qseries -vs |
|
395 | $ hg qseries -vs | |
395 | 0 A test.patch: foo bar |
|
396 | 0 A test.patch: foo bar | |
396 | 1 U test2.patch: |
|
397 | 1 U test2.patch: | |
397 | $ hg sum | grep mq |
|
398 | $ hg sum | grep mq | |
398 | mq: 1 applied, 1 unapplied |
|
399 | mq: 1 applied, 1 unapplied | |
399 | $ hg qpush |
|
400 | $ hg qpush | |
400 | applying test2.patch |
|
401 | applying test2.patch | |
401 | now at: test2.patch |
|
402 | now at: test2.patch | |
402 | $ hg sum | grep mq |
|
403 | $ hg sum | grep mq | |
403 | mq: 2 applied |
|
404 | mq: 2 applied | |
404 | $ hg qapplied |
|
405 | $ hg qapplied | |
405 | test.patch |
|
406 | test.patch | |
406 | test2.patch |
|
407 | test2.patch | |
407 | $ hg qtop |
|
408 | $ hg qtop | |
408 | test2.patch |
|
409 | test2.patch | |
409 |
|
410 | |||
410 |
|
411 | |||
411 | prev |
|
412 | prev | |
412 |
|
413 | |||
413 | $ hg qapp -1 |
|
414 | $ hg qapp -1 | |
414 | test.patch |
|
415 | test.patch | |
415 |
|
416 | |||
416 | next |
|
417 | next | |
417 |
|
418 | |||
418 | $ hg qunapp -1 |
|
419 | $ hg qunapp -1 | |
419 | all patches applied |
|
420 | all patches applied | |
420 | [1] |
|
421 | [1] | |
421 |
|
422 | |||
422 | $ hg qpop |
|
423 | $ hg qpop | |
423 | popping test2.patch |
|
424 | popping test2.patch | |
424 | now at: test.patch |
|
425 | now at: test.patch | |
425 |
|
426 | |||
426 | commit should fail |
|
427 | commit should fail | |
427 |
|
428 | |||
428 | $ hg commit |
|
429 | $ hg commit | |
429 | abort: cannot commit over an applied mq patch |
|
430 | abort: cannot commit over an applied mq patch | |
430 | [255] |
|
431 | [255] | |
431 |
|
432 | |||
432 | push should fail if draft |
|
433 | push should fail if draft | |
433 |
|
434 | |||
434 | $ hg push ../../k |
|
435 | $ hg push ../../k | |
435 | pushing to ../../k |
|
436 | pushing to ../../k | |
436 | abort: source has mq patches applied |
|
437 | abort: source has mq patches applied | |
437 | [255] |
|
438 | [255] | |
438 |
|
439 | |||
439 |
|
440 | |||
440 | import should fail |
|
441 | import should fail | |
441 |
|
442 | |||
442 | $ hg st . |
|
443 | $ hg st . | |
443 | $ echo foo >> ../a |
|
444 | $ echo foo >> ../a | |
444 | $ hg diff > ../../import.diff |
|
445 | $ hg diff > ../../import.diff | |
445 | $ hg revert --no-backup ../a |
|
446 | $ hg revert --no-backup ../a | |
446 | $ hg import ../../import.diff |
|
447 | $ hg import ../../import.diff | |
447 | abort: cannot import over an applied patch |
|
448 | abort: cannot import over an applied patch | |
448 | [255] |
|
449 | [255] | |
449 | $ hg st |
|
450 | $ hg st | |
450 |
|
451 | |||
451 | import --no-commit should succeed |
|
452 | import --no-commit should succeed | |
452 |
|
453 | |||
453 | $ hg import --no-commit ../../import.diff |
|
454 | $ hg import --no-commit ../../import.diff | |
454 | applying ../../import.diff |
|
455 | applying ../../import.diff | |
455 | $ hg st |
|
456 | $ hg st | |
456 | M a |
|
457 | M a | |
457 | $ hg revert --no-backup ../a |
|
458 | $ hg revert --no-backup ../a | |
458 |
|
459 | |||
459 |
|
460 | |||
460 | qunapplied |
|
461 | qunapplied | |
461 |
|
462 | |||
462 | $ hg qunapplied |
|
463 | $ hg qunapplied | |
463 | test2.patch |
|
464 | test2.patch | |
464 |
|
465 | |||
465 |
|
466 | |||
466 | qpush/qpop with index |
|
467 | qpush/qpop with index | |
467 |
|
468 | |||
468 | $ hg qnew test1b.patch |
|
469 | $ hg qnew test1b.patch | |
469 | $ echo 1b > 1b |
|
470 | $ echo 1b > 1b | |
470 | $ hg add 1b |
|
471 | $ hg add 1b | |
471 | $ hg qrefresh |
|
472 | $ hg qrefresh | |
472 | $ hg qpush 2 |
|
473 | $ hg qpush 2 | |
473 | applying test2.patch |
|
474 | applying test2.patch | |
474 | now at: test2.patch |
|
475 | now at: test2.patch | |
475 | $ hg qpop 0 |
|
476 | $ hg qpop 0 | |
476 | popping test2.patch |
|
477 | popping test2.patch | |
477 | popping test1b.patch |
|
478 | popping test1b.patch | |
478 | now at: test.patch |
|
479 | now at: test.patch | |
479 | $ hg qpush test.patch+1 |
|
480 | $ hg qpush test.patch+1 | |
480 | applying test1b.patch |
|
481 | applying test1b.patch | |
481 | now at: test1b.patch |
|
482 | now at: test1b.patch | |
482 | $ hg qpush test.patch+2 |
|
483 | $ hg qpush test.patch+2 | |
483 | applying test2.patch |
|
484 | applying test2.patch | |
484 | now at: test2.patch |
|
485 | now at: test2.patch | |
485 | $ hg qpop test2.patch-1 |
|
486 | $ hg qpop test2.patch-1 | |
486 | popping test2.patch |
|
487 | popping test2.patch | |
487 | now at: test1b.patch |
|
488 | now at: test1b.patch | |
488 | $ hg qpop test2.patch-2 |
|
489 | $ hg qpop test2.patch-2 | |
489 | popping test1b.patch |
|
490 | popping test1b.patch | |
490 | now at: test.patch |
|
491 | now at: test.patch | |
491 | $ hg qpush test1b.patch+1 |
|
492 | $ hg qpush test1b.patch+1 | |
492 | applying test1b.patch |
|
493 | applying test1b.patch | |
493 | applying test2.patch |
|
494 | applying test2.patch | |
494 | now at: test2.patch |
|
495 | now at: test2.patch | |
495 |
|
496 | |||
496 |
|
497 | |||
497 | qpush --move |
|
498 | qpush --move | |
498 |
|
499 | |||
499 | $ hg qpop -a |
|
500 | $ hg qpop -a | |
500 | popping test2.patch |
|
501 | popping test2.patch | |
501 | popping test1b.patch |
|
502 | popping test1b.patch | |
502 | popping test.patch |
|
503 | popping test.patch | |
503 | patch queue now empty |
|
504 | patch queue now empty | |
504 | $ hg qguard test1b.patch -- -negguard |
|
505 | $ hg qguard test1b.patch -- -negguard | |
505 | $ hg qguard test2.patch -- +posguard |
|
506 | $ hg qguard test2.patch -- +posguard | |
506 | $ hg qpush --move test2.patch # can't move guarded patch |
|
507 | $ hg qpush --move test2.patch # can't move guarded patch | |
507 | cannot push 'test2.patch' - guarded by '+posguard' |
|
508 | cannot push 'test2.patch' - guarded by '+posguard' | |
508 | [1] |
|
509 | [1] | |
509 | $ hg qselect posguard |
|
510 | $ hg qselect posguard | |
510 | number of unguarded, unapplied patches has changed from 2 to 3 |
|
511 | number of unguarded, unapplied patches has changed from 2 to 3 | |
511 | $ hg qpush --move test2.patch # move to front |
|
512 | $ hg qpush --move test2.patch # move to front | |
512 | applying test2.patch |
|
513 | applying test2.patch | |
513 | now at: test2.patch |
|
514 | now at: test2.patch | |
514 | $ hg qpush --move test1b.patch # negative guard unselected |
|
515 | $ hg qpush --move test1b.patch # negative guard unselected | |
515 | applying test1b.patch |
|
516 | applying test1b.patch | |
516 | now at: test1b.patch |
|
517 | now at: test1b.patch | |
517 | $ hg qpush --move test.patch # noop move |
|
518 | $ hg qpush --move test.patch # noop move | |
518 | applying test.patch |
|
519 | applying test.patch | |
519 | now at: test.patch |
|
520 | now at: test.patch | |
520 | $ hg qseries -v |
|
521 | $ hg qseries -v | |
521 | 0 A test2.patch |
|
522 | 0 A test2.patch | |
522 | 1 A test1b.patch |
|
523 | 1 A test1b.patch | |
523 | 2 A test.patch |
|
524 | 2 A test.patch | |
524 | $ hg qpop -a |
|
525 | $ hg qpop -a | |
525 | popping test.patch |
|
526 | popping test.patch | |
526 | popping test1b.patch |
|
527 | popping test1b.patch | |
527 | popping test2.patch |
|
528 | popping test2.patch | |
528 | patch queue now empty |
|
529 | patch queue now empty | |
529 |
|
530 | |||
530 | cleaning up |
|
531 | cleaning up | |
531 |
|
532 | |||
532 | $ hg qselect --none |
|
533 | $ hg qselect --none | |
533 | guards deactivated |
|
534 | guards deactivated | |
534 | number of unguarded, unapplied patches has changed from 3 to 2 |
|
535 | number of unguarded, unapplied patches has changed from 3 to 2 | |
535 | $ hg qguard --none test1b.patch |
|
536 | $ hg qguard --none test1b.patch | |
536 | $ hg qguard --none test2.patch |
|
537 | $ hg qguard --none test2.patch | |
537 | $ hg qpush --move test.patch |
|
538 | $ hg qpush --move test.patch | |
538 | applying test.patch |
|
539 | applying test.patch | |
539 | now at: test.patch |
|
540 | now at: test.patch | |
540 | $ hg qpush --move test1b.patch |
|
541 | $ hg qpush --move test1b.patch | |
541 | applying test1b.patch |
|
542 | applying test1b.patch | |
542 | now at: test1b.patch |
|
543 | now at: test1b.patch | |
543 | $ hg qpush --move bogus # nonexistent patch |
|
544 | $ hg qpush --move bogus # nonexistent patch | |
544 | abort: patch bogus not in series |
|
545 | abort: patch bogus not in series | |
545 | [255] |
|
546 | [255] | |
546 | $ hg qpush --move # no patch |
|
547 | $ hg qpush --move # no patch | |
547 | abort: please specify the patch to move |
|
548 | abort: please specify the patch to move | |
548 | [255] |
|
549 | [255] | |
549 | $ hg qpush --move test.patch # already applied |
|
550 | $ hg qpush --move test.patch # already applied | |
550 | abort: cannot push to a previous patch: test.patch |
|
551 | abort: cannot push to a previous patch: test.patch | |
551 | [255] |
|
552 | [255] | |
552 | $ sed '2i\ |
|
553 | $ sed '2i\ | |
553 | > # make qtip index different in series and fullseries |
|
554 | > # make qtip index different in series and fullseries | |
554 | > ' `hg root`/.hg/patches/series > $TESTTMP/sedtmp |
|
555 | > ' `hg root`/.hg/patches/series > $TESTTMP/sedtmp | |
555 | $ cp $TESTTMP/sedtmp `hg root`/.hg/patches/series |
|
556 | $ cp $TESTTMP/sedtmp `hg root`/.hg/patches/series | |
556 | $ cat `hg root`/.hg/patches/series |
|
557 | $ cat `hg root`/.hg/patches/series | |
557 | # comment |
|
558 | # comment | |
558 | # make qtip index different in series and fullseries |
|
559 | # make qtip index different in series and fullseries | |
559 |
|
560 | |||
560 | test.patch |
|
561 | test.patch | |
561 | test1b.patch |
|
562 | test1b.patch | |
562 | test2.patch |
|
563 | test2.patch | |
563 | $ hg qpush --move test2.patch |
|
564 | $ hg qpush --move test2.patch | |
564 | applying test2.patch |
|
565 | applying test2.patch | |
565 | now at: test2.patch |
|
566 | now at: test2.patch | |
566 |
|
567 | |||
567 |
|
568 | |||
568 | series after move |
|
569 | series after move | |
569 |
|
570 | |||
570 | $ cat `hg root`/.hg/patches/series |
|
571 | $ cat `hg root`/.hg/patches/series | |
571 | # comment |
|
572 | # comment | |
572 | # make qtip index different in series and fullseries |
|
573 | # make qtip index different in series and fullseries | |
573 |
|
574 | |||
574 | test.patch |
|
575 | test.patch | |
575 | test1b.patch |
|
576 | test1b.patch | |
576 | test2.patch |
|
577 | test2.patch | |
577 |
|
578 | |||
578 |
|
579 | |||
579 | pop, qapplied, qunapplied |
|
580 | pop, qapplied, qunapplied | |
580 |
|
581 | |||
581 | $ hg qseries -v |
|
582 | $ hg qseries -v | |
582 | 0 A test.patch |
|
583 | 0 A test.patch | |
583 | 1 A test1b.patch |
|
584 | 1 A test1b.patch | |
584 | 2 A test2.patch |
|
585 | 2 A test2.patch | |
585 |
|
586 | |||
586 | qapplied -1 test.patch |
|
587 | qapplied -1 test.patch | |
587 |
|
588 | |||
588 | $ hg qapplied -1 test.patch |
|
589 | $ hg qapplied -1 test.patch | |
589 | only one patch applied |
|
590 | only one patch applied | |
590 | [1] |
|
591 | [1] | |
591 |
|
592 | |||
592 | qapplied -1 test1b.patch |
|
593 | qapplied -1 test1b.patch | |
593 |
|
594 | |||
594 | $ hg qapplied -1 test1b.patch |
|
595 | $ hg qapplied -1 test1b.patch | |
595 | test.patch |
|
596 | test.patch | |
596 |
|
597 | |||
597 | qapplied -1 test2.patch |
|
598 | qapplied -1 test2.patch | |
598 |
|
599 | |||
599 | $ hg qapplied -1 test2.patch |
|
600 | $ hg qapplied -1 test2.patch | |
600 | test1b.patch |
|
601 | test1b.patch | |
601 |
|
602 | |||
602 | qapplied -1 |
|
603 | qapplied -1 | |
603 |
|
604 | |||
604 | $ hg qapplied -1 |
|
605 | $ hg qapplied -1 | |
605 | test1b.patch |
|
606 | test1b.patch | |
606 |
|
607 | |||
607 | qapplied |
|
608 | qapplied | |
608 |
|
609 | |||
609 | $ hg qapplied |
|
610 | $ hg qapplied | |
610 | test.patch |
|
611 | test.patch | |
611 | test1b.patch |
|
612 | test1b.patch | |
612 | test2.patch |
|
613 | test2.patch | |
613 |
|
614 | |||
614 | qapplied test1b.patch |
|
615 | qapplied test1b.patch | |
615 |
|
616 | |||
616 | $ hg qapplied test1b.patch |
|
617 | $ hg qapplied test1b.patch | |
617 | test.patch |
|
618 | test.patch | |
618 | test1b.patch |
|
619 | test1b.patch | |
619 |
|
620 | |||
620 | qunapplied -1 |
|
621 | qunapplied -1 | |
621 |
|
622 | |||
622 | $ hg qunapplied -1 |
|
623 | $ hg qunapplied -1 | |
623 | all patches applied |
|
624 | all patches applied | |
624 | [1] |
|
625 | [1] | |
625 |
|
626 | |||
626 | qunapplied |
|
627 | qunapplied | |
627 |
|
628 | |||
628 | $ hg qunapplied |
|
629 | $ hg qunapplied | |
629 |
|
630 | |||
630 | popping |
|
631 | popping | |
631 |
|
632 | |||
632 | $ hg qpop |
|
633 | $ hg qpop | |
633 | popping test2.patch |
|
634 | popping test2.patch | |
634 | now at: test1b.patch |
|
635 | now at: test1b.patch | |
635 |
|
636 | |||
636 | qunapplied -1 |
|
637 | qunapplied -1 | |
637 |
|
638 | |||
638 | $ hg qunapplied -1 |
|
639 | $ hg qunapplied -1 | |
639 | test2.patch |
|
640 | test2.patch | |
640 |
|
641 | |||
641 | qunapplied |
|
642 | qunapplied | |
642 |
|
643 | |||
643 | $ hg qunapplied |
|
644 | $ hg qunapplied | |
644 | test2.patch |
|
645 | test2.patch | |
645 |
|
646 | |||
646 | qunapplied test2.patch |
|
647 | qunapplied test2.patch | |
647 |
|
648 | |||
648 | $ hg qunapplied test2.patch |
|
649 | $ hg qunapplied test2.patch | |
649 |
|
650 | |||
650 | qunapplied -1 test2.patch |
|
651 | qunapplied -1 test2.patch | |
651 |
|
652 | |||
652 | $ hg qunapplied -1 test2.patch |
|
653 | $ hg qunapplied -1 test2.patch | |
653 | all patches applied |
|
654 | all patches applied | |
654 | [1] |
|
655 | [1] | |
655 |
|
656 | |||
656 | popping -a |
|
657 | popping -a | |
657 |
|
658 | |||
658 | $ hg qpop -a |
|
659 | $ hg qpop -a | |
659 | popping test1b.patch |
|
660 | popping test1b.patch | |
660 | popping test.patch |
|
661 | popping test.patch | |
661 | patch queue now empty |
|
662 | patch queue now empty | |
662 |
|
663 | |||
663 | qapplied |
|
664 | qapplied | |
664 |
|
665 | |||
665 | $ hg qapplied |
|
666 | $ hg qapplied | |
666 |
|
667 | |||
667 | qapplied -1 |
|
668 | qapplied -1 | |
668 |
|
669 | |||
669 | $ hg qapplied -1 |
|
670 | $ hg qapplied -1 | |
670 | no patches applied |
|
671 | no patches applied | |
671 | [1] |
|
672 | [1] | |
672 | $ hg qpush |
|
673 | $ hg qpush | |
673 | applying test.patch |
|
674 | applying test.patch | |
674 | now at: test.patch |
|
675 | now at: test.patch | |
675 |
|
676 | |||
676 |
|
677 | |||
677 | push should succeed |
|
678 | push should succeed | |
678 |
|
679 | |||
679 | $ hg qpop -a |
|
680 | $ hg qpop -a | |
680 | popping test.patch |
|
681 | popping test.patch | |
681 | patch queue now empty |
|
682 | patch queue now empty | |
682 | $ hg push ../../k |
|
683 | $ hg push ../../k | |
683 | pushing to ../../k |
|
684 | pushing to ../../k | |
684 | searching for changes |
|
685 | searching for changes | |
685 | adding changesets |
|
686 | adding changesets | |
686 | adding manifests |
|
687 | adding manifests | |
687 | adding file changes |
|
688 | adding file changes | |
688 | added 1 changesets with 1 changes to 1 files |
|
689 | added 1 changesets with 1 changes to 1 files | |
689 |
|
690 | |||
690 |
|
691 | |||
691 | we want to start with some patches applied |
|
692 | we want to start with some patches applied | |
692 |
|
693 | |||
693 | $ hg qpush -a |
|
694 | $ hg qpush -a | |
694 | applying test.patch |
|
695 | applying test.patch | |
695 | applying test1b.patch |
|
696 | applying test1b.patch | |
696 | applying test2.patch |
|
697 | applying test2.patch | |
697 | now at: test2.patch |
|
698 | now at: test2.patch | |
698 |
|
699 | |||
699 | % pops all patches and succeeds |
|
700 | % pops all patches and succeeds | |
700 |
|
701 | |||
701 | $ hg qpop -a |
|
702 | $ hg qpop -a | |
702 | popping test2.patch |
|
703 | popping test2.patch | |
703 | popping test1b.patch |
|
704 | popping test1b.patch | |
704 | popping test.patch |
|
705 | popping test.patch | |
705 | patch queue now empty |
|
706 | patch queue now empty | |
706 |
|
707 | |||
707 | % does nothing and succeeds |
|
708 | % does nothing and succeeds | |
708 |
|
709 | |||
709 | $ hg qpop -a |
|
710 | $ hg qpop -a | |
710 | no patches applied |
|
711 | no patches applied | |
711 |
|
712 | |||
712 | % fails - nothing else to pop |
|
713 | % fails - nothing else to pop | |
713 |
|
714 | |||
714 | $ hg qpop |
|
715 | $ hg qpop | |
715 | no patches applied |
|
716 | no patches applied | |
716 | [1] |
|
717 | [1] | |
717 |
|
718 | |||
718 | % pushes a patch and succeeds |
|
719 | % pushes a patch and succeeds | |
719 |
|
720 | |||
720 | $ hg qpush |
|
721 | $ hg qpush | |
721 | applying test.patch |
|
722 | applying test.patch | |
722 | now at: test.patch |
|
723 | now at: test.patch | |
723 |
|
724 | |||
724 | % pops a patch and succeeds |
|
725 | % pops a patch and succeeds | |
725 |
|
726 | |||
726 | $ hg qpop |
|
727 | $ hg qpop | |
727 | popping test.patch |
|
728 | popping test.patch | |
728 | patch queue now empty |
|
729 | patch queue now empty | |
729 |
|
730 | |||
730 | % pushes up to test1b.patch and succeeds |
|
731 | % pushes up to test1b.patch and succeeds | |
731 |
|
732 | |||
732 | $ hg qpush test1b.patch |
|
733 | $ hg qpush test1b.patch | |
733 | applying test.patch |
|
734 | applying test.patch | |
734 | applying test1b.patch |
|
735 | applying test1b.patch | |
735 | now at: test1b.patch |
|
736 | now at: test1b.patch | |
736 |
|
737 | |||
737 | % does nothing and succeeds |
|
738 | % does nothing and succeeds | |
738 |
|
739 | |||
739 | $ hg qpush test1b.patch |
|
740 | $ hg qpush test1b.patch | |
740 | qpush: test1b.patch is already at the top |
|
741 | qpush: test1b.patch is already at the top | |
741 |
|
742 | |||
742 | % does nothing and succeeds |
|
743 | % does nothing and succeeds | |
743 |
|
744 | |||
744 | $ hg qpop test1b.patch |
|
745 | $ hg qpop test1b.patch | |
745 | qpop: test1b.patch is already at the top |
|
746 | qpop: test1b.patch is already at the top | |
746 |
|
747 | |||
747 | % fails - can't push to this patch |
|
748 | % fails - can't push to this patch | |
748 |
|
749 | |||
749 | $ hg qpush test.patch |
|
750 | $ hg qpush test.patch | |
750 | abort: cannot push to a previous patch: test.patch |
|
751 | abort: cannot push to a previous patch: test.patch | |
751 | [255] |
|
752 | [255] | |
752 |
|
753 | |||
753 | % fails - can't pop to this patch |
|
754 | % fails - can't pop to this patch | |
754 |
|
755 | |||
755 | $ hg qpop test2.patch |
|
756 | $ hg qpop test2.patch | |
756 | abort: patch test2.patch is not applied |
|
757 | abort: patch test2.patch is not applied | |
757 | [255] |
|
758 | [255] | |
758 |
|
759 | |||
759 | % pops up to test.patch and succeeds |
|
760 | % pops up to test.patch and succeeds | |
760 |
|
761 | |||
761 | $ hg qpop test.patch |
|
762 | $ hg qpop test.patch | |
762 | popping test1b.patch |
|
763 | popping test1b.patch | |
763 | now at: test.patch |
|
764 | now at: test.patch | |
764 |
|
765 | |||
765 | % pushes all patches and succeeds |
|
766 | % pushes all patches and succeeds | |
766 |
|
767 | |||
767 | $ hg qpush -a |
|
768 | $ hg qpush -a | |
768 | applying test1b.patch |
|
769 | applying test1b.patch | |
769 | applying test2.patch |
|
770 | applying test2.patch | |
770 | now at: test2.patch |
|
771 | now at: test2.patch | |
771 |
|
772 | |||
772 | % does nothing and succeeds |
|
773 | % does nothing and succeeds | |
773 |
|
774 | |||
774 | $ hg qpush -a |
|
775 | $ hg qpush -a | |
775 | all patches are currently applied |
|
776 | all patches are currently applied | |
776 |
|
777 | |||
777 | % fails - nothing else to push |
|
778 | % fails - nothing else to push | |
778 |
|
779 | |||
779 | $ hg qpush |
|
780 | $ hg qpush | |
780 | patch series already fully applied |
|
781 | patch series already fully applied | |
781 | [1] |
|
782 | [1] | |
782 |
|
783 | |||
783 | % does nothing and succeeds |
|
784 | % does nothing and succeeds | |
784 |
|
785 | |||
785 | $ hg qpush test2.patch |
|
786 | $ hg qpush test2.patch | |
786 | qpush: test2.patch is already at the top |
|
787 | qpush: test2.patch is already at the top | |
787 |
|
788 | |||
788 | strip |
|
789 | strip | |
789 |
|
790 | |||
790 | $ cd ../../b |
|
791 | $ cd ../../b | |
791 | $ echo x>x |
|
792 | $ echo x>x | |
792 | $ hg ci -Ama |
|
793 | $ hg ci -Ama | |
793 | adding x |
|
794 | adding x | |
794 | $ hg strip tip |
|
795 | $ hg strip tip | |
795 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
796 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
796 | saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob) |
|
797 | saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob) | |
797 | $ hg unbundle .hg/strip-backup/* |
|
798 | $ hg unbundle .hg/strip-backup/* | |
798 | adding changesets |
|
799 | adding changesets | |
799 | adding manifests |
|
800 | adding manifests | |
800 | adding file changes |
|
801 | adding file changes | |
801 | added 1 changesets with 1 changes to 1 files |
|
802 | added 1 changesets with 1 changes to 1 files | |
802 | new changesets 770eb8fce608 (1 drafts) |
|
803 | new changesets 770eb8fce608 (1 drafts) | |
803 | (run 'hg update' to get a working copy) |
|
804 | (run 'hg update' to get a working copy) | |
804 |
|
805 | |||
805 |
|
806 | |||
806 | strip with local changes, should complain |
|
807 | strip with local changes, should complain | |
807 |
|
808 | |||
808 | $ hg up |
|
809 | $ hg up | |
809 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
810 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
810 | $ echo y>y |
|
811 | $ echo y>y | |
811 | $ hg add y |
|
812 | $ hg add y | |
812 | $ hg strip tip |
|
813 | $ hg strip tip | |
813 | abort: local changes found |
|
814 | abort: local changes found | |
814 | [255] |
|
815 | [255] | |
815 |
|
816 | |||
816 | --force strip with local changes |
|
817 | --force strip with local changes | |
817 |
|
818 | |||
818 | $ hg strip -f tip |
|
819 | $ hg strip -f tip | |
819 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
820 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
820 | saved backup bundle to $TESTTMP/b/.hg/strip-backup/770eb8fce608-0ddcae0f-backup.hg |
|
821 | saved backup bundle to $TESTTMP/b/.hg/strip-backup/770eb8fce608-0ddcae0f-backup.hg | |
821 | $ cd .. |
|
822 | $ cd .. | |
822 |
|
823 | |||
823 |
|
824 | |||
824 | cd b; hg qrefresh |
|
825 | cd b; hg qrefresh | |
825 |
|
826 | |||
826 | $ hg init refresh |
|
827 | $ hg init refresh | |
827 | $ cd refresh |
|
828 | $ cd refresh | |
828 | $ echo a > a |
|
829 | $ echo a > a | |
829 | $ hg ci -Ama |
|
830 | $ hg ci -Ama | |
830 | adding a |
|
831 | adding a | |
831 | $ hg qnew -mfoo foo |
|
832 | $ hg qnew -mfoo foo | |
832 | $ echo a >> a |
|
833 | $ echo a >> a | |
833 | $ hg qrefresh |
|
834 | $ hg qrefresh | |
834 | $ mkdir b |
|
835 | $ mkdir b | |
835 | $ cd b |
|
836 | $ cd b | |
836 | $ echo f > f |
|
837 | $ echo f > f | |
837 | $ hg add f |
|
838 | $ hg add f | |
838 | $ hg qrefresh |
|
839 | $ hg qrefresh | |
839 | $ cat ../.hg/patches/foo |
|
840 | $ cat ../.hg/patches/foo | |
840 | foo |
|
841 | foo | |
841 |
|
842 | |||
842 | diff -r cb9a9f314b8b a |
|
843 | diff -r cb9a9f314b8b a | |
843 | --- a/a\t(?P<date>.*) (re) |
|
844 | --- a/a\t(?P<date>.*) (re) | |
844 | \+\+\+ b/a\t(?P<date>.*) (re) |
|
845 | \+\+\+ b/a\t(?P<date>.*) (re) | |
845 | @@ -1,1 +1,2 @@ |
|
846 | @@ -1,1 +1,2 @@ | |
846 | a |
|
847 | a | |
847 | +a |
|
848 | +a | |
848 | diff -r cb9a9f314b8b b/f |
|
849 | diff -r cb9a9f314b8b b/f | |
849 | --- /dev/null\t(?P<date>.*) (re) |
|
850 | --- /dev/null\t(?P<date>.*) (re) | |
850 | \+\+\+ b/b/f\t(?P<date>.*) (re) |
|
851 | \+\+\+ b/b/f\t(?P<date>.*) (re) | |
851 | @@ -0,0 +1,1 @@ |
|
852 | @@ -0,0 +1,1 @@ | |
852 | +f |
|
853 | +f | |
853 |
|
854 | |||
854 | hg qrefresh . |
|
855 | hg qrefresh . | |
855 |
|
856 | |||
856 | $ hg qrefresh . |
|
857 | $ hg qrefresh . | |
857 | $ cat ../.hg/patches/foo |
|
858 | $ cat ../.hg/patches/foo | |
858 | foo |
|
859 | foo | |
859 |
|
860 | |||
860 | diff -r cb9a9f314b8b b/f |
|
861 | diff -r cb9a9f314b8b b/f | |
861 | --- /dev/null\t(?P<date>.*) (re) |
|
862 | --- /dev/null\t(?P<date>.*) (re) | |
862 | \+\+\+ b/b/f\t(?P<date>.*) (re) |
|
863 | \+\+\+ b/b/f\t(?P<date>.*) (re) | |
863 | @@ -0,0 +1,1 @@ |
|
864 | @@ -0,0 +1,1 @@ | |
864 | +f |
|
865 | +f | |
865 | $ hg status |
|
866 | $ hg status | |
866 | M a |
|
867 | M a | |
867 |
|
868 | |||
868 |
|
869 | |||
869 | qpush failure |
|
870 | qpush failure | |
870 |
|
871 | |||
871 | $ cd .. |
|
872 | $ cd .. | |
872 | $ hg qrefresh |
|
873 | $ hg qrefresh | |
873 | $ hg qnew -mbar bar |
|
874 | $ hg qnew -mbar bar | |
874 | $ echo foo > foo |
|
875 | $ echo foo > foo | |
875 | $ echo bar > bar |
|
876 | $ echo bar > bar | |
876 | $ hg add foo bar |
|
877 | $ hg add foo bar | |
877 | $ hg qrefresh |
|
878 | $ hg qrefresh | |
878 | $ hg qpop -a |
|
879 | $ hg qpop -a | |
879 | popping bar |
|
880 | popping bar | |
880 | popping foo |
|
881 | popping foo | |
881 | patch queue now empty |
|
882 | patch queue now empty | |
882 | $ echo bar > foo |
|
883 | $ echo bar > foo | |
883 | $ hg qpush -a |
|
884 | $ hg qpush -a | |
884 | applying foo |
|
885 | applying foo | |
885 | applying bar |
|
886 | applying bar | |
886 | file foo already exists |
|
887 | file foo already exists | |
887 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej |
|
888 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej | |
888 | patch failed, unable to continue (try -v) |
|
889 | patch failed, unable to continue (try -v) | |
889 | patch failed, rejects left in working directory |
|
890 | patch failed, rejects left in working directory | |
890 | errors during apply, please fix and qrefresh bar |
|
891 | errors during apply, please fix and qrefresh bar | |
891 | [2] |
|
892 | [2] | |
892 | $ hg st |
|
893 | $ hg st | |
893 | ? foo |
|
894 | ? foo | |
894 | ? foo.rej |
|
895 | ? foo.rej | |
895 |
|
896 | |||
896 |
|
897 | |||
897 | mq tags |
|
898 | mq tags | |
898 |
|
899 | |||
899 | $ hg log --template '{rev} {tags}\n' -r qparent:qtip |
|
900 | $ hg log --template '{rev} {tags}\n' -r qparent:qtip | |
900 | 0 qparent |
|
901 | 0 qparent | |
901 | 1 foo qbase |
|
902 | 1 foo qbase | |
902 | 2 bar qtip tip |
|
903 | 2 bar qtip tip | |
903 |
|
904 | |||
904 | mq revset |
|
905 | mq revset | |
905 |
|
906 | |||
906 | $ hg log -r 'mq()' --template '{rev}\n' |
|
907 | $ hg log -r 'mq()' --template '{rev}\n' | |
907 | 1 |
|
908 | 1 | |
908 | 2 |
|
909 | 2 | |
909 | $ hg help revisions.mq |
|
910 | $ hg help revisions.mq | |
910 | "mq()" |
|
911 | "mq()" | |
911 | Changesets managed by MQ. |
|
912 | Changesets managed by MQ. | |
912 |
|
913 | |||
913 |
|
914 | |||
914 | bad node in status |
|
915 | bad node in status | |
915 |
|
916 | |||
916 | $ hg qpop |
|
917 | $ hg qpop | |
917 | popping bar |
|
918 | popping bar | |
918 | now at: foo |
|
919 | now at: foo | |
919 | $ hg strip -qn tip |
|
920 | $ hg strip -qn tip | |
920 | $ hg tip |
|
921 | $ hg tip | |
921 | changeset: 0:cb9a9f314b8b |
|
922 | changeset: 0:cb9a9f314b8b | |
922 | tag: tip |
|
923 | tag: tip | |
923 | user: test |
|
924 | user: test | |
924 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
925 | date: Thu Jan 01 00:00:00 1970 +0000 | |
925 | summary: a |
|
926 | summary: a | |
926 |
|
927 | |||
927 | $ hg branches |
|
928 | $ hg branches | |
928 | default 0:cb9a9f314b8b |
|
929 | default 0:cb9a9f314b8b | |
929 | $ hg qpop |
|
930 | $ hg qpop | |
930 | no patches applied |
|
931 | no patches applied | |
931 | [1] |
|
932 | [1] | |
932 |
|
933 | |||
933 | $ cd .. |
|
934 | $ cd .. | |
934 |
|
935 | |||
935 |
|
936 | |||
936 | git patches |
|
937 | git patches | |
937 |
|
938 | |||
938 | $ cat >>$HGRCPATH <<EOF |
|
939 | $ cat >>$HGRCPATH <<EOF | |
939 | > [diff] |
|
940 | > [diff] | |
940 | > git = True |
|
941 | > git = True | |
941 | > EOF |
|
942 | > EOF | |
942 | $ hg init git |
|
943 | $ hg init git | |
943 | $ cd git |
|
944 | $ cd git | |
944 | $ hg qinit |
|
945 | $ hg qinit | |
945 |
|
946 | |||
946 | $ hg qnew -m'new file' new |
|
947 | $ hg qnew -m'new file' new | |
947 | $ echo foo > new |
|
948 | $ echo foo > new | |
948 | #if execbit |
|
949 | #if execbit | |
949 | $ chmod +x new |
|
950 | $ chmod +x new | |
950 | #endif |
|
951 | #endif | |
951 | $ hg add new |
|
952 | $ hg add new | |
952 | $ hg qrefresh |
|
953 | $ hg qrefresh | |
953 |
|
954 | |||
954 | $ cat .hg/patches/new |
|
955 | $ cat .hg/patches/new | |
955 | new file |
|
956 | new file | |
956 |
|
957 | |||
957 | diff --git a/new b/new |
|
958 | diff --git a/new b/new | |
958 | new file mode 100755 (execbit !) |
|
959 | new file mode 100755 (execbit !) | |
959 | new file mode 100644 (no-execbit !) |
|
960 | new file mode 100644 (no-execbit !) | |
960 | --- /dev/null |
|
961 | --- /dev/null | |
961 | +++ b/new |
|
962 | +++ b/new | |
962 | @@ -0,0 +1,1 @@ |
|
963 | @@ -0,0 +1,1 @@ | |
963 | +foo |
|
964 | +foo | |
964 |
|
965 | |||
965 | $ hg qnew -m'copy file' copy |
|
966 | $ hg qnew -m'copy file' copy | |
966 | $ hg cp new copy |
|
967 | $ hg cp new copy | |
967 | $ hg qrefresh |
|
968 | $ hg qrefresh | |
968 | $ cat .hg/patches/copy |
|
969 | $ cat .hg/patches/copy | |
969 | copy file |
|
970 | copy file | |
970 |
|
971 | |||
971 | diff --git a/new b/copy |
|
972 | diff --git a/new b/copy | |
972 | copy from new |
|
973 | copy from new | |
973 | copy to copy |
|
974 | copy to copy | |
974 |
|
975 | |||
975 | $ hg qpop |
|
976 | $ hg qpop | |
976 | popping copy |
|
977 | popping copy | |
977 | now at: new |
|
978 | now at: new | |
978 | $ hg qpush |
|
979 | $ hg qpush | |
979 | applying copy |
|
980 | applying copy | |
980 | now at: copy |
|
981 | now at: copy | |
981 | $ hg qdiff |
|
982 | $ hg qdiff | |
982 | diff --git a/new b/copy |
|
983 | diff --git a/new b/copy | |
983 | copy from new |
|
984 | copy from new | |
984 | copy to copy |
|
985 | copy to copy | |
985 | $ cat >>$HGRCPATH <<EOF |
|
986 | $ cat >>$HGRCPATH <<EOF | |
986 | > [diff] |
|
987 | > [diff] | |
987 | > git = False |
|
988 | > git = False | |
988 | > EOF |
|
989 | > EOF | |
989 | $ hg qdiff --git |
|
990 | $ hg qdiff --git | |
990 | diff --git a/new b/copy |
|
991 | diff --git a/new b/copy | |
991 | copy from new |
|
992 | copy from new | |
992 | copy to copy |
|
993 | copy to copy | |
993 | $ cd .. |
|
994 | $ cd .. | |
994 |
|
995 | |||
995 | empty lines in status |
|
996 | empty lines in status | |
996 |
|
997 | |||
997 | $ hg init emptystatus |
|
998 | $ hg init emptystatus | |
998 | $ cd emptystatus |
|
999 | $ cd emptystatus | |
999 | $ hg qinit |
|
1000 | $ hg qinit | |
1000 | $ printf '\n\n' > .hg/patches/status |
|
1001 | $ printf '\n\n' > .hg/patches/status | |
1001 | $ hg qser |
|
1002 | $ hg qser | |
1002 | $ cd .. |
|
1003 | $ cd .. | |
1003 |
|
1004 | |||
1004 | bad line in status (without ":") |
|
1005 | bad line in status (without ":") | |
1005 |
|
1006 | |||
1006 | $ hg init badstatus |
|
1007 | $ hg init badstatus | |
1007 | $ cd badstatus |
|
1008 | $ cd badstatus | |
1008 | $ hg qinit |
|
1009 | $ hg qinit | |
1009 | $ printf 'babar has no colon in this line\n' > .hg/patches/status |
|
1010 | $ printf 'babar has no colon in this line\n' > .hg/patches/status | |
1010 | $ hg qser |
|
1011 | $ hg qser | |
1011 | malformated mq status line: ['babar has no colon in this line'] |
|
1012 | malformated mq status line: ['babar has no colon in this line'] | |
1012 | $ cd .. |
|
1013 | $ cd .. | |
1013 |
|
1014 | |||
1014 |
|
1015 | |||
1015 | test file addition in slow path |
|
1016 | test file addition in slow path | |
1016 |
|
1017 | |||
1017 | $ hg init slow |
|
1018 | $ hg init slow | |
1018 | $ cd slow |
|
1019 | $ cd slow | |
1019 | $ hg qinit |
|
1020 | $ hg qinit | |
1020 | $ echo foo > foo |
|
1021 | $ echo foo > foo | |
1021 | $ hg add foo |
|
1022 | $ hg add foo | |
1022 | $ hg ci -m 'add foo' |
|
1023 | $ hg ci -m 'add foo' | |
1023 | $ hg qnew bar |
|
1024 | $ hg qnew bar | |
1024 | $ echo bar > bar |
|
1025 | $ echo bar > bar | |
1025 | $ hg add bar |
|
1026 | $ hg add bar | |
1026 | $ hg mv foo baz |
|
1027 | $ hg mv foo baz | |
1027 | $ hg qrefresh --git |
|
1028 | $ hg qrefresh --git | |
1028 | $ hg up -C 0 |
|
1029 | $ hg up -C 0 | |
1029 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
1030 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
1030 | $ echo >> foo |
|
1031 | $ echo >> foo | |
1031 | $ hg ci -m 'change foo' |
|
1032 | $ hg ci -m 'change foo' | |
1032 | created new head |
|
1033 | created new head | |
1033 | $ hg up -C 1 |
|
1034 | $ hg up -C 1 | |
1034 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1035 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
1035 | $ hg qrefresh --git |
|
1036 | $ hg qrefresh --git | |
1036 | $ cat .hg/patches/bar |
|
1037 | $ cat .hg/patches/bar | |
1037 | diff --git a/bar b/bar |
|
1038 | diff --git a/bar b/bar | |
1038 | new file mode 100644 |
|
1039 | new file mode 100644 | |
1039 | --- /dev/null |
|
1040 | --- /dev/null | |
1040 | +++ b/bar |
|
1041 | +++ b/bar | |
1041 | @@ -0,0 +1,1 @@ |
|
1042 | @@ -0,0 +1,1 @@ | |
1042 | +bar |
|
1043 | +bar | |
1043 | diff --git a/foo b/baz |
|
1044 | diff --git a/foo b/baz | |
1044 | rename from foo |
|
1045 | rename from foo | |
1045 | rename to baz |
|
1046 | rename to baz | |
1046 | $ hg log -v --template '{rev} {file_copies}\n' -r . |
|
1047 | $ hg log -v --template '{rev} {file_copies}\n' -r . | |
1047 | 2 baz (foo) |
|
1048 | 2 baz (foo) | |
1048 | $ hg qrefresh --git |
|
1049 | $ hg qrefresh --git | |
1049 | $ cat .hg/patches/bar |
|
1050 | $ cat .hg/patches/bar | |
1050 | diff --git a/bar b/bar |
|
1051 | diff --git a/bar b/bar | |
1051 | new file mode 100644 |
|
1052 | new file mode 100644 | |
1052 | --- /dev/null |
|
1053 | --- /dev/null | |
1053 | +++ b/bar |
|
1054 | +++ b/bar | |
1054 | @@ -0,0 +1,1 @@ |
|
1055 | @@ -0,0 +1,1 @@ | |
1055 | +bar |
|
1056 | +bar | |
1056 | diff --git a/foo b/baz |
|
1057 | diff --git a/foo b/baz | |
1057 | rename from foo |
|
1058 | rename from foo | |
1058 | rename to baz |
|
1059 | rename to baz | |
1059 | $ hg log -v --template '{rev} {file_copies}\n' -r . |
|
1060 | $ hg log -v --template '{rev} {file_copies}\n' -r . | |
1060 | 2 baz (foo) |
|
1061 | 2 baz (foo) | |
1061 | $ hg qrefresh |
|
1062 | $ hg qrefresh | |
1062 | $ grep 'diff --git' .hg/patches/bar |
|
1063 | $ grep 'diff --git' .hg/patches/bar | |
1063 | diff --git a/bar b/bar |
|
1064 | diff --git a/bar b/bar | |
1064 | diff --git a/foo b/baz |
|
1065 | diff --git a/foo b/baz | |
1065 |
|
1066 | |||
1066 |
|
1067 | |||
1067 | test file move chains in the slow path |
|
1068 | test file move chains in the slow path | |
1068 |
|
1069 | |||
1069 | $ hg up -C 1 |
|
1070 | $ hg up -C 1 | |
1070 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
1071 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
1071 | $ echo >> foo |
|
1072 | $ echo >> foo | |
1072 | $ hg ci -m 'change foo again' |
|
1073 | $ hg ci -m 'change foo again' | |
1073 | $ hg up -C 2 |
|
1074 | $ hg up -C 2 | |
1074 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1075 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
1075 | $ hg mv bar quux |
|
1076 | $ hg mv bar quux | |
1076 | $ hg mv baz bleh |
|
1077 | $ hg mv baz bleh | |
1077 | $ hg qrefresh --git |
|
1078 | $ hg qrefresh --git | |
1078 | $ cat .hg/patches/bar |
|
1079 | $ cat .hg/patches/bar | |
1079 | diff --git a/foo b/bleh |
|
1080 | diff --git a/foo b/bleh | |
1080 | rename from foo |
|
1081 | rename from foo | |
1081 | rename to bleh |
|
1082 | rename to bleh | |
1082 | diff --git a/quux b/quux |
|
1083 | diff --git a/quux b/quux | |
1083 | new file mode 100644 |
|
1084 | new file mode 100644 | |
1084 | --- /dev/null |
|
1085 | --- /dev/null | |
1085 | +++ b/quux |
|
1086 | +++ b/quux | |
1086 | @@ -0,0 +1,1 @@ |
|
1087 | @@ -0,0 +1,1 @@ | |
1087 | +bar |
|
1088 | +bar | |
1088 | $ hg log -v --template '{rev} {file_copies}\n' -r . |
|
1089 | $ hg log -v --template '{rev} {file_copies}\n' -r . | |
1089 | 3 bleh (foo) |
|
1090 | 3 bleh (foo) | |
1090 | $ hg mv quux fred |
|
1091 | $ hg mv quux fred | |
1091 | $ hg mv bleh barney |
|
1092 | $ hg mv bleh barney | |
1092 | $ hg qrefresh --git |
|
1093 | $ hg qrefresh --git | |
1093 | $ cat .hg/patches/bar |
|
1094 | $ cat .hg/patches/bar | |
1094 | diff --git a/foo b/barney |
|
1095 | diff --git a/foo b/barney | |
1095 | rename from foo |
|
1096 | rename from foo | |
1096 | rename to barney |
|
1097 | rename to barney | |
1097 | diff --git a/fred b/fred |
|
1098 | diff --git a/fred b/fred | |
1098 | new file mode 100644 |
|
1099 | new file mode 100644 | |
1099 | --- /dev/null |
|
1100 | --- /dev/null | |
1100 | +++ b/fred |
|
1101 | +++ b/fred | |
1101 | @@ -0,0 +1,1 @@ |
|
1102 | @@ -0,0 +1,1 @@ | |
1102 | +bar |
|
1103 | +bar | |
1103 | $ hg log -v --template '{rev} {file_copies}\n' -r . |
|
1104 | $ hg log -v --template '{rev} {file_copies}\n' -r . | |
1104 | 3 barney (foo) |
|
1105 | 3 barney (foo) | |
1105 |
|
1106 | |||
1106 |
|
1107 | |||
1107 | refresh omitting an added file |
|
1108 | refresh omitting an added file | |
1108 |
|
1109 | |||
1109 | $ hg qnew baz |
|
1110 | $ hg qnew baz | |
1110 | $ echo newfile > newfile |
|
1111 | $ echo newfile > newfile | |
1111 | $ hg add newfile |
|
1112 | $ hg add newfile | |
1112 | $ hg qrefresh |
|
1113 | $ hg qrefresh | |
1113 | $ hg st -A newfile |
|
1114 | $ hg st -A newfile | |
1114 | C newfile |
|
1115 | C newfile | |
1115 | $ hg qrefresh -X newfile |
|
1116 | $ hg qrefresh -X newfile | |
1116 | $ hg st -A newfile |
|
1117 | $ hg st -A newfile | |
1117 | A newfile |
|
1118 | A newfile | |
1118 | $ hg revert newfile |
|
1119 | $ hg revert newfile | |
1119 | $ rm newfile |
|
1120 | $ rm newfile | |
1120 | $ hg qpop |
|
1121 | $ hg qpop | |
1121 | popping baz |
|
1122 | popping baz | |
1122 | now at: bar |
|
1123 | now at: bar | |
1123 |
|
1124 | |||
1124 | test qdel/qrm |
|
1125 | test qdel/qrm | |
1125 |
|
1126 | |||
1126 | $ hg qdel baz |
|
1127 | $ hg qdel baz | |
1127 | $ echo p >> .hg/patches/series |
|
1128 | $ echo p >> .hg/patches/series | |
1128 | $ hg qrm p |
|
1129 | $ hg qrm p | |
1129 | $ hg qser |
|
1130 | $ hg qser | |
1130 | bar |
|
1131 | bar | |
1131 |
|
1132 | |||
1132 | create a git patch |
|
1133 | create a git patch | |
1133 |
|
1134 | |||
1134 | $ echo a > alexander |
|
1135 | $ echo a > alexander | |
1135 | $ hg add alexander |
|
1136 | $ hg add alexander | |
1136 | $ hg qnew -f --git addalexander |
|
1137 | $ hg qnew -f --git addalexander | |
1137 | $ grep diff .hg/patches/addalexander |
|
1138 | $ grep diff .hg/patches/addalexander | |
1138 | diff --git a/alexander b/alexander |
|
1139 | diff --git a/alexander b/alexander | |
1139 |
|
1140 | |||
1140 |
|
1141 | |||
1141 | create a git binary patch |
|
1142 | create a git binary patch | |
1142 |
|
1143 | |||
1143 | $ cat > writebin.py <<EOF |
|
1144 | $ cat > writebin.py <<EOF | |
1144 | > import sys |
|
1145 | > import sys | |
1145 | > path = sys.argv[1] |
|
1146 | > path = sys.argv[1] | |
1146 | > open(path, 'wb').write(b'BIN\x00ARY') |
|
1147 | > open(path, 'wb').write(b'BIN\x00ARY') | |
1147 | > EOF |
|
1148 | > EOF | |
1148 | $ "$PYTHON" writebin.py bucephalus |
|
1149 | $ "$PYTHON" writebin.py bucephalus | |
1149 |
|
1150 | |||
1150 | $ "$PYTHON" "$TESTDIR/md5sum.py" bucephalus |
|
1151 | $ "$PYTHON" "$TESTDIR/md5sum.py" bucephalus | |
1151 | 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus |
|
1152 | 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus | |
1152 | $ hg add bucephalus |
|
1153 | $ hg add bucephalus | |
1153 | $ hg qnew -f --git addbucephalus |
|
1154 | $ hg qnew -f --git addbucephalus | |
1154 | $ grep diff .hg/patches/addbucephalus |
|
1155 | $ grep diff .hg/patches/addbucephalus | |
1155 | diff --git a/bucephalus b/bucephalus |
|
1156 | diff --git a/bucephalus b/bucephalus | |
1156 |
|
1157 | |||
1157 |
|
1158 | |||
1158 | check binary patches can be popped and pushed |
|
1159 | check binary patches can be popped and pushed | |
1159 |
|
1160 | |||
1160 | $ hg qpop |
|
1161 | $ hg qpop | |
1161 | popping addbucephalus |
|
1162 | popping addbucephalus | |
1162 | now at: addalexander |
|
1163 | now at: addalexander | |
1163 | $ test -f bucephalus && echo % bucephalus should not be there |
|
1164 | $ test -f bucephalus && echo % bucephalus should not be there | |
1164 | [1] |
|
1165 | [1] | |
1165 | $ hg qpush |
|
1166 | $ hg qpush | |
1166 | applying addbucephalus |
|
1167 | applying addbucephalus | |
1167 | now at: addbucephalus |
|
1168 | now at: addbucephalus | |
1168 | $ test -f bucephalus |
|
1169 | $ test -f bucephalus | |
1169 | $ "$PYTHON" "$TESTDIR/md5sum.py" bucephalus |
|
1170 | $ "$PYTHON" "$TESTDIR/md5sum.py" bucephalus | |
1170 | 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus |
|
1171 | 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus | |
1171 |
|
1172 | |||
1172 |
|
1173 | |||
1173 |
|
1174 | |||
1174 | strip again |
|
1175 | strip again | |
1175 |
|
1176 | |||
1176 | $ cd .. |
|
1177 | $ cd .. | |
1177 | $ hg init strip |
|
1178 | $ hg init strip | |
1178 | $ cd strip |
|
1179 | $ cd strip | |
1179 | $ touch foo |
|
1180 | $ touch foo | |
1180 | $ hg add foo |
|
1181 | $ hg add foo | |
1181 | $ hg ci -m 'add foo' |
|
1182 | $ hg ci -m 'add foo' | |
1182 | $ echo >> foo |
|
1183 | $ echo >> foo | |
1183 | $ hg ci -m 'change foo 1' |
|
1184 | $ hg ci -m 'change foo 1' | |
1184 | $ hg up -C 0 |
|
1185 | $ hg up -C 0 | |
1185 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1186 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1186 | $ echo 1 >> foo |
|
1187 | $ echo 1 >> foo | |
1187 | $ hg ci -m 'change foo 2' |
|
1188 | $ hg ci -m 'change foo 2' | |
1188 | created new head |
|
1189 | created new head | |
1189 | $ HGMERGE=true hg merge |
|
1190 | $ HGMERGE=true hg merge | |
1190 | merging foo |
|
1191 | merging foo | |
1191 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
1192 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
1192 | (branch merge, don't forget to commit) |
|
1193 | (branch merge, don't forget to commit) | |
1193 | $ hg ci -m merge |
|
1194 | $ hg ci -m merge | |
1194 | $ hg log |
|
1195 | $ hg log | |
1195 | changeset: 3:99615015637b |
|
1196 | changeset: 3:99615015637b | |
1196 | tag: tip |
|
1197 | tag: tip | |
1197 | parent: 2:20cbbe65cff7 |
|
1198 | parent: 2:20cbbe65cff7 | |
1198 | parent: 1:d2871fc282d4 |
|
1199 | parent: 1:d2871fc282d4 | |
1199 | user: test |
|
1200 | user: test | |
1200 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1201 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1201 | summary: merge |
|
1202 | summary: merge | |
1202 |
|
1203 | |||
1203 | changeset: 2:20cbbe65cff7 |
|
1204 | changeset: 2:20cbbe65cff7 | |
1204 | parent: 0:53245c60e682 |
|
1205 | parent: 0:53245c60e682 | |
1205 | user: test |
|
1206 | user: test | |
1206 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1207 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1207 | summary: change foo 2 |
|
1208 | summary: change foo 2 | |
1208 |
|
1209 | |||
1209 | changeset: 1:d2871fc282d4 |
|
1210 | changeset: 1:d2871fc282d4 | |
1210 | user: test |
|
1211 | user: test | |
1211 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1212 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1212 | summary: change foo 1 |
|
1213 | summary: change foo 1 | |
1213 |
|
1214 | |||
1214 | changeset: 0:53245c60e682 |
|
1215 | changeset: 0:53245c60e682 | |
1215 | user: test |
|
1216 | user: test | |
1216 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1217 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1217 | summary: add foo |
|
1218 | summary: add foo | |
1218 |
|
1219 | |||
1219 | $ hg strip 1 |
|
1220 | $ hg strip 1 | |
1220 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1221 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1221 | saved backup bundle to $TESTTMP/strip/.hg/strip-backup/*-backup.hg (glob) |
|
1222 | saved backup bundle to $TESTTMP/strip/.hg/strip-backup/*-backup.hg (glob) | |
1222 | $ checkundo strip |
|
1223 | $ checkundo strip | |
1223 | $ hg log |
|
1224 | $ hg log | |
1224 | changeset: 1:20cbbe65cff7 |
|
1225 | changeset: 1:20cbbe65cff7 | |
1225 | tag: tip |
|
1226 | tag: tip | |
1226 | user: test |
|
1227 | user: test | |
1227 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1228 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1228 | summary: change foo 2 |
|
1229 | summary: change foo 2 | |
1229 |
|
1230 | |||
1230 | changeset: 0:53245c60e682 |
|
1231 | changeset: 0:53245c60e682 | |
1231 | user: test |
|
1232 | user: test | |
1232 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1233 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1233 | summary: add foo |
|
1234 | summary: add foo | |
1234 |
|
1235 | |||
1235 | $ cd .. |
|
1236 | $ cd .. | |
1236 |
|
1237 | |||
1237 |
|
1238 | |||
1238 | qclone |
|
1239 | qclone | |
1239 |
|
1240 | |||
1240 | $ qlog() |
|
1241 | $ qlog() | |
1241 | > { |
|
1242 | > { | |
1242 | > echo 'main repo:' |
|
1243 | > echo 'main repo:' | |
1243 | > hg log --template ' rev {rev}: {desc}\n' |
|
1244 | > hg log --template ' rev {rev}: {desc}\n' | |
1244 | > echo 'patch repo:' |
|
1245 | > echo 'patch repo:' | |
1245 | > hg -R .hg/patches log --template ' rev {rev}: {desc}\n' |
|
1246 | > hg -R .hg/patches log --template ' rev {rev}: {desc}\n' | |
1246 | > } |
|
1247 | > } | |
1247 | $ hg init qclonesource |
|
1248 | $ hg init qclonesource | |
1248 | $ cd qclonesource |
|
1249 | $ cd qclonesource | |
1249 | $ echo foo > foo |
|
1250 | $ echo foo > foo | |
1250 | $ hg add foo |
|
1251 | $ hg add foo | |
1251 | $ hg ci -m 'add foo' |
|
1252 | $ hg ci -m 'add foo' | |
1252 | $ hg qinit |
|
1253 | $ hg qinit | |
1253 | $ hg qnew patch1 |
|
1254 | $ hg qnew patch1 | |
1254 | $ echo bar >> foo |
|
1255 | $ echo bar >> foo | |
1255 | $ hg qrefresh -m 'change foo' |
|
1256 | $ hg qrefresh -m 'change foo' | |
1256 | $ cd .. |
|
1257 | $ cd .. | |
1257 |
|
1258 | |||
1258 |
|
1259 | |||
1259 | repo with unversioned patch dir |
|
1260 | repo with unversioned patch dir | |
1260 |
|
1261 | |||
1261 | $ hg qclone qclonesource failure |
|
1262 | $ hg qclone qclonesource failure | |
1262 | abort: versioned patch repository not found (see init --mq) |
|
1263 | abort: versioned patch repository not found (see init --mq) | |
1263 | [255] |
|
1264 | [255] | |
1264 |
|
1265 | |||
1265 | $ cd qclonesource |
|
1266 | $ cd qclonesource | |
1266 | $ hg qinit -c |
|
1267 | $ hg qinit -c | |
1267 | adding .hg/patches/patch1 |
|
1268 | adding .hg/patches/patch1 | |
1268 | $ hg qci -m checkpoint |
|
1269 | $ hg qci -m checkpoint | |
1269 | $ qlog |
|
1270 | $ qlog | |
1270 | main repo: |
|
1271 | main repo: | |
1271 | rev 1: change foo |
|
1272 | rev 1: change foo | |
1272 | rev 0: add foo |
|
1273 | rev 0: add foo | |
1273 | patch repo: |
|
1274 | patch repo: | |
1274 | rev 0: checkpoint |
|
1275 | rev 0: checkpoint | |
1275 | $ cd .. |
|
1276 | $ cd .. | |
1276 |
|
1277 | |||
1277 |
|
1278 | |||
1278 | repo with patches applied |
|
1279 | repo with patches applied | |
1279 |
|
1280 | |||
1280 | $ hg qclone qclonesource qclonedest |
|
1281 | $ hg qclone qclonesource qclonedest | |
1281 | updating to branch default |
|
1282 | updating to branch default | |
1282 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1283 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1283 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1284 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1284 | $ cd qclonedest |
|
1285 | $ cd qclonedest | |
1285 | $ qlog |
|
1286 | $ qlog | |
1286 | main repo: |
|
1287 | main repo: | |
1287 | rev 0: add foo |
|
1288 | rev 0: add foo | |
1288 | patch repo: |
|
1289 | patch repo: | |
1289 | rev 0: checkpoint |
|
1290 | rev 0: checkpoint | |
1290 | $ cd .. |
|
1291 | $ cd .. | |
1291 |
|
1292 | |||
1292 |
|
1293 | |||
1293 | repo with patches unapplied |
|
1294 | repo with patches unapplied | |
1294 |
|
1295 | |||
1295 | $ cd qclonesource |
|
1296 | $ cd qclonesource | |
1296 | $ hg qpop -a |
|
1297 | $ hg qpop -a | |
1297 | popping patch1 |
|
1298 | popping patch1 | |
1298 | patch queue now empty |
|
1299 | patch queue now empty | |
1299 | $ qlog |
|
1300 | $ qlog | |
1300 | main repo: |
|
1301 | main repo: | |
1301 | rev 0: add foo |
|
1302 | rev 0: add foo | |
1302 | patch repo: |
|
1303 | patch repo: | |
1303 | rev 0: checkpoint |
|
1304 | rev 0: checkpoint | |
1304 | $ cd .. |
|
1305 | $ cd .. | |
1305 | $ hg qclone qclonesource qclonedest2 |
|
1306 | $ hg qclone qclonesource qclonedest2 | |
1306 | updating to branch default |
|
1307 | updating to branch default | |
1307 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1308 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1308 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1309 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1309 | $ cd qclonedest2 |
|
1310 | $ cd qclonedest2 | |
1310 | $ qlog |
|
1311 | $ qlog | |
1311 | main repo: |
|
1312 | main repo: | |
1312 | rev 0: add foo |
|
1313 | rev 0: add foo | |
1313 | patch repo: |
|
1314 | patch repo: | |
1314 | rev 0: checkpoint |
|
1315 | rev 0: checkpoint | |
1315 | $ cd .. |
|
1316 | $ cd .. | |
1316 |
|
1317 | |||
1317 |
|
1318 | |||
1318 | Issue1033: test applying on an empty file |
|
1319 | Issue1033: test applying on an empty file | |
1319 |
|
1320 | |||
1320 | $ hg init empty |
|
1321 | $ hg init empty | |
1321 | $ cd empty |
|
1322 | $ cd empty | |
1322 | $ touch a |
|
1323 | $ touch a | |
1323 | $ hg ci -Am addempty |
|
1324 | $ hg ci -Am addempty | |
1324 | adding a |
|
1325 | adding a | |
1325 | $ echo a > a |
|
1326 | $ echo a > a | |
1326 | $ hg qnew -f -e changea |
|
1327 | $ hg qnew -f -e changea | |
1327 | $ hg qpop |
|
1328 | $ hg qpop | |
1328 | popping changea |
|
1329 | popping changea | |
1329 | patch queue now empty |
|
1330 | patch queue now empty | |
1330 | $ hg qpush |
|
1331 | $ hg qpush | |
1331 | applying changea |
|
1332 | applying changea | |
1332 | now at: changea |
|
1333 | now at: changea | |
1333 | $ cd .. |
|
1334 | $ cd .. | |
1334 |
|
1335 | |||
1335 | test qpush with --force, issue1087 |
|
1336 | test qpush with --force, issue1087 | |
1336 |
|
1337 | |||
1337 | $ hg init forcepush |
|
1338 | $ hg init forcepush | |
1338 | $ cd forcepush |
|
1339 | $ cd forcepush | |
1339 | $ echo hello > hello.txt |
|
1340 | $ echo hello > hello.txt | |
1340 | $ echo bye > bye.txt |
|
1341 | $ echo bye > bye.txt | |
1341 | $ hg ci -Ama |
|
1342 | $ hg ci -Ama | |
1342 | adding bye.txt |
|
1343 | adding bye.txt | |
1343 | adding hello.txt |
|
1344 | adding hello.txt | |
1344 | $ hg qnew -d '0 0' empty |
|
1345 | $ hg qnew -d '0 0' empty | |
1345 | $ hg qpop |
|
1346 | $ hg qpop | |
1346 | popping empty |
|
1347 | popping empty | |
1347 | patch queue now empty |
|
1348 | patch queue now empty | |
1348 | $ echo world >> hello.txt |
|
1349 | $ echo world >> hello.txt | |
1349 |
|
1350 | |||
1350 |
|
1351 | |||
1351 | qpush should fail, local changes |
|
1352 | qpush should fail, local changes | |
1352 |
|
1353 | |||
1353 | $ hg qpush |
|
1354 | $ hg qpush | |
1354 | abort: local changes found |
|
1355 | abort: local changes found | |
1355 | [255] |
|
1356 | [255] | |
1356 |
|
1357 | |||
1357 |
|
1358 | |||
1358 | apply force, should not discard changes with empty patch |
|
1359 | apply force, should not discard changes with empty patch | |
1359 |
|
1360 | |||
1360 | $ hg qpush -f |
|
1361 | $ hg qpush -f | |
1361 | applying empty |
|
1362 | applying empty | |
1362 | patch empty is empty |
|
1363 | patch empty is empty | |
1363 | now at: empty |
|
1364 | now at: empty | |
1364 | $ hg diff --config diff.nodates=True |
|
1365 | $ hg diff --config diff.nodates=True | |
1365 | diff -r d58265112590 hello.txt |
|
1366 | diff -r d58265112590 hello.txt | |
1366 | --- a/hello.txt |
|
1367 | --- a/hello.txt | |
1367 | +++ b/hello.txt |
|
1368 | +++ b/hello.txt | |
1368 | @@ -1,1 +1,2 @@ |
|
1369 | @@ -1,1 +1,2 @@ | |
1369 | hello |
|
1370 | hello | |
1370 | +world |
|
1371 | +world | |
1371 | $ hg qdiff --config diff.nodates=True |
|
1372 | $ hg qdiff --config diff.nodates=True | |
1372 | diff -r 9ecee4f634e3 hello.txt |
|
1373 | diff -r 9ecee4f634e3 hello.txt | |
1373 | --- a/hello.txt |
|
1374 | --- a/hello.txt | |
1374 | +++ b/hello.txt |
|
1375 | +++ b/hello.txt | |
1375 | @@ -1,1 +1,2 @@ |
|
1376 | @@ -1,1 +1,2 @@ | |
1376 | hello |
|
1377 | hello | |
1377 | +world |
|
1378 | +world | |
1378 | $ hg log -l1 -p |
|
1379 | $ hg log -l1 -p | |
1379 | changeset: 1:d58265112590 |
|
1380 | changeset: 1:d58265112590 | |
1380 | tag: empty |
|
1381 | tag: empty | |
1381 | tag: qbase |
|
1382 | tag: qbase | |
1382 | tag: qtip |
|
1383 | tag: qtip | |
1383 | tag: tip |
|
1384 | tag: tip | |
1384 | user: test |
|
1385 | user: test | |
1385 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1386 | date: Thu Jan 01 00:00:00 1970 +0000 | |
1386 | summary: imported patch empty |
|
1387 | summary: imported patch empty | |
1387 |
|
1388 | |||
1388 |
|
1389 | |||
1389 | $ hg qref -d '0 0' |
|
1390 | $ hg qref -d '0 0' | |
1390 | $ hg qpop |
|
1391 | $ hg qpop | |
1391 | popping empty |
|
1392 | popping empty | |
1392 | patch queue now empty |
|
1393 | patch queue now empty | |
1393 | $ echo universe >> hello.txt |
|
1394 | $ echo universe >> hello.txt | |
1394 | $ echo universe >> bye.txt |
|
1395 | $ echo universe >> bye.txt | |
1395 |
|
1396 | |||
1396 |
|
1397 | |||
1397 | qpush should fail, local changes |
|
1398 | qpush should fail, local changes | |
1398 |
|
1399 | |||
1399 | $ hg qpush |
|
1400 | $ hg qpush | |
1400 | abort: local changes found |
|
1401 | abort: local changes found | |
1401 | [255] |
|
1402 | [255] | |
1402 |
|
1403 | |||
1403 |
|
1404 | |||
1404 | apply force, should discard changes in hello, but not bye |
|
1405 | apply force, should discard changes in hello, but not bye | |
1405 |
|
1406 | |||
1406 | $ hg qpush -f --verbose --config 'ui.origbackuppath=.hg/origbackups' |
|
1407 | $ hg qpush -f --verbose --config 'ui.origbackuppath=.hg/origbackups' | |
1407 | applying empty |
|
1408 | applying empty | |
1408 | creating directory: $TESTTMP/forcepush/.hg/origbackups |
|
1409 | creating directory: $TESTTMP/forcepush/.hg/origbackups | |
1409 | saving current version of hello.txt as .hg/origbackups/hello.txt |
|
1410 | saving current version of hello.txt as .hg/origbackups/hello.txt | |
1410 | patching file hello.txt |
|
1411 | patching file hello.txt | |
1411 | committing files: |
|
1412 | committing files: | |
1412 | hello.txt |
|
1413 | hello.txt | |
1413 | committing manifest |
|
1414 | committing manifest | |
1414 | committing changelog |
|
1415 | committing changelog | |
1415 | now at: empty |
|
1416 | now at: empty | |
1416 | $ hg st |
|
1417 | $ hg st | |
1417 | M bye.txt |
|
1418 | M bye.txt | |
1418 | $ hg diff --config diff.nodates=True |
|
1419 | $ hg diff --config diff.nodates=True | |
1419 | diff -r ba252371dbc1 bye.txt |
|
1420 | diff -r ba252371dbc1 bye.txt | |
1420 | --- a/bye.txt |
|
1421 | --- a/bye.txt | |
1421 | +++ b/bye.txt |
|
1422 | +++ b/bye.txt | |
1422 | @@ -1,1 +1,2 @@ |
|
1423 | @@ -1,1 +1,2 @@ | |
1423 | bye |
|
1424 | bye | |
1424 | +universe |
|
1425 | +universe | |
1425 | $ hg qdiff --config diff.nodates=True |
|
1426 | $ hg qdiff --config diff.nodates=True | |
1426 | diff -r 9ecee4f634e3 bye.txt |
|
1427 | diff -r 9ecee4f634e3 bye.txt | |
1427 | --- a/bye.txt |
|
1428 | --- a/bye.txt | |
1428 | +++ b/bye.txt |
|
1429 | +++ b/bye.txt | |
1429 | @@ -1,1 +1,2 @@ |
|
1430 | @@ -1,1 +1,2 @@ | |
1430 | bye |
|
1431 | bye | |
1431 | +universe |
|
1432 | +universe | |
1432 | diff -r 9ecee4f634e3 hello.txt |
|
1433 | diff -r 9ecee4f634e3 hello.txt | |
1433 | --- a/hello.txt |
|
1434 | --- a/hello.txt | |
1434 | +++ b/hello.txt |
|
1435 | +++ b/hello.txt | |
1435 | @@ -1,1 +1,3 @@ |
|
1436 | @@ -1,1 +1,3 @@ | |
1436 | hello |
|
1437 | hello | |
1437 | +world |
|
1438 | +world | |
1438 | +universe |
|
1439 | +universe | |
1439 |
|
1440 | |||
1440 | test that the previous call to qpush with -f (--force) and --config actually put |
|
1441 | test that the previous call to qpush with -f (--force) and --config actually put | |
1441 | the orig files out of the working copy |
|
1442 | the orig files out of the working copy | |
1442 | $ ls .hg/origbackups |
|
1443 | $ ls .hg/origbackups | |
1443 | hello.txt |
|
1444 | hello.txt | |
1444 |
|
1445 | |||
1445 | test popping revisions not in working dir ancestry |
|
1446 | test popping revisions not in working dir ancestry | |
1446 |
|
1447 | |||
1447 | $ hg qseries -v |
|
1448 | $ hg qseries -v | |
1448 | 0 A empty |
|
1449 | 0 A empty | |
1449 | $ hg up qparent |
|
1450 | $ hg up qparent | |
1450 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1451 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
1451 | $ hg qpop |
|
1452 | $ hg qpop | |
1452 | popping empty |
|
1453 | popping empty | |
1453 | patch queue now empty |
|
1454 | patch queue now empty | |
1454 |
|
1455 | |||
1455 | $ cd .. |
|
1456 | $ cd .. | |
1456 | $ hg init deletion-order |
|
1457 | $ hg init deletion-order | |
1457 | $ cd deletion-order |
|
1458 | $ cd deletion-order | |
1458 |
|
1459 | |||
1459 | $ touch a |
|
1460 | $ touch a | |
1460 | $ hg ci -Aqm0 |
|
1461 | $ hg ci -Aqm0 | |
1461 |
|
1462 | |||
1462 | $ hg qnew rename-dir |
|
1463 | $ hg qnew rename-dir | |
1463 | $ hg rm a |
|
1464 | $ hg rm a | |
1464 | $ hg qrefresh |
|
1465 | $ hg qrefresh | |
1465 |
|
1466 | |||
1466 | $ mkdir a b |
|
1467 | $ mkdir a b | |
1467 | $ touch a/a b/b |
|
1468 | $ touch a/a b/b | |
1468 | $ hg add -q a b |
|
1469 | $ hg add -q a b | |
1469 | $ hg qrefresh |
|
1470 | $ hg qrefresh | |
1470 |
|
1471 | |||
1471 |
|
1472 | |||
1472 | test popping must remove files added in subdirectories first |
|
1473 | test popping must remove files added in subdirectories first | |
1473 |
|
1474 | |||
1474 | $ hg qpop |
|
1475 | $ hg qpop | |
1475 | popping rename-dir |
|
1476 | popping rename-dir | |
1476 | patch queue now empty |
|
1477 | patch queue now empty | |
1477 | $ cd .. |
|
1478 | $ cd .. | |
1478 |
|
1479 | |||
1479 |
|
1480 | |||
1480 | test case preservation through patch pushing especially on case |
|
1481 | test case preservation through patch pushing especially on case | |
1481 | insensitive filesystem |
|
1482 | insensitive filesystem | |
1482 |
|
1483 | |||
1483 | $ hg init casepreserve |
|
1484 | $ hg init casepreserve | |
1484 | $ cd casepreserve |
|
1485 | $ cd casepreserve | |
1485 |
|
1486 | |||
1486 | $ hg qnew add-file1 |
|
1487 | $ hg qnew add-file1 | |
1487 | $ echo a > TeXtFiLe.TxT |
|
1488 | $ echo a > TeXtFiLe.TxT | |
1488 | $ hg add TeXtFiLe.TxT |
|
1489 | $ hg add TeXtFiLe.TxT | |
1489 | $ hg qrefresh |
|
1490 | $ hg qrefresh | |
1490 |
|
1491 | |||
1491 | $ hg qnew add-file2 |
|
1492 | $ hg qnew add-file2 | |
1492 | $ echo b > AnOtHeRFiLe.TxT |
|
1493 | $ echo b > AnOtHeRFiLe.TxT | |
1493 | $ hg add AnOtHeRFiLe.TxT |
|
1494 | $ hg add AnOtHeRFiLe.TxT | |
1494 | $ hg qrefresh |
|
1495 | $ hg qrefresh | |
1495 |
|
1496 | |||
1496 | $ hg qnew modify-file |
|
1497 | $ hg qnew modify-file | |
1497 | $ echo c >> AnOtHeRFiLe.TxT |
|
1498 | $ echo c >> AnOtHeRFiLe.TxT | |
1498 | $ hg qrefresh |
|
1499 | $ hg qrefresh | |
1499 |
|
1500 | |||
1500 | $ hg qapplied |
|
1501 | $ hg qapplied | |
1501 | add-file1 |
|
1502 | add-file1 | |
1502 | add-file2 |
|
1503 | add-file2 | |
1503 | modify-file |
|
1504 | modify-file | |
1504 | $ hg qpop -a |
|
1505 | $ hg qpop -a | |
1505 | popping modify-file |
|
1506 | popping modify-file | |
1506 | popping add-file2 |
|
1507 | popping add-file2 | |
1507 | popping add-file1 |
|
1508 | popping add-file1 | |
1508 | patch queue now empty |
|
1509 | patch queue now empty | |
1509 |
|
1510 | |||
1510 | this qpush causes problems below, if case preservation on case |
|
1511 | this qpush causes problems below, if case preservation on case | |
1511 | insensitive filesystem is not enough: |
|
1512 | insensitive filesystem is not enough: | |
1512 | (1) unexpected "adding ..." messages are shown |
|
1513 | (1) unexpected "adding ..." messages are shown | |
1513 | (2) patching fails in modification of (1) files |
|
1514 | (2) patching fails in modification of (1) files | |
1514 |
|
1515 | |||
1515 | $ hg qpush -a |
|
1516 | $ hg qpush -a | |
1516 | applying add-file1 |
|
1517 | applying add-file1 | |
1517 | applying add-file2 |
|
1518 | applying add-file2 | |
1518 | applying modify-file |
|
1519 | applying modify-file | |
1519 | now at: modify-file |
|
1520 | now at: modify-file | |
1520 |
|
1521 | |||
1521 | Proper phase default with mq: |
|
1522 | Proper phase default with mq: | |
1522 |
|
1523 | |||
1523 | 1. mq.secret=false |
|
1524 | 1. mq.secret=false | |
1524 |
|
1525 | |||
1525 | $ rm .hg/store/phaseroots |
|
1526 | $ rm .hg/store/phaseroots | |
1526 | $ hg phase 'qparent::' |
|
1527 | $ hg phase 'qparent::' | |
1527 | -1: public |
|
1528 | -1: public | |
1528 | 0: draft |
|
1529 | 0: draft | |
1529 | 1: draft |
|
1530 | 1: draft | |
1530 | 2: draft |
|
1531 | 2: draft | |
1531 | $ echo '[mq]' >> $HGRCPATH |
|
1532 | $ echo '[mq]' >> $HGRCPATH | |
1532 | $ echo 'secret=true' >> $HGRCPATH |
|
1533 | $ echo 'secret=true' >> $HGRCPATH | |
1533 | $ rm -f .hg/store/phaseroots |
|
1534 | $ rm -f .hg/store/phaseroots | |
1534 | $ hg phase 'qparent::' |
|
1535 | $ hg phase 'qparent::' | |
1535 | -1: public |
|
1536 | -1: public | |
1536 | 0: secret |
|
1537 | 0: secret | |
1537 | 1: secret |
|
1538 | 1: secret | |
1538 | 2: secret |
|
1539 | 2: secret | |
1539 |
|
1540 | |||
1540 | Test that qfinish change phase when mq.secret=true |
|
1541 | Test that qfinish change phase when mq.secret=true | |
1541 |
|
1542 | |||
1542 | $ hg qfinish qbase |
|
1543 | $ hg qfinish qbase | |
1543 | patch add-file1 finalized without changeset message |
|
1544 | patch add-file1 finalized without changeset message | |
1544 | $ hg phase 'all()' |
|
1545 | $ hg phase 'all()' | |
1545 | 0: draft |
|
1546 | 0: draft | |
1546 | 1: secret |
|
1547 | 1: secret | |
1547 | 2: secret |
|
1548 | 2: secret | |
1548 |
|
1549 | |||
1549 | Test that qfinish respect phases.new-commit setting |
|
1550 | Test that qfinish respect phases.new-commit setting | |
1550 |
|
1551 | |||
1551 | $ echo '[phases]' >> $HGRCPATH |
|
1552 | $ echo '[phases]' >> $HGRCPATH | |
1552 | $ echo 'new-commit=secret' >> $HGRCPATH |
|
1553 | $ echo 'new-commit=secret' >> $HGRCPATH | |
1553 | $ hg qfinish qbase |
|
1554 | $ hg qfinish qbase | |
1554 | patch add-file2 finalized without changeset message |
|
1555 | patch add-file2 finalized without changeset message | |
1555 | $ hg phase 'all()' |
|
1556 | $ hg phase 'all()' | |
1556 | 0: draft |
|
1557 | 0: draft | |
1557 | 1: secret |
|
1558 | 1: secret | |
1558 | 2: secret |
|
1559 | 2: secret | |
1559 |
|
1560 | |||
1560 | (restore env for next test) |
|
1561 | (restore env for next test) | |
1561 |
|
1562 | |||
1562 | $ sed -e 's/new-commit=secret//' $HGRCPATH > $TESTTMP/sedtmp |
|
1563 | $ sed -e 's/new-commit=secret//' $HGRCPATH > $TESTTMP/sedtmp | |
1563 | $ cp $TESTTMP/sedtmp $HGRCPATH |
|
1564 | $ cp $TESTTMP/sedtmp $HGRCPATH | |
1564 | $ hg qimport -r 1 --name add-file2 |
|
1565 | $ hg qimport -r 1 --name add-file2 | |
1565 |
|
1566 | |||
1566 | Test that qfinish preserve phase when mq.secret=false |
|
1567 | Test that qfinish preserve phase when mq.secret=false | |
1567 |
|
1568 | |||
1568 | $ sed -e 's/secret=true/secret=false/' $HGRCPATH > $TESTTMP/sedtmp |
|
1569 | $ sed -e 's/secret=true/secret=false/' $HGRCPATH > $TESTTMP/sedtmp | |
1569 | $ cp $TESTTMP/sedtmp $HGRCPATH |
|
1570 | $ cp $TESTTMP/sedtmp $HGRCPATH | |
1570 | $ hg qfinish qbase |
|
1571 | $ hg qfinish qbase | |
1571 | patch add-file2 finalized without changeset message |
|
1572 | patch add-file2 finalized without changeset message | |
1572 | $ hg phase 'all()' |
|
1573 | $ hg phase 'all()' | |
1573 | 0: draft |
|
1574 | 0: draft | |
1574 | 1: secret |
|
1575 | 1: secret | |
1575 | 2: secret |
|
1576 | 2: secret | |
1576 |
|
1577 | |||
1577 | Test that secret mq patch does not break hgweb |
|
1578 | Test that secret mq patch does not break hgweb | |
1578 |
|
1579 | |||
1579 | $ cat > hgweb.cgi <<HGWEB |
|
1580 | $ cat > hgweb.cgi <<HGWEB | |
1580 | > from mercurial import demandimport; demandimport.enable() |
|
1581 | > from mercurial import demandimport; demandimport.enable() | |
1581 | > from mercurial.hgweb import hgweb |
|
1582 | > from mercurial.hgweb import hgweb | |
1582 | > from mercurial.hgweb import wsgicgi |
|
1583 | > from mercurial.hgweb import wsgicgi | |
1583 | > import cgitb |
|
1584 | > import cgitb | |
1584 | > cgitb.enable() |
|
1585 | > cgitb.enable() | |
1585 | > app = hgweb(b'.', b'test') |
|
1586 | > app = hgweb(b'.', b'test') | |
1586 | > wsgicgi.launch(app) |
|
1587 | > wsgicgi.launch(app) | |
1587 | > HGWEB |
|
1588 | > HGWEB | |
1588 | $ . "$TESTDIR/cgienv" |
|
1589 | $ . "$TESTDIR/cgienv" | |
1589 | #if msys |
|
1590 | #if msys | |
1590 | $ PATH_INFO=//tags; export PATH_INFO |
|
1591 | $ PATH_INFO=//tags; export PATH_INFO | |
1591 | #else |
|
1592 | #else | |
1592 | $ PATH_INFO=/tags; export PATH_INFO |
|
1593 | $ PATH_INFO=/tags; export PATH_INFO | |
1593 | #endif |
|
1594 | #endif | |
1594 | $ QUERY_STRING='style=raw' |
|
1595 | $ QUERY_STRING='style=raw' | |
1595 | $ "$PYTHON" hgweb.cgi | grep '^tip' |
|
1596 | $ "$PYTHON" hgweb.cgi | grep '^tip' | |
1596 | tip [0-9a-f]{40} (re) |
|
1597 | tip [0-9a-f]{40} (re) | |
1597 |
|
1598 | |||
1598 | $ cd .. |
|
1599 | $ cd .. | |
1599 |
|
1600 | |||
1600 | Test interaction with revset (issue4426) |
|
1601 | Test interaction with revset (issue4426) | |
1601 |
|
1602 | |||
1602 | $ hg init issue4426 |
|
1603 | $ hg init issue4426 | |
1603 | $ cd issue4426 |
|
1604 | $ cd issue4426 | |
1604 |
|
1605 | |||
1605 | $ echo a > a |
|
1606 | $ echo a > a | |
1606 | $ hg ci -Am a |
|
1607 | $ hg ci -Am a | |
1607 | adding a |
|
1608 | adding a | |
1608 | $ echo a >> a |
|
1609 | $ echo a >> a | |
1609 | $ hg ci -m a |
|
1610 | $ hg ci -m a | |
1610 | $ echo a >> a |
|
1611 | $ echo a >> a | |
1611 | $ hg ci -m a |
|
1612 | $ hg ci -m a | |
1612 | $ hg qimport -r 0:: |
|
1613 | $ hg qimport -r 0:: | |
1613 |
|
1614 | |||
1614 | reimport things |
|
1615 | reimport things | |
1615 |
|
1616 | |||
1616 | $ hg qimport -r 1:: |
|
1617 | $ hg qimport -r 1:: | |
1617 | abort: revision 2 is already managed |
|
1618 | abort: revision 2 is already managed | |
1618 | [255] |
|
1619 | [255] | |
1619 |
|
1620 | |||
1620 |
|
1621 | |||
1621 | $ cd .. |
|
1622 | $ cd .. |
@@ -1,1006 +1,1007 b'' | |||||
1 | $ cat <<EOF >> $HGRCPATH |
|
1 | $ cat <<EOF >> $HGRCPATH | |
2 | > [extensions] |
|
2 | > [extensions] | |
3 | > transplant= |
|
3 | > transplant= | |
4 | > EOF |
|
4 | > EOF | |
5 |
|
5 | |||
6 | $ hg init t |
|
6 | $ hg init t | |
7 | $ cd t |
|
7 | $ cd t | |
8 | $ hg transplant |
|
8 | $ hg transplant | |
9 | abort: no source URL, branch revision, or revision list provided |
|
9 | abort: no source URL, branch revision, or revision list provided | |
10 | [255] |
|
10 | [255] | |
11 | $ hg transplant --continue --all |
|
11 | $ hg transplant --continue --all | |
12 | abort: --continue is incompatible with --branch, --all and --merge |
|
12 | abort: --continue is incompatible with --branch, --all and --merge | |
13 | [255] |
|
13 | [255] | |
14 | $ hg transplant --all tip |
|
14 | $ hg transplant --all tip | |
15 | abort: --all requires a branch revision |
|
15 | abort: --all requires a branch revision | |
16 | [255] |
|
16 | [255] | |
17 | $ hg transplant --all --branch default tip |
|
17 | $ hg transplant --all --branch default tip | |
18 | abort: --all is incompatible with a revision list |
|
18 | abort: --all is incompatible with a revision list | |
19 | [255] |
|
19 | [255] | |
20 | $ echo r1 > r1 |
|
20 | $ echo r1 > r1 | |
21 | $ hg ci -Amr1 -d'0 0' |
|
21 | $ hg ci -Amr1 -d'0 0' | |
22 | adding r1 |
|
22 | adding r1 | |
23 | $ hg co -q null |
|
23 | $ hg co -q null | |
24 | $ hg transplant tip |
|
24 | $ hg transplant tip | |
25 | abort: no revision checked out |
|
25 | abort: no revision checked out | |
26 | [255] |
|
26 | [255] | |
27 | $ hg up -q |
|
27 | $ hg up -q | |
28 | $ echo r2 > r2 |
|
28 | $ echo r2 > r2 | |
29 | $ hg ci -Amr2 -d'1 0' |
|
29 | $ hg ci -Amr2 -d'1 0' | |
30 | adding r2 |
|
30 | adding r2 | |
31 | $ hg up 0 |
|
31 | $ hg up 0 | |
32 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
32 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
33 |
|
33 | |||
34 | $ echo b1 > b1 |
|
34 | $ echo b1 > b1 | |
35 | $ hg ci -Amb1 -d '0 0' |
|
35 | $ hg ci -Amb1 -d '0 0' | |
36 | adding b1 |
|
36 | adding b1 | |
37 | created new head |
|
37 | created new head | |
38 | $ hg merge 1 |
|
38 | $ hg merge 1 | |
39 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
39 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
40 | (branch merge, don't forget to commit) |
|
40 | (branch merge, don't forget to commit) | |
41 | $ hg transplant 1 |
|
41 | $ hg transplant 1 | |
42 | abort: outstanding uncommitted merge |
|
42 | abort: outstanding uncommitted merge | |
43 | [255] |
|
43 | [255] | |
44 | $ hg up -qC tip |
|
44 | $ hg up -qC tip | |
45 | $ echo b0 > b1 |
|
45 | $ echo b0 > b1 | |
46 | $ hg transplant 1 |
|
46 | $ hg transplant 1 | |
47 | abort: uncommitted changes |
|
47 | abort: uncommitted changes | |
48 | [255] |
|
48 | [255] | |
49 | $ hg up -qC tip |
|
49 | $ hg up -qC tip | |
50 | $ echo b2 > b2 |
|
50 | $ echo b2 > b2 | |
51 | $ hg ci -Amb2 -d '1 0' |
|
51 | $ hg ci -Amb2 -d '1 0' | |
52 | adding b2 |
|
52 | adding b2 | |
53 | $ echo b3 > b3 |
|
53 | $ echo b3 > b3 | |
54 | $ hg ci -Amb3 -d '2 0' |
|
54 | $ hg ci -Amb3 -d '2 0' | |
55 | adding b3 |
|
55 | adding b3 | |
56 |
|
56 | |||
57 | $ hg log --template '{rev} {parents} {desc}\n' |
|
57 | $ hg log --template '{rev} {parents} {desc}\n' | |
58 | 4 b3 |
|
58 | 4 b3 | |
59 | 3 b2 |
|
59 | 3 b2 | |
60 | 2 0:17ab29e464c6 b1 |
|
60 | 2 0:17ab29e464c6 b1 | |
61 | 1 r2 |
|
61 | 1 r2 | |
62 | 0 r1 |
|
62 | 0 r1 | |
63 |
|
63 | |||
64 | $ hg clone . ../rebase |
|
64 | $ hg clone . ../rebase | |
65 | updating to branch default |
|
65 | updating to branch default | |
66 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
66 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
67 | $ hg init ../emptydest |
|
67 | $ hg init ../emptydest | |
68 | $ cd ../emptydest |
|
68 | $ cd ../emptydest | |
69 | $ hg transplant --source=../t > /dev/null |
|
69 | $ hg transplant --source=../t > /dev/null | |
70 | $ cd ../rebase |
|
70 | $ cd ../rebase | |
71 |
|
71 | |||
72 | $ hg up -C 1 |
|
72 | $ hg up -C 1 | |
73 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
73 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
74 |
|
74 | |||
75 | rebase b onto r1 |
|
75 | rebase b onto r1 | |
76 | (this also tests that editor is not invoked if '--edit' is not specified) |
|
76 | (this also tests that editor is not invoked if '--edit' is not specified) | |
77 |
|
77 | |||
78 | $ HGEDITOR=cat hg transplant -a -b tip |
|
78 | $ HGEDITOR=cat hg transplant -a -b tip | |
79 | applying 37a1297eb21b |
|
79 | applying 37a1297eb21b | |
80 | 37a1297eb21b transplanted to e234d668f844 |
|
80 | 37a1297eb21b transplanted to e234d668f844 | |
81 | applying 722f4667af76 |
|
81 | applying 722f4667af76 | |
82 | 722f4667af76 transplanted to 539f377d78df |
|
82 | 722f4667af76 transplanted to 539f377d78df | |
83 | applying a53251cdf717 |
|
83 | applying a53251cdf717 | |
84 | a53251cdf717 transplanted to ffd6818a3975 |
|
84 | a53251cdf717 transplanted to ffd6818a3975 | |
85 | $ hg log --template '{rev} {parents} {desc}\n' |
|
85 | $ hg log --template '{rev} {parents} {desc}\n' | |
86 | 7 b3 |
|
86 | 7 b3 | |
87 | 6 b2 |
|
87 | 6 b2 | |
88 | 5 1:d11e3596cc1a b1 |
|
88 | 5 1:d11e3596cc1a b1 | |
89 | 4 b3 |
|
89 | 4 b3 | |
90 | 3 b2 |
|
90 | 3 b2 | |
91 | 2 0:17ab29e464c6 b1 |
|
91 | 2 0:17ab29e464c6 b1 | |
92 | 1 r2 |
|
92 | 1 r2 | |
93 | 0 r1 |
|
93 | 0 r1 | |
94 |
|
94 | |||
95 | test format of transplant_source |
|
95 | test format of transplant_source | |
96 |
|
96 | |||
97 | $ hg log -r7 --debug | grep transplant_source |
|
97 | $ hg log -r7 --debug | grep transplant_source | |
98 | extra: transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z |
|
98 | extra: transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z | |
99 | $ hg log -r7 -T '{extras}\n' |
|
99 | $ hg log -r7 -T '{extras}\n' | |
100 | branch=defaulttransplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z |
|
100 | branch=defaulttransplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z | |
101 | $ hg log -r7 -T '{join(extras, " ")}\n' |
|
101 | $ hg log -r7 -T '{join(extras, " ")}\n' | |
102 | branch=default transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z |
|
102 | branch=default transplant_source=\xa52Q\xcd\xf7\x17g\x9d\x19\x07\xb2\x89\xf9\x91SK\xe0\\\x99z | |
103 |
|
103 | |||
104 | test transplanted revset |
|
104 | test transplanted revset | |
105 |
|
105 | |||
106 | $ hg log -r 'transplanted()' --template '{rev} {parents} {desc}\n' |
|
106 | $ hg log -r 'transplanted()' --template '{rev} {parents} {desc}\n' | |
107 | 5 1:d11e3596cc1a b1 |
|
107 | 5 1:d11e3596cc1a b1 | |
108 | 6 b2 |
|
108 | 6 b2 | |
109 | 7 b3 |
|
109 | 7 b3 | |
110 | $ hg log -r 'transplanted(head())' --template '{rev} {parents} {desc}\n' |
|
110 | $ hg log -r 'transplanted(head())' --template '{rev} {parents} {desc}\n' | |
111 | 7 b3 |
|
111 | 7 b3 | |
112 | $ hg help revisions.transplanted |
|
112 | $ hg help revisions.transplanted | |
113 | "transplanted([set])" |
|
113 | "transplanted([set])" | |
114 | Transplanted changesets in set, or all transplanted changesets. |
|
114 | Transplanted changesets in set, or all transplanted changesets. | |
115 |
|
115 | |||
116 |
|
116 | |||
117 | test transplanted keyword |
|
117 | test transplanted keyword | |
118 |
|
118 | |||
119 | $ hg log --template '{rev} {transplanted}\n' |
|
119 | $ hg log --template '{rev} {transplanted}\n' | |
120 | 7 a53251cdf717679d1907b289f991534be05c997a |
|
120 | 7 a53251cdf717679d1907b289f991534be05c997a | |
121 | 6 722f4667af767100cb15b6a79324bf8abbfe1ef4 |
|
121 | 6 722f4667af767100cb15b6a79324bf8abbfe1ef4 | |
122 | 5 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21 |
|
122 | 5 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21 | |
123 | 4 |
|
123 | 4 | |
124 | 3 |
|
124 | 3 | |
125 | 2 |
|
125 | 2 | |
126 | 1 |
|
126 | 1 | |
127 | 0 |
|
127 | 0 | |
128 |
|
128 | |||
129 | test destination() revset predicate with a transplant of a transplant; new |
|
129 | test destination() revset predicate with a transplant of a transplant; new | |
130 | clone so subsequent rollback isn't affected |
|
130 | clone so subsequent rollback isn't affected | |
131 | (this also tests that editor is invoked if '--edit' is specified) |
|
131 | (this also tests that editor is invoked if '--edit' is specified) | |
132 |
|
132 | |||
133 | $ hg clone -q . ../destination |
|
133 | $ hg clone -q . ../destination | |
134 | $ cd ../destination |
|
134 | $ cd ../destination | |
135 | $ hg up -Cq 0 |
|
135 | $ hg up -Cq 0 | |
136 | $ hg branch -q b4 |
|
136 | $ hg branch -q b4 | |
137 | $ hg ci -qm "b4" |
|
137 | $ hg ci -qm "b4" | |
138 | $ hg status --rev "7^1" --rev 7 |
|
138 | $ hg status --rev "7^1" --rev 7 | |
139 | A b3 |
|
139 | A b3 | |
140 | $ cat > $TESTTMP/checkeditform.sh <<EOF |
|
140 | $ cat > $TESTTMP/checkeditform.sh <<EOF | |
141 | > env | grep HGEDITFORM |
|
141 | > env | grep HGEDITFORM | |
142 | > true |
|
142 | > true | |
143 | > EOF |
|
143 | > EOF | |
144 | $ cat > $TESTTMP/checkeditform-n-cat.sh <<EOF |
|
144 | $ cat > $TESTTMP/checkeditform-n-cat.sh <<EOF | |
145 | > env | grep HGEDITFORM |
|
145 | > env | grep HGEDITFORM | |
146 | > cat \$* |
|
146 | > cat \$* | |
147 | > EOF |
|
147 | > EOF | |
148 | $ HGEDITOR="sh $TESTTMP/checkeditform-n-cat.sh" hg transplant --edit 7 |
|
148 | $ HGEDITOR="sh $TESTTMP/checkeditform-n-cat.sh" hg transplant --edit 7 | |
149 | applying ffd6818a3975 |
|
149 | applying ffd6818a3975 | |
150 | HGEDITFORM=transplant.normal |
|
150 | HGEDITFORM=transplant.normal | |
151 | b3 |
|
151 | b3 | |
152 |
|
152 | |||
153 |
|
153 | |||
154 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
154 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
155 | HG: Leave message empty to abort commit. |
|
155 | HG: Leave message empty to abort commit. | |
156 | HG: -- |
|
156 | HG: -- | |
157 | HG: user: test |
|
157 | HG: user: test | |
158 | HG: branch 'b4' |
|
158 | HG: branch 'b4' | |
159 | HG: added b3 |
|
159 | HG: added b3 | |
160 | ffd6818a3975 transplanted to 502236fa76bb |
|
160 | ffd6818a3975 transplanted to 502236fa76bb | |
161 |
|
161 | |||
162 |
|
162 | |||
163 | $ hg log -r 'destination()' |
|
163 | $ hg log -r 'destination()' | |
164 | changeset: 5:e234d668f844 |
|
164 | changeset: 5:e234d668f844 | |
165 | parent: 1:d11e3596cc1a |
|
165 | parent: 1:d11e3596cc1a | |
166 | user: test |
|
166 | user: test | |
167 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
167 | date: Thu Jan 01 00:00:00 1970 +0000 | |
168 | summary: b1 |
|
168 | summary: b1 | |
169 |
|
169 | |||
170 | changeset: 6:539f377d78df |
|
170 | changeset: 6:539f377d78df | |
171 | user: test |
|
171 | user: test | |
172 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
172 | date: Thu Jan 01 00:00:01 1970 +0000 | |
173 | summary: b2 |
|
173 | summary: b2 | |
174 |
|
174 | |||
175 | changeset: 7:ffd6818a3975 |
|
175 | changeset: 7:ffd6818a3975 | |
176 | user: test |
|
176 | user: test | |
177 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
177 | date: Thu Jan 01 00:00:02 1970 +0000 | |
178 | summary: b3 |
|
178 | summary: b3 | |
179 |
|
179 | |||
180 | changeset: 9:502236fa76bb |
|
180 | changeset: 9:502236fa76bb | |
181 | branch: b4 |
|
181 | branch: b4 | |
182 | tag: tip |
|
182 | tag: tip | |
183 | user: test |
|
183 | user: test | |
184 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
184 | date: Thu Jan 01 00:00:02 1970 +0000 | |
185 | summary: b3 |
|
185 | summary: b3 | |
186 |
|
186 | |||
187 | $ hg log -r 'destination(a53251cdf717)' |
|
187 | $ hg log -r 'destination(a53251cdf717)' | |
188 | changeset: 7:ffd6818a3975 |
|
188 | changeset: 7:ffd6818a3975 | |
189 | user: test |
|
189 | user: test | |
190 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
190 | date: Thu Jan 01 00:00:02 1970 +0000 | |
191 | summary: b3 |
|
191 | summary: b3 | |
192 |
|
192 | |||
193 | changeset: 9:502236fa76bb |
|
193 | changeset: 9:502236fa76bb | |
194 | branch: b4 |
|
194 | branch: b4 | |
195 | tag: tip |
|
195 | tag: tip | |
196 | user: test |
|
196 | user: test | |
197 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
197 | date: Thu Jan 01 00:00:02 1970 +0000 | |
198 | summary: b3 |
|
198 | summary: b3 | |
199 |
|
199 | |||
200 |
|
200 | |||
201 | test subset parameter in reverse order |
|
201 | test subset parameter in reverse order | |
202 | $ hg log -r 'reverse(all()) and destination(a53251cdf717)' |
|
202 | $ hg log -r 'reverse(all()) and destination(a53251cdf717)' | |
203 | changeset: 9:502236fa76bb |
|
203 | changeset: 9:502236fa76bb | |
204 | branch: b4 |
|
204 | branch: b4 | |
205 | tag: tip |
|
205 | tag: tip | |
206 | user: test |
|
206 | user: test | |
207 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
207 | date: Thu Jan 01 00:00:02 1970 +0000 | |
208 | summary: b3 |
|
208 | summary: b3 | |
209 |
|
209 | |||
210 | changeset: 7:ffd6818a3975 |
|
210 | changeset: 7:ffd6818a3975 | |
211 | user: test |
|
211 | user: test | |
212 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
212 | date: Thu Jan 01 00:00:02 1970 +0000 | |
213 | summary: b3 |
|
213 | summary: b3 | |
214 |
|
214 | |||
215 |
|
215 | |||
216 | back to the original dir |
|
216 | back to the original dir | |
217 | $ cd ../rebase |
|
217 | $ cd ../rebase | |
218 |
|
218 | |||
219 | rollback the transplant |
|
219 | rollback the transplant | |
220 | $ hg rollback |
|
220 | $ hg rollback | |
221 | repository tip rolled back to revision 4 (undo transplant) |
|
221 | repository tip rolled back to revision 4 (undo transplant) | |
222 | working directory now based on revision 1 |
|
222 | working directory now based on revision 1 | |
223 | $ hg tip -q |
|
223 | $ hg tip -q | |
224 | 4:a53251cdf717 |
|
224 | 4:a53251cdf717 | |
225 | $ hg parents -q |
|
225 | $ hg parents -q | |
226 | 1:d11e3596cc1a |
|
226 | 1:d11e3596cc1a | |
227 | $ hg status |
|
227 | $ hg status | |
228 | ? b1 |
|
228 | ? b1 | |
229 | ? b2 |
|
229 | ? b2 | |
230 | ? b3 |
|
230 | ? b3 | |
231 |
|
231 | |||
232 | $ hg clone ../t ../prune |
|
232 | $ hg clone ../t ../prune | |
233 | updating to branch default |
|
233 | updating to branch default | |
234 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
234 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
235 | $ cd ../prune |
|
235 | $ cd ../prune | |
236 |
|
236 | |||
237 | $ hg up -C 1 |
|
237 | $ hg up -C 1 | |
238 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
238 | 1 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
239 |
|
239 | |||
240 | rebase b onto r1, skipping b2 |
|
240 | rebase b onto r1, skipping b2 | |
241 |
|
241 | |||
242 | $ hg transplant -a -b tip -p 3 |
|
242 | $ hg transplant -a -b tip -p 3 | |
243 | applying 37a1297eb21b |
|
243 | applying 37a1297eb21b | |
244 | 37a1297eb21b transplanted to e234d668f844 |
|
244 | 37a1297eb21b transplanted to e234d668f844 | |
245 | applying a53251cdf717 |
|
245 | applying a53251cdf717 | |
246 | a53251cdf717 transplanted to 7275fda4d04f |
|
246 | a53251cdf717 transplanted to 7275fda4d04f | |
247 | $ hg log --template '{rev} {parents} {desc}\n' |
|
247 | $ hg log --template '{rev} {parents} {desc}\n' | |
248 | 6 b3 |
|
248 | 6 b3 | |
249 | 5 1:d11e3596cc1a b1 |
|
249 | 5 1:d11e3596cc1a b1 | |
250 | 4 b3 |
|
250 | 4 b3 | |
251 | 3 b2 |
|
251 | 3 b2 | |
252 | 2 0:17ab29e464c6 b1 |
|
252 | 2 0:17ab29e464c6 b1 | |
253 | 1 r2 |
|
253 | 1 r2 | |
254 | 0 r1 |
|
254 | 0 r1 | |
255 |
|
255 | |||
256 | test same-parent transplant with --log |
|
256 | test same-parent transplant with --log | |
257 |
|
257 | |||
258 | $ hg clone -r 1 ../t ../sameparent |
|
258 | $ hg clone -r 1 ../t ../sameparent | |
259 | adding changesets |
|
259 | adding changesets | |
260 | adding manifests |
|
260 | adding manifests | |
261 | adding file changes |
|
261 | adding file changes | |
262 | added 2 changesets with 2 changes to 2 files |
|
262 | added 2 changesets with 2 changes to 2 files | |
263 | new changesets 17ab29e464c6:d11e3596cc1a |
|
263 | new changesets 17ab29e464c6:d11e3596cc1a | |
264 | updating to branch default |
|
264 | updating to branch default | |
265 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
265 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
266 | $ cd ../sameparent |
|
266 | $ cd ../sameparent | |
267 | $ hg transplant --log -s ../prune 5 |
|
267 | $ hg transplant --log -s ../prune 5 | |
268 | searching for changes |
|
268 | searching for changes | |
269 | applying e234d668f844 |
|
269 | applying e234d668f844 | |
270 | e234d668f844 transplanted to e07aea8ecf9c |
|
270 | e234d668f844 transplanted to e07aea8ecf9c | |
271 | $ hg log --template '{rev} {parents} {desc}\n' |
|
271 | $ hg log --template '{rev} {parents} {desc}\n' | |
272 | 2 b1 |
|
272 | 2 b1 | |
273 | (transplanted from e234d668f844e1b1a765f01db83a32c0c7bfa170) |
|
273 | (transplanted from e234d668f844e1b1a765f01db83a32c0c7bfa170) | |
274 | 1 r2 |
|
274 | 1 r2 | |
275 | 0 r1 |
|
275 | 0 r1 | |
276 | remote transplant, and also test that transplant doesn't break with |
|
276 | remote transplant, and also test that transplant doesn't break with | |
277 | format-breaking diffopts |
|
277 | format-breaking diffopts | |
278 |
|
278 | |||
279 | $ hg clone -r 1 ../t ../remote |
|
279 | $ hg clone -r 1 ../t ../remote | |
280 | adding changesets |
|
280 | adding changesets | |
281 | adding manifests |
|
281 | adding manifests | |
282 | adding file changes |
|
282 | adding file changes | |
283 | added 2 changesets with 2 changes to 2 files |
|
283 | added 2 changesets with 2 changes to 2 files | |
284 | new changesets 17ab29e464c6:d11e3596cc1a |
|
284 | new changesets 17ab29e464c6:d11e3596cc1a | |
285 | updating to branch default |
|
285 | updating to branch default | |
286 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
286 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
287 | $ cd ../remote |
|
287 | $ cd ../remote | |
288 | $ hg --config diff.noprefix=True transplant --log -s ../t 2 4 |
|
288 | $ hg --config diff.noprefix=True transplant --log -s ../t 2 4 | |
289 | searching for changes |
|
289 | searching for changes | |
290 | applying 37a1297eb21b |
|
290 | applying 37a1297eb21b | |
291 | 37a1297eb21b transplanted to c19cf0ccb069 |
|
291 | 37a1297eb21b transplanted to c19cf0ccb069 | |
292 | applying a53251cdf717 |
|
292 | applying a53251cdf717 | |
293 | a53251cdf717 transplanted to f7fe5bf98525 |
|
293 | a53251cdf717 transplanted to f7fe5bf98525 | |
294 | $ hg log --template '{rev} {parents} {desc}\n' |
|
294 | $ hg log --template '{rev} {parents} {desc}\n' | |
295 | 3 b3 |
|
295 | 3 b3 | |
296 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) |
|
296 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) | |
297 | 2 b1 |
|
297 | 2 b1 | |
298 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) |
|
298 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) | |
299 | 1 r2 |
|
299 | 1 r2 | |
300 | 0 r1 |
|
300 | 0 r1 | |
301 |
|
301 | |||
302 | skip previous transplants |
|
302 | skip previous transplants | |
303 |
|
303 | |||
304 | $ hg transplant -s ../t -a -b 4 |
|
304 | $ hg transplant -s ../t -a -b 4 | |
305 | searching for changes |
|
305 | searching for changes | |
306 | applying 722f4667af76 |
|
306 | applying 722f4667af76 | |
307 | 722f4667af76 transplanted to 47156cd86c0b |
|
307 | 722f4667af76 transplanted to 47156cd86c0b | |
308 | $ hg log --template '{rev} {parents} {desc}\n' |
|
308 | $ hg log --template '{rev} {parents} {desc}\n' | |
309 | 4 b2 |
|
309 | 4 b2 | |
310 | 3 b3 |
|
310 | 3 b3 | |
311 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) |
|
311 | (transplanted from a53251cdf717679d1907b289f991534be05c997a) | |
312 | 2 b1 |
|
312 | 2 b1 | |
313 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) |
|
313 | (transplanted from 37a1297eb21b3ef5c5d2ffac22121a0988ed9f21) | |
314 | 1 r2 |
|
314 | 1 r2 | |
315 | 0 r1 |
|
315 | 0 r1 | |
316 |
|
316 | |||
317 | skip local changes transplanted to the source |
|
317 | skip local changes transplanted to the source | |
318 |
|
318 | |||
319 | $ echo b4 > b4 |
|
319 | $ echo b4 > b4 | |
320 | $ hg ci -Amb4 -d '3 0' |
|
320 | $ hg ci -Amb4 -d '3 0' | |
321 | adding b4 |
|
321 | adding b4 | |
322 | $ hg clone ../t ../pullback |
|
322 | $ hg clone ../t ../pullback | |
323 | updating to branch default |
|
323 | updating to branch default | |
324 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
324 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
325 | $ cd ../pullback |
|
325 | $ cd ../pullback | |
326 | $ hg transplant -s ../remote -a -b tip |
|
326 | $ hg transplant -s ../remote -a -b tip | |
327 | searching for changes |
|
327 | searching for changes | |
328 | applying 4333daefcb15 |
|
328 | applying 4333daefcb15 | |
329 | 4333daefcb15 transplanted to 5f42c04e07cc |
|
329 | 4333daefcb15 transplanted to 5f42c04e07cc | |
330 |
|
330 | |||
331 |
|
331 | |||
332 | remote transplant with pull |
|
332 | remote transplant with pull | |
333 |
|
333 | |||
334 | $ hg serve -R ../t -p $HGPORT -d --pid-file=../t.pid |
|
334 | $ hg serve -R ../t -p $HGPORT -d --pid-file=../t.pid | |
335 | $ cat ../t.pid >> $DAEMON_PIDS |
|
335 | $ cat ../t.pid >> $DAEMON_PIDS | |
336 |
|
336 | |||
337 | $ hg clone -r 0 ../t ../rp |
|
337 | $ hg clone -r 0 ../t ../rp | |
338 | adding changesets |
|
338 | adding changesets | |
339 | adding manifests |
|
339 | adding manifests | |
340 | adding file changes |
|
340 | adding file changes | |
341 | added 1 changesets with 1 changes to 1 files |
|
341 | added 1 changesets with 1 changes to 1 files | |
342 | new changesets 17ab29e464c6 |
|
342 | new changesets 17ab29e464c6 | |
343 | updating to branch default |
|
343 | updating to branch default | |
344 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
344 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
345 | $ cd ../rp |
|
345 | $ cd ../rp | |
346 | $ hg transplant -s http://localhost:$HGPORT/ 37a1297eb21b a53251cdf717 |
|
346 | $ hg transplant -s http://localhost:$HGPORT/ 37a1297eb21b a53251cdf717 | |
347 | searching for changes |
|
347 | searching for changes | |
348 | searching for changes |
|
348 | searching for changes | |
349 | adding changesets |
|
349 | adding changesets | |
350 | adding manifests |
|
350 | adding manifests | |
351 | adding file changes |
|
351 | adding file changes | |
352 | added 1 changesets with 1 changes to 1 files |
|
352 | added 1 changesets with 1 changes to 1 files | |
353 | applying a53251cdf717 |
|
353 | applying a53251cdf717 | |
354 | a53251cdf717 transplanted to 8d9279348abb |
|
354 | a53251cdf717 transplanted to 8d9279348abb | |
355 | $ hg log --template '{rev} {parents} {desc}\n' |
|
355 | $ hg log --template '{rev} {parents} {desc}\n' | |
356 | 2 b3 |
|
356 | 2 b3 | |
357 | 1 b1 |
|
357 | 1 b1 | |
358 | 0 r1 |
|
358 | 0 r1 | |
359 |
|
359 | |||
360 | remote transplant without pull |
|
360 | remote transplant without pull | |
361 | (It was using "2" and "4" (as the previous transplant used to) which referenced |
|
361 | (It was using "2" and "4" (as the previous transplant used to) which referenced | |
362 | revision different from one run to another) |
|
362 | revision different from one run to another) | |
363 |
|
363 | |||
364 | $ hg pull -q http://localhost:$HGPORT/ |
|
364 | $ hg pull -q http://localhost:$HGPORT/ | |
365 | $ hg transplant -s http://localhost:$HGPORT/ 8d9279348abb 722f4667af76 |
|
365 | $ hg transplant -s http://localhost:$HGPORT/ 8d9279348abb 722f4667af76 | |
366 | skipping already applied revision 2:8d9279348abb |
|
366 | skipping already applied revision 2:8d9279348abb | |
367 | applying 722f4667af76 |
|
367 | applying 722f4667af76 | |
368 | 722f4667af76 transplanted to 76e321915884 |
|
368 | 722f4667af76 transplanted to 76e321915884 | |
369 |
|
369 | |||
370 | transplant --continue |
|
370 | transplant --continue | |
371 |
|
371 | |||
372 | $ hg init ../tc |
|
372 | $ hg init ../tc | |
373 | $ cd ../tc |
|
373 | $ cd ../tc | |
374 | $ cat <<EOF > foo |
|
374 | $ cat <<EOF > foo | |
375 | > foo |
|
375 | > foo | |
376 | > bar |
|
376 | > bar | |
377 | > baz |
|
377 | > baz | |
378 | > EOF |
|
378 | > EOF | |
379 | $ echo toremove > toremove |
|
379 | $ echo toremove > toremove | |
380 | $ echo baz > baz |
|
380 | $ echo baz > baz | |
381 | $ hg ci -Amfoo |
|
381 | $ hg ci -Amfoo | |
382 | adding baz |
|
382 | adding baz | |
383 | adding foo |
|
383 | adding foo | |
384 | adding toremove |
|
384 | adding toremove | |
385 | $ cat <<EOF > foo |
|
385 | $ cat <<EOF > foo | |
386 | > foo2 |
|
386 | > foo2 | |
387 | > bar2 |
|
387 | > bar2 | |
388 | > baz2 |
|
388 | > baz2 | |
389 | > EOF |
|
389 | > EOF | |
390 | $ rm toremove |
|
390 | $ rm toremove | |
391 | $ echo added > added |
|
391 | $ echo added > added | |
392 | $ hg ci -Amfoo2 |
|
392 | $ hg ci -Amfoo2 | |
393 | adding added |
|
393 | adding added | |
394 | removing toremove |
|
394 | removing toremove | |
395 | $ echo bar > bar |
|
395 | $ echo bar > bar | |
396 | $ cat > baz <<EOF |
|
396 | $ cat > baz <<EOF | |
397 | > before baz |
|
397 | > before baz | |
398 | > baz |
|
398 | > baz | |
399 | > after baz |
|
399 | > after baz | |
400 | > EOF |
|
400 | > EOF | |
401 | $ hg ci -Ambar |
|
401 | $ hg ci -Ambar | |
402 | adding bar |
|
402 | adding bar | |
403 | $ echo bar2 >> bar |
|
403 | $ echo bar2 >> bar | |
404 | $ hg ci -mbar2 |
|
404 | $ hg ci -mbar2 | |
405 | $ hg up 0 |
|
405 | $ hg up 0 | |
406 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
406 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
407 | $ echo foobar > foo |
|
407 | $ echo foobar > foo | |
408 | $ hg ci -mfoobar |
|
408 | $ hg ci -mfoobar | |
409 | created new head |
|
409 | created new head | |
410 | $ hg transplant 1:3 |
|
410 | $ hg transplant 1:3 | |
411 | applying 46ae92138f3c |
|
411 | applying 46ae92138f3c | |
412 | patching file foo |
|
412 | patching file foo | |
413 | Hunk #1 FAILED at 0 |
|
413 | Hunk #1 FAILED at 0 | |
414 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej |
|
414 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej | |
415 | patch failed to apply |
|
415 | patch failed to apply | |
416 | abort: fix up the working directory and run hg transplant --continue |
|
416 | abort: fix up the working directory and run hg transplant --continue | |
417 | [255] |
|
417 | [255] | |
418 |
|
418 | |||
419 | transplant -c shouldn't use an old changeset |
|
419 | transplant -c shouldn't use an old changeset | |
420 |
|
420 | |||
421 | $ hg up -C |
|
421 | $ hg up -C | |
422 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
422 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
423 | updated to "e8643552fde5: foobar" |
|
423 | updated to "e8643552fde5: foobar" | |
424 | 1 other heads for branch "default" |
|
424 | 1 other heads for branch "default" | |
425 | $ rm added |
|
425 | $ rm added | |
426 | $ hg transplant --continue |
|
426 | $ hg transplant --continue | |
427 | abort: no transplant to continue |
|
427 | abort: no transplant to continue | |
428 | [255] |
|
428 | [255] | |
429 | $ hg transplant 1 |
|
429 | $ hg transplant 1 | |
430 | applying 46ae92138f3c |
|
430 | applying 46ae92138f3c | |
431 | patching file foo |
|
431 | patching file foo | |
432 | Hunk #1 FAILED at 0 |
|
432 | Hunk #1 FAILED at 0 | |
433 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej |
|
433 | 1 out of 1 hunks FAILED -- saving rejects to file foo.rej | |
434 | patch failed to apply |
|
434 | patch failed to apply | |
435 | abort: fix up the working directory and run hg transplant --continue |
|
435 | abort: fix up the working directory and run hg transplant --continue | |
436 | [255] |
|
436 | [255] | |
437 | $ cp .hg/transplant/journal .hg/transplant/journal.orig |
|
437 | $ cp .hg/transplant/journal .hg/transplant/journal.orig | |
438 | $ cat .hg/transplant/journal |
|
438 | $ cat .hg/transplant/journal | |
439 | # User test |
|
439 | # User test | |
440 | # Date 0 0 |
|
440 | # Date 0 0 | |
441 | # Node ID 46ae92138f3ce0249f6789650403286ead052b6d |
|
441 | # Node ID 46ae92138f3ce0249f6789650403286ead052b6d | |
442 | # Parent e8643552fde58f57515e19c4b373a57c96e62af3 |
|
442 | # Parent e8643552fde58f57515e19c4b373a57c96e62af3 | |
443 | foo2 |
|
443 | foo2 | |
444 | $ grep -v 'Date' .hg/transplant/journal.orig > .hg/transplant/journal |
|
444 | $ grep -v 'Date' .hg/transplant/journal.orig > .hg/transplant/journal | |
445 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e |
|
445 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e | |
446 | abort: filter corrupted changeset (no user or date) |
|
446 | abort: filter corrupted changeset (no user or date) | |
447 | [255] |
|
447 | [255] | |
448 | $ cp .hg/transplant/journal.orig .hg/transplant/journal |
|
448 | $ cp .hg/transplant/journal.orig .hg/transplant/journal | |
449 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e |
|
449 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e | |
450 | HGEDITFORM=transplant.normal |
|
450 | HGEDITFORM=transplant.normal | |
451 | 46ae92138f3c transplanted as 9159dada197d |
|
451 | 46ae92138f3c transplanted as 9159dada197d | |
452 | $ hg transplant 1:3 |
|
452 | $ hg transplant 1:3 | |
453 | skipping already applied revision 1:46ae92138f3c |
|
453 | skipping already applied revision 1:46ae92138f3c | |
454 | applying 9d6d6b5a8275 |
|
454 | applying 9d6d6b5a8275 | |
455 | 9d6d6b5a8275 transplanted to 2d17a10c922f |
|
455 | 9d6d6b5a8275 transplanted to 2d17a10c922f | |
456 | applying 1dab759070cf |
|
456 | applying 1dab759070cf | |
457 | 1dab759070cf transplanted to e06a69927eb0 |
|
457 | 1dab759070cf transplanted to e06a69927eb0 | |
458 | $ hg locate |
|
458 | $ hg locate | |
459 | added |
|
459 | added | |
460 | bar |
|
460 | bar | |
461 | baz |
|
461 | baz | |
462 | foo |
|
462 | foo | |
463 |
|
463 | |||
464 | test multiple revisions and --continue |
|
464 | test multiple revisions and --continue | |
465 |
|
465 | |||
466 | $ hg up -qC 0 |
|
466 | $ hg up -qC 0 | |
467 | $ echo bazbaz > baz |
|
467 | $ echo bazbaz > baz | |
468 | $ hg ci -Am anotherbaz baz |
|
468 | $ hg ci -Am anotherbaz baz | |
469 | created new head |
|
469 | created new head | |
470 | $ hg transplant 1:3 |
|
470 | $ hg transplant 1:3 | |
471 | applying 46ae92138f3c |
|
471 | applying 46ae92138f3c | |
472 | 46ae92138f3c transplanted to 1024233ea0ba |
|
472 | 46ae92138f3c transplanted to 1024233ea0ba | |
473 | applying 9d6d6b5a8275 |
|
473 | applying 9d6d6b5a8275 | |
474 | patching file baz |
|
474 | patching file baz | |
475 | Hunk #1 FAILED at 0 |
|
475 | Hunk #1 FAILED at 0 | |
476 | 1 out of 1 hunks FAILED -- saving rejects to file baz.rej |
|
476 | 1 out of 1 hunks FAILED -- saving rejects to file baz.rej | |
477 | patch failed to apply |
|
477 | patch failed to apply | |
478 | abort: fix up the working directory and run hg transplant --continue |
|
478 | abort: fix up the working directory and run hg transplant --continue | |
479 | [255] |
|
479 | [255] | |
480 | $ hg transplant 1:3 |
|
480 | $ hg transplant 1:3 | |
481 | abort: transplant in progress |
|
481 | abort: transplant in progress | |
482 | (use 'hg transplant --continue' or 'hg update' to abort) |
|
482 | (use 'hg transplant --continue' or 'hg update' to abort) | |
483 | [255] |
|
483 | [255] | |
484 | $ echo fixed > baz |
|
484 | $ echo fixed > baz | |
485 | $ hg transplant --continue |
|
485 | $ hg transplant --continue | |
486 | 9d6d6b5a8275 transplanted as d80c49962290 |
|
486 | 9d6d6b5a8275 transplanted as d80c49962290 | |
487 | applying 1dab759070cf |
|
487 | applying 1dab759070cf | |
488 | 1dab759070cf transplanted to aa0ffe6bd5ae |
|
488 | 1dab759070cf transplanted to aa0ffe6bd5ae | |
489 |
|
489 | |||
490 | $ cd .. |
|
490 | $ cd .. | |
491 |
|
491 | |||
492 | Issue1111: Test transplant --merge |
|
492 | Issue1111: Test transplant --merge | |
493 |
|
493 | |||
494 | $ hg init t1111 |
|
494 | $ hg init t1111 | |
495 | $ cd t1111 |
|
495 | $ cd t1111 | |
496 | $ echo a > a |
|
496 | $ echo a > a | |
497 | $ hg ci -Am adda |
|
497 | $ hg ci -Am adda | |
498 | adding a |
|
498 | adding a | |
499 | $ echo b >> a |
|
499 | $ echo b >> a | |
500 | $ hg ci -m appendb |
|
500 | $ hg ci -m appendb | |
501 | $ echo c >> a |
|
501 | $ echo c >> a | |
502 | $ hg ci -m appendc |
|
502 | $ hg ci -m appendc | |
503 | $ hg up -C 0 |
|
503 | $ hg up -C 0 | |
504 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
504 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
505 | $ echo d >> a |
|
505 | $ echo d >> a | |
506 | $ hg ci -m appendd |
|
506 | $ hg ci -m appendd | |
507 | created new head |
|
507 | created new head | |
508 |
|
508 | |||
509 | transplant |
|
509 | transplant | |
510 |
|
510 | |||
511 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant -m 1 -e |
|
511 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant -m 1 -e | |
512 | applying 42dc4432fd35 |
|
512 | applying 42dc4432fd35 | |
513 | HGEDITFORM=transplant.merge |
|
513 | HGEDITFORM=transplant.merge | |
514 | 1:42dc4432fd35 merged at a9f4acbac129 |
|
514 | 1:42dc4432fd35 merged at a9f4acbac129 | |
515 | $ hg update -q -C 2 |
|
515 | $ hg update -q -C 2 | |
516 | $ cat > a <<EOF |
|
516 | $ cat > a <<EOF | |
517 | > x |
|
517 | > x | |
518 | > y |
|
518 | > y | |
519 | > z |
|
519 | > z | |
520 | > EOF |
|
520 | > EOF | |
521 | $ hg commit -m replace |
|
521 | $ hg commit -m replace | |
522 | $ hg update -q -C 4 |
|
522 | $ hg update -q -C 4 | |
523 | $ hg transplant -m 5 |
|
523 | $ hg transplant -m 5 | |
524 | applying 600a3cdcb41d |
|
524 | applying 600a3cdcb41d | |
525 | patching file a |
|
525 | patching file a | |
526 | Hunk #1 FAILED at 0 |
|
526 | Hunk #1 FAILED at 0 | |
527 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej |
|
527 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
528 | patch failed to apply |
|
528 | patch failed to apply | |
529 | abort: fix up the working directory and run hg transplant --continue |
|
529 | abort: fix up the working directory and run hg transplant --continue | |
530 | [255] |
|
530 | [255] | |
531 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e |
|
531 | $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg transplant --continue -e | |
532 | HGEDITFORM=transplant.merge |
|
532 | HGEDITFORM=transplant.merge | |
533 | 600a3cdcb41d transplanted as a3f88be652e0 |
|
533 | 600a3cdcb41d transplanted as a3f88be652e0 | |
534 |
|
534 | |||
535 | $ cd .. |
|
535 | $ cd .. | |
536 |
|
536 | |||
537 | test transplant into empty repository |
|
537 | test transplant into empty repository | |
538 |
|
538 | |||
539 | $ hg init empty |
|
539 | $ hg init empty | |
540 | $ cd empty |
|
540 | $ cd empty | |
541 | $ hg transplant -s ../t -b tip -a |
|
541 | $ hg transplant -s ../t -b tip -a | |
542 | adding changesets |
|
542 | adding changesets | |
543 | adding manifests |
|
543 | adding manifests | |
544 | adding file changes |
|
544 | adding file changes | |
545 | added 4 changesets with 4 changes to 4 files |
|
545 | added 4 changesets with 4 changes to 4 files | |
546 | new changesets 17ab29e464c6:a53251cdf717 |
|
546 | new changesets 17ab29e464c6:a53251cdf717 | |
547 |
|
547 | |||
548 | test "--merge" causing pull from source repository on local host |
|
548 | test "--merge" causing pull from source repository on local host | |
549 |
|
549 | |||
550 | $ hg --config extensions.mq= -q strip 2 |
|
550 | $ hg --config extensions.mq= -q strip 2 | |
551 | $ hg transplant -s ../t --merge tip |
|
551 | $ hg transplant -s ../t --merge tip | |
552 | searching for changes |
|
552 | searching for changes | |
553 | searching for changes |
|
553 | searching for changes | |
554 | adding changesets |
|
554 | adding changesets | |
555 | adding manifests |
|
555 | adding manifests | |
556 | adding file changes |
|
556 | adding file changes | |
557 | added 2 changesets with 2 changes to 2 files |
|
557 | added 2 changesets with 2 changes to 2 files | |
558 | applying a53251cdf717 |
|
558 | applying a53251cdf717 | |
559 | 4:a53251cdf717 merged at 4831f4dc831a |
|
559 | 4:a53251cdf717 merged at 4831f4dc831a | |
560 |
|
560 | |||
561 | test interactive transplant |
|
561 | test interactive transplant | |
562 |
|
562 | |||
563 | $ hg --config extensions.strip= -q strip 0 |
|
563 | $ hg --config extensions.strip= -q strip 0 | |
564 | $ hg -R ../t log -G --template "{rev}:{node|short}" |
|
564 | $ hg -R ../t log -G --template "{rev}:{node|short}" | |
565 | @ 4:a53251cdf717 |
|
565 | @ 4:a53251cdf717 | |
566 | | |
|
566 | | | |
567 | o 3:722f4667af76 |
|
567 | o 3:722f4667af76 | |
568 | | |
|
568 | | | |
569 | o 2:37a1297eb21b |
|
569 | o 2:37a1297eb21b | |
570 | | |
|
570 | | | |
571 | | o 1:d11e3596cc1a |
|
571 | | o 1:d11e3596cc1a | |
572 | |/ |
|
572 | |/ | |
573 | o 0:17ab29e464c6 |
|
573 | o 0:17ab29e464c6 | |
574 |
|
574 | |||
575 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF |
|
575 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF | |
576 | > ? |
|
576 | > ? | |
577 | > x |
|
577 | > x | |
578 | > q |
|
578 | > q | |
579 | > EOF |
|
579 | > EOF | |
580 | 0:17ab29e464c6 |
|
580 | 0:17ab29e464c6 | |
581 | apply changeset? [ynmpcq?]: ? |
|
581 | apply changeset? [ynmpcq?]: ? | |
582 | y: yes, transplant this changeset |
|
582 | y: yes, transplant this changeset | |
583 | n: no, skip this changeset |
|
583 | n: no, skip this changeset | |
584 | m: merge at this changeset |
|
584 | m: merge at this changeset | |
585 | p: show patch |
|
585 | p: show patch | |
586 | c: commit selected changesets |
|
586 | c: commit selected changesets | |
587 | q: quit and cancel transplant |
|
587 | q: quit and cancel transplant | |
588 | ?: ? (show this help) |
|
588 | ?: ? (show this help) | |
589 | apply changeset? [ynmpcq?]: x |
|
589 | apply changeset? [ynmpcq?]: x | |
590 | unrecognized response |
|
590 | unrecognized response | |
591 | apply changeset? [ynmpcq?]: q |
|
591 | apply changeset? [ynmpcq?]: q | |
592 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF |
|
592 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF | |
593 | > p |
|
593 | > p | |
594 | > y |
|
594 | > y | |
595 | > n |
|
595 | > n | |
596 | > n |
|
596 | > n | |
597 | > m |
|
597 | > m | |
598 | > c |
|
598 | > c | |
599 | > EOF |
|
599 | > EOF | |
600 | 0:17ab29e464c6 |
|
600 | 0:17ab29e464c6 | |
601 | apply changeset? [ynmpcq?]: p |
|
601 | apply changeset? [ynmpcq?]: p | |
|
602 | diff -r 000000000000 -r 17ab29e464c6 r1 | |||
602 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
603 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
603 | +++ b/r1 Thu Jan 01 00:00:00 1970 +0000 |
|
604 | +++ b/r1 Thu Jan 01 00:00:00 1970 +0000 | |
604 | @@ -0,0 +1,1 @@ |
|
605 | @@ -0,0 +1,1 @@ | |
605 | +r1 |
|
606 | +r1 | |
606 | apply changeset? [ynmpcq?]: y |
|
607 | apply changeset? [ynmpcq?]: y | |
607 | 1:d11e3596cc1a |
|
608 | 1:d11e3596cc1a | |
608 | apply changeset? [ynmpcq?]: n |
|
609 | apply changeset? [ynmpcq?]: n | |
609 | 2:37a1297eb21b |
|
610 | 2:37a1297eb21b | |
610 | apply changeset? [ynmpcq?]: n |
|
611 | apply changeset? [ynmpcq?]: n | |
611 | 3:722f4667af76 |
|
612 | 3:722f4667af76 | |
612 | apply changeset? [ynmpcq?]: m |
|
613 | apply changeset? [ynmpcq?]: m | |
613 | 4:a53251cdf717 |
|
614 | 4:a53251cdf717 | |
614 | apply changeset? [ynmpcq?]: c |
|
615 | apply changeset? [ynmpcq?]: c | |
615 | $ hg log -G --template "{node|short}" |
|
616 | $ hg log -G --template "{node|short}" | |
616 | @ 88be5dde5260 |
|
617 | @ 88be5dde5260 | |
617 | |\ |
|
618 | |\ | |
618 | | o 722f4667af76 |
|
619 | | o 722f4667af76 | |
619 | | | |
|
620 | | | | |
620 | | o 37a1297eb21b |
|
621 | | o 37a1297eb21b | |
621 | |/ |
|
622 | |/ | |
622 | o 17ab29e464c6 |
|
623 | o 17ab29e464c6 | |
623 |
|
624 | |||
624 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF |
|
625 | $ hg transplant -q --config ui.interactive=true -s ../t <<EOF | |
625 | > x |
|
626 | > x | |
626 | > ? |
|
627 | > ? | |
627 | > y |
|
628 | > y | |
628 | > q |
|
629 | > q | |
629 | > EOF |
|
630 | > EOF | |
630 | 1:d11e3596cc1a |
|
631 | 1:d11e3596cc1a | |
631 | apply changeset? [ynmpcq?]: x |
|
632 | apply changeset? [ynmpcq?]: x | |
632 | unrecognized response |
|
633 | unrecognized response | |
633 | apply changeset? [ynmpcq?]: ? |
|
634 | apply changeset? [ynmpcq?]: ? | |
634 | y: yes, transplant this changeset |
|
635 | y: yes, transplant this changeset | |
635 | n: no, skip this changeset |
|
636 | n: no, skip this changeset | |
636 | m: merge at this changeset |
|
637 | m: merge at this changeset | |
637 | p: show patch |
|
638 | p: show patch | |
638 | c: commit selected changesets |
|
639 | c: commit selected changesets | |
639 | q: quit and cancel transplant |
|
640 | q: quit and cancel transplant | |
640 | ?: ? (show this help) |
|
641 | ?: ? (show this help) | |
641 | apply changeset? [ynmpcq?]: y |
|
642 | apply changeset? [ynmpcq?]: y | |
642 | 4:a53251cdf717 |
|
643 | 4:a53251cdf717 | |
643 | apply changeset? [ynmpcq?]: q |
|
644 | apply changeset? [ynmpcq?]: q | |
644 | $ hg heads --template "{node|short}\n" |
|
645 | $ hg heads --template "{node|short}\n" | |
645 | 88be5dde5260 |
|
646 | 88be5dde5260 | |
646 |
|
647 | |||
647 | $ cd .. |
|
648 | $ cd .. | |
648 |
|
649 | |||
649 |
|
650 | |||
650 | #if unix-permissions system-sh |
|
651 | #if unix-permissions system-sh | |
651 |
|
652 | |||
652 | test filter |
|
653 | test filter | |
653 |
|
654 | |||
654 | $ hg init filter |
|
655 | $ hg init filter | |
655 | $ cd filter |
|
656 | $ cd filter | |
656 | $ cat <<'EOF' >test-filter |
|
657 | $ cat <<'EOF' >test-filter | |
657 | > #!/bin/sh |
|
658 | > #!/bin/sh | |
658 | > sed 's/r1/r2/' $1 > $1.new |
|
659 | > sed 's/r1/r2/' $1 > $1.new | |
659 | > mv $1.new $1 |
|
660 | > mv $1.new $1 | |
660 | > EOF |
|
661 | > EOF | |
661 | $ chmod +x test-filter |
|
662 | $ chmod +x test-filter | |
662 | $ hg transplant -s ../t -b tip -a --filter ./test-filter |
|
663 | $ hg transplant -s ../t -b tip -a --filter ./test-filter | |
663 | filtering * (glob) |
|
664 | filtering * (glob) | |
664 | applying 17ab29e464c6 |
|
665 | applying 17ab29e464c6 | |
665 | 17ab29e464c6 transplanted to e9ffc54ea104 |
|
666 | 17ab29e464c6 transplanted to e9ffc54ea104 | |
666 | filtering * (glob) |
|
667 | filtering * (glob) | |
667 | applying 37a1297eb21b |
|
668 | applying 37a1297eb21b | |
668 | 37a1297eb21b transplanted to 348b36d0b6a5 |
|
669 | 37a1297eb21b transplanted to 348b36d0b6a5 | |
669 | filtering * (glob) |
|
670 | filtering * (glob) | |
670 | applying 722f4667af76 |
|
671 | applying 722f4667af76 | |
671 | 722f4667af76 transplanted to 0aa6979afb95 |
|
672 | 722f4667af76 transplanted to 0aa6979afb95 | |
672 | filtering * (glob) |
|
673 | filtering * (glob) | |
673 | applying a53251cdf717 |
|
674 | applying a53251cdf717 | |
674 | a53251cdf717 transplanted to 14f8512272b5 |
|
675 | a53251cdf717 transplanted to 14f8512272b5 | |
675 | $ hg log --template '{rev} {parents} {desc}\n' |
|
676 | $ hg log --template '{rev} {parents} {desc}\n' | |
676 | 3 b3 |
|
677 | 3 b3 | |
677 | 2 b2 |
|
678 | 2 b2 | |
678 | 1 b1 |
|
679 | 1 b1 | |
679 | 0 r2 |
|
680 | 0 r2 | |
680 | $ cd .. |
|
681 | $ cd .. | |
681 |
|
682 | |||
682 |
|
683 | |||
683 | test filter with failed patch |
|
684 | test filter with failed patch | |
684 |
|
685 | |||
685 | $ cd filter |
|
686 | $ cd filter | |
686 | $ hg up 0 |
|
687 | $ hg up 0 | |
687 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
688 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
688 | $ echo foo > b1 |
|
689 | $ echo foo > b1 | |
689 | $ hg ci -Am foo |
|
690 | $ hg ci -Am foo | |
690 | adding b1 |
|
691 | adding b1 | |
691 | adding test-filter |
|
692 | adding test-filter | |
692 | created new head |
|
693 | created new head | |
693 | $ hg transplant 1 --filter ./test-filter |
|
694 | $ hg transplant 1 --filter ./test-filter | |
694 | filtering * (glob) |
|
695 | filtering * (glob) | |
695 | applying 348b36d0b6a5 |
|
696 | applying 348b36d0b6a5 | |
696 | file b1 already exists |
|
697 | file b1 already exists | |
697 | 1 out of 1 hunks FAILED -- saving rejects to file b1.rej |
|
698 | 1 out of 1 hunks FAILED -- saving rejects to file b1.rej | |
698 | patch failed to apply |
|
699 | patch failed to apply | |
699 | abort: fix up the working directory and run hg transplant --continue |
|
700 | abort: fix up the working directory and run hg transplant --continue | |
700 | [255] |
|
701 | [255] | |
701 | $ cd .. |
|
702 | $ cd .. | |
702 |
|
703 | |||
703 | test environment passed to filter |
|
704 | test environment passed to filter | |
704 |
|
705 | |||
705 | $ hg init filter-environment |
|
706 | $ hg init filter-environment | |
706 | $ cd filter-environment |
|
707 | $ cd filter-environment | |
707 | $ cat <<'EOF' >test-filter-environment |
|
708 | $ cat <<'EOF' >test-filter-environment | |
708 | > #!/bin/sh |
|
709 | > #!/bin/sh | |
709 | > echo "Transplant by $HGUSER" >> $1 |
|
710 | > echo "Transplant by $HGUSER" >> $1 | |
710 | > echo "Transplant from rev $HGREVISION" >> $1 |
|
711 | > echo "Transplant from rev $HGREVISION" >> $1 | |
711 | > EOF |
|
712 | > EOF | |
712 | $ chmod +x test-filter-environment |
|
713 | $ chmod +x test-filter-environment | |
713 | $ hg transplant -s ../t --filter ./test-filter-environment 0 |
|
714 | $ hg transplant -s ../t --filter ./test-filter-environment 0 | |
714 | filtering * (glob) |
|
715 | filtering * (glob) | |
715 | applying 17ab29e464c6 |
|
716 | applying 17ab29e464c6 | |
716 | 17ab29e464c6 transplanted to 5190e68026a0 |
|
717 | 17ab29e464c6 transplanted to 5190e68026a0 | |
717 |
|
718 | |||
718 | $ hg log --template '{rev} {parents} {desc}\n' |
|
719 | $ hg log --template '{rev} {parents} {desc}\n' | |
719 | 0 r1 |
|
720 | 0 r1 | |
720 | Transplant by test |
|
721 | Transplant by test | |
721 | Transplant from rev 17ab29e464c6ca53e329470efe2a9918ac617a6f |
|
722 | Transplant from rev 17ab29e464c6ca53e329470efe2a9918ac617a6f | |
722 | $ cd .. |
|
723 | $ cd .. | |
723 |
|
724 | |||
724 | test transplant with filter handles invalid changelog |
|
725 | test transplant with filter handles invalid changelog | |
725 |
|
726 | |||
726 | $ hg init filter-invalid-log |
|
727 | $ hg init filter-invalid-log | |
727 | $ cd filter-invalid-log |
|
728 | $ cd filter-invalid-log | |
728 | $ cat <<'EOF' >test-filter-invalid-log |
|
729 | $ cat <<'EOF' >test-filter-invalid-log | |
729 | > #!/bin/sh |
|
730 | > #!/bin/sh | |
730 | > echo "" > $1 |
|
731 | > echo "" > $1 | |
731 | > EOF |
|
732 | > EOF | |
732 | $ chmod +x test-filter-invalid-log |
|
733 | $ chmod +x test-filter-invalid-log | |
733 | $ hg transplant -s ../t --filter ./test-filter-invalid-log 0 |
|
734 | $ hg transplant -s ../t --filter ./test-filter-invalid-log 0 | |
734 | filtering * (glob) |
|
735 | filtering * (glob) | |
735 | abort: filter corrupted changeset (no user or date) |
|
736 | abort: filter corrupted changeset (no user or date) | |
736 | [255] |
|
737 | [255] | |
737 | $ cd .. |
|
738 | $ cd .. | |
738 |
|
739 | |||
739 | #endif |
|
740 | #endif | |
740 |
|
741 | |||
741 |
|
742 | |||
742 | test with a win32ext like setup (differing EOLs) |
|
743 | test with a win32ext like setup (differing EOLs) | |
743 |
|
744 | |||
744 | $ hg init twin1 |
|
745 | $ hg init twin1 | |
745 | $ cd twin1 |
|
746 | $ cd twin1 | |
746 | $ echo a > a |
|
747 | $ echo a > a | |
747 | $ echo b > b |
|
748 | $ echo b > b | |
748 | $ echo b >> b |
|
749 | $ echo b >> b | |
749 | $ hg ci -Am t |
|
750 | $ hg ci -Am t | |
750 | adding a |
|
751 | adding a | |
751 | adding b |
|
752 | adding b | |
752 | $ echo a > b |
|
753 | $ echo a > b | |
753 | $ echo b >> b |
|
754 | $ echo b >> b | |
754 | $ hg ci -m changeb |
|
755 | $ hg ci -m changeb | |
755 | $ cd .. |
|
756 | $ cd .. | |
756 |
|
757 | |||
757 | $ hg init twin2 |
|
758 | $ hg init twin2 | |
758 | $ cd twin2 |
|
759 | $ cd twin2 | |
759 | $ echo '[patch]' >> .hg/hgrc |
|
760 | $ echo '[patch]' >> .hg/hgrc | |
760 | $ echo 'eol = crlf' >> .hg/hgrc |
|
761 | $ echo 'eol = crlf' >> .hg/hgrc | |
761 | $ "$PYTHON" -c "open('b', 'wb').write(b'b\r\nb\r\n')" |
|
762 | $ "$PYTHON" -c "open('b', 'wb').write(b'b\r\nb\r\n')" | |
762 | $ hg ci -Am addb |
|
763 | $ hg ci -Am addb | |
763 | adding b |
|
764 | adding b | |
764 | $ hg transplant -s ../twin1 tip |
|
765 | $ hg transplant -s ../twin1 tip | |
765 | searching for changes |
|
766 | searching for changes | |
766 | warning: repository is unrelated |
|
767 | warning: repository is unrelated | |
767 | applying 2e849d776c17 |
|
768 | applying 2e849d776c17 | |
768 | 2e849d776c17 transplanted to 8e65bebc063e |
|
769 | 2e849d776c17 transplanted to 8e65bebc063e | |
769 | $ cat b |
|
770 | $ cat b | |
770 | a\r (esc) |
|
771 | a\r (esc) | |
771 | b\r (esc) |
|
772 | b\r (esc) | |
772 | $ cd .. |
|
773 | $ cd .. | |
773 |
|
774 | |||
774 | test transplant with merge changeset is skipped |
|
775 | test transplant with merge changeset is skipped | |
775 |
|
776 | |||
776 | $ hg init merge1a |
|
777 | $ hg init merge1a | |
777 | $ cd merge1a |
|
778 | $ cd merge1a | |
778 | $ echo a > a |
|
779 | $ echo a > a | |
779 | $ hg ci -Am a |
|
780 | $ hg ci -Am a | |
780 | adding a |
|
781 | adding a | |
781 | $ hg branch b |
|
782 | $ hg branch b | |
782 | marked working directory as branch b |
|
783 | marked working directory as branch b | |
783 | (branches are permanent and global, did you want a bookmark?) |
|
784 | (branches are permanent and global, did you want a bookmark?) | |
784 | $ hg ci -m branchb |
|
785 | $ hg ci -m branchb | |
785 | $ echo b > b |
|
786 | $ echo b > b | |
786 | $ hg ci -Am b |
|
787 | $ hg ci -Am b | |
787 | adding b |
|
788 | adding b | |
788 | $ hg update default |
|
789 | $ hg update default | |
789 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
790 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
790 | $ hg merge b |
|
791 | $ hg merge b | |
791 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
792 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
792 | (branch merge, don't forget to commit) |
|
793 | (branch merge, don't forget to commit) | |
793 | $ hg ci -m mergeb |
|
794 | $ hg ci -m mergeb | |
794 | $ cd .. |
|
795 | $ cd .. | |
795 |
|
796 | |||
796 | $ hg init merge1b |
|
797 | $ hg init merge1b | |
797 | $ cd merge1b |
|
798 | $ cd merge1b | |
798 | $ hg transplant -s ../merge1a tip |
|
799 | $ hg transplant -s ../merge1a tip | |
799 | $ cd .. |
|
800 | $ cd .. | |
800 |
|
801 | |||
801 | test transplant with merge changeset accepts --parent |
|
802 | test transplant with merge changeset accepts --parent | |
802 |
|
803 | |||
803 | $ hg init merge2a |
|
804 | $ hg init merge2a | |
804 | $ cd merge2a |
|
805 | $ cd merge2a | |
805 | $ echo a > a |
|
806 | $ echo a > a | |
806 | $ hg ci -Am a |
|
807 | $ hg ci -Am a | |
807 | adding a |
|
808 | adding a | |
808 | $ hg branch b |
|
809 | $ hg branch b | |
809 | marked working directory as branch b |
|
810 | marked working directory as branch b | |
810 | (branches are permanent and global, did you want a bookmark?) |
|
811 | (branches are permanent and global, did you want a bookmark?) | |
811 | $ hg ci -m branchb |
|
812 | $ hg ci -m branchb | |
812 | $ echo b > b |
|
813 | $ echo b > b | |
813 | $ hg ci -Am b |
|
814 | $ hg ci -Am b | |
814 | adding b |
|
815 | adding b | |
815 | $ hg update default |
|
816 | $ hg update default | |
816 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
817 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
817 | $ hg merge b |
|
818 | $ hg merge b | |
818 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
819 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
819 | (branch merge, don't forget to commit) |
|
820 | (branch merge, don't forget to commit) | |
820 | $ hg ci -m mergeb |
|
821 | $ hg ci -m mergeb | |
821 | $ cd .. |
|
822 | $ cd .. | |
822 |
|
823 | |||
823 | $ hg init merge2b |
|
824 | $ hg init merge2b | |
824 | $ cd merge2b |
|
825 | $ cd merge2b | |
825 | $ hg transplant -s ../merge2a --parent tip tip |
|
826 | $ hg transplant -s ../merge2a --parent tip tip | |
826 | abort: be9f9b39483f is not a parent of be9f9b39483f |
|
827 | abort: be9f9b39483f is not a parent of be9f9b39483f | |
827 | [255] |
|
828 | [255] | |
828 | $ hg transplant -s ../merge2a --parent 0 tip |
|
829 | $ hg transplant -s ../merge2a --parent 0 tip | |
829 | applying be9f9b39483f |
|
830 | applying be9f9b39483f | |
830 | be9f9b39483f transplanted to 9959e51f94d1 |
|
831 | be9f9b39483f transplanted to 9959e51f94d1 | |
831 | $ cd .. |
|
832 | $ cd .. | |
832 |
|
833 | |||
833 | test transplanting a patch turning into a no-op |
|
834 | test transplanting a patch turning into a no-op | |
834 |
|
835 | |||
835 | $ hg init binarysource |
|
836 | $ hg init binarysource | |
836 | $ cd binarysource |
|
837 | $ cd binarysource | |
837 | $ echo a > a |
|
838 | $ echo a > a | |
838 | $ hg ci -Am adda a |
|
839 | $ hg ci -Am adda a | |
839 | >>> open('b', 'wb').write(b'\0b1') and None |
|
840 | >>> open('b', 'wb').write(b'\0b1') and None | |
840 | $ hg ci -Am addb b |
|
841 | $ hg ci -Am addb b | |
841 | >>> open('b', 'wb').write(b'\0b2') and None |
|
842 | >>> open('b', 'wb').write(b'\0b2') and None | |
842 | $ hg ci -m changeb b |
|
843 | $ hg ci -m changeb b | |
843 | $ cd .. |
|
844 | $ cd .. | |
844 |
|
845 | |||
845 | $ hg clone -r0 binarysource binarydest |
|
846 | $ hg clone -r0 binarysource binarydest | |
846 | adding changesets |
|
847 | adding changesets | |
847 | adding manifests |
|
848 | adding manifests | |
848 | adding file changes |
|
849 | adding file changes | |
849 | added 1 changesets with 1 changes to 1 files |
|
850 | added 1 changesets with 1 changes to 1 files | |
850 | new changesets 07f494440405 |
|
851 | new changesets 07f494440405 | |
851 | updating to branch default |
|
852 | updating to branch default | |
852 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
853 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
853 | $ cd binarydest |
|
854 | $ cd binarydest | |
854 | $ cp ../binarysource/b b |
|
855 | $ cp ../binarysource/b b | |
855 | $ hg ci -Am addb2 b |
|
856 | $ hg ci -Am addb2 b | |
856 | $ hg transplant -s ../binarysource 2 |
|
857 | $ hg transplant -s ../binarysource 2 | |
857 | searching for changes |
|
858 | searching for changes | |
858 | applying 7a7d57e15850 |
|
859 | applying 7a7d57e15850 | |
859 | skipping emptied changeset 7a7d57e15850 |
|
860 | skipping emptied changeset 7a7d57e15850 | |
860 |
|
861 | |||
861 | Test empty result in --continue |
|
862 | Test empty result in --continue | |
862 |
|
863 | |||
863 | $ hg transplant -s ../binarysource 1 |
|
864 | $ hg transplant -s ../binarysource 1 | |
864 | searching for changes |
|
865 | searching for changes | |
865 | applying 645035761929 |
|
866 | applying 645035761929 | |
866 | file b already exists |
|
867 | file b already exists | |
867 | 1 out of 1 hunks FAILED -- saving rejects to file b.rej |
|
868 | 1 out of 1 hunks FAILED -- saving rejects to file b.rej | |
868 | patch failed to apply |
|
869 | patch failed to apply | |
869 | abort: fix up the working directory and run hg transplant --continue |
|
870 | abort: fix up the working directory and run hg transplant --continue | |
870 | [255] |
|
871 | [255] | |
871 | $ hg status |
|
872 | $ hg status | |
872 | ? b.rej |
|
873 | ? b.rej | |
873 | $ hg transplant --continue |
|
874 | $ hg transplant --continue | |
874 | 645035761929 skipped due to empty diff |
|
875 | 645035761929 skipped due to empty diff | |
875 |
|
876 | |||
876 | $ cd .. |
|
877 | $ cd .. | |
877 |
|
878 | |||
878 | Explicitly kill daemons to let the test exit on Windows |
|
879 | Explicitly kill daemons to let the test exit on Windows | |
879 |
|
880 | |||
880 | $ killdaemons.py |
|
881 | $ killdaemons.py | |
881 |
|
882 | |||
882 | Test that patch-ed files are treated as "modified", when transplant is |
|
883 | Test that patch-ed files are treated as "modified", when transplant is | |
883 | aborted by failure of patching, even if none of mode, size and |
|
884 | aborted by failure of patching, even if none of mode, size and | |
884 | timestamp of them isn't changed on the filesystem (see also issue4583) |
|
885 | timestamp of them isn't changed on the filesystem (see also issue4583) | |
885 |
|
886 | |||
886 | $ cd t |
|
887 | $ cd t | |
887 |
|
888 | |||
888 | $ cat > $TESTTMP/abort.py <<EOF |
|
889 | $ cat > $TESTTMP/abort.py <<EOF | |
889 | > # emulate that patch.patch() is aborted at patching on "abort" file |
|
890 | > # emulate that patch.patch() is aborted at patching on "abort" file | |
890 | > from mercurial import error, extensions, patch as patchmod |
|
891 | > from mercurial import error, extensions, patch as patchmod | |
891 | > def patch(orig, ui, repo, patchname, |
|
892 | > def patch(orig, ui, repo, patchname, | |
892 | > strip=1, prefix=b'', files=None, |
|
893 | > strip=1, prefix=b'', files=None, | |
893 | > eolmode=b'strict', similarity=0): |
|
894 | > eolmode=b'strict', similarity=0): | |
894 | > if files is None: |
|
895 | > if files is None: | |
895 | > files = set() |
|
896 | > files = set() | |
896 | > r = orig(ui, repo, patchname, |
|
897 | > r = orig(ui, repo, patchname, | |
897 | > strip=strip, prefix=prefix, files=files, |
|
898 | > strip=strip, prefix=prefix, files=files, | |
898 | > eolmode=eolmode, similarity=similarity) |
|
899 | > eolmode=eolmode, similarity=similarity) | |
899 | > if b'abort' in files: |
|
900 | > if b'abort' in files: | |
900 | > raise error.PatchError('intentional error while patching') |
|
901 | > raise error.PatchError('intentional error while patching') | |
901 | > return r |
|
902 | > return r | |
902 | > def extsetup(ui): |
|
903 | > def extsetup(ui): | |
903 | > extensions.wrapfunction(patchmod, 'patch', patch) |
|
904 | > extensions.wrapfunction(patchmod, 'patch', patch) | |
904 | > EOF |
|
905 | > EOF | |
905 |
|
906 | |||
906 | $ echo X1 > r1 |
|
907 | $ echo X1 > r1 | |
907 | $ hg diff --nodates r1 |
|
908 | $ hg diff --nodates r1 | |
908 | diff -r a53251cdf717 r1 |
|
909 | diff -r a53251cdf717 r1 | |
909 | --- a/r1 |
|
910 | --- a/r1 | |
910 | +++ b/r1 |
|
911 | +++ b/r1 | |
911 | @@ -1,1 +1,1 @@ |
|
912 | @@ -1,1 +1,1 @@ | |
912 | -r1 |
|
913 | -r1 | |
913 | +X1 |
|
914 | +X1 | |
914 | $ hg commit -m "X1 as r1" |
|
915 | $ hg commit -m "X1 as r1" | |
915 |
|
916 | |||
916 | $ echo 'marking to abort patching' > abort |
|
917 | $ echo 'marking to abort patching' > abort | |
917 | $ hg add abort |
|
918 | $ hg add abort | |
918 | $ echo Y1 > r1 |
|
919 | $ echo Y1 > r1 | |
919 | $ hg diff --nodates r1 |
|
920 | $ hg diff --nodates r1 | |
920 | diff -r 22c515968f13 r1 |
|
921 | diff -r 22c515968f13 r1 | |
921 | --- a/r1 |
|
922 | --- a/r1 | |
922 | +++ b/r1 |
|
923 | +++ b/r1 | |
923 | @@ -1,1 +1,1 @@ |
|
924 | @@ -1,1 +1,1 @@ | |
924 | -X1 |
|
925 | -X1 | |
925 | +Y1 |
|
926 | +Y1 | |
926 | $ hg commit -m "Y1 as r1" |
|
927 | $ hg commit -m "Y1 as r1" | |
927 |
|
928 | |||
928 | $ hg update -q -C d11e3596cc1a |
|
929 | $ hg update -q -C d11e3596cc1a | |
929 | $ cat r1 |
|
930 | $ cat r1 | |
930 | r1 |
|
931 | r1 | |
931 |
|
932 | |||
932 | $ cat >> .hg/hgrc <<EOF |
|
933 | $ cat >> .hg/hgrc <<EOF | |
933 | > [fakedirstatewritetime] |
|
934 | > [fakedirstatewritetime] | |
934 | > # emulate invoking dirstate.write() via repo.status() or markcommitted() |
|
935 | > # emulate invoking dirstate.write() via repo.status() or markcommitted() | |
935 | > # at 2000-01-01 00:00 |
|
936 | > # at 2000-01-01 00:00 | |
936 | > fakenow = 200001010000 |
|
937 | > fakenow = 200001010000 | |
937 | > |
|
938 | > | |
938 | > # emulate invoking patch.internalpatch() at 2000-01-01 00:00 |
|
939 | > # emulate invoking patch.internalpatch() at 2000-01-01 00:00 | |
939 | > [fakepatchtime] |
|
940 | > [fakepatchtime] | |
940 | > fakenow = 200001010000 |
|
941 | > fakenow = 200001010000 | |
941 | > |
|
942 | > | |
942 | > [extensions] |
|
943 | > [extensions] | |
943 | > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py |
|
944 | > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py | |
944 | > fakepatchtime = $TESTDIR/fakepatchtime.py |
|
945 | > fakepatchtime = $TESTDIR/fakepatchtime.py | |
945 | > abort = $TESTTMP/abort.py |
|
946 | > abort = $TESTTMP/abort.py | |
946 | > EOF |
|
947 | > EOF | |
947 | $ hg transplant "22c515968f13::" |
|
948 | $ hg transplant "22c515968f13::" | |
948 | applying 22c515968f13 |
|
949 | applying 22c515968f13 | |
949 | 22c515968f13 transplanted to * (glob) |
|
950 | 22c515968f13 transplanted to * (glob) | |
950 | applying e38700ba9dd3 |
|
951 | applying e38700ba9dd3 | |
951 | intentional error while patching |
|
952 | intentional error while patching | |
952 | abort: fix up the working directory and run hg transplant --continue |
|
953 | abort: fix up the working directory and run hg transplant --continue | |
953 | [255] |
|
954 | [255] | |
954 | $ cat >> .hg/hgrc <<EOF |
|
955 | $ cat >> .hg/hgrc <<EOF | |
955 | > [hooks] |
|
956 | > [hooks] | |
956 | > fakedirstatewritetime = ! |
|
957 | > fakedirstatewritetime = ! | |
957 | > fakepatchtime = ! |
|
958 | > fakepatchtime = ! | |
958 | > [extensions] |
|
959 | > [extensions] | |
959 | > abort = ! |
|
960 | > abort = ! | |
960 | > EOF |
|
961 | > EOF | |
961 |
|
962 | |||
962 | $ cat r1 |
|
963 | $ cat r1 | |
963 | Y1 |
|
964 | Y1 | |
964 | $ hg debugstate | grep ' r1$' |
|
965 | $ hg debugstate | grep ' r1$' | |
965 | n 644 3 unset r1 |
|
966 | n 644 3 unset r1 | |
966 | $ hg status -A r1 |
|
967 | $ hg status -A r1 | |
967 | M r1 |
|
968 | M r1 | |
968 |
|
969 | |||
969 | Test that rollback by unexpected failure after transplanting the first |
|
970 | Test that rollback by unexpected failure after transplanting the first | |
970 | revision restores dirstate correctly. |
|
971 | revision restores dirstate correctly. | |
971 |
|
972 | |||
972 | $ hg rollback -q |
|
973 | $ hg rollback -q | |
973 | $ rm -f abort |
|
974 | $ rm -f abort | |
974 | $ hg update -q -C d11e3596cc1a |
|
975 | $ hg update -q -C d11e3596cc1a | |
975 | $ hg parents -T "{node|short}\n" |
|
976 | $ hg parents -T "{node|short}\n" | |
976 | d11e3596cc1a |
|
977 | d11e3596cc1a | |
977 | $ hg status -A |
|
978 | $ hg status -A | |
978 | C r1 |
|
979 | C r1 | |
979 | C r2 |
|
980 | C r2 | |
980 |
|
981 | |||
981 | $ cat >> .hg/hgrc <<EOF |
|
982 | $ cat >> .hg/hgrc <<EOF | |
982 | > [hooks] |
|
983 | > [hooks] | |
983 | > # emulate failure at transplanting the 2nd revision |
|
984 | > # emulate failure at transplanting the 2nd revision | |
984 | > pretxncommit.abort = test ! -f abort |
|
985 | > pretxncommit.abort = test ! -f abort | |
985 | > EOF |
|
986 | > EOF | |
986 | $ hg transplant "22c515968f13::" |
|
987 | $ hg transplant "22c515968f13::" | |
987 | applying 22c515968f13 |
|
988 | applying 22c515968f13 | |
988 | 22c515968f13 transplanted to * (glob) |
|
989 | 22c515968f13 transplanted to * (glob) | |
989 | applying e38700ba9dd3 |
|
990 | applying e38700ba9dd3 | |
990 | transaction abort! |
|
991 | transaction abort! | |
991 | rollback completed |
|
992 | rollback completed | |
992 | abort: pretxncommit.abort hook exited with status 1 |
|
993 | abort: pretxncommit.abort hook exited with status 1 | |
993 | [255] |
|
994 | [255] | |
994 | $ cat >> .hg/hgrc <<EOF |
|
995 | $ cat >> .hg/hgrc <<EOF | |
995 | > [hooks] |
|
996 | > [hooks] | |
996 | > pretxncommit.abort = ! |
|
997 | > pretxncommit.abort = ! | |
997 | > EOF |
|
998 | > EOF | |
998 |
|
999 | |||
999 | $ hg parents -T "{node|short}\n" |
|
1000 | $ hg parents -T "{node|short}\n" | |
1000 | d11e3596cc1a |
|
1001 | d11e3596cc1a | |
1001 | $ hg status -A |
|
1002 | $ hg status -A | |
1002 | M r1 |
|
1003 | M r1 | |
1003 | ? abort |
|
1004 | ? abort | |
1004 | C r2 |
|
1005 | C r2 | |
1005 |
|
1006 | |||
1006 | $ cd .. |
|
1007 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now