/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_resolve.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
 
# resolve.py
 
1
# command_resolve.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 ResolveCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
 
 
26
 
 
27
class CommandResolve:
29
28
 
30
29
 
31
30
        def __init__( self ):
65
64
                                                'invalid repository name: ' + optarg )
66
65
                                self.repo = optarg
67
66
                        elif opt in [ '--verbose', '-v' ]:
68
 
                                the.verbose += 1
 
67
                                the.verbose = True
69
68
                        elif opt == "--help":
70
69
                                self.print_help()
71
70
                
87
86
                deployment = Deployment()
88
87
                deployment.check_ongoing( True )
89
88
 
 
89
                # check for conflicts
90
90
                message = ''
91
 
 
92
 
                # check for conflicts in repo
93
 
                files = the.repo.vcs.get_conflicts()
94
 
                if files:
 
91
                conflicts = the.repo.vcs.has_conflicts()
 
92
                if conflicts:
95
93
                        message += 'Conflicts in %s:\n  %s' % \
96
 
                                           ( the.repo.name, '\n  '.join( files ) )
97
 
 
98
 
                # check for deployment conclicts
99
 
                conflicts = deployment.get_conflicts()
 
94
                                           ( the.repo.name, '\n  '.join( conflicts ) )
 
95
                conflicts = deployment.check_conflicts()
100
96
                if conflicts:
101
97
                        message += 'Deployment conflicts:\n  %s' % \
102
98
                                           '\n  '.join( conflicts )
103
 
 
104
 
                # stop if there are conflicts
105
99
                if message:
106
 
                        raise the.program.FatalError(
107
 
                                'there were conflicts...\n' + message )
 
100
                        raise the.program.FatalError( 'there are conflicts:\n' + message )
108
101
 
109
102
                # copy-out changes from repo
110
 
                deployment.copy_out()
 
103
                try:
 
104
                        deployment.copy_out()
 
105
                except deployment.Conflict as e:
 
106
                        raise the.program.FatalError( e.msg )
111
107
 
112
108
                # now we've copied-out, revert any copied-in changes!
113
109
                if the.verbose: print "reverting %s" % the.repo.dir