Rev 3003: (John Arbash Meinel) Fix bug #158333, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Nov 16 05:36:16 GMT 2007


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

------------------------------------------------------------
revno: 3003
revision-id: pqm at pqm.ubuntu.com-20071116053612-g6b07lkde35uvbe8
parent: pqm at pqm.ubuntu.com-20071116044522-3q7b9a1nt4nl5lfy
parent: john at arbash-meinel.com-20071116035541-nwajn3jyy8hq0op7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-11-16 05:36:12 +0000
message:
  (John Arbash Meinel)  Fix bug #158333,
  	make sure that Repository.fetch(self) is properly a no-op for all
  	Repository implementations.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/repository_implementations/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
    ------------------------------------------------------------
    revno: 2948.3.4
    merged: john at arbash-meinel.com-20071116035541-nwajn3jyy8hq0op7
    parent: john at arbash-meinel.com-20071116014617-blf76y9sa8b605t6
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: repository_fetch_self_158333
    timestamp: Thu 2007-11-15 21:55:41 -0600
    message:
      Repository.gather_stats() validly can get None for the revid.
      But is_null() causes a warning in that case.
      so check explicitly for None or is_null()
    ------------------------------------------------------------
    revno: 2948.3.3
    merged: john at arbash-meinel.com-20071116014617-blf76y9sa8b605t6
    parent: john at arbash-meinel.com-20071116013955-3zy651u2crhk31xx
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: repository_fetch_self_158333
    timestamp: Thu 2007-11-15 19:46:17 -0600
    message:
      NEWS
    ------------------------------------------------------------
    revno: 2948.3.2
    merged: john at arbash-meinel.com-20071116013955-3zy651u2crhk31xx
    parent: john at arbash-meinel.com-20071029210241-m2gq4o6ss0kcx2zo
    parent: pqm at pqm.ubuntu.com-20071115144759-zx0nd44rgp38riwr
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: repository_fetch_self_158333
    timestamp: Thu 2007-11-15 19:39:55 -0600
    message:
      [merge] bzr.dev 2998
    ------------------------------------------------------------
    revno: 2948.3.1
    merged: john at arbash-meinel.com-20071029210241-m2gq4o6ss0kcx2zo
    parent: pqm at pqm.ubuntu.com-20071029050400-j2jmz8smj2yecfrr
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: repository_fetch_self_158333
    timestamp: Mon 2007-10-29 16:02:41 -0500
    message:
      Fix bug #158333, make sure that Repository.fetch(self) is properly a no-op for all Repository implementations.
=== modified file 'NEWS'
--- a/NEWS	2007-11-16 03:22:44 +0000
+++ b/NEWS	2007-11-16 05:36:12 +0000
@@ -68,6 +68,9 @@
    * It is clearer when a plugin cannot be loaded because of its name, and a
      suggestion for an acceptable name is given. (Daniel Watkins, #103023)
 
+   * Make sure Repository.fetch(self) is properly a no-op for all
+     Repository implementations. (John Arbash Meinel, #158333)
+
    * Obsolete packs are now cleaned up by pack and autopack operations.
      (Robert Collins, #153789)
 

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-11-15 20:37:38 +0000
+++ b/bzrlib/remote.py	2007-11-16 05:36:12 +0000
@@ -24,6 +24,7 @@
     errors,
     lockdir,
     repository,
+    revision,
 )
 from bzrlib.branch import Branch, BranchReferenceFormat
 from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
@@ -32,7 +33,6 @@
 from bzrlib.errors import NoSuchRevision
 from bzrlib.lockable_files import LockableFiles
 from bzrlib.pack import ContainerReader
-from bzrlib.revision import NULL_REVISION
 from bzrlib.smart import client, vfs
 from bzrlib.symbol_versioning import (
     deprecated_method,
@@ -309,7 +309,7 @@
         """See Repository.get_revision_graph()."""
         if revision_id is None:
             revision_id = ''
-        elif revision_id == NULL_REVISION:
+        elif revision.is_null(revision_id):
             return {}
 
         path = self.bzrdir._path_for_remote_call(self._client)
@@ -357,7 +357,8 @@
     def gather_stats(self, revid=None, committers=None):
         """See Repository.gather_stats()."""
         path = self.bzrdir._path_for_remote_call(self._client)
-        if revid in (None, NULL_REVISION):
+        # revid can be None to indicate no revisions, not just NULL_REVISION
+        if revid is None or revision.is_null(revid):
             fmt_revid = ''
         else:
             fmt_revid = revid
@@ -626,7 +627,7 @@
             # check that last_revision is in 'from' and then return a
             # no-operation.
             if (revision_id is not None and
-                not _mod_revision.is_null(revision_id)):
+                not revision.is_null(revision_id)):
                 self.get_revision(revision_id)
             return 0, []
         self._ensure_real()

=== modified file 'bzrlib/tests/repository_implementations/test_fetch.py'
--- a/bzrlib/tests/repository_implementations/test_fetch.py	2007-10-26 19:18:48 +0000
+++ b/bzrlib/tests/repository_implementations/test_fetch.py	2007-11-16 01:39:55 +0000
@@ -20,6 +20,7 @@
     bzrdir,
     errors,
     gpg,
+    repository,
     )
 from bzrlib.tests import TestSkipped
 from bzrlib.tests.repository_implementations import TestCaseWithRepository
@@ -81,6 +82,31 @@
         rev2_tree = knit3_repo.revision_tree('rev2')
         self.assertEqual('rev1', rev2_tree.inventory.root.revision)
 
+    def test_fetch_all_from_self(self):
+        tree = self.make_branch_and_tree('.')
+        rev_id = tree.commit('one')
+        # This needs to be a new copy of the repository, if this changes, the
+        # test needs to be rewritten
+        repo = tree.branch.repository.bzrdir.open_repository()
+        # This fetch should be a no-op see bug #158333
+        tree.branch.repository.fetch(repo, None)
+
+    def test_fetch_from_self(self):
+        tree = self.make_branch_and_tree('.')
+        rev_id = tree.commit('one')
+        repo = tree.branch.repository.bzrdir.open_repository()
+        # This fetch should be a no-op see bug #158333
+        tree.branch.repository.fetch(repo, rev_id)
+
+    def test_fetch_missing_from_self(self):
+        tree = self.make_branch_and_tree('.')
+        rev_id = tree.commit('one')
+        # Even though the fetch() is a NO-OP it should assert the revision id
+        # is present
+        repo = tree.branch.repository.bzrdir.open_repository()
+        self.assertRaises(errors.NoSuchRevision, tree.branch.repository.fetch,
+                          repo, 'no-such-revision')
+
     def makeARepoWithSignatures(self):
         wt = self.make_branch_and_tree('a-repo-with-sigs')
         wt.commit('rev1', allow_pointless=True, rev_id='rev1')




More information about the bazaar-commits mailing list