[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [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@xxxxxxxxxxxxxxxxxxxxxx>
> ---
>  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:

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 

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.


        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="git $changeset"

        # 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="mercurial $changeset"

        if [ -z "$changeset" ] && test -f "../.hg_archival.txt"; then

            # Determine changeset from node entry in ".hg_archival.txt"
            changeset="tarball $changeset"

        if [ -z "$changeset" ]; then

echo "changeset: $changeset"


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.