[PATCH] localrepo: provide progress updates during commit

Augie Fackler lists at durin42.com
Thu Nov 10 11:44:48 CST 2011


On Mon, Nov 7, 2011 at 8:41 PM, David Golub <golubdr at gmail.com> wrote:
> # HG changeset patch
> # User David Golub <golubdr at gmail.com>
> # Date 1320720015 18000
> # Branch stable
> # Node ID 40a50eda9f5790d00fd5da68225d6fdd2f34bed2
> # Parent  54c0517c0fe8af4f8851a1bbb5bb229f0e7dd853
> localrepo: provide progress updates during commit
>
> diff -r 54c0517c0fe8 -r 40a50eda9f57 mercurial/localrepo.py
> --- a/mercurial/localrepo.py    Fri Nov 04 10:31:38 2011 +0100
> +++ b/mercurial/localrepo.py    Mon Nov 07 21:40:15 2011 -0500
> @@ -1166,9 +1166,14 @@
>
>                 # check in files
>                 new = {}
> +                total = len(ctx.modified() + ctx.added())
> +                i = 0
>                 changed = []
>                 linkrev = len(self)
>                 for f in sorted(ctx.modified() + ctx.added()):
> +                    i += 1

Rather than maintain a counter like this, please use the enumerate() builtin.

> +                    self.ui.progress(_('committing'), i, total=total,
> +                                     unit=_('files'))
>                     self.ui.note(f + "\n")
>                     try:
>                         fctx = ctx[f]
> @@ -1185,6 +1190,7 @@
>                             raise
>                         else:
>                             removed.append(f)
> +                self.ui.progress(_('committing'), None)
>
>                 # update manifest
>                 m1.update(new)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list