Patchwork [5,of,6] scmutil: introduce a filecacheentry that can watch multiple paths

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2013, 11:21 p.m.
Message ID <c31031f519a1410a7ab9.1384644071@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/3000/
State Accepted
Commit d38de18d187aed6d5de246c86eed3d62d0e89de3
Headers show

Comments

Siddharth Agarwal - Nov. 16, 2013, 11:21 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1384637066 28800
#      Sat Nov 16 13:24:26 2013 -0800
# Node ID c31031f519a1410a7ab92a0a0b8c263cf1e92161
# Parent  325bd3d4fba6b30a5b508a4d1d331fe8e8374cb3
scmutil: introduce a filecacheentry that can watch multiple paths

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -906,6 +906,23 @@ 
             if e.errno != errno.ENOENT:
                 raise
 
+class filecacheentry(object):
+    def __init__(self, paths, stat=True):
+        self._entries = []
+        for path in paths:
+            self._entries.append(filecachesubentry(path, stat))
+
+    def changed(self):
+        '''true if any entry has changed'''
+        for entry in self._entries:
+            if entry.changed():
+                return True
+        return False
+
+    def refresh(self):
+        for entry in self._entries:
+            entry.refresh()
+
 class filecache(object):
     '''A property like decorator that tracks a file under .hg/ for updates.