source: tailor/vcpx/source.py @ 14

Revision 14, 2.3 KB checked in by lele@…, 9 years ago (diff)

Preliminary bootstrap functionalities

Line 
1#! /usr/bin/python
2# -*- mode: python; coding: utf-8 -*-
3# :Progetto: vcpx -- Updatable VC working directory
4# :Creato:   mer 09 giu 2004 13:55:35 CEST
5# :Autore:   Lele Gaifax <lele@nautilus.homeip.net>
6#
7
8"""
9Updatable sources are the simplest abstract wrappers around a working
10directory under some kind of version control system.
11"""
12
13__docformat__ = 'reStructuredText'
14
15
16class UpdatableSourceWorkingDir(object):
17    """This is an abstract working dir. Subclasses MUST override at least
18       the _underscoredMethods."""
19
20    def _getUpstreamChangesets(self, root):
21        """
22        Do the actual work of fetching the upstream changeset.
23       
24        This method must be overridden by subclasses.
25        """
26
27        raise "%s should override this method" % self.__class__
28       
29    def _applyChangeset(self, root, changeset):
30        """
31        Do the actual work of applying the changeset to the working copy.
32        """
33
34        raise "%s should override this method" % self.__class__
35
36    def collectUpstreamChangesets(self, root):
37        """
38        Query the upstream repository about what happened on the
39        sources since last sync, returning a sequence of Changesets
40        instances.
41        """
42
43        return self._getUpstreamChangesets(self, root)
44       
45    def applyUpstreamChangesets(self, root, changesets):
46        """
47        Apply the collected upstream changes.
48
49        Loop over the collected changesets, doing whatever is needed
50        to apply each one to the working dir.
51
52        Return a sequence (potentially empty!) of conflicts.
53        """
54
55        conflicts = []
56        for c in changesets:
57            res = self._applyChangeset(root, c)
58            if res:
59                conflicts.append((c, res))
60
61        return conflicts
62       
63    def checkoutUpstreamRevision(self, root, repository, revision):
64        """
65        Extract a working copy from a repository.
66        """
67
68        from os.path import split
69
70        basedir,module = split(root)
71       
72        self._checkoutUpstreamRevision(basedir, repository, module, revision)
73       
74    def _checkoutUpstreamRevision(self, basedir, repository, module, revision):
75        """
76        Concretely do the checkout of the upstream revision.
77        """
78       
79        raise "%s should override this method" % self.__class__
Note: See TracBrowser for help on using the repository browser.