# HG changeset patch # User Pierre-Yves David # Date 1415181938 0 # Node ID 85c634ff395a3c626108b324567b6f11dfd2917d # Parent 8919dc7f2dbbfee80e41cab429d44752d5cab861 transaction: drop backupentries logic from startgroup and endgroup The `startgroup` and `endgroup` methods are used in a very specific context to wrap a very specific operation (revlog truncation). It does not make sense to perform any other operations during such a "group" (eg:file backup). There is currently no user of backupfile during a "group" so we drop the group-specific code and restrict authorized operations during "group". diff -r 8919dc7f2dbb -r 85c634ff395a mercurial/transaction.py --- a/mercurial/transaction.py Wed Nov 05 10:00:15 2014 +0000 +++ b/mercurial/transaction.py Wed Nov 05 10:05:38 2014 +0000 @@ -121,7 +121,7 @@ This is used by strip to delay vision of strip offset. The transaction sees either none or all of the strip actions to be done.""" - self._queue.append(([], [])) + self._queue.append([]) @active def endgroup(self): @@ -130,31 +130,22 @@ This is used by strip to delay vision of strip offset. The transaction sees either none or all of the strip actions to be done.""" q = self._queue.pop() - self.entries.extend(q[0]) - self._backupentries.extend(q[1]) + self.entries.extend(q) offsets = [] - backups = [] - for f, o, _data in q[0]: + for f, o, _data in q: offsets.append((f, o)) - for f, b in q[1]: - backups.append((f, b)) - d = ''.join(['%s\0%d\n' % (f, o) for f, o in offsets]) self.file.write(d) self.file.flush() - d = ''.join(['%s\0%s\n' % (f, b) for f, b in backups]) - self._backupsfile.write(d) - self._backupsfile.flush() - @active def add(self, file, offset, data=None): if file in self.map or file in self._backupmap: return if self._queue: - self._queue[-1][0].append((file, offset, data)) + self._queue[-1].append((file, offset, data)) return self.entries.append((file, offset, data)) @@ -174,6 +165,9 @@ * `file`: the file path, relative to .hg/store * `hardlink`: use a hardlink to quickly create the backup """ + if self._queue: + msg = 'cannot use transaction.addbackup inside "group"' + raise RuntimeError(msg) if file in self.map or file in self._backupmap: return @@ -188,10 +182,6 @@ self.add(file, 0) return - if self._queue: - self._queue[-1][1].append((file, backupfile)) - return - self._backupentries.append((file, backupfile)) self._backupmap[file] = len(self._backupentries) - 1 self._backupsfile.write("%s\0%s\n" % (file, backupfile))