subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1493583 - /subversion/trunk/subversion/libsvn_client/blame.c
Date Sun, 16 Jun 2013 21:07:45 GMT
Author: rhuijben
Date: Sun Jun 16 21:07:44 2013
New Revision: 1493583

URL: http://svn.apache.org/r1493583
Log:
In the blame code: move variables that are passed per delta to the right baton,
this makes the code easier to understand.

* subversion/libsvn_client/blame.c
  (file_rev_baton): Remove per delta variables. Keep last revision pointer.
     Document lifetime.
  (delta_baton): Add variables. Document lifetime.

  (window_handler,
   file_rev_handler): Update baton usages.

  (svn_client_blame5): Handle last_rev.

Modified:
    subversion/trunk/subversion/libsvn_client/blame.c

Modified: subversion/trunk/subversion/libsvn_client/blame.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/blame.c?rev=1493583&r1=1493582&r2=1493583&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/blame.c (original)
+++ subversion/trunk/subversion/libsvn_client/blame.c Sun Jun 16 21:07:44 2013
@@ -73,7 +73,7 @@ struct diff_baton {
   const struct rev *rev;
 };
 
-/* The baton used for a file revision. */
+/* The baton used for a file revision. Lives the entire operation */
 struct file_rev_baton {
   svn_revnum_t start_rev, end_rev;
   const char *target;
@@ -81,8 +81,7 @@ struct file_rev_baton {
   const svn_diff_file_options_t *diff_options;
   /* name of file containing the previous revision of the file */
   const char *last_filename;
-  struct rev *rev;     /* the rev for which blame is being assigned
-                          during a diff */
+  struct rev *last_rev;   /* the rev of the last modification */
   struct blame_chain *chain;      /* the original blame chain. */
   const char *repos_root_url;    /* To construct a url */
   apr_pool_t *mainpool;  /* lives during the whole sequence of calls */
@@ -91,7 +90,6 @@ struct file_rev_baton {
 
   /* These are used for tracking merged revisions. */
   svn_boolean_t include_merged_revisions;
-  svn_boolean_t merged_revision;
   struct blame_chain *merged_chain;  /* the merged blame chain. */
   /* name of file containing the previous merged revision of the file */
   const char *last_original_filename;
@@ -100,7 +98,7 @@ struct file_rev_baton {
   apr_pool_t *prevfilepool;
 };
 
-/* The baton used by the txdelta window handler. */
+/* The baton used by the txdelta window handler. Allocated per revision */
 struct delta_baton {
   /* Our underlying handler/baton that we wrap */
   svn_txdelta_window_handler_t wrapped_handler;
@@ -108,6 +106,8 @@ struct delta_baton {
   struct file_rev_baton *file_rev_baton;
   svn_stream_t *source_stream;  /* the delta source */
   const char *filename;
+  svn_boolean_t is_merged_revision;
+  struct rev *rev;     /* the rev struct for the current revision */
 };
 
 
@@ -342,18 +342,18 @@ window_handler(svn_txdelta_window_t *win
 
   /* Process this file. */
   SVN_ERR(add_file_blame(frb->last_filename,
-                         dbaton->filename, chain, frb->rev,
+                         dbaton->filename, chain, dbaton->rev,
                          frb->diff_options, frb->currpool));
 
   /* If we are including merged revisions, and the current revision is not a
      merged one, we need to add its blame info to the chain for the original
      line of history. */
-  if (frb->include_merged_revisions && ! frb->merged_revision)
+  if (frb->include_merged_revisions && ! dbaton->is_merged_revision)
     {
       apr_pool_t *tmppool;
 
       SVN_ERR(add_file_blame(frb->last_original_filename,
-                             dbaton->filename, frb->chain, frb->rev,
+                             dbaton->filename, frb->chain, dbaton->rev,
                              frb->diff_options, frb->currpool));
 
       /* This filename could be around for a while, potentially, so
@@ -439,8 +439,6 @@ file_rev_handler(void *baton, const char
   if (!content_delta_handler)
     return SVN_NO_ERROR;
 
-  frb->merged_revision = merged_revision;
-
   /* Create delta baton. */
   delta_baton = apr_palloc(frb->currpool, sizeof(*delta_baton));
 
@@ -453,7 +451,7 @@ file_rev_handler(void *baton, const char
     delta_baton->source_stream = NULL;
   last_stream = svn_stream_disown(delta_baton->source_stream, pool);
 
-  if (frb->include_merged_revisions && !frb->merged_revision)
+  if (frb->include_merged_revisions && !merged_revision)
     filepool = frb->filepool;
   else
     filepool = frb->currpool;
@@ -470,11 +468,12 @@ file_rev_handler(void *baton, const char
 
   /* Wrap the window handler with our own. */
   delta_baton->file_rev_baton = frb;
+  delta_baton->is_merged_revision = merged_revision;
   *content_delta_handler = window_handler;
   *content_delta_baton = delta_baton;
 
   /* Create the rev structure. */
-  frb->rev = apr_pcalloc(frb->mainpool, sizeof(struct rev));
+  delta_baton->rev = apr_pcalloc(frb->mainpool, sizeof(struct rev));
 
   if (revnum < MIN(frb->start_rev, frb->end_rev))
     {
@@ -485,7 +484,7 @@ file_rev_handler(void *baton, const char
 
       /* The file existed before start_rev; generate no blame info for
          lines from this revision (or before). */
-      frb->rev->revision = SVN_INVALID_REVNUM;
+      delta_baton->rev->revision = SVN_INVALID_REVNUM;
     }
   else
     {
@@ -493,12 +492,15 @@ file_rev_handler(void *baton, const char
       SVN_ERR_ASSERT(revnum <= 1 + MAX(frb->end_rev, frb->start_rev));
 
       /* Set values from revision props. */
-      frb->rev->revision = revnum;
-      frb->rev->rev_props = svn_prop_hash_dup(rev_props, frb->mainpool);
+      delta_baton->rev->revision = revnum;
+      delta_baton->rev->rev_props = svn_prop_hash_dup(rev_props, frb->mainpool);
     }
 
   if (frb->include_merged_revisions)
-    frb->rev->path = apr_pstrdup(frb->mainpool, path);
+    delta_baton->rev->path = apr_pstrdup(frb->mainpool, path);
+
+  /* Keep last revision for postprocessing after all changes */
+  frb->last_rev = delta_baton->rev;
 
   return SVN_NO_ERROR;
 }
@@ -668,6 +670,7 @@ svn_client_blame5(const char *target,
   frb.diff_options = diff_options;
   frb.include_merged_revisions = include_merged_revisions;
   frb.last_filename = NULL;
+  frb.last_rev = NULL;
   frb.last_original_filename = NULL;
   frb.chain = apr_palloc(pool, sizeof(*frb.chain));
   frb.chain->blame = NULL;
@@ -790,7 +793,7 @@ svn_client_blame5(const char *target,
          the most recently changed revision.  ### Is this really what we want
          to do here?  Do the sematics of copy change? */
       if (!frb.chain->blame)
-        frb.chain->blame = blame_create(frb.chain, frb.rev, 0);
+        frb.chain->blame = blame_create(frb.chain, frb.last_rev, 0);
 
       normalize_blames(frb.chain, frb.merged_chain, pool);
       walk_merged = frb.merged_chain->blame;



Mime
View raw message