This is an archive of the discontinued Mercurial Phabricator instance.

utils: add isauthorwellformed function
AbandonedPublic

Authored by sheehan on Mar 20 2018, 1:56 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

Adds a function to determine if an author field is formatted
correctly (ie "Contributor Name <something@something.com>")

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

sheehan created this revision.Mar 20 2018, 1:56 PM

We are trying to slim down util.py, do you think it would be possible to put it in a new module, something like utils/authorutil.py?

@pulkit do we need the b prefix when calling re.compile for Python3 compat?

@pulkit do we need the b prefix when calling re.compile for Python3 compat?

Not necessary, transformer will do that but it will be good adding the b'' prefix.

yuja added a subscriber: yuja.Mar 21 2018, 9:03 AM

We are trying to slim down util.py, do you think it would be possible to
put it in a new module, something like utils/authorutil.py?

+1. It could be utils/stringutil.py if "author" is too specific.

Some potential functions that should be moved:

  • stringmatcher() (if "stringutil")
  • shortuser()
  • emailuser()
  • email()
  • ellipsis() (if "stringutil")
  • escapestr() (if "stringutil")
  • unescapestr() (if "stringutil")
  • forcebytestr() (if "stringutil")
  • uirepr() (maybe if "stringutil")
  • wrap() (maybe if "stringutil")
yuja added a comment.Mar 21 2018, 9:12 AM

Not necessary, transformer will do that but it will be good adding the b'' prefix.

br'' is preferred here because Python 3 is getting stricter on invalid \<char>
escapes.

In D2903#46735, @yuja wrote:

We are trying to slim down util.py, do you think it would be possible to
put it in a new module, something like utils/authorutil.py?

+1. It could be utils/stringutil.py if "author" is too specific.
Some potential functions that should be moved:

  • stringmatcher() (if "stringutil")
  • shortuser()
  • emailuser()
  • email()
  • ellipsis() (if "stringutil")
  • escapestr() (if "stringutil")
  • unescapestr() (if "stringutil")
  • forcebytestr() (if "stringutil")
  • uirepr() (maybe if "stringutil")
  • wrap() (maybe if "stringutil")

👍 on stringutil

sheehan abandoned this revision.Mar 31 2018, 10:03 AM

Abandoning, this was landed as another differential.