[PATCH 1 of 2] subrepo/svn: abort on commit with missing file (issue3029)

Patrick Mezard patrick at mezard.eu
Thu Apr 26 05:18:21 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1335434107 -7200
# Branch stable
# Node ID 24e35aca83788861d715fd1149edb4a82009a47e
# Parent  e3c7ca15cde24f7e1ef5018fcfd902f4d6c95adc
subrepo/svn: abort on commit with missing file (issue3029)

Previous code was printing a traceback because it expected some error output
from svn. But sometimes our definition of "changed" differs with the subversion
one. For instance, subversion ignores missing files when committing. And when
there are only missing files, svn commit will be a successful no-op with no
output. Still, we should stick to our definition including missing files in
changes as doing otherwise could cause surprising behaviour for the user.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -726,6 +726,12 @@
         self._ui.status(commitinfo)
         newrev = re.search('Committed revision ([0-9]+).', commitinfo)
         if not newrev:
+            if not commitinfo.strip():
+                # Sometimes, our definition of "changed" differs from
+                # svn one. For instance, svn ignores missing files
+                # when committing. If there are only missing files, no
+                # commit is made, no output and no error code.
+                raise util.Abort(_('failed to commit svn changes'))
             raise util.Abort(commitinfo.splitlines()[-1])
         newrev = newrev.groups()[0]
         self._ui.status(self._svncommand(['update', '-r', newrev])[0])
diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t
--- a/tests/test-subrepo-svn.t
+++ b/tests/test-subrepo-svn.t
@@ -120,6 +120,15 @@
    source   file://*/svn-repo/src (glob)
    revision 2
 
+missing svn file, commit should fail
+
+  $ rm s/alpha
+  $ hg commit --subrepos -m 'abort on missing file'
+  committing subrepository s
+  abort: failed to commit svn changes
+  [255]
+  $ svn revert s/alpha > /dev/null
+
 add an unrelated revision in svn and update the subrepo to without
 bringing any changes.
 


More information about the Mercurial-devel mailing list