You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2013/07/22 17:16:01 UTC
svn commit: r1505714 - in /subversion/trunk/subversion: svn/cl.h svn/svn.c
svn/youngest-cmd.c tests/cmdline/basic_tests.py
Author: cmpilato
Date: Mon Jul 22 15:16:00 2013
New Revision: 1505714
URL: http://svn.apache.org/r1505714
Log:
Finish issue #4299 ("Remote version of 'svnlook youngest'") by
introducing 'svn youngest'.
* subversion/svn/cl.h
(svn_cl__opt_state_t): Add no_newline member.
(): Add svn_cl__youngest to the command procedure list.
* subversion/svn/svn.c
(svn_cl__options): Add --new-line option.
(svn_cl__longopt_t): Add opt_no_newline to svn_cl__longopt_t.
(svn_cl__cmd_table): Add 'youngest' entry.
(sub_main): Add handler for opt_no_newline.
* subversion/svn/youngest-cmd.c
(svn_cl__youngest): implement the 'youngest' sub command handler.
* subversion/tests/cmdline/basic_tests.py
(basic_youngest): New test.
(test_list): Add reference to new test.
Patch by: Masaru Tsuchiyama <m.tmatma{_AT_}gmail.com>
(Tweaked be me.)
Added:
subversion/trunk/subversion/svn/youngest-cmd.c (with props)
Modified:
subversion/trunk/subversion/svn/cl.h
subversion/trunk/subversion/svn/svn.c
subversion/trunk/subversion/tests/cmdline/basic_tests.py
Modified: subversion/trunk/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/cl.h?rev=1505714&r1=1505713&r2=1505714&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/cl.h (original)
+++ subversion/trunk/subversion/svn/cl.h Mon Jul 22 15:16:00 2013
@@ -242,6 +242,7 @@ typedef struct svn_cl__opt_state_t
svn_boolean_t mergeinfo_log; /* show log message in mergeinfo command */
svn_boolean_t remove_unversioned;/* remove unversioned items */
svn_boolean_t remove_ignored; /* remove ignored items */
+ svn_boolean_t no_newline; /* do not output the trailing newline */
} svn_cl__opt_state_t;
@@ -289,7 +290,8 @@ svn_opt_subcommand_t
svn_cl__switch,
svn_cl__unlock,
svn_cl__update,
- svn_cl__upgrade;
+ svn_cl__upgrade,
+ svn_cl__youngest;
/* See definition in svn.c for documentation. */
Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1505714&r1=1505713&r2=1505714&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Mon Jul 22 15:16:00 2013
@@ -136,7 +136,8 @@ typedef enum svn_cl__longopt_t {
opt_search_and,
opt_mergeinfo_log,
opt_remove_unversioned,
- opt_remove_ignored
+ opt_remove_ignored,
+ opt_no_newline
} svn_cl__longopt_t;
@@ -385,6 +386,7 @@ const apr_getopt_option_t svn_cl__option
{"remove-unversioned", opt_remove_unversioned, 0,
N_("remove unversioned items")},
{"remove-ignored", opt_remove_ignored, 0, N_("remove ignored items")},
+ {"no-newline", opt_no_newline, 0, N_("do not output trailing newline")},
/* Long-opt Aliases
*
@@ -1638,6 +1640,14 @@ const svn_opt_subcommand_desc2_t svn_cl_
" Local modifications are preserved.\n"),
{ 'q' } },
+ { "youngest", svn_cl__youngest, {0}, N_
+ ("Print the youngest revision number of a target's repository.\n"
+ "usage: youngest [TARGET]\n"
+ "\n"
+ " Print the revision number of the youngest revision in the repository\n"
+ " with which TARGET is associated.\n"),
+ { opt_no_newline } },
+
{ NULL, NULL, {0}, NULL, {0} }
};
@@ -2314,6 +2324,9 @@ sub_main(int argc, const char *argv[], a
case opt_remove_ignored:
opt_state.remove_ignored = TRUE;
break;
+ case opt_no_newline:
+ opt_state.no_newline = TRUE;
+ break;
default:
/* Hmmm. Perhaps this would be a good place to squirrel away
opts that commands like svn diff might need. Hmmm indeed. */
Added: subversion/trunk/subversion/svn/youngest-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/youngest-cmd.c?rev=1505714&view=auto
==============================================================================
--- subversion/trunk/subversion/svn/youngest-cmd.c (added)
+++ subversion/trunk/subversion/svn/youngest-cmd.c Mon Jul 22 15:16:00 2013
@@ -0,0 +1,84 @@
+/*
+ * youngest-cmd.c -- Print the youngest repository revision number
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ */
+
+/* ==================================================================== */
+
+
+
+/*** Includes. ***/
+
+#include "svn_dirent_uri.h"
+#include "svn_path.h"
+#include "cl.h"
+
+#include "svn_private_config.h"
+
+
+/*** Code. ***/
+
+/* This implements the `svn_opt_subcommand_t' interface. */
+svn_error_t *
+svn_cl__youngest(apr_getopt_t *os,
+ void *baton,
+ apr_pool_t *pool)
+{
+ 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_array_header_t *targets = NULL;
+ const char *target_path = NULL; /* TARGET path (working copy path or URL) */
+ const char *target_url = NULL; /* TARGET URL */
+ svn_ra_session_t *session;
+ svn_revnum_t latest_revision = SVN_INVALID_REVNUM;
+
+ SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
+ opt_state->targets,
+ ctx, FALSE, pool));
+
+ /* Add "." if user passed 0 arguments */
+ svn_opt_push_implicit_dot_target(targets, pool);
+
+ /* We want exactly 0 or 1 targets for this subcommand. */
+ if (targets->nelts > 1)
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
+
+ /* Ensure that we have a URL to work with.. */
+ target_path = APR_ARRAY_IDX(targets, 0, const char *);
+ if (svn_path_is_url(target_path))
+ {
+ target_url = target_path;
+ }
+ else
+ {
+ SVN_ERR(svn_dirent_get_absolute(&target_path, target_path, pool));
+ SVN_ERR(svn_client_url_from_path2(&target_url, target_path, ctx,
+ pool, pool));
+ }
+
+ /* Get HEAD Revision from URL */
+ SVN_ERR(svn_client_open_ra_session2(&session, target_url, NULL, ctx,
+ pool, pool));
+ SVN_ERR(svn_ra_get_latest_revnum(session, &latest_revision, pool));
+ SVN_ERR(svn_cmdline_printf(pool, "%ld%s", latest_revision,
+ opt_state->no_newline ? "" : "\n"));
+ return SVN_NO_ERROR;
+}
Propchange: subversion/trunk/subversion/svn/youngest-cmd.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1505714&r1=1505713&r2=1505714&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Mon Jul 22 15:16:00 2013
@@ -3049,6 +3049,34 @@ def peg_rev_on_non_existent_wc_path(sbox
svntest.actions.run_and_verify_svn(None, ['r2\n'], [],
'cat', '-r2', sbox.ospath('mu3') + '@3')
+
+@Issue(4299)
+def basic_youngest(sbox):
+ 'basic youngest'
+
+ sbox.build(read_only=True)
+
+ repos_url = sbox.repo_url
+ deep_repos_url = repos_url + '/A/D/G'
+
+ wc_dir = sbox.wc_dir
+ deep_wc_dir = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
+ bad_wc_dir = os.path.join(wc_dir, 'Z')
+
+ svntest.actions.run_and_verify_svn("'svn youngest' on bad WC path",
+ None, svntest.verify.AnyOutput,
+ 'youngest', bad_wc_dir)
+
+ for flag, output in [(False, "1\n"), (True, "1")]:
+ for path in [repos_url, deep_repos_url, wc_dir, deep_wc_dir]:
+ if flag:
+ svntest.actions.run_and_verify_svn("svn youngest", [output], [],
+ 'youngest', '--no-newline', path)
+ else:
+ svntest.actions.run_and_verify_svn("svn youngest", [output], [],
+ 'youngest', path)
+
+
########################################################################
# Run the tests
@@ -3117,6 +3145,7 @@ test_list = [ None,
rm_missing_with_case_clashing_ondisk_item,
delete_conflicts_one_of_many,
peg_rev_on_non_existent_wc_path,
+ basic_youngest,
]
if __name__ == '__main__':