# HG changeset patch # User Matt Mackall # Date 2009-05-18 22:36:24 # 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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -810,9 +810,14 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 --git a/tests/test-commit.out b/tests/test-commit.out --- a/tests/test-commit.out +++ b/tests/test-commit.out @@ -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: branch 'default' HG: added added HG: changed changed HG: removed removed -transaction abort! -rollback completed abort: empty commit message diff --git a/tests/test-import.out b/tests/test-import.out --- a/tests/test-import.out +++ b/tests/test-import.out @@ -32,8 +32,6 @@ added 1 changesets with 2 changes to 2 f 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 @@ added 1 changesets with 2 changes to 2 f 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 --git a/tests/test-keyword.out b/tests/test-keyword.out --- a/tests/test-keyword.out +++ b/tests/test-keyword.out @@ -112,10 +112,6 @@ A a 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 @@ xxx $ ignore $Id$ a % interrupted commit should not change state -transaction abort! -rollback completed abort: empty commit message % status M a diff --git a/tests/test-record.out b/tests/test-record.out --- a/tests/test-record.out +++ b/tests/test-record.out @@ -53,9 +53,7 @@ date: Thu Jan 01 00:00:00 1970 +0 % 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