Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions hgext/differentiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@


def get_local_repo_callsign(repo) -> str:
"""Returns the callsign from the local repository's `.arcconfig` file."""
repo_path = pathlib.Path(repo.root)
"""Returns the callsign for the local repo parsed from the path.

Uses the repository root path name as the repository ID and returns
the corresponding repository callsign from conduit.
"""
repo_path = pathlib.Path(repo.root.decode("utf-8"))
repo_id = int(repo_path.name)

# Search Conduit for all repositories.
response = call_conduit("diffusion.repository.search", {})

# Retrieve the repo objects.
repo_objects = response["response"]["data"]
repo_objects = response["result"]["data"]

for repo_object in repo_objects:
# If the repo ID we parsed from the working directory matches the
# ID of the current object, return the callsign for this object.
if repo_id == repo_object["id"]:
return repo_object["fields"]["callsign"]

raise error.Abort(b"No repo found with ID %s" % repo_id)
raise error.Abort(b"No repo found with ID %d" % repo_id)


def call_conduit(method: str, params: dict) -> dict:
Expand Down