You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Erik Huelsmann <eh...@gmail.com> on 2005/11/21 22:00:51 UTC

[PATCH] Windows: Fix issue #2431 (blame ignores svn:eol-style)

I can fix the bug, or at least come a long way, but have no way to
test atm.  Could someone with easy windows access please test this
patch?  Thanks!

Log:
[[[
Fix issue #2431 (blame ignores svn:eol-style).

* subversion/libsvn_client/blame.c
  (file_rev_baton): New members eol_style and eol_str for storing
  the requested file translation type.
  (get_eol_style): New. Function to adjust eol style from propdiff sent.
  (file_rev_handler): See if the file needs translation for the eol style,
  translate if it does.
  (svn_client_blame2): Initialize the new baton members.
]]]



Index: subversion/libsvn_client/blame.c
===================================================================
--- subversion/libsvn_client/blame.c    (revision 17463)
+++ subversion/libsvn_client/blame.c    (working copy)
@@ -21,6 +21,7 @@
 #include "client.h"

 #include "svn_client.h"
+#include "svn_subst.h"
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_diff.h"
@@ -58,6 +59,8 @@
   const char *target;
   svn_client_ctx_t *ctx;
   const char *last_filename;
+  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 */
@@ -326,6 +329,25 @@
     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));
@@ -367,6 +389,26 @@
   return SVN_NO_ERROR;
 }

