Commit Graph

63 Commits

Author SHA1 Message Date
Mads Kiilerich
440a607ef9 cleanup: name unused variables using convention of leading _
This helps checker tools ... and readability for those who knows and follows
the convention.
2014-08-15 04:37:46 +02:00
Mads Kiilerich
23da6c1d98 cleanup: avoid _ for local unused tmp variables - that is reserved for i18n
_ is usually used for i18n markup but we also used it for I-don't-care
variables.

Instead, name don't-care variables in a slightly descriptive way but use the _
prefix to designate unused variable.

This will mute some pyflakes "import '_' ... shadowed by loop variable"
warnings.
2014-08-15 16:20:47 +02:00
Pierre-Yves David
3f8b890149 transaction: add a file generation mechanism
A new `transaction.addfilegenerator` function is added. It allows external code
to register files to be generated. See inline documentation for details.

It is important to gather all file creation logic on the transaction
as at some point we'll want to mimic the "pre-transaction-commit"
logic that we use for revlog. I'm refering to the logic that lets
hooks see the result of the transaction before it actually gets
committed.
2014-08-07 14:40:02 -07:00
Pierre-Yves David
98693f71e9 transaction: backup file in a dedicated "namespace"
File backup may conflict with other "journal.*" file. We add a fixed part in the
backup name file to prevent it.
2014-08-07 10:54:17 -07:00
Pierre-Yves David
c81f99d5f9 transaction: use self.journal to create backup file
Transaction journal name is "journal" in most case, but it can be something else.
We use the appropriate attribute to create the file.
2014-08-07 11:56:32 -07:00
Durham Goode
340117ecce transaction: fix file descriptor leak for journal.backupfiles
The journal.backupfiles descriptor wasn't being closed. This resulted in
hgsubversion test runs having a bagillion descriptors open, which crashed on
platforms with low open file limits (like OSX).
2014-04-30 15:36:38 -07:00
Pierre-Yves David
18d2864e3c transaction: add a notion of hook arguments
It is now possible to register parameters to be used when invoking hooks in this
transaction. This will cope with the fact that bundle2 adds multiple data types
in a single transaction.

Do not expect any wide and consistent usages of this in the next release. This
will be used by bundle2 experiments first. It will be made better for the release
after.
2014-04-17 17:04:59 -04:00
Matt Mackall
2cef67b922 transaction: drop extra import caught by pyflakes 2014-04-02 13:41:23 -05:00
Durham Goode
1fd6146a66 transaction: add support for non-append files
This adds support for normal, non-append-only files in transactions.  For
example, .hg/store/fncache and .hg/store/phaseroots should be written as part of
the transaction, but are not append only files.

This adds a journal.backupfiles along side the normal journal. This tracks which
files have been backed up as part of the transaction.  transaction.addbackup()
creates a backup of the file (using a hardlink), which is later used to recover
in the event of the transaction failing.

Using a seperate journal allows the repository to still be used by older
versions of Mercurial. A future patch will use this functionality and add tests
for it.
2014-03-24 15:21:51 -07:00
Durham Goode
503655f175 transaction: add onclose/onabort hook for pre-close logic
Adds an optional onclose parameter to transactions that gets called just before
the transaction is committed. This allows things that build up data over the
course of the transaction (like the fncache) to commit their data.

Also adds onabort. It's not used, but will allow extensions to hook into onclose
and onabort to provide transaction support.
2014-03-24 15:57:47 -07:00
Matt Mackall
0122021cb0 journal: report parsing errors on recover/rollback (issue4172) 2014-02-17 14:49:56 -06:00
FUJIWARA Katsunori
ed122f7175 transaction: take journal file path relative to vfs to use file API via vfs 2013-11-12 16:23:52 +09:00
FUJIWARA Katsunori
cf2ceb0ac9 transaction: unlink target file via vfs
Before this patch, unlink target file is once opened before unlinking,
because "opener" before vfs migration doesn't have "unlink()"
function.

This patch uses "vfs.unlink()" instead of "open()" and "fp.name".
2013-11-12 16:23:52 +09:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Brodie Rao
a706d64a2c cleanup: replace naked excepts with except Exception: ... 2012-05-12 16:02:46 +02:00
Adrian Buehlmann
76e8469c0d transaction: use posixfile and unlink from util
instead of open() and os.unlink()

Avoids potential issues with file access on Windows (e.g. AV-scanners).
2011-02-15 14:41:49 +01:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Patrick Mezard
3153012325 cleanup: typos 2010-07-26 22:29:49 +02:00
Ronny Pfannschmidt
4362059a98 make transactions work on non-refcounted python implementations 2010-05-27 17:47:40 +02:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Benoit Boissinot
8265d7b666 transaction: initialize self.journal to None after deletion
This avoid a warning when having an empty transaction, where hg would try to
delete the journal twice.
2010-01-11 21:40:19 +01:00
Sune Foldager
46c649736d transaction: always remove empty journal on abort
When transactions without entries were aborted, the journal (of size 0) was not
unlinked, which prevents subsequent operations until hg recover is run on the
repository.

