D933: scmutil: add a new function to show changes after a command

dlax (Denis Laxalde) phabricator at mercurial-scm.org
Wed Oct 4 10:59:25 EDT 2017


dlax added a comment.


  > diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
  > 
  > - a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -685,6 +685,18 @@ if tostrip: repair.delayedstrip(repo.ui, repo, tostrip, operation)
  > 
  >   +def showchanges(replacements, fm): +    """ output the hash changes using formatter instance which is passed. +    """ +    nodesdict = {} +    for pred, succs in replacements.iteritems(): +        succlist = [] +        for succ in succs: +            succlist.append(short(succ)) +        nodesdict[short(pred)] = succlist +        fm.write('hashchanges', '%s\n', +                        fm.formatdict(nodesdict, fmt='%r --> %r', sep='\n'))
  
  The indentation looks wrong. Do you really mean to fm.write() on each
  iteration?
  
  Also, nodedict could be written using comprehensions:
  
  nodedict = {
  
    short(pred): [short(s) for s in succs]
    for pred, succs in replacements.iteritems()
  
  }
  
  > +
  > 
  >   def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None):
  >       if opts is None:
  >           opts = {}
  >

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: dlax, quark, yuja, mercurial-devel


More information about the Mercurial-devel mailing list