Page MenuHomePhabricator

Generate ref updates in Mercurial hooks
ClosedPublic

Authored by epriestley on Dec 13 2013, 12:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 13, 7:16 AM
Unknown Object (File)
Wed, Dec 11, 10:08 AM
Unknown Object (File)
Mon, Dec 9, 9:40 AM
Unknown Object (File)
Mon, Dec 9, 9:40 AM
Unknown Object (File)
Mon, Dec 9, 9:39 AM
Unknown Object (File)
Mon, Dec 9, 9:38 AM
Unknown Object (File)
Mon, Dec 9, 9:36 AM
Unknown Object (File)
Wed, Nov 27, 12:46 PM
Subscribers

Details

Summary

Ref T4195. Mercurial is not my favorite VCS.

Test Plan

Hit the split branches case:

>>> orbital ~/repos/INIH $ hg push --force
pushing to ssh://dweller@local.aphront.com/diffusion/INIH
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 2 changes to 1 files (+1 heads)
remote: +---------------------------------------------------------------+
remote: |      * * * PUSH REJECTED BY EVIL DRAGON BUREAUCRATS * * *     |
remote: +---------------------------------------------------------------+
remote:             \
remote:              \                    ^    /^
remote:               \                  / \  // \
remote:                \   |\___/|      /   \//  .\
remote:                 \  /V  V  \__  /    //  | \ \           *----*
remote:                   /     /  \/_/    //   |  \  \          \   |
remote:                   @___@`    \/_   //    |   \   \         \/\ \
remote:                  0/0/|       \/_ //     |    \    \         \  \
remote:              0/0/0/0/|        \///      |     \     \       |  |
remote:           0/0/0/0/0/_|_ /   (  //       |      \     _\     |  /
remote:        0/0/0/0/0/0/`/,_ _ _/  ) ; -.    |    _ _\.-~       /   /
remote:                    ,-}        _      *-.|.-~-.           .~    ~
remote:   \     \__/        `/\      /                 ~-. _ .-~      /
remote:    \____(Oo)           *.   }            {                   /
remote:    (    (--)          .----~-.\        \-`                 .~
remote:    //__\\  \ DENIED!  ///.----..<        \             _ -~
remote:   //    \\               ///-._ _ _ _ _ _ _{^ - - - - ~
remote: 
remote: 
remote: DANGEROUS CHANGE: The change you're attempting to push splits the head of branch 'default' into multiple heads: 802c785c3dd9, e73400db39b0. This is inadvisable and dangerous.
remote: Dangerous change protection is enabled for this repository.
remote: Edit the repository configuration before making dangerous changes.
remote: 
remote: transaction abort!
remote: rollback completed
remote: abort: pretxnchangegroup.phabricator hook exited with status 1

Hit the divergent heads case:

>>> orbital ~/repos/INIH $ hg push --force
pushing to ssh://dweller@local.aphront.com/diffusion/INIH
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files (+1 heads)
remote: +---------------------------------------------------------------+
remote: |      * * * PUSH REJECTED BY EVIL DRAGON BUREAUCRATS * * *     |
remote: +---------------------------------------------------------------+
remote:             \
remote:              \                    ^    /^
remote:               \                  / \  // \
remote:                \   |\___/|      /   \//  .\
remote:                 \  /V  V  \__  /    //  | \ \           *----*
remote:                   /     /  \/_/    //   |  \  \          \   |
remote:                   @___@`    \/_   //    |   \   \         \/\ \
remote:                  0/0/|       \/_ //     |    \    \         \  \
remote:              0/0/0/0/|        \///      |     \     \       |  |
remote:           0/0/0/0/0/_|_ /   (  //       |      \     _\     |  /
remote:        0/0/0/0/0/0/`/,_ _ _/  ) ; -.    |    _ _\.-~       /   /
remote:                    ,-}        _      *-.|.-~-.           .~    ~
remote:   \     \__/        `/\      /                 ~-. _ .-~      /
remote:    \____(Oo)           *.   }            {                   /
remote:    (    (--)          .----~-.\        \-`                 .~
remote:    //__\\  \ DENIED!  ///.----..<        \             _ -~
remote:   //    \\               ///-._ _ _ _ _ _ _{^ - - - - ~
remote: 
remote: 
remote: DANGEROUS CHANGE: The change you're attempting to push creates new, divergent heads for the branch 'default': f56af4232aa9. This is inadvisable and dangerous.
remote: Dangerous change protection is enabled for this repository.
remote: Edit the repository configuration before making dangerous changes.
remote: 
remote: transaction abort!
remote: rollback completed
remote: abort: pretxnchangegroup.phabricator hook exited with status 1

Did a bunch of good/bad pushes:

{F89300}

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This is pretty gross. Basically, in Mercurial you can't ever delete or overwrite a branch, but you can push a new branch head with hg push --force, so then "master" has, like, an arbitrarily large number of heads. We detect creating more heads on some branch than already exist in the repository and reject it as dangerous. Otherwise, we create update refs for all the heads, keeping track of which ones were appended to and which ones are new.

So what is your favorite VCS?

src/applications/diffusion/engine/DiffusionCommitHookEngine.php
443โ€“445

Can you just kill this foreach? My read of this code is it runs the command twice, but this first time doesn't capture output really?

src/applications/diffusion/engine/DiffusionCommitHookEngine.php
443โ€“445

Oh, this should be Futures($futures). The idea is to run all of the commands in parallel.

epriestley updated this revision to Unknown Object (????).Dec 17 2013, 4:34 PM

Fix Futures() construct and explain it.