/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-02-12 21:51:49 UTC
  • Revision ID: tim@ed.am-20140212215149-msaxl7vo98il5i4a
added more commands

Show diffs side-by-side

added added

removed removed

1
 
# stage_revert.py
 
1
# command_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
 
from command import Command
24
 
import stdhome.the as the
25
 
from stdhome.deployment import Deployment
26
 
 
27
 
 
28
 
class StageRevertCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
 
 
26
 
 
27
class CommandStageRevert:
29
28
 
30
29
 
31
30
        def __init__( self ):
66
65
                                                'invalid repository name: ' + optarg )
67
66
                                self.repo = optarg
68
67
                        elif opt in [ '--verbose', '-v' ]:
69
 
                                the.verbose += 1
 
68
                                the.verbose = True
70
69
                        elif opt == "--help":
71
70
                                self.print_help()
72
71
                
84
83
                the.set_repo( self.repo )
85
84
                the.repo.check_dir_exists()
86
85
 
87
 
                # initialise deployment
 
86
                # check there isn't a deployment in progress
88
87
                deployment = Deployment()
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!" )
 
88
                deployment.check_ongoing( False )
92
89
 
93
90
                # check for local changes
94
91
                if the.verbose: print "reverting %s" % the.repo.dir
95
 
                the.repo.vcs.revert( deployment.get_initial_revno() )
96
 
 
97
 
                # remove deployment state
98
 
                deployment.remove_deployment_state()
 
92
                the.repo.vcs.revert()