~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
271
290
    """
272
291
    hidden = True
273
292
    takes_args = ['location?']
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.")]
 
293
    takes_options = [
 
294
        'remember',
 
295
        Option('directory',
 
296
               help='Branch to push from, '
 
297
               'rather than the one containing the working directory.',
 
298
               short_name='d',
 
299
               type=unicode,
 
300
               ),
 
301
        Option('no-rebase', help="Do not rebase after push."),
 
302
        Option('strict',
 
303
               help='Refuse to push if there are uncommitted changes in'
 
304
               ' the working tree, --no-strict disables the check.'),
 
305
        ]
281
306
 
282
 
    def run(self, location=None, remember=False, directory=None, 
283
 
            no_rebase=False):
 
307
    def run(self, location=None, remember=False, directory=None,
 
308
            no_rebase=False, strict=None):
284
309
        from bzrlib import urlutils
285
310
        from bzrlib.bzrdir import BzrDir
286
311
        from bzrlib.errors import BzrCommandError, NoWorkingTree
287
 
        from bzrlib.trace import info
288
312
        from bzrlib.workingtree import WorkingTree
289
313
 
290
314
        if directory is None:
295
319
        except NoWorkingTree:
296
320
            source_branch = Branch.open(directory)
297
321
            source_wt = None
 
322
        if strict is None:
 
323
            strict = source_branch.get_config(
 
324
                ).get_user_option_as_bool('dpush_strict')
 
325
        if strict is None: strict = True # default value
 
326
        if strict and source_wt is not None:
 
327
            if (source_wt.has_changes()):
 
328
                raise errors.UncommittedChanges(
 
329
                    source_wt, more='Use --no-strict to force the push.')
 
330
            if source_wt.last_revision() != source_wt.branch.last_revision():
 
331
                # The tree has lost sync with its branch, there is little
 
332
                # chance that the user is aware of it but he can still force
 
333
                # the push with --no-strict
 
334
                raise errors.OutOfDateTree(
 
335
                    source_wt, more='Use --no-strict to force the push.')
298
336
        stored_loc = source_branch.get_push_location()
299
337
        if location is None:
300
338
            if stored_loc is None: