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

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Oct 4 11:04:46 EDT 2017


pulkit planned changes to this revision.
pulkit added a comment.


  In https://phab.mercurial-scm.org/D933#15594, @dlax wrote:
  
  > > 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?
  
  
  Ah, my bad. Thanks for catching.
  
  > Also, nodedict could be written using comprehensions:
  > 
  > nodedict = {
  > 
  >   short(pred): [short(s) for s in succs]
  >   for pred, succs in replacements.iteritems()
  > 
  > }
  
  Thanks will replace to this is next version.

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