source: tailor/vcpx/dualwd.py @ 305

Revision 305, 3.2 KB checked in by lele@…, 8 years ago (diff)

Explicitly license everything under GPL

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