/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: 2014-04-18 15:00:55 UTC
  • Revision ID: tim@ed.am-20140418150055-wy2zmdiwn7sptk4x
status comand now accepts a list of files

Show diffs side-by-side

added added

removed removed

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