mirror of
https://github.com/facebook/sapling.git
synced 2024-12-29 08:02:24 +03:00
ab3a7cb21f
Summary: In preparation for merging fb-mercurial sources to the Eden repository, move everything from the top-level directory into an `eden/scm` subdirectory.
23 lines
743 B
Python
23 lines
743 B
Python
# 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:
|
|
coid = int(open(stableidentifierfile).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)
|