/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: Canonical.com Patch Queue Manager
  • Date: 2009-10-19 10:59:16 UTC
  • mfrom: (4585.1.10 foreign-tests)
  • Revision ID: pqm@pqm.ubuntu.com-20091019105916-6z2jo34eqr6s0008
(Jelmer) Add infrastructure for testing foreign branch
        implementations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 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
124
124
 
125
125
    branch_format = None
126
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
 
127
    def __init__(self, mapping_registry):
136
128
        self.mapping_registry = mapping_registry
137
129
 
138
130
    def show_foreign_revid(self, foreign_revid):
143
135
        """
144
136
        return { }
145
137
 
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
 
 
155
138
 
156
139
class ForeignVcsRegistry(registry.Registry):
157
140
    """Registry for Foreign VCSes.
225
208
        """Get the default mapping for this repository."""
226
209
        raise NotImplementedError(self.get_default_mapping)
227
210
 
 
211
    def get_inventory_xml(self, revision_id):
 
212
        """See Repository.get_inventory_xml()."""
 
213
        return self.serialise_inventory(self.get_inventory(revision_id))
 
214
 
 
215
    def get_inventory_sha1(self, revision_id):
 
216
        """Get the sha1 for the XML representation of an inventory.
 
217
 
 
218
        :param revision_id: Revision id of the inventory for which to return
 
219
         the SHA1.
 
220
        :return: XML string
 
221
        """
 
222
 
 
223
        return osutils.sha_string(self.get_inventory_xml(revision_id))
 
224
 
 
225
    def get_revision_xml(self, revision_id):
 
226
        """Return the XML representation of a revision.
 
227
 
 
228
        :param revision_id: Revision for which to return the XML.
 
229
        :return: XML string
 
230
        """
 
231
        return self._serializer.write_revision_to_string(
 
232
            self.get_revision(revision_id))
 
233
 
228
234
 
229
235
class ForeignBranch(Branch):
230
236
    """Branch that exists in a foreign version control system."""
259
265
 
260
266
 
261
267
class cmd_dpush(Command):
262
 
    __doc__ = """Push into a different VCS without any custom bzr metadata.
 
268
    """Push into a different VCS without any custom bzr metadata.
263
269
 
264
270
    This will afterwards rebase the local branch on the remote
265
271
    branch unless the --no-rebase option is used, in which case 
296
302
        except NoWorkingTree:
297
303
            source_branch = Branch.open(directory)
298
304
            source_wt = None
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.')
 
305
        if strict is None:
 
306
            strict = source_branch.get_config(
 
307
                ).get_user_option_as_bool('dpush_strict')
 
308
        if strict is None: strict = True # default value
 
309
        if strict and source_wt is not None:
 
310
            if (source_wt.has_changes()):
 
311
                raise errors.UncommittedChanges(
 
312
                    source_wt, more='Use --no-strict to force the push.')
 
313
            if source_wt.last_revision() != source_wt.branch.last_revision():
 
314
                # The tree has lost sync with its branch, there is little
 
315
                # chance that the user is aware of it but he can still force
 
316
                # the push with --no-strict
 
317
                raise errors.OutOfDateTree(
 
318
                    source_wt, more='Use --no-strict to force the push.')
304
319
        stored_loc = source_branch.get_push_location()
305
320
        if location is None:
306
321
            if stored_loc is None: