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)
Sat, Apr 20, 6:09 PM
Unknown Object (File)
Mon, Apr 8, 8:50 PM
Unknown Object (File)
Mon, Apr 8, 8:50 PM
Unknown Object (File)
Mon, Apr 8, 8:50 PM
Unknown Object (File)
Mon, Apr 8, 8:07 PM
Unknown Object (File)
Thu, Apr 4, 12:32 AM
Unknown Object (File)
Mon, Apr 1, 12:57 PM
Unknown Object (File)
Mon, Apr 1, 3:42 AM
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.