sapling/fastmanifest/debug.py
Tony Tung 13718aed04 [fastmanifest] add a uiproxy object that forwards requests to a real ui object
Summary: Whenever fastmanifest needs an ui object, we pass it a global proxy object.  Whenever someone calls `reposetup(..)`, we update the backing object.

Test Plan:
1) pass existing unit tests
2) enable chg, then run `hg diff -c . --debug`.  saw fastmanifest debug output in the console.

Reviewers: lcharignon, quark

Reviewed By: lcharignon

Subscribers: trunkagent, mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3510966

Signature: t1:3510966:1467410140:88fe810d03b9a9aa6818f17eb605a70eee931364
2016-07-05 16:32:05 -07:00

32 lines
927 B
Python

# debug.py
#
# Copyright 2016 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
class manifestaccesslogger(object):
"""Class to log manifest access and confirm our assumptions"""
def __init__(self, ui):
self._ui = ui
def revwrap(self, orig, *args, **kwargs):
"""Wraps manifest.rev and log access"""
r = orig(*args, **kwargs)
logfile = self._ui.config("fastmanifest", "logfile", "")
if logfile:
try:
with open(logfile, "a") as f:
f.write("%s\n" % r)
except EnvironmentError:
pass
return r
class fixedcachelimit(object):
"""A fix cache limit expressed as a number of bytes"""
def __init__(self, bytes):
self._bytes = bytes
def bytes(self):
return self._bytes