Rev 4414: Lock the tree we are about to commit for writing before doing any other work. in http://bazaar.launchpad.net/~jameinel/bzr/1.16-commit-write-lock
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 5 21:11:19 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.16-commit-write-lock
------------------------------------------------------------
revno: 4414
revision-id: john at arbash-meinel.com-20090605201057-ronbp64jipa8xz23
parent: pqm at pqm.ubuntu.com-20090605081039-abvojdsxjbg5i4ff
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.16-commit-write-lock
timestamp: Fri 2009-06-05 15:10:57 -0500
message:
Lock the tree we are about to commit for writing before doing any other work.
This turns out to save a significant amount of time (0.5-1s for mysql commit).
It seems that we have quite a few @needs_read_lock calls on functions that,
causes us to spin more than we would expect.
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-06-02 09:18:26 +0000
+++ b/bzrlib/builtins.py 2009-06-05 20:10:57 +0000
@@ -2745,13 +2745,13 @@
If selected files are specified, only changes to those files are
committed. If a directory is specified then the directory and
everything within it is committed.
-
+
When excludes are given, they take precedence over selected files.
For example, to commit only changes within foo, but not changes
within foo/bar::
-
+
bzr commit foo -x foo/bar
-
+
A selective commit after a merge is not yet supported.
:Custom authors:
@@ -2762,7 +2762,7 @@
"John Doe <jdoe at example.com>". If there is more than one author of
the change you can specify the option multiple times, once for each
author.
-
+
:Checks:
A common mistake is to forget to add a new file or directory before
@@ -2784,7 +2784,7 @@
A selective commit may fail in some cases where the committed
tree would be invalid. Consider::
-
+
bzr init foo
mkdir foo/bar
bzr add foo/bar
@@ -2793,7 +2793,7 @@
mkdir foo/bar
bzr add foo/bar
bzr commit foo/bar -m "committing bar but not baz"
-
+
In the example above, the last commit will fail by design. This gives
the user the opportunity to decide whether they want to commit the
rename at the same time, separately first, or not at all. (As a general
@@ -2925,30 +2925,35 @@
raise errors.BzrCommandError("empty commit message specified")
return my_message
+ tree.lock_write()
try:
- tree.commit(message_callback=get_message,
- specific_files=selected_list,
- allow_pointless=unchanged, strict=strict, local=local,
- reporter=None, verbose=verbose, revprops=properties,
- authors=author,
- exclude=safe_relpath_files(tree, exclude))
- except PointlessCommit:
- # FIXME: This should really happen before the file is read in;
- # perhaps prepare the commit; get the message; then actually commit
- raise errors.BzrCommandError("No changes to commit."
- " Use --unchanged to commit anyhow.")
- except ConflictsInTree:
- raise errors.BzrCommandError('Conflicts detected in working '
- 'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
- ' resolve.')
- except StrictCommitFailed:
- raise errors.BzrCommandError("Commit refused because there are"
- " unknown files in the working tree.")
- except errors.BoundBranchOutOfDate, e:
- raise errors.BzrCommandError(str(e) + "\n"
- 'To commit to master branch, run update and then commit.\n'
- 'You can also pass --local to commit to continue working '
- 'disconnected.')
+ try:
+ tree.commit(message_callback=get_message,
+ specific_files=selected_list,
+ allow_pointless=unchanged, strict=strict,
+ local=local, reporter=None, verbose=verbose,
+ revprops=properties, authors=author,
+ exclude=safe_relpath_files(tree, exclude))
+ except PointlessCommit:
+ # FIXME: This should really happen before the file is read in;
+ # perhaps prepare the commit; get the message; then actually
+ # commit
+ raise errors.BzrCommandError("No changes to commit."
+ " Use --unchanged to commit anyhow.")
+ except ConflictsInTree:
+ raise errors.BzrCommandError('Conflicts detected in working '
+ 'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
+ ' resolve.')
+ except StrictCommitFailed:
+ raise errors.BzrCommandError("Commit refused because there are"
+ " unknown files in the working tree.")
+ except errors.BoundBranchOutOfDate, e:
+ raise errors.BzrCommandError(str(e) + "\n"
+ 'To commit to master branch, run update and then commit.\n'
+ 'You can also pass --local to commit to continue working '
+ 'disconnected.')
+ finally:
+ tree.unlock()
class cmd_check(Command):
More information about the bazaar-commits
mailing list