[PATCH STABLE] strip: do not overwrite existing backup bundles

Frank Kingswood frank at kingswood-consulting.co.uk
Wed Dec 28 09:40:34 CST 2011


On 28/12/11 02:28, Pierre-Yves David wrote:
>
> On 28 déc. 2011, at 03:10, Laurens Holst wrote:
>
>> # HG changeset patch
>> # User Laurens Holst<laurens.hg at grauw.nl>
>> # Date 1325036331 -3600
>> # Node ID 9ef0648c6e5433d1d70642693ff7dba8302328fa
>> # Parent  3317d5c34f384c6d1d8440e19980a2261beecc7a
>> strip: do not overwrite existing backup bundles
>>
>> I ran into a data loss issue where a strip‚s backup overwrote a previous backup
>> which had more descendants. This happens because the backup file name composed
>> of just the hash of the first stripped changeset. The issue is fixed by
>> suffixing the backup file with a - and a number as needed.
>

> I would add a bound to the amount of filename we try.
>
> filename = "%s-%s.hg" % (short(node), suffix)
> for i in itertools.count(1, 256):

That is not how itertools.count works.
This sets the increment to 256, not a limit.

>      name = os.path.join(backupdir, filename)
>      if not os.path.exists(name):
>          break
>      else:
>          filename = "%s-%s-%d.hg" % (short(node), suffix, i)
> else:
>      raise util.Abort(_("can not find available backup file for %s bla bla bla") % filename)
>
>



More information about the Mercurial-devel mailing list