##// END OF EJS Templates
Make mq, record and transplant honor patch.eol
Patrick Mezard -
r8811:8b35b087 default
parent child Browse files
Show More
@@ -0,0 +1,64 b''
1 #!/bin/sh
2
3 # Test interactions between mq and patch.eol
4
5 echo "[extensions]" >> $HGRCPATH
6 echo "mq=" >> $HGRCPATH
7
8 cat > makepatch.py <<EOF
9 f = file('eol.diff', 'wb')
10 w = f.write
11 w('test message\n')
12 w('diff --git a/a b/a\n')
13 w('--- a/a\n')
14 w('+++ b/a\n')
15 w('@@ -1,5 +1,5 @@\n')
16 w(' a\n')
17 w('-b\r\n')
18 w('+y\r\n')
19 w(' c\r\n')
20 w(' d\n')
21 w('-e\n')
22 w('\ No newline at end of file\n')
23 w('+z\r\n')
24 w('\ No newline at end of file\r\n')
25 EOF
26
27 cat > cateol.py <<EOF
28 import sys
29 for line in file(sys.argv[1], 'rb'):
30 line = line.replace('\r', '<CR>')
31 line = line.replace('\n', '<LF>')
32 print line
33 EOF
34
35 hg init repo
36 cd repo
37 echo '\.diff' > .hgignore
38 echo '\.rej' >> .hgignore
39
40 # Test different --eol values
41 python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
42 hg ci -Am adda
43 python ../makepatch.py
44 hg qimport eol.diff
45 echo % should fail in strict mode
46 hg qpush
47 hg qpop
48 echo % invalid eol
49 hg --config patch.eol='LFCR' qpush
50 hg qpop
51 echo % force LF
52 hg --config patch.eol='CRLF' qpush
53 hg qrefresh
54 python ../cateol.py .hg/patches/eol.diff
55 python ../cateol.py a
56 hg qpop
57 echo % push again forcing LF and compare revisions
58 hg --config patch.eol='CRLF' qpush
59 python ../cateol.py a
60 hg qpop
61 echo % push again without LF and compare revisions
62 hg qpush
63 python ../cateol.py a
64 hg qpop
@@ -0,0 +1,63 b''
1 adding .hgignore
2 adding a
3 adding eol.diff to series file
4 % should fail in strict mode
5 applying eol.diff
6 patching file a
7 Hunk #1 FAILED at 0
8 1 out of 1 hunks FAILED -- saving rejects to file a.rej
9 patch failed, unable to continue (try -v)
10 patch failed, rejects left in working dir
11 errors during apply, please fix and refresh eol.diff
12 patch queue now empty
13 % invalid eol
14 applying eol.diff
15 patch failed, unable to continue (try -v)
16 patch failed, rejects left in working dir
17 errors during apply, please fix and refresh eol.diff
18 patch queue now empty
19 % force LF
20 applying eol.diff
21 now at: eol.diff
22 test message<LF>
23 <LF>
24 diff --git a/a b/a<LF>
25 --- a/a<LF>
26 +++ b/a<LF>
27 @@ -1,5 +1,5 @@<LF>
28 -a<LF>
29 -b<LF>
30 -c<LF>
31 -d<LF>
32 -e<LF>
33 \ No newline at end of file<LF>
34 +a<CR><LF>
35 +y<CR><LF>
36 +c<CR><LF>
37 +d<CR><LF>
38 +z<LF>
39 \ No newline at end of file<LF>
40 a<CR><LF>
41 y<CR><LF>
42 c<CR><LF>
43 d<CR><LF>
44 z
45 patch queue now empty
46 % push again forcing LF and compare revisions
47 applying eol.diff
48 now at: eol.diff
49 a<CR><LF>
50 y<CR><LF>
51 c<CR><LF>
52 d<CR><LF>
53 z
54 patch queue now empty
55 % push again without LF and compare revisions
56 applying eol.diff
57 now at: eol.diff
58 a<CR><LF>
59 y<CR><LF>
60 c<CR><LF>
61 d<CR><LF>
62 z
63 patch queue now empty
@@ -507,7 +507,7 b' class queue(object):'
507 files = {}
507 files = {}
508 try:
508 try:
509 fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root,
509 fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root,
510 files=files)
510 files=files, eolmode=None)
511 except Exception, inst:
511 except Exception, inst:
512 self.ui.note(str(inst) + '\n')
512 self.ui.note(str(inst) + '\n')
513 if not self.ui.verbose:
513 if not self.ui.verbose:
@@ -481,7 +481,8 b' def dorecord(ui, repo, committer, *pats,'
481 ui.debug(_('applying patch\n'))
481 ui.debug(_('applying patch\n'))
482 ui.debug(fp.getvalue())
482 ui.debug(fp.getvalue())
483 pfiles = {}
483 pfiles = {}
484 patch.internalpatch(fp, ui, 1, repo.root, files=pfiles)
484 patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,
485 eolmode=None)
485 patch.updatedir(ui, repo, pfiles)
486 patch.updatedir(ui, repo, pfiles)
486 except patch.PatchError, err:
487 except patch.PatchError, err:
487 s = str(err)
488 s = str(err)
@@ -218,7 +218,7 b' class transplanter(object):'
218 files = {}
218 files = {}
219 try:
219 try:
220 patch.patch(patchfile, self.ui, cwd=repo.root,
220 patch.patch(patchfile, self.ui, cwd=repo.root,
221 files=files)
221 files=files, eolmode=None)
222 if not files:
222 if not files:
223 self.ui.warn(_('%s: empty changeset')
223 self.ui.warn(_('%s: empty changeset')
224 % revlog.hex(node))
224 % revlog.hex(node))
@@ -296,3 +296,23 b' y'
296 y
296 y
297 EOF
297 EOF
298 echo; hg tip --config diff.git=True -p
298 echo; hg tip --config diff.git=True -p
299
300
301 echo % with win32ext
302 cd ..
303 echo '[extensions]' >> .hg/hgrc
304 echo 'win32text = ' >> .hg/hgrc
305 echo '[decode]' >> .hg/hgrc
306 echo '** = cleverdecode:' >> .hg/hgrc
307 echo '[encode]' >> .hg/hgrc
308 echo '** = cleverencode:' >> .hg/hgrc
309 echo '[patch]' >> .hg/hgrc
310 echo 'eol = crlf' >> .hg/hgrc
311
312 echo d >> subdir/f1
313 hg record -d '23 0' -mw1 <<EOF
314 y
315 y
316 EOF
317 echo; hg tip -p
318
@@ -572,3 +572,27 b' new mode 100644'
572 b
572 b
573 +c
573 +c
574
574
575 % with win32ext
576 diff --git a/subdir/f1 b/subdir/f1
577 1 hunks, 1 lines changed
578 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -3,3 +3,4 @@
579 a
580 b
581 c
582 +d
583 record this change to 'subdir/f1'? [Ynsfdaq?]
584 changeset: 25:49b3838dc9e7
585 tag: tip
586 user: test
587 date: Thu Jan 01 00:00:23 1970 +0000
588 summary: w1
589
590 diff -r 8fd83ff53ce6 -r 49b3838dc9e7 subdir/f1
591 --- a/subdir/f1 Thu Jan 01 00:00:22 1970 +0000
592 +++ b/subdir/f1 Thu Jan 01 00:00:23 1970 +0000
593 @@ -3,3 +3,4 @@
594 a
595 b
596 c
597 +d
598
@@ -134,3 +134,26 b' chmod +x test-filter'
134 hg transplant -s ../t -b tip -a --filter ./test-filter |\
134 hg transplant -s ../t -b tip -a --filter ./test-filter |\
135 sed 's/filtering.*/filtering/g'
135 sed 's/filtering.*/filtering/g'
136 hg log --template '{rev} {parents} {desc}\n'
136 hg log --template '{rev} {parents} {desc}\n'
137 cd ..
138
139 echo '% test with a win32ext like setup (differing EOLs)'
140 hg init twin1
141 cd twin1
142 echo a > a
143 echo b > b
144 echo b >> b
145 hg ci -Am t
146 echo a > b
147 echo b >> b
148 hg ci -m changeb
149 cd ..
150
151 hg init twin2
152 cd twin2
153 echo '[patch]' >> .hg/hgrc
154 echo 'eol = crlf' >> .hg/hgrc
155 python -c "file('b', 'wb').write('b\r\nb\r\n')"
156 hg ci -m addb
157 hg transplant -s ../twin1 tip
158 python -c "print repr(file('b', 'rb').read())"
159 cd .. No newline at end of file
@@ -159,3 +159,10 b' 3 b3'
159 2 b2
159 2 b2
160 1 b1
160 1 b1
161 0 r2
161 0 r2
162 % test with a win32ext like setup (differing EOLs)
163 adding a
164 adding b
165 nothing changed
166 applying 2e849d776c17
167 2e849d776c17 transplanted to 589cea8ba85b
168 'a\r\nb\r\n'
General Comments 0
You need to be logged in to leave comments. Login now