Page MenuHomePhabricator

Generate ref updates in Mercurial hooks
ClosedPublic

Authored by epriestley on Dec 13 2013, 12:06 AM.
Tags
None
Referenced Files
F14061020: D7763.diff
Mon, Nov 18, 4:45 AM
F14053121: D7763.id17597.diff
Fri, Nov 15, 12:51 PM
F14036458: D7763.diff
Sun, Nov 10, 10:18 AM
F14017600: D7763.diff
Mon, Nov 4, 7:29 PM
F14013760: D7763.id17598.diff
Sat, Nov 2, 12:14 PM
F14011957: D7763.id17597.diff
Fri, Nov 1, 6:17 AM
F14011956: D7763.id.diff
Fri, Nov 1, 6:17 AM
F14011955: D7763.id17560.diff
Fri, Nov 1, 6:17 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.