/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: Jelmer Vernooij
  • Date: 2009-05-09 16:53:46 UTC
  • mto: This revision was merged to the branch mainline in revision 4363.
  • Revision ID: jelmer@samba.org-20090509165346-rt96a2xxa0r2qpfu
Move dpush onto an InterBranch object.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Foreign branch utilities."""
19
19
 
20
20
 
21
 
from bzrlib.branch import Branch
 
21
from bzrlib.branch import (
 
22
    Branch,
 
23
    InterBranch,
 
24
    )
22
25
from bzrlib.commands import Command, Option
23
26
from bzrlib.repository import Repository
24
27
from bzrlib.revision import Revision
253
256
        self.mapping = mapping
254
257
        super(ForeignBranch, self).__init__()
255
258
 
256
 
    def dpull(self, source, stop_revision=None):
257
 
        """Pull deltas from another branch.
258
 
 
259
 
        :note: This does not, like pull, retain the revision ids from 
260
 
            the source branch and will, rather than adding bzr-specific 
261
 
            metadata, push only those semantics of the revision that can be 
262
 
            natively represented by this branch' VCS.
263
 
 
264
 
        :param source: Source branch
265
 
        :param stop_revision: Revision to pull, defaults to last revision.
266
 
        :return: Dictionary mapping revision ids from the source branch 
267
 
            to new revision ids in the target branch, for each 
268
 
            revision that was pull.
269
 
        """
270
 
        raise NotImplementedError(self.dpull)
271
 
 
272
259
 
273
260
def update_workingtree_fileids(wt, target_tree):
274
261
    """Update the file ids in a working tree based on another tree.
340
327
 
341
328
        bzrdir = BzrDir.open(location)
342
329
        target_branch = bzrdir.open_branch()
343
 
        dpull = getattr(target_branch, "dpull", None)
344
 
        if dpull is None:
345
 
            raise BzrCommandError("%r is not a foreign branch, use "
346
 
                                  "regular push." % target_branch)
347
330
        target_branch.lock_write()
348
331
        try:
349
 
            revid_map = dpull(source_branch)
 
332
            revid_map = target_branch.dpush(source_branch)
350
333
            # We successfully created the target, remember it
351
334
            if source_branch.get_push_location() is None or remember:
352
335
                source_branch.set_push_location(target_branch.base)
364
347
                        source_wt.unlock()
365
348
        finally:
366
349
            target_branch.unlock()
 
350
 
 
351
 
 
352
class InterToForeignBranch(InterBranch):
 
353
 
 
354
    def dpush(self, stop_revision=None):
 
355
        """Push deltas from another branch.
 
356
 
 
357
        :note: This does not, like push, retain the revision ids from 
 
358
            the source branch and will, rather than adding bzr-specific 
 
359
            metadata, push only those semantics of the revision that can be 
 
360
            natively represented by this branch' VCS.
 
361
 
 
362
        :param target: Target branch
 
363
        :param stop_revision: Revision to push, defaults to last revision.
 
364
        :return: Dictionary mapping revision ids from the target branch 
 
365
            to new revision ids in the target branch, for each 
 
366
            revision that was pushed.
 
367
        """
 
368
        raise NotImplementedError(self.dpush)