diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -507,7 +507,7 @@ class queue(object): files = {} try: fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root, - files=files) + files=files, eolmode=None) except Exception, inst: self.ui.note(str(inst) + '\n') if not self.ui.verbose: diff --git a/hgext/record.py b/hgext/record.py --- a/hgext/record.py +++ b/hgext/record.py @@ -481,7 +481,8 @@ def dorecord(ui, repo, committer, *pats, ui.debug(_('applying patch\n')) ui.debug(fp.getvalue()) 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) except patch.PatchError, err: s = str(err) diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -218,7 +218,7 @@ class transplanter(object): files = {} try: patch.patch(patchfile, self.ui, cwd=repo.root, - files=files) + files=files, eolmode=None) if not files: self.ui.warn(_('%s: empty changeset') % revlog.hex(node)) diff --git a/tests/test-mq-eol b/tests/test-mq-eol new file mode 100755 --- /dev/null +++ b/tests/test-mq-eol @@ -0,0 +1,64 @@ +#!/bin/sh + +# Test interactions between mq and patch.eol + +echo "[extensions]" >> $HGRCPATH +echo "mq=" >> $HGRCPATH + +cat > makepatch.py < cateol.py <') + line = line.replace('\n', '') + 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 diff --git a/tests/test-mq-eol.out b/tests/test-mq-eol.out new file mode 100644 --- /dev/null +++ b/tests/test-mq-eol.out @@ -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 + +diff --git a/a b/a +--- a/a ++++ b/a +@@ -1,5 +1,5 @@ +-a +-b +-c +-d +-e +\ No newline at end of file ++a ++y ++c ++d ++z +\ No newline at end of file +a +y +c +d +z +patch queue now empty +% push again forcing LF and compare revisions +applying eol.diff +now at: eol.diff +a +y +c +d +z +patch queue now empty +% push again without LF and compare revisions +applying eol.diff +now at: eol.diff +a +y +c +d +z +patch queue now empty diff --git a/tests/test-record b/tests/test-record --- a/tests/test-record +++ b/tests/test-record @@ -296,3 +296,23 @@ y y EOF 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 < 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 .. \ No newline at end of file diff --git a/tests/test-transplant.out b/tests/test-transplant.out --- a/tests/test-transplant.out +++ b/tests/test-transplant.out @@ -159,3 +159,10 @@ 3 b3 2 b2 1 b1 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'