Patchwork [1,of,4,random] convert: when converting from monotone, use the number 1 for close in extras

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 27, 2015, 8:45 p.m.
Message ID <1bb2e55f98580e20b6d5.1425069915@madski>
Download mbox | patch
Permalink /patch/7850/
State Accepted
Commit 8ca263d9f0700a329a04806c808efb53c6b5983a
Headers show

Comments

Mads Kiilerich - Feb. 27, 2015, 8:45 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1421794937 -3600
#      Wed Jan 21 00:02:17 2015 +0100
# Node ID 1bb2e55f98580e20b6d5b95c4f3ba41d213b74cd
# Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
convert: when converting from monotone, use the number 1 for close in extras

Monotone used '1' for close while core Mercurial use 1. Now, for consistency,
use the same value everywhere. It will be stored as a string anyway and the
change will not make any real difference.

(The actual value of 'close' doesn't matter as long as extras has such a key.)
Ryan McElroy - Feb. 28, 2015, 3:33 a.m.
On 2/27/2015 12:45 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1421794937 -3600
> #      Wed Jan 21 00:02:17 2015 +0100
> # Node ID 1bb2e55f98580e20b6d5b95c4f3ba41d213b74cd
> # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> convert: when converting from monotone, use the number 1 for close in extras
>
> Monotone used '1' for close while core Mercurial use 1. Now, for consistency,

grammar nit-pick: "Mercurial uses 1" (note the s for present tense)

> use the same value everywhere. It will be stored as a string anyway and the
> change will not make any real difference.
>
> (The actual value of 'close' doesn't matter as long as extras has such a key.)
>
> diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
> --- a/hgext/convert/monotone.py
> +++ b/hgext/convert/monotone.py
> @@ -297,7 +297,7 @@ class monotone_source(converter_source,
>           extra = {}
>           certs = self.mtngetcerts(rev)
>           if certs.get('suspend') == certs["branch"]:
> -            extra['close'] = '1'
> +            extra['close'] = 1

If you're worried about consistency, why not introduce a constant that 
will be used to signify what this means, and can be used everywhere 
uniformly.

>           return commit(
>               author=certs["author"],
>               date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")),
>
Augie Fackler - March 3, 2015, 4:15 p.m.
On Fri, Feb 27, 2015 at 07:33:36PM -0800, Ryan McElroy wrote:
>
>
> On 2/27/2015 12:45 PM, Mads Kiilerich wrote:
> ># HG changeset patch
> ># User Mads Kiilerich <madski@unity3d.com>
> ># Date 1421794937 -3600
> >#      Wed Jan 21 00:02:17 2015 +0100
> ># Node ID 1bb2e55f98580e20b6d5b95c4f3ba41d213b74cd
> ># Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> >convert: when converting from monotone, use the number 1 for close in extras
> >
> >Monotone used '1' for close while core Mercurial use 1. Now, for consistency,
>
> grammar nit-pick: "Mercurial uses 1" (note the s for present tense)
>
> >use the same value everywhere. It will be stored as a string anyway and the
> >change will not make any real difference.
> >
> >(The actual value of 'close' doesn't matter as long as extras has such a key.)
> >
> >diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
> >--- a/hgext/convert/monotone.py
> >+++ b/hgext/convert/monotone.py
> >@@ -297,7 +297,7 @@ class monotone_source(converter_source,
> >          extra = {}
> >          certs = self.mtngetcerts(rev)
> >          if certs.get('suspend') == certs["branch"]:
> >-            extra['close'] = '1'
> >+            extra['close'] = 1
>
> If you're worried about consistency, why not introduce a constant that will
> be used to signify what this means, and can be used everywhere uniformly.

If someone were to write that patch, I'd be happy to take it.

>
> >          return commit(
> >              author=certs["author"],
> >              date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")),
> >
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -297,7 +297,7 @@  class monotone_source(converter_source, 
         extra = {}
         certs = self.mtngetcerts(rev)
         if certs.get('suspend') == certs["branch"]:
-            extra['close'] = '1'
+            extra['close'] = 1
         return commit(
             author=certs["author"],
             date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")),