[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] make cvs2svn check the exit status of commands

From: Robert Pluim <rpluim_at_bigfoot.com>
Date: 2003-05-14 14:24:16 CEST

Query to black-belt pythoners (pythonistas?): is there a more
pythonesque way of doing this? According to my docs, os.system
doesn't throw exceptions, so checking the return code is the only
way to do this.

* define run_external as an error checking wrapper around os.system,
  and use it in pass3, pass4 & pass5.

Index: tools/cvs2svn/cvs2svn.py
===================================================================
--- tools/cvs2svn/cvs2svn.py (revision 5932)
+++ tools/cvs2svn/cvs2svn.py (working copy)
@@ -272,6 +272,10 @@
   gen_key_base = gen_key_base + 1
   return key
 
+def run_external(command):
+ if os.system(command):
+ print 'Error running "%s"' % command
+ sys.exit(1)
 
 class TreeMirror:
   def __init__(self):
@@ -960,14 +964,14 @@
 
 def pass3(ctx):
   # sort the log files
- os.system('sort %s > %s' % (ctx.log_fname_base + CLEAN_REVS_SUFFIX,
- ctx.log_fname_base + SORTED_REVS_SUFFIX))
+ run_external('sort %s > %s' % (ctx.log_fname_base + CLEAN_REVS_SUFFIX,
+ ctx.log_fname_base + SORTED_REVS_SUFFIX))
 
 def pass4(ctx):
   # create the target repository
   if not ctx.dry_run:
     if ctx.create_repos:
- os.system('%s create %s' % (ctx.svnadmin, ctx.target))
+ run_external('%s create %s' % (ctx.svnadmin, ctx.target))
   else:
     t_fs = t_repos = None
 
@@ -1052,8 +1056,8 @@
     # ### FIXME: Er, does this "<" stuff work under Windows?
     # ### If not, then in general how do we load dumpfiles under Windows?
     print 'loading %s into %s' % (ctx.dumpfile, ctx.target)
- os.system('%s load --ignore-uuid %s < %s'
- % (ctx.svnadmin, ctx.target, ctx.dumpfile))
+ run_external('%s load --ignore-uuid %s < %s'
+ % (ctx.svnadmin, ctx.target, ctx.dumpfile))
 
 _passes = [
   pass1,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed May 14 14:21:57 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.