/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: 2016-02-16 00:26:53 UTC
  • Revision ID: tim@ed.am-20160216002653-oa8dgponknyislg3
added home directory change reporting to CopyOutWalker; added --quiet option to
update, resolve, revert and init commands; replace use of re.match with
re.search for clarity (and fixed related bug in FileMatcher); added BzrVcs.run
command output when verbose >= 2

Show diffs side-by-side

added added

removed removed

29
29
class StatusCommand( Command ):
30
30
 
31
31
 
32
 
        def __init__( self ):
33
 
                self.repo = None
34
 
 
35
 
 
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]..."
38
34
                print
39
35
                #      01234567890123456789012345678901234567890123456789012345678901234567890123456789
40
36
                print "Show the state of files in the local repository (including modifications and"
42
38
                print
43
39
                print "This lists files in your home directory that have been modified and which differ"
44
40
                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."
 
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."
47
43
                print
48
44
                print "For help with adding modified files to the repository, type:"
49
45
                print "    " + the.program.name + " add --help"
61
57
                        [ "repo=", "verbose", "help" ] )
62
58
                for opt, optarg in opts:
63
59
                        if opt in [ '--repo', '-r' ]:
64
 
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
 
60
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
65
61
                                        raise the.program.FatalError(
66
62
                                                'invalid repository name: ' + optarg )
67
 
                                self.repo = optarg
68
 
                        elif opt in [ '--verbose', '-v' ]:
69
 
                                the.verbose += 1
 
63
                                the.repo = optarg
70
64
                        elif opt == "--help":
71
65
                                self.print_help()
72
 
                
 
66
 
73
67
                # discard first argument (the command)
74
68
                args.pop( 0 )
75
69
 
76
70
                # remaining arguments
77
 
                if len( args ):
78
 
                        raise the.program.UsageError( 'too many arguments' )
 
71
                self.files = args
79
72
 
80
73
 
81
74
        def run( self ):
82
75
 
83
76
                # set up repo and check it exists
84
 
                the.set_repo( self.repo )
85
77
                the.repo.check_dir_exists()
86
78
 
 
79
                # determine files
 
80
                files = self.expand_files( self.files )
 
81
 
87
82
                message = ''
88
83
 
89
84
                # initialise deployment and check if it's ongoing
90
85
                deployment = Deployment()
91
86
                if deployment.is_ongoing():
 
87
                        print "deployment ongoing"
92
88
 
93
89
                        # check for conflicts in repo
94
90
                        files = the.repo.vcs.get_conflicts()
95
91
                        if files:
96
 
                                message += 'Conflicts in %s:\n  %s\n' % \
 
92
                                message += 'conflicts in %s:\n  %s\n' % \
97
93
                                                   ( the.repo.name, '\n  '.join( files ) )
98
94
 
99
95
                        # get deployment conflicts
100
96
                        conflicts = deployment.get_conflicts()
101
97
                        if conflicts:
102
 
                                message += 'Deployment conflicts:\n  %s\n' % \
 
98
                                message += 'deployment conflicts:\n  %s\n' % \
103
99
                                                   '\n  '.join( conflicts )
104
100
 
105
101
                else:
106
102
 
107
103
                        # check status
108
 
                        walker = StatusWalker()
 
104
                        walker = StatusWalker( files if files else None )
109
105
                        walker.walk()
110
106
                        if walker.modified:
111
 
                                message += 'Modified:\n  %s\n' % \
 
107
                                message += 'modified:\n  %s\n' % \
112
108
                                                   '\n  '.join( walker.modified )
113
109
                        if walker.missing:
114
 
                                message += 'Missing:\n  %s\n' % \
 
110
                                message += 'missing:\n  %s\n' % \
115
111
                                                   '\n  '.join( walker.missing )
116
112
                        if walker.changed:
117
 
                                message += 'Type changed:\n  %s\n' % \
 
113
                                message += 'kind changed:\n  %s\n' % \
118
114
                                                   '\n  '.join( walker.changed )
119
115
 
120
116
                # show status