comparison svnwrap/svn_swig_wrapper.py @ 301:79440ed81011

Allow specifying a revision to stop at using the -H flag. This is useful for converting repositories which have been deleted or renamed, such as llvm-gcc-4-2 in the LLVM repositories which was renamed to llvm-gcc-4.2 shortly after its creation. Also, consolidate the two places in svn_swig_wrapper.py where a default chunk size is specified to one, single variable declaration.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 27 Mar 2009 03:21:45 +0100
parents 4aba7542f6a9
children ce676eff002b
comparison
equal deleted inserted replaced
300:4aba7542f6a9 301:79440ed81011
26 """ 26 """
27 27
28 class SubversionRepoCanNotDiff(Exception): 28 class SubversionRepoCanNotDiff(Exception):
29 """Exception raised when the svn API diff3() command cannot be used 29 """Exception raised when the svn API diff3() command cannot be used
30 """ 30 """
31
32 '''Default chunk size used in fetch_history_at_paths() and revisions().'''
33 _chunk_size = 1000
31 34
32 def optrev(revnum): 35 def optrev(revnum):
33 optrev = core.svn_opt_revision_t() 36 optrev = core.svn_opt_revision_t()
34 optrev.kind = core.svn_opt_revision_number 37 optrev.kind = core.svn_opt_revision_number
35 optrev.value.number = revnum 38 optrev.value.number = revnum
143 """Wrapper for a Subversion repository. 146 """Wrapper for a Subversion repository.
144 147
145 This uses the SWIG Python bindings, and will only work on svn >= 1.4. 148 This uses the SWIG Python bindings, and will only work on svn >= 1.4.
146 It takes a required param, the URL. 149 It takes a required param, the URL.
147 """ 150 """
148 def __init__(self, url='', username=''): 151 def __init__(self, url='', username='', head=None):
149 self.svn_url = url 152 self.svn_url = url
150 self.uname = username 153 self.uname = username
151 self.auth_baton_pool = core.Pool() 154 self.auth_baton_pool = core.Pool()
152 self.auth_baton = _create_auth_baton(self.auth_baton_pool) 155 self.auth_baton = _create_auth_baton(self.auth_baton_pool)
153 # self.init_ra_and_client() assumes that a pool already exists 156 # self.init_ra_and_client() assumes that a pool already exists
204 HEAD = property(HEAD) 207 HEAD = property(HEAD)
205 208
206 def START(self): 209 def START(self):
207 return 0 210 return 0
208 START = property(START) 211 START = property(START)
212
213 def last_changed_rev(self):
214 try:
215 holder = []
216 ra.get_log(self.ra, [''],
217 self.HEAD, 1,
218 1, #limit of how many log messages to load
219 True, # don't need to know changed paths
220 True, # stop on copies
221 lambda paths, revnum, author, date, message, pool:
222 holder.append(revnum),
223 self.pool)
224
225 return holder[-1]
226 except core.SubversionException, e:
227 if e.apr_err not in [core.SVN_ERR_FS_NOT_FOUND]:
228 raise
229 else:
230 return self.HEAD
231 last_changed_rev = property(last_changed_rev)
209 232
210 def branches(self): 233 def branches(self):
211 """Get the branches defined in this repo assuming a standard layout. 234 """Get the branches defined in this repo assuming a standard layout.
212 235
213 This method should be eliminated; this class does not have 236 This method should be eliminated; this class does not have
300 revision = self.HEAD 323 revision = self.HEAD
301 r = ra.get_dir2(self.ra, dir, revision, core.SVN_DIRENT_KIND, self.pool) 324 r = ra.get_dir2(self.ra, dir, revision, core.SVN_DIRENT_KIND, self.pool)
302 folders, props, junk = r 325 folders, props, junk = r
303 return folders 326 return folders
304 327
305 def revisions(self, start=None, chunk_size=1000): 328 def revisions(self, start=None, stop=None, chunk_size=_chunk_size):
306 """Load the history of this repo. 329 """Load the history of this repo.
307 330
308 This is LAZY. It returns a generator, and fetches a small number 331 This is LAZY. It returns a generator, and fetches a small number
309 of revisions at a time. 332 of revisions at a time.
310 333