/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/program.py

  • Committer: Tim Marston
  • Date: 2014-03-08 00:47:23 UTC
  • Revision ID: tim@ed.am-20140308004723-hkl3s2hobsblf72o
added diff command; moved all command to commands subdir; made stage-revert
handle ongoing deployment automatically (now that initial revno is known); made
verbose level incremental; detect obstructing conflicts in ConflictWalker;
handle files deleted from repo during copy-out (update)

Show diffs side-by-side

added added

removed removed

82
82
        def print_version( self ):
83
83
                print "stdhome " + self.version
84
84
                print
85
 
                print "Copyright (C) 2013 Tim Marston"
 
85
                print "Copyright (C) 2013 to 2014 Tim Marston"
86
86
                print
87
87
                #      01234567890123456789012345678901234567890123456789012345678901234567890123456789
88
88
                print "This program is free software, and you may use, modify and redistribute it"
111
111
                        return command
112
112
 
113
113
                # resolve aliases
114
 
                elif command == 'up':
115
 
                        return 'update'
116
 
                elif command == 'rm':
117
 
                        return 'remove'
 
114
                alias = {
 
115
                        'up': 'update',
 
116
                        'rm': 'remove',
 
117
                        'st': 'status',
 
118
                        'co': 'init',
 
119
                }.get( command, False )
 
120
                if alias: return alias
118
121
 
119
122
                # invalid
120
 
                else:
121
 
                        return None
 
123
                return None
122
124
 
123
125
 
124
126
        def get_command_argument( self, args ):
170
172
                        self.print_usage( "bad command" )
171
173
 
172
174
                # calculate module and class name
 
175
                class_name = module_name = ''
173
176
                bits = the.command.split( '-' )
174
 
                class_name = 'Command'
175
 
                module_name = 'command'
176
177
                for bit in bits:
177
178
                        class_name += bit[ 0 ].upper() + bit[ 1 : ]
178
 
                        module_name += '_' + bit
 
179
                        if module_name: module_name += '_'
 
180
                        module_name += bit
 
181
                class_name += 'Command'
179
182
 
180
183
                # import module and instantiate the class
181
 
                module = __import__( 'stdhome.' + module_name,
 
184
                module = __import__( 'stdhome.command.' + module_name,
182
185
                                                         fromlist = [ class_name ] )
183
186
                instance = getattr( module, class_name )()
184
187
 
190
193
                        self.print_usage( e.msg )
191
194
                except Vcs.VcsError as e:
192
195
                        message = e.msg.rstrip()
193
 
                        if the.verbose and hasattr( e, 'output' ) and e.output:
 
196
                        if the.verbose:
194
197
                                message += '\n\nOUTPUT:\n' + e.output.rstrip()
195
198
                        self.die( message )
196
199
                except self.FatalError as e: