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

[PATCH] eliminate -noproxy flag to SWIG

From: Philipp von Weitershausen <philipp_at_weitershausen.de>
Date: 2003-05-09 11:39:43 CEST

Hello,

here's a patch for my proposal to eliminate the -noproxy flag that is
passed to SWIG (sorry, I attached it because I wasn't sure what Mozilla
would do to long lines).

In order to make this patch work, a non-empty __init__.py file has to be
created in subversion/bindings/swig/python. The
subversion/bindings/swig/python/svn directory becomes obsolete.

A word about renaming symbols:

Yes, I think it is a good idea to rename all symbols like
svn_<lib>_<function> because python has the notion of module namespaces
(svn.<lib>.<function>). However, before that is done, we should agree on
a consistent naming convention for python (and other languages) and then
let SWIG do the renaming, not python with getattr.

So for now, authors of third-party python scripts using the fs module
will need to apply s/fs\./fs\.svn_fs/g to their scripts. I know this is
controversal, but I really think that at this stage we can still form
the python API like a piece of clay. It'll be harder when people are
relying on a piece of rock...

Log Message:

* Makefile.in
   Do not call SWIG with the -noproxy flag: build shadow classes
   instead of accessor functions for structs.

* subversion/bindings/swig/*.i
   This makes the provided python modules in
   subversion/bindings/swig/python/svn obsolete because SWIG needs to
   create its own. Thus included the additional code from the now
   obsolete modules in the SWIG macros using the %pythoncode directive.

* subversion/bindings/swig/svn_fs.i
   tools/*.py
   The old python module fs.py renamed all symbols beginning with svn_fs.
   This was not only totally inconsistent with the other modules, SWIG is
   also not doing this renaming. Thus, converted all python code using
   the fs module to use the prefix svn_fs.

Phil

Index: Makefile.in
===================================================================
--- Makefile.in (revision 5862)
+++ Makefile.in (working copy)
@@ -134,8 +134,8 @@
 
 # these commands run SWIG to generate wrapper source files (*.c)
 ### should we protect against swig not being available?
-RUN_SWIG_PY = $(SWIG) -c -python -noproxy $(SWIG_INCLUDES) $(SWIG_PY_INCLUDES) -o $@
-RUN_SWIG_JAVA = cd ${SWIG_SRC_DIR}/java/org/tigris/subversion/swig && $(SWIG) -c -java -noproxy -package 'org.tigris.subversion.swig' $(SWIG_INCLUDES) -o ${abs_builddir}/$@
+RUN_SWIG_PY = $(SWIG) -c -python $(SWIG_INCLUDES) $(SWIG_PY_INCLUDES) -o $@
+RUN_SWIG_JAVA = cd ${SWIG_SRC_DIR}/java/org/tigris/subversion/swig && $(SWIG) -c -java -package 'org.tigris.subversion.swig' $(SWIG_INCLUDES) -o ${abs_builddir}/$@
 
 # Compilation of SWIG-generated C source code
 COMPILE_PY_WRAPPER = $(LIBTOOL) $(LTFLAGS) --mode=compile $(SWIG_PY_COMPILE) $(SWIG_INCLUDES) $(SWIG_PY_INCLUDES) -prefer-pic -c -o $@
@@ -165,7 +165,7 @@
 INSTALL_SWIG_JAVA_LIB = $(INSTALL_LIB)
 
 # additional installation rules for the SWIG wrappers
-INSTALL_EXTRA_SWIG_PY=$(top_srcdir)/build/copy-swig-py.sh "$(PYTHON)" "$(INSTALL_DATA)" "${SWIG_SRC_DIR}/python/svn" "$(DESTDIR)$(swig_pydir)"
+INSTALL_EXTRA_SWIG_PY=$(top_srcdir)/build/copy-swig-py.sh "$(PYTHON)" "$(INSTALL_DATA)" "${SWIG_SRC_DIR}/python" "$(DESTDIR)$(swig_pydir)"
 INSTALL_EXTRA_SWIG_JAVA=:
 
 APXS = @APXS@
Index: subversion/bindings/swig/svn_ra.i
===================================================================
--- subversion/bindings/swig/svn_ra.i (revision 5862)
+++ subversion/bindings/swig/svn_ra.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _ra
+%module ra
 %include typemaps.i
 
 %import apr.i
Index: subversion/bindings/swig/svn_fs.i
===================================================================
--- subversion/bindings/swig/svn_fs.i (revision 5862)
+++ subversion/bindings/swig/svn_fs.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _fs
+%module fs
 %include typemaps.i
 
 %import apr.i
@@ -171,3 +171,108 @@
 #include "swigutil_java.h"
 #endif
 %}
+
+%pythoncode
+%{
+
+def entries(root, path, pool):
+ """
+ Call dir_entries returning a dictionary mappings names to IDs.
+ """
+ e = svn_fs_dir_entries(root, path, pool)
+ for name, entry in e.items():
+ e[name] = entry.id
+ return e
+
+class FileDiff:
+
+ def __init__(self, root1, path1, root2, path2, pool, diffoptions=[]):
+ assert path1 or path2
+
+ self.tempfile1 = None
+ self.tempfile2 = None
+
+ self.root1 = root1
+ self.path1 = path1
+ self.root2 = root2
+ self.path2 = path2
+ self.diffoptions = diffoptions
+
+ # the caller can't manage this pool very well given our indirect use
+ # of it. so we'll create a subpool and clear it at "proper" times.
+ self.pool = _util.svn_pool_create(pool)
+
+ def either_binary(self):
+ """
+ Return true if either of the files are binary.
+ """
+ if self.path1 is not None:
+ prop = svn_fs_node_prop(self.root1, self.path1,
+ _util.SVN_PROP_MIME_TYPE,
+ self.pool)
+ if prop and _util.svn_mime_type_is_binary(prop):
+ return 1
+ if self.path2 is not None:
+ prop = svn_fs_node_prop(self.root2, self.path2,
+ _util.SVN_PROP_MIME_TYPE,
+ self.pool)
+ if prop and _util.svn_mime_type_is_binary(prop):
+ return 1
+ return 0
+
+ def get_files(self):
+ if self.tempfile1:
+ # no need to do more. we ran this already.
+ return self.tempfile1, self.tempfile2
+
+ self.tempfile1 = tempfile.mktemp()
+ contents = ''
+ if self.path1 is not None:
+ len = svn_fs_file_length(self.root1, self.path1, self.pool)
+ stream = svn_fs_file_contents(self.root1, self.path1, self.pool)
+ contents = _util.svn_stream_read(stream, len)
+ open(self.tempfile1, 'w+').write(contents)
+
+ self.tempfile2 = tempfile.mktemp()
+ contents = ''
+ if self.path2 is not None:
+ len = svn_fs_file_length(self.root2, self.path2, self.pool)
+ stream = svn_fs_file_contents(self.root2, self.path2, self.pool)
+ contents = _util.svn_stream_read(stream, len)
+ open(self.tempfile2, 'w+').write(contents)
+
+ # get rid of anything we put into our subpool
+ _util.svn_pool_clear(self.pool)
+
+ return self.tempfile1, self.tempfile2
+
+ def get_pipe(self):
+ self.get_files()
+
+ # use an array for the command to avoid the shell and potential
+ # security exposures
+ cmd = ["diff"] \
+ + self.diffoptions \
+ + [self.tempfile1, self.tempfile2]
+
+ # open the pipe, forget the end for writing to the child (we won't),
+ # and then return the file object for reading from the child.
+ fromchild, tochild = popen2.popen2(cmd)
+ tochild.close()
+ return fromchild
+
+ def __del__(self):
+ # it seems that sometimes the files are deleted, so just ignore any
+ # failures trying to remove them
+ if self.tempfile1 is not None:
+ try:
+ os.remove(self.tempfile1)
+ except OSError:
+ pass
+ if self.tempfile2 is not None:
+ try:
+ os.remove(self.tempfile2)
+ except OSError:
+ pass
+
+%}
Index: subversion/bindings/swig/svn_wc.i
===================================================================
--- subversion/bindings/swig/svn_wc.i (revision 5862)
+++ subversion/bindings/swig/svn_wc.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _wc
+%module wc
 %include typemaps.i
 
 %import apr.i
Index: subversion/bindings/swig/svn_client.i
===================================================================
--- subversion/bindings/swig/svn_client.i (revision 5862)
+++ subversion/bindings/swig/svn_client.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _client
+%module client
 %include typemaps.i
 
 %import apr.i
Index: subversion/bindings/swig/util.i
===================================================================
--- subversion/bindings/swig/util.i (revision 5862)
+++ subversion/bindings/swig/util.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _util
+%module util
 
 %include typemaps.i
 
@@ -254,3 +254,56 @@
 #endif
 
 %}
+
+%pythoncode
+%{
+
+def run_app(func, *args, **kw):
+ '''Run a function as an "APR application".
+
+ APR is initialized, and an application pool is created. Cleanup is
+ performed as the function exits (normally or via an exception.
+ '''
+ apr_initialize()
+ try:
+ pool = svn_pool_create(None)
+ try:
+ return apply(func, (pool,) + args, kw)
+ finally:
+ svn_pool_destroy(pool)
+ finally:
+ apr_terminate()
+
+# some minor patchups
+svn_pool_destroy = apr_pool_destroy
+
+class Stream:
+ def __init__(self, stream):
+ self._stream = stream
+
+ def read(self, amt=None):
+ if amt is None:
+ # read the rest of the stream
+ chunks = [ ]
+ while 1:
+ data = svn_stream_read(self._stream, SVN_STREAM_CHUNK_SIZE)
+ if not data:
+ break
+ chunks.append(data)
+ return ''.join(chunks)
+
+ # read the amount specified
+ return svn_stream_read(self._stream, int(amt))
+
+ def write(self, buf):
+ ### what to do with the amount written? (the result value)
+ svn_stream_write(self._stream, buf)
+
+def secs_from_timestr(svn_datetime, pool):
+ aprtime = svn_time_from_cstring(svn_datetime, pool)
+
+ # ### convert to a time_t; this requires intimate knowledge of
+ # ### the apr_time_t type
+ # ### aprtime is microseconds; turn it into seconds
+ return aprtime / 1000000
+%}
Index: subversion/bindings/swig/svn_repos.i
===================================================================
--- subversion/bindings/swig/svn_repos.i (revision 5862)
+++ subversion/bindings/swig/svn_repos.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _repos
+%module repos
 %include typemaps.i
 
 %import apr.i
Index: subversion/bindings/swig/svn_delta.i
===================================================================
--- subversion/bindings/swig/svn_delta.i (revision 5862)
+++ subversion/bindings/swig/svn_delta.i (working copy)
@@ -16,7 +16,7 @@
  * ====================================================================
  */
 