+
+static void
+get_eol_style (svn_subst_eol_style_t *style,
+                 const char **eol,
+                 apr_array_header_t *prop_diffs)
+{
+  int i;
+
+  for (i = 0; i < prop_diffs->nelts; ++i)
+    {
+      const svn_prop_t *prop = &APR_ARRAY_IDX(prop_diffs, i, svn_prop_t);
+      if (strcmp (prop->name, SVN_PROP_EOL_STYLE) == 0)
+        {
+          svn_subst_eol_style_from_value
+            (style, eol, prop->value ? prop->value->data : NULL);
+          return;
+        }
+    }
+}
+
 static svn_error_t *
 file_rev_handler (void *baton, const char *path, svn_revnum_t revnum,
                   apr_hash_t *rev_props,
@@ -386,6 +428,9 @@
   /* If this file has a non-textual mime-type, bail out. */
   SVN_ERR (check_mimetype (prop_diffs, frb->target, frb->currpool));

+  /* */
+  get_eol_style (&frb->eol_style, &frb->eol_str, prop_diffs);
+
   if (frb->ctx->notify_func2)
     {
       svn_wc_notify_t *notify
@@ -526,6 +571,8 @@
   frb.target = target;
   frb.ctx = ctx;
   frb.last_filename = NULL;
+  frb.eol_style = svn_subst_eol_style_none;
+  frb.eol_str = NULL;
   frb.blame = NULL;
   frb.avail = NULL;

Re: [PATCH] Windows: Fix issue #2431 (blame ignores svn:eol-style)

Posted by Ivan Zhakov <ch...@gmail.com>.
On 11/23/05, Erik Huelsmann <eh...@gmail.com> wrote:
> On 11/22/05, Ivan Zhakov <ch...@gmail.com> wrote:
> > On 11/22/05, Erik Huelsmann <eh...@gmail.com> wrote:
> > > I can fix the bug, or at least come a long way, but have no way to
> > > test atm.  Could someone with easy windows access please test this
> > > patch?  Thanks!
> > Erik, how I can test it?  Only run all regression tests or do something more?
>
> No, running the test suite will not work: there's no test for it yet.
>
> I'm including olly@tigris.org too (being the original reporter),
> because the issue has no reproduction recipe, but I think the
> following script should show the problem without a patch (and not show
> it with the patch).
>
>
> svnadmin create c:\temp\repos
> svn co file:///c:/temp/repos c:\temp\wc
> echo "line 1" > c:\temp\wc\foo
> echo "line 2" >> c:\temp\wc\foo
> svn add c:\temp\wc\foo
> svn ps svn:eol-style native c:\temp\wc\foo
> svn ci c:\temp\wc
> svn blame c:\temp\wc\foo > c:\temp\wc\foo-blame
> # now check foo-blame for the eols used.
>
Hi Erik,
I have tested your patch and confirm it fixes problem that was without
your patch.

--
Ivan Zhakov

Re: [PATCH] Windows: Fix issue #2431 (blame ignores svn:eol-style)

Posted by Erik Huelsmann <eh...@gmail.com>.
On 11/22/05, Ivan Zhakov <ch...@gmail.com> wrote:
> On 11/22/05, Erik Huelsmann <eh...@gmail.com> wrote:
> > I can fix the bug, or at least come a long way, but have no way to
> > test atm.  Could someone with easy windows access please test this
> > patch?  Thanks!
> Erik, how I can test it?  Only run all regression tests or do something more?

No, running the test suite will not work: there's no test for it yet.

I'm including olly@tigris.org too (being the original reporter),
because the issue has no reproduction recipe, but I think the
following script should show the problem without a patch (and not show
it with the patch).


svnadmin create c:\temp\repos
svn co file:///c:/temp/repos c:\temp\wc
echo "line 1" > c:\temp\wc\foo
echo "line 2" >> c:\temp\wc\foo
svn add c:\temp\wc\foo
svn ps svn:eol-style native c:\temp\wc\foo
svn ci c:\temp\wc
svn blame c:\temp\wc\foo > c:\temp\wc\foo-blame
# now check foo-blame for the eols used.

bye,

Erik.

Re: [PATCH] Windows: Fix issue #2431 (blame ignores svn:eol-style)

Posted by Ivan Zhakov <ch...@gmail.com>.
On 11/22/05, Erik Huelsmann <eh...@gmail.com> wrote:
> I can fix the bug, or at least come a long way, but have no way to
> test atm.  Could someone with easy windows access please test this
> patch?  Thanks!
Erik, how I can test it?  Only run all regression tests or do something more?

>
> Log:
> [[[
> Fix issue #2431 (blame ignores svn:eol-style).
>
> * subversion/libsvn_client/blame.c
>   (file_rev_baton): New members eol_style and eol_str for storing
>   the requested file translation type.
>   (get_eol_style): New. Function to adjust eol style from propdiff sent.
>   (file_rev_handler): See if the file needs translation for the eol style,
>   translate if it does.
>   (svn_client_blame2): Initialize the new baton members.
> ]]]
>
>
>
> Index: subversion/libsvn_client/blame.c
> ===================================================================
> --- subversion/libsvn_client/blame.c    (revision 17463)
> +++ subversion/libsvn_client/blame.c    (working copy)
> @@ -21,6 +21,7 @@
>  #include "client.h"
>
>  #include "svn_client.h"
> +#include "svn_subst.h"
>  #include "svn_string.h"
>  #include "svn_error.h"
>  #include "svn_diff.h"
> @@ -58,6 +59,8 @@
>    const char *target;
>    svn_client_ctx_t *ctx;
>    const char *last_filename;
> +  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 */
> @@ -326,6 +329,25 @@
>      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));
> @@ -367,6 +389,26 @@
>    return SVN_NO_ERROR;
>  }
>
> +
> +static void
> +get_eol_style (svn_subst_eol_style_t *style,
> +                 const char **eol,
> +                 apr_array_header_t *prop_diffs)
> +{
> +  int i;
> +
> +  for (i = 0; i < prop_diffs->nelts; ++i)
> +    {
> +      const svn_prop_t *prop = &APR_ARRAY_IDX(prop_diffs, i, svn_prop_t);
> +      if (strcmp (prop->name, SVN_PROP_EOL_STYLE) == 0)
> +        {
> +          svn_subst_eol_style_from_value
> +            (style, eol, prop->value ? prop->value->data : NULL);
> +          return;
> +        }
> +    }
> +}
> +
>  static svn_error_t *
>  file_rev_handler (void *baton, const char *path, svn_revnum_t revnum,
>                    apr_hash_t *rev_props,
> @@ -386,6 +428,9 @@
>    /* If this file has a non-textual mime-type, bail out. */
>    SVN_ERR (check_mimetype (prop_diffs, frb->target, frb->currpool));
>
> +  /* */
> +  get_eol_style (&frb->eol_style, &frb->eol_str, prop_diffs);
> +
>    if (frb->ctx->notify_func2)
>      {
>        svn_wc_notify_t *notify
> @@ -526,6 +571,8 @@
>    frb.target = target;
>    frb.ctx = ctx;
>    frb.last_filename = NULL;
> +  frb.eol_style = svn_subst_eol_style_none;
> +  frb.eol_str = NULL;
>    frb.blame = NULL;
>    frb.avail = NULL;
>


--
Ivan Zhakov