This is an archive of the discontinued Mercurial Phabricator instance.

cmdutil: add a kludge to make bytes repr() the same on 2 and 3
ClosedPublic

Authored by durin42 on Jan 18 2018, 1:17 PM.

Details

Summary

This fixes the output formatting problems I see in debugobsolete. I
still am seeing some effectflag differences, which we'll need to
tackle separately.

I'm not in love with this approach. There might be something better we
could do, and I'd love it if someone else wanted to take a run at
this.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durin42 created this revision.Jan 18 2018, 1:17 PM
yuja accepted this revision.Jan 19 2018, 8:34 AM
yuja added a subscriber: yuja.

This looks ugly, but seems okay. Since sysstr() decodes bytes as latin-1,
8-bit characters will be escaped by \x, not by \u.

This revision is now accepted and ready to land.Jan 19 2018, 8:34 AM
durin42 updated this revision to Diff 4954.Jan 19 2018, 3:12 PM
yuja added a comment.Jan 27 2018, 4:37 AM

I'm thinking of adding a couple of utility functions as this sort of hack
is unavoidable around the codebase:

  • pycompat.maybebytestr(x)
  • make repr(bytestr) return repr(bytes)[1:]
  • pycompat.rapply(f, xs) to recursively apply f = maybebytestr to dict/list items
This revision was automatically updated to reflect the committed changes.