mercurial/subrepo.py
changeset 10272 886858b834da
parent 10271 9b38bec5dc29
child 10273 e898bc7810ad
equal deleted inserted replaced
10271:9b38bec5dc29 10272:886858b834da
     3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
     3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 import errno, os, re
     8 import errno, os, re, xml.dom.minidom
     9 from i18n import _
     9 from i18n import _
    10 import config, util, node, error
    10 import config, util, node, error
    11 hg = None
    11 hg = None
    12 
    12 
    13 nullstate = ('', '', 'empty')
    13 nullstate = ('', '', 'empty')
   273         if err:
   273         if err:
   274             raise util.Abort(err)
   274             raise util.Abort(err)
   275         return retdata
   275         return retdata
   276 
   276 
   277     def _wcrev(self):
   277     def _wcrev(self):
   278         info = self._svncommand(['info'])
   278         output = self._svncommand(['info', '--xml'])
   279         mat = re.search('Revision: ([\d]+)\n', info)
   279         doc = xml.dom.minidom.parseString(output)
   280         if not mat:
   280         entries = doc.getElementsByTagName('entry')
       
   281         if not entries:
   281             return 0
   282             return 0
   282         return mat.groups()[0]
   283         return int(entries[0].getAttribute('revision') or 0)
   283 
       
   284     def _url(self):
       
   285         info = self._svncommand(['info'])
       
   286         mat = re.search('URL: ([^\n]+)\n', info)
       
   287         if not mat:
       
   288             return 0
       
   289         return mat.groups()[0]
       
   290 
   284 
   291     def _wcclean(self):
   285     def _wcclean(self):
   292         status = self._svncommand(['status'])
   286         output = self._svncommand(['status', '--xml'])
   293         status = '\n'.join([s for s in status.splitlines() if s[0] != '?'])
   287         doc = xml.dom.minidom.parseString(output)
   294         if status.strip():
   288         for s in doc.getElementsByTagName('wc-status'):
   295             return False
   289             st = s.getAttribute('item')
       
   290             if st and st != 'unversioned':
       
   291                 return False
       
   292             props = s.getAttribute('props')
       
   293             if props and props != 'none':
       
   294                 return False
   296         return True
   295         return True
   297 
   296 
   298     def dirty(self):
   297     def dirty(self):
   299         if self._wcrev() == self._state[1] and self._wcclean():
   298         if self._wcrev() == self._state[1] and self._wcclean():
   300             return False
   299             return False