Rev 113: Merge removal of foreign functionality now in bzrlib. in http://people.samba.org/bzr/jelmer/bzr-git/trunk

Jelmer Vernooij jelmer at samba.org
Tue Nov 25 03:26:00 GMT 2008


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

------------------------------------------------------------
revno: 113
revision-id: jelmer at samba.org-20081125032559-6r3sf0q1h1yto7j5
parent: jelmer at samba.org-20081110162254-w72b1vuk55ara152
parent: jelmer at samba.org-20081125031620-h4plmbufgsdjcqiw
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-11-25 04:25:59 +0100
message:
  Merge removal of foreign functionality now in bzrlib.
modified:
  foreign/__init__.py            foreign.py-20080827193306-rxeku2c2obec90c4-1
  foreign/upgrade.py             upgrade.py-20080909124113-1j5ajrrwjp4x7z52-1
  foreign/versionedfiles.py      versionedfiles.py-20080829145632-midkv3h7msuyoibq-2
  mapping.py                     ids.py-20071108230535-su8dxk529f4uk9fx-3
    ------------------------------------------------------------
    revno: 0.1.24
    revision-id: jelmer at samba.org-20081125031620-h4plmbufgsdjcqiw
    parent: jelmer at samba.org-20081125010300-eopsjg95uslhfeqw
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Tue 2008-11-25 04:16:20 +0100
    message:
      Remove elements pending to be included in bzrlib.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
    ------------------------------------------------------------
    revno: 0.1.23
    revision-id: jelmer at samba.org-20081125010300-eopsjg95uslhfeqw
    parent: jelmer at samba.org-20081125003332-60b0uol0fd7436gt
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Tue 2008-11-25 02:03:00 +0100
    message:
      Add more docstrings.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
    ------------------------------------------------------------
    revno: 0.1.22
    revision-id: jelmer at samba.org-20081125003332-60b0uol0fd7436gt
    parent: jelmer at samba.org-20081119131027-4895dyr5a5i28dum
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Tue 2008-11-25 01:33:32 +0100
    message:
      Merge improvements from bzr-svn.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
      upgrade.py                     upgrade.py-20080909124113-1j5ajrrwjp4x7z52-1
    ------------------------------------------------------------
    revno: 0.1.21
    revision-id: jelmer at samba.org-20081119131027-4895dyr5a5i28dum
    parent: jelmer at samba.org-20081112181618-jp45woeqhhfv80oy
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Wed 2008-11-19 14:10:27 +0100
    message:
      Only register foreign property show function once.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
    ------------------------------------------------------------
    revno: 0.1.20
    revision-id: jelmer at samba.org-20081112181618-jp45woeqhhfv80oy
    parent: jelmer at samba.org-20081112143610-30109vbbkeuj94y0
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Wed 2008-11-12 19:16:18 +0100
    message:
      Merge bzr-svn improvements.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
    ------------------------------------------------------------
    revno: 0.1.19
    revision-id: jelmer at samba.org-20081112143610-30109vbbkeuj94y0
    parent: jelmer at samba.org-20081112111919-kicfbop2ucy7dxb0
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Wed 2008-11-12 15:36:10 +0100
    message:
      import bzr-svn improvements.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
      upgrade.py                     upgrade.py-20080909124113-1j5ajrrwjp4x7z52-1
      versionedfiles.py              versionedfiles.py-20080829145632-midkv3h7msuyoibq-2
    ------------------------------------------------------------
    revno: 0.1.18
    revision-id: jelmer at samba.org-20081112111919-kicfbop2ucy7dxb0
    parent: jelmer at samba.org-20081110161650-147q2c84jb754ukg
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Wed 2008-11-12 12:19:19 +0100
    message:
      Add docstrings.
    modified:
      __init__.py                    foreign.py-20080827193306-rxeku2c2obec90c4-1
=== modified file 'foreign/__init__.py'
--- a/foreign/__init__.py	2008-11-10 16:16:50 +0000
+++ b/foreign/__init__.py	2008-11-25 03:16:20 +0000
@@ -16,73 +16,77 @@
 
 """Foreign branch utilities."""
 
-from bzrlib import errors, registry
 from bzrlib.branch import Branch
 from bzrlib.commands import Command, Option
-from bzrlib.trace import info
-
-
-class VcsMapping(object):
-    """Describes the mapping between the semantics of Bazaar and a foreign vcs.
-
-    """
-    experimental = False
-    roundtripping = False
-    revid_prefix = None
-
-    def revision_id_bzr_to_foreign(self, bzr_revid):
-        """Parse a bzr revision id and convert it to a foreign revid.
-
-        :param bzr_revid: The bzr revision id (a string).
-        :return: A foreign revision id, can be any sort of object.
-        """
-        raise NotImplementedError(self.revision_id_bzr_to_foreign)
-
-    def revision_id_foreign_to_bzr(self, foreign_revid):
-        """Parse a foreign revision id and convert it to a bzr revid.
-
-        :param foreign_revid: Foreign revision id, can be any sort of object.
-        :return: A bzr revision id.
-        """
-        raise NotImplementedError(self.revision_id_foreign_to_bzr)
-
-
-class VcsMappingRegistry(registry.Registry):
-    """Registry for Bazaar<->foreign VCS mappings.
-    
-    There should be one instance of this registry for every foreign VCS.
-    """
-
-    def register(self, key, factory, help):
-        """Register a mapping between Bazaar and foreign VCS semantics.
-
-        The factory must be a callable that takes one parameter: the key.
-        It must produce an instance of VcsMapping when called.
-        """
-        registry.Registry.register(self, key, factory, help)
-
-    def set_default(self, key):
-        """Set the 'default' key to be a clone of the supplied key.
-
-        This method must be called once and only once.
-        """
-        self._set_default_key(key)
-
-    def get_default(self):
-        """Convenience function for obtaining the default mapping to use."""
-        return self.get(self._get_default_key())
+from bzrlib.repository import Repository
+from bzrlib.revision import Revision
+from bzrlib.lazy_import import lazy_import
+lazy_import(globals(), """
+from bzrlib import (
+    errors,
+    log,
+    osutils,
+    registry,
+    )
+""")
 
 
 class ForeignBranch(Branch):
