You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2011/04/21 23:03:29 UTC
svn commit: r1095819 -
/subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py
Author: danielsh
Date: Thu Apr 21 21:03:28 2011
New Revision: 1095819
URL: http://svn.apache.org/viewvc?rev=1095819&view=rev
Log:
Factor out repeated code.
Tested by: none
(I just eyeballed the two code sections; this may not compile)
* contrib/server-side/fsfsfixer/fixer/fix-rev.py
(fix_one_error): Factor out two identical chunks into..
(grab_stderr): ..this new function.
Modified:
subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py
Modified: subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py
URL: http://svn.apache.org/viewvc/subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py?rev=1095819&r1=1095818&r2=1095819&view=diff
==============================================================================
--- subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py (original)
+++ subversion/trunk/contrib/server-side/fsfsfixer/fixer/fix-rev.py Thu Apr 21 21:03:28 2011
@@ -164,17 +164,21 @@ def handle_one_error(repo_dir, rev, erro
return False
+def grab_stderr(child_argv):
+ p = Popen(child_argv, stdout=PIPE, stderr=PIPE)
+ _, stderr = p.communicate()
+ child_err = []
+ for line in stderr.splitlines():
+ if line.find('(apr_err=') == -1:
+ child_err.append(line)
+ return child_err
+
def fix_one_error(repo_dir, rev):
"""Verify, and if there is an error we know how to fix, then fix it.
Return False if no error, True if fixed, exception if can't fix."""
# Capture the output of 'svnadmin verify' (ignoring any debug-build output)
- p = Popen([SVNADMIN, 'verify', '-q', '-r'+rev, repo_dir], stdout=PIPE, stderr=PIPE)
- _, stderr = p.communicate()
- svnadmin_err = []
- for line in stderr.splitlines():
- if line.find('(apr_err=') == -1:
- svnadmin_err.append(line)
+ svnadmin_err = grab_stderr([SVNADMIN, 'verify', '-q', '-r'+rev, repo_dir])
if svnadmin_err == []:
return False
@@ -192,12 +196,7 @@ def fix_one_error(repo_dir, rev):
# one that we *can* handle.
# Capture the output of 'svnlook tree' (ignoring any debug-build output)
- p = Popen([SVNLOOK, 'tree', '-r'+rev, repo_dir], stdout=PIPE, stderr=PIPE)
- _, stderr = p.communicate()
- svnlook_err = []
- for line in stderr.splitlines():
- if line.find('(apr_err=') == -1:
- svnlook_err.append(line)
+ svnlook_err = grab_stderr([SVNLOOK, 'tree', '-r'+rev, repo_dir])
if svnlook_err == []:
print 'warning: svnlook did not find an error'