changeset 10272:886858b834da

subrepo: svn xml output is much easier to parse That's especially true with status flags: there are different fields and values for regular changes, meta changes, externals changes and externals meta changes.
author Patrick Mezard <pmezard@gmail.com>
date Thu, 21 Jan 2010 15:13:40 +0100
parents 9b38bec5dc29
children e898bc7810ad
files mercurial/subrepo.py
diffstat 1 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Thu Jan 21 15:13:03 2010 +0100
+++ b/mercurial/subrepo.py	Thu Jan 21 15:13:40 2010 +0100
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import errno, os, re
+import errno, os, re, xml.dom.minidom
 from i18n import _
 import config, util, node, error
 hg = None
@@ -275,24 +275,23 @@
         return retdata
 
     def _wcrev(self):
-        info = self._svncommand(['info'])
-        mat = re.search('Revision: ([\d]+)\n', info)
-        if not mat:
+        output = self._svncommand(['info', '--xml'])
+        doc = xml.dom.minidom.parseString(output)
+        entries = doc.getElementsByTagName('entry')
+        if not entries:
             return 0
-        return mat.groups()[0]
-
-    def _url(self):
-        info = self._svncommand(['info'])
-        mat = re.search('URL: ([^\n]+)\n', info)
-        if not mat:
-            return 0
-        return mat.groups()[0]
+        return int(entries[0].getAttribute('revision') or 0)
 
     def _wcclean(self):
-        status = self._svncommand(['status'])
-        status = '\n'.join([s for s in status.splitlines() if s[0] != '?'])
-        if status.strip():
-            return False
+        output = self._svncommand(['status', '--xml'])
+        doc = xml.dom.minidom.parseString(output)
+        for s in doc.getElementsByTagName('wc-status'):
+            st = s.getAttribute('item')
+            if st and st != 'unversioned':
+                return False
+            props = s.getAttribute('props')
+            if props and props != 'none':
+                return False
         return True
 
     def dirty(self):