/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/revert.py

  • Committer: Tim Marston
  • Date: 2016-02-23 19:35:21 UTC
  • Revision ID: tim@ed.am-20160223193521-2vgtxbfos50rrpku
renamed version -> VERSION

Show diffs side-by-side

added added

removed removed

31
31
 
32
32
        def __init__( self ):
33
33
                self.all = False
 
34
                self.quiet = False
34
35
 
35
36
 
36
37
        def print_help( self ):
50
51
                print
51
52
                print "Options:"
52
53
                print "      --all        confirm that you want to revert all files"
 
54
                print "      --quiet      do not report changes to the home directory"
53
55
                print "  -r, --repo=REPO  select the repo to check-out or create (defaults to 'home')"
54
56
                print "  -v, --verbose    display information about what is being done"
55
57
                print "      --help       display help and exit"
59
61
        def parse_command_line( self ):
60
62
                opts, args = getopt.gnu_getopt(
61
63
                        sys.argv[ 1: ], "r:v",
62
 
                        [ "all", "repo=", "verbose", "help" ] )
 
64
                        [ "all", "quiet", "repo=", "verbose", "help" ] )
63
65
                for opt, optarg in opts:
64
66
                        if opt == "--all":
65
67
                                self.all = True
 
68
                        elif opt == "--quiet":
 
69
                                self.quiet = True
66
70
                        elif opt in [ '--repo', '-r' ]:
67
 
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
 
71
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
68
72
                                        raise the.program.FatalError(
69
73
                                                'invalid repository name: ' + optarg )
70
74
                                the.repo = optarg
71
 
                        elif opt in [ '--verbose', '-v' ]:
72
 
                                the.verbose += 1
73
75
                        elif opt == "--help":
74
76
                                self.print_help()
75
 
                
 
77
 
76
78
                # discard first argument (the command)
77
79
                args.pop( 0 )
78
80
 
104
106
                if the.repo.vcs.has_changes():
105
107
                        raise the.program.FatalError(
106
108
                                'repo has local changes: %s\n'
107
 
                                'Hint: see "%s stage-revert --help"' % 
 
109
                                'Hint: see "%s stage-revert --help"' %
108
110
                                ( the.repo.name, the.program.name ) )
109
111
 
110
112
                # check status
111
 
                walker = CopyOutWalker( files if files else None )
 
113
                walker = CopyOutWalker( files if files else None, self.quiet )
112
114
                walker.walk()