| 1 | # -*- mode: python; coding: utf-8 -*- |
|---|
| 2 | # :Progetto: vcpx -- Dual working directory |
|---|
| 3 | # :Creato: dom 20 giu 2004 11:02:01 CEST |
|---|
| 4 | # :Autore: Lele Gaifax <lele@nautilus.homeip.net> |
|---|
| 5 | # :Licenza: GNU General Public License |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | """ |
|---|
| 9 | The easiest way to propagate changes from one VC control system to one |
|---|
| 10 | of an another kind is having a single directory containing a live |
|---|
| 11 | working copy shared between the two VC systems. |
|---|
| 12 | |
|---|
| 13 | This module implements `DualWorkingDir`, which instances have a |
|---|
| 14 | `source` and `target` properties offering the right capabilities to do |
|---|
| 15 | the job. |
|---|
| 16 | """ |
|---|
| 17 | |
|---|
| 18 | __docformat__ = 'reStructuredText' |
|---|
| 19 | |
|---|
| 20 | from source import UpdatableSourceWorkingDir, InvocationError |
|---|
| 21 | from target import SyncronizableTargetWorkingDir |
|---|
| 22 | from svn import SvnWorkingDir |
|---|
| 23 | from cvs import CvsWorkingDir |
|---|
| 24 | from cvsps import CvspsWorkingDir |
|---|
| 25 | from darcs import DarcsWorkingDir |
|---|
| 26 | from monotone import MonotoneWorkingDir |
|---|
| 27 | from cdv import CdvWorkingDir |
|---|
| 28 | from bzr import BzrWorkingDir |
|---|
| 29 | from hg import HgWorkingDir |
|---|
| 30 | |
|---|
| 31 | class DualWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir): |
|---|
| 32 | """ |
|---|
| 33 | Dual working directory, one that is under two different VC systems at |
|---|
| 34 | the same time. |
|---|
| 35 | |
|---|
| 36 | This class reimplements the two interfaces, dispatching the right method |
|---|
| 37 | to the right instance. |
|---|
| 38 | """ |
|---|
| 39 | |
|---|
| 40 | def __init__(self, source_kind, target_kind): |
|---|
| 41 | globs = globals() |
|---|
| 42 | |
|---|
| 43 | try: |
|---|
| 44 | self.source = globs[source_kind.capitalize() + 'WorkingDir']() |
|---|
| 45 | except KeyError, exp: |
|---|
| 46 | raise InvocationError("Unhandled source VCS kind: " + source_kind) |
|---|
| 47 | |
|---|
| 48 | try: |
|---|
| 49 | self.target = globs[target_kind.capitalize() + 'WorkingDir']() |
|---|
| 50 | except KeyError, exp: |
|---|
| 51 | raise InvocationError("Unhandled target VCS kind: " + target_kind) |
|---|
| 52 | |
|---|
| 53 | # UpdatableSourceWorkingDir |
|---|
| 54 | |
|---|
| 55 | self.getUpstreamChangesets = self.source.getUpstreamChangesets |
|---|
| 56 | self.checkoutUpstreamRevision = self.source.checkoutUpstreamRevision |
|---|
| 57 | |
|---|
| 58 | # SyncronizableTargetWorkingDir |
|---|
| 59 | |
|---|
| 60 | self.initializeNewWorkingDir = self.target.initializeNewWorkingDir |
|---|
| 61 | self.commitDelayedChangesets = self.target.commitDelayedChangesets |
|---|
| 62 | self.replayChangeset = self.target.replayChangeset |
|---|
| 63 | |
|---|
| 64 | def applyUpstreamChangesets(self, root, module, changesets, applyable=None, |
|---|
| 65 | replay=None, applied=None, logger=None, |
|---|
| 66 | delayed_commit=False): |
|---|
| 67 | return self.source.applyUpstreamChangesets(root, module, changesets, |
|---|
| 68 | replay=self.replayChangeset, |
|---|
| 69 | applyable=applyable, |
|---|
| 70 | applied=applied, |
|---|
| 71 | logger=logger, |
|---|
| 72 | delayed_commit=delayed_commit) |
|---|