hgflow.py should prevent a wrong initialization if empty repository

Issue #92 invalid
Antoine Pérus
created an issue

Hello,

With hg 4.4 and hgflow 0.9.8.3 (but 'develop' branch) I'm noting that hgflow initialization in an empty repository fails : none branch is created. hgflow should explicitly throw an error.

A shell script to reproduce:

#!/bin/sh

MODE="$1"

version ()
{
    echo "\n"
    hg --version
    hg flow version
    echo "\n"
}

cleanup ()
{
    rm -rf ./Tst1
}

summary ()
{
    hg summary
    hg branches
}

without_first_commit ()
{
    mkdir Tst1 && cd Tst1 || exit

    hg init . 

    hg flow init --default
}

with_first_commit ()
{
    mkdir Tst1 && cd Tst1 || exit

    hg init .
    cat > .hgignore << EOF
    syntax: glob

    *.orig
EOF
    hg ci -Am "Init .hgignore"

    hg flow init --default
}


case "$MODE" in
    "with")
        cleanup
        with_first_commit
        version
        summary
    ;;

    "without")
        cleanup
        without_first_commit
        version
        summary
    ;;

    *)
        echo "Usage: $0 {with|without}"
        exit 1
    ;;
esac

Comments (4)

  1. Yujie Wu repo owner

    I cannot reproduce the reported problem (with hg v4.4.1 though). In my testing, the develop branch was created in both with and without cases.

  2. Antoine Pérus reporter

    That's strange … Executing the above script:

    > ./hgflow-init.sh without
    flow: Global configuration:
    flow:   autoshelve: on
    marked working directory as branch default
    (branches are permanent and global, did you want a bookmark?)
    nothing changed
    abort: unknown revision 'default'!
    
    
    
    Mercurial Distributed SCM (version 4.4.2)
    (see https://mercurial-scm.org for more information)
    
    Copyright (C) 2005-2017 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    flow: version 0.9.8.3
    
    
    parent: -1:000000000000 tip (empty repository)
    branch: default
    commit: (clean)
    update: (current)
    
    > ./hgflow-init.sh with
    adding .hgignore
    flow: Global configuration:
    flow:   autoshelve: on
    marked working directory as branch develop
    (branches are permanent and global, did you want a bookmark?)
    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
    
    
    
    Mercurial Distributed SCM (version 4.4.2)
    (see https://mercurial-scm.org for more information)
    
    Copyright (C) 2005-2017 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    flow: version 0.9.8.3
    
    
    parent: 0:4b3600556d3d
     Init .hgignore
    branch: default
    commit: (clean)
    update: (current)
    phases: 2 draft
    develop                        1:0dd8ffa7b1de
    default                        0:4b3600556d3d (inactive)
    
  3. Yujie Wu repo owner

    With 4.4.2, I still cannot reproduce this error. Do you have any hooks specified in your .hgrc file? It seems that hg init failed to create the default branch.

  4. Log in to comment