Patchwork [2,of,2] clone: check update rev for being True

login
register
mail settings
Submitter Sean Farley
Date Sept. 24, 2015, 11:08 p.m.
Message ID <d39fa261f9d7491a3b15.1443136087@laptop.office.atlassian.com>
Download mbox | patch
Permalink /patch/10617/
State Accepted
Headers show

Comments

Sean Farley - Sept. 24, 2015, 11:08 p.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1443135131 25200
#      Thu Sep 24 15:52:11 2015 -0700
# Node ID d39fa261f9d7491a3b15ca603721747904314386
# Parent  d19a61caa7c7abb23316df0458954403f2176b13
clone: check update rev for being True

In 30be3aeb5344, there was an attempt to fallback to looking up the update
revision assuming it was always a rev but the documentation states:

  True means update to default rev, anything else is treated as a revision

Therefore, we should only fallback to looking up the update rev if it is not
True. This bug was found in hg-git and I couldn't think of a test that does
this in pure Mercurial since the source repository is checked for the revision
as well (and therefore gracefully falls back).
Augie Fackler - Sept. 25, 2015, 5:35 p.m.
On Thu, Sep 24, 2015 at 04:08:07PM -0700, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1443135131 25200
> #      Thu Sep 24 15:52:11 2015 -0700
> # Node ID d39fa261f9d7491a3b15ca603721747904314386
> # Parent  d19a61caa7c7abb23316df0458954403f2176b13
> clone: check update rev for being True

Queued these, thanks!

>
> In 30be3aeb5344, there was an attempt to fallback to looking up the update
> revision assuming it was always a rev but the documentation states:
>
>   True means update to default rev, anything else is treated as a revision
>
> Therefore, we should only fallback to looking up the update rev if it is not
> True. This bug was found in hg-git and I couldn't think of a test that does
> this in pure Mercurial since the source repository is checked for the revision
> as well (and therefore gracefully falls back).
>
> diff --git a/mercurial/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -580,14 +580,15 @@ def clone(ui, peeropts, source, dest=Non
>                  status = None
>                  if checkout is not None:
>                      try:
>                          uprev = destrepo.lookup(checkout)
>                      except error.RepoLookupError:
> -                        try:
> -                            uprev = destrepo.lookup(update)
> -                        except error.RepoLookupError:
> -                            pass
> +                        if update is not True:
> +                            try:
> +                                uprev = destrepo.lookup(update)
> +                            except error.RepoLookupError:
> +                                pass
>                  if uprev is None:
>                      try:
>                          uprev = destrepo._bookmarks['@']
>                          update = '@'
>                          bn = destrepo[uprev].branch()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -580,14 +580,15 @@  def clone(ui, peeropts, source, dest=Non
                 status = None
                 if checkout is not None:
                     try:
                         uprev = destrepo.lookup(checkout)
                     except error.RepoLookupError:
-                        try:
-                            uprev = destrepo.lookup(update)
-                        except error.RepoLookupError:
-                            pass
+                        if update is not True:
+                            try:
+                                uprev = destrepo.lookup(update)
+                            except error.RepoLookupError:
+                                pass
                 if uprev is None:
                     try:
                         uprev = destrepo._bookmarks['@']
                         update = '@'
                         bn = destrepo[uprev].branch()