Rev 1721: More tag improvements. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Sat Aug 30 22:11:16 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1721
revision-id: jelmer at samba.org-20080830211114-xnl50ubkekvqcrsp
parent: jelmer at samba.org-20080830201737-9g0g1nibbnnus194
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sat 2008-08-30 23:11:14 +0200
message:
More tag improvements.
modified:
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tags.py tags.py-20080822211316-scblu3akdvu0b64c-1
tests/test_workingtree.py test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
=== modified file 'mapping.py'
--- a/mapping.py 2008-08-30 20:17:37 +0000
+++ b/mapping.py 2008-08-30 21:11:14 +0000
@@ -49,6 +49,7 @@
SVN_REVPROP_BZR_REQUIRED_FEATURES = 'bzr:required-features'
SVN_REVPROP_BZR_BASE_REVISION = 'bzr:base-revision'
SVN_REVPROP_BZR_SKIP = 'bzr:skip'
+SVN_REVPROP_BZR_TAGS = 'bzr:tags'
def escape_svn_path(x):
@@ -193,6 +194,24 @@
"Invalid key %r" % key)
+def parse_tags_property(text):
+ for name, revid in [line.split("\t") for line in text.splitlines()]:
+ if revid == "":
+ yield name.decode("utf-8"), None
+ else:
+ yield name.decode("utf-8"), revid
+
+
+def generate_tags_property(tags):
+ ret = ""
+ for name in sorted(tags):
+ ret += "%s\t" % name.encode("utf-8")
+ if tags[name] is not None:
+ ret += tags[name]
+ ret += "\n"
+ return ret
+
+
def parse_revid_property(line):
"""Parse a (revnum, revid) tuple as set in revision id properties.
:param line: line to parse
@@ -734,6 +753,7 @@
return parse_mapping_name(k[len(SVN_PROP_BZR_REVISION_ID):])
return None
+
def is_bzr_revision_revprops(revprops):
if revprops.has_key(SVN_REVPROP_BZR_MAPPING_VERSION):
return True
@@ -741,6 +761,7 @@
return False
return None
+
def is_bzr_revision_fileprops(fileprops):
for k in fileprops:
if k.startswith(SVN_PROP_BZR_REVISION_ID):
=== modified file 'repository.py'
--- a/repository.py 2008-08-30 20:17:37 +0000
+++ b/repository.py 2008-08-30 21:11:14 +0000
@@ -39,6 +39,9 @@
from bzrlib.plugins.svn.config import SvnRepositoryConfig
from bzrlib.plugins.svn.core import SubversionException
from bzrlib.plugins.svn.mapping import (SVN_REVPROP_BZR_SIGNATURE,
+ SVN_REVPROP_BZR_TAGS,
+ SVN_REVPROP_BZR_SKIP,
+ parse_tags_property,
BzrSvnMapping,
get_default_mapping,
is_bzr_revision_revprops, is_bzr_revision_fileprops,
@@ -885,6 +888,14 @@
pb = ui.ui_factory.nested_progress_bar()
try:
for (paths, revnum, revprops) in self._log.iter_changes(None, from_revnum, to_revnum, pb=pb):
+ if (self.transport.has_capability("log-revprops") and
+ SVN_REVPROP_BZR_TAGS in revprops):
+ for name, revid in parse_tags_property(revprops[SVN_REVPROP_BZR_TAGS]):
+ if revid is None:
+ del tags[name]
+ else:
+ tags[name] = revid
+ continue
for p in sorted(paths):
(action, cf, cr) = paths[p]
if layout.is_tag_parent(p, project) and cf is not None:
@@ -972,6 +983,8 @@
try:
for (paths, i, revprops) in self._log.iter_changes([""], from_revnum, to_revnum):
pb.update("finding branches", i, to_revnum)
+ if self.transport.has_capability("log-revprops") and is_bzr_revision_revprops(revprops) is not None:
+ continue
for p in sorted(paths.keys()):
if check_path(p, project):
if paths[p][0] in ('R', 'D') and p in created_branches:
=== modified file 'tags.py'
--- a/tags.py 2008-08-29 23:55:41 +0000
+++ b/tags.py 2008-08-30 21:11:14 +0000
@@ -24,14 +24,18 @@
def __init__(self, branch):
self.branch = branch
self.repository = branch.repository
+ self._parent_exists = False
def _ensure_tag_parent_exists(self, parent):
+ if self._parent_exists:
+ return
assert isinstance(parent, str)
bp_parts = parent.split("/")
existing_bp_parts = commit._check_dirs_exist(
self.repository.transport,
bp_parts, self.repository.get_latest_revnum())
if existing_bp_parts == bp_parts:
+ self._parent_exists = True
return
conn = self.repository.transport.get_connection()
try:
@@ -60,6 +64,7 @@
ci.close()
finally:
self.repository.transport.add_connection(conn)
+ self._parent_exists = True
def set_tag(self, tag_name, tag_target):
path = self.branch.layout.get_tag_path(tag_name, self.branch.project)
@@ -76,7 +81,8 @@
conn = self.repository.transport.get_connection(parent)
deletefirst = (conn.check_path(urlutils.basename(path), self.repository.get_latest_revnum()) != core.NODE_NONE)
try:
- ci = conn.get_commit_editor(self._revprops("Add tag %s" % tag_name.encode("utf-8")))
+ ci = conn.get_commit_editor(self._revprops("Add tag %s" % tag_name.encode("utf-8"),
+ {tag_name.encode("utf-8"): tag_target}))
try:
root = ci.open_root()
if deletefirst:
@@ -90,14 +96,16 @@
finally:
self.repository.transport.add_connection(conn)
- def _revprops(self, message):
+ def _revprops(self, message, tags_dict=None):
"""Create a revprops dictionary.
Optionally sets bzr:skip to slightly optimize fetching of this revision later.
"""
- revprops = {properties.PROP_REVISION_LOG: message}
+ revprops = {properties.PROP_REVISION_LOG: message, }
if self.repository.transport.has_capability("commit-revprops"):
revprops[mapping.SVN_REVPROP_BZR_SKIP] = ""
+ if tags_dict is not None:
+ revprops[mapping.SVN_REVPROP_BZR_TAGS] = mapping.generate_tags_property(tags_dict)
return revprops
def lookup_tag(self, tag_name):
@@ -130,7 +138,8 @@
try:
if conn.check_path(urlutils.basename(path), self.repository.get_latest_revnum()) != core.NODE_DIR:
raise NoSuchTag(tag_name)
- ci = conn.get_commit_editor(self._revprops("Remove tag %s" % tag_name.encode("utf-8")))
+ ci = conn.get_commit_editor(self._revprops("Remove tag %s" % tag_name.encode("utf-8"),
+ {tag_name: ""}))
try:
root = ci.open_root()
root.delete_entry(urlutils.basename(path))
=== modified file 'tests/test_workingtree.py'
--- a/tests/test_workingtree.py 2008-08-30 20:17:37 +0000
+++ b/tests/test_workingtree.py 2008-08-30 21:11:14 +0000
@@ -22,7 +22,7 @@
from bzrlib.errors import NoSuchFile, OutOfDateTree
from bzrlib.inventory import Inventory
from bzrlib.osutils import has_symlinks, supports_executable
-from bzrlib.tests import KnownFailure, TestCase
+from bzrlib.tests import TestCase
from bzrlib.trace import mutter
from bzrlib.workingtree import WorkingTree
@@ -265,6 +265,7 @@
tree = WorkingTree.open("dc")
os.remove("dc/bl")
tree.revert(["bl"])
+ self.assertFalse(tree.changes_from(tree.basis_tree()).has_changed())
self.assertEqual("data", open('dc/bl').read())
def test_rename_one(self):
More information about the bazaar-commits
mailing list