/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:10:31 UTC
  • Revision ID: tim@ed.am-20140226191031-elcqy5j09h2syn2j
moved copy-in, copy-out and deployment conflict checking to a set of "walkers";
bzr vcs back-end now parses affected files during update; deployment state now
includes affected files

Show diffs side-by-side

added added

removed removed

22
22
import sys, re, getopt
23
23
import the
24
24
from deployment import Deployment
 
25
from walker.status_walker import StatusWalker
25
26
 
26
27
 
27
28
class CommandStatus:
82
83
                the.set_repo( self.repo )
83
84
                the.repo.check_dir_exists()
84
85
 
 
86
                message = ''
 
87
 
 
88
                # initialise deployment and check if it's ongoing
85
89
                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
90
                if deployment.is_ongoing():
100
 
                        files = deployment.get_conflicts()
 
91
 
 
92
                        # check for conflicts in repo
 
93
                        files = the.repo.vcs.get_conflicts()
101
94
                        if files:
 
95
                                message += 'Conflicts in %s:\n  %s\n' % \
 
96
                                                   ( the.repo.name, '\n  '.join( files ) )
 
97
 
 
98
                        # get deployment conflicts
 
99
                        conflicts = deployment.get_conflicts()
 
100
                        if conflicts:
102
101
                                message += 'Deployment conflicts:\n  %s\n' % \
103
 
                                                   '\n  '.join( files )
 
102
                                                   '\n  '.join( conflicts )
 
103
 
 
104
                else:
 
105
 
 
106
                        # check status
 
107
                        walker = StatusWalker()
 
108
                        walker.walk()
 
109
                        if walker.modified:
 
110
                                message += 'Modified:\n  %s\n' % \
 
111
                                                   '\n  '.join( walker.modified )
 
112
                        if walker.missing:
 
113
                                message += 'Missing:\n  %s\n' % \
 
114
                                                   '\n  '.join( walker.missing )
 
115
                        if walker.changed:
 
116
                                message += 'Type changed:\n  %s\n' % \
 
117
                                                   '\n  '.join( walker.changed )
104
118
 
105
119
                # show status
106
120
                if message: print message.rstrip()