-
Notifications
You must be signed in to change notification settings - Fork 1
/
cvsRepo.py
109 lines (93 loc) · 3.77 KB
/
cvsRepo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import re
import sys
import os
import subprocess
#import Releaser
import Repo
from repo_defaults import *
from cvs_utils import *
from site_utils import *
from version_utils import *
class cvsError( Exception ):
pass
class cvsRepo( Repo.Repo ):
def __init__( self, url, branch=None, tag=None ):
super(cvsRepo, self).__init__( url, branch, tag )
self._version = ""
self._retcode = 0
self._cvsStub1 = DEF_cvs_STUB1
self._cvsStub2 = DEF_cvs_STUB2
self._cvsRepo = DEF_cvs_REPO
self._cvsTags = DEF_cvs_TAGS
self._prefix = determine_epics_site_top()
# def __repr__( self ):
# return "cvsRepo"
def __str__( self ):
strRep = super(cvsRepo, self).__str__()
strRep += "%s prefix: %s" % ( self.__class__.__name__, self._prefix if self._prefix else 'None' )
return strRep
def GetWorkingBranch( self ):
return cvsGetWorkingBranch()
def FindPackageRelease( packageSpec, tag, debug = False, verbose = False ):
(repo_url, repo_tag) = (None, None)
(packagePath, sep, packageName) = packageSpec.rpartition('/')
print("FindPackageRelease STUBBED: Need to find packagePath=%s, packageName=%s\n" % (packagePath, packageName))
return (repo_url, repo_tag)
def GetDefaultPackage( self, package, verbose=False ):
# TODO: Is this function necessary any more?
# Can we just return package?
# See if we're in a package directory
defaultPackage = None
( cvs_url, cvs_branch, cvs_tag ) = cvsGetWorkingBranch()
if not cvs_url:
print("Current directory is not an cvs working dir!")
return None
branchHead = cvs_url
( branchHead, branchTail ) = os.path.split( branchHead )
# Prepend the tail to the defaultPackage
if len(defaultPackage) == 0:
defaultPackage = branchTail
else:
defaultPackage = os.path.join( branchTail, defaultPackage )
if verbose:
print("package: ", package)
print("defaultPackage: ", defaultPackage)
print("self._branch: ", self._branch)
print("self._url: ", self._url)
print("cvs_url: ", cvs_url)
return defaultPackage
def CheckoutRelease( self, buildDir, verbose=False, dryRun=False ):
if verbose or dryRun:
print("Checking out: %s\nto build dir: %s ..." % ( self._url, buildDir ))
outputPipe = None
if verbose:
outputPipe = subprocess.PIPE
if dryRun:
print("CheckoutRelease: --dryRun--")
return
try:
cmdList = [ "cvs", "co", self._url, buildDir ]
subprocess.check_call( cmdList, stdout=outputPipe, stderr=outputPipe )
except RuntimeError:
raise Releaser.BuildError("CheckoutRelease: cvs co failed for %s %s" % ( self._url, buildDir ))
def RemoveTag( self, dryRun=True ):
print("RemoveTag: Removing %s release tag %s ..." % ( self._package[0], self._tag ))
if dryRun:
print("RemoveTag: --dryRun--")
return
cmdList = [ "cvs", "tag", "-d", self._tag ]
subprocess.check_call( cmdList )
print("Successfully removed release tag %s." % ( self._tag ))
def TagRelease( self, package=None, release=None, branch=None, message="", verbose=True, dryRun=False ):
if branch is None:
branch = self._branch
if release is None:
release = self._repo._tag
if dryRun:
print("--dryRun--", end=' ')
if verbose:
print("Tagging branch %s release %s ..." % ( branch, release ))
if dryRun:
return
cmdList = [ "cvs", "tag", release, branch ]
subprocess.check_call( cmdList )