Rev 1069: Add macro for busy handling, add function for setting busy handler. in file:///data/jelmer/bzr-svn/cext/
Jelmer Vernooij
jelmer at samba.org
Tue Jun 3 11:49:09 BST 2008
At file:///data/jelmer/bzr-svn/cext/
------------------------------------------------------------
revno: 1069
revision-id: jelmer at samba.org-20080603104909-pymko73ppxj2shrd
parent: jelmer at samba.org-20080603104535-s2yjz3q30zgrtys7
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: cext
timestamp: Tue 2008-06-03 12:49:09 +0200
message:
Add macro for busy handling, add function for setting busy handler.
modified:
errors.py errors.py-20061226172623-w1sbj8ynpo0eojqp-1
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_workingtree.py test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
workingtree.py workingtree.py-20060306120941-b083cb0fdd4a69de
=== modified file 'errors.py'
--- a/errors.py 2008-05-30 02:30:03 +0000
+++ b/errors.py 2008-06-03 10:49:09 +0000
@@ -109,11 +109,6 @@
return convert
-class LocalCommitsUnsupported(BzrError):
-
- _fmt = 'Local commits are not supported for lightweight Subversion checkouts.'
-
-
class InvalidPropertyValue(BzrError):
_fmt = 'Invalid property value for Subversion property %(property)s: %(msg)s'
=== modified file 'ra.c'
--- a/ra.c 2008-06-03 07:43:09 +0000
+++ b/ra.c 2008-06-03 10:49:09 +0000
@@ -93,6 +93,8 @@
}
}
+#define RA_UNBUSY(pool, ra) ra->busy = false;
+
typedef struct {
PyObject_HEAD
const svn_ra_reporter2_t *reporter;
@@ -467,6 +469,7 @@
PyObject *progress_func;
AuthObject *auth;
bool busy;
+ PyObject *unbusy_handler;
} RemoteAccessObject;
static bool ra_check_busy(RemoteAccessObject *raobj)
@@ -570,9 +573,8 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_uuid(ra->ra, &uuid, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
ret = PyString_FromString(uuid);
apr_pool_destroy(temp_pool);
return ret;
@@ -594,9 +596,8 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_reparent(ra->ra, url, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
Py_RETURN_NONE;
}
@@ -616,10 +617,9 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_get_latest_revnum(ra->ra, &latest_revnum, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
return PyInt_FromLong(latest_revnum);
}
@@ -658,12 +658,11 @@
apr_pool_destroy(temp_pool);
return NULL;
}
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_log(ra->ra,
apr_paths, start, end, limit,
discover_changed_paths, strict_node_history, py_svn_log_wrapper,
callback, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
Py_RETURN_NONE;
}
@@ -683,10 +682,9 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_get_repos_root(ra->ra, &root, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
return PyString_FromString(root);
}
@@ -712,7 +710,6 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_do_update(ra->ra, &reporter,
&report_baton,
revision_to_update_to,
@@ -751,7 +748,6 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_do_switch(
ra->ra, &reporter, &report_baton,
revision_to_update_to, update_target,
@@ -784,13 +780,12 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_replay(ra->ra, revision, low_water_mark,
send_deltas, &py_editor, update_editor,
temp_pool));
apr_pool_destroy(temp_pool);
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
Py_RETURN_NONE;
}
@@ -811,10 +806,9 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_rev_proplist(ra->ra, rev, &props, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
py_props = prop_hash_to_dict(props);
apr_pool_destroy(temp_pool);
return py_props;
@@ -859,7 +853,6 @@
return NULL;
}
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_commit_editor2(ra->ra, &editor,
&edit_baton,
PyString_AsString(PyDict_GetItemString(revprops, SVN_PROP_REVISION_LOG)), py_commit_callback,
@@ -887,11 +880,10 @@
if (temp_pool == NULL)
return NULL;
val_string = svn_string_ncreate(value, vallen, temp_pool);
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_change_rev_prop(ra->ra, rev, name, val_string,
temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
Py_RETURN_NONE;
}
@@ -925,10 +917,9 @@
if (revision != SVN_INVALID_REVNUM)
fetch_rev = revision;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_dir2(ra->ra, &dirents, &fetch_rev, &props,
path, revision, dirent_fields, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
if (dirents == NULL) {
py_dirents = Py_None;
@@ -983,10 +974,9 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_get_lock(ra->ra, &lock, path, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
return wrap_lock(lock);
}
@@ -1007,11 +997,10 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_check_path(ra->ra, path, revision, &kind,
temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
return PyInt_FromLong(kind);
}
@@ -1033,10 +1022,9 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool,
svn_ra_has_capability(ra->ra, &has, capability, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
return PyBool_FromLong(has);
#else
@@ -1067,10 +1055,9 @@
while (PyDict_Next(path_tokens, &idx, &k, &v)) {
apr_hash_set(hash_path_tokens, PyString_AsString(k), PyString_Size(k), (char *)PyString_AsString(v));
}
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_unlock(ra->ra, hash_path_tokens, break_lock,
py_lock_func, lock_func, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
Py_RETURN_NONE;
@@ -1110,10 +1097,9 @@
apr_hash_set(hash_path_revs, PyString_AsString(k), PyString_Size(k),
PyString_AsString(v));
}
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_lock(ra->ra, hash_path_revs, comment, steal_lock,
py_lock_func, lock_func, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
return NULL;
}
@@ -1139,9 +1125,8 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_locks(ra->ra, &hash_locks, path, temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
ret = PyDict_New();
for (idx = apr_hash_first(temp_pool, hash_locks); idx != NULL;
@@ -1177,12 +1162,11 @@
temp_pool = Pool();
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_locations(ra->ra, &hash_locations,
path, peg_revision,
revnum_list_to_apr_array(temp_pool, location_revisions),
temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
ret = PyDict_New();
for (idx = apr_hash_first(temp_pool, hash_locations); idx != NULL;
@@ -1212,11 +1196,10 @@
if (temp_pool == NULL)
return NULL;
- ra->busy = true;
RUN_SVN_WITH_POOL(temp_pool, svn_ra_get_file_revs(ra->ra, path, start, end,
py_file_rev_handler, (void *)file_rev_handler,
temp_pool));
- ra->busy = false;
+ RA_UNBUSY(temp_pool, ra);
apr_pool_destroy(temp_pool);
@@ -1236,7 +1219,13 @@
return PyString_FromFormat("RemoteAccess(%s)", ra->url);
}
+static PyObject *ra_set_unbusy_handler(PyObject *self, PyObject *args)
+{
+ Py_RETURN_NONE; /* FIXME */
+}
+
static PyMethodDef ra_methods[] = {
+ { "set_unbusy_handler", ra_set_unbusy_handler, METH_VARARGS, NULL },
{ "get_file_revs", ra_get_file_revs, METH_VARARGS, NULL },
{ "get_locations", ra_get_locations, METH_VARARGS, NULL },
{ "get_locks", ra_get_locks, METH_VARARGS, NULL },
=== modified file 'repository.py'
--- a/repository.py 2008-05-30 02:38:27 +0000
+++ b/repository.py 2008-06-03 10:49:09 +0000
@@ -19,7 +19,8 @@
from bzrlib import osutils, ui, urlutils, xml5
from bzrlib.branch import Branch, BranchCheckResult
from bzrlib.errors import (InvalidRevisionId, NoSuchRevision, NotBranchError,
- UninitializableFormat, UnrelatedBranches)
+ UninitializableFormat, UnrelatedBranches,
+ NotWriteLocked)
from bzrlib.graph import CachingParentsProvider
from bzrlib.inventory import Inventory
from bzrlib.lockable_files import LockableFiles, TransportLock
@@ -782,3 +783,13 @@
else:
assert False
+ def abort_write_group(self):
+ self._write_group = None
+
+ def commit_write_group(self):
+ self._write_group = None
+
+ def start_write_group(self):
+ if not self.is_write_locked():
+ raise NotWriteLocked(self)
+ self._write_group = None
=== modified file 'tests/test_workingtree.py'
--- a/tests/test_workingtree.py 2008-03-27 01:49:00 +0000
+++ b/tests/test_workingtree.py 2008-06-03 10:49:09 +0000
@@ -335,7 +335,13 @@
self.build_tree({"dc/bl": "data"})
tree = self.open_checkout("dc")
self.assertEqual([], tree.pending_merges())
-
+
+ def test_get_parent_ids(self):
+ self.make_client('a', 'dc')
+ self.build_tree({"dc/bl": "data"})
+ tree = self.open_checkout("dc")
+ self.assertEqual([Branch.open('a').last_revision()], tree.get_parent_ids())
+
def test_delta(self):
self.make_client('a', 'dc')
self.build_tree({"dc/bl": "data"})
=== modified file 'workingtree.py'
--- a/workingtree.py 2008-06-03 08:13:55 +0000
+++ b/workingtree.py 2008-06-03 10:49:09 +0000
@@ -16,7 +16,7 @@
"""Checkouts and working trees (working copies)."""
import bzrlib, bzrlib.add
-from bzrlib import urlutils
+from bzrlib import osutils, urlutils, ignores
from bzrlib.branch import PullResult
from bzrlib.bzrdir import BzrDirFormat, BzrDir
from bzrlib.errors import (InvalidRevisionId, NotBranchError, NoSuchFile,
@@ -25,7 +25,6 @@
from bzrlib.inventory import Inventory, InventoryFile, InventoryLink
from bzrlib.lockable_files import TransportLock, LockableFiles
from bzrlib.lockdir import LockDir
-from bzrlib.osutils import file_kind, fingerprint_file, supports_executable
from bzrlib.revision import NULL_REVISION
from bzrlib.trace import mutter
from bzrlib.revisiontree import RevisionTree
@@ -36,7 +35,7 @@
from commit import _revision_id_to_svk_feature
import constants
from convert import SvnConverter
-from errors import LocalCommitsUnsupported, NoSvnRepositoryPresent
+from errors import NoSvnRepositoryPresent
from bzrlib.plugins.svn.mapping import (SVN_PROP_BZR_ANCESTRY, SVN_PROP_BZR_FILEIDS,
SVN_PROP_BZR_REVISION_ID, SVN_PROP_BZR_REVISION_INFO,
generate_revision_metadata)
@@ -97,15 +96,16 @@
self._control_files = LockableFiles(control_transport, 'lock', LockDir)
def get_ignore_list(self):
- ignores = set([wc.get_adm_dir()])
- ignores.update(wc.get_default_ignores(svn_config))
+ ignore_globs = set([wc.get_adm_dir()])
+ ignore_globs.update(ignores.get_runtime_ignores())
+ ignore_globs.update(ignores.get_user_ignores())
def dir_add(adm, prefix, patprefix):
ignorestr = adm.prop_get(constants.PROP_IGNORE,
self.abspath(prefix).rstrip("/"))
if ignorestr is not None:
for pat in ignorestr.splitlines():
- ignores.add(urlutils.joinpath(patprefix, pat))
+ ignore_globs.add(urlutils.joinpath(patprefix, pat))
entries = adm.entries_read(False)
for entry in entries:
@@ -131,7 +131,7 @@
finally:
adm.close()
- return ignores
+ return ignore_globs
def is_control_filename(self, path):
return wc.is_adm_dir(path)
@@ -263,7 +263,7 @@
file = InventoryFile(id, os.path.basename(relpath), parent_id)
file.revision = revid
try:
- data = fingerprint_file(open(self.abspath(relpath)))
+ data = osutils.fingerprint_file(open(self.abspath(relpath)))
file.text_sha1 = data['sha1']
file.text_size = data['size']
file.executable = self.is_executable(id, relpath)
@@ -415,85 +415,6 @@
adm.close()
self.base_revid = revid
- def commit(self, message=None, message_callback=None, revprops=None,
- timestamp=None, timezone=None, committer=None, rev_id=None,
- allow_pointless=True, strict=False, verbose=False, local=False,
- reporter=None, config=None, specific_files=None, author=None):
- if author is not None:
- revprops['author'] = author
- # FIXME: Use allow_pointless
- # FIXME: Use verbose
- # FIXME: Use reporter
- # FIXME: Use strict
- if local:
- raise LocalCommitsUnsupported()
-
- if specific_files:
- specific_files = [self.abspath(x).encode('utf8') for x in specific_files]
- else:
- specific_files = [self.basedir.encode('utf8')]
-
- if message_callback is not None:
- def log_message_func(items):
- """ Simple log message provider for unit tests. """
- return message_callback(self).encode("utf-8")
- else:
- assert isinstance(message, basestring)
- def log_message_func(items):
- """ Simple log message provider for unit tests. """
- return message.encode("utf-8")
-
- import client
- self.client_ctx = client.Client()
- self.client_ctx.set_log_msg_func(log_message_func)
- if rev_id is not None:
- extra = "%d %s\n" % (self.branch.revno()+1, rev_id)
- else:
- extra = ""
- adm = self._get_wc(write_lock=True)
- try:
- adm.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme),
- self._get_bzr_revids(self._get_base_branch_props()) + extra,
- self.basedir)
- adm.prop_set(SVN_PROP_BZR_REVISION_INFO,
- generate_revision_metadata(timestamp,
- timezone,
- committer,
- revprops),
- self.basedir)
- finally:
- adm.close()
-
- try:
- try:
- commit_info = self.client_ctx.commit(specific_files, True, False)
- except SubversionException, (_, num):
- if num == constants.ERR_FS_TXN_OUT_OF_DATE:
- raise OutOfDateTree(self)
- raise
- except:
- # Reset properties so the next subversion commit won't
- # accidently set these properties.
- adm = self._get_wc(write_lock=True)
- base_branch_props = self._get_base_branch_props()
- adm.prop_set(SVN_PROP_BZR_REVISION_ID+str(self.branch.mapping.scheme),
- self._get_bzr_revids(base_branch_props), self.basedir)
- adm.prop_set(SVN_PROP_BZR_REVISION_INFO,
- base_branch_props.get(SVN_PROP_BZR_REVISION_INFO, ""),
- self.basedir)
- adm.close()
- raise
-
- self.client_ctx.set_log_msg_func(None)
-
- revid = self.branch.generate_revision_id(commit_info[0])
-
- self.base_revid = revid
- self.base_revnum = commit_info[0]
- self.base_tree = None
-
- return revid
-
def smart_add(self, file_list, recurse=True, action=None, save=True):
assert isinstance(recurse, bool)
if action is None:
@@ -516,7 +437,7 @@
mutter('adding %r' % file_path)
adm.add(file_path, None, 0, None, None, None)
added.append(file_path)
- if recurse and file_kind(file_path) == 'directory':
+ if recurse and osutils.file_kind(file_path) == 'directory':
# Filter out ignored files and update ignored
for c in os.listdir(file_path):
if self.is_control_filename(c):
@@ -594,7 +515,7 @@
def get_file_sha1(self, file_id, path=None, stat_value=None):
if not path:
path = self._inventory.id2path(file_id)
- return fingerprint_file(open(self.abspath(path)))['sha1']
+ return osutils.fingerprint_file(open(self.abspath(path)))['sha1']
def _change_fileid_mapping(self, id, path, adm=None):
if adm is None:
@@ -669,6 +590,9 @@
merges.append(revid)
self.set_pending_merges(merges)
+ def get_parent_ids(self):
+ return [self.base_revid] + self.pending_merges()
+
def pending_merges(self):
merged = self._get_bzr_merges(self._get_base_branch_props()).splitlines()
adm = self._get_wc()
@@ -690,6 +614,32 @@
return []
+ def path_content_summary(self, path, _lstat=os.lstat,
+ _mapper=osutils.file_kind_from_stat_mode):
+ """See Tree.path_content_summary."""
+ abspath = self.abspath(path)
+ try:
+ stat_result = _lstat(abspath)
+ except OSError, e:
+ if getattr(e, 'errno', None) == errno.ENOENT:
+ # no file.
+ return ('missing', None, None, None)
+ # propagate other errors
+ raise
+ kind = _mapper(stat_result.st_mode)
+ if kind == 'file':
+ size = stat_result.st_size
+ # try for a stat cache lookup
+ executable = self._is_executable_from_path_and_stat(path, stat_result)
+ return (kind, size, executable, self._sha_from_stat(
+ path, stat_result))
+ elif kind == 'directory':
+ return kind, None, None, None
+ elif kind == 'symlink':
+ return ('symlink', None, None, os.readlink(abspath))
+ else:
+ return (kind, None, None, None)
+
def _reset_data(self):
pass
@@ -703,7 +653,7 @@
finally:
self.branch.unlock()
- if not supports_executable():
+ if not osutils.supports_executable():
def is_executable(self, file_id, path=None):
inv = self.basis_tree()._inventory
if file_id in inv:
More information about the bazaar-commits
mailing list