Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

hg: Display formatted user name.#874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Niloth-p wants to merge1 commit intozulip:main
base:main
Choose a base branch
Loading
fromNiloth-p:templates-for-screenshots/hg

Conversation

Niloth-p
Copy link
Contributor

Mercurial: Format the user name to hide the user's email in the summary line of the message.
Motivation: Updating example screenshots in integration docs.


Mercurial'sctx.user() returns the username.

The username can be set from these sources:

  • env var$HGUSER
  • [ui] username in.hgrc.
  • System username as a fallback

The username could be in any of the following formats, and may have extra spaces anywhere:

  • username <email> (the recommended format)
  • username
  • <email>

I've added aparse_user function which supports all the formats, and strips extra spaces.
It could have been written in a couple of lines, but I've kept the function elaborate and used intermediate variables for readability.

How did you test this PR?
I did not.

Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (seecommit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

def parse_user(user: str) -> str:
"""Extract the name from user string, or fall back to email or raw string."""
# Match: "Name <email@example.com>"
match = re.match(r"^(.*)<([^>]+)>$", user)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Doesn't Python have anemailaddress module for parsing these correctly? There's no reason to write custom regexes to parse standard formats.

Niloth-p reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timabbotttimabbotttimabbott left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Niloth-p@timabbott@zulipbot

[8]ページ先頭

©2009-2025 Movatter.jp