/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-02-26 19:15:30 UTC
  • Revision ID: tim@ed.am-20140226191530-6x21vlwto2xx80cd
renamed updated_files to affected_files

Show diffs side-by-side

added added

removed removed

1
 
# status.py
 
1
# command_status.py
2
2
#
3
3
# Copyright (C) 2014 Tim Marston <tim@edm.am>
4
4
#
20
20
 
21
21
 
22
22
import sys, re, getopt
23
 
from command import Command
24
 
import stdhome.the as the
25
 
from stdhome.deployment import Deployment
26
 
from stdhome.walker.status import StatusWalker
27
 
 
28
 
 
29
 
class StatusCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
from walker.status_walker import StatusWalker
 
26
 
 
27
 
 
28
class CommandStatus:
 
29
 
 
30
 
 
31
        def __init__( self ):
 
32
                self.repo = None
30
33
 
31
34
 
32
35
        def print_help( self ):
38
41
                print
39
42
                print "This lists files in your home directory that have been modified and which differ"
40
43
                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."
 
44
                print "this also lists files which have conflicts in the local local respository, or"
 
45
                print "which can not be deployed due to conflicts with your home directory."
43
46
                print
44
47
                print "For help with adding modified files to the repository, type:"
45
48
                print "    " + the.program.name + " add --help"
60
63
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
61
64
                                        raise the.program.FatalError(
62
65
                                                'invalid repository name: ' + optarg )
63
 
                                the.repo = optarg
 
66
                                self.repo = optarg
64
67
                        elif opt in [ '--verbose', '-v' ]:
65
 
                                the.verbose += 1
 
68
                                the.verbose = True
66
69
                        elif opt == "--help":
67
70
                                self.print_help()
68
71
                
77
80
        def run( self ):
78
81
 
79
82
                # set up repo and check it exists
 
83
                the.set_repo( self.repo )
80
84
                the.repo.check_dir_exists()
81
85
 
82
86
                message = ''
88
92
                        # check for conflicts in repo
89
93
                        files = the.repo.vcs.get_conflicts()
90
94
                        if files:
91
 
                                message += 'conflicts in %s:\n  %s\n' % \
 
95
                                message += 'Conflicts in %s:\n  %s\n' % \
92
96
                                                   ( the.repo.name, '\n  '.join( files ) )
93
97
 
94
98
                        # get deployment conflicts
95
99
                        conflicts = deployment.get_conflicts()
96
100
                        if conflicts:
97
 
                                message += 'deployment conflicts:\n  %s\n' % \
 
101
                                message += 'Deployment conflicts:\n  %s\n' % \
98
102
                                                   '\n  '.join( conflicts )
99
103
 
100
104
                else:
103
107
                        walker = StatusWalker()
104
108
                        walker.walk()
105
109
                        if walker.modified:
106
 
                                message += 'modified:\n  %s\n' % \
 
110
                                message += 'Modified:\n  %s\n' % \
107
111
                                                   '\n  '.join( walker.modified )
108
112
                        if walker.missing:
109
 
                                message += 'missing:\n  %s\n' % \
 
113
                                message += 'Missing:\n  %s\n' % \
110
114
                                                   '\n  '.join( walker.missing )
111
115
                        if walker.changed:
112
 
                                message += 'kind changed:\n  %s\n' % \
 
116
                                message += 'Type changed:\n  %s\n' % \
113
117
                                                   '\n  '.join( walker.changed )
114
118
 
115
119
                # show status