Index: include/svn_wc.h
===================================================================
--- include/svn_wc.h	(revision 15261)
+++ include/svn_wc.h	(working copy)
@@ -542,7 +542,10 @@
   svn_wc_notify_failed_lock,
 
   /** @since New in 1.2.  Failed to unlock a path. */
-  svn_wc_notify_failed_unlock
+  svn_wc_notify_failed_unlock,
+
+  /** @since New in 1.3.  Got a takeover in an update. */
+  svn_wc_notify_update_takeover,
 } svn_wc_notify_action_t;
 
 
@@ -2176,6 +2179,22 @@
  * FALSE, the working files will be touched with the 'now' time.
  *
  */
+svn_error_t *svn_wc_get_update_editor3 (svn_revnum_t *target_revision,
+                                        svn_wc_adm_access_t *anchor,
+                                        const char *target,
+                                        svn_boolean_t use_commit_times,
+                                        svn_boolean_t recurse,
+                                        svn_wc_notify_func2_t notify_func,
+                                        void *notify_baton,
+                                        svn_cancel_func_t cancel_func,
+                                        void *cancel_baton,
+                                        const char *diff3_cmd,
+                                        const svn_delta_editor_t **editor,
+                                        void **edit_baton,
+                                        svn_wc_traversal_info_t *ti,
+                                        apr_pool_t *pool,
+                                        svn_boolean_t taking_over);
+
 svn_error_t *svn_wc_get_update_editor2 (svn_revnum_t *target_revision,
                                         svn_wc_adm_access_t *anchor,
                                         const char *target,
Index: include/svn_client.h
===================================================================
--- include/svn_client.h	(revision 15261)
+++ include/svn_client.h	(working copy)
@@ -486,6 +486,18 @@
  * Use @a pool for any temporary allocation.
  */
 svn_error_t *
+svn_client_checkout3 (svn_revnum_t *result_rev,
+                      const char *URL,
+                      const char *path,
+                      const svn_opt_revision_t *peg_revision,
+                      const svn_opt_revision_t *revision,
+                      svn_boolean_t recurse,
+                      svn_boolean_t ignore_externals,
+                      svn_client_ctx_t *ctx,
+                      apr_pool_t *pool,
+                      svn_boolean_t taking_over);
+                      
+svn_error_t *
 svn_client_checkout2 (svn_revnum_t *result_rev,
                       const char *URL,
                       const char *path,
Index: libsvn_wc/update_editor.c
===================================================================
--- libsvn_wc/update_editor.c	(revision 15261)
+++ libsvn_wc/update_editor.c	(working copy)
@@ -107,6 +107,11 @@
   void *cancel_baton;
 
   apr_pool_t *pool;
+
+  /* When this boolean value is true, existing unversioned files will
+     be accepted, left untouched, and will not obstruct the update
+     process. */
+  svn_boolean_t taking_over;
 };
 
 
@@ -511,6 +516,9 @@
   /* Set if this file is new. */
   svn_boolean_t added;
 
+  /* Set if this file already existed. */
+  svn_boolean_t taken_over;
+
   /* This gets set if the file underwent a text change, which guides
      the code that syncs up the adm dir and working copy. */
   svn_boolean_t text_changed;
@@ -574,6 +582,7 @@
   f->bump_info    = pb->bump_info;
   f->added        = adding;
   f->dir_baton    = pb;
+  f->taken_over   = FALSE;
 
   /* No need to initialize f->digest, since we used pcalloc(). */
 
@@ -1473,10 +1482,15 @@
 
   /* If adding, there should be nothing with this name. */
   if (adding && (kind != svn_node_none))
-    return svn_error_createf
-      (SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
-       _("Failed to add file '%s': object of the same name already exists"),
-       svn_path_local_style (fb->path, pool));
+  {
+    if (eb->taking_over)
+      fb->taken_over = TRUE;
+    else
+      return svn_error_createf
+        (SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
+         _("Failed to add file '%s': object of the same name already exists"),
+         svn_path_local_style (fb->path, pool));
+  }
 
   /* sussman sez: If we're trying to add a file that's already in
      `entries' (but not on disk), that's okay.  It's probably because
@@ -1709,9 +1723,9 @@
      applied. */
   fb->prop_changed = 1;
 
-  /* Special case: if the file is added during a checkout, cache the
-     last-changed-date propval for future use. */
-  if (eb->use_commit_times
+  /* Special case: if the file is added during a checkout or taken over,
+     cache the last-changed-date propval for future use. */
+  if ((eb->use_commit_times || fb->taken_over)
       && (strcmp (name, SVN_PROP_ENTRY_COMMITTED_DATE) == 0))
     fb->last_changed_date = apr_pstrdup (fb->pool, value->data);
 
@@ -1815,7 +1829,8 @@
               svn_revnum_t copyfrom_rev,
               const char *diff3_cmd,
               const char *timestamp_string,
-              apr_pool_t *pool)
+              apr_pool_t *pool,
+              svn_boolean_t taken_over)
 {
   apr_file_t *log_fp = NULL;
   char *revision_str = NULL;
@@ -2029,8 +2044,11 @@
     *lock_state = svn_wc_notify_lock_state_unchanged;
 
   /* Has the user made local mods to the working file?  */
-  SVN_ERR (svn_wc_text_modified_p (&is_locally_modified,
-                                   file_path, FALSE, adm_access, pool));
+  if (taken_over)
+    is_locally_modified = TRUE;
+  else
+    SVN_ERR (svn_wc_text_modified_p (&is_locally_modified,
+                                     file_path, FALSE, adm_access, pool));
 
   if (new_text_path)   /* is there a new text-base to install? */
     {
@@ -2133,6 +2151,22 @@
                                  NULL);
         }
   
+      else if (taken_over) /* working file already existed, and might
+                              be newer than the repository copy */
+        {
+          /* Set the text-time property of the entry to the commit
+             date/time of the file in the repository */
+          svn_xml_make_open_tag (&log_accum,
+                                 pool,
+                                 svn_xml_self_closing,
+                                 SVN_WC__LOG_MODIFY_ENTRY,
+                                 SVN_WC__LOG_ATTR_NAME,
+                                 base_name,
+                                 SVN_WC__ENTRY_ATTR_TEXT_TIME,
+                                 timestamp_string,
+                                 NULL);
+        }
+
       else   /* working file is locally modified... */
         {
           svn_node_kind_t wfile_kind = svn_node_unknown;
@@ -2409,7 +2443,8 @@
                          SVN_INVALID_REVNUM,
                          eb->diff3_cmd,
                          fb->last_changed_date,
-                         pool));
+                         pool,
+                         fb->taken_over));
 
   /* We have one less referrer to the directory's bump information. */
   SVN_ERR (maybe_bump_dir_info (eb, fb->bump_info, pool));
@@ -2419,10 +2454,18 @@
        (lock_state != svn_wc_notify_lock_state_unchanged)) &&
       eb->notify_func)
     {
-      svn_wc_notify_t *notify
-        = svn_wc_create_notify (fb->path,
-                                fb->added ? svn_wc_notify_update_add 
-                                : svn_wc_notify_update_update, pool);
+      svn_wc_notify_action_t notification;
+      svn_wc_notify_t *notify;
+
+      if (fb->taken_over)
+        notification = svn_wc_notify_update_takeover;
+      else if (fb->added)
+        notification = svn_wc_notify_update_add;
+      else
+        notification = svn_wc_notify_update_update;
+
+      notify = svn_wc_create_notify (fb->path, notification, pool);
+
       notify->kind = svn_node_file;
       notify->content_state = content_state;
       notify->prop_state = prop_state;
@@ -2519,7 +2562,8 @@
              const svn_delta_editor_t **editor,
              void **edit_baton,
              svn_wc_traversal_info_t *traversal_info,
-             apr_pool_t *pool)
+             apr_pool_t *pool,
+             svn_boolean_t taking_over)
 {
   struct edit_baton *eb;
   apr_pool_t *subpool = svn_pool_create (pool);
@@ -2541,6 +2585,7 @@
   eb->diff3_cmd       = diff3_cmd;
   eb->cancel_func     = cancel_func;
   eb->cancel_baton    = cancel_baton;
+  eb->taking_over     = taking_over;
 
   /* Construct an editor. */
   tree_editor->set_target_revision = set_target_revision;
@@ -2572,6 +2617,29 @@
 
 
 svn_error_t *
+svn_wc_get_update_editor3 (svn_revnum_t *target_revision,
+                           svn_wc_adm_access_t *anchor,
+                           const char *target,
+                           svn_boolean_t use_commit_times,
+                           svn_boolean_t recurse,
+                           svn_wc_notify_func2_t notify_func,
+                           void *notify_baton,
+                           svn_cancel_func_t cancel_func,
+                           void *cancel_baton,
+                           const char *diff3_cmd,
+                           const svn_delta_editor_t **editor,
+                           void **edit_baton,
+                           svn_wc_traversal_info_t *traversal_info,
+                           apr_pool_t *pool,
+                           svn_boolean_t taking_over)
+{
+  return make_editor (target_revision, anchor, svn_wc_adm_access_path (anchor),
+                      target, use_commit_times, NULL, recurse, notify_func, 
+                      notify_baton, cancel_func, cancel_baton, diff3_cmd,
+                      editor, edit_baton, traversal_info, pool, taking_over);
+}
+
+svn_error_t *
 svn_wc_get_update_editor2 (svn_revnum_t *target_revision,
                            svn_wc_adm_access_t *anchor,
                            const char *target,
@@ -2590,7 +2658,7 @@
   return make_editor (target_revision, anchor, svn_wc_adm_access_path (anchor),
                       target, use_commit_times, NULL, recurse, notify_func, 
                       notify_baton, cancel_func, cancel_baton, diff3_cmd,
-                      editor, edit_baton, traversal_info, pool);
+                      editor, edit_baton, traversal_info, pool, FALSE);
 }
 
 svn_error_t *
