Rev 623: Move more code to mapping. in file:///data/jelmer/bzr-svn/revprops/
Jelmer Vernooij
jelmer at samba.org
Fri Feb 1 19:31:34 GMT 2008
At file:///data/jelmer/bzr-svn/revprops/
------------------------------------------------------------
revno: 623
revision-id:jelmer at samba.org-20080201193133-zrbbnqo4puizgg0d
parent: jelmer at samba.org-20080201190748-4kvoeqydlo7myg59
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: revprops
timestamp: Fri 2008-02-01 20:31:33 +0100
message:
Move more code to mapping.
modified:
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
=== modified file 'commit.py'
--- a/commit.py 2008-02-01 18:52:36 +0000
+++ b/commit.py 2008-02-01 19:31:33 +0000
@@ -30,16 +30,8 @@
from copy import deepcopy
from cStringIO import StringIO
from errors import ChangesRootLHSHistory, MissingPrefix, RevpropChangeFailed
-from mapping import (SVN_PROP_BZR_ANCESTRY, SVN_PROP_BZR_FILEIDS,
- SVN_PROP_BZR_REVISION_INFO, SVN_PROP_BZR_REVISION_ID,
- SVN_REVPROP_BZR_COMMITTER, SVN_REVPROP_BZR_FILEIDS,
- SVN_REVPROP_BZR_MERGE, SVN_REVPROP_BZR_REVISION_ID,
- SVN_REVPROP_BZR_REVPROP_PREFIX, SVN_REVPROP_BZR_ROOT,
- SVN_REVPROP_BZR_TIMESTAMP, SVN_REVPROP_BZR_MAPPING_VERSION,
- MAPPING_VERSION, generate_revision_metadata)
-from repository import (revision_id_to_svk_feature, format_highres_date,
- SvnRepositoryFormat, SvnRepository)
-from svk import SVN_PROP_SVK_MERGE
+from mapping import (SVN_PROP_BZR_FILEIDS, SVN_REVPROP_BZR_FILEIDS)
+from repository import (SvnRepositoryFormat, SvnRepository)
import urllib
@@ -99,24 +91,6 @@
self.branch = branch
self.pool = Pool()
- # Keep track of what Subversion properties to set later on
- self._svnprops = {}
- self._svnprops[SVN_PROP_BZR_REVISION_INFO] = generate_revision_metadata(
- timestamp, timezone, committer, revprops)
- self._svnprops[SVN_PROP_BZR_FILEIDS] = ""
-
- self._svn_revprops = {SVN_REVPROP_BZR_MAPPING_VERSION: str(MAPPING_VERSION)}
-
- if timestamp is not None:
- self._svn_revprops[SVN_REVPROP_BZR_TIMESTAMP] = format_highres_date(timestamp, timezone)
-
- if committer is not None:
- self._svn_revprops[SVN_REVPROP_BZR_COMMITTER] = committer.encode("utf-8")
-
- if revprops is not None:
- for name, value in revprops.items():
- self._svn_revprops[SVN_REVPROP_BZR_REVPROP_PREFIX+name] = value
-
# Gather information about revision on top of which the commit is
# happening
if parents == []:
@@ -157,60 +131,13 @@
self.modified_files = {}
self.modified_dirs = set()
+ (self._svn_revprops, self._svnprops) = default_mapping.generate_svn_revision(timestamp, timezone, committer, revprops, revision_id)
+ self._svnprops[SVN_PROP_BZR_FILEIDS] = ""
def mutter(self, text):
if 'commit' in debug.debug_flags:
mutter(text)
- def _record_revision_id(self, revid):
- """Store the revision id in a file property.
-
- :param revid: The revision id.
- """
- if self.base_revid is not None:
- old = self.repository.branchprop_list.get_property(
- self.base_path, self.base_revnum,
- SVN_PROP_BZR_REVISION_ID+str(self.base_scheme), "")
- else:
- old = ""
-
- self._svnprops[SVN_PROP_BZR_REVISION_ID+str(self.base_scheme)] = \
- old + "%d %s\n" % (self.base_revno+1, revid)
- self._svn_revprops[SVN_REVPROP_BZR_REVISION_ID] = revid
-
- def _record_merges(self, merges):
- """Store the extra merges (non-LHS parents) in a file property.
-
- :param merges: List of parents.
- """
- # Bazaar Parents
- if self.base_revid is not None:
- old = self.repository.branchprop_list.get_property(
- self.base_path, self.base_revnum,
- SVN_PROP_BZR_ANCESTRY+str(self.base_scheme), "")
- else:
- old = ""
- self._svnprops[SVN_PROP_BZR_ANCESTRY+str(self.base_scheme)] = old + "\t".join(merges) + "\n"
-
- if self.base_revid is not None:
- old = self.repository.branchprop_list.get_property(
- self.base_path, self.base_revnum, SVN_PROP_SVK_MERGE, "")
- else:
- old = ""
-
- new = ""
- # SVK compatibility
- for merge in merges:
- try:
- new += "%s\n" % revision_id_to_svk_feature(merge)
- except InvalidRevisionId:
- pass
-
- if new != "":
- self._svnprops[SVN_PROP_SVK_MERGE] = old + new
-
- self._svn_revprops[SVN_REVPROP_BZR_MERGE] = "".join(map(lambda x: x + "\n", merges))
-
def _generate_revision_if_needed(self):
"""See CommitBuilder._generate_revision_if_needed()."""
@@ -455,7 +382,6 @@
"""
self.revision_metadata = revision_data
- self._svn_revprops[SVN_REVPROP_BZR_ROOT] = self.branch.get_branch_path()
bp_parts = self.branch.get_branch_path().split("/")
repository_latest_revnum = self.repository.transport.get_latest_revnum()
lock = self.repository.transport.lock_write(".")
@@ -495,7 +421,6 @@
existing_bp_parts = _check_dirs_exist(self.repository.transport,
bp_parts, -1)
self.revision_metadata = None
- self._svn_revprops[svn.core.SVN_PROP_REVISION_LOG] = message.encode("utf-8")
try:
self.editor = self.repository.transport.get_commit_editor(self._svn_revprops,
done, None, False)
=== modified file 'mapping.py'
--- a/mapping.py 2008-02-01 19:07:48 +0000
+++ b/mapping.py 2008-02-01 19:31:33 +0000
@@ -311,6 +311,13 @@
def get_fileid_map(revprops, get_branch_file_property):
raise NotImplementedError(self.get_fileid_map)
+ @staticmethod
+ def generate_svn_revision(rev):
+ """Determines the revision properties and branch root file
+ properties.
+ """
+ raise NotImplementedError(self.generate_svn_revision)
+
class BzrSvnMappingv1(BzrSvnMapping):
"""This was the initial version of the mappings as used by bzr-svn
@@ -443,6 +450,79 @@
return {}
return parse_fileid_property(fileids)
+ def _record_revision_id(self, revid):
+ """Store the revision id in a file property.
+
+ :param revid: The revision id.
+ """
+ if self.base_revid is not None:
+ old = self.repository.branchprop_list.get_property(
+ self.base_path, self.base_revnum,
+ SVN_PROP_BZR_REVISION_ID+str(self.base_scheme), "")
+ else:
+ old = ""
+
+ self._svnprops[SVN_PROP_BZR_REVISION_ID+str(self.base_scheme)] = \
+ old + "%d %s\n" % (self.base_revno+1, revid)
+ self._svn_revprops[SVN_REVPROP_BZR_REVISION_ID] = revid
+
+ def _record_merges(self, merges):
+ """Store the extra merges (non-LHS parents) in a file property.
+
+ :param merges: List of parents.
+ """
+ # Bazaar Parents
+ if self.base_revid is not None:
+ old = self.repository.branchprop_list.get_property(
+ self.base_path, self.base_revnum,
+ SVN_PROP_BZR_ANCESTRY+str(self.base_scheme), "")
+ else:
+ old = ""
+ self._svnprops[SVN_PROP_BZR_ANCESTRY+str(self.base_scheme)] = old + "\t".join(merges) + "\n"
+
+ if self.base_revid is not None:
+ old = self.repository.branchprop_list.get_property(
+ self.base_path, self.base_revnum, SVN_PROP_SVK_MERGE, "")
+ else:
+ old = ""
+
+ new = ""
+ # SVK compatibility
+ for merge in merges:
+ try:
+ new += "%s\n" % revision_id_to_svk_feature(merge)
+ except InvalidRevisionId:
+ pass
+
+ if new != "":
+ self._svnprops[SVN_PROP_SVK_MERGE] = old + new
+
+ self._svn_revprops[SVN_REVPROP_BZR_MERGE] = "".join(map(lambda x: x + "\n", merges))
+
+ @staticmethod
+ def generate_svn_revision(timestamp, timezone, committer, message, revprops):
+ # Keep track of what Subversion properties to set later on
+ fileprops = {}
+ fileprops[SVN_PROP_BZR_REVISION_INFO] = generate_revision_metadata(
+ timestamp, timezone, committer, revprops)
+
+ svn_revprops = {SVN_REVPROP_BZR_MAPPING_VERSION: str(MAPPING_VERSION)}
+
+ if timestamp is not None:
+ svn_revprops[SVN_REVPROP_BZR_TIMESTAMP] = format_highres_date(timestamp, timezone)
+
+ if committer is not None:
+ svn_revprops[SVN_REVPROP_BZR_COMMITTER] = committer.encode("utf-8")
+
+ if revprops is not None:
+ for name, value in revprops.items():
+ svn_revprops[SVN_REVPROP_BZR_REVPROP_PREFIX+name] = value
+
+ svn_revprops[SVN_REVPROP_BZR_ROOT] = self.branch.get_branch_path()
+ svn_revprops[svn.core.SVN_PROP_REVISION_LOG] = message.encode("utf-8")
+
+ return (svn_revprops, fileprops)
+
class BzrSvnMappingv4(BzrSvnMappingv3):
@staticmethod
More information about the bazaar-commits
mailing list