Skip to content

Commit 3331771

Browse files
quark-zjufacebook-github-bot
authored andcommitted
hooks: add a hook point after write commands
Summary: This allows us to run commands after changes were made to the repo. Reviewed By: DurhamG Differential Revision: D22993218 fbshipit-source-id: d9943dcda94da42970fb9107f48f4caa14b6a9d4
1 parent 05a99d0 commit 3331771

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

eden/scm/edenscm/mercurial/dispatch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
938938
)
939939
_log_exception(lui, e)
940940
raise
941+
if getattr(repo, "_txnreleased", False):
942+
hook.hook(lui, repo, "postwritecommand", False)
941943
return ret
942944

943945

eden/scm/edenscm/mercurial/localrepo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,10 @@ def __init__(self, baseui, path, create=False):
592592
# generic mapping between names and nodes
593593
self.names = namespaces.namespaces(self)
594594

595+
# whether the repo is changed (by transaction).
596+
# currently used to decide whether to run fsync.
597+
self._txnreleased = False
598+
595599
self._applyopenerreqs()
596600

597601
self._eventreporting = True
@@ -1583,6 +1587,7 @@ def releasefn(tr, success):
15831587
# transaction running
15841588
repo.dirstate.write(None)
15851589
flushchangelog(tr)
1590+
repo._txnreleased = True
15861591
else:
15871592
# discard all changes (including ones already written
15881593
# out) in this transaction

0 commit comments

Comments
 (0)