@@ -2642,7 +2710,7 @@
   return make_editor (target_revision, anchor, svn_wc_adm_access_path (anchor),
                       target, use_commit_times, switch_url, recurse, 
                       notify_func, notify_baton, cancel_func, cancel_baton, 
-                      diff3_cmd, editor, edit_baton, traversal_info, pool);
+                      diff3_cmd, editor, edit_baton, traversal_info, pool, FALSE);
 }
 
 svn_error_t *
@@ -2958,7 +3026,8 @@
                          copyfrom_rev,
                          NULL,
                          NULL,
-                         pool));
+                         pool,
+                         FALSE));
 
   SVN_ERR (svn_wc__run_log (adm_access, NULL, pool));
 
Index: libsvn_client/externals.c
===================================================================
--- libsvn_client/externals.c	(revision 15261)
+++ libsvn_client/externals.c	(working copy)
@@ -249,7 +249,7 @@
                                                 &(new_item->revision),
                                                 TRUE, FALSE,
                                                 ib->timestamp_sleep,
-                                                ib->ctx, ib->pool));
+                                                ib->ctx, ib->pool, FALSE));
     }
   else if (! new_item)
     {
@@ -306,7 +306,7 @@
                                               &(new_item->revision),
                                               TRUE, FALSE,
                                               ib->timestamp_sleep,
-                                              ib->ctx, ib->pool));
+                                              ib->ctx, ib->pool, FALSE));
     }
   else if (ib->update_unchanged)
     {
@@ -345,7 +345,7 @@
                                                     &(new_item->revision),
                                                     TRUE, FALSE,
                                                     ib->timestamp_sleep,
-                                                    ib->ctx, ib->pool));
+                                                    ib->ctx, ib->pool, FALSE));
             }
           /* If, however, the URLs don't match, we need to relegate
              the one subdir, and then checkout a new one. */
