From: Jelmer Vernooij Date: Thu, 8 Jun 2006 09:28:29 +0000 (+0100) Subject: Support `bzr check' using Martins' bzr.mbp.check branch. X-Git-Tag: bzr-svn-0.1~157^2~1 X-Git-Url: http://git.samba.org/samba.git/?p=jelmer%2Fsubvertpy.git;a=commitdiff_plain;h=714c528b7e650af661980968df7ff5ffd05026b2 Support `bzr check' using Martins' bzr.mbp.check branch. --- diff --git a/branch.py b/branch.py index 6390d3f1..27fb3b32 100644 --- a/branch.py +++ b/branch.py @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from bzrlib.branch import Branch, BranchFormat +from bzrlib.branch import Branch, BranchFormat, BranchCheckResult from bzrlib.errors import NotBranchError, NoWorkingTree, NoSuchRevision, \ NoSuchFile from bzrlib.inventory import Inventory, InventoryFile, InventoryDirectory, \ @@ -51,6 +51,9 @@ class SvnBranch(Branch): self.base = "%s/%s" % (repos.url, branch_path) self._format = SvnBranchFormat() mutter("Connected to branch at %s" % branch_path) + + def check(self): + return BranchCheckResult(self) def path_from_file_id(self, revision_id, file_id): """Generate a full Subversion path from a bzr file id. @@ -62,9 +65,6 @@ class SvnBranch(Branch): return self.base+"/"+self.filename_from_file_id(revision_id, file_id) def _generate_revnum_map(self): - #FIXME: Revids should be globally unique, so we should include the - # branch path somehow. If we don't do this there might be revisions - # that have the same id because they were created in the same commit. self._revision_history = [] def rcvr(paths, rev, author, date, message, pool): @@ -169,7 +169,8 @@ class SvnBranch(Branch): raise NotImplementedError(self.get_transaction) def append_revision(self, *revision_ids): - raise NotImplementedError(self.append_revision) + # FIXME: raise NotImplementedError(self.append_revision) + pass def get_physical_lock_status(self): return False @@ -237,6 +238,9 @@ class SvnBranchFormat(BranchFormat): """See Branch.get_format_description.""" return 'Subversion Smart Server' + def get_format_string(self): + return 'Subversion Smart Server' + def initialize(self, to_bzrdir): raise NotImplementedError(self.initialize) diff --git a/commit.py b/commit.py index e3c9dc22..99ff0f88 100644 --- a/commit.py +++ b/commit.py @@ -24,20 +24,18 @@ class SvnCommitBuilder(CommitBuilder): def __init__(self, repository, branch, parents, config, revprops): super(SvnCommitBuilder, self).__init__(repository, parents, config, None, None, None, revprops, None) + self.branch = branch + + # TODO: Allow revision id to be specified, but only if it + # matches the format for Subversion revision ids, the UUID + # matches and the revnum is in the future. Set the + # revision num on the delta editor using set_target_revision def _generate_revision_if_needed(self): pass - @staticmethod - def done(info, pool): - if not info.post_commit_err is None: - raise BzrError(info.post_commit_err) - - self.revnum = info.revnum - def set_message(self, message): - self.editor, self.editor_baton = svn.ra.get_commit_editor2( - self.repository.ra, message, self.done, None, False) + self.message = message def finish_inventory(self): # Subversion doesn't have an inventory @@ -62,9 +60,21 @@ class SvnCommitBuilder(CommitBuilder): pass def commit(self): - root = svn.delta.editor_invoke_open_root(self.editor, self.editor_baton, 4) + def done(info, pool): + if not info.post_commit_err is None: + raise BzrError(info.post_commit_err) + + self.revnum = info.revision + + editor, editor_baton = svn.ra.get_commit_editor2( + self.repository.ra, self.message, done, None, False) + + root = svn.delta.editor_invoke_open_root(editor, editor_baton, 4) + + svn.delta.editor_invoke_close_edit(editor, editor_baton) - svn.delta.editor_invoke_close_edit(self.editor, self.editor_baton) + # Throw away the cache of revision ids + self.branch._generate_revnum_map() return self.repository.generate_revision_id(self.revnum, - branch.branch_path) + self.branch.branch_path) diff --git a/repository.py b/repository.py index 9bb6d04e..36d92445 100644 --- a/repository.py +++ b/repository.py @@ -14,6 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +from bzrlib.branch import BranchCheckResult from bzrlib.repository import Repository from bzrlib.lockable_files import LockableFiles, TransportLock from bzrlib.trace import mutter @@ -109,7 +110,7 @@ class SvnRepository(Repository): self.ra = bzrdir.transport.ra self.uuid = svn.ra.get_uuid(self.ra) - self.url = url + self.base = self.url = url self.fileid_map = {} self.text_cache = {} self.dir_cache = {} @@ -124,6 +125,12 @@ class SvnRepository(Repository): def __del__(self): svn.core.svn_pool_destroy(self.pool) + def check(self, revision_ids): + if not revision_ids: + raise ValueError("revision_ids must be non-empty in %s.check" + % (self,)) + return BranchCheckResult(self) + def get_inventory(self, revision_id): (path, revnum) = self.parse_revision_id(revision_id) mutter('getting inventory %r for branch %r' % (revnum, path))