Rev 1373: Merge support for the dpush command. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4

Jelmer Vernooij jelmer at samba.org
Sun Jun 29 03:17:32 BST 2008


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

------------------------------------------------------------
revno: 1373
revision-id: jelmer at samba.org-20080629021727-f39qtwzn14jqonqm
parent: jelmer at samba.org-20080628185557-wqhpawbqrd3041n6
parent: jelmer at samba.org-20080629021407-vd1li8qqhku9jsa1
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-06-29 04:17:27 +0200
message:
  Merge support for the dpush command.
modified:
  FAQ                            faq-20070910195147-p9u38s9wplds2d4o-1
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  tests/test_blackbox.py         test_blackbox.py-20070325150839-d10llf8arptpcfl6-1
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
    ------------------------------------------------------------
    revno: 1177.1.13
    revision-id: jelmer at samba.org-20080629021407-vd1li8qqhku9jsa1
    parent: jelmer at samba.org-20080629014306-shgxutyy3rtrrls8
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-06-29 04:14:07 +0200
    message:
      Add known failure handling existing data in tree.
    modified:
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      tests/test_blackbox.py         test_blackbox.py-20070325150839-d10llf8arptpcfl6-1
    ------------------------------------------------------------
    revno: 1177.1.12
    revision-id: jelmer at samba.org-20080629014306-shgxutyy3rtrrls8
    parent: jelmer at samba.org-20080629013804-dfkyd0zksxngb1b3
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-06-29 03:43:06 +0200
    message:
      Clarify FAQ about dpush.
    modified:
      FAQ                            faq-20070910195147-p9u38s9wplds2d4o-1
    ------------------------------------------------------------
    revno: 1177.1.11
    revision-id: jelmer at samba.org-20080629013804-dfkyd0zksxngb1b3
    parent: jelmer at samba.org-20080629010425-a4iyg0fm6zr0iw2f
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-06-29 03:38:04 +0200
    message:
      Rename svn-dpush -> dpush.
    modified:
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      tests/test_blackbox.py         test_blackbox.py-20070325150839-d10llf8arptpcfl6-1
    ------------------------------------------------------------
    revno: 1177.1.10
    revision-id: jelmer at samba.org-20080629010425-a4iyg0fm6zr0iw2f
    parent: jelmer at samba.org-20080629003329-4at2clmy70o8t2n4
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-06-29 03:04:25 +0200
    message:
      Rebase after dpush.
    modified:
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
    ------------------------------------------------------------
    revno: 1177.1.9
    revision-id: jelmer at samba.org-20080629003329-4at2clmy70o8t2n4
    parent: jelmer at samba.org-20080628234728-sg6urj2iqxraiiik
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-06-29 02:33:29 +0200
    message:
      make dpush test pass.
    modified:
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
      tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
    ------------------------------------------------------------
    revno: 1177.1.8
    revision-id: jelmer at samba.org-20080628234728-sg6urj2iqxraiiik
    parent: jelmer at samba.org-20080628173931-gpuo7fj9xcog50ou
    parent: jelmer at samba.org-20080628185557-wqhpawbqrd3041n6
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-06-29 01:47:28 +0200
    message:
      Merge 0.4.
    modified:
      NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
      README                         README-20051120210643-bd274a2fef9aed6a
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
    ------------------------------------------------------------
    revno: 1177.1.7
    revision-id: jelmer at samba.org-20080628173931-gpuo7fj9xcog50ou
    parent: jelmer at samba.org-20080628160151-9f1e1vb6h0v9uc1w
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sat 2008-06-28 19:39:31 +0200
    message:
      Add test for dpush.
    modified:
      tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
    ------------------------------------------------------------
    revno: 1177.1.6
    revision-id: jelmer at samba.org-20080628160151-9f1e1vb6h0v9uc1w
    parent: jelmer at samba.org-20080627182306-m9y3ybcg2d3n6mye
    parent: jelmer at samba.org-20080628123728-0lqgtvhe8424ha8j
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sat 2008-06-28 18:01:51 +0200
    message:
      Merge 0.4.
    modified:
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
      ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
      tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
      tests/test_tree.py             test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
      tests/test_versionedfiles.py   test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
      transport.py                   transport.py-20060406231150-b3472d06b3a0818d
      versionedfiles.py              versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
    ------------------------------------------------------------
    revno: 1177.1.5
    revision-id: jelmer at samba.org-20080627182306-m9y3ybcg2d3n6mye
    parent: jelmer at samba.org-20080627182218-sqztv3rh81n0wu71
    parent: jelmer at samba.org-20080627162804-xxfjk30jfb53ilvb
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Fri 2008-06-27 20:23:06 +0200
    message:
      Merge 0.4.
    removed:
      core.py                        core.py-20080615010310-67lnibnp889hlarb-1
      delta.py                       delta.py-20080617225125-jeg43afui0czkuwk-1
      ra.py                          ra.py-20080615005305-t5221niknu8rm6bt-1
    added:
      client.c                       client.pyx-20080313235339-wbyjbw2namuiql8f-1
      core.py                        core.pyx-20080313210413-17k59slolpfe5kdq-1
      delta.py                       delta.py-20080316001917-xyng7m3jlxvdc4c9-1
      editor.c                       editor.c-20080602191336-frj7az1sdk13o1tw-1
      editor.h                       editor.h-20080602191336-frj7az1sdk13o1tw-2
      ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
      ra.h                           ra.h-20080621214350-wlaxxs087eiu02me-1
      repos.c                        repos.pyx-20080314114432-g2b5lqe776tkbl4k-1
      tests/test_client.py           test_client.py-20080603021344-lmgexez0yoyp9b1s-1
      tests/test_core.py             test_core.py-20080603032119-q91zmret1lv84ay9-1
      tests/test_ra.py               test_ra.py-20080313141743-uzsm7ejitrlqone5-1
      tests/test_repos.py            test_repos.py-20080603030558-86ewiakm2z5y9x29-1
      tests/test_versionedfiles.py   test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
      tests/test_wc.py               test_wc.py-20080313142315-woibd1cdv4s2lr7o-1
      util.c                         util.c-20080531154025-s8ef6ej9tytsnkkw-1
      util.h                         util.h-20080531154025-s8ef6ej9tytsnkkw-2
      versionedfiles.py              versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
      wc.c                           wc.pyx-20080313142018-10l8l23vha2j9e6b-1
      wc.h                           wc.h-20080622050149-ir7xe34a497adbmp-1
    renamed:
      tests/test_repos.py => tests/test_repository.py test_repos.py-20060508151940-ddc49a59257ca712
    modified:
      AUTHORS                        AUTHORS-20060508114718-4c90c0062645106d
      FAQ                            faq-20070910195147-p9u38s9wplds2d4o-1
      Makefile                       makefile.other-20080311181537-5svhje3v1flh1n4f-1
      NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
      README                         README-20051120210643-bd274a2fef9aed6a
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      auth.py                        auth.py-20071209174622-w8d42k6nm5yhxvi8-1
      branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
      convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
      errors.py                      errors.py-20061226172623-w1sbj8ynpo0eojqp-1
      fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
      fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
      format.py                      format.py-20070917005147-94kb7zysotf82kqw-1
      layout.py                      layout.py-20080323165407-y9qw8nx4oykvoe1k-1
      logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
      mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
      mapping3/__init__.py           __init__.py-20080502174630-9324zh25kka98vlw-1
      properties.py                  util.py-20080502170127-o220e9py99vt69s6-1
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
      revspec.py                     revspec.py-20071106211507-q4fz2en91yrmjjl8-1
      setup.py                       setup.py-20060502115218-86950492da22353f
      tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
      tests/test_blackbox.py         test_blackbox.py-20070325150839-d10llf8arptpcfl6-1
      tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
      tests/test_branchprops.py      test_branchprops.py-20061223210444-04xf5224zcg69m3w-1
      tests/test_checkout.py         test_checkout.py-20070101154110-eevkc29qj0q7udz5-1
      tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
      tests/test_convert.py          test_convert.py-20060705203611-b1l0bapeku6foco0-1
      tests/test_errors.py           test_errors.py-20070129114605-ban03f32t6ja14ez-1
      tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
      tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
      tests/test_logwalker.py        test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
      tests/test_mapping.py          test_mapping.py-20080201131338-0zd86eznn4bojtee-1
      tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
      tests/test_radir.py            test_radir.py-20061231173434-31utf9o4byu7wktm-1
      tests/test_revspec.py          test_revspec.py-20071111183646-0wohlrzaevdsr9ia-1
      tests/test_transport.py        test_transport.py-20060621232111-xh7xvoblzsrgj79t-1
      tests/test_tree.py             test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
      tests/test_upgrade.py          test_upgrade.py-20070106170128-64zt3eqggg4tng1c-1
      tests/test_workingtree.py      test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
      transport.py                   transport.py-20060406231150-b3472d06b3a0818d
      tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
      workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
      tests/test_repository.py       test_repos.py-20060508151940-ddc49a59257ca712
    ------------------------------------------------------------
    revno: 1177.1.4
    revision-id: jelmer at samba.org-20080627182218-sqztv3rh81n0wu71
    parent: jelmer at samba.org-20080618103600-tqvgxu8pcz7a2rsj
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Fri 2008-06-27 20:22:18 +0200
    message:
      Add news entry about dpush.
    modified:
      NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
    ------------------------------------------------------------
    revno: 1177.1.3
    revision-id: jelmer at samba.org-20080618103600-tqvgxu8pcz7a2rsj
    parent: jelmer at samba.org-20080518151321-r03ep6pq0zo612kx
    parent: jelmer at samba.org-20080617225233-2b79ggobt2sc0qet
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Wed 2008-06-18 12:36:00 +0200
    message:
      Merg e0.4.
    added:
      core.py                        core.py-20080615010310-67lnibnp889hlarb-1
      delta.py                       delta.py-20080617225125-jeg43afui0czkuwk-1
      ra.py                          ra.py-20080615005305-t5221niknu8rm6bt-1
      tests/test_changes.py          test_changes.py-20080529111734-f7fbshmnlgnvue45-1
    renamed:
      util.py => properties.py util.py-20080502170127-o220e9py99vt69s6-1
    modified:
      AUTHORS                        AUTHORS-20060508114718-4c90c0062645106d
      FAQ                            faq-20070910195147-p9u38s9wplds2d4o-1
      Makefile                       makefile.other-20080311181537-5svhje3v1flh1n4f-1
      NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
      auth.py                        auth.py-20071209174622-w8d42k6nm5yhxvi8-1
      branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
      branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
      cache.py                       cache.py-20070520185908-qbtlcet08bllgs0f-1
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
      config.py                      config.py-20070624185721-0j8f1ly75uo4s1lk-1
      convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
      errors.py                      errors.py-20061226172623-w1sbj8ynpo0eojqp-1
      fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
      fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
      format.py                      format.py-20070917005147-94kb7zysotf82kqw-1
      logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
      mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
      mapping3/__init__.py           __init__.py-20080502174630-9324zh25kka98vlw-1
      mapping3/scheme.py             scheme.py-20060516195850-95181aae6b272f9e
      parents.py                     parents.py-20080505192113-5rcif033d6wcam9w-1
      remote.py                      format.py-20060406233823-b6fa009fe35dfde7
      repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
      revids.py                      revids.py-20070416220458-36vfa0730cchevp1-1
      svk.py                         svk.py-20080201171509-m2eg9m6jrmlbwxg5-1
      tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
      tests/test_blackbox.py         test_blackbox.py-20070325150839-d10llf8arptpcfl6-1
      tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
      tests/test_branchprops.py      test_branchprops.py-20061223210444-04xf5224zcg69m3w-1
      tests/test_checkout.py         test_checkout.py-20070101154110-eevkc29qj0q7udz5-1
      tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
      tests/test_config.py           test_config.py-20070624193244-itvnst60evjidr4z-1
      tests/test_convert.py          test_convert.py-20060705203611-b1l0bapeku6foco0-1
      tests/test_errors.py           test_errors.py-20070129114605-ban03f32t6ja14ez-1
      tests/test_fetch.py            test_fetch.py-20070624210302-luvgwjmlfysk5qeq-1
      tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
      tests/test_logwalker.py        test_logwalker.py-20060622141944-pkocc3rj8g62ukbi-1
      tests/test_mapping.py          test_mapping.py-20080201131338-0zd86eznn4bojtee-1
      tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
      tests/test_radir.py            test_radir.py-20061231173434-31utf9o4byu7wktm-1
      tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
      tests/test_revids.py           test_revids.py-20070516230044-d7x872cqi7xb4eow-1
      tests/test_revspec.py          test_revspec.py-20071111183646-0wohlrzaevdsr9ia-1
      tests/test_scheme.py           test_scheme.py-20060621221855-va2xabhlxpmc9llx-1
      tests/test_svk.py              test_svk.py-20080201164711-h6p64zcglxpvygu2-1
      tests/test_transport.py        test_transport.py-20060621232111-xh7xvoblzsrgj79t-1
      tests/test_tree.py             test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
      tests/test_upgrade.py          test_upgrade.py-20070106170128-64zt3eqggg4tng1c-1
      tests/test_workingtree.py      test_workingtree.py-20060622191524-0di7bc3q1ckdbybb-1
      transport.py                   transport.py-20060406231150-b3472d06b3a0818d
      tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
      upgrade.py                     upgrade.py-20070106192108-0rakplee2lzah4gs-1
      workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
      properties.py                  util.py-20080502170127-o220e9py99vt69s6-1
    ------------------------------------------------------------
    revno: 1177.1.2
    revision-id: jelmer at samba.org-20080518151321-r03ep6pq0zo612kx
    parent: jelmer at samba.org-20080518151307-fb8e3741x1ws4lbs
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-05-18 17:13:21 +0200
    message:
      Add dpush command.
    modified:
      __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
    ------------------------------------------------------------
    revno: 1177.1.1
    revision-id: jelmer at samba.org-20080518151307-fb8e3741x1ws4lbs
    parent: jelmer at samba.org-20080518144548-qbrs13zqud2epllq
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: dpush
    timestamp: Sun 2008-05-18 17:13:07 +0200
    message:
      Initial work supporting pushing without metadata.
    modified:
      commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
