[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Annotate broken on trunk on Win32

From: Malcolm Rowe <malcolm-svn-dev_at_farside.org.uk>
Date: 2006-02-09 18:14:52 CET

On Mon, Feb 06, 2006 at 06:18:49PM -0700, D.J. Heap wrote:
> Thanks, that did help! Blame now finishes and the lines are correct.
> However, now in the blame info (rev, author) the last person to change
> the file gets credit for every single line...it's like it line-diffing
> translated and untranslated files now?
>

You got it exactly right: we were still passing the untranslated 'old'
file to add_file_blame(), so every line was coming up as changed.
How about the attached patch?

[[[
Fix blame for files whose translated eol-style differs from the
untranslated style. For example, files with eol-style of 'native'
on Win32.

Followup to r17513.

Found by: djh
          brane

* subversion/libsvn_client/blame.c
  (struct file_rev_baton): Add 'last_filename_translated' to hold the
    name of the translated version of the prior revision.
  (window_handler): Call add_file_blame() with the name of the
    translated version of the prior revision, rather than the untranslated
    version. Set frb->last_filename to the untranslated version of
    the current revision, rather than the translated version (important
    because this will be the delta source for the next revision), and
    instead set frb->last_filename_translated to the translated version.
  (svn_client_blame2): Initialise frb.last_filename_translated to NULL.
]]]

Regards,
Malcolm

Index: subversion/libsvn_client/blame.c
===================================================================
--- subversion/libsvn_client/blame.c (revision 18400)
+++ subversion/libsvn_client/blame.c (working copy)
@@ -1,11 +1,11 @@
 /*
  * blame.c: return blame messages
  *
  * ====================================================================
- * Copyright (c) 2000-2004 CollabNet. All rights reserved.
+ * Copyright (c) 2000-2006 CollabNet. All rights reserved.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
  * are also available at http://subversion.tigris.org/license-1.html.
  * If newer versions of this license are posted there, you may use a
  * newer version instead, at your option.
@@ -55,13 +55,18 @@ struct blame
 /* The baton used for a file revision. Also used for the diff output
    routine. */
 struct file_rev_baton {
   svn_revnum_t start_rev, end_rev;
   const char *target;
   svn_client_ctx_t *ctx;
+ /* name of file containing the previous revision of the file */
   const char *last_filename;
+ /* name of file containing the previous revision of the file, translated
+ to the appropriate EOL style. May be identical to the above if no
+ translation was required. */
+ const char *last_filename_translated;
   svn_subst_eol_style_t eol_style;
   const char *eol_str;
   struct rev *rev; /* the rev for which blame is being assigned
                           during a diff */
   struct blame *blame; /* linked list of blame chunks */
   struct blame *avail; /* linked list of free blame chunks */
@@ -310,12 +315,13 @@ add_file_blame (const char *last_file, c
 
 static svn_error_t *
 window_handler (svn_txdelta_window_t *window, void *baton)
 {
   struct delta_baton *dbaton = baton;
   struct file_rev_baton *frb = dbaton->file_rev_baton;
+ const char *translation_tgt = dbaton->filename;
 
   /* Call the wrapped handler first. */
   SVN_ERR (dbaton->wrapped_handler (window, dbaton->wrapped_baton));
 
   /* We patiently wait for the NULL window marking the end. */
   if (window)
@@ -329,36 +335,34 @@ window_handler (svn_txdelta_window_t *wi
     SVN_ERR (svn_io_file_close (dbaton->source_file, frb->currpool));
   SVN_ERR (svn_io_file_close (dbaton->file, frb->currpool));
 
   if (svn_subst_translation_required (frb->eol_style, frb->eol_str,
                                       NULL, FALSE, FALSE))
     {
- const char *translation_tgt;
-
       SVN_ERR (svn_io_open_unique_file2 (NULL,
                                          &translation_tgt,
                                          frb->tmp_path,
                                          ".tmp",
                                          svn_io_file_del_on_pool_cleanup,
                                          frb->currpool));
       SVN_ERR (svn_subst_copy_and_translate3 (dbaton->filename,
                                               translation_tgt,
                                               frb->eol_str, FALSE,
                                               NULL, FALSE, FALSE,
                                               frb->currpool));
- dbaton->filename = translation_tgt;
     }
 
   /* Process this file. */
- SVN_ERR (add_file_blame (frb->last_filename,
- dbaton->filename, frb));
+ SVN_ERR (add_file_blame (frb->last_filename_translated,
+ translation_tgt, frb));
 
   /* Prepare for next revision. */
 
   /* Remember the file name so we can diff it with the next revision. */
   frb->last_filename = dbaton->filename;
+ frb->last_filename_translated = translation_tgt;
 
   /* Switch pools. */
   {
     apr_pool_t *tmp_pool = frb->lastpool;
     frb->lastpool = frb->currpool;
     frb->currpool = tmp_pool;
@@ -567,12 +571,13 @@ svn_client_blame2 (const char *target,
 
   frb.start_rev = start_revnum;
   frb.end_rev = end_revnum;
   frb.target = target;
   frb.ctx = ctx;
   frb.last_filename = NULL;
+ frb.last_filename_translated = NULL;
   frb.eol_style = svn_subst_eol_style_none;
   frb.eol_str = NULL;
   frb.blame = NULL;
   frb.avail = NULL;
 
   SVN_ERR (svn_io_temp_dir (&frb.tmp_path, pool));

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Feb 9 18:41:02 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.