@@ -363,7 +363,7 @@
                                                       &(new_item->revision),
                                                       TRUE, FALSE,
                                                       ib->timestamp_sleep,
-                                                      ib->ctx, ib->pool));
+                                                      ib->ctx, ib->pool, FALSE));
             }
         }
       else /* Not a directory at all -- just try the checkout. */
@@ -379,7 +379,7 @@
                                                   &(new_item->revision),
                                                   TRUE, FALSE,
                                                   ib->timestamp_sleep,
-                                                  ib->ctx, ib->pool));
+                                                  ib->ctx, ib->pool, FALSE));
         }
     }
 
Index: libsvn_client/client.h
===================================================================
--- libsvn_client/client.h	(revision 15261)
+++ libsvn_client/client.h	(working copy)
@@ -322,7 +322,8 @@
                              svn_boolean_t ignore_externals,
                              svn_boolean_t *timestamp_sleep,
                              svn_client_ctx_t *ctx,
-                             apr_pool_t *pool);
+                             apr_pool_t *pool,
+                             svn_boolean_t taking_over);
 
 /* Checkout into PATH a working copy of URL at REVISION, and (if not
    NULL) set RESULT_REV to the checked out revision.  RECURSE if so
@@ -342,7 +343,8 @@
                                svn_boolean_t ignore_externals,
                                svn_boolean_t *timestamp_sleep,
                                svn_client_ctx_t *ctx,
-                               apr_pool_t *pool);
+                               apr_pool_t *pool,
+                               svn_boolean_t taking_over);
 
 /* ---------------------------------------------------------------- */
 
Index: libsvn_client/checkout.c
===================================================================
--- libsvn_client/checkout.c	(revision 15261)
+++ libsvn_client/checkout.c	(working copy)
@@ -50,7 +50,8 @@
                                svn_boolean_t ignore_externals,
                                svn_boolean_t *timestamp_sleep,
                                svn_client_ctx_t *ctx,
-                               apr_pool_t *pool)
+                               apr_pool_t *pool,
+                               svn_boolean_t taking_over)
 {
   svn_wc_traversal_info_t *traversal_info = svn_wc_init_traversal_info (pool);
   svn_error_t *err = NULL;
@@ -98,6 +99,11 @@
 
       if (kind == svn_node_none)
         {
+          if (taking_over)
+            return svn_error_createf
+              (SVN_ERR_UNSUPPORTED_FEATURE , NULL,
+              _("URL '%s' refers to a non-existent repository path; the takeover command is supported only for existing repository paths"), URL);
+
           /* Bootstrap: create an incomplete working-copy root dir.  Its
              entries file should only have an entry for THIS_DIR with a
              URL, revnum, and an 'incomplete' flag.  */
@@ -107,7 +113,7 @@
           /* Have update fix the incompleteness. */
           err = svn_client__update_internal (result_rev, path, revision,
                                              recurse, ignore_externals,
-                                             use_sleep, ctx, pool);
+                                             use_sleep, ctx, pool, FALSE);
         }
       else if (kind == svn_node_dir)
         {
@@ -122,7 +128,7 @@
               SVN_ERR (svn_wc_ensure_adm (path, uuid, URL, revnum, pool));
               err = svn_client__update_internal (result_rev, path, revision,
                                                  recurse, ignore_externals,
-                                                 use_sleep, ctx, pool);
+                                                 use_sleep, ctx, pool, taking_over);
               goto done;
             }
 
@@ -140,7 +146,7 @@
             {
               err = svn_client__update_internal (result_rev, path, revision,
                                                  recurse, ignore_externals,
-                                                 use_sleep, ctx, pool);
+                                                 use_sleep, ctx, pool, taking_over);
             }
           else
             {
@@ -190,6 +196,23 @@
 }
 
 svn_error_t *