=== modified file 'FAQ'
--- a/FAQ	2008-06-22 08:09:10 +0000
+++ b/FAQ	2008-06-29 01:43:06 +0000
@@ -116,9 +116,12 @@
 you're pushing. These properties are used for storing Bazaar metadata that 
 can not be losslessly mapped to existing Subversion metadata. 
 
-It would be possible to support pushing changes to Subversion without
-setting that metadata but then the revision created in Subversion
-would actually be a different one than in your local branch. 
+It is possible to push changes to Subversion without
+setting that metadata by using the ``bzr dpush`` command. 
+Since revisions created in Subversion this way are actually (slightly) different 
+from the matching revisions in the local branch, it is necessary for the dpush command 
+to rebase your branch to the remote branch after pushing.
+
 You would get a DivergedBranches error when pulling from a svn branch you have 
 just pushed to. 
 

=== modified file 'NEWS'
--- a/NEWS	2008-06-28 16:07:23 +0000
+++ b/NEWS	2008-06-28 23:47:28 +0000
@@ -22,6 +22,10 @@
 
    * Basic support for stacked branches.
 
+  FEATURES
+  
+   * Add new "dpush" command that works similar to git-svn's dcommit.
+
   BUG FIXES
 
    * More efficient use of mutter.

=== modified file '__init__.py'
--- a/__init__.py	2008-06-28 18:55:57 +0000
+++ b/__init__.py	2008-06-29 02:14:07 +0000
@@ -369,6 +369,67 @@
 
 register_command(cmd_svn_push)
 
