source: tailor/vcpx/dualwd.py @ 15

Revision 15, 2.1 KB checked in by lele@…, 9 years ago (diff)

Dual working directories

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#
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
20class DualWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir):
21    """
22    Dual working directory, one that is under two different VC systems at
23    the same time.
24
25    This class reimplements the two interfaces, dispatching the right method
26    to the right instance.
27    """
28
29    def __init__(self, source_kind, target_kind):
30        self.source_kind = source_kind
31        self.target_kind = target_kind
32
33        ## XXX these need class registering machinery!
34       
35        self.source = source.get(source_kind.capitalize() + 'WorkingDir')()
36        self.target = target.get(source_kind.capitalize() + 'WorkingDir')()
37
38    ## UpdatableSourceWorkingDir
39       
40    def collectUpstreamChangesets(self, root):
41        return self.source._getUpstreamChangesets(self, root)
42
43    def applyUpstreamChangesets(self, root, changesets, replay=None):
44        return self.source.applyUpstreamChangesets(root, changesets,
45                                                   self.replayChangeset)
46       
47    def checkoutUpstreamRevision(self, root, repository, revision):
48        return self.source.checkoutUpstreamRevision(root, repository, revision)
49
50    ## SyncronizableTargetWorkingDir
51   
52    def initializeNewWorkingDir(self, root, repository, revision):
53        self.target.initializeNewWorkingDir(root, repository, revision)
54       
55    def commitChangeset(self, root, changeset):
56        self.target.commitChangeset(root, changeset)
57       
58    def replayChangeset(self, root, changeset):
59        self.target.replayChangeset(root, changeset)
60        self.target.commitChangeset(root, changeset)
61       
Note: See TracBrowser for help on using the repository browser.