/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-03-19 20:02:10 UTC
  • Revision ID: tim@ed.am-20140319200210-b6nm63rpktfmw0l3
changed working of output

Show diffs side-by-side

added added

removed removed

1
 
# command_stage_revert.py
 
1
# stage_revert.py
2
2
#
3
3
# Copyright (C) 2014 Tim Marston <tim@edm.am>
4
4
#
20
20
 
21
21
 
22
22
import sys, re, getopt
23
 
import the
24
 
from deployment import Deployment
25
 
 
26
 
 
27
 
class CommandStageRevert:
 
23
from command import Command
 
24
import stdhome.the as the
 
25
from stdhome.deployment import Deployment
 
26
 
 
27
 
 
28
class StageRevertCommand( Command ):
28
29
 
29
30
 
30
31
        def __init__( self ):
65
66
                                                'invalid repository name: ' + optarg )
66
67
                                self.repo = optarg
67
68
                        elif opt in [ '--verbose', '-v' ]:
68
 
                                the.verbose = True
 
69
                                the.verbose += 1
69
70
                        elif opt == "--help":
70
71
                                self.print_help()
71
72
                
83
84
                the.set_repo( self.repo )
84
85
                the.repo.check_dir_exists()
85
86
 
86
 
                # check there isn't a deployment in progress
 
87
                # initialise deployment
87
88
                deployment = Deployment()
88
 
                deployment.check_ongoing( False )
 
89
                if deployment.is_ongoing() and deployment.get_initial_revno() is None:
 
90
                        raise RunteimError(
 
91
                                "can't revert ongoing deployment: initial revno is missing!" )
89
92
 
90
93
                # check for local changes
91
94
                if the.verbose: print "reverting %s" % the.repo.dir
92
 
                the.repo.vcs.revert()
 
95
                the.repo.vcs.revert( deployment.get_initial_revno() )
 
96
 
 
97
                # remove deployment state
 
98
                deployment.remove_deployment_state()