+class cmd_dpush(Command):
+    """Push revisions to Subversion without setting any magic Bazaar-specific 
+    properties.
+
+    This will afterwards rebase the local Bazaar branch on the Subversion 
+    branch. 
+    """
+    takes_args = ['location?']
+    takes_options = ['remember', Option('directory',
+            help='Branch to push from, '
+                 'rather than the one containing the working directory.',
+            short_name='d',
+            type=unicode,
+            ),
+            Option('no-rebase', help="Don't rebase after push")]
+
+    def run(self, location=None, remember=False, directory=None, no_rebase=False):
+        from bzrlib import urlutils
+        from bzrlib.bzrdir import BzrDir
+        from bzrlib.branch import Branch
+        from bzrlib.errors import NotBranchError, BzrCommandError, NoWorkingTree
+        from bzrlib.workingtree import WorkingTree
+
+        from bzrlib.plugins.svn.commit import dpush
+
+        if directory is None:
+            directory = "."
+        try:
+            source_wt = WorkingTree.open_containing(directory)[0]
+            source_branch = source_wt.branch
+        except NoWorkingTree:
+            source_branch = Branch.open_containing(directory)[0]
+            source_wt = None
+        stored_loc = source_branch.get_push_location()
+        if location is None:
+            if stored_loc is None:
+                raise BzrCommandError("No push location known or specified.")
+            else:
+                display_url = urlutils.unescape_for_display(stored_loc,
+                        self.outf.encoding)
+                self.outf.write("Using saved location: %s\n" % display_url)
+                location = stored_loc
+
+        bzrdir = BzrDir.open(location)
+        target_branch = bzrdir.open_branch()
+        target_branch.lock_write()
+        revid_map = dpush(target_branch, source_branch)
+        # 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)
+        if not no_rebase:
+            revno, old_last_revid = source_branch.last_revision_info()
+            new_last_revid = revid_map[old_last_revid]
+            if source_wt is not None:
+                source_wt.pull(target_branch, overwrite=True, stop_revision=new_last_revid)
+            else:
+                source_branch.pull(target_branch, overwrite=True, stop_revision=new_last_revid)
+
+
+register_command(cmd_dpush)
+
 
 class cmd_svn_branching_scheme(Command):
     """Show or change the branching scheme for a Subversion repository.

=== modified file 'commit.py'
--- a/commit.py	2008-06-27 16:28:04 +0000
+++ b/commit.py	2008-06-29 00:33:29 +0000
@@ -15,13 +15,13 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Committing and pushing to Subversion repositories."""
 
