bundle2 prechangegroup & incoming hooks set HG_URL=push when pushing

Danek Duvall danek.duvall at oracle.com
Sun Mar 13 21:49:01 EDT 2016


A user noticed that a hook that prevented incoming changesets from being
pushed from unauthorized repositories (it's in a simple clone repo) had
started failing after our upgrade from 3.4 to 3.7.1.

A simple test with

    [hooks]
    prechangegroup = echo HG_URL=$HG_URL; exit 1

in the parent repo's hgrc demonstrated that HG_URL was being set to "push",
rather than the URL of the source repo.

A bisect showed that the first failing changeset was

    changeset:   25404:ff955e7b1085
    user:        Pierre-Yves David <pierre-yves.david at fb.com>
    date:        Fri Feb 06 10:41:24 2015 -0700
    description:
    bundle2: use bundle2 by default

Despite all the hook tests, both in test-hook.t and
test-bundle2-exchange.t, somehow this one managed to slip by.  It looks
like the prechangegroup hook was only tested with a pull, and not with a
push, so this was never caught.  A simple demonstration by taking the
pull-type tests from test-hook.t, stripping what we got and doing it again
with a push shows the problem, too.

    --- .../tests/test-hook.t
    +++ .../tests/test-hook.t.err
    @@ -126,8 +126,28 @@
       incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
       (run 'hg update' to get a working copy)
       $ hg strip ab228980c14deea8b9555d91c9581127383e40fd
    +  saved backup bundle to $TESTTMP/b/.hg/strip-backup/ab228980c14d-4649ab67-backup.hg (glob)
    +  prechangegroup hook: HG_BUNDLE2=1 HG_SOURCE=strip HG_URL=bundle:$TESTTMP/b/.hg/strip-backup/ab228980c14d-769f911c-temp.hg
    +  changegroup hook: HG_BUNDLE2=1 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_NODE_LAST=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=strip HG_URL=bundle:$TESTTMP/b/.hg/strip-backup/ab228980c14d-769f911c-temp.hg
    +  incoming hook: HG_BUNDLE2=1 HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=strip HG_URL=bundle:$TESTTMP/b/.hg/strip-backup/ab228980c14d-769f911c-temp.hg
       $ cd ../a
       $ hg push ../b
    +  pushing to ../b
    +  searching for changes
    +  prechangegroup hook: HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:cea353b92adfdb9f297a28d090939c62471ad7ef HG_URL=push
    +  adding changesets
    +  adding manifests
    +  adding file changes
    +  added 2 changesets with 1 changes to 1 files
    +  changegroup hook: HG_BUNDLE2=1 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=push HG_TXNID=TXN:cea353b92adfdb9f297a28d090939c62471ad7ef HG_URL=push
    +  incoming hook: HG_BUNDLE2=1 HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=push HG_TXNID=TXN:cea353b92adfdb9f297a28d090939c62471ad7ef HG_URL=push
    +  incoming hook: HG_BUNDLE2=1 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=push HG_TXNID=TXN:cea353b92adfdb9f297a28d090939c62471ad7ef HG_URL=push
    +  pretxnopen hook: HG_TXNID=TXN:63b0ff80fb7801db1b617cdfee5652533a54f29b HG_TXNNAME=push-response
    +  file://$TESTTMP/b
    +  pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_SOURCE=push-response HG_TXNID=TXN:63b0ff80fb7801db1b617cdfee5652533a54f29b HG_TXNNAME=push-response
    +  file://$TESTTMP/b HG_URL=file:$TESTTMP/b
    +  txnclose hook: HG_PHASES_MOVED=1 HG_SOURCE=push-response HG_TXNID=TXN:63b0ff80fb7801db1b617cdfee5652533a54f29b HG_TXNNAME=push-response
    +  file://$TESTTMP/b HG_URL=file:$TESTTMP/b

Is this a real bug, or are we misunderstanding what's supposed to be here?
The latter certainly seems possible, given how long this has been around
and hasn't been caught.

Thanks,
Danek


More information about the Mercurial-devel mailing list