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
29
class StatusCommand( Command ):
24
from deployment import Deployment
25
from walker.status_walker import StatusWalker
32
35
def print_help( self ):
33
print "Usage: " + the.program.name + " status [--repo=REPO] [FILE]..."
36
print "Usage: " + the.program.name + " status [--repo=REPO]"
35
38
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789
36
39
print "Show the state of files in the local repository (including modifications and"
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."
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 )
67
elif opt in [ '--verbose', '-v' ]:
64
69
elif opt == "--help":
67
72
# discard first argument (the command)
70
75
# remaining arguments
77
raise the.program.UsageError( 'too many arguments' )
76
82
# set up repo and check it exists
83
the.set_repo( self.repo )
77
84
the.repo.check_dir_exists()
80
files = self.expand_files( self.files )
84
88
# initialise deployment and check if it's ongoing
85
89
deployment = Deployment()
86
90
if deployment.is_ongoing():
87
print "deployment ongoing"
89
92
# check for conflicts in repo
90
93
files = the.repo.vcs.get_conflicts()
92
message += 'conflicts in %s:\n %s\n' % \
95
message += 'Conflicts in %s:\n %s\n' % \
93
96
( the.repo.name, '\n '.join( files ) )
95
98
# get deployment conflicts
96
99
conflicts = deployment.get_conflicts()
98
message += 'deployment conflicts:\n %s\n' % \
101
message += 'Deployment conflicts:\n %s\n' % \
99
102
'\n '.join( conflicts )
104
walker = StatusWalker( files if files else None )
107
walker = StatusWalker()
106
109
if walker.modified:
107
message += 'modified:\n %s\n' % \
110
message += 'Modified:\n %s\n' % \
108
111
'\n '.join( walker.modified )
109
112
if walker.missing:
110
message += 'missing:\n %s\n' % \
113
message += 'Missing:\n %s\n' % \
111
114
'\n '.join( walker.missing )
112
115
if walker.changed:
113
message += 'kind changed:\n %s\n' % \
116
message += 'Type changed:\n %s\n' % \
114
117
'\n '.join( walker.changed )