in fluent/migrate/repo_client.py [0:0]
def blame(self, file: str) -> list[Tuple[str, int]]:
"Return a list of (author, time) tuples for each line in `file`."
if self.hgclient:
args = hglib.util.cmdbuilder(
b"annotate",
file.encode("latin-1"),
template="json",
date=True,
user=True,
cwd=self.root,
)
blame_json = self.hgclient.rawcommand(args)
return [
(line["user"], int(line["date"][0]))
for line in json.loads(blame_json)[0]["lines"]
]
else:
lines: list[Tuple[str, int]] = []
user = ""
time = 0
stdout = git(self.root, "blame", "--porcelain", file)
for line in stdout.splitlines():
if line.startswith("author "):
user = line[7:] or "[noname]"
elif line.startswith("author-mail "):
email = line[11:] # includes leading space
user += email if email != ' <>' else ' <nomail>'
elif line.startswith("author-time "):
time = int(line[12:])
elif line.startswith("\t"):
lines.append((user, time))
return lines