Rev 1756: Add --svn-override-revprops option to svn-push. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Tue Nov 11 01:28:52 GMT 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1756
revision-id: jelmer at samba.org-20081111012849-zu9ag87ue40b5zhe
parent: jelmer at samba.org-20081110142037-1b7gvx1zq21buceu
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Tue 2008-11-11 02:28:49 +0100
message:
  Add --svn-override-revprops option to svn-push.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  remote.py                      format.py-20060406233823-b6fa009fe35dfde7
=== modified file 'NEWS'
--- a/NEWS	2008-11-10 14:20:37 +0000
+++ b/NEWS	2008-11-11 01:28:49 +0000
@@ -5,6 +5,8 @@
    * Don't print backtrace when error occurs while accessing repository root.
      (#296224)
 
+   * Add --svn-override-revprops option to svn-push.
+
 bzr-svn 0.4.15	2008-11-10
 
   BUG FIXES

=== modified file '__init__.py'
--- a/__init__.py	2008-11-10 02:11:54 +0000
+++ b/__init__.py	2008-11-11 01:28:49 +0000
@@ -359,10 +359,13 @@
             short_name='d',
             type=unicode,
             ),
-            Option("merged", help="Push merged (right hand side) revisions.")]
+            Option("merged", help="Push merged (right hand side) revisions."),
+            Option("svn-override-revprops", type=str, 
+                help="Comma-separated list of svn properties to override (date/author)")
+            ]
 
     def run(self, location=None, revision=None, remember=False, 
-            directory=None, merged=None):
+            directory=None, merged=None, svn_override_revprops=None):
         from bzrlib.bzrdir import BzrDir
         from bzrlib.branch import Branch
         from bzrlib.errors import NotBranchError, BzrCommandError
@@ -381,6 +384,14 @@
                 self.outf.write("Using saved location: %s\n" % display_url)
                 location = stored_loc
 
+        if svn_override_revprops is not None:
+            override_svn_revprops = svn_override_revprops.split(",")
+            if len(set(override_svn_revprops).difference(set(["author", "date"]))) > 0:
+                raise BzrCommandError("Can only override 'author' and 'date' revision properties")
+            override_svn_revprops = [("svn:" + v) for v in override_svn_revprops]
+        else:
+            override_svn_revprops = None
+
         source_branch.lock_read()
         try:
             bzrdir = BzrDir.open(location)
@@ -396,11 +407,13 @@
                 target_branch = bzrdir.open_branch()
                 target_branch.lock_write()
                 try:
-                    target_branch.pull(source_branch, stop_revision=revision_id, _push_merged=merged)
+                    target_branch.pull(source_branch, stop_revision=revision_id, _push_merged=merged,
+                                       _override_svn_revprops=override_svn_revprops)
                 finally:
                     target_branch.unlock()
             except NotBranchError:
-                target_branch = bzrdir.import_branch(source_branch, revision_id, _push_merged=merged)
+                target_branch = bzrdir.import_branch(source_branch, revision_id, _push_merged=merged,
+                                       _override_svn_revprops=override_svn_revprops)
         finally:
             source_branch.unlock()
         # We successfully created the target, remember it

=== modified file 'branch.py'
--- a/branch.py	2008-08-25 02:03:39 +0000
+++ b/branch.py	2008-11-11 01:28:49 +0000
@@ -353,7 +353,8 @@
         return self.generate_revision_id(self.get_revnum())
 
     def pull(self, source, overwrite=False, stop_revision=None, 
-             _hook_master=None, run_hooks=True, _push_merged=None):
+             _hook_master=None, run_hooks=True, _push_merged=None,
+             _override_svn_revprops=None):
         """See Branch.pull()."""
         result = PullResult()
         result.source_branch = source
@@ -363,7 +364,8 @@
         try:
             (result.old_revno, result.old_revid) = self.last_revision_info()
             self.update_revisions(source, stop_revision, overwrite, 
-                                  _push_merged=_push_merged)
+                                  _push_merged=_push_merged,
+                                  _override_svn_revprops=_override_svn_revprops)
             result.tag_conflicts = source.tags.merge_to(self.tags, overwrite)
             (result.new_revno, result.new_revid) = self.last_revision_info()
             return result
@@ -402,7 +404,8 @@
         destination.set_last_revision_info(revno, revision_id)
 
     def update_revisions(self, other, stop_revision=None, overwrite=False, 
-                         graph=None, _push_merged=False):
+                         graph=None, _push_merged=False, 
+                         _override_svn_revprops=None):
         """See Branch.update_revisions()."""
         if stop_revision is None:
             stop_revision = ensure_null(other.last_revision())
@@ -427,10 +430,10 @@
         if _push_merged is None:
             _push_merged = self.layout.push_merged_revisions(self.project)
         self._push_missing_revisions(graph, other, other_graph, todo, 
-                                     _push_merged)
+                                     _push_merged, _override_svn_revprops)
 
     def _push_missing_revisions(self, my_graph, other, other_graph, todo, 
-                                push_merged=False):
+                                push_merged=False, _override_svn_revprops=None):
         pb = ui.ui_factory.nested_progress_bar()
         try:
             for revid in todo:
@@ -439,7 +442,7 @@
                 if push_merged:
                     parent_revids = other_graph.get_parent_map([revid])[revid]
                     push_ancestors(self.repository, other.repository, self.layout, self.project, parent_revids, other_graph)
-                push(my_graph, self, other.repository, revid)
+                push(my_graph, self, other.repository, revid, override_svn_revprops=_override_svn_revprops)
                 self._clear_cached_state()
         finally:
             pb.finished()

