22
22
import sys, re, getopt
23
from command import Command
23
from .command import Command
24
24
import stdhome.the as the
25
25
from stdhome.deployment import Deployment
26
26
from stdhome.walker.status import StatusWalker
29
29
class StatusCommand( Command ):
36
32
def print_help( self ):
37
print "Usage: " + the.program.name + " status [--repo=REPO]"
33
print("Usage: " + the.program.name + " status [--repo=REPO] [FILE]...")
39
35
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789
40
print "Show the state of files in the local repository (including modifications and"
43
print "This lists files in your home directory that have been modified and which differ"
44
print "from those in the local repository. During an update that resulted in conflicts"
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."
48
print "For help with adding modified files to the repository, type:"
49
print " " + the.program.name + " add --help"
52
print " -r, --repo=REPO select the repo to check-out or create (defaults to 'home')"
53
print " -v, --verbose display information about what is being done"
54
print " --help display help and exit"
36
print("Show the state of files in your home directory (including modifications and")
39
print("This lists files in your home directory that have been modified and which differ")
40
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(" -r, --repo=REPO select the repo to check-out or create (defaults to 'home')")
46
print(" -v, --verbose display information about what is being done")
47
print(" --help display help and exit")
61
54
[ "repo=", "verbose", "help" ] )
62
55
for opt, optarg in opts:
63
56
if opt in [ '--repo', '-r' ]:
64
if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
57
if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
65
58
raise the.program.FatalError(
66
59
'invalid repository name: ' + optarg )
68
61
elif opt in [ '--verbose', '-v' ]:
70
63
elif opt == "--help":
73
66
# discard first argument (the command)
76
69
# remaining arguments
78
raise the.program.UsageError( 'too many arguments' )
83
75
# set up repo and check it exists
84
the.set_repo( self.repo )
85
76
the.repo.check_dir_exists()
79
files = self.expand_files( self.files )
89
83
# initialise deployment and check if it's ongoing
90
84
deployment = Deployment()
91
85
if deployment.is_ongoing():
86
print("deployment ongoing")
93
88
# check for conflicts in repo
94
89
files = the.repo.vcs.get_conflicts()