Patchwork [STABLE] transaction: really fix _addbackupentry key usage (issue4684)

login
register
mail settings
Submitter Pierre-Yves David
Date May 26, 2015, 8:58 p.m.
Message ID <6747e6f6bfa5c202af0d.1432673929@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9290/
State Accepted
Headers show

Comments

Pierre-Yves David - May 26, 2015, 8:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432670548 25200
#      Tue May 26 13:02:28 2015 -0700
# Branch stable
# Node ID 6747e6f6bfa5c202af0d04699e8a78cd6b8f2c44
# Parent  a973b050621d7489287856a125d1a706924447a1
transaction: really fix _addbackupentry  key usage (issue4684)

The fix in fd905b2bea59 is actually wrong. We now use the filename to match what
'_addentry'. This whole untested code is quite suspicious. This seems to point
that no one is ever running 'tr.find' for a backup file.
Augie Fackler - May 27, 2015, 3:21 p.m.
On Tue, May 26, 2015 at 01:58:49PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1432670548 25200
> #      Tue May 26 13:02:28 2015 -0700
> # Branch stable
> # Node ID 6747e6f6bfa5c202af0d04699e8a78cd6b8f2c44
> # Parent  a973b050621d7489287856a125d1a706924447a1
> transaction: really fix _addbackupentry  key usage (issue4684)

queued for stable, thanks

>
> The fix in fd905b2bea59 is actually wrong. We now use the filename to match what
> '_addentry'. This whole untested code is quite suspicious. This seems to point
> that no one is ever running 'tr.find' for a backup file.
>
> diff --git a/mercurial/transaction.py b/mercurial/transaction.py
> --- a/mercurial/transaction.py
> +++ b/mercurial/transaction.py
> @@ -220,11 +220,11 @@ class transaction(object):
>          self._addbackupentry((location, file, backupfile, False))
>
>      def _addbackupentry(self, entry):
>          """register a new backup entry and write it to disk"""
>          self._backupentries.append(entry)
> -        self._backupmap[entry] = len(self._backupentries) - 1
> +        self._backupmap[entry[1]] = len(self._backupentries) - 1
>          self._backupsfile.write("%s\0%s\0%s\0%d\n" % entry)
>          self._backupsfile.flush()
>
>      @active
>      def registertmp(self, tmpfile, location=''):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -220,11 +220,11 @@  class transaction(object):
         self._addbackupentry((location, file, backupfile, False))
 
     def _addbackupentry(self, entry):
         """register a new backup entry and write it to disk"""
         self._backupentries.append(entry)
-        self._backupmap[entry] = len(self._backupentries) - 1
+        self._backupmap[entry[1]] = len(self._backupentries) - 1
         self._backupsfile.write("%s\0%s\0%s\0%d\n" % entry)
         self._backupsfile.flush()
 
     @active
     def registertmp(self, tmpfile, location=''):