[PATCH] subrepo: move prompts out of the if (issue5505)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Mar 17 20:28:14 EDT 2017


At Fri, 17 Mar 2017 13:10:57 -0700,
Simon Farnsworth wrote:
> 
> # HG changeset patch
> # User Simon Farnsworth <simonfar at fb.com>
> # Date 1489781443 25200
> #      Fri Mar 17 13:10:43 2017 -0700
> # Node ID 0ccc212fc0224209864e8c902920a91acd1bc414
> # Parent  a5bad127128d8f60060be53d161acfa7a32a17d5
> subrepo: move prompts out of the if (issue5505)
> 
> Prompts weren't available in the else clause
> 
> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> --- a/mercurial/subrepo.py
> +++ b/mercurial/subrepo.py
> @@ -195,6 +195,7 @@
>              r = "%s:%s:%s" % r
>          repo.ui.debug("  subrepo %s: %s %s\n" % (s, msg, r))
>  
> +    prompts = filemerge.partextras(labels)
>      for s, l in sorted(s1.iteritems()):
>          a = sa.get(s, nullstate)
>          ld = l # local state with possible dirty flag for compares
> @@ -203,9 +204,8 @@
>          if wctx == actx: # overwrite
>              a = ld
>  
> +        prompts['s'] = s
>          if s in s2:
> -            prompts = filemerge.partextras(labels)
> -            prompts['s'] = s
>              r = s2[s]
>              if ld == r or r == a: # no change or local is newer
>                  sm[s] = l
> @@ -275,6 +275,7 @@
>              mctx.sub(s).get(r)
>              sm[s] = r
>          elif r != sa[s]:
> +            prompts['s'] = s
>              if repo.ui.promptchoice(
>                  _(' remote%(o)s changed subrepository %(s)s'
>                    ' which local%(l)s removed\n'

How about copying before modification at each repetitions ?

    promptssrc = filemerge.partextras(labels)
    for s, l in sorted(s1.iteritems()):
        ....
        prompts = promptssrc.copy()
        prompts['s'] = s

    ....
    for s, r in sorted(s2.items()):
        ....
        elif r != sa[s]:
            prompts = promptssrc.copy()
            prompts['s'] = s


("del prompts" before s2 loop for safety is over-killing ? :-) )

Sharing result of filemerge.partextras() between each repetitions and
modifying it directly might cause wrong information, which is assigned
at previous repetition, like below.

In this case, shallow copy seems cheap enough.

> diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
> --- a/tests/test-subrepo.t
> +++ b/tests/test-subrepo.t
> @@ -349,7 +349,7 @@
>  local removed, remote changed, keep changed
>  
>    $ hg merge 6
> -   remote [merge rev] changed subrepository s which local [working copy] removed
> +   remote [merge rev] changed subrepository t which local [working copy] removed
>    use (c)hanged version or (d)elete? c
>    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    (branch merge, don't forget to commit)
> @@ -380,7 +380,7 @@
>    $ hg merge --config ui.interactive=true 6 <<EOF
>    > d
>    > EOF
> -   remote [merge rev] changed subrepository s which local [working copy] removed
> +   remote [merge rev] changed subrepository t which local [working copy] removed
>    use (c)hanged version or (d)elete? d
>    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    (branch merge, don't forget to commit)

According to "hg debugsub" output in test-subrepo.t, merging revision
6 into revision 11 decreases managed subrepos from "s, t" to "s".

  $ hg ci -m6 # change sub
  committing subrepository t
  $ hg debugsub
  path s
   source   s
   revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
  path t
   source   t
   revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad

  ....

  $ hg ci -m11
  created new head
  $ hg debugsub
  path s
   source   s
   revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4

Therefore, subrepo removed on "local" side is not "s" but "t" at this
merging, and changes (or fixing wrong expectations) above seem
reasonable.


> @@ -404,7 +404,7 @@
>    $ hg co -C 6
>    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    $ hg merge 11
> -   local [working copy] changed subrepository s which remote [merge rev] removed
> +   local [working copy] changed subrepository t which remote [merge rev] removed
>    use (c)hanged version or (d)elete? c
>    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    (branch merge, don't forget to commit)
> @@ -436,7 +436,7 @@
>    $ hg merge --config ui.interactive=true 11 <<EOF
>    > d
>    > EOF
> -   local [working copy] changed subrepository s which remote [merge rev] removed
> +   local [working copy] changed subrepository t which remote [merge rev] removed
>    use (c)hanged version or (d)elete? d
>    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    (branch merge, don't forget to commit)

On the other hand, merging revision 11 into revision 6 increases
managed subrepos from "s" to "s, t".

Therefore, subrepo removed on "remote" side is not "s" but "t" at this
merging, and changes above seem reasonable, too.


> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

-- 
----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list