Rev 438: General cleanups: remove unused imports, fix line lengths, unused parameters. in sftp://people.samba.org/~/bzr/bzr-svn/0.3/
Jelmer Vernooij
jelmer at samba.org
Sat Mar 24 15:41:02 GMT 2007
At sftp://people.samba.org/~/bzr/bzr-svn/0.3/
------------------------------------------------------------
revno: 438
revision-id: jelmer at samba.org-20070324154013-9slv88wjxilfigto
parent: jelmer at samba.org-20070321131427-3y69fpq97umynbk0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.3
timestamp: Sat 2007-03-24 16:40:13 +0100
message:
General cleanups: remove unused imports, fix line lengths, unused parameters.
modified:
TODO todo-20060729211917-2kpobww0zyvvo0j2-1
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
branchprops.py branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
checkout.py workingtree.py-20060306120941-b083cb0fdd4a69de
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
convert.py svn2bzr.py-20051018015439-cb4563bff29e632d
fetch.py fetch.py-20060625004942-x2lfaib8ra707a8p-1
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
format.py format.py-20060406233823-b6fa009fe35dfde7
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'TODO'
--- a/TODO 2007-03-13 09:42:14 +0000
+++ b/TODO 2007-03-24 15:40:13 +0000
@@ -16,3 +16,4 @@
- free memory!
- report changes to delta editor in Branch.pull()
- add tests for objects returned by WorkingTree.pull(), Branch.pull()
+- blackbox tests
=== modified file '__init__.py'
--- a/__init__.py 2007-03-19 02:30:01 +0000
+++ b/__init__.py 2007-03-24 15:40:13 +0000
@@ -22,8 +22,10 @@
import unittest
import bzrlib
+from bzrlib.trace import warning
+
__version__ = '0.3.2'
-compatible_bzr_versions = [(0,15),(0,16)]
+COMPATIBLE_BZR_VERSIONS = [(0, 15), (0, 16)]
def check_bzrlib_version(desired):
"""Check that bzrlib is compatible.
@@ -35,11 +37,6 @@
bzrlib_version = bzrlib.version_info[:2]
if bzrlib_version in desired:
return
- try:
- from bzrlib.trace import warning
- except ImportError:
- # get the message out any way we can
- from warnings import warn as warning
if bzrlib_version < desired[0]:
warning('Installed bzr version %s is too old to be used with bzr-svn'
' %s.' % (bzrlib.__version__, __version__))
@@ -56,25 +53,25 @@
"""Check that Subversion is compatible.
"""
- from bzrlib.trace import warning
try:
from svn.delta import svn_delta_invoke_txdelta_window_handler
except:
- warning('Installed Subversion version does not have updated Python bindings. See the bzr-svn README for details.')
+ warning('Installed Subversion version does not have updated Python '
+ 'bindings. See the bzr-svn README for details.')
raise bzrlib.errors.BzrError("incompatible python subversion bindings")
def check_pysqlite_version():
"""Check that sqlite library is compatible.
"""
- from bzrlib.trace import warning
try:
try:
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3
except:
- warning('Needs at least Python2.5 or Python2.4 with the pysqlite2 module')
+ warning('Needs at least Python2.5 or Python2.4 with the pysqlite2 '
+ 'module')
raise bzrlib.errors.BzrError("missing sqlite library")
if (sqlite3.sqlite_version_info[0] < 3 or
@@ -83,7 +80,7 @@
warning('Needs at least sqlite 3.3.x')
raise bzrlib.errors.BzrError("incompatible sqlite library")
-check_bzrlib_version(compatible_bzr_versions)
+check_bzrlib_version(COMPATIBLE_BZR_VERSIONS)
check_subversion_version()
check_pysqlite_version()
@@ -106,10 +103,9 @@
BzrDirFormat.register_control_format(format.SvnFormat)
import svn.core
-subr_version = svn.core.svn_subr_version()
+_subr_version = svn.core.svn_subr_version()
-if subr_version.major == 1 and subr_version.minor < 4:
- from bzrlib.trace import warning
+if _subr_version.major == 1 and _subr_version.minor < 4:
warning('Subversion version too old for working tree support.')
else:
BzrDirFormat.register_control_format(checkout.SvnWorkingTreeDirFormat)
@@ -140,7 +136,9 @@
takes_args = ['from_location', 'to_location?']
takes_options = [Option('trees', help='Create working trees'),
Option('shared', help='Create shared repository'),
- Option('all', help='Convert all revisions, even those not in current branch history (implies --shared)'),
+ Option('all',
+ help='Convert all revisions, even those not in '
+ 'current branch history (implies --shared)'),
Option('scheme', type=get_scheme,
help='Branching scheme (none, trunk, or trunk-INT)')]
@@ -197,7 +195,7 @@
def test_suite():
- from unittest import TestSuite, TestLoader
+ from unittest import TestSuite
import tests
suite = TestSuite()
=== modified file 'branch.py'
--- a/branch.py 2007-03-13 09:40:12 +0000
+++ b/branch.py 2007-03-24 15:40:13 +0000
@@ -14,27 +14,18 @@
# 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, BranchCheckResult, BzrBranch, PullResult
+from bzrlib.branch import Branch, BranchFormat, BranchCheckResult, PullResult
from bzrlib.bzrdir import BzrDir
-from bzrlib.config import TreeConfig
-from bzrlib.errors import (NotBranchError, NoWorkingTree, NoSuchRevision,
- NoSuchFile, DivergedBranches)
-from bzrlib.inventory import (Inventory, InventoryFile, InventoryDirectory)
-from bzrlib.revision import Revision, NULL_REVISION
-from bzrlib.symbol_versioning import deprecated_function, zero_nine
-from bzrlib.tree import Tree
-from bzrlib.trace import mutter, note
+from bzrlib.errors import NoSuchFile, DivergedBranches
+from bzrlib.inventory import (Inventory)
+from bzrlib.trace import mutter
from bzrlib.workingtree import WorkingTree
-import os
-
import svn.client, svn.core
-from svn.core import SubversionException
from commit import push_as_merged
from repository import SvnRepository
from transport import bzr_to_svn_url, svn_config
-from tree import SvnRevisionTree
class FakeControlFiles(object):
@@ -184,7 +175,8 @@
self.update_revisions(source, stop_revision)
except DivergedBranches:
if overwrite:
- raise NotImplementedError('overwrite not supported for Subversion branches')
+ raise NotImplementedError('overwrite not supported for '
+ 'Subversion branches')
raise
(result.new_revno, result.new_revid) = self.last_revision_info()
return result
@@ -271,7 +263,7 @@
class SvnBranchFormat(BranchFormat):
- """ Branch format for Subversion Branches."""
+ """Branch format for Subversion Branches."""
def __init__(self):
BranchFormat.__init__(self)
=== modified file 'branchprops.py'
--- a/branchprops.py 2007-03-13 09:40:12 +0000
+++ b/branchprops.py 2007-03-24 15:40:13 +0000
@@ -14,8 +14,11 @@
# 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.errors import NoSuchRevision
from bzrlib.trace import mutter
+
from svn.core import SubversionException, Pool
+import svn.core
class BranchPropertyList:
def __init__(self, log, cachedb):
@@ -37,7 +40,7 @@
try:
(_, _, props) = self.log.transport.get_dir(path.encode('utf8'),
revnum, pool=self.pool)
- except SubversionException, (msg, num):
+ except SubversionException, (_, num):
if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
raise NoSuchRevision(self, revnum)
raise
@@ -49,7 +52,8 @@
assert isinstance(origrevnum, int) and origrevnum >= 0
proplist = {}
revnum = self.log.find_latest_change(path, origrevnum)
- assert revnum is not None, "can't find latest change for %r:%r" % (path, origrevnum)
+ assert revnum is not None, \
+ "can't find latest change for %r:%r" % (path, origrevnum)
proplist = {}
for (name, value) in self.cachedb.execute("select name, value from branchprop where revnum=%d and branchpath='%s'" % (revnum, path)):
=== modified file 'checkout.py'
--- a/checkout.py 2007-03-13 09:40:12 +0000
+++ b/checkout.py 2007-03-24 15:40:13 +0000
@@ -14,7 +14,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from binascii import hexlify
from bzrlib.branch import PullResult
from bzrlib.bzrdir import BzrDirFormat, BzrDir
from bzrlib.errors import (InvalidRevisionId, NotBranchError, NoSuchFile,
@@ -23,10 +22,10 @@
InventoryLink, ROOT_ID)
from bzrlib.lockable_files import TransportLock, LockableFiles
from bzrlib.lockdir import LockDir
-from bzrlib.osutils import rand_bytes, fingerprint_file
-from bzrlib.progress import DummyProgress
+from bzrlib.osutils import fingerprint_file
from bzrlib.revision import NULL_REVISION
from bzrlib.trace import mutter
+from bzrlib.tree import RevisionTree
from bzrlib.transport.local import LocalTransport
from bzrlib.workingtree import WorkingTree, WorkingTreeFormat
@@ -66,10 +65,11 @@
self.pool = Pool()
self.client_ctx = svn.client.create_context()
self.client_ctx.config = svn_config
- self.client_ctx.log_msg_func2 = svn.client.svn_swig_py_get_commit_log_func
+ self.client_ctx.log_msg_func2 = \
+ svn.client.svn_swig_py_get_commit_log_func
self.client_ctx.auth_baton = _create_auth_baton(self.pool)
- wc = self._get_wc()
+ self._get_wc()
status = svn.wc.revision_status(self.basedir, None, True, None, None)
if status.min_rev != status.max_rev:
#raise WorkingTreeInconsistent(status.min_rev, status.max_rev)
@@ -86,13 +86,15 @@
self.read_working_inventory()
- self.controldir = os.path.join(self.basedir, svn.wc.get_adm_dir(), 'bzr')
+ self.controldir = os.path.join(self.basedir, svn.wc.get_adm_dir(),
+ 'bzr')
try:
os.makedirs(self.controldir)
os.makedirs(os.path.join(self.controldir, 'lock'))
except OSError:
pass
- control_transport = bzrdir.transport.clone(os.path.join(svn.wc.get_adm_dir(), 'bzr'))
+ control_transport = bzrdir.transport.clone(os.path.join(
+ svn.wc.get_adm_dir(), 'bzr'))
self._control_files = LockableFiles(control_transport, 'lock', LockDir)
def lock_write(self):
@@ -105,10 +107,12 @@
pass
def get_ignore_list(self):
- ignores = [svn.wc.get_adm_dir()] + svn.wc.get_default_ignores(svn_config)
+ ignores = [svn.wc.get_adm_dir()] + \
+ svn.wc.get_default_ignores(svn_config)
def dir_add(wc, prefix):
- ignorestr = svn.wc.prop_get(svn.core.SVN_PROP_IGNORE, self.abspath(prefix).rstrip("/"), wc)
+ ignorestr = svn.wc.prop_get(svn.core.SVN_PROP_IGNORE,
+ self.abspath(prefix).rstrip("/"), wc)
if ignorestr is not None:
for pat in ignorestr.splitlines():
ignores.append("./"+os.path.join(prefix, pat))
@@ -123,7 +127,8 @@
subprefix = os.path.join(prefix, entry)
- subwc = svn.wc.adm_open3(wc, self.abspath(subprefix), False, 0, None)
+ subwc = svn.wc.adm_open3(wc, self.abspath(subprefix), False,
+ 0, None)
try:
dir_add(subwc, subprefix)
finally:
@@ -144,6 +149,8 @@
return svn.wc.is_adm_dir(path)
def remove(self, files, verbose=False, to_file=None):
+ # FIXME: Use to_file argument
+ # FIXME: Use verbose argument
assert isinstance(files, list)
wc = self._get_wc(write_lock=True)
try:
@@ -165,12 +172,13 @@
file = os.path.basename(relpath)
return (self._get_wc(dir, write_lock), file)
- def move(self, from_paths, to_name):
+ def move(self, from_paths, to_dir=None, after=False, **kwargs):
+ # FIXME: Use after argument
revt = svn.core.svn_opt_revision_t()
revt.kind = svn.core.svn_opt_revision_working
for entry in from_paths:
try:
- to_wc = self._get_wc(to_name, write_lock=True)
+ to_wc = self._get_wc(to_dir, write_lock=True)
svn.wc.copy(self.abspath(entry), to_wc,
os.path.basename(entry), None, None)
finally:
@@ -180,13 +188,14 @@
svn.wc.delete2(self.abspath(entry), from_wc, None, None, None)
finally:
svn.wc.adm_close(from_wc)
- new_name = "%s/%s" % (to_name, os.path.basename(entry))
+ new_name = "%s/%s" % (to_dir, os.path.basename(entry))
self._change_fileid_mapping(self.inventory.path2id(entry), new_name)
self._change_fileid_mapping(None, entry)
self.read_working_inventory()
- def rename_one(self, from_rel, to_rel):
+ def rename_one(self, from_rel, to_rel, after=False):
+ # FIXME: Use after
revt = svn.core.svn_opt_revision_t()
revt.kind = svn.core.svn_opt_revision_unspecified
(to_wc, to_file) = self._get_rel_wc(to_rel, write_lock=True)
@@ -210,7 +219,7 @@
assert isinstance(revnum, int) and revnum >= 0
assert isinstance(path, basestring)
- (bp, rp) = self.branch.repository.scheme.unprefix(path)
+ (_, rp) = self.branch.repository.scheme.unprefix(path)
entry = self.base_tree.id_map[rp]
assert entry[0] is not None
return entry
@@ -274,9 +283,10 @@
entry.schedule == svn.wc.schedule_replace):
# See if the file this file was copied from disappeared
# and has no other copies -> in that case, take id of other file
- if entry.copyfrom_url and list(find_copies(entry.copyfrom_url)) == [relpath]:
- return self.path_to_file_id(entry.copyfrom_rev, entry.revision,
- entry.copyfrom_url[len(entry.repos):])
+ if (entry.copyfrom_url and
+ list(find_copies(entry.copyfrom_url)) == [relpath]):
+ return self.path_to_file_id(entry.copyfrom_rev,
+ entry.revision, entry.copyfrom_url[len(entry.repos):])
ids = self._get_new_file_ids(rootwc)
if ids.has_key(relpath):
return (ids[relpath], None)
@@ -285,7 +295,8 @@
def add_dir_to_inv(relpath, wc, parent_id):
entries = svn.wc.entries_read(wc, False)
entry = entries[""]
- assert parent_id is None or isinstance(parent_id, str), "%r is not a string" % parent_id
+ assert parent_id is None or isinstance(parent_id, str), \
+ "%r is not a string" % parent_id
(id, revid) = find_ids(entry, rootwc)
if id is None:
mutter('no id for %r' % entry.url)
@@ -297,7 +308,8 @@
inv.add_path("", 'directory', ROOT_ID)
inv.revision_id = revid
else:
- inventry = InventoryDirectory(id, os.path.basename(relpath), parent_id)
+ inventry = InventoryDirectory(id, os.path.basename(relpath),
+ parent_id)
inventry.revision = revid
inv.add(inventry)
@@ -384,9 +396,17 @@
svn.wc.adm_close(wc)
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):
+ 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):
+ # FIXME: Use allow_pointless
+ # FIXME: Use committer
+ # FIXME: Use verbose
+ # FIXME: Use reporter
+ # FIXME: Use revprops
+ # FIXME: Raise exception when local is True
+ # FIXME: Use strct
assert timestamp is None
assert timezone is None
assert rev_id is None
@@ -407,7 +427,8 @@
return message.encode("utf-8")
self.client_ctx.log_msg_baton2 = log_message_func
- commit_info = svn.client.commit3(specific_files, True, False, self.client_ctx)
+ commit_info = svn.client.commit3(specific_files, True, False,
+ self.client_ctx)
self.client_ctx.log_msg_baton2 = None
revid = self.branch.repository.generate_revision_id(
@@ -423,7 +444,8 @@
return revid
- def add(self, files, ids=None):
+ def add(self, files, ids=None, kinds=None):
+ # FIXME: Use kinds
if isinstance(files, str):
files = [files]
if isinstance(ids, str):
@@ -456,7 +478,10 @@
return self.base_tree
- def pull(self, source, overwrite=False, stop_revision=None, delta_reporter=None):
+ def pull(self, source, overwrite=False, stop_revision=None,
+ delta_reporter=None):
+ # FIXME: Use delta_reporter
+ # FIXME: Use overwrite
result = PullResult()
result.source_branch = source
result.master_branch = None
@@ -552,7 +577,7 @@
def add_pending_merge(self, revid):
merges = self.pending_merges()
merges.append(revid)
- self.set_pending_merges(existing)
+ self.set_pending_merges(merges)
def pending_merges(self):
merged = self._get_bzr_merges().splitlines()
@@ -610,17 +635,19 @@
if not self.scheme.is_branch(self.branch_path):
raise NotBranchError(path=self.transport.base)
- def clone(self, path):
+ def clone(self, path, revision_id=None, basis=None, force_new_repo=False):
raise NotImplementedError(self.clone)
def open_workingtree(self, _unsupported=False):
return SvnWorkingTree(self, self.local_path, self.open_branch())
- def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
+ def sprout(self, url, revision_id=None, basis=None, force_new_repo=False,
+ recurse='down'):
# FIXME: honor force_new_repo
+ # FIXME: Use recurse
result = BzrDirFormat.get_default_format().initialize(url)
repo = self.find_repository()
- result_repo = repo.clone(result, revision_id, basis)
+ repo.clone(result, revision_id, basis)
branch = self.open_branch()
branch.sprout(result, revision_id)
result.create_workingtree()
@@ -650,9 +677,9 @@
try:
branch = SvnBranch(self.root_transport.base, repos, self.branch_path)
- except SubversionException, (msg, num):
+ except SubversionException, (_, num):
if num == svn.core.SVN_ERR_WC_NOT_DIRECTORY:
- raise NotBranchError(path=self.url)
+ raise NotBranchError(path=self.base)
raise
branch.bzrdir = self
=== modified file 'commit.py'
--- a/commit.py 2007-03-15 16:09:51 +0000
+++ b/commit.py 2007-03-24 15:40:13 +0000
@@ -17,12 +17,11 @@
import svn.delta
from svn.core import Pool, SubversionException
-from bzrlib.errors import (UnsupportedOperation, BzrError, InvalidRevisionId,
- DivergedBranches)
+from bzrlib.errors import InvalidRevisionId, DivergedBranches
from bzrlib.inventory import Inventory, ROOT_ID
import bzrlib.osutils as osutils
from bzrlib.repository import RootCommitBuilder
-from bzrlib.trace import mutter, warning
+from bzrlib.trace import mutter
from repository import (SvnRepository, SVN_PROP_BZR_MERGE, SVN_PROP_BZR_FILEIDS,
SVN_PROP_SVK_MERGE, SVN_PROP_BZR_REVPROP_PREFIX,
@@ -151,10 +150,10 @@
child_ie.parent_id != self.new_inventory[child_ie.file_id].parent_id or
# ... name changed
self.new_inventory[child_ie.file_id].name != child_name):
- mutter('removing %r' % child_ie.file_id)
- svn.delta.editor_invoke_delete_entry(self.editor,
- os.path.join(self.branch.branch_path, self.old_inv.id2path(child_ie.file_id)),
- self.base_revnum, baton, self.pool)
+ mutter('removing %r' % child_ie.file_id)
+ svn.delta.editor_invoke_delete_entry(self.editor,
+ os.path.join(self.branch.branch_path, self.old_inv.id2path(child_ie.file_id)),
+ self.base_revnum, baton, self.pool)
# Loop over file members of file_id in self.new_inventory
for child_name in self.new_inventory[file_id].children:
@@ -289,13 +288,14 @@
def commit(self, message):
def done(revision, date, author):
+ assert revision > 0
self.revnum = revision
- assert self.revnum > 0
self.date = date
self.author = author
mutter('committed %r, author: %r, date: %r' % (revision, author, date))
mutter('obtaining commit editor')
+ self.revnum = None
self.editor, editor_baton = self.repository.transport.get_commit_editor(
message.encode("utf-8"), done, None, False)
@@ -320,6 +320,7 @@
svn.delta.editor_invoke_close_edit(self.editor, editor_baton)
+ assert self.revnum is not None
revid = self.repository.generate_revision_id(self.revnum,
self.branch.branch_path)
@@ -399,7 +400,7 @@
delta = new_tree.changes_from(old_tree)
builder.new_inventory = inv
- for (name, ie) in inv.entries():
+ for (_, ie) in inv.entries():
if not delta.touches_file_id(ie.file_id):
continue
=== modified file 'convert.py'
--- a/convert.py 2007-03-19 01:37:49 +0000
+++ b/convert.py 2007-03-24 15:40:13 +0000
@@ -22,20 +22,17 @@
from bzrlib.bzrdir import BzrDir, BzrDirFormat
from bzrlib.branch import Branch
-from bzrlib.errors import BzrError, NotBranchError, NoSuchFile, NoRepositoryPresent
+from bzrlib.errors import (BzrError, NotBranchError,
+ NoSuchFile, NoRepositoryPresent)
import bzrlib.osutils as osutils
-from bzrlib.progress import DummyProgress
-from bzrlib.repository import Repository
-from bzrlib.trace import info, mutter
+from bzrlib.trace import mutter
from bzrlib.transport import get_transport
import bzrlib.urlutils as urlutils
import bzrlib.ui as ui
-from format import SvnRemoteAccess, SvnFormat
from repository import SvnRepository
-from transport import SvnRaTransport
-import svn.core
+import svn.core, svn.repos
def transport_makedirs(transport, location_url):
needed = [(transport, transport.relpath(location_url))]
@@ -51,19 +48,18 @@
class NotDumpFile(BzrError):
_fmt = """%(dumpfile)s is not a dump file."""
def __init__(self, dumpfile):
+ super(NotDumpFile, self).__init__()
self.dumpfile = dumpfile
def load_dumpfile(dumpfile, outputdir):
- import svn
- from svn.core import SubversionException
from cStringIO import StringIO
repos = svn.repos.svn_repos_create(outputdir, '', '', None, None)
try:
file = open(dumpfile)
svn.repos.load_fs2(repos, file, StringIO(),
svn.repos.load_uuid_default, '', 0, 0, None)
- except SubversionException, (svn.core.SVN_ERR_STREAM_MALFORMED_DATA, _):
+ except svn.core.SubversionException, (svn.core.SVN_ERR_STREAM_MALFORMED_DATA, _):
raise NotDumpFile(dumpfile)
return repos
@@ -141,7 +137,7 @@
target_branch.pull(source_branch)
if working_trees and not target_dir.has_workingtree():
target_dir.create_workingtree()
- i+=1
+ i += 1
finally:
pb.finished()
finally:
=== modified file 'fetch.py'
--- a/fetch.py 2007-03-19 13:27:10 +0000
+++ b/fetch.py 2007-03-24 15:40:13 +0000
@@ -27,7 +27,7 @@
import md5
import os
-from svn.core import SubversionException, Pool
+from svn.core import Pool
import svn.core, svn.ra
from fileids import generate_file_id
@@ -44,6 +44,9 @@
class RevisionBuildEditor(svn.delta.Editor):
+ """Implementation of the Subversion commit editor interface that builds a
+ Bazaar revision.
+ """
def __init__(self, source, target, branch_path, prev_inventory, revid,
svn_revprops, id_map):
self.branch_path = branch_path
@@ -62,6 +65,10 @@
self.pool = Pool()
def _get_revision(self, revid):
+ """Creates the revision object.
+
+ :param revid: Revision id of the revision to create.
+ """
if self._parent_ids is None:
self._parent_ids = ""
@@ -115,7 +122,8 @@
if not file_weave.has_version(self.revid):
file_weave.add_lines(self.revid, self.dir_baserev[id], [])
- def add_directory(self, path, parent_id, copyfrom_path, copyfrom_revnum, pool):
+ def add_directory(self, path, parent_id, copyfrom_path, copyfrom_revnum,
+ pool):
path = path.decode("utf-8")
file_id = self._get_new_id(parent_id, path)
@@ -213,7 +221,8 @@
self.file_id = self._get_existing_id(parent_id, path)
self.is_executable = None
self.is_symlink = (self.inventory[base_file_id].kind == 'symlink')
- file_weave = self.weave_store.get_weave_or_empty(base_file_id, self.transact)
+ file_weave = self.weave_store.get_weave_or_empty(base_file_id,
+ self.transact)
self.file_data = file_weave.get_text(base_revid)
self.file_stream = None
if self.file_id == base_file_id:
@@ -235,7 +244,8 @@
actual_checksum = md5_strings(lines)
assert checksum is None or checksum == actual_checksum
- file_weave = self.weave_store.get_weave_or_empty(self.file_id, self.transact)
+ file_weave = self.weave_store.get_weave_or_empty(self.file_id,
+ self.transact)
if not file_weave.has_version(self.revid):
file_weave.add_lines(self.revid, self.file_parents, lines)
@@ -275,9 +285,11 @@
def apply_textdelta(self, file_id, base_checksum):
actual_checksum = md5.new(self.file_data).hexdigest(),
assert (base_checksum is None or base_checksum == actual_checksum,
- "base checksum mismatch: %r != %r" % (base_checksum, actual_checksum))
+ "base checksum mismatch: %r != %r" % (base_checksum,
+ actual_checksum))
self.file_stream = StringIO()
- return apply_txdelta_handler(StringIO(self.file_data), self.file_stream, self.pool)
+ return apply_txdelta_handler(StringIO(self.file_data),
+ self.file_stream, self.pool)
class InterSvnRepository(InterRepository):
@@ -295,7 +307,8 @@
for (branch, revnum) in self.source.follow_history(
self.source._latest_revnum):
revid = self.source.generate_revision_id(revnum, branch)
- parents[revid] = self.source._mainline_revision_parent(branch, revnum)
+ parents[revid] = self.source._mainline_revision_parent(branch,
+ revnum)
if not self.target.has_revision(revid):
needed.append(revid)
@@ -356,6 +369,7 @@
else:
nested_pb = None
num = 0
+ prev_inv = None
try:
for revid in needed:
(branch, revnum) = self.source.parse_revision_id(revid)
@@ -368,6 +382,7 @@
elif prev_revid != parent_revid:
parent_inv = self.target.get_inventory(parent_revid)
else:
+ assert prev_inv is not None
parent_inv = prev_inv
changes = self.source._log.get_revision_paths(revnum, branch)
@@ -376,9 +391,9 @@
revnum, branch, changes, renames)
editor = RevisionBuildEditor(self.source, self.target, branch,
- parent_inv, revid,
- self.source._log.get_revision_info(revnum),
- id_map)
+ parent_inv, revid,
+ self.source._log.get_revision_info(revnum),
+ id_map)
pool = Pool()
edit, edit_baton = svn.delta.make_editor(editor, pool)
@@ -392,7 +407,8 @@
svn.ra.reporter2_invoke_set_path(reporter, reporter_baton,
"", revnum, True, None, pool)
else:
- (parent_branch, parent_revnum) = self.source.parse_revision_id(parent_revid)
+ (parent_branch, parent_revnum) = \
+ self.source.parse_revision_id(parent_revid)
transport.reparent("%s/%s" % (repos_root, parent_branch))
if parent_branch != branch:
@@ -409,7 +425,8 @@
"", parent_revnum, False, None, pool)
transport.lock()
- svn.ra.reporter2_invoke_finish_report(reporter, reporter_baton, pool)
+ svn.ra.reporter2_invoke_finish_report(reporter, reporter_baton,
+ pool)
transport.unlock()
prev_inv = editor.inventory
=== modified file 'fileids.py'
--- a/fileids.py 2007-03-19 01:05:20 +0000
+++ b/fileids.py 2007-03-24 15:40:13 +0000
@@ -14,21 +14,17 @@
# 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.errors import RevisionNotPresent, NotBranchError
+from bzrlib.errors import NotBranchError
from bzrlib.inventory import ROOT_ID
-from bzrlib.knit import KnitVersionedFile
from bzrlib.trace import mutter
-from bzrlib.transport import get_transport
import bzrlib.ui as ui
-import bzrlib.urlutils as urlutils
-from warnings import warn
import os
import sha
import logwalker
from repository import (escape_svn_path, generate_svn_revision_id,
- parse_svn_revision_id, MAPPING_VERSION)
+ parse_svn_revision_id)
def generate_svn_file_id(uuid, revnum, branch, path):
"""Create a file id identifying a Subversion file.
@@ -85,8 +81,6 @@
new_paths[new_p] = data
return new_paths
-dbs = {}
-
class FileIdMap(object):
""" File id store.
@@ -112,7 +106,7 @@
def load(self, revid):
map = {}
- for filename,create_revid,id in self.cachedb.execute("select filename, create_revid, id from filemap where revid='%s'"%revid):
+ for filename, create_revid, id in self.cachedb.execute("select filename, create_revid, id from filemap where revid='%s'"%revid):
map[filename] = (id.encode("utf-8"),create_revid.encode("utf-8"))
return map
=== modified file 'format.py'
--- a/format.py 2007-03-19 01:05:20 +0000
+++ b/format.py 2007-03-24 15:40:13 +0000
@@ -18,7 +18,6 @@
from bzrlib.errors import NotBranchError, NotLocalUrl, NoRepositoryPresent
from bzrlib.lockable_files import TransportLock
from bzrlib.transport.local import LocalTransport
-import bzrlib.urlutils as urlutils
from svn.core import SubversionException
import svn.core, svn.repos
@@ -62,8 +61,10 @@
"""
raise NotImplementedError(SvnRemoteAccess.clone)
- def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
+ def sprout(self, url, revision_id=None, basis=None, force_new_repo=False,
+ recurse='down'):
"""See BzrDir.sprout()."""
+ # FIXME: Use recurse
result = BzrDirFormat.get_default_format().initialize(url)
repo = self.find_repository()
if force_new_repo:
@@ -155,7 +156,7 @@
def _open(self, transport):
try:
return SvnRemoteAccess(transport, self)
- except SubversionException, (msg, num):
+ except SubversionException, (_, num):
if num == svn.core.SVN_ERR_RA_DAV_REQUEST_FAILED:
raise NotBranchError(transport.base)
raise
=== modified file 'logwalker.py'
--- a/logwalker.py 2007-03-19 01:05:20 +0000
+++ b/logwalker.py 2007-03-24 15:40:13 +0000
@@ -14,9 +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.errors import NoSuchRevision, BzrError, NotBranchError
-from bzrlib.progress import DummyProgress
-from bzrlib.trace import mutter
+from bzrlib.errors import NoSuchRevision
import bzrlib.ui as ui
import os
@@ -32,8 +30,6 @@
except ImportError:
from pysqlite2 import dbapi2 as sqlite3
-shelves = {}
-
def _escape_commit_message(message):
"""Replace xml-incompatible control characters."""
if message is None:
@@ -104,7 +100,6 @@
def rcvr(orig_paths, rev, author, date, message, pool):
pb.update('fetching svn revision info', rev, to_revnum)
- paths = {}
if orig_paths is None:
orig_paths = {}
for p in orig_paths:
@@ -175,7 +170,7 @@
revnum = revpaths[path][2]
path = revpaths[path][1]
continue
- revnum-=1
+ revnum -= 1
def get_revision_paths(self, revnum, path=None):
"""Obtain dictionary with all the changes in a particular revision.
=== modified file 'repository.py'
--- a/repository.py 2007-03-19 13:27:10 +0000
+++ b/repository.py 2007-03-24 15:40:13 +0000
@@ -299,7 +299,7 @@
for revid in revids:
yield self.revision_tree(revid)
- def revision_tree(self, revision_id, inventory=None):
+ def revision_tree(self, revision_id):
if revision_id is None:
revision_id = NULL_REVISION
@@ -308,7 +308,7 @@
inventory.revision_id = revision_id
return RevisionTree(self, inventory, revision_id)
- return SvnRevisionTree(self, revision_id, inventory)
+ return SvnRevisionTree(self, revision_id)
def revision_fileid_renames(self, revid):
(path, revnum) = self.parse_revision_id(revid)
More information about the bazaar-commits
mailing list