hgext/mq.py
changeset 49306 2e726c934fcd
parent 49305 53e9422a9b45
child 49743 f22364e4eb13
equal deleted inserted replaced
49305:53e9422a9b45 49306:2e726c934fcd
    61 This extension used to provide a strip command. This command now lives
    61 This extension used to provide a strip command. This command now lives
    62 in the strip extension.
    62 in the strip extension.
    63 '''
    63 '''
    64 
    64 
    65 
    65 
    66 import errno
       
    67 import os
    66 import os
    68 import re
    67 import re
    69 import shutil
    68 import shutil
    70 import sys
    69 import sys
    71 from mercurial.i18n import _
    70 from mercurial.i18n import _
   549                 # else we ignore empty lines
   548                 # else we ignore empty lines
   550 
   549 
   551         try:
   550         try:
   552             lines = self.opener.read(self.statuspath).splitlines()
   551             lines = self.opener.read(self.statuspath).splitlines()
   553             return list(parselines(lines))
   552             return list(parselines(lines))
   554         except IOError as e:
   553         except FileNotFoundError:
   555             if e.errno == errno.ENOENT:
   554             return []
   556                 return []
       
   557             raise
       
   558 
   555 
   559     @util.propertycache
   556     @util.propertycache
   560     def fullseries(self):
   557     def fullseries(self):
   561         try:
   558         try:
   562             return self.opener.read(self.seriespath).splitlines()
   559             return self.opener.read(self.seriespath).splitlines()
   563         except IOError as e:
   560         except FileNotFoundError:
   564             if e.errno == errno.ENOENT:
   561             return []
   565                 return []
       
   566             raise
       
   567 
   562 
   568     @util.propertycache
   563     @util.propertycache
   569     def series(self):
   564     def series(self):
   570         self.parseseries()
   565         self.parseseries()
   571         return self.series
   566         return self.series
   689     def active(self):
   684     def active(self):
   690         if self.activeguards is None:
   685         if self.activeguards is None:
   691             self.activeguards = []
   686             self.activeguards = []
   692             try:
   687             try:
   693                 guards = self.opener.read(self.guardspath).split()
   688                 guards = self.opener.read(self.guardspath).split()
   694             except IOError as err:
   689             except FileNotFoundError:
   695                 if err.errno != errno.ENOENT:
       
   696                     raise
       
   697                 guards = []
   690                 guards = []
   698             for i, guard in enumerate(guards):
   691             for i, guard in enumerate(guards):
   699                 bad = self.checkguard(guard)
   692                 bad = self.checkguard(guard)
   700                 if bad:
   693                 if bad:
   701                     self.ui.warn(
   694                     self.ui.warn(
  1138             if r:
  1131             if r:
  1139                 r[None].forget(patches)
  1132                 r[None].forget(patches)
  1140             for p in patches:
  1133             for p in patches:
  1141                 try:
  1134                 try:
  1142                     os.unlink(self.join(p))
  1135                     os.unlink(self.join(p))
  1143                 except OSError as inst:
  1136                 except FileNotFoundError:
  1144                     if inst.errno != errno.ENOENT:
  1137                     pass
  1145                         raise
       
  1146 
  1138 
  1147         qfinished = []
  1139         qfinished = []
  1148         if numrevs:
  1140         if numrevs:
  1149             qfinished = self.applied[:numrevs]
  1141             qfinished = self.applied[:numrevs]
  1150             del self.applied[:numrevs]
  1142             del self.applied[:numrevs]