-from bzrlib import debug, osutils, urlutils
+from bzrlib import debug, osutils, urlutils, ui
 from bzrlib.branch import Branch
 from bzrlib.errors import (BzrError, InvalidRevisionId, DivergedBranches, 
                            UnrelatedBranches, AppendRevisionsOnlyViolation)
 from bzrlib.inventory import Inventory
 from bzrlib.repository import RootCommitBuilder, InterRepository
-from bzrlib.revision import NULL_REVISION
+from bzrlib.revision import NULL_REVISION, ensure_null
 from bzrlib.trace import mutter, warning
 
 from cStringIO import StringIO
@@ -88,7 +88,8 @@
     """Commit Builder implementation wrapped around svn_delta_editor. """
 
     def __init__(self, repository, branch, parents, config, timestamp, 
-                 timezone, committer, revprops, revision_id, old_inv=None):
+                 timezone, committer, revprops, revision_id, old_inv=None,
+                 push_metadata=True):
         """Instantiate a new SvnCommitBuilder.
 
         :param repository: SvnRepository to commit to.
@@ -102,10 +103,13 @@
         :param revision_id: Revision id for the new revision.
         :param old_inv: Optional revision on top of which 
             the commit is happening
+        :param push_metadata: Whether or not to push all bazaar metadata
+                              (in svn file properties, etc).
         """
         super(SvnCommitBuilder, self).__init__(repository, parents, 
             config, timestamp, timezone, committer, revprops, revision_id)
         self.branch = branch