-%module _delta
+%module delta
 
 %include "typemaps.i"
 
@@ -69,3 +69,56 @@
 #include "swigutil_java.h"
 #endif
 %}
+
+%pythoncode
+%{
+class Editor:
+
+ def set_target_revision(self, target_revision):
+ pass
+
+ def open_root(self, base_revision, dir_pool):
+ return None
+
+ def delete_entry(self, path, revision, parent_baton, pool):
+ pass
+
+ def add_directory(self, path, parent_baton,
+ copyfrom_path, copyfrom_revision, dir_pool):
+ return None
+
+ def open_directory(self, path, parent_baton, base_revision, dir_pool):
+ return None
+
+ def change_dir_prop(self, dir_baton, name, value, pool):
+ pass
+
+ def close_directory(self, dir_baton):
+ pass
+
+ def add_file(self, path, parent_baton,
+ copyfrom_path, copyfrom_revision, file_pool):
+ return None
+
+ def open_file(self, path, parent_baton, base_revision, file_pool):
+ return None
+
+ def apply_textdelta(self, file_baton, base_checksum):
+ return None
+
+ def change_file_prop(self, file_baton, name, value, pool):
+ pass
+
+ def close_file(self, text_checksum, file_baton):
+ pass
+
+ def close_edit(self):
+ pass
+
+ def abort_edit(self):
+ pass
+
+def make_editor(editor, pool):
+ return svn_swig_py_make_editor(editor, pool)
+
+%}
Index: tools/cvs2svn/cvs2svn.py
===================================================================
--- tools/cvs2svn/cvs2svn.py (revision 5862)
+++ tools/cvs2svn/cvs2svn.py (working copy)
@@ -214,9 +214,9 @@
     for i in range(1, len(parts) + 1):
       # reassemble the pieces, adding a leading slash
       parent_dir = '/' + string.join(parts[:i], '/')
