/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: 2021-07-05 21:04:21 UTC
  • Revision ID: tim@ed.am-20210705210421-75rb9swyku2397lb
added stage-status to main help

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
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
30
30
 
31
31
 
32
32
        def print_help( self ):
33
 
                print "Usage: " + the.program.name + " status [--repo=REPO]"
34
 
                print
 
33
                print("Usage: " + the.program.name + " status [--repo=REPO] [FILE]...")
 
34
                print()
35
35
                #      01234567890123456789012345678901234567890123456789012345678901234567890123456789
36
 
                print "Show the state of files in the local repository (including modifications and"
37
 
                print "conflicts)."
38
 
                print
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."
43
 
                print
44
 
                print "For help with adding modified files to the repository, type:"
45
 
                print "    " + the.program.name + " add --help"
46
 
                print
47
 
                print "Options:"
48
 
                print "  -r, --repo=REPO  select the repo to check-out or create (defaults to 'home')"
49
 
                print "  -v, --verbose    display information about what is being done"
50
 
                print "      --help       display help and exit"
 
36
                print("Show the state of files in your home directory (including modifications and")
 
37
                print("conflicts).")
 
38
                print()
 
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.")
 
43
                print()
 
44
                print("Options:")
 
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")
51
48
                exit( 0 )
52
49
 
53
50
 
57
54
                        [ "repo=", "verbose", "help" ] )
58
55
                for opt, optarg in opts:
59
56
                        if opt in [ '--repo', '-r' ]:
60
 
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
 
57
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
61
58
                                        raise the.program.FatalError(
62
59
                                                'invalid repository name: ' + optarg )
63
60
                                the.repo = optarg
65
62
                                the.verbose += 1
66
63
                        elif opt == "--help":
67
64
                                self.print_help()
68
 
                
 
65
 
69
66
                # discard first argument (the command)
70
67
                args.pop( 0 )
71
68
 
72
69
                # remaining arguments
73
 
                if len( args ):
74
 
                        raise the.program.UsageError( 'too many arguments' )
 
70
                self.files = args
75
71
 
76
72
 
77
73
        def run( self ):
79
75
                # set up repo and check it exists
80
76
                the.repo.check_dir_exists()
81
77
 
 
78
                # determine files
 
79
                files = self.expand_files( self.files )
 
80
 
82
81
                message = ''
83
82
 
84
83
                # initialise deployment and check if it's ongoing
85
84
                deployment = Deployment()
86
85
                if deployment.is_ongoing():
87
 
                        print "deployment ongoing"
 
86
                        print("deployment ongoing")
88
87
 
89
88
                        # check for conflicts in repo
90
89
                        files = the.repo.vcs.get_conflicts()
101
100
                else:
102
101
 
103
102
                        # check status
104
 
                        walker = StatusWalker()
 
103
                        walker = StatusWalker( files if files else None )
105
104
                        walker.walk()
106
105
                        if walker.modified:
107
106
                                message += 'modified:\n  %s\n' % \
114
113
                                                   '\n  '.join( walker.changed )
115
114
 
116
115
                # show status
117
 
                if message: print message.rstrip()
 
116
                if message: print(message.rstrip())