+        self.push_metadata = push_metadata
 
         # Gather information about revision on top of which the commit is 
         # happening
@@ -440,6 +444,8 @@
         if self._config.get_log_strip_trailing_newline():
             self.base_mapping.export_message(message, self._svn_revprops, self._svnprops)
             message = message.rstrip("\n")
+        if not self.push_metadata:
+            self._svn_revprops = {}
         self._svn_revprops[properties.PROP_REVISION_LOG] = message.encode("utf-8")
 
         try:
@@ -485,13 +491,14 @@
                 branch_editors[-1])
 
             # Set all the revprops
-            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)
-                if value is not None:
-                    value = value.encode('utf-8')
-                branch_editors[-1].change_prop(prop, value)
-                self.mutter("Setting root file property %r -> %r", prop, value)
+            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)
+                    if value is not None:
+                        value = value.encode('utf-8')
+                    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()
@@ -508,7 +515,7 @@
 
         revid = self.branch.generate_revision_id(result_revision)
 
-        assert self._new_revision_id is None or self._new_revision_id == revid
+        assert not self.push_metadata or self._new_revision_id is None or self._new_revision_id == revid
 
         self.mutter('commit %d finished. author: %r, date: %r, revid: %r',
                result_revision, result_author, 
@@ -602,18 +609,16 @@
 
 
 def push_new(target_repository, target_branch_path, source, 
-             stop_revision=None):
+             push_metadata=True):
     """Push a revision into Subversion, creating a new branch.
 
     This will do a new commit in the target branch.
 
+    :param target_repository: Repository to push to
     :param target_branch_path: Path to create new branch at
     :param source: Branch to pull the revision from
-    :param revision_id: Revision id of the revision to push
     """
     assert isinstance(source, Branch)
