From 23aa7bda11f578ecf6b2cf7ba425e88be76c0d9e Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Wed, 20 Feb 2019 10:54:38 -0800 Subject: [PATCH] rage: read fsmonitor state from treestate Summary: If treestate is in use, fsmonitor state is stored in the treestate, rather than in a separate fsmonitor.state file. Update rage to understand this. Reviewed By: quark-zju Differential Revision: D14131131 fbshipit-source-id: d80d766625d7915b6a76f66f33e763eed23677e9 --- edenscm/hgext/rage.py | 45 ++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/edenscm/hgext/rage.py b/edenscm/hgext/rage.py index 29623372b3..dc1a3b99a8 100644 --- a/edenscm/hgext/rage.py +++ b/edenscm/hgext/rage.py @@ -210,30 +210,27 @@ def readfsmonitorstate(repo): Based on file format version 4. See hgext/fsmonitor/state.py for real implementation. """ - f = repo.localvfs("fsmonitor.state", "rb") - versionbytes = f.read(4) - version = struct.unpack(">I", versionbytes)[0] - data = f.read() - state = data.split("\0") - hostname, clock, ignorehash = state[0:3] - files = state[3:-1] # discard empty entry after final file - numfiles = len(files) - prettyfiles = "\n".join(files[:20]) - return """\ -version: %d -hostname: %s -clock: %s -ignorehash: %s -files (first 20 of %d): -%s -""" % ( - version, - hostname, - clock, - ignorehash, - numfiles, - prettyfiles, - ) + lines = [] + if "treestate" in repo.requirements: + lines.append("from treestate") + clock = repo.dirstate.getclock() + lines.append("clock: %s" % clock) + else: + f = repo.localvfs("fsmonitor.state", "rb") + versionbytes = f.read(4) + version = struct.unpack(">I", versionbytes)[0] + data = f.read() + state = data.split("\0") + hostname, clock, ignorehash = state[0:3] + files = state[3:-1] # discard empty entry after final file + numfiles = len(files) + lines.append("version: %d" % version) + lines.append("hostname: %s" % hostname) + lines.append("clock: %s" % clock) + lines.append("ignorehash: %s" % ignorehash) + lines.append("files (first 20 of %d):" % numfiles) + lines.extend(files[:20]) + return "\n".join(lines) + "\n" def _makerage(ui, repo, **opts):