/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
36
""")
37
37
 
38
38
class VcsMapping(object):
39
 
    """Describes the mapping between the semantics of Bazaar and a foreign vcs.
 
39
    """Describes the mapping between the semantics of Bazaar and a foreign VCS.
40
40
 
41
41
    """
42
42
    # Whether this is an experimental mapping that is still open to changes.
122
122
class ForeignVcs(object):
123
123
    """A foreign version control system."""
124
124
 
125
 
    def __init__(self, mapping_registry):
 
125
    branch_format = None
 
126
 
 
127
    repository_format = None
 
128
 
 
129
    def __init__(self, mapping_registry, abbreviation=None):
 
130
        """Create a new foreign vcs instance.
 
131
 
 
132
        :param mapping_registry: Registry with mappings for this VCS.
 
133
        :param abbreviation: Optional abbreviation ('bzr', 'svn', 'git', etc)
 
134
        """
 
135
        self.abbreviation = abbreviation
126
136
        self.mapping_registry = mapping_registry
127
137
 
128
138
    def show_foreign_revid(self, foreign_revid):
133
143
        """
134
144
        return { }
135
145
 
 
146
    def serialize_foreign_revid(self, foreign_revid):
 
147
        """Serialize a foreign revision id for this VCS.
 
148
 
 
149
        :param foreign_revid: Foreign revision id
 
150
        :return: Bytestring with serialized revid, will not contain any 
 
151
            newlines.
 
152
        """
 
153
        raise NotImplementedError(self.serialize_foreign_revid)
 
154
 
136
155
 
137
156
class ForeignVcsRegistry(registry.Registry):
138
157
    """Registry for Foreign VCSes.
206
225
        """Get the default mapping for this repository."""
207
226
        raise NotImplementedError(self.get_default_mapping)
208
227
 
209
 
    def get_inventory_xml(self, revision_id):
210
 
        """See Repository.get_inventory_xml()."""
211
 
        return self.serialise_inventory(self.get_inventory(revision_id))
212
 
 
213
 
    def get_inventory_sha1(self, revision_id):
214
 
        """Get the sha1 for the XML representation of an inventory.
215
 
 
216
 
        :param revision_id: Revision id of the inventory for which to return
217
 
         the SHA1.
218
 
        :return: XML string
219
 
        """
220
 
 
221
 
        return osutils.sha_string(self.get_inventory_xml(revision_id))
222
 
 
223
 
    def get_revision_xml(self, revision_id):
224
 
        """Return the XML representation of a revision.
225
 
 
226
 
        :param revision_id: Revision for which to return the XML.
227
 
        :return: XML string
228
 
        """
229
 
        return self._serializer.write_revision_to_string(
230
 
            self.get_revision(revision_id))
231
 
 
232
228
 
233
229
class ForeignBranch(Branch):
234
230
    """Branch that exists in a foreign version control system."""
263
259
 
264
260
 
265
261
class cmd_dpush(Command):
266
 
    """Push into a different VCS without any custom bzr metadata.
 
262
    __doc__ = """Push into a different VCS without any custom bzr metadata.
267
263
 
268
264
    This will afterwards rebase the local branch on the remote
269
265
    branch unless the --no-rebase option is used, in which case 
300
296
        except NoWorkingTree:
301
297
            source_branch = Branch.open(directory)
302
298
            source_wt = None
303
 
        if strict is None:
304
 
            strict = source_branch.get_config(
305
 
                ).get_user_option_as_bool('dpush_strict')
306
 
        if strict is None: strict = True # default value
307
 
        if strict and source_wt is not None:
308
 
            if (source_wt.has_changes()):
309
 
                raise errors.UncommittedChanges(
310
 
                    source_wt, more='Use --no-strict to force the push.')
311
 
            if source_wt.last_revision() != source_wt.branch.last_revision():
312
 
                # The tree has lost sync with its branch, there is little
313
 
                # chance that the user is aware of it but he can still force
314
 
                # the push with --no-strict
315
 
                raise errors.OutOfDateTree(
316
 
                    source_wt, more='Use --no-strict to force the push.')
 
299
        if source_wt is not None:
 
300
            source_wt.check_changed_or_out_of_date(
 
301
                strict, 'dpush_strict',
 
302
                more_error='Use --no-strict to force the push.',
 
303
                more_warning='Uncommitted changes will not be pushed.')
317
304
        stored_loc = source_branch.get_push_location()
318
305
        if location is None:
319
306
            if stored_loc is None: