Patchwork [4,of,7] transaction: write pending generated file

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 18, 2014, 11:40 p.m.
Message ID <def76a6affbe440a60c6.1416354001@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6774/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 18, 2014, 11:40 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413609545 25200
#      Fri Oct 17 22:19:05 2014 -0700
# Node ID def76a6affbe440a60c67804e3920efe5ea19020
# Parent  d7ca924c69d4e09076df64a28e22bef7e8387c46
transaction: write pending generated file

Such file are generated with a .pending prefix. It is up to the reader to
implement the necessary logic for reading pending files.

We add a test to ensure pending file are properly cleaned-up in both success and
error case.

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -340,10 +340,11 @@  class transaction(object):
         categories = sorted(self._pendingcallback)
         for cat in categories:
             # remove callback since the data will have been flushed
             any = self._pendingcallback.pop(cat)(self)
             self._anypending = self._anypending or any
+        self._anypending |= self._generatefiles(suffix='.pending')
         return self._anypending
 
     @active
     def addfinalize(self, category, callback):
         """add a callback to be called when the transaction is closed
diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t
+++ b/tests/test-bundle2-exchange.t
@@ -302,10 +302,19 @@  Check final content.
   4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
   5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
   6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
   7777777777777777777777777777777777777777 32af7686d403cf45b5d95f2d70cebea587ac806a 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
 
+(check that no 'pending' file remains)
+
+  $ ls -1 other/.hg/bookmarks*
+  other/.hg/bookmarks
+  $ ls -1 other/.hg/store/phaseroots*
+  other/.hg/store/phaseroots
+  $ ls -1 other/.hg/store/00changelog.i*
+  other/.hg/store/00changelog.i
+
 Error Handling
 ==============
 
 Check that errors are properly returned to the client during push.
 
@@ -477,6 +486,14 @@  Doing the actual push: hook abort
   pushing to http://localhost:$HGPORT2/
   searching for changes
   abort: b2x-pretransactionclose.failpush hook exited with status 1
   [255]
 
+(check that no 'pending' file remains)
 
+  $ ls -1 other/.hg/bookmarks*
+  other/.hg/bookmarks
+  $ ls -1 other/.hg/store/phaseroots*
+  other/.hg/store/phaseroots
+  $ ls -1 other/.hg/store/00changelog.i*
+  other/.hg/store/00changelog.i
+