/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: 2016-02-13 13:25:21 UTC
  • Revision ID: tim@ed.am-20160213132521-46v5774k6ql7tdfn
fixed uninitialised variable

Show diffs side-by-side

added added

removed removed

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