-    if stop_revision is None:
-        stop_revision = source.last_revision()
     history = source.revision_history()
     revhistory = list(history)
     start_revid = NULL_REVISION
@@ -667,22 +672,54 @@
                 revnum, self.get_branch_path(revnum), 
                 self.repository.get_mapping())
 
-    push(ImaginaryBranch(target_repository), source, start_revid)
+    push(ImaginaryBranch(target_repository), source, start_revid, push_metadata=push_metadata)
+
+
+def dpush(target, source, stop_revision=None):
+    source.lock_read()
+    try:
+        if stop_revision is None:
+            stop_revision = ensure_null(source.last_revision())
+        if target.last_revision() in (stop_revision, source.last_revision()):
+            return
+        graph = target.repository.get_graph()
+        if not source.repository.get_graph().is_ancestor(target.last_revision(), 
+                                                        stop_revision):
+            if graph.is_ancestor(stop_revision, target.last_revision()):
+                return
+            raise DivergedBranches(self, other)
+        todo = target.repository.lhs_missing_revisions(source.revision_history(), 
+                                                     stop_revision)
+        revid_map = {}
+        pb = ui.ui_factory.nested_progress_bar()
+        try:
+            for revid in todo:
+                pb.update("pushing revisions", todo.index(revid), 
+                          len(todo))
+                revid_map[revid] = push(target, source, revid, push_metadata=False)
+                target._clear_cached_state()
+        finally:
+            pb.finished()
+        (new_revno, new_revid) = target.last_revision_info()
+        return revid_map
+    finally:
+        source.unlock()
 
 
 def push_revision_tree(target, config, source_repo, base_revid, revision_id, 
-                       rev):
+                       rev, push_metadata=True):
     old_tree = source_repo.revision_tree(revision_id)
     base_tree = source_repo.revision_tree(base_revid)
 
     builder = SvnCommitBuilder(target.repository, target, rev.parent_ids,
                                config, rev.timestamp,
                                rev.timezone, rev.committer, rev.properties, 
-                               revision_id, base_tree.inventory)
+                               revision_id, base_tree.inventory, 
+                               push_metadata=push_metadata)
                          
     replay_delta(builder, base_tree, old_tree)
     try:
-        builder.commit(rev.message)
+        revid = builder.commit(rev.message)
     except SubversionException, (_, num):
         if num == ERR_FS_TXN_OUT_OF_DATE:
             raise DivergedBranches(source, target)
@@ -693,8 +730,10 @@
     if source_repo.has_signature_for_revision_id(revision_id):
         pass # FIXME: Copy revision signature for rev
 
-
-def push(target, source, revision_id):
+    return revid
+
+
+def push(target, source, revision_id, push_metadata=True):
     """Push a revision into Subversion.
 
     This will do a new commit in the target branch.
@@ -702,6 +741,7 @@
     :param target: Branch to push to
     :param source: Branch to pull the revision from
     :param revision_id: Revision id of the revision to push
+    :return: revision id of revision that was pushed
     """
     assert isinstance(source, Branch)
     rev = source.repository.get_revision(revision_id)
@@ -715,11 +755,14 @@
 
     source.lock_read()
     try:
-        push_revision_tree(target, target.get_config(), source.repository, base_revid, revision_id, rev)
+        revid = push_revision_tree(target, target.get_config(), source.repository, base_revid, 
+                                   revision_id, rev, push_metadata=push_metadata)
     finally:
         source.unlock()
 
-    if 'validate' in debug.debug_flags:
+    assert revid == revision_id or not push_metadata
+
+    if 'validate' in debug.debug_flags and push_metadata:
         crev = target.repository.get_revision(revision_id)
         ctree = target.repository.revision_tree(revision_id)
         treedelta = ctree.changes_from(old_tree)
@@ -730,6 +773,8 @@
         assert crev.message == rev.message
         assert crev.properties == rev.properties
 
+    return revid
+
 
 class InterToSvnRepository(InterRepository):
     """Any to Subversion repository actions."""

=== modified file 'tests/test_blackbox.py'
--- a/tests/test_blackbox.py	2008-06-26 16:34:37 +0000
+++ b/tests/test_blackbox.py	2008-06-29 02:14:07 +0000
@@ -17,6 +17,7 @@
 
 from bzrlib.repository import Repository
 from bzrlib.tests.blackbox import ExternalBase
+from bzrlib.tests import KnownFailure
 from bzrlib.trace import mutter
 
 from bzrlib.plugins.svn.mapping3 import BzrSvnMappingv3FileProps
@@ -46,6 +47,62 @@
         repos_url = self.make_repository('d')
         self.run_bzr('info -v %s' % repos_url)
 
