You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/08/15 22:04:35 UTC
svn commit: r1157972 - in /subversion/branches/fs-py/subversion:
libsvn_fs_py/fs_fs.c python/svn/fs.py
Author: hwright
Date: Mon Aug 15 20:03:41 2011
New Revision: 1157972
URL: http://svn.apache.org/viewvc?rev=1157972&view=rev
Log:
On the fs-py branch:
Implement the write_format() function in Python, thereby allowing the entire
"create a filesystem" functionality to live all in Python.
* subversion/python/svn/fs.py
(_write_format): New.
(FS._create_fs): Write the format file upon creation.
* subversion/libsvn_fs_py/fs_fs.c
(svn_fs_py__create): Remove any remaining C, just let the Python method do
the work!
Modified:
subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c
subversion/branches/fs-py/subversion/python/svn/fs.py
Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c?rev=1157972&r1=1157971&r2=1157972&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c Mon Aug 15 20:03:41 2011
@@ -6271,8 +6271,6 @@ svn_fs_py__create(svn_fs_t *fs,
apr_pool_t *pool)
{
fs_fs_data_t *ffd = fs->fsap_data;
- int max_files_per_dir;
- int format;
fs->path = apr_pstrdup(pool, path);
@@ -6282,14 +6280,6 @@ svn_fs_py__create(svn_fs_t *fs,
apr_pool_cleanup_register(fs->pool, ffd->p_fs, svn_fs_py__destroy_py_object,
apr_pool_cleanup_null);
- SVN_ERR(svn_fs_py__get_int_attr(&format, ffd->p_fs, "format"));
- SVN_ERR(svn_fs_py__get_int_attr(&max_files_per_dir, ffd->p_fs,
- "max_files_per_dir"));
-
- /* This filesystem is ready. Stamp it with a format number. */
- SVN_ERR(write_format(path_format(fs, pool),
- format, max_files_per_dir, FALSE, pool));
-
return SVN_NO_ERROR;
}
Modified: subversion/branches/fs-py/subversion/python/svn/fs.py
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/python/svn/fs.py?rev=1157972&r1=1157971&r2=1157972&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/python/svn/fs.py (original)
+++ subversion/branches/fs-py/subversion/python/svn/fs.py Mon Aug 15 20:03:41 2011
@@ -113,6 +113,31 @@ _DEFAULT_CONFIG_CONTENTS = \
CONFIG_OPTION_ENABLE_REP_SHARING)
+def _write_format(path, format, max_files_per_dir, overwrite=True):
+ assert 1 <= format and format <= FORMAT_NUMBER
+
+ if format >= MIN_LAYOUT_FORMAT_OPTION_FORMAT:
+ if max_files_per_dir:
+ contents = "%d\nlayout sharded %d\n" % (format, max_files_per_dir)
+ else:
+ contents = "%d\nlayout linear\n" % (format, max_files_per_dir)
+ else:
+ format = "%d\n" % format
+
+ if not overwrite:
+ with open(path, 'wb') as f:
+ f.write(contents)
+ else:
+ tempf = tempfile.NamedTemporaryFile(dir=os.path.dirname(path),
+ delete=False)
+ tempf.write(contents)
+ tempf.close()
+ os.rename(tempf.name, path)
+
+ # And set the perms to make it read only
+ os.chmod(path, stat.S_IREAD)
+
+
class FS(object):
def __path_rev_shard(self, rev):
assert self.max_files_per_dir
@@ -330,6 +355,10 @@ class FS(object):
with open(self.__path_txn_current_lock, 'wb') as f:
f.write('')
+ # This filesystem is ready. Stamp it with a format number.
+ _write_format(self.__path_format, self.format, self.max_files_per_dir,
+ False)
+
def _open_fs(self):
'Open an existing Subvesion filesystem'