~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Martin von Gagern
  • Date: 2010-04-22 06:25:26 UTC
  • mfrom: (0.27.39 trunk)
  • mto: This revision was merged to the branch mainline in revision 5240.
  • Revision ID: martin.vgagern@gmx.net-20100422062526-4lyy2yoor932u80w
Join bzr-bash-completion plugin into core bzr tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 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
20
20
 
21
21
from bzrlib.branch import (
22
22
    Branch,
 
23
    InterBranch,
23
24
    )
24
25
from bzrlib.commands import Command, Option
25
26
from bzrlib.repository import Repository
28
29
lazy_import(globals(), """
29
30
from bzrlib import (
30
31
    errors,
 
32
    osutils,
31
33
    registry,
32
34
    transform,
33
35
    )
257
259
 
258
260
 
259
261
class cmd_dpush(Command):
260
 
    __doc__ = """Push into a different VCS without any custom bzr metadata.
 
262
    """Push into a different VCS without any custom bzr metadata.
261
263
 
262
264
    This will afterwards rebase the local branch on the remote
263
265
    branch unless the --no-rebase option is used, in which case 
294
296
        except NoWorkingTree:
295
297
            source_branch = Branch.open(directory)
296
298
            source_wt = None
297
 
        if source_wt is not None:
298
 
            source_wt.check_changed_or_out_of_date(
299
 
                strict, 'dpush_strict',
300
 
                more_error='Use --no-strict to force the push.',
301
 
                more_warning='Uncommitted changes will not be pushed.')
 
299
        if strict is None:
 
300
            strict = source_branch.get_config(
 
301
                ).get_user_option_as_bool('dpush_strict')
 
302
        if strict is None: strict = True # default value
 
303
        if strict and source_wt is not None:
 
304
            if (source_wt.has_changes()):
 
305
                raise errors.UncommittedChanges(
 
306
                    source_wt, more='Use --no-strict to force the push.')
 
307
            if source_wt.last_revision() != source_wt.branch.last_revision():
 
308
                # The tree has lost sync with its branch, there is little
 
309
                # chance that the user is aware of it but he can still force
 
310
                # the push with --no-strict
 
311
                raise errors.OutOfDateTree(
 
312
                    source_wt, more='Use --no-strict to force the push.')
302
313
        stored_loc = source_branch.get_push_location()
303
314
        if location is None:
304
315
            if stored_loc is None:
314
325
        target_branch.lock_write()
315
326
        try:
316
327
            try:
317
 
                push_result = source_branch.push(target_branch, lossy=True)
 
328
                push_result = source_branch.lossy_push(target_branch)
318
329
            except errors.LossyPushToSameVCS:
319
330
                raise BzrCommandError("%r and %r are in the same VCS, lossy "
320
331
                    "push not necessary. Please use regular push." %
337
348
            push_result.report(self.outf)
338
349
        finally:
339
350
            target_branch.unlock()
 
351
 
 
352
 
 
353
class InterToForeignBranch(InterBranch):
 
354
 
 
355
    def lossy_push(self, stop_revision=None):
 
356
        """Push deltas into another branch.
 
357
 
 
358
        :note: This does not, like push, retain the revision ids from 
 
359
            the source branch and will, rather than adding bzr-specific 
 
360
            metadata, push only those semantics of the revision that can be 
 
361
            natively represented by this branch' VCS.
 
362
 
 
363
        :param target: Target branch
 
364
        :param stop_revision: Revision to push, defaults to last revision.
 
365
        :return: BranchPushResult with an extra member revidmap: 
 
366
            A dictionary mapping revision ids from the target branch 
 
367
            to new revision ids in the target branch, for each 
 
368
            revision that was pushed.
 
369
        """
 
370
        raise NotImplementedError(self.lossy_push)