monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] Two small diff issues fixed...


From: Richard Levitte - VMS Whacker
Subject: [Monotone-devel] Two small diff issues fixed...
Date: Thu, 02 Sep 2004 17:09:22 +0200 (CEST)

Hey,

I just committed a change that takes care of two issues:

 - diff doesn't keep track of the skew correctly, which means that the
   position indications a few hunks down seem to be kind of reset to
   be equal, instead of keeping track of the difference between all
   the deleted and added lines so far.  Attached are two diffs of this
   committed change, one done before the change (diff1.diff) and one
   after (diff2.diff).  You can note that some numbers became different.

 - if there's a change at the beginning of a file that is up to 3
   lines (for example one delete and two adds, or three adds, or two
   adds), diff doesn't output any trailer context at all.  This is
   what caused the problems report in bug 8715.

I haven't been able to figure out savannah yet, and especially how
email feedback works (if it does), or I wouldn't feel the need to send
this email.

I'd appreciate it if others tested these changes, since I probably
won't spot all problems coming from this...

Cheers,
Richard

-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.

-- 
Richard Levitte                         address@hidden
                                        http://richard.levitte.org/

"When I became a man I put away childish things, including
 the fear of childishness and the desire to be very grown up."
                                                -- C.S. Lewis
# Old manifest: 722fbdd79abd46f7ab4a7397b589fa50f2def68f
# New manifest: cb9127ee6f67c27db3acca05f86cb33e7ffdad27
# Summary of changes:
# 
#   patch ChangeLog
#    from 93df288d34930a50a54942c5daa8650ba8e91c47
#      to ee7b821498adb5e516f24c3abac75af561c36455
# 
#   patch diff_patch.cc
#    from 514802c91c6afec3ef5a1ed59191050576c2d806
#      to b2aeecb044c340e2364756e39fa2d5d2c2ff847f
# 
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,15 @@
+2004-09-02  Richard Levitte  <address@hidden>
+
+       fix bug 8715 and more
+       * diff_patch.cc (struct unidiff_hunk_writer,
+       unidiff_hunk_writer::flush_hunk): the skew is not just the
+       size difference between added and deleted lines in the current
+       hunk, it's the size difference between /all/ added and deleted
+       lines so far.  Therefore, the skew needs to be a member of the
+       struct rather than being something calculated for each hunk.
+       Furthermore, we need to add trailing context even if the change
+       only consisted of one line.
+
 2004-08-17  Richard Levitte  <address@hidden>
 
        * monotone.texi (Working Copy): Change the description of
--- diff_patch.cc
+++ diff_patch.cc
@@ -1568,6 +1568,7 @@
   size_t ctx;
   ostream & ost;
   size_t a_begin, b_begin, a_len, b_len;
+  long skew;
   vector<string> hunk;
   unidiff_hunk_writer(vector<string> const & a,
                      vector<string> const & b,
@@ -1585,8 +1586,8 @@
                                         size_t ctx,
                                         ostream & ost)
 : a(a), b(b), ctx(ctx), ost(ost),
-  a_begin(0), b_begin(0), 
-  a_len(0), b_len(0)
+  a_begin(0), b_begin(0),
+  a_len(0), b_len(0), skew(0)
 {}
 
 void unidiff_hunk_writer::insert_at(size_t b_pos)
@@ -1603,7 +1603,7 @@
 
 void unidiff_hunk_writer::flush_hunk(size_t pos)
 {
-  if (hunk.size() > ctx)
+  if (hunk.size() > 0)
     {
       // insert trailing context
       size_t a_pos = a_begin + a_len;
@@ -1633,7 +1633,7 @@
   
   // reset hunk
   hunk.clear();
-  int skew = b_len - a_len;
+  skew += b_len - a_len;
   a_begin = pos;
   b_begin = pos + skew;
   a_len = 0;
# Old manifest: 722fbdd79abd46f7ab4a7397b589fa50f2def68f
# New manifest: cb9127ee6f67c27db3acca05f86cb33e7ffdad27
# Summary of changes:
# 
#   patch ChangeLog
#    from 93df288d34930a50a54942c5daa8650ba8e91c47
#      to ee7b821498adb5e516f24c3abac75af561c36455
# 
#   patch diff_patch.cc
#    from 514802c91c6afec3ef5a1ed59191050576c2d806
#      to b2aeecb044c340e2364756e39fa2d5d2c2ff847f
# 
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,15 @@
+2004-09-02  Richard Levitte  <address@hidden>
+
+       fix bug 8715 and more
+       * diff_patch.cc (struct unidiff_hunk_writer,
+       unidiff_hunk_writer::flush_hunk): the skew is not just the
+       size difference between added and deleted lines in the current
+       hunk, it's the size difference between /all/ added and deleted
+       lines so far.  Therefore, the skew needs to be a member of the
+       struct rather than being something calculated for each hunk.
+       Furthermore, we need to add trailing context even if the change
+       only consisted of one line.
+
 2004-08-17  Richard Levitte  <address@hidden>
 
        * monotone.texi (Working Copy): Change the description of
--- diff_patch.cc
+++ diff_patch.cc
@@ -1568,6 +1568,7 @@
   size_t ctx;
   ostream & ost;
   size_t a_begin, b_begin, a_len, b_len;
+  long skew;
   vector<string> hunk;
   unidiff_hunk_writer(vector<string> const & a,
                      vector<string> const & b,
@@ -1585,8 +1586,8 @@
                                         size_t ctx,
                                         ostream & ost)
 : a(a), b(b), ctx(ctx), ost(ost),
-  a_begin(0), b_begin(0), 
-  a_len(0), b_len(0)
+  a_begin(0), b_begin(0),
+  a_len(0), b_len(0), skew(0)
 {}
 
 void unidiff_hunk_writer::insert_at(size_t b_pos)
@@ -1603,7 +1604,7 @@
 
 void unidiff_hunk_writer::flush_hunk(size_t pos)
 {
-  if (hunk.size() > ctx)
+  if (hunk.size() > 0)
     {
       // insert trailing context
       size_t a_pos = a_begin + a_len;
@@ -1633,7 +1634,7 @@
   
   // reset hunk
   hunk.clear();
-  int skew = b_len - a_len;
+  skew += b_len - a_len;
   a_begin = pos;
   b_begin = pos + skew;
   a_len = 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]