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

login
register
mail settings
Submitter Angel Ezquerra
Date Nov. 25, 2013, 8:46 p.m.
Message ID <744f6a7b25cd7ea810dd.1385412409@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/3136/
State Superseded
Commit 427d672c0e4e07642d2400a28946cefde11e04ff
Headers show

Comments

Angel Ezquerra - Nov. 25, 2013, 8:46 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1385255837 -3600
#      Sun Nov 24 02:17:17 2013 +0100
# Node ID 744f6a7b25cd7ea810ddcce3724ed82108706d5c
# Parent  15941436e0ab88dee0f5321f737bcf4bc9774fce
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).
Angel Ezquerra - Jan. 16, 2014, 9:19 p.m.
Forwarding Pierre-Yves┬┤s comment to the list:

---------- Forwarded message ----------
From: Pierre-Yves David <pierre-yves.david@ens-lyon.org>
Date: Wed, Jan 15, 2014 at 4:07 PM
Subject: Re: [PATCH 3 of 4] subrepo: make it possible to update to
hidden subrepo revisions
To: Angel Ezquerra <angel.ezquerra@gmail.com>


On 11/25/2013 12:46 PM, Angel Ezquerra wrote:
>
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra@gmail.com>
> # Date 1385255837 -3600
> #      Sun Nov 24 02:17:17 2013 +0100
> # Node ID 744f6a7b25cd7ea810ddcce3724ed82108706d5c
> # Parent  15941436e0ab88dee0f5321f737bcf4bc9774fce
> 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).


I'm not sure about the choice part. What about updating to it anyway
and printing a big red warning.

The user is asking for an upgrade of the super-repo, lets give him this update.

--
Pierre-Yves
Angel Ezquerra - Jan. 16, 2014, 9:20 p.m.
> From: Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> Date: Wed, Jan 15, 2014 at 4:07 PM
> Subject: Re: [PATCH 3 of 4] subrepo: make it possible to update to
> hidden subrepo revisions
> To: Angel Ezquerra <angel.ezquerra@gmail.com>
>
>
> On 11/25/2013 12:46 PM, Angel Ezquerra wrote:
>>
>> # HG changeset patch
>> # User Angel Ezquerra <angel.ezquerra@gmail.com>
>> # Date 1385255837 -3600
>> #      Sun Nov 24 02:17:17 2013 +0100
>> # Node ID 744f6a7b25cd7ea810ddcce3724ed82108706d5c
>> # Parent  15941436e0ab88dee0f5321f737bcf4bc9774fce
>> 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).
>
>
> I'm not sure about the choice part. What about updating to it anyway
> and printing a big red warning.
>
> The user is asking for an upgrade of the super-repo, lets give him this update.

I'd be fine with that. I'll make it so on the next version of this series.

Cheers,

Angel

Patch

# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1385255837 -3600
#      Sun Nov 24 02:17:17 2013 +0100
# Node ID 744f6a7b25cd7ea810ddcce3724ed82108706d5c
# Parent  15941436e0ab88dee0f5321f737bcf4bc9774fce
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
@@ -650,7 +650,7 @@ 
         source, revision, kind = state
         urepo = self._repo.unfiltered()
         if revision in urepo:
-            return
+            return True
         self._repo._subsource = source
         srcurl = _abssource(self._repo)
         other = hg.peer(self._repo, {}, srcurl)
@@ -676,13 +676,25 @@ 
             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():
+                choice = urepo.ui.promptchoice(
+                    _('target revision (%s) in subrepo %s is hidden\n'
+                      'do you want to update to it anyway (Yn)? '
+                      '$$ &Yes $$ &No') % (revision[0:12], self._path))
+                if choice == 0:
+                    repo = urepo
+        hg.updaterepo(repo, revision, overwrite)
 
     @annotatesubrepoerror
     def merge(self, state):