+svn_client_checkout3 (svn_revnum_t *result_rev,
+                      const char *URL,
+                      const char *path,
+                      const svn_opt_revision_t *peg_revision,
+                      const svn_opt_revision_t *revision,
+                      svn_boolean_t recurse,
+                      svn_boolean_t ignore_externals,
+                      svn_client_ctx_t *ctx,
+                      apr_pool_t *pool,
+                      svn_boolean_t taking_over)
+{
+  return svn_client__checkout_internal (result_rev, URL, path, peg_revision,
+                                        revision, recurse, ignore_externals,
+                                        NULL, ctx, pool, taking_over);
+}
+
+svn_error_t *
 svn_client_checkout2 (svn_revnum_t *result_rev,
                       const char *URL,
                       const char *path,
@@ -202,7 +225,7 @@
 {
   return svn_client__checkout_internal (result_rev, URL, path, peg_revision,
                                         revision, recurse, ignore_externals,
-                                        NULL, ctx, pool);
+                                        NULL, ctx, pool, FALSE);
 }
 
 svn_error_t *
@@ -220,5 +243,5 @@
   
   return svn_client__checkout_internal (result_rev, URL, path, &peg_revision,
                                         revision, recurse, FALSE, NULL, 
-                                        ctx, pool);
+                                        ctx, pool, FALSE);
 }
Index: libsvn_client/copy.c
===================================================================
--- libsvn_client/copy.c	(revision 15261)
+++ libsvn_client/copy.c	(working copy)
@@ -892,7 +892,7 @@
     {
       SVN_ERR (svn_client__checkout_internal
                (NULL, src_url, dst_path, &revision, &revision,
-                TRUE, FALSE, NULL, ctx, pool));
+                TRUE, FALSE, NULL, ctx, pool, FALSE));
 
       if ((revision.kind == svn_opt_revision_head) && same_repositories)
         {
Index: libsvn_client/update.c
===================================================================
--- libsvn_client/update.c	(revision 15261)
+++ libsvn_client/update.c	(working copy)
@@ -46,7 +46,8 @@
                              svn_boolean_t ignore_externals,
                              svn_boolean_t *timestamp_sleep,
                              svn_client_ctx_t *ctx,
-                             apr_pool_t *pool)
+                             apr_pool_t *pool,
+                             svn_boolean_t taking_over)
 {
   const svn_delta_editor_t *update_editor;
   void *update_edit_baton;
@@ -113,14 +114,14 @@
 
   /* 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_editor2 (&revnum, adm_access, target,
+  SVN_ERR (svn_wc_get_update_editor3 (&revnum, adm_access, target,
                                       use_commit_times, recurse,
                                       ctx->notify_func2, ctx->notify_baton2,
                                       ctx->cancel_func, ctx->cancel_baton,
                                       diff3_cmd,
                                       &update_editor, &update_edit_baton,
                                       traversal_info,
-                                      pool));
+                                      pool, taking_over));
 
   /* Tell RA to do an update of URL+TARGET to REVISION; if we pass an
      invalid revnum, that means RA will use the latest revision.  */
@@ -210,7 +211,7 @@
 
       err = svn_client__update_internal (&result_rev, path, revision,
                                          recurse, ignore_externals, 
-                                         &sleep, ctx, subpool);
+                                         &sleep, ctx, subpool, FALSE);
       if (err && err->apr_err != SVN_ERR_WC_NOT_DIRECTORY)
         {
           return err;
@@ -246,5 +247,5 @@
                    apr_pool_t *pool)
 {
   return svn_client__update_internal (result_rev, path, revision, recurse, 
-                                      FALSE, NULL, ctx, pool);
+                                      FALSE, NULL, ctx, pool, FALSE);
 }
Index: clients/cmdline/cl.h
===================================================================
--- clients/cmdline/cl.h	(revision 15261)
+++ clients/cmdline/cl.h	(working copy)
@@ -156,6 +156,7 @@
   svn_cl__add,
   svn_cl__blame,
   svn_cl__checkout,
+  svn_cl__takeover,
   svn_cl__cleanup,
   svn_cl__commit,
   svn_cl__copy,
