D3665: graph: improve graph output by using Unicode characters

smf (Sean Farley) phabricator at mercurial-scm.org
Sat Jun 16 21:18:11 EDT 2018


smf added a comment.


  In https://phab.mercurial-scm.org/D3665#58976, @smf wrote:
  
  > In https://phab.mercurial-scm.org/D3665#58973, @johnstiles wrote:
  >
  > > Thanks for the assist, @smf ! I appreciate it.
  >
  >
  > Sure, no problem :-)
  >
  > By the way, here's the diff of what I changed:
  >
  >   diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py
  >   index 7ff3c08..254d2cc 100644
  >   --- a/hgext/beautifygraph.py
  >   +++ b/hgext/beautifygraph.py
  >   @@ -4,23 +4,23 @@
  >    # Copyright 2018 John Stiles <johnstiles at gmail.com>
  >    #
  >    # This software may be used and distributed according to the terms of the
  >    # GNU General Public License version 2 or any later version.
  >   
  >   -'''This extension beautifies log -G output by using Unicode characters.
  >   +'''beautify log -G output by using Unicode characters (EXPERIMENTAL)
  
  
  In the Mercurial project, we use "EXPERIMENTAL" as a flag to mean "we have the option to remove this later." In general, we have a very strong breaking change policy (as in, we try to never have one). The only exceptions to that rule that I'm aware of are if it's a security problem (e.g. default clone of subrepositories changed due to major security flaws) or was broken from day 1.
  
  >      A terminal with UTF-8 support and monospace narrow text are required.
  >   '''
  >   
  >   from __future__ import absolute_import
  >   
  >   from mercurial.i18n import _
  >   from mercurial import (
  >       encoding,
  >       extensions,
  > 
  > +    graphmod,
  > 
  >   templatekw,
  > 
  > - graphmod )
  
  I'll go through and briefly explain each hunk (just for reference and if any other newcomers find this patch). The `graphmod` import needed to be earlier due to our code style checker.
  
  > 1. Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
  > 2. extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
  > 3. be specifying the version(s) of Mercurial they are tested with, or diff --git a/tests/test-duplicateoptions.py b/tests/test-duplicateoptions.py index 4511a89..397eca4 100644
  >   - a/tests/test-duplicateoptions.py +++ b/tests/test-duplicateoptions.py @@ -4,11 +4,11 @@ from mercurial import ( commands, extensions, ui as uimod, )
  > 
  >     -ignore = {b'highlight', b'win32text', b'factotum'} +ignore = {b'highlight', b'win32text', b'factotum', b'beautifygraph'}
  
  I only found this test breaking on the gcc compile farm with the output changing to "beautifygraph: unsupported encoding, UTF-8 required" so I choose to skip importing that extension in this test.
  
  >   if os.name != 'nt':
  >       ignore.add(b'win32mbcs')
  >   
  >   disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore]
  > 
  > diff --git a/tests/test-glog-beautifygraph.t b/tests/test-glog-beautifygraph.t
  >  index c3d1fb7..e62334f 100644
  > 
  > - a/tests/test-glog-beautifygraph.t +++ b/tests/test-glog-beautifygraph.t @@ -89,10 +89,14 @@ o  (0) root >   logcmdutil, >   revsetlang, >   smartset, > ) > +  > from mercurial.utils import ( +  >   stringutil, +  > )
  
  Ah, yes, a classic race condition with another dev changing something that you're working on.
  
  >   > def logrevset(repo, pats, opts):
  >   >     revs = logcmdutil._initialrevs(repo, opts)
  >   >     if not revs:
  >   >         return None
  >   >     match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
  > 
  > @@ -109,11 +113,11 @@ o  (0) root
  > 
  >   >             else:
  >   >                 tree = []
  >   >             ui = repo.ui
  >   >             ui.write(b'%r\n' % (opts.get(b'rev', []),))
  >   >             ui.write(revsetlang.prettyformat(tree) + b'\n')
  > 
  > - >             ui.write(smartset.prettyformat(revs) + b'\n') +  >             ui.write(stringutil.prettyrepr(revs) + b'\n')
  
  As I mentioned above, it seems Yuya changed this and it landed before your patch.
  
  >   >             revs = smartset.baseset()  # display no revisions
  >   >         return revs, filematcher
  >   >     extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
  >   >     aliases, entry = cmdutil.findcmd(b'log', commands.table)
  >   >     entry[1].append((b'', b'print-revset', False,
  > 
  > @@ -324,1003 +328,1001 @@ The extension should not turn on if we'r
  > 
  >     
  >   
  >   The rest of our tests will use the default narrow text UTF-8.
  >   
  >     $ hg log -G -q
  > 
  > - \xe2\x8c\xbe  34:fea3ac5810e0 (esc) +  \xe2\x97\x8d  34:fea3ac5810e0 (esc)
  
  Ah, I think you forgot to update the test output when changing some of the characters you used (at least I hope that was the problem here). All I did to update the whole test at large was run with: `run-tests.py -l tests/test-glog-beautifygraph.t -i`. The `-i` meaning "interactively ask the user to accept this change" which will automatically change the test file for you.
  
  >   \xe2\x94\x82 (esc)
  > 
  > - \xe2\x94\x82 \xe2\x97\xaf  33:68608f5145f9 (esc) +  \xe2\x94\x82 \xe2\x97\x8b  33:68608f5145f9 (esc)
  > 
  >   [... elided the rest] ```
  
  The rest of the diff was just more of the same as the previous error.
  
  Hope that helps!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3665

To: johnstiles, #hg-reviewers, spectral, indygreg
Cc: quark, spectral, indygreg, smf, yuja, mercurial-devel


More information about the Mercurial-devel mailing list