Commit Graph

82 Commits

Author SHA1 Message Date
Pierre-Yves David
5e9a275007 bookmarks: change bookmark within a transaction
For some time, bookmark can and should be moved in the transaction. This
changeset migrates the 'hg bookmarks' commands to use a transaction.

Tests regarding rollback and transaction hooks are impacted for
obvious reasons. Some have to be slightly updated to keep testing the
same things. Some can just be dropped because they do not make sense
anymore.
2014-09-28 00:49:36 -07:00
Pierre-Yves David
c09d056447 bookmarks: abort the whole push if bookmarks fails to update (BC)
When using bundle2, the bookmark's pushkey parts are now made mandatory. As a
result failure to update the bookmark server side will result in the transaction
being aborted.
2015-05-27 22:25:33 -07:00
Matt Mackall
36e5db11e5 tests: simplify printenv calls
Make printenv executable so that we don't need python, TESTDIR, or
quoting.
2015-06-08 15:10:15 -05:00
Pierre-Yves David
a1ac214778 pull: prevent race condition in bookmark update when using -B (issue4689)
We are already fetching remote bookmarks to honor the -B option, we
now pass that data to the pull process so it can reuse it. This
prevents a race condition between the initial looking and the actual
pulling of changesets and bookmarks. Tests are updated to handle this
fact.
2015-06-01 22:34:01 -07:00
Pierre-Yves David
0e4b4ad18c tests: use bundle2 for test-hook
Using bundle2 has an effect on which hooks are run when. We turn it on for
test-hooks early to reduce the noise of switching the default exchange to
bundle2.
2015-05-27 04:56:44 -07:00
FUJIWARA Katsunori
1a1aa7a153 localrepo: pass hook argument txnid to pretxnopen hooks
Before this patch, hook argument `txnid` isn't passed to `pretxnopen`
hooks, even though `hooks` section of `hg help config` describes so.

  ``pretxnopen``
    Run before any new repository transaction is open. The reason for the
    transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
    transaction will be in ``HG_TXNID``. A non-zero status will prevent the
    transaction from being opened.
2015-05-25 01:26:23 +09:00
FUJIWARA Katsunori
c75b05f3e1 localrepo: use correct argument name for pretxnclose hooks (BC)
Before this patch, "the reason for the transaction" is passed to
`pretxnclose` hooks via wrong name argument `xnname` (`HG_XNNAME` for
external hooks)
2015-05-20 04:34:27 +09:00
FUJIWARA Katsunori
3c33b6c286 localrepo: rename hook argument from TXNID to txnid (BC)
From the first (3.4 or 4e01e6d8d623), `TXNID` is passed to Python
hooks without lowering its name, but it is wrong.
2015-05-20 04:34:27 +09:00
Matt Harbison
7422218b87 merge: run update hook after the last wlock release
There were 2 test failures in 3.4-rc when running test-hook.t with the
largefiles extension enabled.  For context, the first is a commit hook:

  @@ -618,9 +621,9 @@
     $ echo 'update = hg id' >> .hg/hgrc
     $ echo bb > a
     $ hg ci -ma
  -  223eafe2750c tip
  +  d3354c4310ed+
     $ hg up 0
  -  cb9a9f314b8b
  +  223eafe2750c+ tip
     1 files updated, 0 files merged, 0 files removed, 0 files unresolved

   make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui

In both cases, largefiles acquires the wlock before calling into core, which
also acquires the wlock.  The first case was fixed in 4100e338a886 by ensuring
the hook only runs after the lock has been fully released.  The full release is
important, because that is what writes dirstate to the disk, allowing external
hooks to see the result of the update.  This simply changes how the update hook
is called, so that it too is deferred until the lock is finally released.

There are many uses of mergemod.update(), but in terms of commands, it looks
like the following commands take wlock while calling mergemod.update(), and
therefore will now have their hook fired at a later time:

    backout, fetch, histedit, qpush, rebase, shelve, transplant

Unlike the others, fetch immediately unlocks after calling update(), so for all
intents and purposes, its hook invocation is not deferred (but the external hook
still sees the proper state).
2015-04-29 15:52:31 -04:00
Matt Harbison
172c5c52cf test-hook.t: don't directly use redirect to /dev/null in hook for Windows
This goes with 4100e338a886.  External hooks are run in cmd.exe, which doesn't
know about /dev/null, but sh can handle it.
2015-04-20 13:43:10 -04:00
Pierre-Yves David
cb2e913723 afterlock: add the callback to the top level lock (issue4608)
If 'wlock' is taken, we should add 'afterlock' callback to the 'wlock' instead.
Otherwise, running post transaction hook after 'lock' is release but 'wlock' is
still taken lead to a deadlock (eg: 'hg update' during a hook).

This situation is much more common since: b7067abc16c0

  push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
