mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
5da0c6903d
Summary: The Rust bindings now provide a subset of time parsing features. Replace the old Python implementation. This has multiple benefits: - Strong gurarnatee that Rust and Python behave the same. - Parse relative time (ex. `5 minutes ago`) - Parse date beyound i32 range (ex. >= year 2038) Reviewed By: DurhamG Differential Revision: D18946332 fbshipit-source-id: 721f47bc5b2835d7ca0a05ab34ea4faa1a411a4e
50 lines
1011 B
Python
50 lines
1011 B
Python
# extension to emulate invoking 'patch.internalpatch()' at the time
|
|
# specified by '[fakepatchtime] fakenow'
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from edenscm.mercurial import extensions, patch as patchmod, registrar, util
|
|
|
|
|
|
configtable = {}
|
|
configitem = registrar.configitem(configtable)
|
|
|
|
configitem("fakepatchtime", "fakenow", default=None)
|
|
|
|
|
|
def internalpatch(
|
|
orig,
|
|
ui,
|
|
repo,
|
|
patchobj,
|
|
strip,
|
|
prefix="",
|
|
files=None,
|
|
eolmode="strict",
|
|
similarity=0,
|
|
):
|
|
if files is None:
|
|
files = set()
|
|
r = orig(
|
|
ui,
|
|
repo,
|
|
patchobj,
|
|
strip,
|
|
prefix=prefix,
|
|
files=files,
|
|
eolmode=eolmode,
|
|
similarity=similarity,
|
|
)
|
|
|
|
fakenow = ui.config("fakepatchtime", "fakenow")
|
|
if fakenow:
|
|
fakenow = util.parsedate(fakenow)[0]
|
|
for f in files:
|
|
repo.wvfs.utime(f, (fakenow, fakenow))
|
|
|
|
return r
|
|
|
|
|
|
def extsetup(ui):
|
|
extensions.wrapfunction(patchmod, "internalpatch", internalpatch)
|