Rev 4076: (Jelmer) Add Branch.import_last_revision_info(). in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Mar 4 14:42:43 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4076
revision-id: pqm at pqm.ubuntu.com-20090304144239-ttukklew8lkxslgy
parent: pqm at pqm.ubuntu.com-20090303085413-35seprvnu885xorz
parent: jelmer at samba.org-20090304140130-mnpbbpwbwb2zwxzd
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-03-04 14:42:39 +0000
message:
  (Jelmer) Add Branch.import_last_revision_info().
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
  bzrlib/tests/branch_implementations/test_last_revision_info.py test_last_revision_i-20070201133317-51mzi40m8hv1i0i9-1
    ------------------------------------------------------------
    revno: 4048.2.4
    revision-id: jelmer at samba.org-20090304140130-mnpbbpwbwb2zwxzd
    parent: jelmer at samba.org-20090304132750-2mdmad8r8agxc0hn
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: masterbranch-update
    timestamp: Wed 2009-03-04 15:01:30 +0100
    message:
      Fix whitespace.
    modified:
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
    ------------------------------------------------------------
    revno: 4048.2.3
    revision-id: jelmer at samba.org-20090304132750-2mdmad8r8agxc0hn
    parent: jelmer at samba.org-20090227160014-8k9jb60wz40m9l93
    parent: pqm at pqm.ubuntu.com-20090303085413-35seprvnu885xorz
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: masterbranch-update
    timestamp: Wed 2009-03-04 14:27:50 +0100
    message:
      Merge bzr.dev.
    added:
      bzrlib/tests/per_interbranch/  per_interbranch-20090224001510-b1eq9kzmh3psmh6x-1
      bzrlib/tests/per_interbranch/__init__.py __init__.py-20090225010018-l7w4uvvt73ea2vj9-1
      bzrlib/tests/per_interbranch/test_update_revisions.py test_update_revision-20090225011043-7u1jnapdeuj07rre-1
      bzrlib/tests/test_export.py    test_export.py-20090220201010-tpbxssdnezsvu9pk-1
      bzrlib/tests/test_patches_data/diff-7 diff7-20081201221107-q9f611rir3xx1hdp-1
      bzrlib/tests/test_patches_data/mod-7 mod7-20081201221107-q9f611rir3xx1hdp-2
      bzrlib/tests/test_patches_data/orig-7 orig7-20081201221107-q9f611rir3xx1hdp-3
      doc/developers/ec2-windows.txt ec2windows.txt-20090219062112-2ga0nqpcm7n02njf-1
      doc/en/user-guide/filtered_views.txt filtered_views.txt-20090226100856-a16ba1v97v91ru58-1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
      bzrlib/export/__init__.py      __init__.py-20051114235828-1ba62cb4062304e6
      bzrlib/fetch.py                fetch.py-20050818234941-26fea6105696365d
      bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
      bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
      bzrlib/pack.py                 container.py-20070607160755-tr8zc26q18rn0jnb-1
      bzrlib/patches.py              patches.py-20050727183609-378c1cc5972ce908
      bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
      bzrlib/plugins/launchpad/lp_registration.py lp_registration.py-20060315190948-daa617eafe3a8d48
      bzrlib/plugins/launchpad/test_lp_open.py test_lp_open.py-20090125174355-hxrsxh3sj84225qu-1
      bzrlib/plugins/launchpad/test_lp_service.py test_lp_service.py-20080213034527-drf0ucr2x1js3onb-1
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repofmt/weaverepo.py    presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/smart/bzrdir.py         bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
      bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
      bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
      bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
      bzrlib/tests/branch_implementations/test_create_clone.py test_create_clone.py-20090225031440-8ybpkzojo7cvourv-1
      bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
      bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
      bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
      bzrlib/tests/interrepository_implementations/__init__.py __init__.py-20060220054744-baf49a1f88f17b1a
      bzrlib/tests/per_repository/test_add_fallback_repository.py test_add_fallback_re-20080215040003-8w9n4ck9uqdxj18m-1
      bzrlib/tests/per_repository/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
      bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
      bzrlib/tests/test_fetch.py     testfetch.py-20050825090644-f73e07e7dfb1765a
      bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
      bzrlib/tests/test_http.py      testhttp.py-20051018020158-b2eef6e867c514d9
      bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
      bzrlib/tests/test_patches.py   test_patches.py-20051231203844-f4974d20f6aea09c
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tests/test_smart_request.py test_smart_request.p-20090211070731-o38wayv3asm25d6a-1
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/tests/workingtree_implementations/test_views.py test_views.py-20080729134135-v4zjnb85eu9srl80-1
      bzrlib/transport/ftp/__init__.py ftp.py-20051116161804-58dc9506548c2a53
      bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
      bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
      bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
      bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
      bzrlib/views.py                views.py-20080729082027-1ouh6t9cdobc0eea-1
      doc/developers/index.txt       index.txt-20070508041241-qznziunkg0nffhiw-1
      doc/developers/network-protocol.txt networkprotocol.txt-20070903044232-woustorrjbmg5zol-1
      doc/en/mini-tutorial/index.txt index.txt-20070813141352-2u64ooqzo0or4hss-2
      doc/en/tutorials/using_bazaar_with_launchpad.txt using_bazaar_with_lp-20071211073140-7msh8uf9a9h4y9hb-1
      doc/en/user-guide/adv_merging.txt adv_merging.txt-20071213070245-d7u7150lb2hhnvby-1
      doc/en/user-guide/index.txt    index.txt-20060622101119-tgwtdci8z769bjb9-2
      doc/en/user-guide/organizing_branches.txt organizing_branches.-20071123154453-dk2mjhrg1vpjm5w2-3
      doc/en/user-guide/setting_up_email.txt setting_up_email.txt-20060314161707-fd242c8944346173
      doc/en/user-guide/solo_intro.txt solo_workflow.txt-20071121073725-0corxykv5irjal00-7
      doc/en/user-guide/specifying_revisions.txt specifying_revisions.txt-20060314161707-19deb139101bea33
      doc/en/user-guide/undoing_mistakes.txt undoing_mistakes.txt-20071121092300-8fyacngt1w98e5mp-1
      doc/en/user-guide/using_aliases.txt using_aliases.txt-20060314161707-c21d27fa2939e039
      doc/en/user-guide/using_gatekeepers.txt using_gatekeepers.tx-20071123154453-dk2mjhrg1vpjm5w2-5
    ------------------------------------------------------------
    revno: 4048.2.2
    revision-id: jelmer at samba.org-20090227160014-8k9jb60wz40m9l93
    parent: jelmer at samba.org-20090225155910-a73p5tkqqve1cue1
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: masterbranch-update
    timestamp: Fri 2009-02-27 17:00:14 +0100
    message:
      New Branch.import_last_Revision_info() function used to pull revisions into the master branch during commit.
    modified:
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
      bzrlib/tests/branch_implementations/test_last_revision_info.py test_last_revision_i-20070201133317-51mzi40m8hv1i0i9-1
    ------------------------------------------------------------
    revno: 4048.2.1
    revision-id: jelmer at samba.org-20090225155910-a73p5tkqqve1cue1
    parent: pqm at pqm.ubuntu.com-20090225063528-m6c41lna1xu4bdwm
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: masterbranch-update
    timestamp: Wed 2009-02-25 16:59:10 +0100
    message:
      Use Branch.pull() to update master branch.
    modified:
      bzrlib/commit.py               commit.py-20050511101309-79ec1a0168e0e825
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2009-03-03 05:50:55 +0000
+++ b/bzrlib/branch.py	2009-03-04 14:01:30 +0000
@@ -706,6 +706,20 @@
         return InterBranch.get(other, self).update_revisions(stop_revision,
             overwrite, graph)
 