Index: clients/cmdline/checkout-cmd.c
===================================================================
--- clients/cmdline/checkout-cmd.c	(revision 15261)
+++ clients/cmdline/checkout-cmd.c	(working copy)
@@ -55,6 +55,8 @@
   Is this the same as CVS?  Does it matter if it is not?
 */
 
+/* Forward declaration */
+svn_error_t *checkout_takeover_impl (apr_getopt_t *os, void *baton, apr_pool_t *pool, svn_boolean_t taking_over);
 
 /* This implements the `svn_opt_subcommand_t' interface. */
 svn_error_t *
@@ -62,6 +64,23 @@
                   void *baton,
                   apr_pool_t *pool)
 {
+  return checkout_takeover_impl(os, baton, pool, FALSE);
+}
+
+svn_error_t *
+svn_cl__takeover (apr_getopt_t *os,
+                  void *baton,
+                  apr_pool_t *pool)
+{
+  return checkout_takeover_impl(os, baton, pool, TRUE);
+}
+
+static svn_error_t *
+checkout_takeover_impl (apr_getopt_t *os,
+                        void *baton,
+                        apr_pool_t *pool,
+                        svn_boolean_t taking_over)
+{
   svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_pool_t *subpool;
@@ -146,12 +165,13 @@
       if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
         opt_state->start_revision.kind = svn_opt_revision_head;
 
-      SVN_ERR (svn_client_checkout2 (NULL, true_url, target_dir,
+      SVN_ERR (svn_client_checkout3 (NULL, true_url, target_dir,
                                      &peg_revision,
                                      &(opt_state->start_revision),
                                      opt_state->nonrecursive ? FALSE : TRUE,
                                      opt_state->ignore_externals,
-                                     ctx, subpool));
+                                     ctx, subpool,
+                                     taking_over));
     }
   svn_pool_destroy (subpool);
   
Index: clients/cmdline/notify.c
===================================================================
--- clients/cmdline/notify.c	(revision 15261)
+++ clients/cmdline/notify.c	(working copy)
@@ -90,6 +90,12 @@
         goto print_error;
       break;
 
+    case svn_wc_notify_update_takeover:
+      nb->received_some_change = TRUE;
+      if ((err = svn_cmdline_printf (pool, "T    %s\n", path_local)))
+        goto print_error;
+      break;
+
     case svn_wc_notify_restore:
       if ((err = svn_cmdline_printf (pool, _("Restored '%s'\n"),
                                      path_local)))
Index: clients/cmdline/main.c
===================================================================
--- clients/cmdline/main.c	(revision 15261)
+++ clients/cmdline/main.c	(working copy)
@@ -216,6 +216,26 @@
     {'r', 'q', 'N', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt,
      svn_cl__ignore_externals_opt} },
 
+  { "takeover", svn_cl__takeover, {"to"}, N_
+    ("Make an existing source tree a working tree for a repository.\n"
+     "usage: takeover URL[@REV]... [PATH]\n"
+     "\n"
+     "  If specified, REV determines in which revision the URL is first\n"
+     "  looked up.\n"
+     "\n"
+     "  If PATH is omitted, the basename of the URL will be used as\n"
+     "  the destination. If multiple URLs are given each will be used to\n"
+     "  take over a sub-directory of PATH, with the name of the sub-directory\n"
+     "  being the basename of the URL.\n"
+     "\n"
+     "  The takeover command works exactly the same as the checkout command,\n"
+     "  except that existing files will be left as-is and will not obstruct\n"
+     "  the operation. Any such files will be treated as newer than the\n"
+     "  repository copy. That is, SVN will treat the files as though they\n"
+     "  had been checked out normally and then edited to their present state.\n"),
+    {'r', 'q', 'N', SVN_CL__AUTH_OPTIONS, svn_cl__config_dir_opt,
+     svn_cl__ignore_externals_opt} },
+
   { "cleanup", svn_cl__cleanup, {0},
     N_("Recursively clean up the working copy, removing locks, resuming\n"
        "unfinished operations, etc.\n"