- if fs.check_path(root, parent_dir, f_pool) == util.svn_node_none:
+ if fs.svn_fs_check_path(root, parent_dir, f_pool) == util.svn_node_none:
         print ' making dir:', parent_dir
- fs.make_dir(root, parent_dir, f_pool)
+ fs.svn_fs_make_dir(root, parent_dir, f_pool)
 
 def visit_file(arg, dirname, files):
   cd, p, stats = arg
@@ -341,9 +341,9 @@
     # create a pool for the entire commit
     c_pool = util.svn_pool_create(ctx.pool)
 
- rev = fs.youngest_rev(t_fs, c_pool)
- txn = fs.begin_txn(t_fs, rev, c_pool)
- root = fs.txn_root(txn, c_pool)
+ rev = fs.svn_fs_youngest_rev(t_fs, c_pool)
+ txn = fs.svn_fs_begin_txn(t_fs, rev, c_pool)
+ root = fs.svn_fs_txn_root(txn, c_pool)
 
     lastcommit = (None, None)
 
@@ -363,13 +363,13 @@
 
       make_path(fs, root, repos_path, f_pool)
 
- if fs.check_path(root, repos_path, f_pool) == util.svn_node_none:
+ if fs.svn_fs_check_path(root, repos_path, f_pool) == util.svn_node_none:
         created_file = 1
- fs.make_file(root, repos_path, f_pool)
+ fs.svn_fs_make_file(root, repos_path, f_pool)
       else:
         created_file = 0
 
- handler, baton = fs.apply_textdelta(root, repos_path, None, None, f_pool)
+ handler, baton = fs.svn_fs_apply_textdelta(root, repos_path, None, None, f_pool)
 
       # figure out the real file path for "co"
       try:
@@ -388,7 +388,7 @@
       if created_file:
         delta.svn_txdelta_send_string(pipe.read(), handler, baton, f_pool)
         if f_st[0] & stat.S_IXUSR:
- fs.change_node_prop(root, repos_path, "svn:executable", "", f_pool)
+ fs.svn_fs_change_node_prop(root, repos_path, "svn:executable", "", f_pool)
       else:
         # open an SVN stream onto the pipe
         stream2 = util.svn_stream_from_aprfile(pipe, f_pool)
@@ -403,7 +403,7 @@
                              % (lastcommit[1], f), "r", 102400)
           stream1 = util.svn_stream_from_aprfile(infile2, f_pool)
         else:
- stream1 = fs.file_contents(root, repos_path, f_pool)
+ stream1 = fs.svn_fs_file_contents(root, repos_path, f_pool)
 
         txstream = delta.svn_txdelta(stream1, stream2, f_pool)
         delta.svn_txdelta_send_txstream(txstream, handler, baton, f_pool)
@@ -441,7 +441,7 @@
       # fail, since it doesn't really exist.
       if r != '1.1':
         ### need to discriminate between OS paths and FS paths
- fs.delete(root, repos_path, f_pool)
+ fs.svn_fs_delete(root, repos_path, f_pool)
 
       for to_branch in branches:
         to_branch_path = branch_path(ctx, to_branch) + rel_name
@@ -459,10 +459,10 @@
     a = unicode(author, ctx.encoding)
 
     # put UTF-8 encoded unicode-"strings" into svn filesystem
