Rev 428: Move revid code to separate file in preparation of expansion. in sftp://people.samba.org/~/bzr/bzr-svn/customrevids/
Jelmer Vernooij
jelmer at samba.org
Tue Apr 17 00:30:25 BST 2007
At sftp://people.samba.org/~/bzr/bzr-svn/customrevids/
------------------------------------------------------------
revno: 428
revision-id: jelmer at samba.org-20070416232957-4p8w07zrz9fgjk96
parent: jelmer at samba.org-20070416013009-i1fs5ukhj3hg1i1i
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Tue 2007-04-17 01:29:57 +0200
message:
Move revid code to separate file in preparation of expansion.
added:
revids.py revids.py-20070416220458-36vfa0730cchevp1-1
modified:
checkout.py workingtree.py-20060306120941-b083cb0fdd4a69de
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
upgrade.py upgrade.py-20070106192108-0rakplee2lzah4gs-1
=== added file 'revids.py'
--- a/revids.py 1970-01-01 00:00:00 +0000
+++ b/revids.py 2007-04-16 23:29:57 +0000
@@ -0,0 +1,72 @@
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# 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 (InvalidRevisionId, NoSuchRevision,
+ NotBranchError, UninitializableFormat)
+
+MAPPING_VERSION = 3
+REVISION_ID_PREFIX = "svn-v%d-" % MAPPING_VERSION
+
+import urllib
+
+def escape_svn_path(x):
+ if isinstance(x, unicode):
+ x = x.encode("utf-8")
+ return urllib.quote(x, "")
+unescape_svn_path = urllib.unquote
+
+
+def parse_svn_revision_id(revid):
+ """Parse an existing Subversion-based revision id.
+
+ :param revid: The revision id.
+ :raises: InvalidRevisionId
+ :return: Tuple with uuid, branch path and revision number.
+ """
+
+ assert revid
+ assert isinstance(revid, basestring)
+
+ if not revid.startswith(REVISION_ID_PREFIX):
+ raise InvalidRevisionId(revid, "")
+
+ try:
+ (version, uuid, branch_path, srevnum)= revid.split(":")
+ except ValueError:
+ raise InvalidRevisionId(revid, "")
+
+ revid = revid[len(REVISION_ID_PREFIX):]
+
+ return (uuid, unescape_svn_path(branch_path), int(srevnum))
+
+
+def generate_svn_revision_id(uuid, revnum, path, scheme="undefined"):
+ """Generate a unambiguous revision id.
+
+ :param uuid: UUID of the repository.
+ :param revnum: Subversion revision number.
+ :param path: Branch path.
+ :param scheme: Name of the branching scheme in use
+
+ :return: New revision id.
+ """
+ assert isinstance(revnum, int)
+ assert isinstance(path, basestring)
+ assert revnum >= 0
+ assert revnum > 0 or path == ""
+ return "%s%s:%s:%s:%d" % (REVISION_ID_PREFIX, scheme, uuid, \
+ escape_svn_path(path.strip("/")), revnum)
+
=== modified file 'checkout.py'
--- a/checkout.py 2007-04-15 17:35:04 +0000
+++ b/checkout.py 2007-04-16 23:29:57 +0000
@@ -30,9 +30,10 @@
from branch import SvnBranch
from convert import SvnConverter
-from repository import (SvnRepository, escape_svn_path, SVN_PROP_BZR_MERGE,
+from repository import (SvnRepository, SVN_PROP_BZR_MERGE,
SVN_PROP_SVK_MERGE, SVN_PROP_BZR_FILEIDS,
revision_id_to_svk_feature)
+from revids import escape_svn_path
from scheme import BranchingScheme
from transport import (SvnRaTransport, svn_config, bzr_to_svn_url,
_create_auth_baton)
=== modified file 'commit.py'
--- a/commit.py 2007-04-15 17:35:04 +0000
+++ b/commit.py 2007-04-16 23:29:57 +0000
@@ -25,8 +25,8 @@
from repository import (SvnRepository, SVN_PROP_BZR_MERGE, SVN_PROP_BZR_FILEIDS,
SVN_PROP_SVK_MERGE, SVN_PROP_BZR_REVPROP_PREFIX,
- SVN_PROP_BZR_REVISION_ID, revision_id_to_svk_feature,
- escape_svn_path)
+ SVN_PROP_BZR_REVISION_ID, revision_id_to_svk_feature)
+from revids import escape_svn_path
import os
=== modified file 'fileids.py'
--- a/fileids.py 2007-03-25 19:50:45 +0000
+++ b/fileids.py 2007-04-16 23:29:57 +0000
@@ -21,8 +21,8 @@
import sha
-from repository import (escape_svn_path, generate_svn_revision_id,
- parse_svn_revision_id)
+from revids import (generate_svn_revision_id, parse_svn_revision_id,
+ escape_svn_path)
def generate_svn_file_id(uuid, revnum, branch, path):
"""Create a file id identifying a Subversion file.
=== modified file 'repository.py'
--- a/repository.py 2007-04-16 01:30:09 +0000
+++ b/repository.py 2007-04-16 23:29:57 +0000
@@ -40,10 +40,10 @@
from branchprops import BranchPropertyList
import errors
import logwalker
+from revids import (generate_svn_revision_id, parse_svn_revision_id,
+ MAPPING_VERSION)
from tree import SvnRevisionTree
-MAPPING_VERSION = 3
-REVISION_ID_PREFIX = "svn-v%d-" % MAPPING_VERSION
SVN_PROP_BZR_PREFIX = 'bzr:'
SVN_PROP_BZR_MERGE = 'bzr:merge'
SVN_PROP_BZR_FILEIDS = 'bzr:file-ids'
@@ -53,56 +53,6 @@
SVN_REVPROP_BZR_SIGNATURE = 'bzr:gpg-signature'
SVN_PROP_BZR_REVISION_ID = 'bzr:revision-id-v%d' % MAPPING_VERSION
-import urllib
-
-def escape_svn_path(x):
- if isinstance(x, unicode):
- x = x.encode("utf-8")
- return urllib.quote(x, "")
-unescape_svn_path = urllib.unquote
-
-
-def parse_svn_revision_id(revid):
- """Parse an existing Subversion-based revision id.
-
- :param revid: The revision id.
- :raises: InvalidRevisionId
- :return: Tuple with uuid, branch path and revision number.
- """
-
- assert revid
- assert isinstance(revid, basestring)
-
- if not revid.startswith(REVISION_ID_PREFIX):
- raise InvalidRevisionId(revid, "")
-
- try:
- (version, uuid, branch_path, srevnum)= revid.split(":")
- except ValueError:
- raise InvalidRevisionId(revid, "")
-
- revid = revid[len(REVISION_ID_PREFIX):]
-
- return (uuid, unescape_svn_path(branch_path), int(srevnum))
-
-
-def generate_svn_revision_id(uuid, revnum, path, scheme="undefined"):
- """Generate a unambiguous revision id.
-
- :param uuid: UUID of the repository.
- :param revnum: Subversion revision number.
- :param path: Branch path.
- :param scheme: Name of the branching scheme in use
-
- :return: New revision id.
- """
- assert isinstance(revnum, int)
- assert isinstance(path, basestring)
- assert revnum >= 0
- assert revnum > 0 or path == ""
- return "%s%s:%s:%s:%d" % (REVISION_ID_PREFIX, scheme, uuid, \
- escape_svn_path(path.strip("/")), revnum)
-
def svk_feature_to_revision_id(feature):
"""Create a revision id from a svk feature identifier.
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2007-04-14 18:00:15 +0000
+++ b/tests/test_repos.py 2007-04-16 23:29:57 +0000
@@ -32,10 +32,10 @@
from scheme import TrunkBranchingScheme, NoBranchingScheme
from transport import SvnRaTransport
from tests import TestCaseWithSubversionRepository
-from repository import (parse_svn_revision_id, generate_svn_revision_id,
- svk_feature_to_revision_id, revision_id_to_svk_feature,
- MAPPING_VERSION, escape_svn_path, unescape_svn_path,
+from repository import (svk_feature_to_revision_id, revision_id_to_svk_feature,
SvnRepositoryFormat)
+from revids import (MAPPING_VERSION, escape_svn_path, unescape_svn_path,
+ parse_svn_revision_id, generate_svn_revision_id)
class TestSubversionRepositoryWorks(TestCaseWithSubversionRepository):
=== modified file 'upgrade.py'
--- a/upgrade.py 2007-03-25 18:41:40 +0000
+++ b/upgrade.py 2007-04-16 23:29:57 +0000
@@ -20,8 +20,8 @@
from bzrlib.trace import mutter
import bzrlib.ui as ui
-from repository import (MAPPING_VERSION, parse_svn_revision_id,
- unescape_svn_path, generate_svn_revision_id)
+from revids import (generate_svn_revision_id, parse_svn_revision_id,
+ MAPPING_VERSION, unescape_svn_path)
# Takes an existing Bazaar branch and replaces all old-version mapped revisions
# with new-style revisions mappings.
More information about the bazaar-commits
mailing list