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

  • Committer: Tim Marston
  • Date: 2014-04-18 15:00:34 UTC
  • Revision ID: tim@ed.am-20140418150034-l94wfs6ururhi9t5
fixed error in walker.py (from last checkin)

Show diffs side-by-side

added added

removed removed

28
28
class StageRevertCommand( Command ):
29
29
 
30
30
 
31
 
        def __init__( self ):
32
 
                self.force = False
33
 
 
34
 
 
35
31
        def print_help( self ):
36
32
                print "Usage: " + the.program.name + " stage-revert [--repo=REPO]"
37
33
                print
49
45
                print "repository."
50
46
                print
51
47
                print "Options:"
52
 
                print "      --force      force revert of stage (when there is a problem)"
53
48
                print "  -r, --repo=REPO  select the repo to check-out or create (defaults to 'home')"
54
49
                print "  -v, --verbose    display information about what is being done"
55
50
                print "      --help       display help and exit"
59
54
        def parse_command_line( self ):
60
55
                opts, args = getopt.gnu_getopt(
61
56
                        sys.argv[ 1: ], "r:v",
62
 
                        [ "force", "repo=", "verbose", "help" ] )
 
57
                        [ "repo=", "verbose", "help" ] )
63
58
                for opt, optarg in opts:
64
 
                        if opt == "--force":
65
 
                                self.force = True
66
 
                        elif opt in [ '--repo', '-r' ]:
67
 
                                if not re.search( '^[-a-zA-z0-9.]+$', optarg ):
 
59
                        if opt in [ '--repo', '-r' ]:
 
60
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
68
61
                                        raise the.program.FatalError(
69
62
                                                'invalid repository name: ' + optarg )
70
63
                                the.repo = optarg
 
64
                        elif opt in [ '--verbose', '-v' ]:
 
65
                                the.verbose += 1
71
66
                        elif opt == "--help":
72
67
                                self.print_help()
73
 
 
 
68
                
74
69
                # discard first argument (the command)
75
70
                args.pop( 0 )
76
71
 
86
81
 
87
82
                # initialise deployment
88
83
                deployment = Deployment()
89
 
                if deployment.is_ongoing() and deployment.get_initial_revno() is None \
90
 
                   and not self.force:
91
 
                        raise RuntimeError(
92
 
                                "can't revert ongoing deployment: initial revno is missing!\n"
93
 
                                "use --force to override, but an update may miss changes!" )
 
84
                if deployment.is_ongoing() and deployment.get_initial_revno() is None:
 
85
                        raise RunteimError(
 
86
                                "can't revert ongoing deployment: initial revno is missing!" )
94
87
 
95
88
                # check for local changes
96
89
                if the.verbose >= 1: print "reverting %s" % the.repo.dir