Patchwork Add support for english date names on non-english systems

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date Feb. 27, 2015, 3:15 p.m.
Message ID <1425050122.15413.9.camel@Iris>
Download mbox | patch
Permalink /patch/7847/
State Deferred
Headers show

Comments

Jordi Gutiérrez Hermoso - Feb. 27, 2015, 3:15 p.m.
On Fri, 2015-02-27 at 12:29 +0100, A. Klitzing wrote:
> Thanks for your reply. I attached a new patch with improved commit
> message.

What Yuya meant is that we expected in the body of your email a commit
like the one below. That is, the commit message should be the body of
your email message.

Yes, put your blog post in your commit message. Include a poem, if you
want. Or a novel that proceeds as slowly as life itself about an
adulterous woman, disgraced by Russian society, who suicides on the
train tracks. Make your commit message lyrical, gigantic, beautiful.
Or if you possess the soul of wit and have time to make it shorter, do
so. Anything you have to say should go in the commit message. Look at
some examples in `hg log -v`.

The Mercurial patchbomb extension can help you do this.

# HG changeset patch
# User André Klitzing <aklitzing@gmail.com>
# Date 1424783533 -3600
#      Tue Feb 24 14:12:13 2015 +0100
# Node ID 619543a27d036264977bd5ca97be688416ce4cc9
# Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
util: accept "now, today, yesterday" for dates even the locale is not english

Hi there!

Fixed date names are helpful for automated systems. So it is possible to
use english date parameter even if the underlying system uses another
locale.

We have here a jenkins with build jobs on different slaves that will do
some operations with "dates" parameter. Some systems uses English locale
and some systems uses German locale. So we needed to configure the job to
uses other date names.

As this is really annoying to keep the systems locale in mind for some
operations I looked into util.py. It would be helpful for automated systems
if the "default English" date names would even usable on other
locales.

I attached a simple patch for this.

Best regards
  André Klitzing
Matt Mackall - March 3, 2015, 7:50 p.m.
On Fri, 2015-02-27 at 10:15 -0500, Jordi Gutiérrez Hermoso wrote:
> On Fri, 2015-02-27 at 12:29 +0100, A. Klitzing wrote:
> > Thanks for your reply. I attached a new patch with improved commit
> > message.
> 
> What Yuya meant is that we expected in the body of your email a commit
> like the one below. That is, the commit message should be the body of
> your email message.
> 
> Yes, put your blog post in your commit message. Include a poem, if you
> want. Or a novel that proceeds as slowly as life itself about an
> adulterous woman, disgraced by Russian society, who suicides on the
> train tracks. Make your commit message lyrical, gigantic, beautiful.
> Or if you possess the soul of wit and have time to make it shorter, do
> so. Anything you have to say should go in the commit message. Look at
> some examples in `hg log -v`.
> 
> The Mercurial patchbomb extension can help you do this.
> 
> # HG changeset patch
> # User André Klitzing <aklitzing@gmail.com>
> # Date 1424783533 -3600
> #      Tue Feb 24 14:12:13 2015 +0100
> # Node ID 619543a27d036264977bd5ca97be688416ce4cc9
> # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> util: accept "now, today, yesterday" for dates even the locale is not english

I've queued Jordi's reformat of this patch, thanks. For future
reference, we don't accept patches as attachments because we can't
review them with the reply button.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1350,11 +1350,11 @@ 
         formats = defaultdateformats
     date = date.strip()
 
-    if date == _('now'):
+    if date == 'now' or date == _('now'):
         return makedate()
-    if date == _('today'):
+    if date == 'today' or date == _('today'):
         date = datetime.date.today().strftime('%b %d')
-    elif date == _('yesterday'):
+    elif date == 'yesterday' or date == _('yesterday'):
         date = (datetime.date.today() -
                 datetime.timedelta(days=1)).strftime('%b %d')