/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/command/status.py

  • Committer: Tim Marston
  • Date: 2014-04-04 22:28:49 UTC
  • Revision ID: tim@ed.am-20140404222849-32apy1i949qaq2na
walker now passes Walker.File objects to process(), which includes file name,
type and the type of file it points to when it's a symlink

Show diffs side-by-side

added added

removed removed

29
29
class StatusCommand( Command ):
30
30
 
31
31
 
 
32
        def __init__( self ):
 
33
                self.repo = None
 
34
 
 
35
 
32
36
        def print_help( self ):
33
 
                print "Usage: " + the.program.name + " status [--repo=REPO] [FILE]..."
 
37
                print "Usage: " + the.program.name + " status [--repo=REPO]"
34
38
                print
35
39
                #      01234567890123456789012345678901234567890123456789012345678901234567890123456789
36
40
                print "Show the state of files in the local repository (including modifications and"
38
42
                print
39
43
                print "This lists files in your home directory that have been modified and which differ"
40
44
                print "from those in the local repository.  During an update that resulted in conflicts"
41
 
                print "this also lists files which have conflicts in the local respository, or which"
42
 
                print "can not be deployed due to conflicts with your home directory."
 
45
                print "this also lists files which have conflicts in the local local respository, or"
 
46
                print "which can not be deployed due to conflicts with your home directory."
43
47
                print
44
48
                print "For help with adding modified files to the repository, type:"
45
49
                print "    " + the.program.name + " add --help"
57
61
                        [ "repo=", "verbose", "help" ] )
58
62
                for opt, optarg in opts:
59
63
                        if opt in [ '--repo', '-r' ]:
60
 
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
 
64
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
61
65
                                        raise the.program.FatalError(
62
66
                                                'invalid repository name: ' + optarg )
63
 
                                the.repo = optarg
 
67
                                self.repo = optarg
64
68
                        elif opt in [ '--verbose', '-v' ]:
65
69
                                the.verbose += 1
66
70
                        elif opt == "--help":
67
71
                                self.print_help()
68
 
 
 
72
                
69
73
                # discard first argument (the command)
70
74
                args.pop( 0 )
71
75
 
72
76
                # remaining arguments
73
 
                self.files = args
 
77
                if len( args ):
 
78
                        raise the.program.UsageError( 'too many arguments' )
74
79
 
75
80
 
76
81
        def run( self ):
77
82
 
78
83
                # set up repo and check it exists
 
84
                the.set_repo( self.repo )
79
85
                the.repo.check_dir_exists()
80
86
 
81
 
                # determine files
82
 
                files = self.expand_files( self.files )
83
 
 
84
87
                message = ''
85
88
 
86
89
                # initialise deployment and check if it's ongoing
87
90
                deployment = Deployment()
88
91
                if deployment.is_ongoing():
89
 
                        print "deployment ongoing"
90
92
 
91
93
                        # check for conflicts in repo
92
94
                        files = the.repo.vcs.get_conflicts()
103
105
                else:
104
106
 
105
107
                        # check status
106
 
                        walker = StatusWalker( files if files else None )
 
108
                        walker = StatusWalker()
107
109
                        walker.walk()
108
110
                        if walker.modified:
109
111
                                message += 'modified:\n  %s\n' % \