comparison fetch_command.py @ 76:6c62bd201785

SubversionRepo: make get_file() return the file mode It is cheap to get it, and it will be useful to fetch revisions.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 Nov 2008 18:08:35 -0600
parents 450d5d9d3b80
children ed3dd5bf45da
comparison
equal deleted inserted replaced
75:cca31b6b1318 76:6c62bd201785
117 if hg_editor.missing_plaintexts: 117 if hg_editor.missing_plaintexts:
118 hg_editor.ui.status('Fetching %s files that could not use replay.\n' % 118 hg_editor.ui.status('Fetching %s files that could not use replay.\n' %
119 len(hg_editor.missing_plaintexts)) 119 len(hg_editor.missing_plaintexts))
120 files_to_grab = set() 120 files_to_grab = set()
121 dirs_to_list = [] 121 dirs_to_list = []
122 props = {}
123 hg_editor.ui.status('Getting properties...\n')
124 for p in hg_editor.missing_plaintexts: 122 for p in hg_editor.missing_plaintexts:
125 hg_editor.ui.status('.') 123 hg_editor.ui.status('.')
126 hg_editor.ui.flush() 124 hg_editor.ui.flush()
127 p2 = p
128 if svn.subdir:
129 p2 = p2[len(svn.subdir)-1:]
130 # this *sometimes* raises on me, and I have
131 # no idea why. TODO(augie) figure out the why.
132 try:
133 pl = svn.proplist(p2, r.revnum, recurse=True)
134 cleanup_file_handles(svn, i)
135 i += 1
136 except core.SubversionException, e: #pragma: no cover
137 pass
138 props.update(pl)
139 if p[-1] == '/': 125 if p[-1] == '/':
140 dirs_to_list.append(p) 126 dirs_to_list.append(p)
141 else: 127 else:
142 files_to_grab.add(p) 128 files_to_grab.add(p)
143 if dirs_to_list: 129 if dirs_to_list:
152 p2 = p[:-1] 138 p2 = p[:-1]
153 if svn.subdir: 139 if svn.subdir:
154 p2 = p2[len(svn.subdir)-1:] 140 p2 = p2[len(svn.subdir)-1:]
155 l = svn.list_dir(p2, r.revnum) 141 l = svn.list_dir(p2, r.revnum)
156 for f in l: 142 for f in l:
157
158 if l[f].kind == core.svn_node_dir: 143 if l[f].kind == core.svn_node_dir:
159 dirs_to_list.append(p+f+'/') 144 dirs_to_list.append(p+f+'/')
160 elif l[f].kind == core.svn_node_file: 145 elif l[f].kind == core.svn_node_file:
161 files_to_grab.add(p+f) 146 files_to_grab.add(p+f)
162 hg_editor.ui.status('\nFetching files...\n') 147 hg_editor.ui.status('\nFetching files...\n')
166 p2 = p 151 p2 = p
167 if svn.subdir: 152 if svn.subdir:
168 p2 = p2[len(svn.subdir)-1:] 153 p2 = p2[len(svn.subdir)-1:]
169 cleanup_file_handles(svn, i) 154 cleanup_file_handles(svn, i)
170 i += 1 155 i += 1
171 hg_editor.current_files[p] = svn.get_file(p2, r.revnum) 156 data, mode = svn.get_file(p2, r.revnum)
172 hg_editor.current_files_exec[p] = False 157 hg_editor.current_files[p] = data
173 if p in props: 158 hg_editor.current_files_exec[p] = 'x' in mode
174 if 'svn:executable' in props[p]: 159 hg_editor.current_files_symlink[p] = 'l' in mode
175 hg_editor.current_files_exec[p] = True
176 if 'svn:special' in props[p]:
177 hg_editor.current_files_symlink[p] = True
178 hg_editor.missing_plaintexts = set() 160 hg_editor.missing_plaintexts = set()
179 hg_editor.ui.status('\n') 161 hg_editor.ui.status('\n')
180 hg_editor.commit_current_delta() 162 hg_editor.commit_current_delta()
181 163
182 164
345 try: 327 try:
346 os.makedirs(os.path.dirname(file_path)) 328 os.makedirs(os.path.dirname(file_path))
347 except OSError, e: 329 except OSError, e:
348 pass 330 pass
349 f = open(file_path, 'w') 331 f = open(file_path, 'w')
350 f.write(svn.get_file(diff_path+'/'+m, r.revnum)) 332 f.write(svn.get_file(diff_path+'/'+m, r.revnum)[0])
351 f.close() 333 f.close()
352 except IOError: 334 except IOError:
353 pass 335 pass
354 d2 = empty_file_patch_wont_make_re.sub('', d) 336 d2 = empty_file_patch_wont_make_re.sub('', d)
355 d2 = property_exec_set_re.sub('', d2) 337 d2 = property_exec_set_re.sub('', d2)