- fs.change_txn_prop(txn, 'svn:author', a.encode('utf8'), c_pool)
- fs.change_txn_prop(txn, 'svn:log', l.encode('utf8'), c_pool)
+ fs.svn_fs_change_txn_prop(txn, 'svn:author', a.encode('utf8'), c_pool)
+ fs.svn_fs_change_txn_prop(txn, 'svn:log', l.encode('utf8'), c_pool)
 
- conflicts, new_rev = fs.commit_txn(txn)
+ conflicts, new_rev = fs.svn_fs_commit_txn(txn)
     if conflicts:
       # our commit processing should never generate a conflict. if we *do*
       # see something, then we've got some badness going on. punt.
@@ -471,29 +471,29 @@
     print ' new revision:', new_rev
 
     # set the time to the proper (past) time
- fs.change_rev_prop(t_fs, new_rev, 'svn:date', date, c_pool)
+ fs.svn_fs_change_rev_prop(t_fs, new_rev, 'svn:date', date, c_pool)
 
     if len(do_copies) > 0:
       # make a new transaction for the tags
- rev = fs.youngest_rev(t_fs, c_pool)
- txn = fs.begin_txn(t_fs, rev, c_pool)
- root = fs.txn_root(txn, c_pool)
+ rev = fs.svn_fs_youngest_rev(t_fs, c_pool)
+ txn = fs.svn_fs_begin_txn(t_fs, rev, c_pool)
+ root = fs.svn_fs_txn_root(txn, c_pool)
 
       for c_from, c_to, c_type in do_copies:
         print "copying", c_from, "to", c_to
 
- t_root = fs.revision_root(t_fs, rev, f_pool)
+ t_root = fs.svn_fs_revision_root(t_fs, rev, f_pool)
         make_path(fs, root, c_to, f_pool)
- fs.copy(t_root, c_from, root, c_to, f_pool)
+ fs.svn_fs_copy(t_root, c_from, root, c_to, f_pool)
 
         # clear the pool after each copy
         util.svn_pool_clear(f_pool)
 
       log_msg = "%d copies to tags/branches\n" % (len(do_copies))
- fs.change_txn_prop(txn, 'svn:author', "cvs2svn", c_pool)
- fs.change_txn_prop(txn, 'svn:log', log_msg, c_pool)
+ fs.svn_fs_change_txn_prop(txn, 'svn:author', "cvs2svn", c_pool)
+ fs.svn_fs_change_txn_prop(txn, 'svn:log', log_msg, c_pool)
 
- conflicts, new_rev = fs.commit_txn(txn)
+ conflicts, new_rev = fs.svn_fs_commit_txn(txn)
       if conflicts:
         # our commit processing should never generate a conflict. if we *do*
         # see something, then we've got some badness going on. punt.
Index: tools/hook-scripts/mailer.py
===================================================================
--- tools/hook-scripts/mailer.py (revision 5862)
+++ tools/hook-scripts/mailer.py (working copy)
@@ -389,7 +389,7 @@
       return
 
     output.write('\nDeleted: %s\n' % change.base_path)
- diff = svn.fs.FileDiff(repos.root_prev, change.base_path, None, None, pool)
+ diff = svn.fs.svn_fs_FileDiff(repos.root_prev, change.base_path, None, None, pool)
 
     label1 = '%s\t%s' % (change.base_path, date)
     label2 = '(empty file)'
@@ -406,7 +406,7 @@
       # note that we strip the leading slash from the base (copyfrom) path
       output.write('\nCopied: %s (from rev %d, %s)\n'
                    % (change.path, change.base_rev, change.base_path[1:]))
- diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
+ diff = svn.fs.svn_fs_FileDiff(repos.get_root(change.base_rev),
                              change.base_path[1:],
                              repos.root_this, change.path,
                              pool)
@@ -415,7 +415,7 @@
       singular = False
     else:
       output.write('\nAdded: %s\n' % change.path)
- diff = svn.fs.FileDiff(None, None, repos.root_this, change.path, pool)
+ diff = svn.fs.svn_fs_FileDiff(None, None, repos.root_this, change.path, pool)
       label1 = '(empty file)'
       label2 = '%s\t%s' % (change.path, date)
       singular = True
@@ -424,7 +424,7 @@
     return
   else:
     output.write('\nModified: %s\n' % change.path)
