The unified diff between revisions [20dc96bb..] and [00597974..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "database.cc"
#  from [50bc8f5465b8e513a449f98a7816f5a8543bea5d]
#    to [769689f77de5d18418e092b713cb19f2da2fb934]
#
============================================================
--- database.cc	50bc8f5465b8e513a449f98a7816f5a8543bea5d
+++ database.cc	769689f77de5d18418e092b713cb19f2da2fb934
@@ -1148,13 +1148,13 @@ database::get_version(hexenc<id> const &
       boost::shared_ptr<delta_applicator> app = new_piecewise_applicator();
       app->begin(begin());

-      size_t skip_length = 0;
-      // XXX: sucks if it's not copy-on-write
-      data skip_dat(begin);
-      hexenc<id> skip_id(curr);
+      data skip_dat;
+      hexenc<id> skip_id;
+      const size_t skip_const = 10;

       MM(*selected_path);

+      size_t skip_index = 0;
       for (version_path::reverse_iterator i = selected_path->rbegin();
            i != selected_path->rend(); ++i)
         {
@@ -1175,39 +1175,42 @@ database::get_version(hexenc<id> const &
           app->next();
           curr = nxt;

-          if (skip_length == 10)
+          // note that when we get to the end of the path, we use use the
+          // finished data here for the get_version()'s final return value.
+          if ((selected_path->size() - skip_index - 1) % skip_const == 0)
             {
-              ++skip;
               // TODO: can we be smarter and create the xdelta directly using
               // the piecewise_applicator? sounds a bit too clever.
+
+              // save this data
               string tmp;
               MM(tmp);
               app->finish(tmp);
               data curr_dat = data(tmp);
-              // required? probably.
               hexenc<id> check;
               MM(skip_id);
               MM(check);
               MM(curr);
               calculate_ident(curr_dat, check);
               I(check == curr);
-              delta del;
-              diff(skip_dat, curr_dat, del);
-              put_delta(curr, skip_id, del, delta_table);
-              skip_length = 0;
+
+              // store the skip-delta
+              if (!null_id(skip_id))
+                {
+                  ++skip;
+                  delta del;
+                  diff(skip_dat, curr_dat, del);
+                  put_delta(curr, skip_id, del, delta_table);
+                }
               skip_dat.swap(curr_dat);
               skip_id = curr;
             }
-          else
-            {
-              skip_length++;
-            }
+          skip_index++;
         }

-      string tmp;
-      app->finish(tmp);
-      dat = data(tmp);
+      dat.swap(skip_dat);

+      // TODO: can remove after have more faith in the skip delta bit
       hexenc<id> final;
       calculate_ident(dat, final);
       I(final == ident);