Submitter | Durham Goode |
---|---|
Date | May 6, 2013, 7:36 p.m. |
Message ID | <4ddd3b2b3407fe3344fd.1367869011@dev350.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/1557/ |
State | Superseded, archived |
Headers | show |
Comments
On Mon, 2013-05-06 at 12:36 -0700, Durham Goode wrote: > # HG changeset patch > # User Durham Goode <durham@fb.com> > # Date 1367429725 25200 > # Wed May 01 10:35:25 2013 -0700 > # Node ID 4ddd3b2b3407fe3344fd800ea11ab377a34b8ae6 > # Parent bfd128c3fbb830b332fec89eddc82b0b9aa31b64 > update: add pre-applyupdate hook > > This adds a hook after update actions are calculated but before they are > applied. This allows an extension to download any data necessary for the > update if necessary. Given that 'hooks' are a public interface (on par with the command line) and 'actions' are rather ad-hoc guts of the merge code, I think this is probably not the right way to expose this.
On 5/6/13 12:52 PM, "Matt Mackall" <mpm@selenic.com> wrote: >On Mon, 2013-05-06 at 12:36 -0700, Durham Goode wrote: >> # HG changeset patch >> # User Durham Goode <durham@fb.com> >> # Date 1367429725 25200 >> # Wed May 01 10:35:25 2013 -0700 >> # Node ID 4ddd3b2b3407fe3344fd800ea11ab377a34b8ae6 >> # Parent bfd128c3fbb830b332fec89eddc82b0b9aa31b64 >> update: add pre-applyupdate hook >> >> This adds a hook after update actions are calculated but before they are >> applied. This allows an extension to download any data necessary for the >> update if necessary. > >Given that 'hooks' are a public interface (on par with the command line) >and 'actions' are rather ad-hoc guts of the merge code, I think this is >probably not the right way to expose this. > Ok. I think I can achieve my goal by wrapping merge.applyupdates, so I'll remove this patch from the series entirely.
Patch
diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -477,6 +477,11 @@ removed = len(removeactions) actions = [a for a in actions if a[1] not in 'gr'] + repo.hook('pre-applyupdate', + manifest=mctx.manifest(), + actions=workeractions, + throw=True) + hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate'] if hgsub and hgsub[0] == 'r': subrepo.submerge(repo, wctx, mctx, wctx, overwrite) diff --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -469,6 +469,26 @@ adding remote bookmark quux (run 'hg update' to get a working copy) +pre-applyupdate hook + + $ echo '[hooks]' > .hg/hgrc + $ echo 'pre-applyupdate.success = python:hooktests.passhook' >> .hg/hgrc + $ hg up . + hook args: + actions [] + hooktype pre-applyupdate + manifest {'a': '*'} (glob) + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + +pre-applyupdate hook can fail update + + $ echo '[hooks]' > .hg/hgrc + $ echo 'pre-applyupdate.fail = python:hooktests.aborthook' >> .hg/hgrc + $ hg up 0 + error: pre-applyupdate.fail hook failed: raise abort from hook + abort: raise abort from hook + [255] + make sure --traceback works $ echo '[hooks]' > .hg/hgrc