+    """Branch that exists in a foreign version control system."""
 
     def __init__(self, mapping):
+        self.mapping = mapping
         super(ForeignBranch, self).__init__()
-        self.mapping = mapping
 
     def dpull(self, source, stop_revision=None):
+        """Pull deltas from another branch.
+
+        :note: This does not, like pull, retain the revision ids from 
+        the source branch and will, rather than adding bzr-specific metadata,
+        push only those semantics of the revision that can be natively 
+        represented in this branch.
+
+        :param source: Source branch
+        :param stop_revision: Revision to pull, defaults to last revision.
+        """
         raise NotImplementedError(self.pull)
 
 
+class ForeignRepository(Repository):
+
+    def has_foreign_revision(self, foreign_revid):
+        raise NotImplementedError(self.has_foreign_revision)
+
+    def all_revision_ids(self, mapping=None):
+        raise NotImplementedError(self.all_revision_ids)
+
+    def get_mapping(self):
+        raise NotImplementedError(self.get_default_mapping)
+
+    def get_inventory_xml(self, revision_id):
+        """See Repository.get_inventory_xml()."""
+        return self.serialise_inventory(self.get_inventory(revision_id))
+
+    def get_inventory_sha1(self, revision_id):
+        """Get the sha1 for the XML representation of an inventory.
+
+        :param revision_id: Revision id of the inventory for which to return 
+         the SHA1.
+        :return: XML string
+        """
+
+        return osutils.sha_string(self.get_inventory_xml(revision_id))
+
+    def get_revision_xml(self, revision_id):
+        """Return the XML representation of a revision.
+
+        :param revision_id: Revision for which to return the XML.
+        :return: XML string
+        """
+        return self._serializer.write_revision_to_string(self.get_revision(revision_id))
+
+
+
 class FakeControlFiles(object):
     """Dummy implementation of ControlFiles.
     
@@ -119,8 +123,8 @@
             no_rebase=False):
         from bzrlib import urlutils
         from bzrlib.bzrdir import BzrDir
-        from bzrlib.branch import Branch
         from bzrlib.errors import BzrCommandError, NoWorkingTree
+        from bzrlib.trace import info
         from bzrlib.workingtree import WorkingTree
 
         if directory is None:
@@ -168,11 +172,11 @@
     from bzrlib.tests import TestUtil
     loader = TestUtil.TestLoader()
     suite = TestSuite()
-    import test_versionedfiles
-    testmod_names = ['test_versionedfiles',]
+    testmod_names = ['test_versionedfiles', ]
     suite.addTest(loader.loadTestsFromModuleNames(testmod_names))
     return suite
 
+
 def escape_commit_message(message):
     """Replace xml-incompatible control characters."""
     if message is None:
@@ -194,4 +198,3 @@
     return message
 
 
-

=== modified file 'foreign/upgrade.py'
--- a/foreign/upgrade.py	2008-11-10 16:14:20 +0000
+++ b/foreign/upgrade.py	2008-11-25 00:33:32 +0000
@@ -17,7 +17,6 @@
 
 from bzrlib import ui
 from bzrlib.errors import BzrError, InvalidRevisionId, DependencyNotPresent
-from bzrlib.revision import Revision
 from bzrlib.trace import info
 
 import itertools
@@ -229,7 +228,7 @@
             repository.fetch(foreign_repository, revid)
 
     if not allow_changes:
-        for oldrevid, newrevid in upgrade_map.items():
+        for oldrevid, newrevid in upgrade_map.iteritems():
             oldrev = repository.get_revision(oldrevid)
             newrev = repository.get_revision(newrevid)
             check_revision_changed(oldrev, newrev)
@@ -243,7 +242,7 @@
       graph, lambda revid: create_upgraded_revid(revid, new_mapping.upgrade_suffix))
     def remove_parents((oldrevid, (newrevid, parents))):
         return (oldrevid, newrevid)
-    upgrade_map.update(dict(map(remove_parents, plan.items())))
+    upgrade_map.update(dict(map(remove_parents, plan.iteritems())))
 
     return (plan, upgrade_map)
 

=== modified file 'foreign/versionedfiles.py'
--- a/foreign/versionedfiles.py	2008-08-29 14:56:37 +0000
+++ b/foreign/versionedfiles.py	2008-11-12 14:36:10 +0000
@@ -13,10 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from bzrlib import osutils, urlutils
-from bzrlib.versionedfile import FulltextContentFactory, VersionedFiles, VirtualVersionedFiles
-
-from cStringIO import StringIO
+from bzrlib import osutils
+from bzrlib.versionedfile import VirtualVersionedFiles
 
 
 class VirtualRevisionTexts(VirtualVersionedFiles):

=== modified file 'mapping.py'
--- a/mapping.py	2008-08-30 17:22:05 +0000
+++ b/mapping.py	2008-11-25 03:25:59 +0000
@@ -16,8 +16,7 @@
 
 """Converters, etc for going between Bazaar and Git ids."""
 
-from bzrlib import errors
-from bzrlib.plugins.git import foreign
+from bzrlib import errors, foreign
 
 class BzrGitMapping(foreign.VcsMapping):
     """Class that maps between Git and Bazaar semantics."""




More information about the bazaar-commits mailing list