From 41b43d781ba3a1ec8cbeace92ab12a3f1449ee8b Mon Sep 17 00:00:00 2001 From: Julian Foad Date: Thu, 14 Aug 2008 20:15:54 +0000 Subject: [PATCH] Make the output of "proplist" and "propget" easier to read, especially with multi-line property values. In "propget", allow the option "--verbose" and make it give an output almost the same as "proplist --verbose". In "proplist", change the property name header line to have just the property name (indented by 2 spaces) without a following colon, regardless whether we're printing the value as well. In both cases, indent every line of the property value by the same amount (4 spaces). * subversion/svn/propget-cmd.c (print_properties): In verbose mode, print exactly like "proplist -v" does with the property value, indented, on subsequent lines. Otherwise keep the old format of "filename - propval". (svn_cl__propget): Check that "--verbose" does not clash with incompatible options. Pass appropriate behaviour flags to print_properties(). * subversion/svn/props.c (svn_cl__print_prop_hash): When printing values, print the property name on a line by itself just like when printing names only, and then print the value, indented, on subsequent lines. * subversion/svn/cl.h (svn_cl__indent_string): New function. * subversion/svn/util.c (next_line, svn_cl__indent_string): New functions. * subversion/svn/main.c (svn_cl__cmd_table): Add 'v' to the options that 'propget' can take. * subversion/tests/cmdline/svntest/tree.py (get_props): Adjust for the new "proplist" output format. * subversion/tests/cmdline/prop_tests.py (recursive_base_wc_ops, url_props_ops, removal_schedule_added_props, depthy_wc_proplist, props_over_time): Adjust for new "proplist" output. git-svn-id: http://svn.apache.org/repos/asf/subversion/trunk/subversion/tests/cmdline@872558 13f79535-47bb-0310-9956-ffa450edef68 --- svntest/tree.py | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/svntest/tree.py b/svntest/tree.py index c8c24a2..c8aee74 100644 --- a/svntest/tree.py +++ b/svntest/tree.py @@ -313,7 +313,8 @@ def create_from_path(path, contents=None, props={}, atts={}): # helper for handle_dir(), which is a helper for build_tree_from_wc() def get_props(path): - "Return a hash of props for PATH, using the svn client." + """Return a hash of props for PATH, using the svn client. Convert each + embedded end-of-line to a single LF character.""" # It's not kosher to look inside .svn/ and try to read the internal # property storage format. Instead, we use 'svn proplist'. After @@ -323,33 +324,28 @@ def get_props(path): props = {} exit_code, output, errput = main.run_svn(1, "proplist", path, "--verbose") + # Parse the output for line in output: + line = line.rstrip('\r\n') # ignore stdout's EOL sequence + if line.startswith('Properties on '): continue - if line.startswith(' ') and line.find(' : ') >= 3: - name, value = line.split(' : ') - name = name[2:] - value = value.rstrip("\r\n") - props[name] = value - else: # Multi-line property, so re-use the current name. - # Keep the line endings consistent with what was done to the first - # line by stripping whitespace and then appending a newline. This - # prevents multiline props on Windows that must be stored as UTF8/LF - # in the repository (e.g. svn:mergeinfo), say like this: - # - # "propname : propvalLine1propvalLine2propvalLine3" - # - # but that print to stdout like this: - # - # Properties on 'somepath': - # propname : propvalLine1 - # propvalLine1 - # propvalLine1 - # - # from looking like this in the returned PROPS hash: - # - # "propname" --> "propvalLine1propvalLine2propvalLine3" - props[name] = props[name] + "\n" + line.rstrip("\r\n") + + elif line.startswith(' '): + # It's (part of) the value + props[name] += line[4:] + '\n' # strip the indentation + + elif line.startswith(' '): + # It's the name + name = line[2:] # strip the indentation + props[name] = '' + + else: + raise "Malformed line from proplist: '"+line+"'" + + # Strip, from each property value, the final new-line that we added + for name in props: + props[name] = props[name][:-1] return props -- 2.11.4.GIT