/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-26 19:15:30 UTC
  • Revision ID: tim@ed.am-20140226191530-6x21vlwto2xx80cd
renamed updated_files to affected_files

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:
 
28
 
 
29
 
 
30
        def __init__( self ):
 
31
                self.repo = None
29
32
 
30
33
 
31
34
        def print_help( self ):
59
62
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
60
63
                                        raise the.program.FatalError(
61
64
                                                'invalid repository name: ' + optarg )
62
 
                                the.repo = optarg
 
65
                                self.repo = optarg
 
66
                        elif opt in [ '--verbose', '-v' ]:
 
67
                                the.verbose = True
63
68
                        elif opt == "--help":
64
69
                                self.print_help()
65
 
 
 
70
                
66
71
                # discard first argument (the command)
67
72
                args.pop( 0 )
68
73
 
74
79
        def run( self ):
75
80
 
76
81
                # set up repo and check it exists
 
82
                the.set_repo( self.repo )
77
83
                the.repo.check_dir_exists()
78
84
 
79
85
                # initialise deployment (check it's valid)
85
91
                # check for conflicts in repo
86
92
                files = the.repo.vcs.get_conflicts()
87
93
                if files:
88
 
                        message += 'conflicts in %s:\n  %s' % \
 
94
                        message += 'Conflicts in %s:\n  %s' % \
89
95
                                           ( the.repo.name, '\n  '.join( files ) )
90
96
 
91
97
                # check for deployment conclicts
92
98
                conflicts = deployment.get_conflicts()
93
99
                if conflicts:
94
 
                        message += 'deployment conflicts:\n  %s' % \
 
100
                        message += 'Deployment conflicts:\n  %s' % \
95
101
                                           '\n  '.join( conflicts )
96
102
 
97
103
                # stop if there are conflicts
103
109
                deployment.copy_out()
104
110
 
105
111
                # now we've copied-out, revert any copied-in changes!
106
 
                if the.verbose >= 1: print "reverting %s" % the.repo.dir
 
112
                if the.verbose: print "reverting %s" % the.repo.dir
107
113
                the.repo.vcs.revert()