We also make sure the journal is unlinked when committing, even if the provided
hook doesn't do so.
2009-11-02 10:19:14 +01:00
Benoit Boissinot
864f95d532 transaction: more specific exceptions, os.unlink can raise OSError 2009-10-31 18:17:59 +01:00
Greg Ward
b42121b634 transaction: document close(), abort() methods 2009-07-21 20:31:45 -04:00
Henrik Stuart
2108f47c49 transaction: fix uncaught ENOENT (issue1724)
The opener raises an IOError on errors where transaction expects an
OSError.
2009-07-07 19:24:52 +02:00
Henrik Stuart
ec8d726ba0 transaction: add atomic groups to transaction logic
When performing a strip operation on a repository, it is vital that all the
truncations are performed, or that none of them are. This is done by adding
support for writing a number of entries in a single operation.

Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-05-11 21:12:40 +02:00
Henrik Stuart
d0b7d204d4 transaction: refactor transaction.abort and rollback to use the same code
This adds a change to the way that abort is processed, as it will not continue
truncating files beyond the first failure, otherwise the respective
functionality is maintained, i.e. abort will not unlink files, but rollback
will.

Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-05-04 15:31:57 +02:00
Henrik Stuart
206e98a6fb transaction: reset transaction on abort
Prevent the use of the transaction after it has been aborted.

Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-04-19 20:02:32 +02:00
Henrik Stuart
db9b1644e1 transaction: ensure finished transactions are not reused
All transactional methods on the transaction class have had a decorator
added that ensures the transaction is running.

Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-04-24 09:56:53 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Henrik Stuart
c57f2e28ee transaction: only delete journal on successful abort/commit
This solves that the journal file was always deleted when the transaction
was deleted, no matter whether the abort (rollback) succeeded or not.
Thus, never supporting a hg recover. The journal file is now only deleted
on close (commit) or a successful abort.
2009-04-16 15:41:25 +02:00
Benoit Boissinot
becc8b09ae add missing import from d329ec89ce55 2008-11-07 18:42:43 +01:00
Benoit Boissinot
a95f4bd10d fix restart of interrupted recover
Ignore missing files if they are already removed.
Thanks maelcum on IRC for reporting it.
2008-11-07 18:41:22 +01:00
Brendan Cully
9d21508cbe rollback: unlink files truncated to length 0 2008-03-31 23:02:25 -07:00
Alexis S. L. Carvalho
6b4c649e55 make the journal/undo files from transactions inherit the mode from .hg/store 2008-02-09 18:38:54 -02:00
Matt Mackall
a68910fcf1 transactions: don't show a backtrace when journal exists
Now we simply print a message on how to recover.
2008-01-16 11:32:25 -06:00
Matt Mackall
296d6a7cb8 Simplify i18n imports 2006-12-14 20:25:19 -06:00
Matt Mackall
f17a4e1934 Replace demandload with new demandimport 2006-12-13 13:27:09 -06:00
Vadim Gelfer
dc377b58c1 update copyrights. 2006-08-12 12:30:02 -07:00
Vadim Gelfer
9a0c813fdc use demandload more. 2006-06-20 23:58:21 -07:00
Chris Mason
4841dc10da Fix transaction handling during interleaved file split. 2006-04-17 13:19:58 -04:00
mason@suse.com
9090463607 Automatic nesting into running transactions in the same repository.
This associates a transaction handle with a given repository object, and
any additional calls to start new transactions reuse that transaction.

For the 2700 patch import run, this brings the system time down from
1m20s to 50s, mostly by skipping backups of the dirstate file.

(note, this patch does not change hg import to use the nested transaction,
mq is the only user right now)
2006-02-28 12:24:54 -06:00
Eric Hopper
dd6718fc31 Convert all classes to new-style classes by deriving them from object. 2005-11-18 22:48:47 -08:00
twaldmann@thinkmo.de
55d74a6b77 fixed some stuff pychecker shows, marked unclear/wrong stuff with XXX 2005-11-14 03:59:35 +02:00
Benoit Boissinot
06e39e559b i18n part2: use '_' for all strings who are part of the user interface 2005-10-18 18:38:39 -07:00
Benoit Boissinot
e38e94088a i18n first part: make '_' available for files who need it 2005-10-18 18:37:48 -07:00
Bart Trojanowski
3529a29a40 [PATCH] raise exceptions with Exception subclasses
Fixed the patch.  Using Exception subclasses.

(tweaked by mpm)
2005-08-26 19:08:25 -07:00
benoit.boissinot@ens-lyon.fr
95b97f01ed pep-0008 cleanup
- Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value.
2005-08-26 13:06:58 +02:00
mpm@selenic.com
e4d910ab82 Fix undo after aborted commit bug
Commit would overwrite undo.dirstate unconditionally, so an undo after
an aborted commit would restore the dirstate from the aborted commit
and not the prior transaction.

This copies dirstate to journal.dirstate and moves it after a
successful transaction.
2005-07-27 18:16:20 -08:00