Rev 608: Use revision properties rather than file properties where possible. in file:///data/jelmer/bzr-svn/revprops/
Jelmer Vernooij
jelmer at samba.org
Sat Dec 15 18:45:25 GMT 2007
At file:///data/jelmer/bzr-svn/revprops/
------------------------------------------------------------
revno: 608
revision-id:jelmer at samba.org-20071215184524-cspi2ioxoglhpb0j
parent: jelmer at samba.org-20071215154446-hyk9gnepf89sz2oi
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: revprops
timestamp: Sat 2007-12-15 19:45:24 +0100
message:
Use revision properties rather than file properties where possible.
modified:
BRANCH.TODO branch.todo-20070721175243-w23kkak0gm2jbr8b-1
NEWS news-20061231030336-h9fhq245ie0de8bs-1
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
fetch.py fetch.py-20060625004942-x2lfaib8ra707a8p-1
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'BRANCH.TODO'
--- a/BRANCH.TODO 2007-12-15 15:44:46 +0000
+++ b/BRANCH.TODO 2007-12-15 18:45:24 +0000
@@ -1,21 +1,3 @@
-Subversion 1.5 adds support for custom revision properties. This allows moving the various Bazaar-related
-properties from file to revision properties.
-
-The following settings would be set on the revisions:
-* bzr:branch
-* bzr:revision-id
-* bzr:merge
-* bzr:pgp-signature
-* bzr:committer
-* bzr:timestamp
-* bzr:properties:branch-nick
-* bzr:properties:*
-* bzr:root
-* bzr:mapping-version
-
-bzr-svn should not be looking at any file properties set on the branch root if any
-of these revision properties is set.
-
-Needs more tests...:
-
-Make sure that bzr revprops set as bzr:* in svn properties don't get converted to svn:bzr: in bzr revprops.
+- Needs more tests
+- Needs upgrade command that can use legacy file properties and set revprops
+- Support disabling legacy file property support somehow
=== modified file 'NEWS'
--- a/NEWS 2007-12-14 13:52:08 +0000
+++ b/NEWS 2007-12-15 18:45:24 +0000
@@ -8,6 +8,8 @@
* Work around memory leak in the Python Subversion bindings of svn.ra.get_log().
+ * Set revision properties when possible.
+
bzr-svn 0.4.5 2007-12-01
IMPROVEMENTS
=== modified file 'commit.py'
--- a/commit.py 2007-12-15 15:44:46 +0000
+++ b/commit.py 2007-12-15 18:45:24 +0000
@@ -38,8 +38,8 @@
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_TIMEZONE,
- SVN_REVPROP_BZR_MAPPING_VERSION)
+ SVN_REVPROP_BZR_TIMESTAMP, SVN_REVPROP_BZR_MAPPING_VERSION,
+ format_highres_date)
import urllib
@@ -108,10 +108,7 @@
self._svn_revprops = {SVN_REVPROP_BZR_MAPPING_VERSION: str(MAPPING_VERSION)}
if timestamp is not None:
- self._svn_revprops[SVN_REVPROP_BZR_TIMESTAMP] = str(timestamp)
-
- if timezone is not None:
- self._svn_revprops[SVN_REVPROP_BZR_TIMEZONE] = str(timezone)
+ 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")
@@ -490,7 +487,7 @@
fileids += list(_dir_process_file_id(self.old_inv, self.new_inventory, "", self.new_inventory.root.file_id))
if fileids != []:
- file_id_text = "".join(["%s\t%s\n" % (urllib.quote(path), file_id) for (path, file_id) in fileids])
+ file_id_text = "".join(["%s\t%s\n" % (urllib.quote(path), file_id) for (file_id, path) in fileids])
self._svn_revprops[SVN_REVPROP_BZR_FILEIDS] = file_id_text
self._svnprops[SVN_PROP_BZR_FILEIDS] = file_id_text
@@ -537,7 +534,6 @@
value = value.encode('utf-8')
self.editor.change_dir_prop(branch_batons[-1], prop, value,
self.pool)
- self.mutter("setting revision property %r to %r" % (prop, value))
for baton in reversed(branch_batons):
self.editor.close_directory(baton, self.pool)
=== modified file 'fetch.py'
--- a/fetch.py 2007-11-26 11:32:01 +0000
+++ b/fetch.py 2007-12-15 18:45:24 +0000
@@ -34,8 +34,10 @@
SVN_PROP_SVK_MERGE, SVN_PROP_BZR_MERGE,
SVN_PROP_BZR_PREFIX, SVN_PROP_BZR_REVISION_INFO,
SVN_PROP_BZR_BRANCHING_SCHEME, SVN_PROP_BZR_REVISION_ID,
+ SVN_REVPROP_BZR_MAPPING_VERSION, MAPPING_VERSION,
SVN_PROP_BZR_FILEIDS, SvnRepositoryFormat,
- parse_revision_metadata, parse_merge_property)
+ parse_revision_metadata, parse_merge_property,
+ revision_parse_svn_revprops)
from tree import apply_txdelta_handler
@@ -121,26 +123,9 @@
rev = Revision(revision_id=revid, parent_ids=self._get_parent_ids())
svn_revprops = self.source._log._get_transport().revprop_list(self.revnum)
- if svn_revprops.has_key(svn.core.SVN_PROP_REVISION_DATE):
- rev.timestamp = 1.0 * svn.core.secs_from_timestr(
- svn_revprops[svn.core.SVN_PROP_REVISION_DATE], None)
- else:
- rev.timestamp = 0 # FIXME: Obtain repository creation time
- rev.timezone = None
-
- if svn_revprops.has_key(svn.core.SVN_PROP_REVISION_AUTHOR):
- rev.committer = svn_revprops[svn.core.SVN_PROP_REVISION_AUTHOR]
- else:
- rev.committer = ""
- rev.message = svn_revprops.get(svn.core.SVN_PROP_REVISION_LOG)
- if rev.message is not None:
- assert isinstance(rev.message, str)
- try:
- rev.message = rev.message.decode("utf-8")
- except UnicodeDecodeError:
- pass
-
- if self._revinfo:
+ revision_parse_svn_revprops(rev, svn_revprops)
+
+ if self._revinfo and svn_revprops.get(SVN_REVPROP_BZR_MAPPING_VERSION) != str(MAPPING_VERSION):
parse_revision_metadata(self._revinfo, rev)
return rev
=== modified file 'logwalker.py'
--- a/logwalker.py 2007-12-14 15:56:28 +0000
+++ b/logwalker.py 2007-12-15 18:45:24 +0000
@@ -26,7 +26,7 @@
from cache import sqlite3
-LOG_CHUNK_LIMIT = 1000
+LOG_CHUNK_LIMIT = 0
class LogWalker(object):
"""Easy way to access the history of a Subversion repository."""
=== modified file 'repository.py'
--- a/repository.py 2007-12-15 15:44:46 +0000
+++ b/repository.py 2007-12-15 18:45:24 +0000
@@ -64,7 +64,6 @@
SVN_REVPROP_BZR_ROOT = 'bzr:root'
SVN_REVPROP_BZR_SIGNATURE = 'bzr:gpg-signature'
SVN_REVPROP_BZR_TIMESTAMP = 'bzr:timestamp'
-SVN_REVPROP_BZR_TIMEZONE = 'bzr:timezone'
SVN_REVPROP_BZR_MAPPING_VERSION = 'bzr:mapping-version'
# The following two functions don't use day names (which can vary by
@@ -238,6 +237,42 @@
return "%s:/%s:%d" % (uuid, branch, revnum)
+def revision_parse_svn_revprops(rev, props):
+ """Update a Revision object from a set of Subversion revision properties.
+
+ :param rev: Revision object
+ :param props: Dictionary with Subversion revision properties.
+ """
+ rev.timezone = None
+
+ if props.has_key(SVN_REVPROP_BZR_TIMESTAMP):
+ (rev.timestamp, rev.timezone) = unpack_highres_date(props[SVN_REVPROP_BZR_TIMESTAMP])
+ elif props.has_key(svn.core.SVN_PROP_REVISION_DATE):
+ rev.timestamp = 1.0 * svn.core.secs_from_timestr(
+ props[svn.core.SVN_PROP_REVISION_DATE], None)
+ else:
+ rev.timestamp = 0 # FIXME: Obtain repository creation time
+
+ if props.has_key(SVN_REVPROP_BZR_COMMITTER):
+ rev.committer = props[SVN_REVPROP_BZR_COMMITTER].decode("utf-8")
+ elif props.has_key(svn.core.SVN_PROP_REVISION_AUTHOR):
+ rev.committer = props[svn.core.SVN_PROP_REVISION_AUTHOR]
+ else:
+ rev.committer = ""
+
+ rev.message = props.get(svn.core.SVN_PROP_REVISION_LOG)
+ if rev.message is not None:
+ assert isinstance(rev.message, str)
+ try:
+ rev.message = rev.message.decode("utf-8")
+ except UnicodeDecodeError:
+ pass
+
+ for name, value in props.items():
+ if name.startswith(SVN_REVPROP_BZR_REVPROP_PREFIX):
+ rev.properties[name[len(SVN_REVPROP_BZR_REVPROP_PREFIX):]] = value
+
+
class SvnRepositoryFormat(RepositoryFormat):
"""Repository format for Subversion repositories (accessed using svn_ra).
"""
@@ -498,14 +533,21 @@
:return: dictionary with paths as keys, file ids as values
"""
(path, revnum, _) = self.lookup_revision_id(revid)
- # Only consider bzr:file-ids if this is a bzr revision
- if not self.branchprop_list.touches_property(path, revnum,
- SVN_PROP_BZR_REVISION_INFO):
- return {}
- fileids = self.branchprop_list.get_property(path, revnum,
- SVN_PROP_BZR_FILEIDS)
- if fileids is None:
- return {}
+
+ svn_revprops = self.transport.revprop_list(revnum)
+ if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
+ if not svn_revprops.has_key(SVN_REVPROP_BZR_FILEIDS):
+ return {}
+ fileids = svn_revprops[SVN_REVPROP_BZR_FILEIDS]
+ else:
+ # Only consider bzr:file-ids if this is a bzr revision
+ if not self.branchprop_list.touches_property(path, revnum,
+ SVN_PROP_BZR_REVISION_INFO):
+ return {}
+ fileids = self.branchprop_list.get_property(path, revnum,
+ SVN_PROP_BZR_FILEIDS)
+ if fileids is None:
+ return {}
ret = {}
for line in fileids.splitlines():
(path, key) = line.split("\t", 2)
@@ -623,15 +665,21 @@
if not self._log.touches_path(branch, revnum):
return parent_ids
+ svn_revprops = self.transport.revprop_list(revnum)
+ if svn_revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
+ if svn_revprops[SVN_REVPROP_BZR_ROOT] != branch:
+ return parent_ids
+ if not svn_revprops.has_key(SVN_REVPROP_BZR_MERGE):
+ return parent_ids
+ return parent_ids + svn_revprops[SVN_REVPROP_BZR_MERGE].splitlines()
+
if bzr_merges is None:
bzr_merges = self._bzr_merged_revisions(branch, revnum, scheme)
- if svk_merges is None:
+
+ parent_ids.extend(bzr_merges)
+
+ if bzr_merges == [] and svk_merges is None:
svk_merges = self._svk_merged_revisions(branch, revnum, scheme)
-
- parent_ids.extend(bzr_merges)
-
- if bzr_merges == []:
- # Commit was doing using svk apparently
parent_ids.extend(svk_merges)
return parent_ids
@@ -650,29 +698,13 @@
inventory_sha1 = property(lambda rev: self.get_inventory_sha1(rev.revision_id))
rev = LazySvnRevision(revision_id=revision_id, parent_ids=parent_ids)
-
- svn_revprops = self.transport.revprop_list(revnum)
-
- if svn_revprops.has_key(svn.core.SVN_PROP_REVISION_AUTHOR):
- rev.committer = svn_revprops[svn.core.SVN_PROP_REVISION_AUTHOR]
- else:
- rev.committer = ""
-
- rev.message = svn_revprops.get(svn.core.SVN_PROP_REVISION_LOG)
-
- if rev.message:
- try:
- rev.message = rev.message.decode("utf-8")
- except UnicodeDecodeError:
- pass
-
- if svn_revprops.has_key(svn.core.SVN_PROP_REVISION_DATE):
- rev.timestamp = 1.0 * svn.core.secs_from_timestr(svn_revprops[svn.core.SVN_PROP_REVISION_DATE], None)
- else:
- rev.timestamp = 0.0 # FIXME: Obtain repository creation time
- rev.timezone = None
rev.properties = {}
- parse_revision_metadata(
+
+ svn_revprops = self.transport.revprop_list(revnum)
+ revision_parse_svn_revprops(rev, svn_revprops)
+
+ if svn_revprops.get(SVN_REVPROP_BZR_MAPPING_VERSION) != str(MAPPING_VERSION):
+ parse_revision_metadata(
self.branchprop_list.get_property(path, revnum,
SVN_PROP_BZR_REVISION_INFO, ""), rev)
@@ -703,24 +735,33 @@
if revid is not None:
return revid
- # Lookup the revision from the bzr:revision-id-vX property
- line = self.branchprop_list.get_property_diff(path, revnum,
- SVN_PROP_BZR_REVISION_ID+str(scheme)).strip("\n")
- # Or generate it
- if line == "":
- revid = generate_svn_revision_id(self.uuid, revnum, path,
- scheme)
+ # See if there is a bzr:revision-id revprop set
+ revprops = self._log._get_transport().revprop_list(revnum)
+ if revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
+ if revprops[SVN_REVPROP_BZR_ROOT] == path:
+ revid = revprops[SVN_REVPROP_BZR_REVISION_ID]
+ else:
+ revid = generate_svn_revision_id(self.uuid, revnum, path,
+ scheme)
else:
- try:
- (bzr_revno, revid) = parse_revid_property(line)
- self.revmap.insert_revid(revid, path, revnum, revnum,
- scheme, bzr_revno)
- except errors.InvalidPropertyValue, e:
- mutter(str(e))
+ # Lookup the revision from the bzr:revision-id-vX property
+ line = self.branchprop_list.get_property_diff(path, revnum,
+ SVN_PROP_BZR_REVISION_ID+str(scheme)).strip("\n")
+ # Or generate it
+ if line == "":
revid = generate_svn_revision_id(self.uuid, revnum, path,
scheme)
- self.revmap.insert_revid(revid, path, revnum, revnum,
- scheme)
+ else:
+ try:
+ (bzr_revno, revid) = parse_revid_property(line)
+ self.revmap.insert_revid(revid, path, revnum, revnum,
+ scheme, bzr_revno)
+ except errors.InvalidPropertyValue, e:
+ mutter(str(e))
+ revid = generate_svn_revision_id(self.uuid, revnum, path,
+ scheme)
+ self.revmap.insert_revid(revid, path, revnum, revnum,
+ scheme)
return revid
More information about the bazaar-commits
mailing list