+    def test_push(self):
+        repos_url = self.make_repository('d')
+        
+        dc = self.get_commit_editor(repos_url)
+        dc.add_file("foo").modify()
+        dc.close()
+
+        self.run_bzr("branch %s dc" % repos_url)
+        self.build_tree({"dc/foo": "blaaaa"})
+        self.run_bzr("commit -m msg dc")
+        self.run_bzr("push -d dc %s" % repos_url)
+        self.check_output("", "status dc")
+
+    def test_dpush(self):
+        repos_url = self.make_repository('d')
+        
+        dc = self.get_commit_editor(repos_url)
+        dc.add_file("foo").modify()
+        dc.close()
+
+        self.run_bzr("branch %s dc" % repos_url)
+        self.build_tree({"dc/foo": "blaaaa"})
+        self.run_bzr("commit -m msg dc")
+        self.run_bzr("dpush -d dc %s" % repos_url)
+        self.check_output("", "status dc")
+
+    def test_dpush_new(self):
+        repos_url = self.make_repository('d')
+        
+        dc = self.get_commit_editor(repos_url)
+        dc.add_file("foo").modify()
+        dc.close()
+
+        self.run_bzr("branch %s dc" % repos_url)
+        self.build_tree({"dc/foofile": "blaaaa"})
+        self.run_bzr("add dc/foofile")
+        self.run_bzr("commit -m msg dc")
+        self.run_bzr("dpush -d dc %s" % repos_url)
+        self.check_output("", "status dc")
+
+    def test_dpush_wt_diff(self):
+        raise KnownFailure
+        repos_url = self.make_repository('d')
+        
+        dc = self.get_commit_editor(repos_url)
+        dc.add_file("foo").modify()
+        dc.close()
+
+        self.run_bzr("branch %s dc" % repos_url)
+        self.build_tree({"dc/foofile": "blaaaa"})
+        self.run_bzr("add dc/foofile")
+        self.run_bzr("commit -m msg dc")
+        self.build_tree({"dc/foofile": "blaaaal"})
+        self.run_bzr("dpush -d dc %s" % repos_url)
+        self.check_output('modified:\n  foofile\n', "status dc")
+
     def test_info_workingtree(self):
         repos_url = self.make_client('d', 'dc')
         self.run_bzr('info -v dc')

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2008-06-27 18:43:40 +0000
+++ b/tests/test_push.py	2008-06-29 01:04:25 +0000
@@ -33,10 +33,49 @@
 
 from bzrlib.plugins.svn import format, ra
 from bzrlib.plugins.svn.errors import ChangesRootLHSHistory, MissingPrefix
-from bzrlib.plugins.svn.commit import push
+from bzrlib.plugins.svn.commit import push, dpush
 from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_REVISION_ID
 from bzrlib.plugins.svn.tests import TestCaseWithSubversionRepository
 
+class TestDPush(TestCaseWithSubversionRepository):
+    def setUp(self):
+        super(TestDPush, self).setUp()
+        self.repos_url = self.make_repository('d')
+
+        dc = self.commit_editor()
+        foo = dc.add_dir("foo")
+        foo.add_file("foo/bla").modify("data")
+        dc.close()
+
+        self.svndir = BzrDir.open(self.repos_url)
+        os.mkdir("dc")
+        self.bzrdir = self.svndir.sprout("dc")
+
+    def commit_editor(self):
+        return self.get_commit_editor(self.repos_url)
+
+    def test_change(self):
+        self.build_tree({'dc/foo/bla': 'other data'})
+        wt = self.bzrdir.open_workingtree()
+        newid = wt.commit(message="Commit from Bzr")
+
+        revid_map = dpush(self.svndir.open_branch(), self.bzrdir.open_branch())
+
+        self.assertEquals([newid], revid_map.keys())
+
+        c = ra.RemoteAccess(self.repos_url)
+        (entries, fetch_rev, props) = c.get_dir("", c.get_latest_revnum())
+        self.assertEquals(set(['svn:entry:committed-rev', 
+            'svn:entry:last-author', 'svn:entry:uuid', 
+            'svn:entry:committed-date']), set(props.keys()))
+
+        r = self.svndir.find_repository()
+        self.assertEquals([r.generate_revision_id(
+                c.get_latest_revnum(),
+                "", 
+                r.get_mapping())], revid_map.values())
+ 
+
 class TestPush(TestCaseWithSubversionRepository):
     def setUp(self):
         super(TestPush, self).setUp()




More information about the bazaar-commits mailing list