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

[PATCH] Pass the mime-type to the notify callback

From: SteveKing <steveking_at_gmx.ch>
Date: 2004-01-24 21:20:05 CET

Hi,

While working on TSVN I wanted to show the user the mime-type of files
during checkouts/updates/... and made use of the parameter passed in
from the notification callback. But whatever I tried I never got a
mime-type passed in - the parameter was always NULL. That's when I
started to dig into the subversion code and found a suspicious line in
/subversion/libsvn_wc/update_editor.c where the mime-type param gets
passed to the notification callback:
NULL, /* ### use install_file() mimetype here */

So I thought I'll do exactly that. Below is my patch. Tested with
TortoiseSVN.

Stefan

---
Don't blame me, I'm having a blonde moment!
---
Log Message:
Pass the mime-type of files to the notification callback so clients can 
use it.
* subversion/libsvn_wc/update_editor.c
   (close_file): pass mime-type to callback function
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(revision 8291)
+++ subversion/libsvn_wc/update_editor.c	(working copy)
@@ -2311,15 +2311,27 @@
        (prop_state != svn_wc_notify_state_unchanged))
      {
        if (eb->notify_func)
+      {
+      	const char * mimetype = NULL;
+      	int i;
+        for (i = 0; i < propchanges->nelts; i++)
+          {
+            svn_prop_t *propchange
+              = &APR_ARRAY_IDX (propchanges, i, svn_prop_t);
+
+            if (strcmp (propchange->name, SVN_PROP_MIME_TYPE) == 0)
+              mimetype = propchange->value->data;
+          }
          (*eb->notify_func) (eb->notify_baton,
                              fb->path,
                              fb->added ? svn_wc_notify_update_add
                                        : svn_wc_notify_update_update,
                              svn_node_file,
-                            NULL,  /* ### use install_file() mimetype 
here */
+                            mimetype,
                              content_state,
                              prop_state,
                              SVN_INVALID_REVNUM);
+      }
      }
    return SVN_NO_ERROR;
  }

Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c (revision 8291)
+++ subversion/libsvn_wc/update_editor.c (working copy)
@@ -2311,15 +2311,27 @@
       (prop_state != svn_wc_notify_state_unchanged))
     {
       if (eb->notify_func)
+ {
+ const char * mimetype = NULL;
+ int i;
+ for (i = 0; i < propchanges->nelts; i++)
+ {
+ svn_prop_t *propchange
+ = &APR_ARRAY_IDX (propchanges, i, svn_prop_t);
+
+ if (strcmp (propchange->name, SVN_PROP_MIME_TYPE) == 0)
+ mimetype = propchange->value->data;
+ }
         (*eb->notify_func) (eb->notify_baton,
                             fb->path,
                             fb->added ? svn_wc_notify_update_add
                                       : svn_wc_notify_update_update,
                             svn_node_file,
- NULL, /* ### use install_file() mimetype here */
+ mimetype,
                             content_state,
                             prop_state,
                             SVN_INVALID_REVNUM);
+ }
     }
   return SVN_NO_ERROR;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 24 21:21:50 2004

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.