/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: 2016-02-28 18:26:06 UTC
  • Revision ID: tim@ed.am-20160228182606-7jjvu9mbxppjlqjq
check directories for (permission) changes in copy base walker

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
                self.dir = dir
39
39
 
40
40
 
 
41
        def has_authority( self ):
 
42
                """Check that the directory is under this VCS's control.
 
43
                """
 
44
 
 
45
                return os.path.exists( os.path.join( self.dir, '.bzr' ) )
 
46
 
 
47
 
 
48
        def expand_repo_url( self, url ):
 
49
                """Convert a simple hostname in to an URL that the VCS can use.
 
50
                """
 
51
 
 
52
                return 'bzr+ssh://%s/%s/%s' % ( url, the.dir, the.repo.name )
 
53
 
 
54
 
41
55
        def init( self ):
42
56
                """Create a new, empty branch
43
57
                """
86
100
                """Obtain some sort of revision identifier
87
101
                """
88
102
 
89
 
                # bzr revert
 
103
                # bzr revno
90
104
                output = self.run( [ 'bzr', 'revno', '--tree' ] )
91
105
 
92
106
                # parse revno
109
123
                # symlink to a non-existant file)
110
124
                if 'kind changed' in files:
111
125
                        for file in files[ 'kind changed' ]:
112
 
                                matches = re.match( r'(.+?)[/@+]? \([^)]+\)', file )
 
126
                                matches = re.search( '^(.+?)[/@+]? \([^)]+\)$', file )
113
127
                                if not matches:
114
128
                                        raise RunTimeError(
115
129
                                                'failed to parse bzr kind change: %s' % file )
133
147
                # remove unknown files
134
148
                if 'unknown' in files:
135
149
                        for file in files[ 'unknown' ]:
 
150
                                matches = re.search( r'^(.+?)[/@+]?$', file )
 
151
                                if not matches:
 
152
                                        raise RunTimeError(
 
153
                                                'failed to parse bzr unknowns: %s' % file )
 
154
                                file = matches.group( 1 )
136
155
                                if the.verbose >= 2: print "removing (unknown): " + file
137
156
                                full_file = os.path.join( self.dir, file )
138
 
                                if os.path.isfile( full_file ):
 
157
                                if os.path.isfile( full_file ) or os.path.islink( full_file ):
139
158
                                        os.unlink( full_file )
140
159
                                elif os.path.isdir( full_file ):
141
160
                                        shutil.rmtree( full_file )
203
222
                for line in buf:
204
223
                        if not re.search( '^[-R+ ?][K NMD!][* ] ', line ): continue
205
224
                        line = line.rstrip()
206
 
                        if the.verbose >= 2: print '  %s' % line
207
225
 
208
226
                        # renames show before and after file names
209
227
                        matches = re.search( '^R.. (.*?)[/@+]? => (.*?)[/@+]?$', line )
278
296
                output = p.communicate()[ 0 ]
279
297
                if p.returncode > 0:
280
298
                        raise self.VcsError( ' '.join( cmd[ : 2 ] ), output )
 
299
                if the.verbose >= 2:
 
300
                        verbose_output = output.rstrip()
 
301
                        if len( verbose_output ):
 
302
                                print re.sub( '(^|\n)', '\\1  : ', verbose_output )
281
303
                return output
282
304
 
283
305