2015-04-20 15:27:55 +02:00
Pierre-Yves David
bfdd8d2ada hooks: add a 'txnabort' hook
This hook will be called whenever a transaction is aborted. This will make it
easy for people to clean up temporary content they may have created during a
transaction.
2015-04-16 05:36:49 -04:00
Pierre-Yves David
502fe91f02 transaction: introduce a transaction ID, to be available to all hooks
The transaction ID is built from the object ID and creation time stamp to make
sure it is unique.
2015-04-15 11:11:54 -04:00
Pierre-Yves David
bba1369f79 transaction: actually use tr.hookargs in pretxnclose
The 'tr.hookargs' is a dictionary containing all the arguments to be passed to
hooks. It is actually used for hooks now...
2015-04-14 13:07:41 -04:00
Pierre-Yves David
06735d963a hook: add a generic hook right before we commit a transaction
We are adding a 'txnclose' hook that will be run right before a transaction is
closed. Hooks running at that time will have access to the full transaction
content through both 'hookargs' content and on-disk reading. They will be able
to abort the transaction.
2015-03-09 22:50:49 -07:00
Pierre-Yves David
44751929cc hook: add a generic hook after transaction has been closed
We are adding generic hooking for all transactions. We may have useful
information about what happened during the transaction, user of the transaction
should have filled the 'hookargs' dictionnary of the transaction. This hook is
simple because it has no power to rollback the transaction.
2015-03-09 22:36:56 -07:00
Pierre-Yves David
dd9fda46b5 hook: have a generic hook for transaction opening
We are adding generic hooking for all transactions. We do not really have any
useful information to include when opening the transaction but this is a
useful time to allow a hook anyway. We better let people abort transaction before
they happen than after multiple seconds/minutes of processing.
2014-12-10 18:19:49 -08:00
Pierre-Yves David
be1b3a5e03 transaction: include backup file in the "undo" transaction
Once the transaction is closed, we now write transaction related data for
possible future undo. For now, we only do it for full file "backup" because
their were not handle at all in that case. In the future, we could move all the
current logic to set undo up (that currently exists in localrepository) inside
transaction itself, but it is not strictly requires to solve the current
situation.
2015-01-16 18:34:14 -08:00
Mads Kiilerich
7167031347 localrepo: show headline notes in commitctx before showing filenames
commitctx already showed notes with filenames but didn't provide any context.
It is just as relevant to know when manifest or changelog is committed.

So, in addition to filenames, also show headlines 'committing files:',
'committing manifest' and 'committing changelog'.
2014-04-18 13:33:20 +02:00
Matt Mackall
289d6b53bc merge with stable 2014-12-01 19:34:11 -06:00
Pierre-Yves David
1e785e1322 pushkey: gracefully handle prepushkey hook failure (issue4455)
This allow to gracefully report the failure of the bookmark push and carry on.
Before this change set. Local push would plain quit and wireprotocol would
failed in various ungraceful way.
2014-11-29 19:17:47 -08:00
Pierre-Yves David
500808d844 changelog: register changelog.i.a as a temporary file
The file is registered to make sure the transaction is cleaned up in all cases.
2014-11-08 17:08:09 +00:00
Mike Hommey
14669879bf changegroup: use a copy of hookargs when invoking the changegroup hook
addchangegroup creates a runhook function that is used to invoke the
changegroup and incoming hooks, but at the time the function is called,
the contents of hookargs associated with the transaction may have been
modified externally. For instance, bundle2 code affects it with
obsolescence markers and bookmarks info.

It also creates problems when a single transaction is used with multiple
changegroups added (as per an upcoming change), whereby the contents
of hookargs are that of after adding a latter changegroup when invoking
the hook for the first changegroup.
2014-10-16 15:54:53 +09:00
Pierre-Yves David
578b6cd317 phases: inform transaction-related hooks that a phase was moved
We do not have enough information to provide finer data, but this is still
useful information.
2014-10-12 08:03:20 -07:00
Pierre-Yves David
23ce37ca7e pull: merge bookmark updates and imports
We do all the things in one go now, updating existing bookmark, adding new ones,
and overwriting the ones explicitly specified for --bookmark. This impacts the
tests by removing some duplicated or unnecessary output.
2014-09-28 14:07:56 -07:00
Pierre-Yves David
f69b4810ae push: gather all bookmark decisions together
The discovery phases for bookmarks now use the list of explicitly pushed bookmarks
to do addition, removal and overwriting.

Tests are impacted because this reduces the amount of listkeys calls issued, removes
some duplicated messages and improves the accuracy of some messages.
2014-09-27 20:51:53 -07:00
Pierre-Yves David
627b3886af pull: move bookmark movements inside the exchange.pull
There is no reason for bookmarks to get a special treatment. As a first step we
move the code as is in the `exchange.pull` function. Integration with the rest
of the flow will come later.

Adding bookmarks to pull means that most clone paths are now pulling bookmarks
through pull. We ensure that bookmark-update messages are properly suppressed in
that case.

