sapling/eden/scm/edenscm/replay.py
Muir Manders 44343769f8 collapse edenscm.mercurial package into edenscm
Summary:
We want to rename away from "mercurial". Rather than rename the "mercurial" Python package, we opted to just collapse it into the parent "edenscm" package. This is also a step towards further organizing we want to do around the new project name.

To ease the transition wrt hotfixes, we now replace "edenscm.mercurial" with "mercurial" to fix imports within base64-python extensions.

Reviewed By: sggutier

Differential Revision: D38943169

fbshipit-source-id: 03fa18079c51e2f7fac05d65b127095da3ab7c99
2022-08-24 13:45:53 -07:00

58 lines
2.1 KiB
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# replay.py - types and utils for unbundle replays.
from __future__ import absolute_import
from . import json
class ReplayData(object):
"""A structure to store and serialize/deserialize replay-related data
Replay is a process of re-application of an `unbundle`, captured on
the wire in some other system. Such re-application might have some
expectations, which we need to be able to verify, and some additional
data, which we may need to use. Currently, the following are stored:
`commitdates` - a map form the original hash to the commit date to
be used in a rebased commit. Must be in the format,
understood by `util.parsedate`.
- `ontobook` - a bookmark, used for pushrebase
- `rebasedhead`- an expected hash of the rebased head
- `hgbonsaimapping` - mapping from hg changesets to bonsai changesets.
Normally it's used only by mononoke
"""
def __init__(self, commitdates, rebasedhead, ontobook, hgbonsaimapping):
self.commitdates = commitdates
self.rebasedhead = rebasedhead
self.ontobook = ontobook
self.hgbonsaimapping = hgbonsaimapping
def serialize(self):
res = {
"commitdates": self.commitdates,
"rebasedhead": self.rebasedhead,
"ontobook": self.ontobook,
"hgbonsaimapping": self.hgbonsaimapping,
}
return json.dumps(res)
@classmethod
def deserialize(cls, s):
d = json.loads(s)
commitdates = d.get("commitdates", {})
rebasedhead = d.get("rebasedhead")
ontobook = d.get("ontobook")
hgbonsaimapping = d.get("hgbonsaimapping", {})
return cls(commitdates, rebasedhead, ontobook, hgbonsaimapping)
def getcommitdate(self, ui, commithash, commitdate):
saveddate = self.commitdates.get(commithash)
if saveddate:
return (int(saveddate), commitdate[1])
return commitdate