Rev 1637: Add --merged option to svn-push. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sun Aug 24 16:53:12 BST 2008


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

------------------------------------------------------------
revno: 1637
revision-id: jelmer at samba.org-20080824155305-l6kvu47fsucqzn2z
parent: jelmer at samba.org-20080824152946-bk9de0aqgckgjdrt
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-08-24 17:53:05 +0200
message:
  Add --merged option to svn-push.
modified:
  __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 '__init__.py'
--- a/__init__.py	2008-08-23 14:55:24 +0000
+++ b/__init__.py	2008-08-24 15:53:05 +0000
@@ -376,10 +376,11 @@
                  'rather than the one containing the working directory.',
             short_name='d',
             type=unicode,
-            )]
+            ),
+            Option("merged", help="Push merged (right hand side) revisions.")]
 
     def run(self, location=None, revision=None, remember=False, 
-            directory=None):
+            directory=None, merged=None):
         from bzrlib.bzrdir import BzrDir
         from bzrlib.branch import Branch
         from bzrlib.errors import NotBranchError, BzrCommandError
@@ -413,11 +414,11 @@
                 target_branch = bzrdir.open_branch()
                 target_branch.lock_write()
                 try:
-                    target_branch.pull(source_branch, stop_revision=revision_id)
+                    target_branch.pull(source_branch, stop_revision=revision_id, _push_merged=merged)
                 finally:
                     target_branch.unlock()
             except NotBranchError:
-                target_branch = bzrdir.import_branch(source_branch, revision_id)
+                target_branch = bzrdir.import_branch(source_branch, revision_id, _push_merged=merged)
             # We successfully created the target, remember it
             if source_branch.get_push_location() is None or remember:
                 source_branch.set_push_location(target_branch.base)

=== modified file 'branch.py'
--- a/branch.py	2008-08-23 14:55:24 +0000
+++ b/branch.py	2008-08-24 15:53:05 +0000
@@ -352,7 +352,7 @@
         return self.generate_revision_id(self.get_revnum())
 
     def pull(self, source, overwrite=False, stop_revision=None, 
-             _hook_master=None, run_hooks=True):
+             _hook_master=None, run_hooks=True, _push_merged=None):
         """See Branch.pull()."""
         result = PullResult()
         result.source_branch = source
@@ -361,7 +361,8 @@
         source.lock_read()
         try:
             (result.old_revno, result.old_revid) = self.last_revision_info()
-            self.update_revisions(source, stop_revision, overwrite)
+            self.update_revisions(source, stop_revision, overwrite, 
+                                  _push_merged=_push_merged)
             result.tag_conflicts = source.tags.merge_to(self.tags, overwrite)
             (result.new_revno, result.new_revid) = self.last_revision_info()
             return result
@@ -400,7 +401,7 @@
         destination.set_last_revision_info(revno, revision_id)
 
     def update_revisions(self, other, stop_revision=None, overwrite=False, 
-                         graph=None):
+                         graph=None, _push_merged=False):
         """See Branch.update_revisions()."""
         if stop_revision is None:
             stop_revision = ensure_null(other.last_revision())
@@ -421,10 +422,11 @@
             todo = self.otherline_missing_revisions(other, stop_revision, overwrite)
         if todo is None:
             raise DivergedBranches(self, other)
-        self._push_missing_revisions(other, todo)
+        if _push_merged is None:
+            _push_merged = self.layout.push_merged_revisions(self.project)
+        self._push_missing_revisions(other, todo, _push_merged)
 
-    def _push_missing_revisions(self, other, todo):
-        push_merged = self.layout.push_merged_revisions(self.project)
+    def _push_missing_revisions(self, other, todo, push_merged=False):
         if push_merged:
             graph = other.repository.get_graph()
         pb = ui.ui_factory.nested_progress_bar()

=== modified file 'commit.py'
--- a/commit.py	2008-08-24 15:22:40 +0000
+++ b/commit.py	2008-08-24 15:53:05 +0000
@@ -487,40 +487,43 @@
                     warning("Setting property %r with invalid characters in name", prop)
             self.editor = self.repository.transport.get_commit_editor(
                     self._svn_revprops, done, None, False)
-
-            root = self.editor.open_root(self.base_revnum)
-
-            replace_existing = False
-            # See whether the base of the commit matches the lhs parent
-            # if not, we need to replace the existing directory
-            if len(bp_parts) == len(existing_bp_parts):
-                if self.base_path is None or self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
-                    replace_existing = True
-                elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum):
-                    replace_existing = True
-
-            if replace_existing and self.branch._get_append_revisions_only():
-                raise AppendRevisionsOnlyViolation(self.branch.base)
-
-            # TODO: Accept create_prefix argument
-            branch_editors = self.open_branch_editors(root, bp_parts,
-                existing_bp_parts, self.base_path, self.base_revnum, 
-                replace_existing)
-
-            self._dir_process("", self.new_inventory.root.file_id, 
-                branch_editors[-1])
-
-            # Set all the revprops
-            if self.push_metadata:
-                for prop, value in self._svnprops.items():
-                    if not properties.is_valid_property_name(prop):
-                        warning("Setting property %r with invalid characters in name", prop)
-                    assert isinstance(value, str)
-                    branch_editors[-1].change_prop(prop, value)
-                    self.mutter("Setting root file property %r -> %r", prop, value)
-
-            for dir_editor in reversed(branch_editors):
-                dir_editor.close()
+            try:
+                root = self.editor.open_root(self.base_revnum)
+
+                replace_existing = False
+                # See whether the base of the commit matches the lhs parent
+                # if not, we need to replace the existing directory
+                if len(bp_parts) == len(existing_bp_parts):
+                    if self.base_path is None or self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
+                        replace_existing = True
+                    elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum):
+                        replace_existing = True
+
+                if replace_existing and self.branch._get_append_revisions_only():
+                    raise AppendRevisionsOnlyViolation(self.branch.base)
+
+                # TODO: Accept create_prefix argument
+                branch_editors = self.open_branch_editors(root, bp_parts,
+                    existing_bp_parts, self.base_path, self.base_revnum, 
+                    replace_existing)
+
+                self._dir_process("", self.new_inventory.root.file_id, 
+                    branch_editors[-1])
+
+                # Set all the revprops
+                if self.push_metadata:
+                    for prop, value in self._svnprops.items():
+                        if not properties.is_valid_property_name(prop):
+                            warning("Setting property %r with invalid characters in name", prop)
+                        assert isinstance(value, str)
+                        branch_editors[-1].change_prop(prop, value)
+                        self.mutter("Setting root file property %r -> %r", prop, value)
+
+                for dir_editor in reversed(branch_editors):
+                    dir_editor.close()
+            except:
+                self.editor.abort()
+                raise
 
             self.editor.close()
         finally:

=== modified file 'remote.py'
--- a/remote.py	2008-08-23 14:55:24 +0000
+++ b/remote.py	2008-08-24 15:53:05 +0000
@@ -115,7 +115,7 @@
             format = BzrDirFormat.get_default_format()
         return not isinstance(self._format, format.__class__)
 
-    def import_branch(self, source, stop_revision=None):
+    def import_branch(self, source, stop_revision=None, _push_merged=None):
         """Create a new branch in this repository, possibly 
         with the specified history, optionally importing revisions.
         
@@ -143,7 +143,8 @@
             branch = self.open_branch()
             branch.lock_write()
             try:
-                branch.pull(source, stop_revision=stop_revision)
+                branch.pull(source, stop_revision=stop_revision, 
+                            _push_merged=_push_merged)
             finally:
                 branch.unlock()
         finally:




More information about the bazaar-commits mailing list