In the command-line client, forbid
[svn.git] / subversion / tests / cmdline / svneditor.py
blob72ad69dc1bbfffa5f2ee03180d2f634fe28e0602
1 #!/usr/bin/env python
3 # svneditor.py: a mock $SVN_EDITOR for the Subversion test suite
5 # Subversion is a tool for revision control.
6 # See http://subversion.tigris.org for more information.
8 # ====================================================================
9 # Copyright (c) 2006 CollabNet. All rights reserved.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://subversion.tigris.org/license-1.html.
14 # If newer versions of this license are posted there, you may use a
15 # newer version instead, at your option.
17 ######################################################################
19 import sys
20 import os
22 def main():
23 if len(sys.argv) not in [2, 5]:
24 print "usage: svneditor.py file"
25 print " svneditor.py base theirs mine merged"
26 sys.exit(1)
28 filename = sys.argv[-1]
30 # Read in the input file.
31 f = open(filename)
32 contents = f.read()
33 f.close()
35 funcname = os.environ['SVNTEST_EDITOR_FUNC']
36 func = sys.modules['__main__'].__dict__[funcname]
38 # Run the conversion.
39 contents = func(contents)
41 # Write edited version back to the file.
42 f = open(filename, 'w')
43 f.write(contents)
44 f.close()
46 def foo_to_bar(m):
47 return m.replace('foo', 'bar')
49 def append_foo(m):
50 return m + 'foo\n'
52 def identity(m):
53 return m
55 main()
56 sys.exit(0)