[PATCH 3 of 3] svnsubrepo: check if subrepo is missing when checking dirty state (issue5657)

Jordi GutiƩrrez Hermoso jordigh at octave.org
Tue Jan 16 08:42:17 EST 2018


# HG changeset patch
# User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
# Date 1516110014 18000
#      Tue Jan 16 08:40:14 2018 -0500
# Node ID 3a379eceab7886ae9a8f661c648c2759c69a9013
# Parent  cebbb137db75c45e891a65a8dbc50631ed8cb83c
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.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1336,6 +1336,8 @@ class svnsubrepo(abstractsubrepo):
 
     @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:
diff --git a/tests/test-convert-svn-source.t b/tests/test-convert-svn-source.t
--- a/tests/test-convert-svn-source.t
+++ b/tests/test-convert-svn-source.t
@@ -253,3 +253,72 @@ depot that can be seen from the test env
   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


More information about the Mercurial-devel mailing list