/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-04-18 14:52:41 UTC
  • Revision ID: tim@ed.am-20140418145241-gldwc2ey6d2gjv96
defaulted Walker.generate_walk_list() to act on the.repo.full_dir

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] [FILE]...")
34
 
                print()
 
33
                print "Usage: " + the.program.name + " status [--repo=REPO]"
 
34
                print
35
35
                #      01234567890123456789012345678901234567890123456789012345678901234567890123456789
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")
 
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"
48
51
                exit( 0 )
49
52
 
50
53
 
54
57
                        [ "repo=", "verbose", "help" ] )
55
58
                for opt, optarg in opts:
56
59
                        if opt in [ '--repo', '-r' ]:
57
 
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
 
60
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
58
61
                                        raise the.program.FatalError(
59
62
                                                'invalid repository name: ' + optarg )
60
63
                                the.repo = optarg
62
65
                                the.verbose += 1
63
66
                        elif opt == "--help":
64
67
                                self.print_help()
65
 
 
 
68
                
66
69
                # discard first argument (the command)
67
70
                args.pop( 0 )
68
71
 
69
72
                # remaining arguments
70
 
                self.files = args
 
73
                if len( args ):
 
74
                        raise the.program.UsageError( 'too many arguments' )
71
75
 
72
76
 
73
77
        def run( self ):
75
79
                # set up repo and check it exists
76
80
                the.repo.check_dir_exists()
77
81
 
78
 
                # determine files
79
 
                files = self.expand_files( self.files )
80
 
 
81
82
                message = ''
82
83
 
83
84
                # initialise deployment and check if it's ongoing
84
85
                deployment = Deployment()
85
86
                if deployment.is_ongoing():
86
 
                        print("deployment ongoing")
 
87
                        print "deployment ongoing"
87
88
 
88
89
                        # check for conflicts in repo
89
90
                        files = the.repo.vcs.get_conflicts()
100
101
                else:
101
102
 
102
103
                        # check status
103
 
                        walker = StatusWalker( files if files else None )
 
104
                        walker = StatusWalker()
104
105
                        walker.walk()
105
106
                        if walker.modified:
106
107
                                message += 'modified:\n  %s\n' % \
113
114
                                                   '\n  '.join( walker.changed )
114
115
 
115
116
                # show status
116
 
                if message: print(message.rstrip())
 
117
                if message: print message.rstrip()