~ubuntu-branches/ubuntu/saucy/xxdiff/saucy

« back to all changes in this revision

Viewing changes to tools/clearcase/xxcleartool

  • Committer: Bazaar Package Importer
  • Author(s): Tomas Pospisek
  • Date: 2006-12-03 21:41:08 UTC
  • mfrom: (3.1.3 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203214108-l7d3sleqmf1uu1is
Tags: 1:3.2-2
* oops /usr/man slipped in again. Re-re-re-moving it.
* fix doc-base reference problems reported by lintian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
#******************************************************************************\
3
 
#* $Id: xxcleartool,v 1.7 2003/12/25 21:32:56 blais Exp $
4
 
#* $Date: 2003/12/25 21:32:56 $
 
3
#* $Id: xxcleartool 682 2003-12-25 21:32:57Z blais $
 
4
#* $Date: 2003-12-25 16:32:57 -0500 (Thu, 25 Dec 2003) $
5
5
#*
6
6
#* Copyright (C) 2001 Martin Blais <blais@furius.ca>
7
7
#*
31
31
company-specific, send a suggestion to the author at blais@furius.ca.
32
32
"""
33
33
 
34
 
__version__ = "$Revision: 1.7 $"
 
34
__version__ = "$Revision: 682 $"
35
35
__author__ = "Martin Blais <blais@furius.ca>"
36
 
__state__ = "$State: Exp $"
37
 
# $Source: /u/blais/cvsroot/xxdiff/tools/clearcase/xxcleartool,v $
 
36
__state__ = "$State$"
 
37
# $Source$
38
38
 
39
39
#===============================================================================
40
40
# EXTERNAL DECLARATIONS
53
53
 
54
54
#-------------------------------------------------------------------------------
55
55
#
56
 
def runDiff( cargs ):
 
56
def runDiff(cargs):
57
57
    xargs = string.split( gopts.xxdiffargs ) + cargs
58
58
    run( gopts.xxdiff, xargs )
59
59
    if not gopts.nowait:
61
61
 
62
62
#-------------------------------------------------------------------------------
63
63
#
64
 
def run( program, args, stdinn = None ):
 
64
def run(program, args, stdinn = None):
65
65
    command = string.join( [ program ] + filter( lambda x: x, args ) )
66
66
 
67
67
    if gopts.debug or gopts.fake:
82
82
 
83
83
#-------------------------------------------------------------------------------
84
84
#
85
 
def runCt( cmd ):
 
85
def runCt(cmd):
86
86
    if gopts.debug or gopts.fake:
87
87
        print "running: cleartool", cmd 
88
88
    if gopts.fake:
93
93
 
94
94
#-------------------------------------------------------------------------------
95
95
#
96
 
def checkEqualFiles( files ):
 
96
def checkEqualFiles(files):
97
97
    """Compares filename to make sure that no two of them are the same."""
98
98
    # FIXME todo
99
99
    pass
112
112
 
113
113
    _mre = re.compile( '([^@]*)@@(.*)' )
114
114
 
115
 
    def __init__( self, origname ):
 
115
    def __init__(self, origname):
116
116
        self.fullname = origname
117
117
        ( self.filename, self.rev ) = self.parseName( origname )
118
118
        self.rev_cur = None
121
121
        self.rev_latest = None
122
122
        self.checkedout = None
123
123
 
124
 
    def dump( self ):
 
124
    def dump(self):
125
125
        print
126
126
        print "current", self.getCurrentRevision()
127
127
        print "previous", self.getPreviousRevision()
137
137
        print "checkedout", self.checkedout
138
138
        print 
139
139
    
140
 
    def parseName( self, fname ):
 
140
    def parseName(self, fname):
141
141
        """Parses extended names and returns a list of ( filename, revision )
142
142
pairs."""
143
143
        mo = CmFile._mre.match( fname )
145
145
            return mo.groups()
146
146
        return [fname, None]
147
147
 
148
 
    def isCheckedOut( self ):
 
148
    def isCheckedOut(self):
149
149
        self.getCurrentRevision()
150
150
        return self.checkedout
151
151
 
152
 
    def getCurrent( self ):
 
152
    def getCurrent(self):
153
153
        rev_cur = self.getCurrentRevision()
154
154
        if rev_cur:
155
155
            return self.filename + '@@' + rev_cur
156
156
        return self.filename
157
157
 
158
 
    def getCurrentRevision( self ):
 
158
    def getCurrentRevision(self):
159
159
        """Gets the current revision."""
160
160
        if not self.rev_cur:
161
161
            out = runCt( ' describe -s ' + self.filename  )
167
167
                    self.checkedout = 1
168
168
        return self.rev_cur
169
169
 
170
 
    def getPrevious( self ):
 
170
    def getPrevious(self):
171
171
        return self.filename + '@@' + self.getPreviousRevision()
172
172
 
173
 
    def getPreviousRevision( self ):
 
173
    def getPreviousRevision(self):
174
174
        """Gets the previous revision."""
175
175
        if not self.rev_pre:
176
176
            preout = runCt( ' describe -s -pre ' + self.filename )
177
177
            self.rev_pre = preout
178
178
        return self.rev_pre
179
179
 
180
 
    def getAncestorRevision( self ):
 
180
    def getAncestorRevision(self):
181
181
        """Gets the ancestor revision."""
182
182
        if not self.rev_anc:
183
183
            self.rev_anc = self.getAncestorRevisionFile( self.fullname )
184
184
        return self.rev_anc
185
185
 
186
 
    def getAncestorRevisionFile( self, filename ):
 
186
    def getAncestorRevisionFile(self, filename):
187
187
        """Gets the ancestor revision of a particular file."""
188
188
        out = runCt( ' describe -s -anc ' + \
189
189
                     filename + ' ' + self.getMainLatestSimple() )
192
192
            return mo.group( 2 )
193
193
        return None
194
194
 
195
 
    def getAncestor( self ):
 
195
    def getAncestor(self):
196
196
        return self.filename + '@@' + self.getAncestorRevision()
197
197
 
198
 
    def getMainLatestSimple( self ):
 
198
    def getMainLatestSimple(self):
199
199
        return self.filename + '@@/main/LATEST'
200
200
 
201
 
    def getMainLatest( self ):
 
201
    def getMainLatest(self):
202
202
        return self.filename + '@@' + self.getMainLatestRevision()
203
203
 
204
 
    def getMainLatestRevision( self ):
 
204
    def getMainLatestRevision(self):
205
205
        """Gets the revision for the latest in the main branch."""
206
206
        if not self.rev_latest:
207
207
            out = runCt( ' describe -s ' + self.getMainLatestSimple() )
221
221
 
222
222
    FIXME do doc."""
223
223
    
224
 
    def __init__( self ):
 
224
    def __init__(self):
225
225
        self.child_stdin = None
226
226
 
227
 
    def getFiles( self, names ):
 
227
    def getFiles(self, names):
228
228
        files = map( lambda x: CmFile(x), names )
229
229
        return files
230
230
        
242
242
 
243
243
    name = 'diff'
244
244
 
245
 
    def __init__( self ):
 
245
    def __init__(self):
246
246
        ExtCmdBase.__init__( self )
247
247
 
248
 
    def execute( self, args ):
 
248
    def execute(self, args):
249
249
        args = self.getFiles( args )
250
250
        runDiff( map( lambda x: x.fullname, args ) )
251
251
 
263
263
 
264
264
    name = 'previous'
265
265
 
266
 
    def __init__( self ):
 
266
    def __init__(self):
267
267
        ExtCmdBase.__init__( self )
268
268
        
269
 
    def execute( self, args ):
 
269
    def execute(self, args):
270
270
        args = self.getFiles( args )
271
271
        for f in args:
272
272
            current = f.getCurrent()
295
295
    name = 'branch'
296
296
    optmap = []
297
297
 
298
 
    def __init__( self ):
 
298
    def __init__(self):
299
299
        ExtCmdBase.__init__( self )
300
300
 
301
 
    def execute( self, args ):
 
301
    def execute(self, args):
302
302
        args = self.getFiles( args )
303
303
        for f in args:
304
304
            current = f.getCurrent()
362
362
        ( 'latest', 'l', "If file is still checked out, don't bother showing ancestor." ),
363
363
        ]
364
364
 
365
 
    def __init__( self ):
 
365
    def __init__(self):
366
366
        ExtCmdBase.__init__( self )
367
367
 
368
 
    def execute( self, args ):
 
368
    def execute(self, args):
369
369
        args = self.getFiles( args )
370
370
 
371
371
        s = 0
458
458
    name = 'update'
459
459
    optmap = []
460
460
    
461
 
    def __init__( self ):
 
461
    def __init__(self):
462
462
        ExtCmdBase.__init__( self )
463
463
        
464
 
    def execute( self, args ):
 
464
    def execute(self, args):
465
465
        args = self.getFiles( args )
466
466
        pass
467
467
 
481
481
import distutils.fancy_getopt as fgetopt  # getopt()
482
482
from distutils.errors import DistutilsArgError
483
483
 
484
 
def parse_options_subcmds( optmap, subcmds=[] ):
 
484
def parse_options_subcmds(optmap, subcmds=[]):
485
485
 
486
486
    optmap = [
487
487
        ( 'help', 'h', "Prints help message." ),