Mercurial > hg
comparison mercurial/cmdutil.py @ 17471:ad1561723dde
amend: lock the repository during the whole process
Without this changes another writer can lock the repository in the middle the
amend process. The resulting mess can be pretty ugly.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sat, 25 Aug 2012 15:37:28 +0200 |
parents | 8fea378242e3 |
children | 965fbe04fd96 |
comparison
equal
deleted
inserted
replaced
17470:89467a7c2132 | 17471:ad1561723dde |
---|---|
9 from i18n import _ | 9 from i18n import _ |
10 import os, sys, errno, re, tempfile | 10 import os, sys, errno, re, tempfile |
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies | 11 import util, scmutil, templater, patch, error, templatekw, revlog, copies |
12 import match as matchmod | 12 import match as matchmod |
13 import subrepo, context, repair, bookmarks, graphmod, revset, phases | 13 import subrepo, context, repair, bookmarks, graphmod, revset, phases |
14 import lock as lockmod | |
14 | 15 |
15 def parsealiases(cmd): | 16 def parsealiases(cmd): |
16 return cmd.lstrip("^").split("|") | 17 return cmd.lstrip("^").split("|") |
17 | 18 |
18 def findpossible(cmd, table, strict=False): | 19 def findpossible(cmd, table, strict=False): |
1573 | 1574 |
1574 def amend(ui, repo, commitfunc, old, extra, pats, opts): | 1575 def amend(ui, repo, commitfunc, old, extra, pats, opts): |
1575 ui.note(_('amending changeset %s\n') % old) | 1576 ui.note(_('amending changeset %s\n') % old) |
1576 base = old.p1() | 1577 base = old.p1() |
1577 | 1578 |
1578 wlock = repo.wlock() | 1579 wlock = lock = None |
1579 try: | 1580 try: |
1581 wlock = repo.wlock() | |
1582 lock = repo.lock() | |
1580 # First, do a regular commit to record all changes in the working | 1583 # First, do a regular commit to record all changes in the working |
1581 # directory (if there are any) | 1584 # directory (if there are any) |
1582 ui.callhooks = False | 1585 ui.callhooks = False |
1583 try: | 1586 try: |
1584 node = commit(ui, repo, commitfunc, pats, opts) | 1587 node = commit(ui, repo, commitfunc, pats, opts) |
1692 repo._bookmarks[bm] = newid | 1695 repo._bookmarks[bm] = newid |
1693 bookmarks.write(repo) | 1696 bookmarks.write(repo) |
1694 | 1697 |
1695 # Strip the intermediate commit (if there was one) and the amended | 1698 # Strip the intermediate commit (if there was one) and the amended |
1696 # commit | 1699 # commit |
1697 lock = repo.lock() | 1700 if node: |
1698 try: | 1701 ui.note(_('stripping intermediate changeset %s\n') % ctx) |
1699 if node: | 1702 ui.note(_('stripping amended changeset %s\n') % old) |
1700 ui.note(_('stripping intermediate changeset %s\n') % ctx) | 1703 repair.strip(ui, repo, old.node(), topic='amend-backup') |
1701 ui.note(_('stripping amended changeset %s\n') % old) | |
1702 repair.strip(ui, repo, old.node(), topic='amend-backup') | |
1703 finally: | |
1704 lock.release() | |
1705 finally: | 1704 finally: |
1706 wlock.release() | 1705 lockmod.release(wlock, lock) |
1707 return newid | 1706 return newid |
1708 | 1707 |
1709 def commiteditor(repo, ctx, subs): | 1708 def commiteditor(repo, ctx, subs): |
1710 if ctx.description(): | 1709 if ctx.description(): |
1711 return ctx.description() | 1710 return ctx.description() |