# HG changeset patch # User Matt Mackall # Date 1242686184 18000 # Node ID a21605de1509cee2f27bac3081d69725e580f59e # Parent 5b7596b142adc7f733aba8954a0ba8bc63c0a084 commit: move editor outside transaction The commit editor is now invoked before files and manifest are committed. The editor is now run with only the wlock held and aborting an edit no longer requires rolling back a transaction. Changes to files during a commit still result in undefined behavior. (This is preliminary work for committing subrepositories) diff -r 5b7596b142ad -r a21605de1509 mercurial/localrepo.py --- a/mercurial/localrepo.py Mon May 18 22:55:45 2009 +0200 +++ b/mercurial/localrepo.py Mon May 18 17:36:24 2009 -0500 @@ -810,9 +810,14 @@ if f in ms and ms[f] == 'u': raise util.Abort(_("unresolved merge conflicts " "(see hg resolve)")) + wctx = context.workingctx(self, (p1, p2), text, user, date, extra, changes) - ret = self.commitctx(wctx, editor, True) + if editor: + wctx._text = editor(self, wctx, + changes[1], changes[0], changes[2]) + + ret = self.commitctx(wctx, True) ms.reset() # update dirstate @@ -829,7 +834,7 @@ self.dirstate.invalidate() # didn't successfully commit wlock.release() - def commitctx(self, ctx, editor=None, error=False): + def commitctx(self, ctx, error=False): """Add a new revision to current repository. Revision information is passed via the context argument. @@ -870,13 +875,6 @@ else: remove.append(f) - updated, added = [], [] - for f in sorted(changed): - if f in m1 or f in m2: - updated.append(f) - else: - added.append(f) - # update manifest m1.update(new) removed = [f for f in sorted(remove) if f in m1 or f in m2] @@ -890,9 +888,6 @@ p2.manifestnode(), (new, removed1)) text = ctx.description() - if editor: - text = editor(self, ctx, added, updated, removed) - lines = [line.rstrip() for line in text.rstrip().splitlines()] while lines and not lines[0]: del lines[0] diff -r 5b7596b142ad -r a21605de1509 tests/test-commit.out --- a/tests/test-commit.out Mon May 18 22:55:45 2009 +0200 +++ b/tests/test-commit.out Mon May 18 17:36:24 2009 -0500 @@ -1,6 +1,4 @@ % commit date test -transaction abort! -rollback completed abort: empty commit message abort: impossible time zone offset: 4444444 abort: invalid date: '1\t15.1' @@ -116,6 +114,4 @@ HG: added added HG: changed changed HG: removed removed -transaction abort! -rollback completed abort: empty commit message diff -r 5b7596b142ad -r a21605de1509 tests/test-import.out --- a/tests/test-import.out Mon May 18 22:55:45 2009 +0200 +++ b/tests/test-import.out Mon May 18 17:36:24 2009 -0500 @@ -32,8 +32,6 @@ updating working directory 2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying ../tip.patch -transaction abort! -rollback completed abort: empty commit message % import of plain diff should be ok with message requesting all changes @@ -150,8 +148,6 @@ updating working directory 2 files updated, 0 files merged, 0 files removed, 0 files unresolved applying patch from stdin -transaction abort! -rollback completed abort: empty commit message % hg export in email, should use patch header requesting all changes diff -r 5b7596b142ad -r a21605de1509 tests/test-keyword.out --- a/tests/test-keyword.out Mon May 18 22:55:45 2009 +0200 +++ b/tests/test-keyword.out Mon May 18 17:36:24 2009 -0500 @@ -112,10 +112,6 @@ A b % default keyword expansion including commit hook % interrupted commit should not change state or run commit hook -a -b -transaction abort! -rollback completed abort: empty commit message % status A a @@ -281,8 +277,6 @@ ignore $Id$ a % interrupted commit should not change state -transaction abort! -rollback completed abort: empty commit message % status M a diff -r 5b7596b142ad -r a21605de1509 tests/test-record.out --- a/tests/test-record.out Mon May 18 22:55:45 2009 +0200 +++ b/tests/test-record.out Mon May 18 17:36:24 2009 -0500 @@ -53,9 +53,7 @@ % select files but no hunks diff --git a/empty-rw b/empty-rw new file mode 100644 -examine changes to 'empty-rw'? [Ynsfdaq?] transaction abort! -rollback completed -abort: empty commit message +examine changes to 'empty-rw'? [Ynsfdaq?] abort: empty commit message changeset: -1:000000000000 tag: tip