changeset 16530:e37199a1f9d4 stable

subrepo/svn: improve error message on missing files From: abort: failed to commit svn changes to: abort: cannot commit missing svn entries
author Patrick Mezard <patrick@mezard.eu>
date Thu, 26 Apr 2012 12:13:20 +0200
parents 3d5d204a08c7
children b9f51f49bf2a
files mercurial/subrepo.py tests/test-subrepo-svn.t
diffstat 2 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Thu Apr 26 11:55:07 2012 +0200
+++ b/mercurial/subrepo.py	Thu Apr 26 12:13:20 2012 +0200
@@ -680,12 +680,13 @@
         return self._wcrevs()[0]
 
     def _wcchanged(self):
-        """Return (changes, extchanges) where changes is True
-        if the working directory was changed, and extchanges is
-        True if any of these changes concern an external entry.
+        """Return (changes, extchanges, missing) where changes is True
+        if the working directory was changed, extchanges is
+        True if any of these changes concern an external entry and missing
+        is True if any change is a missing entry.
         """
         output, err = self._svncommand(['status', '--xml'])
-        externals, changes = [], []
+        externals, changes, missing = [], [], []
         doc = xml.dom.minidom.parseString(output)
         for e in doc.getElementsByTagName('entry'):
             s = e.getElementsByTagName('wc-status')
@@ -696,14 +697,16 @@
             path = e.getAttribute('path')
             if item == 'external':
                 externals.append(path)
+            elif item == 'missing':
+                missing.append(path)
             if (item not in ('', 'normal', 'unversioned', 'external')
                 or props not in ('', 'none', 'normal')):
                 changes.append(path)
         for path in changes:
             for ext in externals:
                 if path == ext or path.startswith(ext + os.sep):
-                    return True, True
-        return bool(changes), False
+                    return True, True, bool(missing)
+        return bool(changes), False, bool(missing)
 
     def dirty(self, ignoreupdate=False):
         if not self._wcchanged()[0]:
@@ -716,12 +719,16 @@
 
     def commit(self, text, user, date):
         # user and date are out of our hands since svn is centralized
-        changed, extchanged = self._wcchanged()
+        changed, extchanged, missing = self._wcchanged()
         if not changed:
             return self._wcrev()
         if extchanged:
             # Do not try to commit externals
             raise util.Abort(_('cannot commit svn externals'))
+        if missing:
+            # svn can commit with missing entries but aborting like hg
+            # seems a better approach.
+            raise util.Abort(_('cannot commit missing svn entries'))
         commitinfo, err = self._svncommand(['commit', '-m', text])
         self._ui.status(commitinfo)
         newrev = re.search('Committed revision ([0-9]+).', commitinfo)
@@ -773,7 +780,7 @@
         status, err = self._svncommand(args, failok=True)
         if not re.search('Checked out revision [0-9]+.', status):
             if ('is already a working copy for a different URL' in err
-                and (self._wcchanged() == (False, False))):
+                and (self._wcchanged()[:2] == (False, False))):
                 # obstructed but clean working copy, so just blow it away.
                 self.remove()
                 self.get(state, overwrite=False)
--- a/tests/test-subrepo-svn.t	Thu Apr 26 11:55:07 2012 +0200
+++ b/tests/test-subrepo-svn.t	Thu Apr 26 12:13:20 2012 +0200
@@ -125,7 +125,7 @@
   $ rm s/alpha
   $ hg commit --subrepos -m 'abort on missing file'
   committing subrepository s
-  abort: failed to commit svn changes
+  abort: cannot commit missing svn entries
   [255]
   $ svn revert s/alpha > /dev/null