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

Re: [PATCH] Allow to made multible backup from same version

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2002-12-15 22:09:36 CET

Karl Fogel <kfogel@newton.ch.collab.net> writes:

> > Index: tools/backup/hot-backup.py
> > ===================================================================
> > --- tools/backup/hot-backup.py (revision 4111)
> > +++ tools/backup/hot-backup.py (working copy)
> > @@ -77,6 +77,15 @@
> > # Step 2: copy the whole repository structure.
> >
> > backup_subdir = os.path.join(backup_dir, repo + "-" + youngest)
> > +
> > +# if there is backup already, add additional
> > +# increment at the end of path
> > +try_count = 1
> > +while os.path.exists(backup_subdir):
> > + backup_subdir = os.path.join(backup_dir, repo + "-" + youngest + "-" + `try_count`)
> > + try_count += 1
> > +
> > +
> > print "Backing up repository to '" + backup_subdir + "'..."
> > shutil.copytree(repo_dir, backup_subdir)
> > print "Done."

I don't understand why one would want multiple backups of the same
revison, particularly if they are in directories with arbitrary names.

However looking at the patch I see a race in the existing code when
used a a post-commit hook. A post-commit script runs asynchronously,
so it cannot assume that the repository has not changed since the
commit that triggered the script. Consider the following

  1. Commit X completes and triggers the 'X' run of the post-commit.
  2. Commit Y completes and triggers the 'Y' run of the post-commit.
  3. The 'X' post-commit starts.
  4. The 'Y' post-commit starts.
  5. The 'X' post-commit completes, but backs-up Y since that HEAD.
  6. The 'Y' post-commit will now do
       shutil.copytree(repo_dir, backup_subdir)
     but backup_subdir already exists and contains a backup of Y.

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Dec 15 22:10:16 2002

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.