[PATCH 1 of 1] subrepo: check for dirty warns on missing revision instead of abort

Matt Mackall mpm at selenic.com
Thu May 12 18:30:37 CDT 2011


On Thu, 2011-05-12 at 20:32 +0200, Friedrich Kastner-Masilko wrote:
> # HG changeset patch
> # User Friedrich Kastner-Masilko <face at snoopie.at>
> # Date 1305203454 -7200
> # Node ID 8afba392a97c2fa6d90576c52d5fe8f8d9818e69
> # Parent  b0f97b2589cc1f2c07c415c480c6ed02e347704a
> subrepo: check for dirty warns on missing revision instead of abort
> 
> There are certain situations where the user is stuck with an abort-message
> "abort: unknown revision 'rev'!" when dealing with subrepos. One of these
> situations is history-rewrite with rebase or strip.
> If you have e.g. a superrepo referencing the tip revision of a subrepo, and you
> strip away the tip in the subrepo, your superrepo is basically stuck. You can't
> "hg update" away from it, not even with "-C".
> 
> The expected behaviour would be to have "hg update -C" pull the subrepo again.
> This is prohibited by the dirty detection in subrepo throwing an exception. This
> patch is fixing this by means of issuing a warning instead. Additionally, a
> subrepo with unknown revision is returned as being dirty.
> 
> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> --- a/mercurial/subrepo.py
> +++ b/mercurial/subrepo.py
> @@ -408,8 +408,13 @@
>          if r == '' and not ignoreupdate: # no state recorded
>              return True
>          w = self._repo[None]
> -        if w.p1() != self._repo[r] and not ignoreupdate:
> -            # different version checked out
> +        try:
> +            if w.p1() != self._repo[r] and not ignoreupdate:
> +                # different version checked out
> +                return True
> +        except error.RepoLookupError, inst:
> +            self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n')
> +                               % (inst, subrelpath(self)))
>              return True
>          return w.dirty() # working directory changed

This patch seems unnecessarily complex. Does this do what you want?

diff -r 9bbac962f4dd mercurial/subrepo.py
--- a/mercurial/subrepo.py	Thu May 12 20:27:35 2011 +0200
+++ b/mercurial/subrepo.py	Thu May 12 18:27:46 2011 -0500
@@ -408,7 +408,7 @@
         if r == '' and not ignoreupdate: # no state recorded
             return True
         w = self._repo[None]
-        if w.p1() != self._repo[r] and not ignoreupdate:
+        if r != w.p1().node() and not ignoreupdate:
             # different version checked out
             return True
         return w.dirty() # working directory changed

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list