[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Alternate fix for the hot-backup.py read-only file issue

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: 2007-04-23 22:35:23 CEST

darkwing@proaxis.com wrote:
> Attached is an alternate fix for the hot-backup.py and read-only file
> issue. I believe this is a cleaner solution since it does not use timeout
> delays, and it only traverses the directory tree one time. Also, the code
> that changes the file mode only runs if it is needed. Feel free to use
> any part of the script. I do my work in the windows environement, so I
> have not been able to test this script under Linux. If you try it under
> Linux, let me know the results.

Thanks for the patch! For those unfamiliar with the problem, do you
know have a more specific definition of it? That, or an issue number,
would go a long way toward helping reviewers look at your patch.
Including an appropriate log message, helps attract reviews, and gives
understanding to the problem you are trying to solve.

Also, submitting your patch in accordance with the patch guidelines
found in HACKING[1] is the best way to get quick and helpful review.
Perhaps you can resubmit your patch, following these guidelines?

[1] http://subversion.tigris.org/hacking.html#patches


> <--- last part of the modified hot-backup.py script --->
> ### Step 5: finally, remove all repository backups other than the last
> # Python cannot delete read-only files under Windows; this handler tries
> to remove the
> # the read-only protection and then delete the file.
> def handler(func, path, execinfo):
> # if this is called because we could not remove a file,
> # then see if it READONLY...
> if (func == os.remove) and not os.access(path, os.W_OK):
> # if it is READONLY, change it back to NORMAL and try again...
> os.chmod(path, stat.S_IWRITE)
> os.remove(path)
> else:
> # something else must be wrong...
> raise
> if num_backups > 0:
> regexp = re.compile("^" + repo + "-[0-9]+(-[0-9]+)?" + ext_re + "$")
> directory_list = os.listdir(backup_dir)
> old_list = filter(lambda x: regexp.search(x), directory_list)
> old_list.sort(comparator)
> del old_list[max(0,len(old_list)-num_backups):]
> for item in old_list:
> old_backup_item = os.path.join(backup_dir, item)
> print "Removing old backup: " + old_backup_item
> if os.path.isdir(old_backup_item):
> # specify an error handler to process read-only files
> shutil.rmtree(old_backup_item, False, handler)
> else:
> os.remove(old_backup_item)

Received on Mon Apr 23 22:35:35 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.