hgext/shelve.py
changeset 27775 3ea35a0769fe
parent 27694 2dc363274702
child 27834 476f53058ee8
equal deleted inserted replaced
27774:8ceaaf63ca80 27775:3ea35a0769fe
   422         used = 16
   422         used = 16
   423         age = '(%s)' % templatefilters.age(util.makedate(mtime), abbrev=True)
   423         age = '(%s)' % templatefilters.age(util.makedate(mtime), abbrev=True)
   424         ui.write(age, label='shelve.age')
   424         ui.write(age, label='shelve.age')
   425         ui.write(' ' * (12 - len(age)))
   425         ui.write(' ' * (12 - len(age)))
   426         used += 12
   426         used += 12
   427         fp = open(name + '.patch', 'rb')
   427         with open(name + '.patch', 'rb') as fp:
   428         try:
       
   429             while True:
   428             while True:
   430                 line = fp.readline()
   429                 line = fp.readline()
   431                 if not line:
   430                 if not line:
   432                     break
   431                     break
   433                 if not line.startswith('#'):
   432                 if not line.startswith('#'):
   445                     ui.write(chunk, label=label)
   444                     ui.write(chunk, label=label)
   446             if opts['stat']:
   445             if opts['stat']:
   447                 for chunk, label in patch.diffstatui(difflines, width=width,
   446                 for chunk, label in patch.diffstatui(difflines, width=width,
   448                                                      git=True):
   447                                                      git=True):
   449                     ui.write(chunk, label=label)
   448                     ui.write(chunk, label=label)
   450         finally:
       
   451             fp.close()
       
   452 
   449 
   453 def singlepatchcmds(ui, repo, pats, opts, subcommand):
   450 def singlepatchcmds(ui, repo, pats, opts, subcommand):
   454     """subcommand that displays a single shelf"""
   451     """subcommand that displays a single shelf"""
   455     if len(pats) != 1:
   452     if len(pats) != 1:
   456         raise error.Abort(_("--%s expects a single shelf") % subcommand)
   453         raise error.Abort(_("--%s expects a single shelf") % subcommand)