Rev 3920: (mbp) Merge ForeignRepository base class in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 24 05:08:45 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3920
revision-id: pqm at pqm.ubuntu.com-20081224050842-15xix09apawzgs05
parent: pqm at pqm.ubuntu.com-20081224035802-esmxzpzqfmjbf3vu
parent: mbp at sourcefrog.net-20081224042608-q8s1acu2q75gfcuc
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-12-24 05:08:42 +0000
message:
(mbp) Merge ForeignRepository base class
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/foreign.py foreign.py-20081112170002-olsxmandkk8qyfuq-1
------------------------------------------------------------
revno: 3918.2.2
revision-id: mbp at sourcefrog.net-20081224042608-q8s1acu2q75gfcuc
parent: mbp at sourcefrog.net-20081224030107-fc2g6obokty8en79
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: integration
timestamp: Wed 2008-12-24 15:26:08 +1100
message:
Add import statement
modified:
bzrlib/foreign.py foreign.py-20081112170002-olsxmandkk8qyfuq-1
------------------------------------------------------------
revno: 3918.2.1
revision-id: mbp at sourcefrog.net-20081224030107-fc2g6obokty8en79
parent: pqm at pqm.ubuntu.com-20081224000433-nqbyejff1bb3bpu8
parent: jelmer at samba.org-20081205031941-wssmem2a81nvdqr4
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: integration
timestamp: Wed 2008-12-24 14:01:07 +1100
message:
Merge ForeignRepository base class
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/foreign.py foreign.py-20081112170002-olsxmandkk8qyfuq-1
------------------------------------------------------------
revno: 3878.5.1
revision-id: jelmer at samba.org-20081205031941-wssmem2a81nvdqr4
parent: pqm at pqm.ubuntu.com-20081202015700-3mc9dola31w7h5h4
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr.dev
timestamp: Fri 2008-12-05 04:19:41 +0100
message:
Add a ForeignRepository base class.
modified:
bzrlib/foreign.py foreign.py-20081112170002-olsxmandkk8qyfuq-1
=== modified file 'NEWS'
--- a/NEWS 2008-12-23 03:44:45 +0000
+++ b/NEWS 2008-12-24 03:01:07 +0000
@@ -97,6 +97,9 @@
API CHANGES:
+ * New ``ForeignRepository`` base class, to help with foreign branch
+ support (e.g. svn). (Jelmer Vernooij)
+
* ``node_distances`` and ``select_farthest`` can no longer be imported
from ``bzrlib.graph``. They can still be imported from
``bzrlib.deprecated_graph``, which has been the preferred way to
=== modified file 'bzrlib/foreign.py'
--- a/bzrlib/foreign.py 2008-11-25 03:08:14 +0000
+++ b/bzrlib/foreign.py 2008-12-24 04:26:08 +0000
@@ -13,15 +13,20 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
"""Foreign branch utilities."""
+
from bzrlib.branch import Branch
from bzrlib.commands import Command, Option
+from bzrlib.repository import Repository
from bzrlib.revision import Revision
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
from bzrlib import (
errors,
+ osutils,
registry,
)
""")
@@ -174,3 +179,63 @@
foreign_vcs_registry = ForeignVcsRegistry()
+
+
+class ForeignRepository(Repository):
+ """A Repository that exists in a foreign version control system.
+
+ The data in this repository can not be represented natively using
+ Bazaars internal datastructures, but have to converted using a VcsMapping.
+ """
+
+ # This repository's native version control system
+ vcs = None
+
+ def has_foreign_revision(self, foreign_revid):
+ """Check whether the specified foreign revision is present.
+
+ :param foreign_revid: A foreign revision id, in the format used
+ by this Repository's VCS.
+ """
+ raise NotImplementedError(self.has_foreign_revision)
+
+ def lookup_bzr_revision_id(self, revid):
+ """Lookup a mapped or roundtripped revision by revision id.
+
+ :param revid: Bazaar revision id
+ :return: Tuple with foreign revision id and mapping.
+ """
+ raise NotImplementedError(self.lookup_revision_id)
+
+ def all_revision_ids(self, mapping=None):
+ """See Repository.all_revision_ids()."""
+ raise NotImplementedError(self.all_revision_ids)
+
+ def get_default_mapping(self):
+ """Get the default mapping for this repository."""
+ 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))
+
+
More information about the bazaar-commits
mailing list