Rev 1601: Add --incremental option to svn-import. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Fri Aug 22 17:13:06 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1601
revision-id: jelmer at samba.org-20080822161303-grscoqlrn9myx6p0
parent: jelmer at samba.org-20080822154821-qaxucsnlvpypgu01
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-08-22 18:13:03 +0200
message:
Add --incremental option to svn-import.
modified:
NEWS news-20061231030336-h9fhq245ie0de8bs-1
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
convert.py svn2bzr.py-20051018015439-cb4563bff29e632d
transport.py transport.py-20060406231150-b3472d06b3a0818d
=== modified file 'NEWS'
--- a/NEWS 2008-08-22 15:48:21 +0000
+++ b/NEWS 2008-08-22 16:13:03 +0000
@@ -18,6 +18,8 @@
(#246243). The --keep option can be specified to keep
branches removed in Subversion around.
+ * add --incremental option to bzr-svn for incremental imports.
+
bzr-svn 0.4.11~rc1 2008-08-08
CHANGES
=== modified file '__init__.py'
--- a/__init__.py 2008-08-22 15:47:02 +0000
+++ b/__init__.py 2008-08-22 16:13:03 +0000
@@ -219,7 +219,9 @@
help='Branching scheme (none, trunk, etc). '
'Default: auto.'),
Option('keep',
- help="Don't delete branches removed in Subversion"),
+ help="Don't delete branches removed in Subversion."),
+ Option('incremental',
+ help="Import revisions incrementally."),
Option('prefix', type=str,
help='Only consider branches of which path starts '
'with prefix.')
@@ -227,7 +229,8 @@
@display_command
def run(self, from_location, to_location=None, trees=False,
- standalone=False, scheme=None, all=False, prefix=None, keep=False):
+ standalone=False, scheme=None, all=False, prefix=None, keep=False,
+ incremental=False):
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDir
from bzrlib.errors import BzrCommandError, NoRepositoryPresent, NotBranchError
@@ -289,7 +292,7 @@
convert_repository(from_repos, to_location, scheme, None,
not standalone, trees, all,
filter_branch=filter_branch,
- keep=keep)
+ keep=keep, incremental=incremental)
if tmp_repos is not None:
from bzrlib import osutils
=== modified file 'convert.py'
--- a/convert.py 2008-08-22 15:47:02 +0000
+++ b/convert.py 2008-08-22 16:13:03 +0000
@@ -31,6 +31,34 @@
from bzrlib.plugins.svn.errors import ERR_STREAM_MALFORMED_DATA
from bzrlib.plugins.svn.format import get_rich_root_format
+LATEST_SVN_IMPORT_REVISION_FILENAME = "bzr-svn-import-revision"
+
+def get_latest_svn_import_revision(repo, uuid):
+ """Retrieve the latest revision checked by svn-import.
+
+ :param repo: A repository object.
+ :param uuid: Subversion repository UUID.
+ """
+ try:
+ text = repo.bzrdir.transport.get_bytes(LATEST_SVN_IMPORT_REVISION_FILENAME)
+ except NoSuchFile:
+ return 0
+ (text_uuid, revnum) = text.strip().split(" ")
+ if text_uuid != uuid:
+ return 0
+ return int(revnum)
+
+
+def put_latest_svn_import_revision(repo, uuid, revnum):
+ """Store the latest revision checked by svn-import.
+
+ :param repo: A repository object.
+ :param uuid: Subversion repository UUID.
+ :param revnum: A revision number.
+ """
+ repo.bzrdir.transport.put_bytes(LATEST_SVN_IMPORT_REVISION_FILENAME,
+ "%s %d\n" % (uuid, revnum))
+
def transport_makedirs(transport, location_url):
"""Create missing directories.
@@ -86,7 +114,8 @@
def convert_repository(source_repos, output_url, scheme=None, layout=None,
create_shared_repo=True, working_trees=False, all=False,
- format=None, filter_branch=None, keep=False):
+ format=None, filter_branch=None, keep=False,
+ incremental=False):
"""Convert a Subversion repository and its' branches to a
Bazaar repository.
@@ -132,10 +161,16 @@
except NoRepositoryPresent:
target_repos = get_dir("").create_repository(shared=True)
target_repos.set_make_working_trees(working_trees)
+ else:
+ target_repos = None
source_repos.lock_read()
try:
- from_revnum = 0
+ if incremental and target_repos is not None:
+ from_revnum = get_latest_svn_import_revision(target_repos,
+ source_repos.uuid)
+ else:
+ from_revnum = 0
to_revnum = source_repos.get_latest_revnum()
changed_branches = source_repos.find_fileprop_branches(layout=layout,
from_revnum=from_revnum, to_revnum=to_revnum, check_removed=True)
@@ -203,6 +238,9 @@
pb.finished()
finally:
source_repos.unlock()
+
+ if target_repos is not None:
+ put_latest_svn_import_revision(target_repos, source_repos.uuid, to_revnum)
class SvnConverter(Converter):
=== modified file 'transport.py'
--- a/transport.py 2008-08-22 13:38:31 +0000
+++ b/transport.py 2008-08-22 16:13:03 +0000
@@ -128,7 +128,8 @@
new_url = msg[msg.index("»")+2:msg.index("«")]
else:
new_url = None
- raise RedirectRequested(source=url, target=new_url, is_permanent=True)
+ raise RedirectRequested(source=url, target=new_url,
+ is_permanent=True)
raise
from bzrlib.plugins.svn import lazy_check_versions
More information about the bazaar-commits
mailing list