diff --git a/py/cmdline/pysvnwcrevert.py b/py/cmdline/pysvnwcrevert.py index 565b9533e..4080b2c76 100755 --- a/py/cmdline/pysvnwcrevert.py +++ b/py/cmdline/pysvnwcrevert.py @@ -1,6 +1,6 @@ #! /usr/bin/env python """\ -py.svnwcrevert WCPATH [precious...] +py.svnwcrevert [options] WCPATH Running this script and then 'svn up' puts the working copy WCPATH in a state as clean as a fresh check-out. @@ -14,12 +14,9 @@ or that svn doesn't explicitly know about, including svn:ignored files The goal of this script is to leave the working copy with some files and directories possibly missing, but - most importantly - in a state where the following 'svn up' won't just crash. - -Optionally filenames that should be left untouched can be passed as arguments -too. """ -import py +import sys, py def kill(p, root): print '< %s' % (p.relto(root),) @@ -43,12 +40,17 @@ def svnwcrevert(path, root=None, precious=[]): elif p.check(dir=1): svnwcrevert(p, root) +# XXX add a functional test +optparse = py.compat.optparse -# XXX use optparse, and add a functional test +parser = optparse.OptionParser(usage=__doc__) +parser.add_option("-p", "--precious", + action="append", dest="precious", default=[], + help="preserve files with this name") def main(): - import sys - if len(sys.argv) < 2: - print __doc__ + opts, args = parser.parse_args() + if len(args) != 1: + parser.print_help() sys.exit(2) - svnwcrevert(py.path.local(sys.argv[1]), precious=sys.argv[1:]) + svnwcrevert(py.path.local(args[0]), precious=opts.precious)