On Wed, Apr 29, 2009 at 1:30 PM,  <[email protected]> wrote:
> # HG changeset patch
> # User Trey Roessig
> # Date 1241029346 25200
> # Node ID b73e08c25108414e384cc2ed80008bd38a09c382
> # Parent  028b6666aa594c6a51bc7d51f66a14192a949c5b
> commit: add message format check
>
> checks for formatting on commit

good stuff

>
> diff -r 028b6666aa59 -r b73e08c25108 hggtk/commit.py
> --- a/hggtk/commit.py   Wed Apr 29 10:49:23 2009 -0700
> +++ b/hggtk/commit.py   Wed Apr 29 11:22:26 2009 -0700
> @@ -539,6 +539,47 @@
>                    _('Please enter commit message'), self).run()
>             self.text.grab_focus()
>             return False
> +
> +        try:
> +            sumlen = int(self.repo.ui.config('tortoisehg', 'summarylen', 0))
> +            maxlen = int(self.repo.ui.config('tortoisehg', 'messagewrap', 0))
> +        except (TypeError, ValueError):
> +            Prompt(_('Error'),
> +                   _('Message format configuration error'),
> +                   self).run()
> +            self._msg_config(None)
> +            return
> +
> +        lines = buf.get_text(buf.get_start_iter(),
> +                             buf.get_end_iter()).splitlines()
> +
> +        if sumlen and len(lines[0].rstrip()) > sumlen:
> +            resp = Confirm(_('Commit'), [], self,
> +                           _('The summary line length of %i is greater than'
> +                             ' %i.  Would you like to continue?' %

The gettext wrapper _() should only go around the string.

> +                                (len(lines[0].rstrip()), sumlen))).run()
> +            if resp != gtk.RESPONSE_YES:
> +                return False
> +        if sumlen and len(lines) > 1 and len(lines[1].strip()):
> +            resp = Confirm(_('Commit'), [], self,
> +                           _('The summary line is not followed by a blank'
> +                             ' line.  Would you like to continue?')).run()

perhaps 'Ignore format policy and continue commit?'  And you can use
\n line feeds here if you feel it improves the look of the dialog.

> +            if resp != gtk.RESPONSE_YES:
> +                return False
> +        if maxlen:
> +            start = int(sumlen > 0)
> +            tmp = [len(x.rstrip()) > maxlen for x in lines[start:]]
> +            errs = [str(x[1]+start+1) for x in zip(tmp, range(len(tmp)))
> +                    if x[0]]
> +            if errs:
> +                resp = Confirm(_('Commit'), [], self,
> +                               _('The following lines are over the %i-'
> +                                 'character limit: %s.  Would you like'
> +                                 ' to continue?' %

Ditto both above comments

--
Steve Borho

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to