In test-pull-http.t the 'requesting all changes' message disappear because we
now get the authentication error on the `listkeys`command before such message
is printed.
2014-09-26 17:44:00 -07:00
Pierre-Yves David
f2ec8aebea push: move bookmark discovery with other discovery steps
The discovery of necessary bookmark updates is now done within the "discovery
phase". This opens the door to the inclusion of bookmarks in a unified bundle2
push.
2014-08-15 18:39:39 -07:00
Pierre-Yves David
bee675a073 push: perform phases discovery before the push
This will allow including phase information in the same bundle2 as the
changesets.
2014-07-30 19:26:47 -07:00
Mads Kiilerich
906d7f81d3 hooks: for python hooks, consistently use __name__ etc as name, not the repr
There is no reason to expose unnecessary Python implementation details and
memory locations, also not in debug mode.

readablefunc was already creating a nice name - we move that functionality
up and reuse it.

We consider having a __call__ and being types.FunctionType sufficiently
similar and unify these two to just using the existing check for __call__.
2014-02-15 01:23:12 +01:00
Siddharth Agarwal
33d0a49008 dispatch: print 'abort:' when a pre-command hook fails (BC)
This also changes the exit code from whatever the hook returned to 255. This
brings it in line with all the other hooks that abort.
2013-04-16 14:39:37 -07:00
Siddharth Agarwal
262d694589 pull: list bookmarks before pulling changesets (issue3873)
Consider a bookmark B that exists both locally and remotely. If B is updated
remotely, and then a pull is performed where the pull set contains the new
location of B, the bookmark is updated locally. However, if remote B is
updated in the middle of a pull to a location not in the pull set, the
bookmark won't be updated locally at all.

To fix this, list bookmarks before pulling in changesets, not after. This
still leaves a race open if B gets moved in between listing bookmarks and
pulling in changesets, but the race window is much smaller. Fixing the race
properly would require a bundle format upgrade.

test-hook.t's output changes because we no longer do two listkeys calls during
pull, just one.

test-pull-http.t's output changes because we now search for bookmarks before
searching for changes.
2013-03-29 19:54:06 -07:00
Siddharth Agarwal
9480bd91e6 test-hook.t: remove prelistkeys.forbid hook before moving on
An upcoming patch will change the order of operations and perform a listkeys
before a changegroup fetch. This will cause a few tests to print out the wrong
error message.
2013-03-29 19:52:02 -07:00
Mads Kiilerich
b156c9a772 tests: make test-hook.t output more stable 2013-01-15 02:59:14 +01:00
timeless@mozdev.org
e2f489f93f spelling: propagated 2012-08-17 13:58:18 -07:00
timeless@mozdev.org
f029229d67 spelling: nonexistent 2012-08-17 13:58:18 -07:00
Pierre-Yves David
fd393b84f3 pushkey: do not exchange obsole markers if feature is disabled
This apply to both push and pull both when client or server.
2012-07-28 13:33:06 +02:00
Mads Kiilerich
27e4baeebb test-hook.t: Solaris /usr/bin/egrep do not support {4} 2012-07-30 02:38:29 +02:00
Patrick Mezard
f40d444448 push: do not try to push remote obsolete if local has none 2012-07-24 21:20:56 +02:00
Simon Heimberg
8eb4380be9 hooks: print out more information when loading a python hook fails
When loading a python hook with file syntax fails, there is no
information that this happened while loading a hook. When the python
file does not exist even the file name is not printed. (Only that a
file is missing.)

This patch adds this information and a test for loading a non existing file and
a directory not being a python module.
2012-07-06 18:41:25 +02:00
Pierre-Yves David
9cbee4c2aa push: fix bug in detection of remote obsolete support
Current code check obsolete availability in local repo.
2012-07-12 03:03:19 +02:00
Simon Heimberg
387ef4195f tests: do exclude what is expected 2012-07-04 08:55:16 +02:00
Pierre-Yves.David@ens-lyon.org
d60eedc2d6 obsolete: exchange obsolete marker over pushkey
For a version of the exchange, all markers are exchange. This won't
scale and we will need a better protocol later.
2012-06-07 19:21:59 +02:00
Adrian Buehlmann
b761076e81 tests/printenv.py: eliminate trailing spaces on output 2012-06-17 00:27:31 +02:00
Adrian Buehlmann
4bb68f47e6 test-hook: adapt for Windows 2012-06-15 21:42:47 +02:00
Matt Mackall
05e48d4041 merge with stable 2012-05-13 12:52:24 +02:00
Levi Bard
ff2ee52b29 bookmarks: pull new bookmarks from remote by default (BC) 2012-05-12 17:00:01 +02:00
Bryan O'Sullivan
ab8ba40835 changelog: ensure that nodecache is valid (issue3428)
This ensures that an out-of-process hook can see an incoming changegroup.
2012-05-11 01:55:33 -07:00
Mads Kiilerich
93c3b99c27 tag: run commit hook when lock is released (issue3344) 2012-05-12 20:06:02 +02:00
Matt Mackall
31ad230c52 pull: backout change to return code
This bit a number of people.
2012-02-10 16:09:30 -06:00