Index: subversion/include/svn_config.h
===================================================================
--- subversion/include/svn_config.h	(revision 7381)
+++ subversion/include/svn_config.h	(working copy)
@@ -81,11 +81,11 @@
 #define SVN_CONFIG_OPTION_LOG_ENCODING              "log-encoding"
 #define SVN_CONFIG_OPTION_USE_COMMIT_TIMES          "use-commit-times"
 #define SVN_CONFIG_OPTION_TEMPLATE_ROOT             "template-root"
+#define SVN_CONFIG_OPTION_COMPRESS_TEXT_BASE        "compress-text-base" 
 #define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS         "enable-auto-props"
 #define SVN_CONFIG_SECTION_TUNNELS              "tunnels"
 #define SVN_CONFIG_SECTION_AUTO_PROPS           "auto-props"
 
-
 /*** Configuration Default Values ***/
 
 #define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \
Index: subversion/include/svn_io.h
===================================================================
--- subversion/include/svn_io.h	(revision 7381)
+++ subversion/include/svn_io.h	(working copy)
@@ -393,6 +393,25 @@
 svn_stream_t *svn_stream_compressed (svn_stream_t *stream, 
                                      apr_pool_t *pool);
 
+/** Mark the @c apr_file_t @a file as being a compressed file.
+ *
+ * Mark @a file as compressed. Any subsequent calls to @c
+ * svn_stream_from_aprfile with this @c apr_file_t will automatically
+ * wrap it around a compressed stream.
+ */
+svn_error_t *svn_stream_mark_apr_file_compressed (apr_file_t *file, 
+                                                  apr_pool_t *pool);
+
+/** Is the @c apr_file_t @a file marked as compressed?
+ *
+ * Set @a compressed to @c TRUE if @a file has been marked compressed,
+ * @c FALSE otherwise.
+ */
+svn_error_t *svn_stream_is_apr_file_marked_compressed (apr_file_t *file, 
+                                                       svn_boolean_t 
+                                                       *compressed,
+                                                       apr_pool_t *pool);
+
 /** Read from a generic stream. */
 svn_error_t *svn_stream_read (svn_stream_t *stream, char *buffer,
                               apr_size_t *len);
@@ -452,6 +471,29 @@
                                          apr_file_t *file,
                                          apr_pool_t *pool);
 
+/** The filename extension for compressed files.  */
+#define SVN_IO_COMPRESS_SUFFIX ".gz"
+
+/** Compress file @a file, a utf8-encoded path.
+ * 
+ * Compress @a file to a new file named @a file + @c
+ * SVN_IO_COMPRESS_SUFFIX. The old file is removed once the compression
+ * is finished.
+ */
+svn_error_t *svn_io_file_compress (const char *file, apr_pool_t *pool);
+
+/** Decompress file @a file, a utf8-encoded path.
+ *
+ * Decompress @a to a new file with the @c SVN_IO_COMPRESS_SUFFIX
+ * striped off the end of the filename. @a file is removed once
+ * compression is finished.
+ */
+svn_error_t *svn_io_file_decompress (const char *file, apr_pool_t *pool);
+
+svn_error_t *svn_io_file_decompress_to_file (const char *file, 
+                                             const char *dst_file,
+                                             apr_pool_t *pool);
+
 /** Remove file @a path, a utf8-encoded path.  This wraps @c apr_file_remove(), 
  * converting any error to a Subversion error.
  */
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h	(revision 7381)
+++ subversion/include/svn_wc.h	(working copy)
@@ -1540,6 +1540,8 @@
  * If @a diff3_cmd is non-null, then use it as the diff3 command for
  * any merging; otherwise, use the built-in merge code.
  *
+ * If @a compress_text_base is true, compress all the new text base files. 
+ *
  * @a target_revision is the repository revision that results from this set
  * of changes.
  *
@@ -1558,6 +1560,7 @@
                                        svn_cancel_func_t cancel_func,
                                        void *cancel_baton,
                                        const char *diff3_cmd,
+                                       svn_boolean_t compress_text_base,
                                        const svn_delta_editor_t **editor,
                                        void **edit_baton,
                                        svn_wc_traversal_info_t *ti,
@@ -1566,6 +1569,42 @@
 
 /** A variant of @c svn_wc_get_update_editor().
  *
+ * @a dest will be created as a working copy, if it does not exist
+ * already.  It is not an error for it to exist; if it does, checkout
+ * just behaves like update.
+ *
+ * It is the caller's job to make sure that @a dest is not some other
+ * working copy, or that if it is, it will not be damaged by the
+ * application of this delta.  The wc library tries to detect
+ * such a case and do as little damage as possible, but makes no
+ * promises.
+ *
+ * The editor invokes @a notify_func with @a notify_baton as the checkout
+ * progresses, if @a notify_func is non-null.
+ *
+ * If @a cancel_func is non-null, it gets called, with @a cancel_baton as 
+ * the checkout progresses, to determine if it should continue.
+ *
+ * @a ancestor_url is the repository string to be recorded in this
+ * working copy.
+ */
+svn_error_t *svn_wc_get_checkout_editor (const char *dest,
+                                         const char *ancestor_url,
+                                         svn_revnum_t target_revision,
+                                         svn_boolean_t recurse,
+                                         svn_wc_notify_func_t notify_func,
+                                         void *notify_baton,
+                                         svn_cancel_func_t cancel_func,
+                                         void *cancel_baton,
+                                         svn_boolean_t compress_text_base,
+                                         const svn_delta_editor_t **editor,
+                                         void **edit_baton,
+                                         svn_wc_traversal_info_t *ti,
+                                         apr_pool_t *pool);
+
+
+/** Another variant of @c svn_wc_get_update_editor().
+ *
  * Set @a *editor and @a *edit_baton to an editor and baton for "switching"
  * a working copy to a new @a switch_url.  (Right now, this URL must be
  * within the same repository that the working copy already comes
@@ -1611,12 +1650,80 @@
                                        svn_cancel_func_t cancel_func,
                                        void *cancel_baton,
                                        const char *diff3_cmd,
+                                       svn_boolean_t compress_text_base,
                                        const svn_delta_editor_t **editor,
                                        void **edit_baton,
                                        svn_wc_traversal_info_t *ti,
                                        apr_pool_t *pool);
 
 
+/** Given a @a file_path already under version control, fully "install" a
+ * @a new_revision of the file.  @a adm_access is an access baton with a 
+ * write lock for the directory containing @a file_path.
+ *
+ * By "install", we mean: the working copy library creates a new
+ * text-base and prop-base, merges any textual and property changes
+ * into the working file, and finally updates all metadata so that the
+ * working copy believes it has a new working revision of the file.
+ * All of this work includes being sensitive to eol translation,
+ * keyword substitution, and performing all actions using a journaled
+ * logfile.
+ *
+ * The caller provides a @a new_text_path which points to a temporary
+ * file containing the 'new' full text of the file at revision
+ * @a new_revision.  This function automatically removes @a new_text_path
+ * upon successful completion.  If there is no new text, then caller
+ * must set @a new_text_path to @c NULL.
+ *
+ * The caller also provides the new properties for the file in the
+ * @a props array; if there are no new props, then caller must pass 
+ * @c NULL instead.  This argument is an array of @c svn_prop_t structures, 
+ * and can be interpreted in one of two ways:
+ *
+ *    - if @a is_full_proplist is true, then the array represents the
+ *      complete list of all properties for the file.  It is the new
+ *      'pristine' proplist.
+ *
+ *    - if @a is_full_proplist is false, then the array represents a set of
+ *      *differences* against the file's existing pristine proplist.
+ *      (A deletion is represented by setting an @c svn_prop_t's 'value'
+ *      field to @c NULL.)  
+ *
+ * Note that the @a props array is expected to contain all categories of
+ * props, not just 'regular' ones that the user sees.  (See <tt>enum
+ * svn_prop_kind</tt>).
+ *
+ * If @a content_state is non-null, set @a *content_state to the state of
+ * the file contents after the installation; if return error, the
+ * value of @a *content_state is undefined.
+ *
+ * If @a prop_state is non-null, set @a *prop_state to the state of the
+ * properties after the installation; if return error, the value of
+ * @a *prop_state is undefined.
+ *
+ * If @a new_url is non-null, then this URL will be attached to the file
+ * in the 'entries' file.  Otherwise, the file will simply "inherit"
+ * its URL from the parent dir.
+ *
+ * If @a diff3_cmd is non-null, then use it as the diff3 command for
+ * any merging; otherwise, use the built-in merge code.
+ *
+ * @a pool is used for all bookkeeping work during the installation.
+ */
+svn_error_t *svn_wc_install_file (svn_wc_notify_state_t *content_state,
+                                  svn_wc_notify_state_t *prop_state,
+                                  svn_wc_adm_access_t *adm_access,
+                                  const char *file_path,
+                                  svn_revnum_t new_revision,
+                                  const char *new_text_path,
+                                  const apr_array_header_t *props,
+                                  svn_boolean_t is_full_proplist,
+                                  const char *new_URL,
+                                  const char *diff3_cmd,
+                                  svn_boolean_t compress_text_base,
+                                  apr_pool_t *pool);
+
+
 
 /* A word about the implementation of working copy property storage:
  *
Index: subversion/libsvn_wc/diff.c
===================================================================
--- subversion/libsvn_wc/diff.c	(revision 7381)
+++ subversion/libsvn_wc/diff.c	(working copy)
@@ -474,7 +474,8 @@
     schedule = svn_wc_schedule_normal;
 
   /* Prep these two paths early. */
