Skip to content

Commit

Permalink
localrepo: log public base info to the commit_info table
Browse files Browse the repository at this point in the history
Summary: log public base info to the commit_info table.

Reviewed By: sggutier

Differential Revision: D66898560

fbshipit-source-id: f886d4ae3e344ada9aa3bd14164f953d4cc9d3cd
  • Loading branch information
zzl0 authored and facebook-github-bot committed Dec 9, 2024
1 parent f742c15 commit 6ccafa7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions eden/scm/sapling/localrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
# - '' for svfs relative paths
_cachedfiles = set()

SECONDS_IN_A_DAY = 60 * 60 * 24


class _basefilecache(scmutil.filecache):
"""filecache usage on repo"""
Expand Down Expand Up @@ -2872,6 +2874,8 @@ def commitctx(self, ctx, error=False):
if diffnumber is not None:
loginfo.update({"phabricator_diff_number": diffnumber})

_set_public_base_age(self, p1, loginfo)

self.ui.log(
"commit_info",
node=hex(n),
Expand Down Expand Up @@ -3387,3 +3391,14 @@ def _validate_committable_ctx(ui, ctx):
% (len(ctx.files()), file_count_limit),
hint=hint,
)


def _set_public_base_age(repo, ctx, loginfo):
if publicbase := scmutil.publicbase(repo, ctx):
age = int(time.time() - publicbase.date()[0]) / SECONDS_IN_A_DAY
loginfo.update(
{
"public_base": publicbase.hex(),
"public_base_age": age,
}
)

0 comments on commit 6ccafa7

Please sign in to comment.