Rev 436: Support setting the revision id on commits from lightweight checkouts. in file:///home/jelmer/bzr-svn/customrevids/
Jelmer Vernooij
jelmer at samba.org
Fri May 18 02:25:28 BST 2007
At file:///home/jelmer/bzr-svn/customrevids/
------------------------------------------------------------
revno: 436
revision-id: jelmer at samba.org-20070518012526-sm3mjnioq93ub9iq
parent: jelmer at samba.org-20070518004338-7iyyvupsj2en6tld
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Fri 2007-05-18 02:25:26 +0100
message:
Support setting the revision id on commits from lightweight checkouts.
modified:
checkout.py workingtree.py-20060306120941-b083cb0fdd4a69de
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
tests/test_commit.py test_commit.py-20060624213521-l5kcufywkh9mnilk-1
tests/test_push.py test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'checkout.py'
--- a/checkout.py 2007-05-17 19:04:30 +0000
+++ b/checkout.py 2007-05-18 01:25:26 +0000
@@ -33,6 +33,7 @@
from convert import SvnConverter
from repository import (SvnRepository, SVN_PROP_BZR_MERGE,
SVN_PROP_SVK_MERGE, SVN_PROP_BZR_FILEIDS,
+ SVN_PROP_BZR_REVISION_ID,
revision_id_to_svk_feature)
from revids import escape_svn_path
from scheme import BranchingScheme
@@ -408,7 +409,6 @@
# FIXME: Use strct
assert timestamp is None
assert timezone is None
- assert rev_id is None
if specific_files:
specific_files = [self.abspath(x).encode('utf8') for x in specific_files]
@@ -426,6 +426,15 @@
return message.encode("utf-8")
self.client_ctx.log_msg_baton2 = log_message_func
+ if rev_id is not None:
+ wc = self._get_wc(write_lock=True)
+ try:
+ svn.wc.prop_set(SVN_PROP_BZR_REVISION_ID,
+ self._get_bzr_revids() + rev_id + "\n",
+ self.basedir, wc)
+ finally:
+ svn.wc.adm_close(wc)
+
commit_info = svn.client.commit3(specific_files, True, False,
self.client_ctx)
self.client_ctx.log_msg_baton2 = None
@@ -535,6 +544,11 @@
return dict(map(lambda x: str(x).split("\t"),
existing[len(committed):].splitlines()))
+ def _get_bzr_revids(self):
+ return self.branch.repository.branchprop_list.get_property(
+ self.branch.branch_path, self.base_revnum,
+ SVN_PROP_BZR_REVISION_ID, "")
+
def _get_bzr_merges(self):
return self.branch.repository.branchprop_list.get_property(
self.branch.branch_path, self.base_revnum,
=== modified file 'commit.py'
--- a/commit.py 2007-05-17 19:04:30 +0000
+++ b/commit.py 2007-05-18 01:25:26 +0000
@@ -84,7 +84,7 @@
self._svnprops[SVN_PROP_SVK_MERGE] = old + new
if revision_id is not None:
- self._svnprops[SVN_PROP_BZR_REVISION_ID] = revision_id
+ self._svnprops[SVN_PROP_BZR_REVISION_ID] += "%s\n" % revision_id
# At least one of the parents has to be the last revision on the
# mainline in # Subversion.
=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py 2007-05-17 19:04:30 +0000
+++ b/tests/test_commit.py 2007-05-18 01:25:26 +0000
@@ -57,6 +57,20 @@
self.assertEqual(wt.branch.last_revision(), new_revision.revision_id)
self.assertEqual("data", new_revision.message)
+ def test_commit_rev_id(self):
+ self.make_client('d', 'dc')
+ self.build_tree({'dc/foo/bla': "data"})
+ self.client_add("dc/foo")
+ wt = self.open_checkout("dc")
+ revid = wt.commit(message="data", rev_id="some-revid-bla")
+ self.assertEqual("some-revid-bla", revid)
+ self.assertEqual(wt.branch.generate_revision_id(1), revid)
+ self.assertEqual(
+ wt.branch.generate_revision_id(1), wt.branch.last_revision())
+ new_revision = wt.branch.repository.get_revision(
+ wt.branch.last_revision())
+ self.assertEqual(wt.branch.last_revision(), new_revision.revision_id)
+
def test_commit_message_nordic(self):
self.make_client('d', 'dc')
self.build_tree({'dc/foo/bla': "data"})
=== modified file 'tests/test_push.py'
--- a/tests/test_push.py 2007-04-16 01:30:09 +0000
+++ b/tests/test_push.py 2007-05-18 01:25:26 +0000
@@ -24,7 +24,7 @@
import format
import checkout
import svn.core
-from repository import MAPPING_VERSION
+from repository import MAPPING_VERSION, SVN_PROP_BZR_REVISION_ID
from tests import TestCaseWithSubversionRepository
class TestPush(TestCaseWithSubversionRepository):
@@ -142,6 +142,16 @@
self.assertEqual("Commit from Bzr",
repos.get_revision(repos.generate_revision_id(2, "")).message)
+ def test_commit_set_revid(self):
+ self.build_tree({'dc/file': 'data'})
+ wt = self.bzrdir.open_workingtree()
+ wt.add('file')
+ wt.commit(message="Commit from Bzr", rev_id="some-rid")
+
+ self.client_update("sc")
+ self.assertEqual("some-rid\n",
+ self.client_get_prop("sc", SVN_PROP_BZR_REVISION_ID))
+
def test_multiple(self):
self.build_tree({'dc/file': 'data'})
wt = self.bzrdir.open_workingtree()
More information about the bazaar-commits
mailing list