| 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 | |
|---|
| 23 | IGNORED_METADIRS = [] |
|---|
| 24 | |
|---|
| 25 | class DualWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir): |
|---|
| 26 | """ |
|---|
| 27 | Dual working directory, one that is under two different VC systems at |
|---|
| 28 | the same time. |
|---|
| 29 | |
|---|
| 30 | This class reimplements the two interfaces, dispatching the right method |
|---|
| 31 | to the right backend. |
|---|
| 32 | """ |
|---|
| 33 | |
|---|
| 34 | def __init__(self, source_repo, target_repo): |
|---|
| 35 | global IGNORED_METADIRS |
|---|
| 36 | |
|---|
| 37 | self.source = source_repo.workingDir() |
|---|
| 38 | self.target = target_repo.workingDir() |
|---|
| 39 | |
|---|
| 40 | IGNORED_METADIRS = [source_repo.METADIR, target_repo.METADIR] |
|---|
| 41 | |
|---|
| 42 | # UpdatableSourceWorkingDir |
|---|
| 43 | |
|---|
| 44 | self.getPendingChangesets = self.source.getPendingChangesets |
|---|
| 45 | self.checkoutUpstreamRevision = self.source.checkoutUpstreamRevision |
|---|
| 46 | |
|---|
| 47 | # SyncronizableTargetWorkingDir |
|---|
| 48 | |
|---|
| 49 | self.prepareWorkingDirectory = self.target.prepareWorkingDirectory |
|---|
| 50 | self.importFirstRevision = self.target.importFirstRevision |
|---|
| 51 | self.replayChangeset = self.target.replayChangeset |
|---|
| 52 | |
|---|
| 53 | def setStateFile(self, state_file): |
|---|
| 54 | """ |
|---|
| 55 | Set the state file used to store the revision and pending changesets. |
|---|
| 56 | """ |
|---|
| 57 | |
|---|
| 58 | self.source.setStateFile(state_file) |
|---|
| 59 | self.target.setStateFile(state_file) |
|---|
| 60 | |
|---|
| 61 | def setLogfile(self, logfile): |
|---|
| 62 | """ |
|---|
| 63 | Set the name of the logfile, just to ignore it. |
|---|
| 64 | """ |
|---|
| 65 | |
|---|
| 66 | self.target.logfile = logfile |
|---|
| 67 | |
|---|
| 68 | def applyPendingChangesets(self, applyable=None, replay=None, applied=None): |
|---|
| 69 | return self.source.applyPendingChangesets(replay=self.replayChangeset, |
|---|
| 70 | applyable=applyable, |
|---|
| 71 | applied=applied) |
|---|