mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
Make mq, record and transplant honor patch.eol
This commit is contained in:
parent
c1548a6a3e
commit
7039de96dc
@ -507,7 +507,7 @@ class queue(object):
|
|||||||
files = {}
|
files = {}
|
||||||
try:
|
try:
|
||||||
fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root,
|
fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root,
|
||||||
files=files)
|
files=files, eolmode=None)
|
||||||
except Exception, inst:
|
except Exception, inst:
|
||||||
self.ui.note(str(inst) + '\n')
|
self.ui.note(str(inst) + '\n')
|
||||||
if not self.ui.verbose:
|
if not self.ui.verbose:
|
||||||
|
@ -481,7 +481,8 @@ def dorecord(ui, repo, committer, *pats, **opts):
|
|||||||
ui.debug(_('applying patch\n'))
|
ui.debug(_('applying patch\n'))
|
||||||
ui.debug(fp.getvalue())
|
ui.debug(fp.getvalue())
|
||||||
pfiles = {}
|
pfiles = {}
|
||||||
patch.internalpatch(fp, ui, 1, repo.root, files=pfiles)
|
patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,
|
||||||
|
eolmode=None)
|
||||||
patch.updatedir(ui, repo, pfiles)
|
patch.updatedir(ui, repo, pfiles)
|
||||||
except patch.PatchError, err:
|
except patch.PatchError, err:
|
||||||
s = str(err)
|
s = str(err)
|
||||||
|
@ -218,7 +218,7 @@ class transplanter(object):
|
|||||||
files = {}
|
files = {}
|
||||||
try:
|
try:
|
||||||
patch.patch(patchfile, self.ui, cwd=repo.root,
|
patch.patch(patchfile, self.ui, cwd=repo.root,
|
||||||
files=files)
|
files=files, eolmode=None)
|
||||||
if not files:
|
if not files:
|
||||||
self.ui.warn(_('%s: empty changeset')
|
self.ui.warn(_('%s: empty changeset')
|
||||||
% revlog.hex(node))
|
% revlog.hex(node))
|
||||||
|
64
tests/test-mq-eol
Executable file
64
tests/test-mq-eol
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Test interactions between mq and patch.eol
|
||||||
|
|
||||||
|
echo "[extensions]" >> $HGRCPATH
|
||||||
|
echo "mq=" >> $HGRCPATH
|
||||||
|
|
||||||
|
cat > makepatch.py <<EOF
|
||||||
|
f = file('eol.diff', 'wb')
|
||||||
|
w = f.write
|
||||||
|
w('test message\n')
|
||||||
|
w('diff --git a/a b/a\n')
|
||||||
|
w('--- a/a\n')
|
||||||
|
w('+++ b/a\n')
|
||||||
|
w('@@ -1,5 +1,5 @@\n')
|
||||||
|
w(' a\n')
|
||||||
|
w('-b\r\n')
|
||||||
|
w('+y\r\n')
|
||||||
|
w(' c\r\n')
|
||||||
|
w(' d\n')
|
||||||
|
w('-e\n')
|
||||||
|
w('\ No newline at end of file\n')
|
||||||
|
w('+z\r\n')
|
||||||
|
w('\ No newline at end of file\r\n')
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > cateol.py <<EOF
|
||||||
|
import sys
|
||||||
|
for line in file(sys.argv[1], 'rb'):
|
||||||
|
line = line.replace('\r', '<CR>')
|
||||||
|
line = line.replace('\n', '<LF>')
|
||||||
|
print line
|
||||||
|
EOF
|
||||||
|
|
||||||
|
hg init repo
|
||||||
|
cd repo
|
||||||
|
echo '\.diff' > .hgignore
|
||||||
|
echo '\.rej' >> .hgignore
|
||||||
|
|
||||||
|
# Test different --eol values
|
||||||
|
python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
|
||||||
|
hg ci -Am adda
|
||||||
|
python ../makepatch.py
|
||||||
|
hg qimport eol.diff
|
||||||
|
echo % should fail in strict mode
|
||||||
|
hg qpush
|
||||||
|
hg qpop
|
||||||
|
echo % invalid eol
|
||||||
|
hg --config patch.eol='LFCR' qpush
|
||||||
|
hg qpop
|
||||||
|
echo % force LF
|
||||||
|
hg --config patch.eol='CRLF' qpush
|
||||||
|
hg qrefresh
|
||||||
|
python ../cateol.py .hg/patches/eol.diff
|
||||||
|
python ../cateol.py a
|
||||||
|
hg qpop
|
||||||
|
echo % push again forcing LF and compare revisions
|
||||||
|
hg --config patch.eol='CRLF' qpush
|
||||||
|
python ../cateol.py a
|
||||||
|
hg qpop
|
||||||
|
echo % push again without LF and compare revisions
|
||||||
|
hg qpush
|
||||||
|
python ../cateol.py a
|
||||||
|
hg qpop
|
63
tests/test-mq-eol.out
Normal file
63
tests/test-mq-eol.out
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
adding .hgignore
|
||||||
|
adding a
|
||||||
|
adding eol.diff to series file
|
||||||
|
% should fail in strict mode
|
||||||
|
applying eol.diff
|
||||||
|
patching file a
|
||||||
|
Hunk #1 FAILED at 0
|
||||||
|
1 out of 1 hunks FAILED -- saving rejects to file a.rej
|
||||||
|
patch failed, unable to continue (try -v)
|
||||||
|
patch failed, rejects left in working dir
|
||||||
|
errors during apply, please fix and refresh eol.diff
|
||||||
|
patch queue now empty
|
||||||
|
% invalid eol
|
||||||
|
applying eol.diff
|
||||||
|
patch failed, unable to continue (try -v)
|
||||||
|
patch failed, rejects left in working dir
|
||||||
|
errors during apply, please fix and refresh eol.diff
|
||||||
|
patch queue now empty
|
||||||
|
% force LF
|
||||||
|
applying eol.diff
|
||||||
|
now at: eol.diff
|
||||||
|
test message<LF>
|
||||||
|
<LF>
|
||||||
|
diff --git a/a b/a<LF>
|
||||||
|
--- a/a<LF>
|
||||||
|
+++ b/a<LF>
|
||||||
|
@@ -1,5 +1,5 @@<LF>
|
||||||
|
-a<LF>
|
||||||
|
-b<LF>
|
||||||
|
-c<LF>
|
||||||
|
-d<LF>
|
||||||
|
-e<LF>
|
||||||
|
\ No newline at end of file<LF>
|
||||||
|
+a<CR><LF>
|
||||||
|
+y<CR><LF>
|
||||||
|
+c<CR><LF>
|
||||||
|
+d<CR><LF>
|
||||||
|
+z<LF>
|
||||||
|
\ No newline at end of file<LF>
|
||||||
|
a<CR><LF>
|
||||||
|
y<CR><LF>
|
||||||
|
c<CR><LF>
|
||||||
|
d<CR><LF>
|
||||||
|
z
|
||||||
|
patch queue now empty
|
||||||
|
% push again forcing LF and compare revisions
|
||||||
|
applying eol.diff
|
||||||
|
now at: eol.diff
|
||||||
|
a<CR><LF>
|
||||||
|
y<CR><LF>
|
||||||
|
c<CR><LF>
|
||||||
|
d<CR><LF>
|
||||||
|
z
|
||||||
|
patch queue now empty
|
||||||
|
% push again without LF and compare revisions
|
||||||
|
applying eol.diff
|
||||||
|
now at: eol.diff
|
||||||
|
a<CR><LF>
|
||||||
|
y<CR><LF>
|
||||||
|
c<CR><LF>
|
||||||
|
d<CR><LF>
|
||||||
|
z
|
||||||
|
patch queue now empty
|
@ -296,3 +296,23 @@ y
|
|||||||
y
|
y
|
||||||
EOF
|
EOF
|
||||||
echo; hg tip --config diff.git=True -p
|
echo; hg tip --config diff.git=True -p
|
||||||
|
|
||||||
|
|
||||||
|
echo % with win32ext
|
||||||
|
cd ..
|
||||||
|
echo '[extensions]' >> .hg/hgrc
|
||||||
|
echo 'win32text = ' >> .hg/hgrc
|
||||||
|
echo '[decode]' >> .hg/hgrc
|
||||||
|
echo '** = cleverdecode:' >> .hg/hgrc
|
||||||
|
echo '[encode]' >> .hg/hgrc
|
||||||
|
echo '** = cleverencode:' >> .hg/hgrc
|
||||||
|
echo '[patch]' >> .hg/hgrc
|
||||||
|
echo 'eol = crlf' >> .hg/hgrc
|
||||||
|
|
||||||
|
echo d >> subdir/f1
|
||||||
|
hg record -d '23 0' -mw1 <<EOF
|
||||||
|
y
|
||||||
|
y
|
||||||
|
EOF
|
||||||
|
echo; hg tip -p
|
||||||
|
|
||||||
|
@ -572,3 +572,27 @@ new mode 100644
|
|||||||
b
|
b
|
||||||
+c
|
+c
|
||||||
|
|
||||||
|
% with win32ext
|
||||||
|
diff --git a/subdir/f1 b/subdir/f1
|
||||||
|
1 hunks, 1 lines changed
|
||||||
|
examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -3,3 +3,4 @@
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
+d
|
||||||
|
record this change to 'subdir/f1'? [Ynsfdaq?]
|
||||||
|
changeset: 25:49b3838dc9e7
|
||||||
|
tag: tip
|
||||||
|
user: test
|
||||||
|
date: Thu Jan 01 00:00:23 1970 +0000
|
||||||
|
summary: w1
|
||||||
|
|
||||||
|
diff -r 8fd83ff53ce6 -r 49b3838dc9e7 subdir/f1
|
||||||
|
--- a/subdir/f1 Thu Jan 01 00:00:22 1970 +0000
|
||||||
|
+++ b/subdir/f1 Thu Jan 01 00:00:23 1970 +0000
|
||||||
|
@@ -3,3 +3,4 @@
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
+d
|
||||||
|
|
||||||
|
@ -134,3 +134,26 @@ chmod +x test-filter
|
|||||||
hg transplant -s ../t -b tip -a --filter ./test-filter |\
|
hg transplant -s ../t -b tip -a --filter ./test-filter |\
|
||||||
sed 's/filtering.*/filtering/g'
|
sed 's/filtering.*/filtering/g'
|
||||||
hg log --template '{rev} {parents} {desc}\n'
|
hg log --template '{rev} {parents} {desc}\n'
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo '% test with a win32ext like setup (differing EOLs)'
|
||||||
|
hg init twin1
|
||||||
|
cd twin1
|
||||||
|
echo a > a
|
||||||
|
echo b > b
|
||||||
|
echo b >> b
|
||||||
|
hg ci -Am t
|
||||||
|
echo a > b
|
||||||
|
echo b >> b
|
||||||
|
hg ci -m changeb
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
hg init twin2
|
||||||
|
cd twin2
|
||||||
|
echo '[patch]' >> .hg/hgrc
|
||||||
|
echo 'eol = crlf' >> .hg/hgrc
|
||||||
|
python -c "file('b', 'wb').write('b\r\nb\r\n')"
|
||||||
|
hg ci -m addb
|
||||||
|
hg transplant -s ../twin1 tip
|
||||||
|
python -c "print repr(file('b', 'rb').read())"
|
||||||
|
cd ..
|
@ -159,3 +159,10 @@ a53251cdf717 transplanted to 14f8512272b5
|
|||||||
2 b2
|
2 b2
|
||||||
1 b1
|
1 b1
|
||||||
0 r2
|
0 r2
|
||||||
|
% test with a win32ext like setup (differing EOLs)
|
||||||
|
adding a
|
||||||
|
adding b
|
||||||
|
nothing changed
|
||||||
|
applying 2e849d776c17
|
||||||
|
2e849d776c17 transplanted to 589cea8ba85b
|
||||||
|
'a\r\nb\r\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user