/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-12-13 21:40:34 UTC
  • Revision ID: tim@ed.am-20161213214034-nd5t7ztnlrjd627i
fix add command and generic filename expansion/resolution to expend to
homedir-relative filename and absolute filename based on original filename, as
specified, rather than a fully, symlink-resolved filename.  So, e.g., if ~/bob
was a symlink to ~/fred, then ~/bob/a would resolve to the relative filename
bob/a, becuase it is inside the homedir (it would resolve to fred/a otherwise)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
 
32
32
        def print_help( self ):
33
 
                print "Usage: " + the.program.name + " status [--repo=REPO]"
 
33
                print "Usage: " + the.program.name + " status [--repo=REPO] [FILE]..."
34
34
                print
35
35
                #      01234567890123456789012345678901234567890123456789012345678901234567890123456789
36
36
                print "Show the state of files in the local repository (including modifications and"
57
57
                        [ "repo=", "verbose", "help" ] )
58
58
                for opt, optarg in opts:
59
59
                        if opt in [ '--repo', '-r' ]:
60
 
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
 
60
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
61
61
                                        raise the.program.FatalError(
62
62
                                                'invalid repository name: ' + optarg )
63
63
                                the.repo = optarg
65
65
                                the.verbose += 1
66
66
                        elif opt == "--help":
67
67
                                self.print_help()
68
 
                
 
68
 
69
69
                # discard first argument (the command)
70
70
                args.pop( 0 )
71
71
 
72
72
                # remaining arguments
73
 
                if len( args ):
74
 
                        raise the.program.UsageError( 'too many arguments' )
 
73
                self.files = args
75
74
 
76
75
 
77
76
        def run( self ):
79
78
                # set up repo and check it exists
80
79
                the.repo.check_dir_exists()
81
80
 
 
81
                # determine files
 
82
                files = self.expand_files( self.files )
 
83
 
82
84
                message = ''
83
85
 
84
86
                # initialise deployment and check if it's ongoing
101
103
                else:
102
104
 
103
105
                        # check status
104
 
                        walker = StatusWalker()
 
106
                        walker = StatusWalker( files if files else None )
105
107
                        walker.walk()
106
108
                        if walker.modified:
107
109
                                message += 'modified:\n  %s\n' % \