-  pristine_copy = svn_wc__text_base_path (path, FALSE, pool);
+  SVN_ERR (svn_wc__uncompressed_text_base_path (path, FALSE, &pristine_copy, 
+                                                pool));
   empty_file = svn_wc__empty_file_path (path, pool);
 
   switch (schedule)
@@ -548,7 +549,8 @@
           const char *translated;
           svn_error_t *err, *err2 = SVN_NO_ERROR;
 
-          pristine_copy = svn_wc__text_base_path (path, FALSE, pool);   
+          SVN_ERR (svn_wc__uncompressed_text_base_path (path, FALSE, 
+                                                        &pristine_copy, pool));
 
           /* Note that this might be the _second_ time we translate
              the file, as svn_wc_text_modified_p() might have used a
@@ -806,8 +808,9 @@
       if (eb->reverse_order)
         {
           /* Whenever showing a deletion, we show the text-base vanishing. */
-          const char *textbase = svn_wc__text_base_path (full_path,
-                                                         FALSE, pool);
+          const char *textbase;
+          SVN_ERR (svn_wc__uncompressed_text_base_path (full_path, FALSE, 
+                                                        &textbase, pool));
 
           SVN_ERR (pb->edit_baton->callbacks->file_deleted
                    (NULL, NULL, full_path,
@@ -1088,7 +1091,7 @@
 
   {
     const char *tmp_path;
-
+    
     apr_file_name_get (&tmp_path, b->temp_file);
     svn_txdelta_apply (svn_stream_from_aprfile (b->original_file, b->pool),
                        svn_stream_from_aprfile (b->temp_file, b->pool),
@@ -1170,9 +1173,11 @@
              file is deleted. */
           svn_error_t *err1, *err2 = SVN_NO_ERROR;
           const char *localfile;
+          svn_boolean_t ignored;
 
           if (eb->use_text_base)
-            localfile = svn_wc__text_base_path (b->path, FALSE, b->pool);
+            SVN_ERR (svn_wc__real_text_base_path (b->path, FALSE, &localfile, 
+                                                  &ignored, b->pool));
           else
             /* a detranslated version of the working file */
             SVN_ERR (svn_wc_translated_file (&localfile, b->path, adm_access,
Index: subversion/libsvn_wc/copy.c
===================================================================
--- subversion/libsvn_wc/copy.c	(revision 7381)
+++ subversion/libsvn_wc/copy.c	(working copy)
@@ -204,8 +204,15 @@
     const char *src_wprop, *src_bprop, *dst_wprop, *dst_bprop;
 
     /* Discover the paths to the two text-base files */
-    const char *src_txtb = svn_wc__text_base_path (src_path, FALSE, pool);
-    const char *dst_txtb = svn_wc__text_base_path (dst_path, FALSE, pool);
+    const char *src_txtb, *dst_txtb;
+	svn_boolean_t src_txtb_compressed;
+	
+	SVN_ERR (svn_wc__real_text_base_path (src_path, FALSE, &src_txtb, 
+										  &src_txtb_compressed, pool));
+    if (src_txtb_compressed)
+	  dst_txtb = svn_wc__text_base_compressed_path (dst_path, FALSE, pool);
+	else
+	  dst_txtb = svn_wc__text_base_path (dst_path, FALSE, pool);
 
     /* Discover the paths to the four prop files */
     SVN_ERR (svn_wc__prop_path (&src_wprop, src_path, 
Index: subversion/libsvn_wc/wc.h
===================================================================
--- subversion/libsvn_wc/wc.h	(revision 7381)
+++ subversion/libsvn_wc/wc.h	(working copy)
@@ -25,6 +25,7 @@
 
 #include "svn_types.h"
 #include "svn_error.h"
+#include "svn_io.h"
 #include "svn_wc.h"
 
 #ifdef __cplusplus
@@ -37,6 +38,7 @@
 #define SVN_WC__TEXT_REJ_EXT  ".rej"
 #define SVN_WC__PROP_REJ_EXT  ".prej"
 #define SVN_WC__BASE_EXT      ".svn-base" /* for text and prop bases */
+#define SVN_WC__BASE_EXT_GZ   (SVN_WC__BASE_EXT SVN_IO_COMPRESS_SUFFIX)
 #define SVN_WC__WORK_EXT      ".svn-work" /* for working propfiles */
 
 
Index: subversion/libsvn_wc/adm_crawler.c
===================================================================
--- subversion/libsvn_wc/adm_crawler.c	(revision 7381)
+++ subversion/libsvn_wc/adm_crawler.c	(working copy)
@@ -53,13 +53,14 @@
    USE_COMMIT_TIMES is set, then set working file's timestamp to
    last-commit-time.  Either way, set entry-timestamp to match that of
    the working file when all is finished. */
+
 static svn_error_t *
 restore_file (const char *file_path,
               svn_wc_adm_access_t *adm_access,
               svn_boolean_t use_commit_times,
               apr_pool_t *pool)
 {
-  const char *text_base_path, *tmp_text_base_path;
+  const char *text_base_path;
   svn_subst_keywords_t *keywords;
   const char *eol;
   const svn_wc_entry_t *entry;
@@ -68,29 +69,24 @@
   const char *bname;
   apr_uint32_t modify_flags = 0;
 
-  text_base_path = svn_wc__text_base_path (file_path, FALSE, pool);
-  tmp_text_base_path = svn_wc__text_base_path (file_path, TRUE, pool);
+  SVN_ERR (svn_wc__uncompressed_text_base_path (file_path, FALSE, 
+                                                &text_base_path, pool));
   bname = svn_path_basename (file_path, pool);
 
-  SVN_ERR (svn_io_copy_file (text_base_path, tmp_text_base_path,
-                             FALSE, pool));
-
   SVN_ERR (svn_wc__get_eol_style (NULL, &eol, file_path, adm_access, pool));
   SVN_ERR (svn_wc__get_keywords (&keywords,
                                  file_path, adm_access, NULL, pool));
   
-  /* When copying the tmp-text-base out to the working copy, make
+  /* When copying the text-base out to the working copy, make
      sure to do any eol translations or keyword substitutions,
      as dictated by the property values.  If these properties
      are turned off, then this is just a normal copy. */
-  SVN_ERR (svn_subst_copy_and_translate (tmp_text_base_path,
+  SVN_ERR (svn_subst_copy_and_translate (text_base_path,
                                          file_path,
                                          eol, FALSE, /* don't repair */
                                          keywords,
                                          TRUE, /* expand keywords */
                                          pool));
-  
-  SVN_ERR (svn_io_remove_file (tmp_text_base_path, pool));
 
   /* If necessary, tweak the new working file's executable bit. */
   SVN_ERR (svn_wc__maybe_set_executable (NULL, file_path, adm_access, pool));
@@ -630,9 +626,11 @@
       /* For backwards compatibility, no checksum means assume a match. */
       if (ent->checksum)
         {
-          const char *tb = svn_wc__text_base_path (path, FALSE, pool);
+          const char *tb;
           unsigned char tb_digest[MD5_DIGESTSIZE];
 
+          SVN_ERR (svn_wc__uncompressed_text_base_path (path, FALSE, &tb, 
+                                                        pool));
           SVN_ERR (svn_io_file_checksum (tb_digest, tb, pool));
           base_digest_hex = svn_md5_digest_to_cstring (tb_digest, pool);
 
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c	(revision 7381)
+++ subversion/libsvn_wc/log.c	(working copy)
@@ -432,9 +432,33 @@
   return SVN_NO_ERROR;
 }
 
+/* Compress file */
+static svn_error_t *
+log_do_compress (struct log_runner *loggy, const char *name)
+{
+  const char *full_path
+    = svn_path_join (svn_wc_adm_access_path (loggy->adm_access),
+                     name, loggy->pool);
+  const char *compress_path = apr_pstrcat (loggy->pool, full_path, 
+                                           SVN_IO_COMPRESS_SUFFIX, NULL);
+  SVN_ERR (svn_io_set_file_read_write (compress_path, TRUE, loggy->pool));
+  SVN_ERR (svn_io_file_compress (full_path, loggy->pool));
+  
+  return SVN_NO_ERROR;
+}
 
+/* Decompress file */
+static svn_error_t *
+log_do_decompress (struct log_runner *loggy, const char *name)
+{
+  const char *full_path 
+    = svn_path_join (svn_wc_adm_access_path (loggy->adm_access),
+                     name, loggy->pool);
+  SVN_ERR (svn_io_file_decompress (full_path, loggy->pool));
+  
+  return SVN_NO_ERROR;
+}
 
-
 static svn_error_t *
 log_do_modify_entry (struct log_runner *loggy,
                      const char *name,
@@ -1146,6 +1170,12 @@
   else if (strcmp (eltname, SVN_WC__LOG_RM) == 0) {
     err = log_do_rm (loggy, name);
   }
+  else if (strcmp (eltname, SVN_WC__LOG_COMPRESS) == 0) {
+    err = log_do_compress (loggy, name);
+  }
+  else if (strcmp (eltname, SVN_WC__LOG_DECOMPRESS) == 0) {
+    err = log_do_decompress (loggy, name);
+  }
   else if (strcmp (eltname, SVN_WC__LOG_MERGE) == 0) {
     err = log_do_merge (loggy, name, atts);
   }
Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c	(revision 7381)
+++ subversion/libsvn_wc/adm_ops.c	(working copy)
@@ -277,7 +277,8 @@
       SVN_ERR (svn_io_check_path (latest_base, &kind, pool));
       if (kind == svn_node_none)
         {
-          latest_base = svn_wc__text_base_path (path, FALSE, pool);
+          SVN_ERR (svn_wc__uncompressed_text_base_path (path, FALSE, 
+                                                        &latest_base, pool));
           SVN_ERR (svn_io_check_path (latest_base, &kind, pool));
         }
 
@@ -1256,9 +1257,10 @@
              file. */
           svn_subst_keywords_t *keywords;
           const char *eol;
-          
-          base_thing = svn_wc__text_base_path (fullpath, 0, pool);
 
+          SVN_ERR (svn_wc__uncompressed_text_base_path (fullpath, FALSE, 
+                                                        &base_thing, pool));
+
           SVN_ERR (svn_wc__get_eol_style (NULL, &eol, fullpath, adm_access,
                                           pool));
           SVN_ERR (svn_wc__get_keywords (&keywords, fullpath, adm_access, NULL,
@@ -1685,7 +1687,8 @@
         const char *svn_thang;
 
         /* Text base. */
-        svn_thang = svn_wc__text_base_path (full_path, 0, pool);
+        SVN_ERR (svn_wc__real_text_base_path (full_path, 0, &svn_thang, 
+                                              NULL, pool));
         SVN_ERR (svn_io_set_file_read_write (svn_thang, TRUE, pool));
         SVN_ERR (remove_file_if_present (svn_thang, pool));
 
Index: subversion/libsvn_wc/adm_files.c
===================================================================
--- subversion/libsvn_wc/adm_files.c	(revision 7381)
+++ subversion/libsvn_wc/adm_files.c	(working copy)
@@ -29,6 +29,7 @@
 #include <apr_file_io.h>
 #include <apr_time.h>
 #include <apr_strings.h>
+#include "svn_pools.h"
 #include "svn_types.h"
 #include "svn_string.h"
 #include "svn_error.h"
@@ -238,7 +239,6 @@
   return SVN_NO_ERROR;
 }
 
-
 
 /*** Syncing files in the adm area. ***/
 
@@ -281,9 +281,27 @@
 svn_wc__sync_text_base (const char *path, apr_pool_t *pool)
 {
   const char *parent_path, *base_name;
+  const char *tb, *tmp_tb, *extension;
+  svn_boolean_t tb_compressed, tmp_tb_compressed;
+
   svn_path_split (path, &parent_path, &base_name, pool);
+  
+  SVN_ERR (svn_wc__real_text_base_path (path, FALSE, &tb, &tb_compressed, 
+                                        pool));
+  SVN_ERR (svn_wc__real_text_base_path (path, TRUE, &tmp_tb, 
+                                        &tmp_tb_compressed, pool));
+  if (tb_compressed != tmp_tb_compressed)
+    {
+      if (tmp_tb_compressed)
+        SVN_ERR (svn_io_file_decompress (tmp_tb, pool));
+      else
+        SVN_ERR (svn_io_file_compress (tmp_tb, pool));
+    }
+  
+  extension = tb_compressed ? SVN_WC__BASE_EXT_GZ : SVN_WC__BASE_EXT;
+  
   return sync_adm_file (parent_path,
-                        SVN_WC__BASE_EXT,
+                        extension,
                         pool,
                         SVN_WC__ADM_TEXT_BASE,
                         base_name,
@@ -305,9 +323,127 @@
                                SVN_WC__ADM_TEXT_BASE,
                                base_name,
                                NULL);
+  
 }
 
+const char *
+svn_wc__text_base_compressed_path(const char *path,
+                                  svn_boolean_t tmp,
+                                  apr_pool_t *pool)
+{
+  const char *newpath, *base_name;
 
+  svn_path_split (path, &newpath, &base_name, pool);
+  return extend_with_adm_name (newpath,
+                               SVN_WC__BASE_EXT_GZ,
+                               tmp,
+                               pool,
+                               SVN_WC__ADM_TEXT_BASE,
+                               base_name,
+                               NULL);
+}
+
+struct tmp_cleaner_t {
+  const char *tmp_file;
+  apr_pool_t *pool;
+};
+
+
+static apr_status_t
+cleanup_uncompressed_tmp (void *arg)
+{
+  svn_error_t *err = SVN_NO_ERROR;
+  apr_status_t status;
+  struct tmp_cleaner_t *cleaner = arg;
+
+  err = svn_io_remove_file (cleaner->tmp_file, cleaner->pool);
+  status = err != SVN_NO_ERROR ? err->apr_err : APR_SUCCESS;
+  svn_error_clear (err);
+  
+  if (APR_STATUS_IS_SUCCESS (status) || APR_STATUS_IS_ENOENT (status))
+    status = APR_SUCCESS;
+  
+  return status;
+}
+
+svn_error_t *
+svn_wc__uncompressed_text_base_path(const char *path, 
+                                    svn_boolean_t tmp,
+                                    const char **newpath,
+                                    apr_pool_t *pool)
+{
+  svn_boolean_t compressed;
+  char *compressed_path;
+  const char *tmp_path, *npath, *suffix;
+  struct tmp_cleaner_t *cleaner;
+  svn_node_kind_t kind;
+  
+  SVN_ERR (svn_wc__real_text_base_path (path, FALSE, &npath, &compressed, 
+                                        pool));
+  
+  if (! compressed)
+    {
+      *newpath = npath;
+    }
+  else
+    {
+      compressed_path = 
+        apr_pstrcat (pool, svn_wc__text_base_compressed_path (path, tmp, 
+                                                              pool), 
+                     ".tmp", NULL);
+      suffix = tmp ? ".uncomptmp" : ".uncomp";
+      tmp_path = apr_pstrcat (pool, 
+                              svn_wc__text_base_path (path, TRUE, pool),
+                              suffix, NULL);
+      SVN_ERR (svn_io_check_path (tmp_path, &kind, pool));
+      
+      if (kind == svn_node_none) 
+        {
+          cleaner = apr_palloc (pool, sizeof (struct tmp_cleaner_t));
+          cleaner->tmp_file = tmp_path;
+          cleaner->pool = pool;
+          apr_pool_cleanup_register (pool, cleaner, cleanup_uncompressed_tmp, 
+                                     NULL);
+      
+          SVN_ERR (svn_io_copy_file (npath, compressed_path, TRUE, pool));
+          SVN_ERR (svn_io_file_decompress_to_file (compressed_path, 
+                                                   tmp_path, pool));
+        }
+      
+      *newpath = tmp_path;
+    }
+  
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__real_text_base_path(const char *path,
+                            svn_boolean_t tmp,
+                            const char **newpath,
+                            svn_boolean_t *compressed,
+                            apr_pool_t *pool)
+{
+  const char *compressed_path;
+  svn_node_kind_t kind;
+  
+  compressed_path = svn_wc__text_base_compressed_path (path, tmp, pool);
+  SVN_ERR (svn_io_check_path (compressed_path, &kind, pool));
+  if (kind == svn_node_none)
+    {
+      *newpath = svn_wc__text_base_path (path, tmp, pool);
+      if (compressed)
+        *compressed = FALSE;
+    }
+  else
+    {
+      *newpath = compressed_path;
+      if (compressed)
+        *compressed = TRUE;
+    }
+  return SVN_NO_ERROR;
+}
+
+
 static svn_error_t *
 prop_path_internal (const char **prop_path,
                     const char *path,
@@ -432,7 +568,7 @@
 {
   svn_error_t *err = SVN_NO_ERROR;
   va_list ap;
-
+  
   /* If we're writing, always do it to a tmp file. */
   if (flags & APR_WRITE)
     {
@@ -622,10 +758,23 @@
                         apr_int32_t flags,
                         apr_pool_t *pool)
 {
-  const char *parent_path, *base_name;
+  const char *parent_path, *base_name, *extension;
+  svn_boolean_t compressed;
+  
+  SVN_ERR (svn_wc__real_text_base_path (path, FALSE, &parent_path, 
+                                        &compressed, pool));
+  extension = compressed ? SVN_WC__BASE_EXT_GZ : SVN_WC__BASE_EXT;
+    
   svn_path_split (path, &parent_path, &base_name, pool);
-  return open_adm_file (handle, parent_path, SVN_WC__BASE_EXT, APR_OS_DEFAULT,
-                        flags, pool, SVN_WC__ADM_TEXT_BASE, base_name, NULL);
+  SVN_ERR (open_adm_file (handle, parent_path, extension, APR_OS_DEFAULT,
+                        flags, pool, SVN_WC__ADM_TEXT_BASE, base_name, NULL));
+  
+  /* If compressed, mark the handle as compressed so the compressed
+     stream wrapper will work. */
+  if (compressed)
+    return svn_stream_mark_apr_file_compressed(*handle, pool);
+  else
+    return SVN_NO_ERROR;
 }
 
 
@@ -635,9 +784,14 @@
                          int write,
                          apr_pool_t *pool)
 {
-  const char *parent_path, *base_name;
+  const char *parent_path, *base_name, *extension;
+  svn_boolean_t compressed;
+  
+  SVN_ERR (svn_stream_is_apr_file_marked_compressed (fp, &compressed, pool));
+  extension = compressed ? SVN_WC__BASE_EXT_GZ : SVN_WC__BASE_EXT;
+
   svn_path_split (path, &parent_path, &base_name, pool);
-  return close_adm_file (fp, parent_path, SVN_WC__BASE_EXT, write, pool,
+  return close_adm_file (fp, parent_path, extension, write, pool,
                          SVN_WC__ADM_TEXT_BASE, base_name, NULL);
 }
 
Index: subversion/libsvn_wc/log.h
===================================================================
--- subversion/libsvn_wc/log.h	(revision 7381)
+++ subversion/libsvn_wc/log.h	(working copy)
@@ -65,6 +65,12 @@
    properties of NAME. */
 #define SVN_WC__LOG_CP_AND_DETRANSLATE    "cp-and-detranslate"
 
+/* Compress file SVN_WC__LOG_ATTR_NAME. */
+#define SVN_WC__LOG_COMPRESS            "compress"
+
+/* Decompress file SVN_WC__LOG_ATTR_NAME. */
+#define SVN_WC__LOG_DECOMPRESS          "decompress"
+
 /* Remove file SVN_WC__LOG_ATTR_NAME. */
 #define SVN_WC__LOG_RM                  "rm"
 
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(revision 7381)
+++ subversion/libsvn_wc/update_editor.c	(working copy)
@@ -86,6 +86,9 @@
   /* Non-null if this is a 'switch' operation. */
   const char *switch_url;
 
+  /* Should the text-base be compressed? */
+  svn_boolean_t compress_text_base;
+  
   /* External diff3 to use for merges (can be null, in which case
      internal merge code is used). */
   const char *diff3_cmd;
@@ -1421,8 +1424,9 @@
       unsigned char digest[MD5_DIGESTSIZE];
       const char *hex_digest;
       const char *tb;
-      
-      tb = svn_wc__text_base_path (fb->path, FALSE, pool);
+
+      SVN_ERR (svn_wc__uncompressed_text_base_path (fb->path, FALSE, &tb,
+                                                    pool));
       SVN_ERR (svn_io_file_checksum (digest, tb, pool));
       hex_digest = svn_md5_digest_to_cstring (digest, pool);
       
@@ -1638,6 +1642,7 @@
               svn_revnum_t copyfrom_rev,
               const char *diff3_cmd,
               const char *timestamp_string,
+              svn_boolean_t compress_text_base,
               apr_pool_t *pool)
 {
   apr_file_t *log_fp = NULL;
@@ -1645,7 +1650,7 @@
   char *revision_str = NULL;
   const char *parent_dir, *base_name;
   svn_stringbuf_t *log_accum;
-  svn_boolean_t is_locally_modified;
+  svn_boolean_t is_locally_modified, is_compressed, is_new_compressed;
   svn_boolean_t magic_props_changed = FALSE;
   apr_array_header_t *regular_props = NULL, *wc_props = NULL,
     *entry_props = NULL;
@@ -1653,7 +1658,8 @@
   /* The code flow does not depend upon these being set to NULL, but
      it removes a gcc 3.1 `might be used uninitialized in this
      function' warning. */
-  const char *txtb = NULL, *tmp_txtb = NULL;
+  const char *txtb = NULL, *tmp_txtb = NULL, *real_txtb = NULL,
+    *compressed_txtb = NULL, *compressed_tmp_txtb = NULL;
 
   /* Start by splitting FILE_PATH. */
   svn_path_split (file_path, &parent_dir, &base_name, pool);
@@ -1737,8 +1743,10 @@
      -- that's where the rest of this code wants it to be anyway. */
   if (new_text_path)
     {
-      const char *final_location = 
-        svn_wc__text_base_path (file_path, TRUE, pool);
+      const char *final_location;  
+        
+      SVN_ERR (svn_wc__real_text_base_path (file_path, TRUE, &final_location,
+                                            &is_new_compressed, pool));
       
       /* Only do the 'move' if NEW_TEXT_PATH isn't -already-
          pointing to parent_dir/.svn/tmp/text-base/basename.  */
@@ -1847,6 +1855,21 @@
     {
       txtb     = svn_wc__text_base_path (base_name, FALSE, pool);
       tmp_txtb = svn_wc__text_base_path (base_name, TRUE, pool);
+      compressed_txtb = svn_wc__text_base_compressed_path (base_name, FALSE, 
+                                                           pool);
+      compressed_tmp_txtb = svn_wc__text_base_compressed_path (base_name,
+                                                               TRUE, pool);
+      SVN_ERR (svn_wc__real_text_base_path (file_path, FALSE, &real_txtb,
+                                            &is_compressed, pool));
+      
+      /* If the new_text_path is compressed, decompress it first. */
+      if (is_new_compressed)
+        svn_xml_make_open_tag (&log_accum, pool,
+                               svn_xml_self_closing,
+                               SVN_WC__LOG_DECOMPRESS, 
+                               SVN_WC__LOG_ATTR_NAME,
+                               compressed_tmp_txtb,
+                               NULL);
     }
   else if (magic_props_changed) /* no new text base, but... */
     {
@@ -1967,6 +1990,17 @@
               const char *oldrev_str, *newrev_str;
               const svn_wc_entry_t *e;
               
+              /* If our text-base is compressed, we need to decompress
+                 it before we try to do the merge */
+              if (is_compressed)
+                svn_xml_make_open_tag (&log_accum,
+                                       pool,
+                                       svn_xml_self_closing,
+                                       SVN_WC__LOG_DECOMPRESS,
+                                       SVN_WC__LOG_ATTR_NAME,
+                                       compressed_txtb,
+                                       NULL);
+              
               /* Create strings representing the revisions of the
                  old and new text-bases. */
               SVN_ERR (svn_wc_entry (&e, file_path, adm_access, FALSE, pool));
@@ -2000,6 +2034,16 @@
                  marked "Conflicted" and will track either 2 or 3 new
                  temporary fulltext files that resulted. */
               
+              /* If our text-base was compressed, remove the
+                 decompressed file */
+              if (is_compressed)
+                svn_xml_make_open_tag (&log_accum,
+                                       pool,
+                                       svn_xml_self_closing,
+                                       SVN_WC__LOG_RM,
+                                       SVN_WC__LOG_ATTR_NAME, txtb,
+                                       NULL);
+              
             } /* end: working file exists and has mods */
         } /* end: working file has mods */
     }  /* end:  "textual" merging process */
@@ -2047,7 +2091,7 @@
     }
 
   if (new_text_path)
-    {
+    { 
       /* Write out log commands to set up the new text base and its
          checksum. */
 
@@ -2061,17 +2105,34 @@
                              txtb,
                              NULL);
       
+      if (compress_text_base)
+        svn_xml_make_open_tag (&log_accum,
+                               pool,
+                               svn_xml_self_closing,
+                               SVN_WC__LOG_COMPRESS,
+                               SVN_WC__LOG_ATTR_NAME,
+                               txtb,
+                               NULL);
+
       svn_xml_make_open_tag (&log_accum,
                              pool,
                              svn_xml_self_closing,
                              SVN_WC__LOG_READONLY,
                              SVN_WC__LOG_ATTR_NAME,
-                             txtb,
+                             compress_text_base ? compressed_txtb : txtb,
                              NULL);
 
       {
         unsigned char digest[MD5_DIGESTSIZE];
-        SVN_ERR (svn_io_file_checksum (digest, new_text_path, pool));
+        const char *uncompressed_tb;
+
+        if (is_new_compressed)
+          SVN_ERR (svn_wc__uncompressed_text_base_path (file_path, TRUE, 
+                                                        &uncompressed_tb, 
+                                                        pool));
+        else
+          uncompressed_tb = new_text_path;
+        SVN_ERR (svn_io_file_checksum (digest, uncompressed_tb, pool));
         svn_xml_make_open_tag (&log_accum,
                                pool,
                                svn_xml_self_closing,
@@ -2166,6 +2227,7 @@
 {
   struct file_baton *fb = file_baton;
   const char *new_text_path = NULL, *parent_path;
+  svn_boolean_t ignored;
   apr_array_header_t *propchanges = NULL;
   svn_wc_notify_state_t content_state, prop_state;
   svn_wc_adm_access_t *adm_access;
@@ -2173,8 +2235,9 @@
   /* window-handler assembles new pristine text in .svn/tmp/text-base/  */
   if (fb->text_changed)
     {
-      new_text_path = svn_wc__text_base_path (fb->path, TRUE, pool);
-
+      SVN_ERR (svn_wc__real_text_base_path (fb->path, TRUE, &new_text_path,
+                                            &ignored, pool));
+      
       if (text_checksum)
         {
           const char *real_sum = svn_md5_digest_to_cstring (fb->digest, pool);
@@ -2212,6 +2275,7 @@
                          SVN_INVALID_REVNUM,
                          fb->edit_baton->diff3_cmd,
                          fb->last_changed_date,
+                         fb->edit_baton->compress_text_base,
                          pool));
 
   /* We have one less referrer to the directory's bump information. */
@@ -2330,6 +2394,7 @@
              svn_cancel_func_t cancel_func,
              void *cancel_baton,
              const char *diff3_cmd,
+             svn_boolean_t compress_text_base,
              const svn_delta_editor_t **editor,
              void **edit_baton,
              svn_wc_traversal_info_t *traversal_info,
@@ -2352,6 +2417,7 @@
   eb->notify_func     = notify_func;
   eb->notify_baton    = notify_baton;
   eb->traversal_info  = traversal_info;
+  eb->compress_text_base = compress_text_base;
   eb->diff3_cmd       = diff3_cmd;
   eb->cancel_func     = cancel_func;
   eb->cancel_baton    = cancel_baton;
@@ -2394,6 +2460,7 @@
                           svn_cancel_func_t cancel_func,
                           void *cancel_baton,
                           const char *diff3_cmd,
+                          svn_boolean_t compress_text_base,
                           const svn_delta_editor_t **editor,
                           void **edit_baton,
                           svn_wc_traversal_info_t *traversal_info,
@@ -2402,7 +2469,7 @@
   return make_editor (anchor, svn_wc_adm_access_path (anchor),
                       target, target_revision, use_commit_times, NULL,
                       recurse, notify_func, notify_baton,
-                      cancel_func, cancel_baton, diff3_cmd,
+                      cancel_func, cancel_baton, diff3_cmd, compress_text_base,
                       editor, edit_baton, traversal_info, pool);
 }
 
@@ -2419,6 +2486,7 @@
                           svn_cancel_func_t cancel_func,
                           void *cancel_baton,
                           const char *diff3_cmd,
+                          svn_boolean_t compress_text_base,
                           const svn_delta_editor_t **editor,
                           void **edit_baton,
                           svn_wc_traversal_info_t *traversal_info,
@@ -2429,8 +2497,8 @@
   return make_editor (anchor, svn_wc_adm_access_path (anchor),
                       target, target_revision, use_commit_times, switch_url,
                       recurse, notify_func, notify_baton,
-                      cancel_func, cancel_baton, diff3_cmd,
-                      editor, edit_baton,
+                      cancel_func, cancel_baton, diff3_cmd, 
+                      compress_text_base, editor, edit_baton,
                       traversal_info, pool);
 }
 
@@ -2703,6 +2771,7 @@
                          copyfrom_rev,
                          NULL,
                          NULL,
+                         FALSE,
                          pool));
 
   return SVN_NO_ERROR;
Index: subversion/libsvn_wc/adm_files.h
===================================================================
--- subversion/libsvn_wc/adm_files.h	(revision 7381)
+++ subversion/libsvn_wc/adm_files.h	(working copy)
@@ -72,7 +72,30 @@
                                     svn_boolean_t tmp,
                                     apr_pool_t *pool);
 
+/* Return a path to PATH's compressed text-base file. */ 
+const char *svn_wc__text_base_compressed_path(const char *path,
+                                              svn_boolean_t tmp,
+                                              apr_pool_t *pool);
 
+/* If the text-base is uncompressed, return the path in NEWPATH. If
+   compressed, decompress the file to the tmp area and return the path
+   to it in NEWPATH, and register a cleanup handler on the pool to
+   remove that tmp file. */
+svn_error_t *svn_wc__uncompressed_text_base_path(const char *path, 
+                                                 svn_boolean_t tmp,
+                                                 const char **newpath,
+                                                 apr_pool_t *pool);
+
+/* Place the path to the actual text-base (compressed or uncompressed)
+   in NEWPATH. COMPRESSED is TRUE if the text-base is compressed,
+   FALSE otherwise. */
+svn_error_t *svn_wc__real_text_base_path(const char *path,
+                                         svn_boolean_t tmp,
+                                         const char **newpath,
+                                         svn_boolean_t *compressed,
+                                         apr_pool_t *pool);
+
+
 /* Return a path to the 'wcprop' file for PATH, possibly in TMP area.
    ADM_ACCESS is an access baton set that contains PATH. */
 svn_error_t *svn_wc__wcprop_path (const char **wcprop_path,
Index: subversion/libsvn_wc/questions.c
===================================================================
--- subversion/libsvn_wc/questions.c	(revision 7381)
+++ subversion/libsvn_wc/questions.c	(working copy)
@@ -267,7 +267,8 @@
   /* If there's no text-base file, we have to assume the working file
      is modified.  For example, a file scheduled for addition but not
      yet committed. */
-  textbase_filename = svn_wc__text_base_path (filename, 0, subpool);
+  SVN_ERR (svn_wc__uncompressed_text_base_path (filename, FALSE, 
+                                                &textbase_filename, subpool));
   SVN_ERR (svn_io_check_path (textbase_filename, &kind, subpool));
   if (kind != svn_node_file)
     {
Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c	(revision 7381)
+++ subversion/libsvn_subr/io.c	(working copy)
@@ -467,7 +467,98 @@
 #endif
 }
 
+
+/*** Compress and decompress file ***/
 
+static svn_error_t *
+compress_or_decompress(const char *src_file, const char *dst_file, 
+                       svn_boolean_t compress, apr_pool_t *pool)
+{
+  apr_file_t *src, *dst;
+  svn_stream_t *in_stream, *out_stream;
+  char *buf;
+  apr_size_t read, len;
+
+  SVN_ERR (svn_io_file_open (&src, src_file, APR_READ,
+                             APR_OS_DEFAULT, pool));
+  SVN_ERR (svn_io_file_open (&dst, dst_file, APR_WRITE | APR_CREATE
+                             | APR_TRUNCATE, APR_OS_DEFAULT, pool));
+  
+  in_stream = svn_stream_from_aprfile (src, pool);
+  out_stream = svn_stream_from_aprfile (dst, pool);
+  if (compress)
+    out_stream = svn_stream_compressed (out_stream, pool);
+  else 
+    in_stream = svn_stream_compressed (in_stream, pool);
+  
+  buf = apr_palloc (pool, SVN_STREAM_CHUNK_SIZE);
+  
+  do {
+    len = SVN_STREAM_CHUNK_SIZE;
+    SVN_ERR (svn_stream_read (in_stream, buf, &len));
+    read = len;
+    SVN_ERR (svn_stream_write (out_stream, buf, &len));
+  } while (read >= SVN_STREAM_CHUNK_SIZE);
+  
+  SVN_ERR (svn_stream_close (in_stream));
+  SVN_ERR (svn_stream_close (out_stream));
+  apr_file_close (src);
+  apr_file_close (dst);
+  SVN_ERR (svn_io_remove_file (src_file, pool));
+  
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_io_file_compress (const char *file, apr_pool_t *pool)
+{
+#ifdef SVN_HAVE_ZLIB
+  apr_file_t *src, *dst;
+  char *dst_file;
+  
+  dst_file = apr_pstrcat (pool, file, SVN_IO_COMPRESS_SUFFIX, NULL);
+  
+  return compress_or_decompress (file, dst_file, TRUE, pool);
+#else
+  return svn_error_create (APR_ENOTIMPL, NULL, "no zlib support");
+#endif
+}
+
+svn_error_t *
+svn_io_file_decompress_to_file (const char *file, const char *dst_file,
+                                apr_pool_t *pool)
+{
+#ifdef SVN_HAVE_ZLIB
+  return compress_or_decompress (file, dst_file, FALSE, pool);
+#else
+  return svn_error_create (APR_ENOTIMPL, NULL, "no zlib support"); 
+#endif
+}
+
+svn_error_t *
+svn_io_file_decompress (const char *file, apr_pool_t *pool)
+{
+#ifdef SVN_HAVE_ZLIB
+  char *dst_file;
+  int len, suffix_len;
+  
+  len = strlen(file);
+  suffix_len = strlen (SVN_IO_COMPRESS_SUFFIX);
+  if (len <= suffix_len || apr_strnatcmp (SVN_IO_COMPRESS_SUFFIX, 
+                                          file + (len - suffix_len)) != 0)
+    return svn_error_createf (SVN_ERR_BAD_FILENAME, NULL, 
+                              "svn_io_file_decompress: Bad filename '%s'",
+                              file);
+  
+  dst_file = apr_pstrdup (pool, file);
+  dst_file[len - suffix_len] = '\0';
+  
+  return compress_or_decompress (file, dst_file, FALSE, pool);
+#else
+  return svn_error_create (APR_ENOTIMPL, NULL, "no zlib support");
+#endif
+}
+
 
 /*** Modtime checking. ***/
 
Index: subversion/libsvn_subr/stream.c
===================================================================
--- subversion/libsvn_subr/stream.c	(revision 7381)
+++ subversion/libsvn_subr/stream.c	(working copy)
@@ -36,6 +36,7 @@
 #include "svn_error.h"
 #include "svn_string.h"
 
+#define SVN_COMPRESSED "svn:compressed"
 
 struct svn_stream_t {
   void *baton;
@@ -215,7 +216,9 @@
 {
   struct baton_apr *btn = baton;
   apr_status_t status;
-
+  const char *name;
+  
+  apr_file_name_get (&name, btn->file); 
   status = apr_file_read_full (btn->file, buffer, *len, len);
   if (status && ! APR_STATUS_IS_EOF(status))
     return svn_error_create (status, NULL,
@@ -245,6 +248,9 @@
 {
   struct baton_apr *baton;
   svn_stream_t *stream;
+  svn_boolean_t compressed;
+  svn_error_t *err;
+  void *data;
 
   if (file == NULL)
     return svn_stream_empty(pool);
@@ -254,6 +260,16 @@
   stream = svn_stream_create (baton, pool);
   svn_stream_set_read (stream, read_handler_apr);
   svn_stream_set_write (stream, write_handler_apr);
+  
+  err = svn_stream_is_apr_file_marked_compressed (file, &compressed, pool);
+  if (err != SVN_NO_ERROR)
+    {
+      svn_error_clear (err);
+      stream = NULL;
+    }
+  else if (compressed)
+    stream = svn_stream_compressed (stream, pool);
+    
   return stream;
 }
 
@@ -375,7 +391,7 @@
 read_handler_gz (void *baton, char *buffer, apr_size_t *len)
 {
   struct zbaton *btn = baton;
-  int zerr;
+  int zerr = Z_OK;
 
   if (btn->in == NULL)
     {
@@ -546,6 +562,47 @@
 #endif /* SVN_HAVE_ZLIB */
 }
 
+svn_error_t *
+svn_stream_mark_apr_file_compressed (apr_file_t *file, apr_pool_t *pool)
+{
+  apr_status_t status;
+  const char *key, *name;
+
+  status = apr_file_name_get (&name, file);
+  if (! APR_STATUS_IS_SUCCESS (status))
+      return svn_error_create (status, NULL, "Error fetching file name");
+  key = apr_pstrcat (pool, SVN_COMPRESSED, ":", name, NULL);
+  status = apr_file_data_set (file, (void *) TRUE, key, NULL);
+  if (! APR_STATUS_IS_SUCCESS (status))
+    return svn_error_create (status, NULL, 
+                             "Unable to mark apr_file_t compressed");
+  
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_stream_is_apr_file_marked_compressed (apr_file_t *file, 
+                                          svn_boolean_t *compressed,
+                                          apr_pool_t *pool)
+{
+  apr_status_t err;
+  void *data = NULL;
+  const char *key, *name;
+
+  err = apr_file_name_get (&name, file);
+  if (! APR_STATUS_IS_SUCCESS (err))
+    return svn_error_create (err, NULL, "Error fetching file name");
+  key = apr_pstrcat (pool, SVN_COMPRESSED, ":", name, NULL);
+  /* Use apr's data method to see if this stream is compressed */
+  err = apr_file_data_get (&data, key, file);
+  if (APR_STATUS_IS_SUCCESS(err) && (data != NULL))
+    *compressed = TRUE;
+  else
+    *compressed = FALSE;
+  
+  return SVN_NO_ERROR;
+}
+
 
 /* Miscellaneous stream functions. */
 struct string_stream_baton
Index: subversion/libsvn_client/switch.c
===================================================================
--- subversion/libsvn_client/switch.c	(revision 7381)
+++ subversion/libsvn_client/switch.c	(working copy)
@@ -65,6 +65,7 @@
   void *ra_baton, *session;
   svn_ra_plugin_t *ra_lib;
   svn_revnum_t revnum;
+  svn_boolean_t compress_text_base;
   svn_error_t *err = SVN_NO_ERROR;
   svn_wc_adm_access_t *adm_access;
   const char *diff3_cmd;
@@ -83,6 +84,9 @@
   svn_config_get (cfg, &diff3_cmd, SVN_CONFIG_SECTION_HELPERS,
                   SVN_CONFIG_OPTION_DIFF3_CMD, NULL);
 
+  /* Get compress-text-base config */
+  compress_text_base = svn_client__compress_text_base(ctx->config);
+  
   /* See if the user wants last-commit timestamps instead of current ones. */
   svn_config_get (cfg, &commit_time_str, SVN_CONFIG_SECTION_MISCELLANY,
                   SVN_CONFIG_OPTION_USE_COMMIT_TIMES, NULL);
@@ -172,6 +176,7 @@
                                      ctx->notify_func, ctx->notify_baton,
                                      ctx->cancel_func, ctx->cancel_baton,
                                      diff3_cmd,
+                                     compress_text_base,
                                      &switch_editor, &switch_edit_baton,
                                      traversal_info, pool));
 
@@ -180,7 +185,6 @@
   SVN_ERR (ra_lib->do_switch (session, &reporter, &report_baton, revnum,
                               target, recurse, switch_url,
                               switch_editor, switch_edit_baton, pool));
-      
   /* Drive the reporter structure, describing the revisions within
      PATH.  When we call reporter->finish_report, the update_editor
      will be driven by svn_repos_dir_delta.
Index: subversion/libsvn_client/checkout.c
===================================================================
--- subversion/libsvn_client/checkout.c	(revision 7381)
+++ subversion/libsvn_client/checkout.c	(working copy)
@@ -54,6 +54,7 @@
   svn_wc_traversal_info_t *traversal_info = svn_wc_init_traversal_info (pool);
   svn_error_t *err = NULL;
   svn_revnum_t revnum;
+  svn_boolean_t compress_text_base;
   svn_boolean_t sleep_here = FALSE;
   svn_boolean_t *use_sleep = timestamp_sleep ? timestamp_sleep : &sleep_here;
 
@@ -61,6 +62,9 @@
   assert (path != NULL);
   assert (URL != NULL);
 
+  /* Get compress-text-base config */
+  compress_text_base = svn_client__compress_text_base (ctx->config);
+
   /* Fulfill the docstring promise of svn_client_checkout: */
   if ((revision->kind != svn_opt_revision_number)
       && (revision->kind != svn_opt_revision_date)
Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c	(revision 7381)
+++ subversion/libsvn_client/copy.c	(working copy)
@@ -747,7 +747,7 @@
   svn_revnum_t src_revnum;
   svn_wc_adm_access_t *adm_access;
   const char *src_uuid = NULL, *dst_uuid = NULL;
-  svn_boolean_t same_repositories;
+  svn_boolean_t same_repositories, compress_text_base;
   const char *auth_dir;
   svn_opt_revision_t revision;
 
Index: subversion/libsvn_client/update.c
===================================================================
--- subversion/libsvn_client/update.c	(revision 7381)
+++ subversion/libsvn_client/update.c	(working copy)
@@ -23,7 +23,9 @@
 /*** Includes. ***/
 
 #include <assert.h>
+#include <apr_strings.h>
 
+#include "svn_private_config.h"
 #include "svn_wc.h"
 #include "svn_client.h"
 #include "svn_string.h"
@@ -57,7 +59,7 @@
   svn_wc_traversal_info_t *traversal_info = svn_wc_init_traversal_info (pool);
   svn_wc_adm_access_t *adm_access;
   svn_boolean_t use_commit_times;
-  svn_boolean_t sleep_here = FALSE;
+  svn_boolean_t compress_text_base, sleep_here = FALSE;
   svn_boolean_t *use_sleep = timestamp_sleep ? timestamp_sleep : &sleep_here;
   const char *diff3_cmd;
   
@@ -110,8 +112,9 @@
       use_commit_times = FALSE;
   }
 
+  /* Get the text-base compression config. */
+  compress_text_base = svn_client__compress_text_base (ctx->config);
 
-
   /* Fetch the update editor.  If REVISION is invalid, that's okay;
      the RA driver will call editor->set_target_revision later on. */
   SVN_ERR (svn_wc_get_update_editor (adm_access,
@@ -122,6 +125,7 @@
                                      ctx->notify_func, ctx->notify_baton,
                                      ctx->cancel_func, ctx->cancel_baton,
                                      diff3_cmd,
+                                     compress_text_base,
                                      &update_editor, &update_edit_baton,
                                      traversal_info,
                                      pool));
@@ -208,3 +212,24 @@
 {
   return svn_client__update_internal (path, revision, recurse, NULL, ctx, pool);
 }
+
+svn_boolean_t
+svn_client__compress_text_base(apr_hash_t *config)
+{
+  
+  const char *str;
+  svn_boolean_t compress;
+  svn_config_t *cfg = config
+    ? apr_hash_get (config, SVN_CONFIG_CATEGORY_CONFIG,  
+                    APR_HASH_KEY_STRING) : NULL;
+  
+  svn_config_get (cfg, &str, SVN_CONFIG_SECTION_MISCELLANY,
+                  SVN_CONFIG_OPTION_COMPRESS_TEXT_BASE, "no");
+  
+#ifdef SVN_HAVE_ZLIB
+  return apr_strnatcasecmp(str, "yes") == 0;
+#else
+  return FALSE;
+#endif
+
+}
Index: subversion/libsvn_client/client.h
===================================================================
--- subversion/libsvn_client/client.h	(revision 7381)
+++ subversion/libsvn_client/client.h	(working copy)
@@ -296,6 +296,10 @@
                                svn_client_ctx_t *ctx,
                                apr_pool_t *pool);
 
+/* Get the compress-text-base from the config file */
+svn_boolean_t
+svn_client__compress_text_base(apr_hash_t *config);
+
 /* ---------------------------------------------------------------- */
 
 /*** Editor for repository diff ***/


