Rev 769: Support optionally overriding svn:author and svn:date (#140001) in file:///data/jelmer/bzr-svn/override-svnrevprops/

Jelmer Vernooij jelmer at samba.org
Tue Oct 30 22:08:14 GMT 2007


At file:///data/jelmer/bzr-svn/override-svnrevprops/

------------------------------------------------------------
revno: 769
revision-id:jelmer at samba.org-20071030220813-pskwtn2uo3avbo78
parent: jelmer at samba.org-20071030211026-7o30l30uqivf1ei3
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: override-svnrevprops
timestamp: Tue 2007-10-30 23:08:13 +0100
message:
  Support optionally overriding svn:author and svn:date (#140001)
modified:
  FAQ                            faq-20070910195147-p9u38s9wplds2d4o-1
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  config.py                      config.py-20070624185721-0j8f1ly75uo4s1lk-1
  tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'FAQ'
--- a/FAQ	2007-10-25 22:47:09 +0000
+++ b/FAQ	2007-10-30 22:08:13 +0000
@@ -78,3 +78,14 @@
 0.3.x can not be used directly with 0.4.0 but will have to be upgraded to 
 work with 0.4.0 using the "bzr svn-upgrade" command. The bzr-rebase package 
 has to be installed for this command to work correctly.
+
+============================================================================
+Is it possible to keep the author name when pushing changes into Subversion?
+============================================================================
+Yes, but this requires the repository to allow revision property changes. 
+
+See hooks/pre-revprop-change in the Subversion repository for 
+more information about how to do this.
+
+You also need to enable support for this in bzr-svn by setting 
+pre-revprop-change to True in ~/.bazaar/bazaar.conf.

=== modified file 'NEWS'
--- a/NEWS	2007-10-29 22:34:05 +0000
+++ b/NEWS	2007-10-30 22:08:13 +0000
@@ -18,6 +18,8 @@
 
    * Clearer error when prefix is missing during push.
 
+   * Support optionally overriding svn:author and svn:date (#140001)
+
   INTERNALS
 
    * Handle NULL_REVISION in SvnRepository.copy_content(). Fixes compatibility 

=== modified file 'commit.py'
--- a/commit.py	2007-10-30 21:10:26 +0000
+++ b/commit.py	2007-10-30 22:08:13 +0000
@@ -16,7 +16,7 @@
 """Committing and pushing to Subversion repositories."""
 
 import svn.delta
-from svn.core import Pool, SubversionException
+from svn.core import Pool, SubversionException, svn_time_to_cstring
 
 from bzrlib import debug, osutils, urlutils
 from bzrlib.branch import Branch
@@ -54,18 +54,19 @@
     return []
 
 
-def set_svn_revprops(transport, revnum, date, author):
+def set_svn_revprops(transport, revnum, author, timestamp, timezone):
     """Attempt to change the revision properties on the
     specified revision.
 
     :param transport: SvnRaTransport connected to target repository
     :param revnum: Revision number of revision to change metadata of.
-    :param date: New date
     :param author: New author
+    :param timestamp: Timestamp
+    :param timezone: Timezone
     """
     revprops = {
         svn.core.SVN_PROP_REVISION_AUTHOR: author,
-        svn.core.SVN_PROP_REVISION_DATE: date
+        svn.core.SVN_PROP_REVISION_DATE: svn_time_to_cstring(1000000*(timestamp+timezone))
     }
     for (name, value) in revprops.items():
         try:
@@ -514,6 +515,11 @@
         self.mutter('commit %d finished. author: %r, date: %r, revid: %r' % 
                (self.revnum, self.author, self.date, revid))
 
+        if self.repository.get_config().get_override_svn_revprops():
+            set_svn_revprops(self.repository.transport, 
+                             self.revnum, self._committer, 
+                             self._timestamp, self._timezone)
+
         return revid
 
     def _record_file_id(self, ie, path):

=== modified file 'config.py'
--- a/config.py	2007-10-30 20:03:43 +0000
+++ b/config.py	2007-10-30 22:08:13 +0000
@@ -61,7 +61,10 @@
 
         :return: BranchingScheme instance.
         """
-        return BranchingScheme.find_scheme(self._get_user_option("branching-scheme", use_global=False))
+        schemename = self._get_user_option("branching-scheme", use_global=False)
+        if schemename is not None:
+            return BranchingScheme.find_scheme(schemename)
+        return None
 
     def get_override_svn_revprops(self):
         """Check whether or not bzr-svn should attempt to override Subversion revision 

=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py	2007-10-30 21:10:26 +0000
+++ b/tests/test_commit.py	2007-10-30 22:08:13 +0000
@@ -557,9 +557,9 @@
         self.client_commit("dc", "My commit")
 
         transport = SvnRaTransport(repos_url)
-        set_svn_revprops(transport, 1, "2007-11-11", "Somebody")
+        set_svn_revprops(transport, 1, "Somebody", 473382000, 3600)
 
-        self.assertEquals(("Somebody", "2007-11-11", "My commit"), 
+        self.assertEquals(("Somebody", "1985-01-01T00:00:00.000000Z", "My commit"), 
                           self.client_log("dc")[1][1:])
 
     def test_change_revprops_disallowed(self):
@@ -570,4 +570,4 @@
 
         transport = SvnRaTransport(repos_url)
         self.assertRaises(RevpropChangeFailed, 
-            lambda: set_svn_revprops(transport, 1, "2007-11-11", "Somebody"))
+            lambda: set_svn_revprops(transport, 1, "Somebody", 473382000, 3600))

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2007-10-29 22:34:05 +0000
+++ b/tests/test_push.py	2007-10-30 22:08:13 +0000
@@ -120,6 +120,18 @@
         self.assertEqual(repos.generate_revision_id(2, "", "none"),
                         self.svndir.open_branch().last_revision())
 
+    def test_override_revprops(self):
+        self.svndir.find_repository().get_config().set_user_option("override-svn-revprops", "True")
+        self.build_tree({'dc/file': 'data'})
+        wt = self.bzrdir.open_workingtree()
+        wt.add('file')
+        wt.commit(message="Commit from Bzr", committer="Sombody famous", timestamp=1012604400, timezone=0)
+
+        self.svndir.open_branch().pull(self.bzrdir.open_branch())
+
+        self.assertEquals(("Sombody famous", "2002-02-01T23:00:00.000000Z", "Commit from Bzr"), 
+            self.client_log(self.repos_url)[2][1:])
+
     def test_empty_file(self):
         self.build_tree({'dc/file': ''})
         wt = self.bzrdir.open_workingtree()




More information about the bazaar-commits mailing list