Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h	(revision 15298)
+++ subversion/include/svn_client.h	(working copy)
@@ -915,7 +915,8 @@
 /** 
  * Invoke @a receiver with @a receiver_baton on each log message from @a 
  * start to @a end in turn, inclusive (but never invoke @a receiver on a 
- * given log message more than once).
+ * given log message more than once). @a peg_revision indicates in which
+ * revision @a targets are valid.
  *
  * @a targets contains either a URL followed by zero or more relative
  * paths, or a list of working copy paths, as <tt>const char *</tt>,
@@ -947,10 +948,11 @@
  * If @a ctx->notify_func2 is non-null, then call @a ctx->notify_func2/baton2
  * with a 'skip' signal on any unversioned targets.
  *
- * @since New in 1.2.
+ * @since New in 1.3.
  */
 svn_error_t *
-svn_client_log2 (const apr_array_header_t *targets,
+svn_client_log3 (const apr_array_header_t *targets,
+                 const svn_opt_revision_t *peg_revision,
                  const svn_opt_revision_t *start,
                  const svn_opt_revision_t *end,
                  int limit,
@@ -963,6 +965,23 @@
 
 
 /**
+ * Similar to svn_client_log3(), but with the @a peg_revision
+ * parameter always set to @c svn_opt_revision_unspecified.
+ *
+ * @deprecated Provided for backward compatibility with the 1.2 API.
+ */
+svn_error_t *
+svn_client_log2 (const apr_array_header_t *targets,
+                 const svn_opt_revision_t *start,
+                 const svn_opt_revision_t *end,
+                 int limit,
+                 svn_boolean_t discover_changed_paths,
+                 svn_boolean_t strict_node_history,
+                 svn_log_message_receiver_t receiver,
+                 void *receiver_baton,
+                 svn_client_ctx_t *ctx,
+                 apr_pool_t *pool);
+/**
  * Similar to svn_client_log2(), but with the @a limit parameter set to 0,
  * and the following special case:
  *
Index: subversion/libsvn_client/log.c
===================================================================
--- subversion/libsvn_client/log.c	(revision 15298)
+++ subversion/libsvn_client/log.c	(working copy)
@@ -45,7 +45,8 @@
 
 
 svn_error_t *
-svn_client_log2 (const apr_array_header_t *targets,
+svn_client_log3 (const apr_array_header_t *targets,
+                 const svn_opt_revision_t *peg_revision,
                  const svn_opt_revision_t *start,
                  const svn_opt_revision_t *end,
                  int limit,
@@ -63,6 +64,9 @@
   apr_array_header_t *condensed_targets;
   svn_revnum_t start_revnum, end_revnum;
   svn_error_t *err = SVN_NO_ERROR;  /* Because we might have no targets. */
+  svn_revnum_t rev; /* Actual revision number of the object */
+  const char *url_p;
+  svn_opt_revision_t revision; /* Desired revision */
 
   if ((start->kind == svn_opt_revision_unspecified)
       || (end->kind == svn_opt_revision_unspecified))
@@ -157,13 +161,17 @@
       targets = real_targets;
     }
 
-  /* Open a repository session to the BASE_URL. */
-  SVN_ERR (svn_path_condense_targets (&base_name, NULL, targets, TRUE, pool)); 
-  SVN_ERR (svn_client__open_ra_session_internal (&ra_session, base_url, 
-                                                 base_name, NULL, NULL,
-                                                 (NULL != base_name), TRUE, 
-                                                 ctx, pool));
+  if (start->kind == svn_opt_revision_number && 
+      end->kind == svn_opt_revision_number)
+        revision = (start->value.number > end->value.number) ? *start : *end;
+  else
+        revision.kind = svn_opt_revision_unspecified;
 
+  SVN_ERR (svn_client__ra_session_from_path (&ra_session, &rev,
+                                             &url_p, path, 
+                                             peg_revision, &revision, ctx, 
+                                             pool));
+
   /* It's a bit complex to correctly handle the special revision words
    * such as "BASE", "COMMITTED", and "PREV".  For example, if the
    * user runs
@@ -270,6 +278,30 @@
 }
 
 svn_error_t *
+svn_client_log2 (const apr_array_header_t *targets,
+                 const svn_opt_revision_t *start,
+                 const svn_opt_revision_t *end,
+                 int limit,
+                 svn_boolean_t discover_changed_paths,
+                 svn_boolean_t strict_node_history,
+                 svn_log_message_receiver_t receiver,
+                 void *receiver_baton,
+                 svn_client_ctx_t *ctx,
+                 apr_pool_t *pool)
+{
+  svn_error_t *err = SVN_NO_ERROR;
+  svn_opt_revision_t peg_revision;
+
+  peg_revision.kind = svn_opt_revision_unspecified;
+   
+  err = svn_client_log3 (targets, &peg_revision, start, end, limit, 
+                         discover_changed_paths, strict_node_history, 
+                         receiver, receiver_baton, ctx, pool);
+
+  return err;
+}
+
+svn_error_t *
 svn_client_log (const apr_array_header_t *targets,
                 const svn_opt_revision_t *start,
                 const svn_opt_revision_t *end,
@@ -281,11 +313,14 @@
                 apr_pool_t *pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
+  svn_opt_revision_t peg_revision;
 
-  err = svn_client_log2 (targets, start, end, 0, discover_changed_paths,
-                         strict_node_history, receiver, receiver_baton, ctx,
-                         pool);
-    
+  peg_revision.kind = svn_opt_revision_unspecified;
+
+  err = svn_client_log3 (targets, &peg_revision, start, end, 0,
+                         discover_changed_paths, strict_node_history,
+                         receiver, receiver_baton, ctx, pool);
+   
   /* Special case: If there have been no commits, we'll get an error
    * for requesting log of a revision higher than 0.  But the
    * default behavior of "svn log" is to give revisions HEAD through
Index: subversion/clients/cmdline/log-cmd.c
===================================================================
--- subversion/clients/cmdline/log-cmd.c	(revision 15298)
+++ subversion/clients/cmdline/log-cmd.c	(working copy)
@@ -398,6 +398,8 @@
   struct log_receiver_baton lb;
   const char *target;
   int i;
+  svn_opt_revision_t peg_revision;
+  const char *truepath;
 
   SVN_ERR (svn_opt_args_to_target_array2 (&targets, os, 
                                           opt_state->targets, pool));
@@ -408,6 +410,10 @@
   /* Retrieve the first target in the list. */
   target = APR_ARRAY_IDX (targets, 0, const char *);
 
+  SVN_ERR (svn_opt_parse_path (&peg_revision, &truepath, target, pool));
+
+  APR_ARRAY_IDX (targets, 0, const char *) = truepath;
+
   if ((opt_state->start_revision.kind != svn_opt_revision_unspecified)
       && (opt_state->end_revision.kind == svn_opt_revision_unspecified))
     {
@@ -486,7 +492,8 @@
           SVN_ERR (svn_cl__error_checked_fputs (sb->data, stdout));
         }
       
-      SVN_ERR (svn_client_log2 (targets,
+      SVN_ERR (svn_client_log3 (targets,
+                                &peg_revision,
                                 &(opt_state->start_revision),
                                 &(opt_state->end_revision),
                                 opt_state->limit,
@@ -516,7 +523,8 @@
        * is concerned, the result of 'svn log --quiet' is the same
        * either way.
        */
-      SVN_ERR (svn_client_log2 (targets,
+      SVN_ERR (svn_client_log3 (targets,
+                                &peg_revision,
                                 &(opt_state->start_revision),
                                 &(opt_state->end_revision),
                                 opt_state->limit,
Index: subversion/tests/clients/cmdline/log_tests.py
===================================================================
--- subversion/tests/clients/cmdline/log_tests.py	(revision 15298)
+++ subversion/tests/clients/cmdline/log_tests.py	(working copy)
@@ -482,7 +482,7 @@
 
   guarantee_repos_and_wc(sbox)
 
-  my_url = svntest.main.current_repo_url + "/A/B/E/alpha"
+  my_url = svntest.main.current_repo_url + "/A/B/E/alpha" + "@8"
   
   svntest.actions.run_and_verify_svn(None, None, [],
                                      'log', '-r', '8', my_url)
@@ -555,25 +555,35 @@
 
   # First "oddity", the full log for mu2 doesn't include r3, but the -r3
   # log works!
+  peg_mu2_path = mu2_path + "@3"
   output, err = svntest.actions.run_and_verify_svn (None, None, [],
-                                                    'log', '-r', '3', mu2_path)
+                                                    'log', '-r', '3', 
+                                                    peg_mu2_path)
   log_chain = parse_log_output (output)
   if check_log_chain (log_chain, [3]):
     raise svntest.Failure
 
+  peg_mu2_URL = mu2_URL + "@3"
   output, err = svntest.actions.run_and_verify_svn (None, None, [],
-                                                    'log', '-r', '3', mu2_URL)
+                                                    'log', '-r', '3', 
+                                                    peg_mu2_URL)
   log_chain = parse_log_output (output)
   if check_log_chain (log_chain, [3]):
     raise svntest.Failure
 
-  # Second "oddity", the full log for mu2 includes r2, but the -r2 log
-  # fails!
-  svntest.actions.run_and_verify_svn (None, [], SVNAnyOutput,
-                                      'log', '-r', '2', mu2_path)
-  svntest.actions.run_and_verify_svn (None, [], SVNAnyOutput,
-                                      'log', '-r', '2', mu2_URL)
-  
+  output, err = svntest.actions.run_and_verify_svn (None, None, [],
+                                                    'log', '-r', '2', 
+                                                    mu2_path)
+  log_chain = parse_log_output (output)
+  if check_log_chain (log_chain, [2]):
+    raise svntest.Failure
+
+  output, err = svntest.actions.run_and_verify_svn (None, None, [],
+                                                    'log', '-r', '2', 
+                                                    mu2_URL)
+  log_chain = parse_log_output (output)
+  if check_log_chain (log_chain, [2]):
+    raise svntest.Failure 
 #----------------------------------------------------------------------
 def escape_control_chars(sbox):
   "mod_dav_svn must escape invalid XML control chars"
