Patchwork [3,of,7] transaction: have _generatefile return a boolean

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 18, 2014, 11:40 p.m.
Message ID <d7ca924c69d4e09076df.1416354000@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6776/
State Accepted
Commit ba033f461f004857a28f6ea5f9ed0eac18d6e37d
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 1413608252 25200
#      Fri Oct 17 21:57:32 2014 -0700
# Node ID d7ca924c69d4e09076df64a28e22bef7e8387c46
# Parent  aa43d1604f651da073cfd87a3e2c9f7d4fb4afb4
transaction: have _generatefile return a boolean

The function return True is any file were generated. This will be used to know
if any pending file have been written.

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -262,11 +262,13 @@  class transaction(object):
         # but for bookmarks that are handled outside this mechanism.
         self._filegenerators[genid] = (order, filenames, genfunc, location)
 
     def _generatefiles(self, suffix=''):
         # write files registered for generation
+        any = False
         for entry in sorted(self._filegenerators.values()):
+            any = True
             order, filenames, genfunc, location = entry
             vfs = self._vfsmap[location]
             files = []
             try:
                 for name in filenames:
@@ -278,10 +280,11 @@  class transaction(object):
                     files.append(vfs(name, 'w', atomictemp=True))
                 genfunc(*files)
             finally:
                 for f in files:
                     f.close()
+        return any
 
     @active
     def find(self, file):
         if file in self.map:
             return self.entries[self.map[file]]