Marek Marczykowski
2013-Apr-10 23:32 UTC
[PATCH] Try to use git commit id if hg changeset is unavailable
As Xen uses git as primary repository, get git commit id for xen_changeset info. Maybe hg code should be removed completely? Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> --- xen/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/Makefile b/xen/Makefile index 0fb3db7..9e4e6f3 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner -e ''s/@@version@@/$(XEN_VERSION)/g'' \ -e ''s/@@subversion@@/$(XEN_SUBVERSION)/g'' \ -e ''s/@@extraversion@@/$(XEN_EXTRAVERSION)/g'' \ - -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g'' \ + -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || git show -s --pretty="%ad %h" || echo "unavailable") 2>/dev/null | tr -d ''\n'')!g'' \ < include/xen/compile.h.in > $@.new @grep \" .banner >> $@.new @grep -v \" .banner -- 1.8.1.4
Keir Fraser
2013-Apr-11 06:40 UTC
Re: [PATCH] Try to use git commit id if hg changeset is unavailable
On 11/04/2013 00:32, "Marek Marczykowski" <marmarek@invisiblethingslab.com> wrote:> As Xen uses git as primary repository, get git commit id for > xen_changeset info. > > Maybe hg code should be removed completely? > > Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>I think we could just remove the hg code. Any other opinions? -- Keir> --- > xen/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/xen/Makefile b/xen/Makefile > index 0fb3db7..9e4e6f3 100644 > --- a/xen/Makefile > +++ b/xen/Makefile > @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner > -e ''s/@@version@@/$(XEN_VERSION)/g'' \ > -e ''s/@@subversion@@/$(XEN_SUBVERSION)/g'' \ > -e ''s/@@extraversion@@/$(XEN_EXTRAVERSION)/g'' \ > - -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} > {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} > {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g'' \ > + -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} > {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} > {rev}:{node|short}") || git show -s --pretty="%ad %h" || echo "unavailable") > 2>/dev/null | tr -d ''\n'')!g'' \ > < include/xen/compile.h.in > $@.new > @grep \" .banner >> $@.new > @grep -v \" .banner
Jan Beulich
2013-Apr-11 07:28 UTC
Re: [PATCH] Try to use git commit id if hg changeset is unavailable
>>> On 11.04.13 at 08:40, Keir Fraser <keir.xen@gmail.com> wrote: > On 11/04/2013 00:32, "Marek Marczykowski" <marmarek@invisiblethingslab.com> wrote: > >> As Xen uses git as primary repository, get git commit id for >> xen_changeset info. >> >> Maybe hg code should be removed completely? >> >> Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> > > I think we could just remove the hg code. Any other opinions?No. But if we someone wants it to be retained, the git invocation should precede the hg one in any case. Jan>> --- >> xen/Makefile | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/xen/Makefile b/xen/Makefile >> index 0fb3db7..9e4e6f3 100644 >> --- a/xen/Makefile >> +++ b/xen/Makefile >> @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner >> -e ''s/@@version@@/$(XEN_VERSION)/g'' \ >> -e ''s/@@subversion@@/$(XEN_SUBVERSION)/g'' \ >> -e ''s/@@extraversion@@/$(XEN_EXTRAVERSION)/g'' \ >> - -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} >> {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} >> {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g'' \ >> + -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} >> {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} >> {rev}:{node|short}") || git show -s --pretty="%ad %h" || echo "unavailable") >> 2>/dev/null | tr -d ''\n'')!g'' \ >> < include/xen/compile.h.in > $@.new >> @grep \" .banner >> $@.new >> @grep -v \" .banner > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Sander Eikelenboom
2013-Apr-11 07:33 UTC
Re: [PATCH] Try to use git commit id if hg changeset is unavailable
Thursday, April 11, 2013, 1:32:05 AM, you wrote:> As Xen uses git as primary repository, get git commit id for > xen_changeset info.> Maybe hg code should be removed completely?> Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> > --- > xen/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-)> diff --git a/xen/Makefile b/xen/Makefile > index 0fb3db7..9e4e6f3 100644 > --- a/xen/Makefile > +++ b/xen/Makefile > @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner > -e ''s/@@version@@/$(XEN_VERSION)/g'' \ > -e ''s/@@subversion@@/$(XEN_SUBVERSION)/g'' \ > -e ''s/@@extraversion@@/$(XEN_EXTRAVERSION)/g'' \ > - -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g'' \ > + -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || git show -s --pretty="%ad %h" || echo "unavailable") 2>/dev/null | tr -d ''\n'')!g'' \ > < include/xen/compile.h.in > $@.new > @grep \" .banner >> $@.new > @grep -v \" .bannerHi Marek, Yesterday i was looking into the same, i tried to also reflect if the tree was dirty or not (after this discussion: http://lists.xen.org/archives/html/xen-devel/2013-02/msg02077.html). Haven''t got it in a nice oneliner though. Following that discussion the tree can be a: git tree, mercurial tree, tarball For both the git and mercurial tree, changes are tracked and it should be able to mark the tree as dirty when there are changes not in the upstream tree: a) uncommited changes (and untracked files) b) local commits (outgoing/not pushed) Git does have a option to mark the tree dirty for uncommitted changes, but probably due it''s philosophy of "my tree is as good as yours", this doesn''t work if the changes have been only locally committed and not pushed. Mercurial doesn''t have a facility to mark the tree as dirty. Another thing is the rev/node/hash to show, to me it would be preferable to: - get the last upstream commit this local tree was based on. - appended with -dirty if local commits or uncommitted changes dirty the tree. That''s what i have tried with the script below, but getting the upstream commit for mercurial proves difficult because some functions from hg''s revset (like remote() or outgoing()) seem unavailable on Debian squeeze. script: local dirty=false local changeset="" # Check for git and a git repo. if test -d "../.git" && changeset="`git rev-parse --verify --long origin/HEAD 2>/dev/null`"; then # If there are differences with remote, commited, uncommited or untracked, mark as dirty if [ -n "`git diff-index origin/HEAD 2>/dev/null`" -o -n "`git status --porcelain 2>/dev/null`" ]; then changeset="$changeset-dirty" fi changeset="git $changeset" fi # Check for mercurial and a mercurial repo. if [ -z "$changeset" ] && test -d "../.hg" && hg parents --template ''{date|date} {rev}:{node|short}'' >/dev/null && changeset="`hg parents --template ''{rev}:{node|short}''`"; then # If there are differences with remote, outgoing commits, uncommited or untracked, mark as dirty if [ -z "`hg outgoing | grep ''no changes found'' 2> /dev/null`" -o -n "`hg id | grep ''+''`" ]; then changeset="$changeset-dirty" fi changeset="mercurial $changeset" fi if [ -z "$changeset" ] && test -f "../.hg_archival.txt"; then # Determine changeset from node entry in ".hg_archival.txt" changeset="tarball $changeset" fi if [ -z "$changeset" ]; then changeset="unavailable" fi echo "changeset: $changeset" -- Sander
Ian Campbell
2013-Apr-11 07:41 UTC
Re: [PATCH] Try to use git commit id if hg changeset is unavailable
On Thu, 2013-04-11 at 08:33 +0100, Sander Eikelenboom wrote:> Thursday, April 11, 2013, 1:32:05 AM, you wrote: > > > As Xen uses git as primary repository, get git commit id for > > xen_changeset info. > > > Maybe hg code should be removed completely? > > > Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> > > --- > > xen/Makefile | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > diff --git a/xen/Makefile b/xen/Makefile > > index 0fb3db7..9e4e6f3 100644 > > --- a/xen/Makefile > > +++ b/xen/Makefile > > @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner > > -e ''s/@@version@@/$(XEN_VERSION)/g'' \ > > -e ''s/@@subversion@@/$(XEN_SUBVERSION)/g'' \ > > -e ''s/@@extraversion@@/$(XEN_EXTRAVERSION)/g'' \ > > - -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g'' \ > > + -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || git show -s --pretty="%ad %h" || echo "unavailable") 2>/dev/null | tr -d ''\n'')!g'' \ > > < include/xen/compile.h.in > $@.new > > @grep \" .banner >> $@.new > > @grep -v \" .banner > > Hi Marek, > > Yesterday i was looking into the same, i tried to also reflect if the tree was > dirty or not (after this discussion: > http://lists.xen.org/archives/html/xen-devel/2013-02/msg02077.html). > > Haven''t got it in a nice oneliner though.The one liner is getting a bit silly. Perhaps we should import something like Linux''s scripts/setlocalversion.> Following that discussion the tree can be a: git tree, mercurial tree, tarball > > For both the git and mercurial tree, changes are tracked and it should be able > to mark the tree as dirty when there are changes not in the upstream tree: > a) uncommited changes (and untracked files) > b) local commits (outgoing/not pushed) > > Git does have a option to mark the tree dirty for uncommitted changes, > but probably due it''s philosophy of "my tree is as good as yours", > this doesn''t work if the changes have been only locally committed and not pushed. > > Mercurial doesn''t have a facility to mark the tree as dirty. > > Another thing is the rev/node/hash to show, to me it would be preferable to: > - get the last upstream commit this local tree was based on. > - appended with -dirty if local commits or uncommitted changes dirty the tree.I think it is best to show the actual literal commit which was used, whether or not that has been pushed. That''s useful to me as a dev when I am building locally and when users report things with commits which don''t appear in the main tree we can easily say "what additinal commits do you have" Ian.
Sander Eikelenboom
2013-Apr-11 08:25 UTC
Re: [PATCH] Try to use git commit id if hg changeset is unavailable
Thursday, April 11, 2013, 9:41:15 AM, you wrote:> Delivery-date: Thu, 11 Apr 2013 09:41:29 +0200 > Received: from Debian-exim by smtp.eikelenboom.it with spam-scanned (Exim 4.72) > id 1UQC8D-0005xX-Oc > for linux@eikelenboom.it; Thu, 11 Apr 2013 09:41:29 +0200 > X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on > vserver.eikelenboom.it > X-Spam-Level: > X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00=-1.9, > RP_MATCHES_RCVD=-2.373,SPF_HELO_PASS=-0.001,SPF_PASS=-0.001, > USER_IN_WHITELIST=-7.5 autolearn=ham version=3.3.2 > X-Spam-Language: en > Received: from smtp.eu.citrix.com ([46.33.159.39]:29476) > by smtp.eikelenboom.it with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) > (Exim 4.72) > (envelope-from <Ian.Campbell@citrix.com>) > id 1UQC8D-0005xS-Ll > for linux@eikelenboom.it; Thu, 11 Apr 2013 09:41:17 +0200 > X-IronPort-AV: E=Sophos;i="4.87,454,1363132800"; > d="scan''208";a="3446646" > Received: from lonpmailmx01.citrite.net ([10.30.203.162]) > by LONPIPO01.EU.CITRIX.COM with ESMTP/TLS/RC4-MD5; 11 Apr 2013 07:41:17 +0000 > Received: from [10.80.2.42] (10.80.2.42) by LONPMAILMX01.citrite.net > (10.30.203.162) with Microsoft SMTP Server id 8.3.298.1; Thu, 11 Apr 2013 > 08:41:16 +0100 > Message-ID: <1365666075.27868.111.camel@zakaz.uk.xensource.com> > Subject: Re: [Xen-devel] [PATCH] Try to use git commit id if hg changeset is > unavailable > From: Ian Campbell <Ian.Campbell@citrix.com> > To: Sander Eikelenboom <linux@eikelenboom.it> > CC: Marek Marczykowski <marmarek@invisiblethingslab.com>, > "xen-devel@lists.xen.org" <xen-devel@lists.xen.org> > Date: Thu, 11 Apr 2013 08:41:15 +0100 > In-Reply-To: <3310359051.20130411093331@eikelenboom.it> > References: <20130410233918.66DF61D3@duch.mimuw.edu.pl> > <3310359051.20130411093331@eikelenboom.it> > Organization: Citrix Systems, Inc. > Content-Type: text/plain; charset="UTF-8" > X-Mailer: Evolution 3.4.4-1 > MIME-Version: 1.0 > Content-Transfer-Encoding: 7bit> On Thu, 2013-04-11 at 08:33 +0100, Sander Eikelenboom wrote: >> Thursday, April 11, 2013, 1:32:05 AM, you wrote: >> >> > As Xen uses git as primary repository, get git commit id for >> > xen_changeset info. >> >> > Maybe hg code should be removed completely? >> >> > Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> >> > --- >> > xen/Makefile | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> >> > diff --git a/xen/Makefile b/xen/Makefile >> > index 0fb3db7..9e4e6f3 100644 >> > --- a/xen/Makefile >> > +++ b/xen/Makefile >> > @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner >> > -e ''s/@@version@@/$(XEN_VERSION)/g'' \ >> > -e ''s/@@subversion@@/$(XEN_SUBVERSION)/g'' \ >> > -e ''s/@@extraversion@@/$(XEN_EXTRAVERSION)/g'' \ >> > - -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g'' \ >> > + -e ''s!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || git show -s --pretty="%ad %h" || echo "unavailable") 2>/dev/null | tr -d ''\n'')!g'' \ >> > < include/xen/compile.h.in > $@.new >> > @grep \" .banner >> $@.new >> > @grep -v \" .banner >> >> Hi Marek, >> >> Yesterday i was looking into the same, i tried to also reflect if the tree was >> dirty or not (after this discussion: >> http://lists.xen.org/archives/html/xen-devel/2013-02/msg02077.html). >> >> Haven''t got it in a nice oneliner though.> The one liner is getting a bit silly. Perhaps we should import something > like Linux''s scripts/setlocalversion.>> Following that discussion the tree can be a: git tree, mercurial tree, tarball >> >> For both the git and mercurial tree, changes are tracked and it should be able >> to mark the tree as dirty when there are changes not in the upstream tree: >> a) uncommited changes (and untracked files) >> b) local commits (outgoing/not pushed) >> >> Git does have a option to mark the tree dirty for uncommitted changes, >> but probably due it''s philosophy of "my tree is as good as yours", >> this doesn''t work if the changes have been only locally committed and not pushed. >> >> Mercurial doesn''t have a facility to mark the tree as dirty. >> >> Another thing is the rev/node/hash to show, to me it would be preferable to: >> - get the last upstream commit this local tree was based on. >> - appended with -dirty if local commits or uncommitted changes dirty the tree.> I think it is best to show the actual literal commit which was used, > whether or not that has been pushed. That''s useful to me as a dev when I > am building locally and when users report things with commits which > don''t appear in the main tree we can easily say "what additinal commits > do you have"Ok, the linux script "setlocalversion" seems to also use tags to derive the version, but since the last tag is of the previous tagged release (for unstable) this seems to confuse. (as is with linux during the merge window, which generates a kernel with the name of the previous version) And since the version, subversion and extraversion are already derived by other means, i don''t think that the git tags are needed for describing the changeset. So the changeset should only reflect the hash of the last commit with a dirty flag appended to make it easy to see if the tree was dirty. So the script shouldn''t be a verbatim copy from linux i guess. -- Sander> Ian.