mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
cbd6366e9a
Summary: Expose the correlator to core. This also reduces the lifetime of correlator from global (process lifetime) to ui (dispatch.request/command), which makes more sense and is more compatible with a multi-command per process world (not using it by default yet). This is needed to move edenapi to core. Reviewed By: kulshrax Differential Revision: D27897891 fbshipit-source-id: 7bd7e422c15e09a82e726436f92d4315ae876d94
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# An extension to make identifiers from util.makerandomidentifier into a stable
|
|
# incrementing sequence.
|
|
import os
|
|
|
|
from edenscm.hgext import extutil
|
|
from edenscm.mercurial import extensions, util
|
|
|
|
|
|
def makestableidentifier(orig, length=16):
|
|
stableidentifierfile = os.path.join(os.environ["TESTTMP"], "stableidentifier")
|
|
with extutil.flock(stableidentifierfile, "stableidentifier"):
|
|
try:
|
|
with open(stableidentifierfile) as f:
|
|
coid = int(f.read().strip())
|
|
except Exception:
|
|
coid = 0
|
|
with open(stableidentifierfile, "w") as f:
|
|
f.write("%s\n" % (coid + 1))
|
|
return "%0*d" % (length, coid)
|
|
|
|
|
|
def uisetup(ui):
|
|
extensions.wrapfunction(util, "makerandomidentifier", makestableidentifier)
|
|
assert ui._correlator.get() is None
|
|
ui._correlator.swap("stableidentifiers:correlator")
|