From patchwork Wed Jan 12 05:53:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 473101 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0C8XI23022364 for ; Wed, 12 Jan 2011 08:33:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751272Ab1ALFqA (ORCPT ); Wed, 12 Jan 2011 00:46:00 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:58949 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755Ab1ALFp7 (ORCPT ); Wed, 12 Jan 2011 00:45:59 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id BE00B1B4119; Wed, 12 Jan 2011 05:45:58 +0000 (UTC) From: Mike Frysinger To: linux-kbuild@vger.kernel.org, Michal Marek Cc: Mike Crowe Subject: [PATCH] setlocalversion: update mercurial tag parsing Date: Wed, 12 Jan 2011 00:53:52 -0500 Message-Id: <1294811632-23688-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.4.rc1 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 12 Jan 2011 08:33:33 +0000 (UTC) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index ef8729f..4d40384 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -86,12 +86,16 @@ scm_version() # Check for mercurial and a mercurial repo. if test -d .hg && hgid=`hg id 2>/dev/null`; then - tag=`printf '%s' "$hgid" | cut -s -d' ' -f2` - - # Do we have an untagged version? - if [ -z "$tag" -o "$tag" = tip ]; then - id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + # Do we have an tagged version? If so, latesttagdistance == 1 + if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then + id=`hg log -r . --template '{latesttag}'` printf '%s%s' -hg "$id" + else + tag=`printf '%s' "$hgid" | cut -d' ' -f2` + if [ -z "$tag" -o "$tag" = tip ]; then + id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + printf '%s%s' -hg "$id" + fi fi # Are there uncommitted changes?