source: tailor/vcpx/dualwd.py @ 380

Revision 380, 2.8 KB checked in by lele@…, 8 years ago (diff)

Do not suggest every source is a script by itself

Line 
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"""
9The easiest way to propagate changes from one VC control system to one
10of an another kind is having a single directory containing a live
11working copy shared between the two VC systems.
12
13This module implements `DualWorkingDir`, which instances have a
14`source` and `target` properties offering the right capabilities to do
15the job.
16"""
17
18__docformat__ = 'reStructuredText'
19
20from source import UpdatableSourceWorkingDir, InvocationError
21from target import SyncronizableTargetWorkingDir
22from svn import SvnWorkingDir
23from cvs import CvsWorkingDir
24from cvsps import CvspsWorkingDir
25from darcs import DarcsWorkingDir
26from monotone import MonotoneWorkingDir
27from cdv import CdvWorkingDir
28from bzr import BzrWorkingDir
29from hg import HgWorkingDir
30
31class 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)
Note: See TracBrowser for help on using the repository browser.