forked from charleso/git-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clearcase.py
54 lines (51 loc) · 1.8 KB
/
clearcase.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
from common import *
class Clearcase:
def rebase(self):
pass
def mkact(self, comment):
pass
def rmactivity(self):
pass
def commit(self):
pass
def getCommentFmt(self):
return '%Nc'
def getRealComment(self, comment):
return comment
class UCM:
def __init__(self):
self.activities = {}
def rebase(self):
out = cc_exec(['rebase', '-rec', '-f'])
if not out.startswith('No rebase needed'):
debug(out)
debug(cc_exec(['rebase', '-complete']))
def mkact(self, comment):
self.rebase()
self.activity = self._getActivities().get(comment)
if self.activity:
cc_exec(['setact', self.activity])
return
_comment = cc_exec(['mkact', '-f', '-headline', comment])
_comment = _comment.split('\n')[0]
self.activity = _comment[_comment.find('"')+1:_comment.rfind('"')]
self._getActivities()[comment] = self.activity
def rmactivity(self):
cc_exec(['setact', '-none'])
cc_exec(['rmactivity', '-f', self.activity])
def commit(self):
cc_exec(['setact', '-none'])
debug(cc_exec(['deliver','-f']))
debug(cc_exec(['deliver', '-com', '-f']))
def getCommentFmt(self):
return '%[activity]p'
def getRealComment(self, activity):
return cc_exec(['lsactivity', '-fmt', '%[headline]p', activity]) if activity else activity
def _getActivities(self):
if not self.activities:
for line in cc_exec(['lsactivity', '-fmt', '%[headline]p|%n\n']).split('\n'):
if line:
line = line.strip().split('|')
self.activities[line[0]] = line[1]
return self.activities
cc = (UCM if cfg.get('type') == 'UCM' else Clearcase)();