- diff = svn.fs.FileDiff(repos.get_root(change.base_rev), change.base_path[1:],
+ diff = svn.fs.svn_fs_FileDiff(repos.get_root(change.base_rev), change.base_path[1:],
                            repos.root_this, change.path,
                            pool)
     label1 = change.base_path[1:] + '\t(original)'
@@ -464,8 +464,8 @@
     if not os.path.exists(db_path):
       db_path = repos_dir
 
- self.fs_ptr = svn.fs.new(None, pool)
- svn.fs.open_berkeley(self.fs_ptr, db_path)
+ self.fs_ptr = svn.fs.svn_fs_new(None, pool)
+ svn.fs.svn_fs_open_berkeley(self.fs_ptr, db_path)
 
     self.roots = { }
 
@@ -475,14 +475,14 @@
     self.author = self.get_rev_prop(svn.util.SVN_PROP_REVISION_AUTHOR)
 
   def get_rev_prop(self, propname):
- return svn.fs.revision_prop(self.fs_ptr, self.rev, propname, self.pool)
+ return svn.fs.svn_fs_revision_prop(self.fs_ptr, self.rev, propname, self.pool)
 
   def get_root(self, rev):
     try:
       return self.roots[rev]
     except KeyError:
       pass
- root = self.roots[rev] = svn.fs.revision_root(self.fs_ptr, rev, self.pool)
+ root = self.roots[rev] = svn.fs.svn_fs_revision_root(self.fs_ptr, rev, self.pool)
     return root
 
 
@@ -500,7 +500,7 @@
     return ('', '', base_revision) # dir_baton
 
   def delete_entry(self, path, revision, parent_baton, pool):
- if svn.fs.is_dir(self.root_prev, '/' + path, pool):
+ if svn.fs.svn_fs_is_dir(self.root_prev, '/' + path, pool):
       item_type = ChangeCollector.DIR
     else:
       item_type = ChangeCollector.FILE
Index: tools/hook-scripts/tests/mailer-tweak.py
===================================================================
--- tools/hook-scripts/tests/mailer-tweak.py (revision 5862)
+++ tools/hook-scripts/tests/mailer-tweak.py (working copy)
@@ -24,14 +24,14 @@
   if not os.path.exists(db_path):
     db_path = home
 
- fsob = fs.new(pool)
- fs.open_berkeley(fsob, db_path)
+ fsob = fs.svn_fs_new(pool)
+ fs.svn_fs_open_berkeley(fsob, db_path)
 
- for i in range(fs.youngest_rev(fsob, pool)):
+ for i in range(fs.svn_fs_youngest_rev(fsob, pool)):
     # convert secs into microseconds, then a string
     date = util.svn_time_to_cstring((DATE_BASE+i*DATE_INCR) * 1000000L, pool)
     #print date
- fs.change_rev_prop(fsob, i+1, util.SVN_PROP_REVISION_DATE, date, pool)
+ fs.svn_fs_change_rev_prop(fsob, i+1, util.SVN_PROP_REVISION_DATE, date, pool)
 
 def main():
   if len(sys.argv) != 2:
Index: tools/examples/revplist.py
===================================================================
--- tools/examples/revplist.py (revision 5862)
+++ tools/examples/revplist.py (working copy)
@@ -27,22 +27,22 @@
   if not os.path.exists(db_path):
     db_path = home
 
- fs_ptr = fs.new(pool)
- fs.open_berkeley(fs_ptr, db_path)
+ fs_ptr = fs.svn_fs_new(pool)
+ fs.svn_fs_open_berkeley(fs_ptr, db_path)
 
   if rev is None:
- rev = fs.youngest_rev(fs_ptr, pool)
+ rev = fs.svn_fs_youngest_rev(fs_ptr, pool)
 
   print 'Properties for revision:', rev
   if props:
     for propname in props:
- value = fs.revision_prop(fs_ptr, rev, propname, pool)
+ value = fs.svn_fs_revision_prop(fs_ptr, rev, propname, pool)
       if value is None:
         print '%s: <not present>' % propname
       else:
         print '%s: %s' % (propname, value)
   else:
- proplist = fs.revision_proplist(fs_ptr, rev, pool)
+ proplist = fs.svn_fs_revision_proplist(fs_ptr, rev, pool)
     for propname, value in proplist.items():
       print '%s: %s' % (propname, value)
 
Index: tools/examples/putfile.py
===================================================================
--- tools/examples/putfile.py (revision 5862)
+++ tools/examples/putfile.py (working copy)
@@ -19,27 +19,27 @@
   if not os.path.exists(db_path):
     db_path = home
 
- fsob = fs.new(pool)
- fs.open_berkeley(fsob, db_path)
+ fsob = fs.svn_fs_new(pool)
+ fs.svn_fs_open_berkeley(fsob, db_path)
 
   # open a transaction against HEAD
- rev = fs.youngest_rev(fsob, pool)
+ rev = fs.svn_fs_youngest_rev(fsob, pool)
 
- txn = fs.begin_txn(fsob, rev, pool)
+ txn = fs.svn_fs_begin_txn(fsob, rev, pool)
   print `txn`
 
- root = fs.txn_root(txn, pool)
- fs.make_file(root, rpath, pool)
+ root = fs.svn_fs_txn_root(txn, pool)
+ fs.svn_fs_make_file(root, rpath, pool)
 
- handler, baton = fs.apply_textdelta(root, rpath, pool)
+ handler, baton = fs.svn_fs_apply_textdelta(root, rpath, pool)
 
   ### it would be nice to get an svn_stream_t. for now, just load in the
- ### whole file and shove it into the FS.
+ ### whole file and shove it into the FS.SVN_FS_
   _delta.svn_txdelta_send_string(open(fname, 'rb').read(),
                                  handler, baton,
                                  pool)
 
- conflicts, new_rev = fs.commit_txn(txn)
+ conflicts, new_rev = fs.svn_fs_commit_txn(txn)
   if conflicts:
     print 'conflicts:', conflicts
   print 'New revision:', new_rev
Index: tools/examples/dumpprops.py
===================================================================
--- tools/examples/dumpprops.py (revision 5862)
+++ tools/examples/dumpprops.py (working copy)
@@ -19,19 +19,19 @@
   if not os.path.exists(db_path):
     db_path = home
 
- fsob = fs.new(pool)
- fs.open_berkeley(fsob, db_path)
+ fsob = fs.svn_fs_new(pool)
+ fs.svn_fs_open_berkeley(fsob, db_path)
 
   if rev is None:
- rev = fs.youngest_rev(fsob, pool)
+ rev = fs.svn_fs_youngest_rev(fsob, pool)
 
- root = fs.revision_root(fsob, rev, pool)
+ root = fs.svn_fs_revision_root(fsob, rev, pool)
   print_props(root, path, pool)
- if fs.is_dir(root, path, pool):
+ if fs.svn_fs_is_dir(root, path, pool):
     walk_tree(root, path, pool)
 
 def print_props(root, path, pool):
- raw_props = fs.node_proplist(root, path, pool)
+ raw_props = fs.svn_fs_node_proplist(root, path, pool)
   # need to massage some buffers into strings for printing
   props = { }
   for key, value in raw_props.items():
@@ -43,10 +43,10 @@
 def walk_tree(root, path, pool):
   subpool = util.svn_pool_create(pool)
   try:
- for name in fs.entries(root, path, subpool).keys():
+ for name in fs.svn_fs_entries(root, path, subpool).keys():
       full = path + '/' + name
       print_props(root, full, subpool)
- if fs.is_dir(root, full, subpool):
+ if fs.svn_fs_is_dir(root, full, subpool):
         walk_tree(root, full, subpool)
       util.svn_pool_clear(subpool)
   finally:
Index: tools/examples/svnlook.py
===================================================================
--- tools/examples/svnlook.py (revision 5862)
+++ tools/examples/svnlook.py (working copy)
@@ -31,18 +31,18 @@
     self.fs_ptr = _repos.svn_repos_fs(repos)
 
     if txn:
- self.txn_ptr = fs.open_txn(self.fs_ptr, txn, pool)
+ self.txn_ptr = fs.svn_fs_open_txn(self.fs_ptr, txn, pool)
     else:
       self.txn_ptr = None
       if rev is None:
- rev = fs.youngest_rev(self.fs_ptr, pool)
+ rev = fs.svn_fs_youngest_rev(self.fs_ptr, pool)
     self.rev = rev
 
     try:
       getattr(self, 'cmd_' + cmd)()
     finally:
       if self.txn_ptr:
- fs.close_txn(txn_ptr)
+ fs.svn_fs_close_txn(txn_ptr)
 
   def cmd_default(self):
     self.cmd_info()
@@ -99,26 +99,26 @@
 
   def _get_property(self, name):
     if self.txn_ptr:
- return fs.txn_prop(self.txn_ptr, name, self.pool)
- return fs.revision_prop(self.fs_ptr, self.rev, name, self.pool)
+ return fs.svn_fs_txn_prop(self.txn_ptr, name, self.pool)
+ return fs.svn_fs_revision_prop(self.fs_ptr, self.rev, name, self.pool)
 
   def _print_tree(self, e_factory, base_rev=None, pass_root=0):
     if base_rev is None:
       # a specific base rev was not provided. use the transaction base,
       # or the previous revision
       if self.txn_ptr:
- base_rev = fs.txn_base_revision(self.txn_ptr)
+ base_rev = fs.svn_fs_txn_base_revision(self.txn_ptr)
       else:
         base_rev = self.rev - 1
 
     # get the current root
     if self.txn_ptr:
- root = fs.txn_root(self.txn_ptr, self.pool)
+ root = fs.svn_fs_txn_root(self.txn_ptr, self.pool)
     else:
- root = fs.revision_root(self.fs_ptr, self.rev, self.pool)
+ root = fs.svn_fs_revision_root(self.fs_ptr, self.rev, self.pool)
 
     # the base of the comparison
- base_root = fs.revision_root(self.fs_ptr, base_rev, self.pool)
+ base_root = fs.svn_fs_revision_root(self.fs_ptr, base_rev, self.pool)
 
     if pass_root:
       editor = e_factory(root, base_root)
@@ -166,8 +166,8 @@
 
   def _get_id(self, path, pool):
     if self.root:
- id = fs.node_id(self.root, path, pool)
- return ' <%s>' % fs.unparse_id(id, pool)
+ id = fs.svn_fs_node_id(self.root, path, pool)
+ return ' <%s>' % fs.svn_fs_unparse_id(id, pool)
     return ''
 
 
@@ -214,7 +214,7 @@
 
   def delete_entry(self, path, revision, parent_baton, pool):
     ### need more logic to detect 'replace'
- if fs.is_dir(self.base_root, '/' + path, pool):
+ if fs.svn_fs_is_dir(self.base_root, '/' + path, pool):
       print 'D ' + path + '/'
     else:
       print 'D ' + path
@@ -283,7 +283,7 @@
     args.append("-L")
     args.append(label + "\t(new)")
     args.append("-u")
- differ = fs.FileDiff(self.base_root, base_path, self.root,
+ differ = fs.svn_fs_FileDiff(self.base_root, base_path, self.root,
                          path, pool, args)
     pobj = differ.get_pipe()
     while 1:
@@ -295,7 +295,7 @@
     
   def delete_entry(self, path, revision, parent_baton, pool):
     ### need more logic to detect 'replace'
- if not fs.is_dir(self.base_root, '/' + path, pool):
+ if not fs.svn_fs_is_dir(self.base_root, '/' + path, pool):
       self._do_diff(path, None, pool)
 
   def add_file(self, path, parent_baton,
Index: tools/examples/svnshell.py
===================================================================
--- tools/examples/svnshell.py (revision 5862)
+++ tools/examples/svnshell.py (working copy)
@@ -33,9 +33,9 @@
     self.taskpool = util.svn_pool_create(pool)
     self.fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(path, pool))
     self.is_rev = 1
- self.rev = fs.youngest_rev(self.fs_ptr, pool)
+ self.rev = fs.svn_fs_youngest_rev(self.fs_ptr, pool)
     self.txn = None
- self.root = fs.revision_root(self.fs_ptr, self.rev, pool)
+ self.root = fs.svn_fs_revision_root(self.fs_ptr, self.rev, pool)
     self.path = "/"
     self._do_prompt()
 
@@ -59,7 +59,7 @@
       print "You must supply a file path."
       return
     catpath = self._parse_path(args[0])
- kind = fs.check_path(self.root, catpath, self.taskpool)
+ kind = fs.svn_fs_check_path(self.root, catpath, self.taskpool)
     if kind == util.svn_node_none:
       print "Path '%s' does not exist." % catpath
       return
@@ -68,8 +68,8 @@
       return
     ### be nice to get some paging in here. also, not reading the
     ### whole contents of the file at once. but whatever.
- filelen = fs.file_length(self.root, catpath, self.taskpool)
- stream = fs.file_contents(self.root, catpath, self.taskpool)
+ filelen = fs.svn_fs_file_length(self.root, catpath, self.taskpool)
+ stream = fs.svn_fs_file_contents(self.root, catpath, self.taskpool)
     print util.svn_stream_read(stream, filelen)
     
   def cmd_cd(self, *args):
@@ -80,7 +80,7 @@
     newpath = self._parse_path(args[0])
     
     # make sure that path actually exists in the filesystem as a directory
- kind = fs.check_path(self.root, newpath, self.taskpool)
+ kind = fs.svn_fs_check_path(self.root, newpath, self.taskpool)
     if kind != util.svn_node_dir:
       print "Path '%s' is not a valid filesystem directory." % newpath
       return
@@ -93,20 +93,20 @@
     parent = self.path
     if not len(args):
       # no args -- show a listing for the current directory.
- entries = fs.dir_entries(self.root, self.path, self.taskpool)
+ entries = fs.svn_fs_dir_entries(self.root, self.path, self.taskpool)
     else:
       # args? show a listing of that path.
       newpath = self._parse_path(args[0])
- kind = fs.check_path(self.root, newpath, self.taskpool)
+ kind = fs.svn_fs_check_path(self.root, newpath, self.taskpool)
       if kind == util.svn_node_dir:
         parent = newpath
- entries = fs.dir_entries(self.root, parent, self.taskpool)
+ entries = fs.svn_fs_dir_entries(self.root, parent, self.taskpool)
       elif kind == util.svn_node_file:
         parts = self._path_to_parts(newpath)
         name = parts.pop(-1)
         parent = self._parts_to_path(parts)
         print parent + ':' + name
- tmpentries = fs.dir_entries(self.root, parent, self.taskpool)
+ tmpentries = fs.svn_fs_dir_entries(self.root, parent, self.taskpool)
         if not tmpentries.get(name, None):
           return
         entries = {}
@@ -124,20 +124,20 @@
     for entry in keys:
       fullpath = parent + '/' + entry
       size = ''
- is_dir = fs.is_dir(self.root, fullpath, self.taskpool)
+ is_dir = fs.svn_fs_is_dir(self.root, fullpath, self.taskpool)
       if is_dir:
         name = entry + '/'
       else:
- size = str(fs.file_length(self.root, fullpath, self.taskpool))
+ size = str(fs.svn_fs_file_length(self.root, fullpath, self.taskpool))
         name = entry
- node_id = fs.unparse_id(fs.dirent_t_id_get(entries[entry]),
- self.taskpool)
- created_rev = fs.node_created_rev(self.root, fullpath, self.taskpool)
- author = fs.revision_prop(self.fs_ptr, created_rev,
+ node_id = fs.svn_fs_unparse_id(entries[entry].id,
+ self.taskpool)
+ created_rev = fs.svn_fs_node_created_rev(self.root, fullpath, self.taskpool)
+ author = fs.svn_fs_revision_prop(self.fs_ptr, created_rev,
                                 util.SVN_PROP_REVISION_AUTHOR, self.taskpool)
       if not author:
         author = ""
- date = fs.revision_prop(self.fs_ptr, created_rev,
+ date = fs.svn_fs_revision_prop(self.fs_ptr, created_rev,
                               util.SVN_PROP_REVISION_DATE, self.taskpool)
       if not date:
         date = ""
@@ -150,7 +150,7 @@
   
   def cmd_lstxns(self, *args):
     """list the transactions available for browsing"""
- txns = fs.list_transactions(self.fs_ptr, self.taskpool)
+ txns = fs.svn_fs_list_transactions(self.fs_ptr, self.taskpool)
     txns.sort()
     counter = 0
     for txn in txns:
@@ -168,11 +168,11 @@
     catpath = self.path
     if args:
       catpath = self._parse_path(args[0])
- kind = fs.check_path(self.root, catpath, self.taskpool)
+ kind = fs.svn_fs_check_path(self.root, catpath, self.taskpool)
     if kind == util.svn_node_none:
       print "Path '%s' does not exist." % catpath
       return
- plist = fs.node_proplist(self.root, catpath, self.taskpool)
+ plist = fs.svn_fs_node_proplist(self.root, catpath, self.taskpool)
     if not plist:
       return
     for pkey, pval in plist.items():
@@ -187,11 +187,11 @@
     args = args[0]
     try:
       rev = int(args[0])
- newroot = fs.revision_root(self.fs_ptr, rev, self.pool)
+ newroot = fs.svn_fs_revision_root(self.fs_ptr, rev, self.pool)
     except:
       print "Error setting the revision to '" + str(rev) + "'."
       return
- fs.close_root(self.root)
+ fs.svn_fs_close_root(self.root)
     self.root = newroot
     self.rev = rev
     self.is_rev = 1
@@ -202,12 +202,12 @@
     args = args[0]
     txn = args[0]
     try:
- txnobj = fs.open_txn(self.fs_ptr, txn, self.pool)
- newroot = fs.txn_root(txnobj, self.pool)
+ txnobj = fs.svn_fs_open_txn(self.fs_ptr, txn, self.pool)
+ newroot = fs.svn_fs_txn_root(txnobj, self.pool)
     except:
       print "Error setting the transaction to '" + txn + "'."
       return
- fs.close_root(self.root)
+ fs.svn_fs_close_root(self.root)
     self.root = newroot
     self.txn = txn
     self.is_rev = 0
@@ -215,7 +215,7 @@
   
   def cmd_youngest(self, *args):
     """list the youngest revision available for browsing"""
- rev = fs.youngest_rev(self.fs_ptr, self.taskpool)
+ rev = fs.svn_fs_youngest_rev(self.fs_ptr, self.taskpool)
     print rev
     util.svn_pool_clear(self.taskpool)
 
@@ -260,7 +260,7 @@
     not_found = 1
     newpath = self.path
     while not_found:
- kind = fs.check_path(self.root, newpath, self.taskpool)
+ kind = fs.svn_fs_check_path(self.root, newpath, self.taskpool)
       if kind == util.svn_node_dir:
         not_found = 0
       else:
Index: tools/examples/getfile.py
===================================================================
--- tools/examples/getfile.py (revision 5862)
+++ tools/examples/getfile.py (working copy)
@@ -19,14 +19,14 @@
   if not os.path.exists(db_path):
     db_path = home
 
- fsob = fs.new(pool)
- fs.open_berkeley(fsob, db_path)
+ fsob = fs.svn_fs_new(pool)
+ fs.svn_fs_open_berkeley(fsob, db_path)
 
   if rev is None:
- rev = fs.youngest_rev(fsob, pool)
+ rev = fs.svn_fs_youngest_rev(fsob, pool)
 
- root = fs.revision_root(fsob, rev, pool)
- file = fs.file_contents(root, path, pool)
+ root = fs.svn_fs_revision_root(fsob, rev, pool)
+ file = fs.svn_fs_file_contents(root, path, pool)
   while 1:
     data = util.svn_stream_read(file, CHUNK_SIZE)
     if not data:
Index: tools/examples/blame.py
===================================================================
--- tools/examples/blame.py (revision 5862)
+++ tools/examples/blame.py (working copy)
@@ -17,27 +17,27 @@
   if not os.path.exists(db_path):
     db_path = home
   annotresult = {}
- fsob = fs.new(pool)
- fs.open_berkeley(fsob, db_path)
+ fsob = fs.svn_fs_new(pool)
+ fs.svn_fs_open_berkeley(fsob, db_path)
   
   if rev is None:
- rev = fs.youngest_rev(fsob, pool)
+ rev = fs.svn_fs_youngest_rev(fsob, pool)
   filedata = ''
   for i in xrange(0, rev+1):
- root = fs.revision_root(fsob, i, pool)
- if fs.check_path(root, path, pool) != util.svn_node_none:
+ root = fs.svn_fs_revision_root(fsob, i, pool)
+ if fs.svn_fs_check_path(root, path, pool) != util.svn_node_none:
       first = i
       break
   print "First revision is %d" % first
   print "Last revision is %d" % rev
   for i in xrange(first, rev+1):
     previousroot = root
- root = fs.revision_root(fsob, i, pool)
+ root = fs.svn_fs_revision_root(fsob, i, pool)
     if i != first:
- if not fs.contents_changed(root, path, previousroot, path, pool):
+ if not fs.svn_fs_contents_changed(root, path, previousroot, path, pool):
         continue
       
- file = fs.file_contents(root, path, pool)
+ file = fs.svn_fs_file_contents(root, path, pool)
     previousdata = filedata
     filedata = ''
     while 1:
Index: tools/examples/geturl.py
===================================================================
--- tools/examples/geturl.py (revision 5862)
+++ tools/examples/geturl.py (working copy)
@@ -19,7 +19,7 @@
     adm_baton = svn.wc.svn_wc_adm_open(None, dirpath, 1, 1, pool)
     try:
       entry = svn.wc.svn_wc_entry(fullpath, adm_baton, 0, pool)
- print svn.wc.svn_wc_entry_t_url_get(entry)
+ print entry.url
     finally:
       svn.wc.svn_wc_adm_close(adm_baton)
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 9 11:39:42 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.