changeset 35676:9c575c22dcf4

svnsubrepo: check if subrepo is missing when checking dirty state (issue5657) During an hg convert command, subrepos are not checked out. However, a manifestmerge may occur during an hg convert if there is a merge commit, which in particular will check the dirty state of subrepos. Before this change, the lack of a checked out subrepo would error out. This check for svn subrepos is modelled after 2fdea636f254 for git subrepos.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 16 Jan 2018 08:40:14 -0500
parents 01496e9269f9
children cf2e2a7399bc
files mercurial/subrepo.py tests/test-convert-svn-source.t
diffstat 2 files changed, 71 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Wed Jan 17 13:02:42 2018 +0100
+++ b/mercurial/subrepo.py	Tue Jan 16 08:40:14 2018 -0500
@@ -1332,6 +1332,8 @@
 
     @annotatesubrepoerror
     def dirty(self, ignoreupdate=False, missing=False):
+        if self._svnmissing():
+            return self._state[1] != ''
         wcchanged = self._wcchanged()
         changed = wcchanged[0] or (missing and wcchanged[2])
         if not changed:
--- a/tests/test-convert-svn-source.t	Wed Jan 17 13:02:42 2018 +0100
+++ b/tests/test-convert-svn-source.t	Tue Jan 16 08:40:14 2018 -0500
@@ -253,3 +253,72 @@
   abort: svn-empty: missing or unsupported repository
   [255]
   $ mv format svn-empty/format
+
+enable svn subrepos
+
+  $ cat >> $HGRCPATH <<EOF
+  > [subrepos]
+  > svn:allowed = true
+  > EOF
+
+try converting when we have an svn subrepo and a merge in hg superrepo (issue5657)
+
+  $ cd "$TESTTMP"
+  $ hg init withmerge
+  $ cd withmerge
+  $ echo "subrepo = [svn]$SVNREPOURL" >.hgsub
+  $ hg add .hgsub
+  $ svn checkout "$SVNREPOURL" subrepo
+  A    subrepo/proj B
+  A    subrepo/proj B/mytrunk
+  A    subrepo/proj B/mytrunk/letter .txt
+  A    subrepo/proj B/mytrunk/letter2.txt
+  A    subrepo/proj B/tags
+  A    subrepo/proj B/tags/v0.1
+  A    subrepo/proj B/tags/v0.1/letter .txt
+  A    subrepo/proj B/tags/v0.2
+  A    subrepo/proj B/tags/v0.2/letter .txt
+  A    subrepo/proj B/tags/v0.2/letter2.txt
+  Checked out revision 9.
+  $ hg ci -m "Adding svn subrepo"
+  $ touch file1.txt
+  $ hg add file1.txt
+  $ hg ci -m "Adding file1"
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ touch file2.txt
+  $ hg add file2.txt
+  $ hg ci -m "Adding file2"
+  created new head
+  $ hg merge 1
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m "merged"
+  $ cd ..
+  $ hg --config extensions.convert= convert withmerge withmerge-converted
+  initializing destination withmerge-converted repository
+  scanning source...
+  sorting...
+  converting...
+  3 Adding svn subrepo
+  2 Adding file1
+  1 Adding file2
+  0 merged
+  $ cd withmerge-converted
+  $ hg up
+  A    subrepo/proj B
+  A    subrepo/proj B/mytrunk
+  A    subrepo/proj B/mytrunk/letter .txt
+  A    subrepo/proj B/mytrunk/letter2.txt
+  A    subrepo/proj B/tags
+  A    subrepo/proj B/tags/v0.1
+  A    subrepo/proj B/tags/v0.1/letter .txt
+  A    subrepo/proj B/tags/v0.2
+  A    subrepo/proj B/tags/v0.2/letter .txt
+  A    subrepo/proj B/tags/v0.2/letter2.txt
+  Checked out revision 9.
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ ls
+  file1.txt
+  file2.txt
+  subrepo