Patchwork [3,of,3,[STABLE,V2] ] subrepo: make it possible to update to hidden subrepo revisions

login
register
mail settings
Submitter Angel Ezquerra
Date Jan. 22, 2014, 7:17 a.m.
Message ID <82f6a23bff15158f7d01.1390375061@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/3399/
State Accepted
Commit 427d672c0e4e07642d2400a28946cefde11e04ff
Headers show

Comments

Angel Ezquerra - Jan. 22, 2014, 7:17 a.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1385255837 -3600
#      Sun Nov 24 02:17:17 2013 +0100
# Branch stable
# Node ID 82f6a23bff15158f7d013c6b0655b300becbfedd
# Parent  f6fea99f0271185fe272cc5d0366ca537f6c45b6
subrepo: make it possible to update to hidden subrepo revisions

When a subrepo revision was hidden it was considered missing and mercurial was
unable to update to the corresponding parent revision. Instead warn the user of
the problem and let it choose what to do (the default is to udpate anyway).
Matt Mackall - Jan. 24, 2014, 12:10 a.m.
On Wed, 2014-01-22 at 08:17 +0100, Angel Ezquerra wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra@gmail.com>
> # Date 1385255837 -3600
> #      Sun Nov 24 02:17:17 2013 +0100
> # Branch stable
> # Node ID 82f6a23bff15158f7d013c6b0655b300becbfedd
> # Parent  f6fea99f0271185fe272cc5d0366ca537f6c45b6
> subrepo: make it possible to update to hidden subrepo revisions
> 
> When a subrepo revision was hidden it was considered missing and mercurial was
> unable to update to the corresponding parent revision. Instead warn the user of
> the problem and let it choose what to do (the default is to udpate anyway).

Queued these for stable as they smell enough like a bug a fix to go in
during the freeze. Thanks!
Angel Ezquerra - Jan. 24, 2014, 12:34 a.m.
On Thu, Jan 23, 2014 at 4:10 PM, Matt Mackall <mpm@selenic.com> wrote:
> On Wed, 2014-01-22 at 08:17 +0100, Angel Ezquerra wrote:
>> # HG changeset patch
>> # User Angel Ezquerra <angel.ezquerra@gmail.com>
>> # Date 1385255837 -3600
>> #      Sun Nov 24 02:17:17 2013 +0100
>> # Branch stable
>> # Node ID 82f6a23bff15158f7d013c6b0655b300becbfedd
>> # Parent  f6fea99f0271185fe272cc5d0366ca537f6c45b6
>> subrepo: make it possible to update to hidden subrepo revisions
>>
>> When a subrepo revision was hidden it was considered missing and mercurial was
>> unable to update to the corresponding parent revision. Instead warn the user of
>> the problem and let it choose what to do (the default is to udpate anyway).
>
> Queued these for stable as they smell enough like a bug a fix to go in
> during the freeze. Thanks!

Thanks a lot! :-)

I just noticed however that the commit message of this last patch is
wrong. It says

"warn the user of the problem and let it choose what to do"

But in V2 of that patch we only give a warning (i.e. there is no prompt).

Sorry about that :-/

Angel

Patch

# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1385255837 -3600
#      Sun Nov 24 02:17:17 2013 +0100
# Branch stable
# Node ID 82f6a23bff15158f7d013c6b0655b300becbfedd
# Parent  f6fea99f0271185fe272cc5d0366ca537f6c45b6
subrepo: make it possible to update to hidden subrepo revisions

When a subrepo revision was hidden it was considered missing and mercurial was
unable to update to the corresponding parent revision. Instead warn the user of
the problem and let it choose what to do (the default is to udpate anyway).

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -702,7 +702,7 @@ 
     def _get(self, state):
         source, revision, kind = state
         if revision in self._repo.unfiltered():
-            return
+            return True
         self._repo._subsource = source
         srcurl = _abssource(self._repo)
         other = hg.peer(self._repo, {}, srcurl)
@@ -728,13 +728,23 @@ 
             if cleansub:
                 # keep the repo clean after pull
                 self._cachestorehash(srcurl)
+        return False
 
     @annotatesubrepoerror
     def get(self, state, overwrite=False):
-        self._get(state)
+        inrepo = self._get(state)
         source, revision, kind = state
-        self._repo.ui.debug("getting subrepo %s\n" % self._path)
-        hg.updaterepo(self._repo, revision, overwrite)
+        repo = self._repo
+        repo.ui.debug("getting subrepo %s\n" % self._path)
+        if inrepo:
+            urepo = repo.unfiltered()
+            ctx = urepo[revision]
+            if ctx.hidden():
+                urepo.ui.warn(
+                    _('revision %s in subrepo %s is hidden\n') \
+                    % (revision[0:12], self._path))
+                repo = urepo
+        hg.updaterepo(repo, revision, overwrite)
 
     @annotatesubrepoerror
     def merge(self, state):
diff --git a/tests/test-subrepo-missing.t b/tests/test-subrepo-missing.t
--- a/tests/test-subrepo-missing.t
+++ b/tests/test-subrepo-missing.t
@@ -68,4 +68,35 @@ 
   $ ls subrepo
   a
 
+Enable obsolete
+
+  $ cat > ${TESTTMP}/obs.py << EOF
+  > import mercurial.obsolete
+  > mercurial.obsolete._enabled = True
+  > EOF
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > logtemplate= {rev}:{node|short} {desc|firstline}
+  > [phases]
+  > publish=False
+  > [extensions]'
+  > obs=${TESTTMP}/obs.py
+  > EOF
+
+check that we can update parent repo with missing (amended) subrepo revision
+
+  $ hg up --repository subrepo -r tip
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg ci -m "updated subrepo to tip"
+  created new head
+  $ cd subrepo
+  $ hg update -r tip
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foo > a
+  $ hg commit --amend -m "addb (amended)"
   $ cd ..
+  $ hg update --clean .
+  revision 102a90ea7b4a in subrepo subrepo is hidden
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ cd ..