~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 00:49:50 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909004950-43z4zdicb5u91iet
tweak quick reference naming to make it consistent with other PDFs

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
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
 
    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
 
125
    def __init__(self, mapping_registry):
136
126
        self.mapping_registry = mapping_registry
137
127
 
138
128
    def show_foreign_revid(self, foreign_revid):
143
133
        """
144
134
        return { }
145
135
 
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
136
 
156
137
class ForeignVcsRegistry(registry.Registry):
157
138
    """Registry for Foreign VCSes.
225
206
        """Get the default mapping for this repository."""
226
207
        raise NotImplementedError(self.get_default_mapping)
227
208
 
228
 
    def _get_inventory_xml(self, revision_id):
229
 
        """See Repository._get_inventory_xml()."""
230
 
        return self._serialise_inventory(self.get_inventory(revision_id))
 
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))
231
222
 
232
223
    def get_revision_xml(self, revision_id):
233
224
        """Return the XML representation of a revision.
280
271
    """
281
272
    hidden = True
282
273
    takes_args = ['location?']
283
 
    takes_options = [
284
 
        'remember',
285
 
        Option('directory',
286
 
               help='Branch to push from, '
287
 
               'rather than the one containing the working directory.',
288
 
               short_name='d',
289
 
               type=unicode,
290
 
               ),
291
 
        Option('no-rebase', help="Do not rebase after push."),
292
 
        Option('strict',
293
 
               help='Refuse to push if there are uncommitted changes in'
294
 
               ' the working tree, --no-strict disables the check.'),
295
 
        ]
 
274
    takes_options = ['remember', Option('directory',
 
275
            help='Branch to push from, '
 
276
                 'rather than the one containing the working directory.',
 
277
            short_name='d',
 
278
            type=unicode,
 
279
            ),
 
280
            Option('no-rebase', help="Do not rebase after push.")]
296
281
 
297
 
    def run(self, location=None, remember=False, directory=None,
298
 
            no_rebase=False, strict=None):
 
282
    def run(self, location=None, remember=False, directory=None, 
 
283
            no_rebase=False):
299
284
        from bzrlib import urlutils
300
285
        from bzrlib.bzrdir import BzrDir
301
286
        from bzrlib.errors import BzrCommandError, NoWorkingTree
 
287
        from bzrlib.trace import info
302
288
        from bzrlib.workingtree import WorkingTree
303
289
 
304
290
        if directory is None:
309
295
        except NoWorkingTree:
310
296
            source_branch = Branch.open(directory)
311
297
            source_wt = None
312
 
        if strict is None:
313
 
            strict = source_branch.get_config(
314
 
                ).get_user_option_as_bool('dpush_strict')
315
 
        if strict is None: strict = True # default value
316
 
        if strict and source_wt is not None:
317
 
            if (source_wt.has_changes()):
318
 
                raise errors.UncommittedChanges(
319
 
                    source_wt, more='Use --no-strict to force the push.')
320
 
            if source_wt.last_revision() != source_wt.branch.last_revision():
321
 
                # The tree has lost sync with its branch, there is little
322
 
                # chance that the user is aware of it but he can still force
323
 
                # the push with --no-strict
324
 
                raise errors.OutOfDateTree(
325
 
                    source_wt, more='Use --no-strict to force the push.')
326
298
        stored_loc = source_branch.get_push_location()
327
299
        if location is None:
328
300
            if stored_loc is None: