Rev 1078: Merge 0.4. in file:///data/jelmer/bzr-svn/rm-logpath/
Jelmer Vernooij
jelmer at samba.org
Fri Apr 4 15:20:44 BST 2008
At file:///data/jelmer/bzr-svn/rm-logpath/
------------------------------------------------------------
revno: 1078
revision-id: jelmer at samba.org-20080404141239-db1l13m1xd81p9x8
parent: jelmer at samba.org-20080403204333-d5b721bj1sps1841
parent: jelmer at samba.org-20080404135734-zq2qmd6pu9lebcmx
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: rm-logpath
timestamp: Fri 2008-04-04 16:12:39 +0200
message:
Merge 0.4.
modified:
NEWS news-20061231030336-h9fhq245ie0de8bs-1
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
remote.py format.py-20060406233823-b6fa009fe35dfde7
repository.py repository.py-20060306123302-1f8c5069b3fe0265
revids.py revids.py-20070416220458-36vfa0730cchevp1-1
------------------------------------------------------------
revno: 1076.1.3
revision-id: jelmer at samba.org-20080404135734-zq2qmd6pu9lebcmx
parent: jelmer at samba.org-20080404132025-mks3mf5u0i2wgio8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-04-04 15:57:34 +0200
message:
Cache revision number when repository is read locked. Significantly improves performance of push.
modified:
NEWS news-20061231030336-h9fhq245ie0de8bs-1
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
remote.py format.py-20060406233823-b6fa009fe35dfde7
repository.py repository.py-20060306123302-1f8c5069b3fe0265
------------------------------------------------------------
revno: 1076.1.2
revision-id: jelmer at samba.org-20080404132025-mks3mf5u0i2wgio8
parent: jelmer at samba.org-20080404121627-3hhgee3pqjlsusjl
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-04-04 15:20:25 +0200
message:
Handle exceptions in get_log().
modified:
transport.py transport.py-20060406231150-b3472d06b3a0818d
------------------------------------------------------------
revno: 1076.1.1
revision-id: jelmer at samba.org-20080404121627-3hhgee3pqjlsusjl
parent: jelmer at samba.org-20080402173552-qakpsv1d9ge0v2jc
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-04-04 14:16:27 +0200
message:
Use Repository.get_latest_revnum() rather than Repository.transport.get_latest_revnum() so it can be cached when there is a read lock.
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
remote.py format.py-20060406233823-b6fa009fe35dfde7
repository.py repository.py-20060306123302-1f8c5069b3fe0265
revids.py revids.py-20070416220458-36vfa0730cchevp1-1
=== modified file 'NEWS'
--- a/NEWS 2008-03-26 15:50:35 +0000
+++ b/NEWS 2008-04-04 13:57:34 +0000
@@ -22,6 +22,9 @@
* Parse mergeWithUpstream set by svn-buildpackage.
+ * Cache last revision number during read locks, significantly speeds
+ up push.
+
INTERNALS
* Branching from a Subversion repository will now fetch right-hand side
=== modified file 'branch.py'
--- a/branch.py 2008-03-30 00:54:46 +0000
+++ b/branch.py 2008-04-04 13:57:34 +0000
@@ -69,7 +69,6 @@
self._format = SvnBranchFormat()
self._lock_mode = None
self._lock_count = 0
- self._cached_revnum = None
self.mapping = self.repository.get_mapping()
self._branch_path = branch_path.strip("/")
assert isinstance(self._branch_path, str)
@@ -125,7 +124,7 @@
"""
if self._lock_mode == 'r' and self._cached_revnum:
return self._cached_revnum
- latest_revnum = self.repository.transport.get_latest_revnum()
+ latest_revnum = self.repository.get_latest_revnum()
self._cached_revnum = self.repository._log.find_latest_change(self.get_branch_path(), latest_revnum, include_children=True)
return self._cached_revnum
@@ -349,6 +348,7 @@
else:
self._lock_mode = 'w'
self._lock_count = 1
+ self.repository.lock_write()
def lock_read(self):
"""See Branch.lock_read()."""
@@ -358,14 +358,19 @@
else:
self._lock_mode = 'r'
self._lock_count = 1
+ self.repository.lock_read()
def unlock(self):
"""See Branch.unlock()."""
self._lock_count -= 1
if self._lock_count == 0:
self._lock_mode = None
- self._cached_revnum = None
self._clear_cached_state()
+ self.repository.unlock()
+
+ def _clear_cached_state(self):
+ super(SvnBranch,self)._clear_cached_state()
+ self._cached_revnum = None
def get_parent(self):
"""See Branch.get_parent()."""
=== modified file 'commit.py'
--- a/commit.py 2008-03-30 21:43:54 +0000
+++ b/commit.py 2008-04-04 13:57:34 +0000
@@ -409,7 +409,7 @@
self.revision_metadata = revision_data
bp_parts = self.branch.get_branch_path().split("/")
- repository_latest_revnum = self.repository.transport.get_latest_revnum()
+ repository_latest_revnum = self.repository.get_latest_revnum()
lock = self.repository.transport.lock_write(".")
set_revprops = self.repository.get_config().get_set_revprops()
remaining_revprops = self._svn_revprops # Keep track of the revprops that haven't been set yet
@@ -510,6 +510,7 @@
# Make sure the logwalker doesn't try to use ra
# during checkouts...
+ self.repository._clear_cached_state()
self.repository._log.fetch_revisions(self.revision_metadata.revision)
revid = self.branch.generate_revision_id(self.revision_metadata.revision)
=== modified file 'remote.py'
--- a/remote.py 2008-03-24 04:52:30 +0000
+++ b/remote.py 2008-04-04 13:57:34 +0000
@@ -140,14 +140,18 @@
stop_revision = source.last_revision()
target_branch_path = self.branch_path.strip("/")
repos = self.find_repository()
- full_branch_url = urlutils.join(repos.transport.base,
- target_branch_path)
- if repos.transport.check_path(target_branch_path,
- repos.transport.get_latest_revnum()) != svn.core.svn_node_none:
- raise AlreadyBranchError(full_branch_url)
- push_new(repos, target_branch_path, source, stop_revision)
- branch = self.open_branch()
- branch.pull(source, stop_revision=stop_revision)
+ repos.lock_write()
+ try:
+ full_branch_url = urlutils.join(repos.transport.base,
+ target_branch_path)
+ if repos.transport.check_path(target_branch_path,
+ repos.get_latest_revnum()) != svn.core.svn_node_none:
+ raise AlreadyBranchError(full_branch_url)
+ push_new(repos, target_branch_path, source, stop_revision)
+ branch = self.open_branch()
+ branch.pull(source, stop_revision=stop_revision)
+ finally:
+ repos.unlock()
return branch
def create_branch(self):
@@ -158,7 +162,7 @@
if self.branch_path != "":
# TODO: Set NULL_REVISION in SVN_PROP_BZR_BRANCHING_SCHEME
repos.transport.mkdir(self.branch_path.strip("/"))
- elif repos.transport.get_latest_revnum() > 0:
+ elif repos.get_latest_revnum() > 0:
# Bail out if there are already revisions in this repository
raise AlreadyBranchError(self.root_transport.base)
branch = SvnBranch(self.root_transport.base, repos, self.branch_path)
=== modified file 'repository.py'
--- a/repository.py 2008-04-03 20:43:33 +0000
+++ b/repository.py 2008-04-04 14:12:39 +0000
@@ -114,6 +114,9 @@
Repository.__init__(self, SvnRepositoryFormat(), bzrdir,
control_files, None, None, None)
+ self._cached_revnum = None
+ self._lock_mode = None
+ self._lock_count = 0
self.transport = transport
self.uuid = transport.get_uuid()
assert self.uuid is not None
@@ -161,6 +164,40 @@
def get_transaction(self):
raise NotImplementedError(self.get_transaction)
+ def lock_read(self):
+ if self._lock_mode:
+ assert self._lock_mode in ('r', 'w')
+ self._lock_count += 1
+ else:
+ self._lock_mode = 'r'
+ self._lock_count = 1
+
+ def unlock(self):
+ """See Branch.unlock()."""
+ self._lock_count -= 1
+ if self._lock_count == 0:
+ self._lock_mode = None
+ self._clear_cached_state()
+
+ def _clear_cached_state(self):
+ self._cached_revnum = None
+
+ def lock_write(self):
+ """See Branch.lock_write()."""
+ # TODO: Obtain lock on the remote server?
+ if self._lock_mode:
+ assert self._lock_mode == 'w'
+ self._lock_count += 1
+ else:
+ self._lock_mode = 'w'
+ self._lock_count = 1
+
+ def get_latest_revnum(self):
+ if self._lock_mode in ('r','w') and self._cached_revnum:
+ return self._cached_revnum
+ self._cached_revnum = self.transport.get_latest_revnum()
+ return self._cached_revnum
+
def get_stored_scheme(self):
"""Retrieve the stored branching scheme, either in the repository
or in the configuration file.
@@ -169,7 +206,7 @@
if scheme is not None:
return (scheme, self.get_config().branching_scheme_is_mandatory())
- last_revnum = self.transport.get_latest_revnum()
+ last_revnum = self.get_latest_revnum()
scheme = self._get_property_scheme(last_revnum)
if scheme is not None:
return (scheme, True)
@@ -202,7 +239,7 @@
self._scheme = scheme
return scheme
- last_revnum = self.transport.get_latest_revnum()
+ last_revnum = self.get_latest_revnum()
self.set_branching_scheme(
self._guess_scheme(last_revnum, self._hinted_branch_path),
store=(last_revnum > 20),
@@ -212,7 +249,7 @@
def _get_property_scheme(self, revnum=None):
if revnum is None:
- revnum = self.transport.get_latest_revnum()
+ revnum = self.get_latest_revnum()
text = self.branchprop_list.get_properties("", revnum).get(SVN_PROP_BZR_BRANCHING_SCHEME, None)
if text is None:
return None
@@ -278,7 +315,7 @@
if mapping is None:
mapping = self.get_mapping()
- latest_revnum = self.transport.get_latest_revnum()
+ latest_revnum = self.get_latest_revnum()
for (paths, revnum, revprops) in self._log.iter_changes("", latest_revnum):
if pb:
@@ -697,7 +734,7 @@
"""
assert scheme is not None
if to_revnum is None:
- to_revnum = self.transport.get_latest_revnum()
+ to_revnum = self.get_latest_revnum()
created_branches = {}
=== modified file 'revids.py'
--- a/revids.py 2008-03-31 03:00:42 +0000
+++ b/revids.py 2008-04-04 12:16:27 +0000
@@ -61,7 +61,7 @@
pass
found = False
- for entry_revid, branch, revno in self.discover_revids(scheme, 0, self.repos.transport.get_latest_revnum()):
+ for entry_revid, branch, revno in self.discover_revids(scheme, 0, self.repos.get_latest_revnum()):
if revid == entry_revid:
found = True
break
@@ -155,7 +155,7 @@
if min_revnum == max_revnum:
return (branch_path, min_revnum, BzrSvnMappingv3FileProps(get_scheme(scheme)))
except NoSuchRevision, e:
- last_revnum = self.actual.repos.transport.get_latest_revnum()
+ last_revnum = self.actual.repos.get_latest_revnum()
if (last_revnum <= self.cache.last_revnum_checked(str(scheme))):
# All revision ids in this repository for the current
# scheme have already been discovered. No need to
More information about the bazaar-commits
mailing list