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