22
22
import sys, re, getopt
24
from deployment import Deployment
23
from command import Command
24
import stdhome.the as the
25
from stdhome.deployment import Deployment
28
class ResolveCommand( Command ):
34
31
def print_help( self ):
62
59
if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
63
60
raise the.program.FatalError(
64
61
'invalid repository name: ' + optarg )
66
elif opt in [ '--verbose', '-v' ]:
68
63
elif opt == "--help":
71
66
# discard first argument (the command)
81
76
# set up repo and check it exists
82
the.set_repo( self.repo )
83
77
the.repo.check_dir_exists()
85
79
# initialise deployment (check it's valid)
86
80
deployment = Deployment()
87
81
deployment.check_ongoing( True )
91
conflicts = the.repo.vcs.has_conflicts()
93
message += 'Conflicts in %s:\n %s' % \
94
( the.repo.name, '\n '.join( conflicts ) )
95
conflicts = deployment.check_conflicts()
97
message += 'Deployment conflicts:\n %s' % \
85
# check for conflicts in repo
86
files = the.repo.vcs.get_conflicts()
88
message += 'conflicts in %s:\n %s' % \
89
( the.repo.name, '\n '.join( files ) )
91
# check for deployment conclicts
92
conflicts = deployment.get_conflicts()
94
message += 'deployment conflicts:\n %s' % \
98
95
'\n '.join( conflicts )
97
# stop if there are conflicts
100
raise the.program.FatalError( 'there are conflicts:\n' + message )
99
raise the.program.FatalError(
100
'there were conflicts...\n' + message )
102
102
# copy-out changes from repo
104
deployment.copy_out()
105
except deployment.Conflict as e:
106
raise the.program.FatalError( e.msg )
103
deployment.copy_out()
108
105
# now we've copied-out, revert any copied-in changes!
109
if the.verbose: print "reverting %s" % the.repo.dir
106
if the.verbose >= 1: print "reverting %s" % the.repo.dir
110
107
the.repo.vcs.revert()