=== modified file 'commit.py'
--- a/commit.py	2008-11-08 20:02:02 +0000
+++ b/commit.py	2008-11-11 01:28:49 +0000
@@ -132,7 +132,8 @@
     def __init__(self, repository, branch, parents, config, timestamp, 
                  timezone, committer, revprops, revision_id, old_inv=None,
                  push_metadata=True,
-                 graph=None, texts=None):
+                 graph=None, texts=None, 
+                 override_svn_revprops=None):
         """Instantiate a new SvnCommitBuilder.
 
         :param repository: SvnRepository to commit to.
@@ -156,6 +157,11 @@
         self._text_parents = {}
         self._texts = texts
 
+        if override_svn_revprops is None:
+            self._override_svn_revprops = self._config.get_override_svn_revprops()
+        else:
+            self._override_svn_revprops = override_svn_revprops
+
         # Gather information about revision on top of which the commit is 
         # happening
         if parents == []:
@@ -567,12 +573,11 @@
                result_revision, result_author, 
                    result_date, revid)
 
-        override_svn_revprops = self._config.get_override_svn_revprops()
-        if override_svn_revprops is not None:
+        if self._override_svn_revprops is not None:
             new_revprops = {}
-            if properties.PROP_REVISION_AUTHOR in override_svn_revprops:
+            if properties.PROP_REVISION_AUTHOR in self._override_svn_revprops:
                 new_revprops[properties.PROP_REVISION_AUTHOR] = self._committer.encode("utf-8")
-            if properties.PROP_REVISION_DATE in override_svn_revprops:
+            if properties.PROP_REVISION_DATE in self._override_svn_revprops:
                 new_revprops[properties.PROP_REVISION_DATE] = properties.time_to_cstring(1000000*self._timestamp)
             set_svn_revprops(self.repository.transport, result_revision, new_revprops)
 
@@ -651,7 +656,7 @@
 
 
 def push_new(target_repository, target_branch_path, source, stop_revision,
-             push_metadata=True):
+             push_metadata=True, override_svn_revprops=None):
     """Push a revision into Subversion, creating a new branch.
 
     This will do a new commit in the target branch.
@@ -713,7 +718,7 @@
                 revnum, self.get_branch_path(revnum), 
                 self.repository.get_mapping())
 
-    push(target_repository.get_graph(), ImaginaryBranch(target_repository), source, start_revid, push_metadata=push_metadata)
+    push(target_repository.get_graph(), ImaginaryBranch(target_repository), source, start_revid, push_metadata=push_metadata, override_svn_revprops=override_svn_revprops)
 
 
 def dpush(target, source, stop_revision=None):
@@ -757,7 +762,8 @@
 
 
 def push_revision_tree(graph, target, config, source_repo, base_revid, 
-                       revision_id, rev, push_metadata=True):
+                       revision_id, rev, push_metadata=True,
+                       override_svn_revprops=None):
     old_tree = source_repo.revision_tree(revision_id)
     base_tree = source_repo.revision_tree(base_revid)
 
@@ -773,7 +779,8 @@
                                revision_id, base_tree.inventory, 
                                push_metadata=push_metadata,
                                graph=graph,
-                               texts=source_repo.texts)
+                               texts=source_repo.texts,
+                               override_svn_revprops=override_svn_revprops)
                          
     replay_delta(builder, base_tree, old_tree)
     try:
@@ -791,7 +798,8 @@
     return revid
 
 
-def push(graph, target, source_repo, revision_id, push_metadata=True):
+def push(graph, target, source_repo, revision_id, push_metadata=True, 
+         override_svn_revprops=None):
     """Push a revision into Subversion.
 
     This will do a new commit in the target branch.
@@ -799,6 +807,7 @@
     :param target: Branch to push to
     :param source_repo: Branch to pull the revision from
     :param revision_id: Revision id of the revision to push
+    :param override_svn_revprops: List of Subversion revision properties to override
     :return: revision id of revision that was pushed
     """
     assert isinstance(source_repo, Repository)
@@ -818,7 +827,8 @@
     try:
         revid = push_revision_tree(graph, target, target.get_config(), 
                                    source_repo, base_revid, revision_id, 
-                                   rev, push_metadata=push_metadata)
+                                   rev, push_metadata=push_metadata,
+                                   override_svn_revprops=override_svn_revprops)
     finally:
         source_repo.unlock()
 

=== modified file 'remote.py'
--- a/remote.py	2008-10-10 18:02:22 +0000
+++ b/remote.py	2008-11-11 01:28:49 +0000
@@ -118,7 +118,8 @@
             format = BzrDirFormat.get_default_format()
         return not isinstance(self._format, format.__class__)
 
-    def import_branch(self, source, stop_revision=None, _push_merged=None):
+    def import_branch(self, source, stop_revision=None, _push_merged=None,
+                      _override_svn_revprops=None):
         """Create a new branch in this repository, possibly 
         with the specified history, optionally importing revisions.
         
@@ -140,14 +141,15 @@
                 if repos.transport.check_path(target_branch_path,
                     repos.get_latest_revnum()) != core.NODE_NONE:
                     raise AlreadyBranchError(full_branch_url)
-                push_new(repos, target_branch_path, source.repository, stop_revision)
+                push_new(repos, target_branch_path, source.repository, stop_revision,
+                         override_svn_revprops=_override_svn_revprops)
             finally:
                 repos.unlock()
             branch = self.open_branch()
             branch.lock_write()
             try:
                 branch.pull(source, stop_revision=stop_revision, 
-                            _push_merged=_push_merged)
+                            _push_merged=_push_merged, _override_svn_revprops=_override_svn_revprops)
             finally:
                 branch.unlock()
         finally:




More information about the bazaar-commits mailing list