+    def import_last_revision_info(self, source_repo, revno, revid):
+        """Set the last revision info, importing from another repo if necessary.
+
+        This is used by the bound branch code to upload a revision to
+        the master branch first before updating the tip of the local branch.
+
+        :param source_repo: Source repository to optionally fetch from
+        :param revno: Revision number of the new tip
+        :param revid: Revision id of the new tip
+        """
+        if not self.repository.has_same_location(source_repo):
+            self.repository.fetch(source_repo, revision_id=revid)
+        self.set_last_revision_info(revno, revid)
+
     def revision_id_to_revno(self, revision_id):
         """Given a revision id, return its revno"""
         if _mod_revision.is_null(revision_id):

=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py	2009-01-17 01:30:58 +0000
+++ b/bzrlib/commit.py	2009-02-27 16:00:14 +0000
@@ -395,16 +395,11 @@
             # Upload revision data to the master.
             # this will propagate merged revisions too if needed.
             if self.bound_branch:
-                if not self.master_branch.repository.has_same_location(
-                        self.branch.repository):
-                    self._set_progress_stage("Uploading data to master branch")
-                    self.master_branch.repository.fetch(self.branch.repository,
-                        revision_id=self.rev_id)
-                # now the master has the revision data
+                self._set_progress_stage("Uploading data to master branch")
                 # 'commit' to the master first so a timeout here causes the
                 # local branch to be out of date
-                self.master_branch.set_last_revision_info(new_revno,
-                                                          self.rev_id)
+                self.master_branch.import_last_revision_info(
+                    self.branch.repository, new_revno, self.rev_id)
 
             # and now do the commit locally.
             self.branch.set_last_revision_info(new_revno, self.rev_id)

=== modified file 'bzrlib/tests/branch_implementations/test_last_revision_info.py'
--- a/bzrlib/tests/branch_implementations/test_last_revision_info.py	2009-01-17 01:30:58 +0000
+++ b/bzrlib/tests/branch_implementations/test_last_revision_info.py	2009-02-27 16:00:14 +0000
@@ -33,3 +33,22 @@
         tree.commit('1st post')
         revid = tree.commit('2st post', allow_pointless=True)
         self.assertEqual((2, revid), tree.branch.last_revision_info())
+
+    def test_import(self):
+        # importing and setting last revision
+        tree1 = self.make_branch_and_tree('branch1')
+        tree1.commit('1st post')
+        revid = tree1.commit('2st post', allow_pointless=True)
+        branch2 = self.make_branch('branch2')
+        branch2.import_last_revision_info(tree1.branch.repository, 2, revid)
+        self.assertEqual((2, revid), branch2.last_revision_info())
+        self.assertTrue(branch2.repository.has_revision(revid))
+
+    def test_same_repo(self):
+        # importing and setting last revision within the same repo
+        tree = self.make_branch_and_tree('branch1')
+        tree.commit('1st post')
+        revid = tree.commit('2st post', allow_pointless=True)
+        tree.branch.set_last_revision_info(0, NULL_REVISION)
+        tree.branch.import_last_revision_info(tree.branch.repository, 2, revid)
+        self.assertEqual((2, revid), tree.branch.last_revision_info())




More information about the bazaar-commits mailing list