diff mercurial/subrepo.py @ 16554:ae2664ee0223 stable

subrepo/svn: fix checked out rev number retrieval (issue2968) The initial version was to take the "Revision" field from svn info. It works but produces false positive when parent paths are being moved or unrelated changes are being committed, causing it to change while the svn checkout itself remains the same. To avoid spurious commit, we took "Revision" and "Last Changed Rev" for general comparison and kept the latter to answer "what is your revision?" question. This is better but fails when the subrepo path exists at "Revision" but not at "Last Changed Rev". This patch adds a check for this, and returns "Revision" if the path does not exist. We try to avoid doing this as much as possible at it implies an extra, *remote* call.
author Patrick Mezard <patrick@mezard.eu>
date Mon, 30 Apr 2012 17:03:15 +0200
parents e37199a1f9d4
children 4955e7bf085c
line wrap: on
line diff
--- a/mercurial/subrepo.py	Mon Apr 30 20:45:45 2012 +0200
+++ b/mercurial/subrepo.py	Mon Apr 30 17:03:15 2012 +0200
@@ -715,13 +715,24 @@
         return True
 
     def basestate(self):
-        return self._wcrev()
+        lastrev, rev = self._wcrevs()
+        if lastrev != rev:
+            # Last committed rev is not the same than rev. We would
+            # like to take lastrev but we do not know if the subrepo
+            # URL exists at lastrev.  Test it and fallback to rev it
+            # is not there.
+            try:
+                self._svncommand(['info', '%s@%s' % (self._state[0], lastrev)])
+                return lastrev
+            except error.Abort:
+                pass
+        return rev
 
     def commit(self, text, user, date):
         # user and date are out of our hands since svn is centralized
         changed, extchanged, missing = self._wcchanged()
         if not changed:
-            return self._wcrev()
+            return self.basestate()
         if extchanged:
             # Do not try to commit externals
             raise util.Abort(_('cannot commit svn externals'))