OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /v/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-src Date: 07-Mar-2008 13:41:38 Branch: HEAD Handle: 2008030712413600 Added files: openpkg-src/monotone monotone.patch Modified files: openpkg-src/monotone monotone.spec Log: improve the world by fixing a very subtle bug in Monotone's 'mtn diff' processing which bite me the second time now and hence was no longer acceptable to me to be ignored Summary: Revision Changes Path 1.13 +132 -0 openpkg-src/monotone/monotone.patch 1.31 +3 -1 openpkg-src/monotone/monotone.spec ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/monotone/monotone.patch ============================================================================ $ cvs diff -u -r0 -r1.13 monotone.patch --- /dev/null 2008-03-07 13:36:05 +0100 +++ monotone.patch 2008-03-07 13:41:37 +0100 @@ -0,0 +1,132 @@ +Fix "mtn diff" output by handling the special cases of missing trailing +newline at end of file. This makes the output compatible with GNU +diffutils' diff(1) and especially allows it to be correctly applied with +GNU patch(1) again, too. + +The source of the problem is that diff_patch:cc:make_diff() called the +generic function simplestring_xform.cc:split_into_lines() for splitting +the file data into individual lines, this way removed all(!) newlines at +all and hence lost the information about the special case of a missing +trailing newline. + +The least invasive fix is to already preserve the information in +simplestring_xform.cc:split_into_lines() by representing the missing +newline with the appended text "[\r]\n\\No newline at end of file" on +the last line (notice that this is the only case were a line can still +contain a newline after splitting). + +Additionally, diff_patch.cc:walk_hunk_consumer() for unknown reasons +produces added before deleted lines (instead of the expection order of +deleted before added lines) and hence also had to be fixed in order to +produce output 100% compatible to GNU diff(1). + +Finally, two existing tests related to diff_patch.cc:walk_hunk_consumer() +were adjusted and a new test suite was added for checking all four +special cases related to the missing trailing newline. The complete +Monotone test suite still succeeed with 0 failures after this change. + +Index: diff_patch.cc +--- diff_patch.cc e359a4c03c6ce548d6414dce11160fbcb6fcb831 ++++ diff_patch.cc daeb9be7d8c10d33781b54debd541027618dbfce +@@ -1010,17 +1010,17 @@ void walk_hunk_consumer(vector<long, QA( + while (idx(lines2,b) != *i) + cons.insert_at(b++); + } +- if (b < lines2.size()) ++ if (a < lines1.size()) + { + cons.advance_to(a); +- while(b < lines2.size()) +- cons.insert_at(b++); ++ while(a < lines1.size()) ++ cons.delete_at(a++); + } +- if (a < lines1.size()) ++ if (b < lines2.size()) + { + cons.advance_to(a); +- while(a < lines1.size()) +- cons.delete_at(a++); ++ while(b < lines2.size()) ++ cons.insert_at(b++); + } + cons.flush_hunk(a); + } +@@ -1349,8 +1349,8 @@ make_diff(string const & filename1, + } + + vector<string> lines1, lines2; +- split_into_lines(data1(), lines1); +- split_into_lines(data2(), lines2); ++ split_into_lines(data1(), lines1, true); ++ split_into_lines(data2(), lines2, true); + + vector<long, QA(long)> left_interned; + vector<long, QA(long)> right_interned; +Index: simplestring_xform.cc +--- simplestring_xform.cc 5f2e4fcd288a2ec1fd59feb97ebc777b56597608 ++++ simplestring_xform.cc dcaa75eb0ed67ddc119ef62f06c21bd7d13bf5cb +@@ -50,9 +50,24 @@ void split_into_lines(string const & in, + } + + void split_into_lines(string const & in, ++ vector<string> & out, ++ bool diff_compat) ++{ ++ return split_into_lines(in, constants::default_encoding, out, diff_compat); ++} ++ ++void split_into_lines(string const & in, + string const & encoding, + vector<string> & out) + { ++ return split_into_lines(in, encoding, out, false); ++} ++ ++void split_into_lines(string const & in, ++ string const & encoding, ++ vector<string> & out, ++ bool diff_compat) ++{ + string lc_encoding = lowercase(encoding); + out.clear(); + +@@ -92,8 +107,16 @@ void split_into_lines(string const & in, + break; + end = in.find_first_of("\r\n", begin); + } +- if (begin < in.size()) +- out.push_back(in.substr(begin, in.size() - begin)); ++ if (begin < in.size()) { ++ // special case: last line without trailing newline ++ string s = in.substr(begin, in.size() - begin); ++ if (diff_compat) { ++ // special handling: produce diff(1) compatible output ++ s += (in.find_first_of("\r") != string::npos ? "\r\n" : "\n"); ++ s += "\\ No newline at end of file"; ++ } ++ out.push_back(s); ++ } + } + else + { +Index: simplestring_xform.hh +--- simplestring_xform.hh 0280d49b889bc0b7b2900d5d123cc8ec95a115eb ++++ simplestring_xform.hh 564a305c99ca931c93956ac3ef903683dcb15db7 +@@ -13,6 +13,15 @@ void split_into_lines(std::string const + std::string const & encoding, + std::vector<std::string> & out); + ++void split_into_lines(std::string const & in, ++ std::vector<std::string> & out, ++ bool diff_compat); ++ ++void split_into_lines(std::string const & in, ++ std::string const & encoding, ++ std::vector<std::string> & out, ++ bool diff_compat); ++ + void join_lines(std::vector<std::string> const & in, + std::string & out, + std::string const & linesep); + @@ . patch -p0 <<'@@ .' Index: openpkg-src/monotone/monotone.spec ============================================================================ $ cvs diff -u -r1.30 -r1.31 monotone.spec --- openpkg-src/monotone/monotone.spec 27 Feb 2008 19:14:59 -0000 1.30 +++ openpkg-src/monotone/monotone.spec 7 Mar 2008 12:41:36 -0000 1.31 @@ -32,7 +32,7 @@ Group: SCM License: GPL Version: 0.39 -Release: 20080227 +Release: 20080307 # package options %option with_rse yes @@ -44,6 +44,7 @@ Source4: monotone-colorize.pl Source5: monotone-colorize.bashrc Source6: monotone.bashrc +Patch0: monotone.patch Patch1: monotone.patch.rse # build information @@ -76,6 +77,7 @@ %prep %setup -q + %patch -p0 -P 0 %if "%{with_rse}" == "yes" %patch -p0 -P 1 %endif @@ . ______________________________________________________________________ OpenPKG http://openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org