hgext/mq.py
changeset 14588 bd3d75a03f80
parent 14587 5d3bb4460256
child 14589 7d59ee9e711b
equal deleted inserted replaced
14587:5d3bb4460256 14588:bd3d75a03f80
   269         self.ui = ui
   269         self.ui = ui
   270         self.applied_dirty = 0
   270         self.applied_dirty = 0
   271         self.series_dirty = 0
   271         self.series_dirty = 0
   272         self.added = []
   272         self.added = []
   273         self.seriespath = "series"
   273         self.seriespath = "series"
   274         self.status_path = "status"
   274         self.statuspath = "status"
   275         self.guards_path = "guards"
   275         self.guards_path = "guards"
   276         self.active_guards = None
   276         self.active_guards = None
   277         self.guards_dirty = False
   277         self.guards_dirty = False
   278         # Handle mq.git as a bool with extended values
   278         # Handle mq.git as a bool with extended values
   279         try:
   279         try:
   285             self.gitmode = ui.config('mq', 'git', 'auto').lower()
   285             self.gitmode = ui.config('mq', 'git', 'auto').lower()
   286         self.plainmode = ui.configbool('mq', 'plain', False)
   286         self.plainmode = ui.configbool('mq', 'plain', False)
   287 
   287 
   288     @util.propertycache
   288     @util.propertycache
   289     def applied(self):
   289     def applied(self):
   290         if os.path.exists(self.join(self.status_path)):
   290         if os.path.exists(self.join(self.statuspath)):
   291             def parselines(lines):
   291             def parselines(lines):
   292                 for l in lines:
   292                 for l in lines:
   293                     entry = l.split(':', 1)
   293                     entry = l.split(':', 1)
   294                     if len(entry) > 1:
   294                     if len(entry) > 1:
   295                         n, name = entry
   295                         n, name = entry
   296                         yield statusentry(bin(n), name)
   296                         yield statusentry(bin(n), name)
   297                     elif l.strip():
   297                     elif l.strip():
   298                         self.ui.warn(_('malformated mq status line: %s\n') % entry)
   298                         self.ui.warn(_('malformated mq status line: %s\n') % entry)
   299                     # else we ignore empty lines
   299                     # else we ignore empty lines
   300             lines = self.opener.read(self.status_path).splitlines()
   300             lines = self.opener.read(self.statuspath).splitlines()
   301             return list(parselines(lines))
   301             return list(parselines(lines))
   302         return []
   302         return []
   303 
   303 
   304     @util.propertycache
   304     @util.propertycache
   305     def fullseries(self):
   305     def fullseries(self):
   494             fp = self.opener(path, 'w')
   494             fp = self.opener(path, 'w')
   495             for i in items:
   495             for i in items:
   496                 fp.write("%s\n" % i)
   496                 fp.write("%s\n" % i)
   497             fp.close()
   497             fp.close()
   498         if self.applied_dirty:
   498         if self.applied_dirty:
   499             write_list(map(str, self.applied), self.status_path)
   499             write_list(map(str, self.applied), self.statuspath)
   500         if self.series_dirty:
   500         if self.series_dirty:
   501             write_list(self.fullseries, self.seriespath)
   501             write_list(self.fullseries, self.seriespath)
   502         if self.guards_dirty:
   502         if self.guards_dirty:
   503             write_list(self.active_guards, self.guards_path)
   503             write_list(self.active_guards, self.guards_path)
   504         if self.added:
   504         if self.added:
  1591             for root, dirs, files in os.walk(self.path):
  1591             for root, dirs, files in os.walk(self.path):
  1592                 d = root[len(self.path) + 1:]
  1592                 d = root[len(self.path) + 1:]
  1593                 for f in files:
  1593                 for f in files:
  1594                     fl = os.path.join(d, f)
  1594                     fl = os.path.join(d, f)
  1595                     if (fl not in self.series and
  1595                     if (fl not in self.series and
  1596                         fl not in (self.status_path, self.seriespath,
  1596                         fl not in (self.statuspath, self.seriespath,
  1597                                    self.guards_path)
  1597                                    self.guards_path)
  1598                         and not fl.startswith('.')):
  1598                         and not fl.startswith('.')):
  1599                         msng_list.append(fl)
  1599                         msng_list.append(fl)
  1600             for x in sorted(msng_list):
  1600             for x in sorted(msng_list):
  1601                 pfx = self.ui.verbose and ('D ') or ''
  1601                 pfx = self.ui.verbose and ('D ') or ''
  2673             newpath = savename(path)
  2673             newpath = savename(path)
  2674         ui.warn(_("copy %s to %s\n") % (path, newpath))
  2674         ui.warn(_("copy %s to %s\n") % (path, newpath))
  2675         util.copyfiles(path, newpath)
  2675         util.copyfiles(path, newpath)
  2676     if opts.get('empty'):
  2676     if opts.get('empty'):
  2677         try:
  2677         try:
  2678             os.unlink(q.join(q.status_path))
  2678             os.unlink(q.join(q.statuspath))
  2679         except:
  2679         except:
  2680             pass
  2680             pass
  2681     return 0
  2681     return 0
  2682 
  2682 
  2683 @command("strip",
  2683 @command("strip",