/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-03-12 22:36:44 UTC
  • Revision ID: tim@ed.am-20140312223644-9pehua402pww0op7
fixed incorrect variable name

Show diffs side-by-side

added added

removed removed

1
 
# command_status.py
 
1
# 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
 
import the
24
 
from deployment import Deployment
25
 
 
26
 
 
27
 
class CommandStatus:
 
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 ):
28
30
 
29
31
 
30
32
        def __init__( self ):
64
66
                                                'invalid repository name: ' + optarg )
65
67
                                self.repo = optarg
66
68
                        elif opt in [ '--verbose', '-v' ]:
67
 
                                the.verbose = True
 
69
                                the.verbose += 1
68
70
                        elif opt == "--help":
69
71
                                self.print_help()
70
72
                
82
84
                the.set_repo( self.repo )
83
85
                the.repo.check_dir_exists()
84
86
 
 
87
                message = ''
 
88
 
 
89
                # initialise deployment and check if it's ongoing
85
90
                deployment = Deployment()
86
 
                message = ''
87
 
 
88
 
                # check for differing files
89
 
                files = deployment.get_diffs()
90
 
                if files:
91
 
                        message += 'Modified files in %s\n  %s\n' % \
92
 
                                           ( the.fsdir, '\n  '.join( files ) )
93
 
 
94
 
                # check for conflicts
95
 
                files = the.repo.vcs.get_conflicts()
96
 
                if files:
97
 
                        message += 'Conflicts in %s:\n  %s\n' % \
98
 
                                           ( the.repo.dir, '\n  '.join( files ) )
99
91
                if deployment.is_ongoing():
100
 
                        files = deployment.get_conflicts()
 
92
 
 
93
                        # check for conflicts in repo
 
94
                        files = the.repo.vcs.get_conflicts()
101
95
                        if files:
 
96
                                message += 'Conflicts in %s:\n  %s\n' % \
 
97
                                                   ( the.repo.name, '\n  '.join( files ) )
 
98
 
 
99
                        # get deployment conflicts
 
100
                        conflicts = deployment.get_conflicts()
 
101
                        if conflicts:
102
102
                                message += 'Deployment conflicts:\n  %s\n' % \
103
 
                                                   '\n  '.join( files )
 
103
                                                   '\n  '.join( conflicts )
 
104
 
 
105
                else:
 
106
 
 
107
                        # check status
 
108
                        walker = StatusWalker()
 
109
                        walker.walk()
 
110
                        if walker.modified:
 
111
                                message += 'Modified:\n  %s\n' % \
 
112
                                                   '\n  '.join( walker.modified )
 
113
                        if walker.missing:
 
114
                                message += 'Missing:\n  %s\n' % \
 
115
                                                   '\n  '.join( walker.missing )
 
116
                        if walker.changed:
 
117
                                message += 'Type changed:\n  %s\n' % \
 
118
                                                   '\n  '.join( walker.changed )
104
119
 
105
120
                # show status
106
121
                if message: print message.rstrip()