/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/deployment.py

  • Committer: Tim Marston
  • Date: 2014-03-19 20:03:32 UTC
  • Revision ID: tim@ed.am-20140319200332-6jpt67qon2ugmg2n
changed wording of status command output

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
                # list of files that were copied-in (or at least given the opportunity
46
46
        # to be) and updated through the vcs update.  This means that, while
47
 
        # there may have been conflicts during the update (which the user will
48
 
        # have to have dealt with in the repo), any conflicts arising with these
49
 
        # files in the home directory are no longer important and can be
50
 
        # ignored.  In short, this is a list of files that can safely be
51
 
        # deployed, regardless of the state of the home directory.
52
 
                self.imported_files = None
 
47
        # there may have been conflicts during the update (which will be dealt
 
48
        # with in the repo), any conflicts arising with these files in the home
 
49
        # directory are no longer important and can be ignored.  In short, this
 
50
        # is a list of files that it is safe to deploy, regardless of their
 
51
        # state in the home directory.
 
52
                self.deploy_files = None
53
53
 
54
54
                # list of files that were affected by a recent vcs update (so only these
55
55
                # files need to be checked for deployment conflicts or copied-out)
67
67
                        return
68
68
 
69
69
                # read the file list
70
 
                if the.verbose >= 1: print "deployment state found; loading"
 
70
                if the.verbose: print "deployment state found; loading"
71
71
                f = open( file, 'r' )
72
72
                state = json.loads( f.read() )
73
73
 
74
74
                # unpack deployment state
75
 
                self.imported_files = state['imported_files'];
 
75
                self.deploy_files = state['deploy_files'];
76
76
                self.initial_revno = state['initial_revno'];
77
77
                self.affected_files = state['affected_files'];
78
78
 
81
81
                """Save the current deployment state (so there will be a deployment ongoing).
82
82
                """
83
83
 
84
 
                if the.verbose >= 1: print "saving deployment state"
 
84
                if the.verbose: print "saving deployment state"
85
85
 
86
86
                # create metadata directory, as necessary
87
87
                if not os.path.isdir( the.full_mddir ):
89
89
 
90
90
                # pack deployment state
91
91
                state = {
92
 
                        'imported_files': self.imported_files,
 
92
                        'deploy_files': self.deploy_files,
93
93
                        'initial_revno': self.initial_revno,
94
94
                        'affected_files': self.affected_files,
95
95
                }
109
109
                if( os.path.isfile( file ) ):
110
110
 
111
111
                        # delete it
112
 
                        if the.verbose >= 1: print "removing deployment state"
 
112
                        if the.verbose: print "removing deployment state"
113
113
                        os.unlink( file )
114
114
 
115
115
 
117
117
                """Is there a deployment currently ongoing?
118
118
                """
119
119
 
120
 
                return False if self.imported_files is None else True
 
120
                return False if self.deploy_files is None else True
121
121
 
122
122
 
123
123
        def check_ongoing( self, ongoing = True ):
126
126
                """
127
127
 
128
128
                if( ongoing ):
129
 
                        if self.imported_files is None:
 
129
                        if self.deploy_files is None:
130
130
                                raise self.DeploymentOngoing( False )
131
131
                else:
132
 
                        if self.imported_files is not None:
 
132
                        if self.deploy_files is not None:
133
133
                                raise self.DeploymentOngoing( True )
134
134
 
135
135
 
150
150
 
151
151
                # if the repo doesn't exist, we have an empty file list
152
152
                if not os.path.exists( the.repo.full_dir ):
153
 
                        self.imported_files = list()
 
153
                        self.deploy_files = list()
154
154
                else:
155
155
                        # copy in
156
 
                        if the.verbose >= 1: print "importing files..."
 
156
                        if the.verbose: print "importing files..."
157
157
                        walker = CopyInWalker()
158
158
                        walker.walk()
159
 
                        self.imported_files = walker.walk_list
 
159
                        if( walker.changed ):
 
160
                                raise self.CopyInConflicts( walker.changed )
 
161
                        self.deploy_files = walker.walk_list
160
162
 
161
163
                        # obtain initial revno
162
164
                        self.initial_revno = the.repo.vcs.get_revno()
166
168
 
167
169
 
168
170
        def get_conflicts( self, affected_files = None ):
169
 
                """Check to see if there are any deployment conflicts.  If a list of affected
 
171
                """Check to see if there are any delpoyment conflicts.  If a list of affected
170
172
                files is supplied, then only those files are checked (and they are also
171
173
                saved with the deployment state).  Otherwise, all files in the
172
174
                repository are checked.
181
183
                        self.save_deployment_state()
182
184
 
183
185
                # check for deployment conflicts
184
 
                walker = ConflictWalker( self.imported_files, self.affected_files )
 
186
                walker = ConflictWalker( self.deploy_files, self.affected_files )
185
187
                walker.walk()
186
188
 
187
189
                self.conflicts_checked = True
189
191
 
190
192
 
191
193
        def copy_out( self ):
192
 
                """Copy-out changed files from the repository to the home directory.  If the
193
 
                deployment state includes a list of affected files, then only those
194
 
                files are copied-out.
 
194
                """Copy-out changed files frmo the repository to the home directory.  If the
 
195
                deployment state incudes a list of affected files, then only those fiels
 
196
                are copied-out.
195
197
                """
196
198
 
197
199
                # check we have a file list
202
204
                        raise RuntimeError('logic error: deployment conflicts unchecked' )
203
205
 
204
206
                # copy out
205
 
                if the.verbose >= 1: print "exporting files..."
 
207
                if the.verbose: print "exporting files..."
206
208
                walker = CopyOutWalker( self.affected_files )
207
209
                walker.walk()
208
210