Patchwork [3,of,3,RFC,V2] setup: use changes since latest tag instead of just distance

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 13, 2014, 1:02 a.m.
Message ID <b00b4bbaefac444a40dc.1418432550@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7071/
State Accepted
Commit eb55e09202c82b8e26d19d1b04ed1fdadadff60f
Delegated to: Matt Mackall
Headers show

Comments

Siddharth Agarwal - Dec. 13, 2014, 1:02 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1418427088 28800
#      Fri Dec 12 15:31:28 2014 -0800
# Node ID b00b4bbaefac444a40dcadb2e019c4c6b463d9d6
# Parent  71df59b4066e7df2b38c81376fb4152c5735e311
setup: use changes since latest tag instead of just distance

For a Mercurial built on the merge from stable into default right after 3.2.2
was released -- 19ebd2f88fc7 -- the version number produced was "3.2.2+4". This
is potentially misleading, since in reality the built Mercurial includes many
more changes compared to 3.2.2.

Change the versioning scheme so that we take into consideration all the changes
present in the current revision that aren't present in the latest tag. For
19ebd2f88fc7 the new versioning scheme results in a version number of
"3.2.2+256". This gives users a much better idea of how many changes have
actually happened since the latest release.

Since changessincelatesttag is always greater than or equal to the
latesttagdistance, this will produce version numbers that are always greater
than or equal to the old scheme. Thus there's minimal compatibility risk.
Pierre-Yves David - Dec. 14, 2014, 10:17 p.m.
On 12/12/2014 05:02 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1418427088 28800
> #      Fri Dec 12 15:31:28 2014 -0800
> # Node ID b00b4bbaefac444a40dcadb2e019c4c6b463d9d6
> # Parent  71df59b4066e7df2b38c81376fb4152c5735e311
> setup: use changes since latest tag instead of just distance

The change sounds a good idea.

The goos seems fine at first glance.

I'll let Matt take a decision on that.
Matt Mackall - Dec. 23, 2014, 6:51 p.m.
On Fri, 2014-12-12 at 17:02 -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1418427088 28800
> #      Fri Dec 12 15:31:28 2014 -0800
> # Node ID b00b4bbaefac444a40dcadb2e019c4c6b463d9d6
> # Parent  71df59b4066e7df2b38c81376fb4152c5735e311
> setup: use changes since latest tag instead of just distance

These are queued for default, thanks.

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -196,9 +196,13 @@ 
         if hgid.endswith('+'): # propagate the dirty status to the tag
             version += '+'
     else: # no tag found
-        cmd = [sys.executable, 'hg', 'parents', '--template',
-               '{latesttag}+{latesttagdistance}-']
-        version = runhg(cmd, env) + hgid
+        ltagcmd = [sys.executable, 'hg', 'parents', '--template',
+                   '{latesttag}']
+        ltag = runhg(ltagcmd, env)
+        changessincecmd = [sys.executable, 'hg', 'log', '-T', 'x\n', '-r',
+                           "only(.,'%s')" % ltag]
+        changessince = len(runhg(changessincecmd, env).splitlines())
+        version = '%s+%s-%s' % (ltag, changessince, hgid)
     if version.endswith('+'):
         version += time.strftime('%Y%m%d')
 elif os.path.exists('.hg_archival.txt'):