/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/vcs/bzr.py

  • Committer: Tim Marston
  • Date: 2014-07-30 19:08:15 UTC
  • Revision ID: tim@ed.am-20140730190815-f3fs5cgtwb88jbvb
added checks to not die when information is missing in deployment

Show diffs side-by-side

added added

removed removed

34
34
 
35
35
                @param dir the fully-qualified directory to work in.
36
36
                """
37
 
 
38
37
                self.dir = dir
39
38
 
40
39
 
86
85
                """Obtain some sort of revision identifier
87
86
                """
88
87
 
89
 
                # bzr revno
 
88
                # bzr revert
90
89
                output = self.run( [ 'bzr', 'revno', '--tree' ] )
91
90
 
92
91
                # parse revno
109
108
                # symlink to a non-existant file)
110
109
                if 'kind changed' in files:
111
110
                        for file in files[ 'kind changed' ]:
112
 
                                matches = re.search( '^(.+?)[/@+]? \([^)]+\)$', file )
 
111
                                matches = re.match( r'(.+?)[/@+]? \([^)]+\)', file )
113
112
                                if not matches:
114
113
                                        raise RunTimeError(
115
114
                                                'failed to parse bzr kind change: %s' % file )
133
132
                # remove unknown files
134
133
                if 'unknown' in files:
135
134
                        for file in files[ 'unknown' ]:
136
 
                                matches = re.search( r'^(.+?)[/@+]?$', file )
137
 
                                if not matches:
138
 
                                        raise RunTimeError(
139
 
                                                'failed to parse bzr unknowns: %s' % file )
140
 
                                file = matches.group( 1 )
141
135
                                if the.verbose >= 2: print "removing (unknown): " + file
142
136
                                full_file = os.path.join( self.dir, file )
143
 
                                if os.path.isfile( full_file ) or os.path.islink( full_file ):
 
137
                                if os.path.isfile( full_file ):
144
138
                                        os.unlink( full_file )
145
139
                                elif os.path.isdir( full_file ):
146
140
                                        shutil.rmtree( full_file )
147
141
                                else:
148
142
                                        raise RuntimeError( 'exotic file in repo: %s' % file )
149
143
 
150
 
                # if a revision identifier has been given, ensure we're updated to that
151
 
                if revno is not None and self.get_revno() != revno:
 
144
                # if a revision identifyer has been given, update to that
 
145
                if revno is not None:
152
146
 
153
147
                        # bzr update
154
148
                        self.run( [ 'bzr', 'update', '-r', revno ] )
208
202
                for line in buf:
209
203
                        if not re.search( '^[-R+ ?][K NMD!][* ] ', line ): continue
210
204
                        line = line.rstrip()
 
205
                        if the.verbose >= 2: print '  %s' % line
211
206
 
212
207
                        # renames show before and after file names
213
208
                        matches = re.search( '^R.. (.*?)[/@+]? => (.*?)[/@+]?$', line )
264
259
                """
265
260
 
266
261
                # bzr add
267
 
                self.run( [ 'bzr', 'add', '-N' ] + files )
 
262
                self.run( [ 'bzr', 'add' ] + files )
268
263
 
269
264
 
270
265
        def commit( self ):
282
277
                output = p.communicate()[ 0 ]
283
278
                if p.returncode > 0:
284
279
                        raise self.VcsError( ' '.join( cmd[ : 2 ] ), output )
285
 
                if the.verbose >= 2:
286
 
                        print re.sub( '(^|\n)', '\\1  > ', output.rstrip() )
287
280
                return output
288
281
 
289
282