Mercurial > hg
changeset 8811:8b35b08724eb
Make mq, record and transplant honor patch.eol
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 15 Jun 2009 00:03:27 +0200 |
parents | ac92775b3b80 |
children | 859f841937d0 |
files | hgext/mq.py hgext/record.py hgext/transplant.py tests/test-mq-eol tests/test-mq-eol.out tests/test-record tests/test-record.out tests/test-transplant tests/test-transplant.out |
diffstat | 9 files changed, 205 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Mon Jun 15 00:03:26 2009 +0200 +++ b/hgext/mq.py Mon Jun 15 00:03:27 2009 +0200 @@ -507,7 +507,7 @@ 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:
--- a/hgext/record.py Mon Jun 15 00:03:26 2009 +0200 +++ b/hgext/record.py Mon Jun 15 00:03:27 2009 +0200 @@ -481,7 +481,8 @@ 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)
--- a/hgext/transplant.py Mon Jun 15 00:03:26 2009 +0200 +++ b/hgext/transplant.py Mon Jun 15 00:03:27 2009 +0200 @@ -218,7 +218,7 @@ 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))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-eol Mon Jun 15 00:03:27 2009 +0200 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-eol.out Mon Jun 15 00:03:27 2009 +0200 @@ -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
--- a/tests/test-record Mon Jun 15 00:03:26 2009 +0200 +++ b/tests/test-record Mon Jun 15 00:03:27 2009 +0200 @@ -296,3 +296,23 @@ 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 <<EOF +y +y +EOF +echo; hg tip -p +
--- a/tests/test-record.out Mon Jun 15 00:03:26 2009 +0200 +++ b/tests/test-record.out Mon Jun 15 00:03:27 2009 +0200 @@ -572,3 +572,27 @@ b +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 +
--- a/tests/test-transplant Mon Jun 15 00:03:26 2009 +0200 +++ b/tests/test-transplant Mon Jun 15 00:03:27 2009 +0200 @@ -134,3 +134,26 @@ hg transplant -s ../t -b tip -a --filter ./test-filter |\ sed 's/filtering.*/filtering/g' 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 .. \ No newline at end of file
--- a/tests/test-transplant.out Mon Jun 15 00:03:26 2009 +0200 +++ b/tests/test-transplant.out Mon Jun 15 00:03:27 2009 +0200 @@ -159,3 +159,10 @@ 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'