[svn r58190] adding arigo/hacks/svnwcrevert as a py.svnwcrevert script on py lib trunk

--HG--
branch : trunk
This commit is contained in:
pedronis 2008-09-17 10:50:04 +02:00
parent 3f7588948c
commit 33b0390ee6
4 changed files with 57 additions and 2 deletions

View File

@ -26,8 +26,8 @@ version = "1.0.0a1"
initpkg(__name__, initpkg(__name__,
description = "pylib and py.test: agile development and test support library", description = "pylib and py.test: agile development and test support library",
revision = int('$LastChangedRevision: 57754 $'.split(':')[1][:-1]), revision = int('$LastChangedRevision: 58190 $'.split(':')[1][:-1]),
lastchangedate = '$LastChangedDate: 2008-09-02 14:24:15 +0200 (Tue, 02 Sep 2008) $', lastchangedate = '$LastChangedDate: 2008-09-17 10:50:04 +0200 (Wed, 17 Sep 2008) $',
version = version, version = version,
url = "http://pylib.org", url = "http://pylib.org",
download_url = "http://codespeak.net/py/0.9.2/download.html", download_url = "http://codespeak.net/py/0.9.2/download.html",
@ -60,6 +60,7 @@ initpkg(__name__,
'cmdline.pycountloc' : ('./cmdline/pycountloc.py', 'main',), 'cmdline.pycountloc' : ('./cmdline/pycountloc.py', 'main',),
'cmdline.pycleanup' : ('./cmdline/pycleanup.py', 'main',), 'cmdline.pycleanup' : ('./cmdline/pycleanup.py', 'main',),
'cmdline.pywhich' : ('./cmdline/pywhich.py', 'main',), 'cmdline.pywhich' : ('./cmdline/pywhich.py', 'main',),
'cmdline.pysvnwcrevert' : ('./cmdline/pysvnwcrevert.py', 'main',),
# helpers for use from test functions or collectors # helpers for use from test functions or collectors
'test.__doc__' : ('./test/__init__.py', '__doc__'), 'test.__doc__' : ('./test/__init__.py', '__doc__'),

3
py/bin/py.svnwcrevert Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env python
from _findpy import py
py.cmdline.pysvnwcrevert()

View File

@ -0,0 +1,2 @@
@echo off
python "%~dp0\..\py.svnwcrevert" %*

49
py/cmdline/pysvnwcrevert.py Executable file
View File

@ -0,0 +1,49 @@
#! /usr/bin/env python
"""\
py.svnwcrevert WCPATH
Running this script and then 'svn up' puts the working copy WCPATH in a state
as clean as a fresh check-out.
WARNING: you'll loose all local changes, obviously!
This script deletes all files that have been modified
or that svn doesn't explicitly know about, including svn:ignored files
(like .pyc files, hint hint).
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.
"""
import py
def kill(p, root):
print '< %s' % (p.relto(root),)
p.remove(rec=1)
def svnwcrevert(path, root=None):
if root is None:
root = path
wcpath = py.path.svnwc(path)
try:
st = wcpath.status()
except ValueError: # typically, "bad char in wcpath"
kill(path, root)
return
for p in path.listdir():
if p.basename == '.svn':
continue
wcp = py.path.svnwc(p)
if wcp not in st.unchanged and wcp not in st.external:
kill(p, root)
elif p.check(dir=1):
svnwcrevert(p, root)
def main():
import sys
if len(sys.argv) != 2:
print __doc__
sys.exit(2)
svnwcrevert(py.path.local(sys.argv[1]))