Changeset 12 in tailor
- Timestamp:
- 06/19/04 01:51:47 (9 years ago)
- Hash name:
- 20040618235147-97f81-4ee191bc82973330cdc14d1f7ae12afc58c63b26
- Location:
- vcpx
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vcpx/cvs.py
r11 r12 12 12 from target import SyncronizableTargetWorkingDir 13 13 14 14 15 class CvsPsLog(SystemCommand): 15 COMMAND = "cvsps -u -b%(branch)s" 16 16 COMMAND = "cvsps %(update)s-b%(branch)s" 17 18 def __call__(self, output=None, dry_run=False, **kwargs): 19 update = kwargs.get('update', '') 20 if update: 21 update = '-u ' 22 kwargs['update'] = update 23 24 return SystemCommand.__call__(self, output=output, 25 dry_run=dry_run, **kwargs) 26 27 17 28 class CvsUpdate(SystemCommand): 18 29 COMMAND = 'cvs %(dry)supdate -d -r%(revision)s %(entry)s2>&1' … … 26 37 return SystemCommand.__call__(self, output=output, 27 38 dry_run=False, **kwargs) 28 39 40 41 class CvsAdd(SystemCommand): 42 COMMAND = "cvs add %(entry)s" 43 44 45 class CvsCommit(SystemCommand): 46 COMMAND = "cvs ci -F %(logfile)s %(entries)s" 47 48 49 class CvsRemove(SystemCommand): 50 COMMAND = "cvs remove %(entry)s" 51 52 29 53 from textwrap import TextWrapper 30 54 from re import compile, MULTILINE … … 48 72 49 73 50 class CvsSourceWorkingDir(UpdatableSourceWorkingDir): 51 def _getLastSyncedRevision(self): 74 class CvsWorkingDir(UpdatableSourceWorkingDir, 75 SyncronizableTargetWorkingDir): 76 77 ## UpdatableSourceWorkingDir 78 79 def __getLastUpstreamRevision(self, root): 52 80 from os.path import join, exists 53 81 54 fname = join( self.root, 'CVS', 'last-synced-revision')82 fname = join(root, 'CVS', 'last-synced-revision') 55 83 if exists(fname): 56 84 return open(fname).read() 57 85 58 def _ setLastSyncedRevision(self, revision):86 def __setLastUpstreamRevision(self, root, revision): 59 87 from os.path import join, exists 60 88 61 fname = join( self.root, 'CVS', 'last-synced-revision')89 fname = join(root, 'CVS', 'last-synced-revision') 62 90 open(fname, 'w').write(revision) 63 91 64 def _getUpstreamChangesets(self, startfrom_rev=None): 65 cvsps = CvsPsLog(working_dir=self.root) 66 92 def _getUpstreamChangesets(self, root): 93 cvsps = CvsPsLog(update=True, working_dir=root) 94 95 startfrom_rev = self.__getLastUpstreamRevision(root) 67 96 if startfrom_rev: 68 97 startfrom_rev = int(startfrom_rev) … … 75 104 else: 76 105 branch="HEAD" 77 78 for cs in self.__enumerateChangesets(cvsps(output=True,branch=branch)): 106 107 log = cvsps(output=True, branch=branch) 108 for cs in self.__enumerateChangesets(log): 79 109 if not startfrom_rev or (startfrom_rev<=cs.revision): 80 110 self.changesets.append(cs) … … 153 183 yield Changeset(**pset) 154 184 155 def _applyChangeset(self, changeset):156 cvsup = CvsUpdate(working_dir= self.root)185 def _applyChangeset(self, root, changeset): 186 cvsup = CvsUpdate(working_dir=root) 157 187 for e in cs.entries: 158 188 cvsup(entry=e.name, revision=e.new_revision) 159 160 class CvsAdd(SystemCommand): 161 COMMAND = "cvs add %(entry)s" 162 163 164 class CvsCommit(SystemCommand): 165 COMMAND = "cvs ci -F %(logfile)s %(entries)s" 166 167 168 class CvsRemove(SystemCommand): 169 COMMAND = "cvs remove %(entry)s" 170 171 172 class CvsTargetWorkingDir(SyncronizableTargetWorkingDir): 189 self.__setLastUpstreamRevision(root, revision) 190 191 ## SyncronizableTargetWorkingDir 192 173 193 def _addEntry(self, root, entry): 174 194 """ … … 176 196 """ 177 197 198 from os.path import split, join, exists 199 200 basedir = split(entry)[0] 201 if basedir and not exists(join(basedir, 'CVS')): 202 self._addEntry(root, basedir) 203 178 204 c = CvsAdd(working_dir=root) 179 205 c(entry=entry) 180 206 181 def _commit(self, root, remark, changelog, entries):207 def _commit(self, root, author, remark, changelog, entries): 182 208 """ 183 209 Commit the changeset. -
vcpx/source.py
r11 r12 15 15 16 16 class UpdatableSourceWorkingDir(object): 17 """This is an abstract working dir. Subclasses MUST override ALL18 the se methods."""17 """This is an abstract working dir. Subclasses MUST override at least 18 the _underscoredMethods.""" 19 19 20 def _getLastSyncedRevision(self, root): 21 """ 22 Return the last synced revision. 23 24 Since this info must be stored somewhere, it's up to the target 25 storage how/where it best fits; as such, this method must be 26 overridden by subclasses. 27 """ 28 29 raise "SubclassResponsibility" 30 31 def _setLastSyncedRevision(self, root, revision): 32 """ 33 Record the last synced revision. 34 35 Since this info must be stored somewhere, it's up to the target 36 storage how/where it best fits; as such, this method must be 37 overridden by subclasses. 38 """ 39 40 raise "SubclassResponsibility" 41 42 def _getUpstreamChangesets(self, root, startfrom_rev=None): 20 def _getUpstreamChangesets(self, root): 43 21 """ 44 22 Do the actual work of fetching the upstream changeset. … … 47 25 """ 48 26 49 raise " SubclassResponsibility"27 raise "%s should override this method" % self.__class__ 50 28 51 29 def _applyChangeset(self, root, changeset): 52 30 """ 53 Do the actual work of applying the changeset to the workin kcopy.31 Do the actual work of applying the changeset to the working copy. 54 32 """ 55 33 56 raise " SubclassResponsibility"34 raise "%s should override this method" % self.__class__ 57 35 58 36 def collectUpstreamChangesets(self, root): … … 63 41 """ 64 42 65 lastrev = self._getLastSyncedRevision(root) 66 return self._getUpstreamChangesets(self, root, startfrom_rev=lastrev) 43 self._getUpstreamChangesets(self, root) 67 44 68 45 def applyUpstreamChangesets(self, root, changesets): -
vcpx/target.py
r11 r12 15 15 class SyncronizableTargetWorkingDir(object): 16 16 """ 17 This is an abstract working dir. Subclasses MUST override ALL18 the se methods.17 This is an abstract working dir. Subclasses MUST override at least 18 the _underscoredMethods. 19 19 """ 20 20 … … 41 41 changelog = changeset.log 42 42 entries = [e.name for e in changeset.entries] 43 self._commit(root, remark, changelog, entries)43 self._commit(root, changeset.author, remark, changelog, entries) 44 44 45 45 def _addEntry(self, root, entry): … … 50 50 raise "%s should override this method" % self.__class__ 51 51 52 def _commit(self, root, remark, changelog, entries):52 def _commit(self, root, author, remark, changelog, entries): 53 53 """ 54 54 Commit the changeset.
Note: See TracChangeset
for help on using the changeset viewer.
