[PATCH 5 of 7 mergedriver] merge.applyupdates: use counters from mergestate

Martin von Zweigbergk martinvonz at google.com
Mon Nov 23 05:32:26 UTC 2015


On Fri, Nov 20, 2015 at 5:05 PM Siddharth Agarwal <sid0 at fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0 at fb.com>
> # Date 1448066259 28800
> #      Fri Nov 20 16:37:39 2015 -0800
> # Node ID 9f9a937bb5af83115f1c3349fd2058bb82fe4486
> # Parent  45f8add0d3082f025c7f3e67b1e28cd78680e72f
> # Available At http://42.netv6.net/sid0-wip/hg/
> #              hg pull http://42.netv6.net/sid0-wip/hg/ -r 9f9a937bb5af
> merge.applyupdates: use counters from mergestate
>
> This eliminates a whole bunch of duplicate code and allows us to update the
> removed count for change/delete conflicts where the delete action was
> chosen.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -944,7 +944,7 @@ def applyupdates(repo, actions, wctx, mc
>      describes how many files were affected by the update.
>      """
>
> -    updated, merged, removed, unresolved = 0, 0, 0, 0
> +    updated, merged, removed = 0, 0, 0
>      ms = mergestate.clean(repo, wctx.p1().node(), mctx.node())
>      moves = []
>      for m, l in actions.items():
> @@ -1084,15 +1084,7 @@ def applyupdates(repo, actions, wctx, mc
>              continue
>          audit(f)
>          complete, r = ms.preresolve(f, wctx, labels=labels)
>

Can 'preresolve' now stop returning the 'r' value now? I saw that it's also
used in commands.py:5677, but maybe there's now a better way to do that
just there was here?


> -        if complete:
> -            if r is not None and r > 0:
> -                unresolved += 1
> -            else:
> -                if r is None:
> -                    updated += 1
> -                else:
> -                    merged += 1
> -        else:
> +        if not complete:
>              numupdates += 1
>              tocomplete.append((f, args, msg))
>
> @@ -1101,17 +1093,12 @@ def applyupdates(repo, actions, wctx, mc
>          repo.ui.debug(" %s: %s -> m (merge)\n" % (f, msg))
>          z += 1
>          progress(_updating, z, item=f, total=numupdates, unit=_files)
> -        r = ms.resolve(f, wctx, labels=labels)
> -        if r is not None and r > 0:
> -            unresolved += 1
> -        else:
> -            if r is None:
> -                updated += 1
> -            else:
> -                merged += 1
> +        ms.resolve(f, wctx, labels=labels)
>
>      ms.commit()
>
> +    unresolved = ms.unresolvedcount()
> +
>      if usemergedriver and not unresolved and ms.mdstate() != 's':
>          if not driverconclude(repo, ms, wctx, labels=labels):
>              # XXX setting unresolved to at least 1 is a hack to make sure
> we
> @@ -1120,6 +1107,10 @@ def applyupdates(repo, actions, wctx, mc
>
>          ms.commit()
>
> +    msupdated, msmerged, msremoved = ms.counts()
> +    updated += msupdated
> +    merged += msmerged
> +    removed += msremoved
>      progress(_updating, None, total=numupdates, unit=_files)
>
>      return updated, merged, removed, unresolved
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20151123/c71e1646/attachment-0002.html>


More information about the Mercurial-devel mailing list