Rev 2071: Merge removal of foreign utility functions now moved to bzrlib. in http://people.samba.org/bzr/jelmer/bzr-svn/0.5
Jelmer Vernooij
jelmer at samba.org
Tue Nov 25 03:24:00 GMT 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.5
------------------------------------------------------------
revno: 2071
revision-id: jelmer at samba.org-20081125032358-m32ath3q7dec0ln0
parent: jelmer at samba.org-20081125010407-8k1yhrxm9ydx4i91
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.5
timestamp: Tue 2008-11-25 04:23:58 +0100
message:
Merge removal of foreign utility functions now moved to bzrlib.
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
foreign/__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
mapping.py mapping.py-20080128201303-6cp01phc0dmc0kiv-1
revmeta.py revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
=== modified file '__init__.py'
--- a/__init__.py 2008-11-24 20:30:08 +0000
+++ b/__init__.py 2008-11-25 03:23:58 +0000
@@ -35,6 +35,7 @@
import bzrlib.api, bzrlib.repository
from bzrlib.bzrdir import BzrDirFormat, format_registry
from bzrlib.errors import BzrError
+from bzrlib.foreign import foreign_vcs_registry
from bzrlib.commands import Command, register_command, display_command
from bzrlib.help_topics import topic_registry
from bzrlib.option import Option, RegistryOption
@@ -55,7 +56,7 @@
version_string = '%d.%d.%d%s%d' % version_info
__version__ = version_string
-COMPATIBLE_BZR_VERSIONS = [(1, 9, 0)]
+COMPATIBLE_BZR_VERSIONS = [(1, 10, 0)]
def check_subversion_version(subvertpy):
@@ -430,12 +431,11 @@
register_command(cmd_svn_push)
-from bzrlib.plugins.svn import foreign
-register_command(foreign.cmd_dpush)
+from bzrlib.plugins.svn.foreign import cmd_dpush
+register_command(cmd_dpush)
-foreign.foreign_vcs_registry.register_lazy("svn",
- "bzrlib.plugins.svn.mapping",
- "foreign_vcs_svn")
+foreign_vcs_registry.register_lazy("svn", "bzrlib.plugins.svn.mapping",
+ "foreign_vcs_svn")
class cmd_svn_branching_scheme(Command):
"""Show or change the branching scheme for a Subversion repository.
=== modified file 'foreign/__init__.py'
--- a/foreign/__init__.py 2008-11-25 01:04:07 +0000
+++ b/foreign/__init__.py 2008-11-25 03:23:58 +0000
@@ -31,78 +31,6 @@
""")
-class VcsMapping(object):
- """Describes the mapping between the semantics of Bazaar and a foreign vcs.
-
- """
- # Whether this is an experimental mapping that is still open to changes.
- experimental = False
-
- # Whether this mapping supports exporting and importing all bzr semantics.
- roundtripping = False
-
- # Prefix used when importing native foreign revisions (not roundtripped)
- # using this mapping.
- 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)
-
- def show_foreign_revid(self, foreign_revid):
- """Prepare a foreign revision id for formatting using bzr log.
-
- :param foreign_revid: Foreign revision id.
- :return: Dictionary mapping string keys to string values.
- """
- # TODO: This could be on ForeignVcs instead
- return { }
-
-
-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.
- """
- if ":" in key:
- raise ValueError("mapping name can not contain colon (:)")
- 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())
-
- def revision_id_bzr_to_foreign(self, revid):
- """Convert a bzr revision id to a foreign revid."""
- raise NotImplementedError(self.revision_id_bzr_to_foreign)
-
-
class ForeignBranch(Branch):
"""Branch that exists in a foreign version control system."""
@@ -270,84 +198,3 @@
return message
-class ForeignRevision(Revision):
- """A Revision from a Foreign repository. Remembers
- information about foreign revision id and mapping.
-
- """
-
- def __init__(self, foreign_revid, mapping, *args, **kwargs):
- if not "inventory_sha1" in kwargs:
- kwargs["inventory_sha1"] = ""
- super(ForeignRevision, self).__init__(*args, **kwargs)
- self.foreign_revid = foreign_revid
- self.mapping = mapping
-
-
-def show_foreign_properties(rev):
- """Custom log displayer for foreign revision identifiers.
-
- :param rev: Revision object.
- """
- # Revision comes directly from a foreign repository
- if isinstance(rev, ForeignRevision):
- return rev.mapping.show_foreign_revid(rev.foreign_revid)
-
- # Revision was once imported from a foreign repository
- try:
- foreign_revid, mapping = \
- foreign_vcs_registry.parse_revision_id(rev.revision_id)
- except errors.InvalidRevisionId:
- return {}
-
- return mapping.show_foreign_revid(foreign_revid)
-
-
-class ForeignVcs(object):
- """A foreign version control system."""
-
- def __init__(self, mapping_registry):
- self.mapping_registry = mapping_registry
-
-
-class ForeignVcsRegistry(registry.Registry):
- """Registry for Foreign VCSes.
-
- There should be one entry per foreign VCS. Example entries would be
- "git", "svn", "hg", "darcs", etc.
-
- """
-
- def register(self, key, foreign_vcs, help):
- """Register a foreign VCS.
-
- :param key: Prefix of the foreign VCS in revision ids
- :param foreign_vcs: ForeignVCS instance
- :param help: Description of the foreign VCS
- """
- if ":" in key or "-" in key:
- raise ValueError("vcs name can not contain : or -")
- registry.Registry.register(self, key, foreign_vcs, help)
-
- def parse_revision_id(self, revid):
- """Parse a bzr revision and return the matching mapping and foreign
- revid.
-
- :param revid: The bzr revision id
- :return: tuple with foreign revid and vcs mapping
- """
- if not "-" in revid:
- raise errors.InvalidRevisionId(revid, None)
- try:
- foreign_vcs = self.get(revid.split("-")[0])
- except KeyError:
- raise errors.InvalidRevisionId(revid, None)
- return foreign_vcs.mapping_registry.revision_id_bzr_to_foreign(revid)
-
-
-if not "foreign" in log.properties_handler_registry:
- log.properties_handler_registry.register("foreign",
- show_foreign_properties,
- "Show foreign VCS properties")
-
-foreign_vcs_registry = ForeignVcsRegistry()
=== modified file 'mapping.py'
--- a/mapping.py 2008-11-24 20:30:08 +0000
+++ b/mapping.py 2008-11-25 03:23:58 +0000
@@ -15,12 +15,12 @@
"""Maps between Subversion and Bazaar semantics."""
-from bzrlib import osutils
+from bzrlib import foreign, osutils
from bzrlib.errors import InvalidRevisionId
from bzrlib.revision import NULL_REVISION
from bzrlib.trace import mutter
-from bzrlib.plugins.svn import errors, foreign, version_info, get_client_string
+from bzrlib.plugins.svn import errors, version_info, get_client_string
import calendar
from subvertpy import properties
=== modified file 'revmeta.py'
--- a/revmeta.py 2008-11-24 23:20:27 +0000
+++ b/revmeta.py 2008-11-25 03:23:58 +0000
@@ -20,6 +20,9 @@
from bzrlib import (
ui,
)
+from bzrlib.foreign import (
+ ForeignRevision,
+ )
from bzrlib.revision import (
NULL_REVISION,
)
@@ -28,7 +31,6 @@
errors as svn_errors,
logwalker,
)
-from bzrlib.plugins.svn.foreign import ForeignRevision
from bzrlib.plugins.svn.mapping import (
estimate_bzr_ancestors,
find_mapping,
More information about the bazaar-commits
mailing list