Mercurial > hg-stable
changeset 5014:914054ca532e
convert: acquire/release locks periodically
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 26 Jul 2007 13:34:36 -0700 |
parents | 6c1029aacc9a |
children | cb100605a516 |
files | hgext/convert/__init__.py hgext/convert/hg.py |
diffstat | 2 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/__init__.py Thu Jul 26 13:34:36 2007 -0700 +++ b/hgext/convert/__init__.py Thu Jul 26 13:34:36 2007 -0700 @@ -217,6 +217,7 @@ def convert(self): try: + self.dest.before() self.source.setrevmap(self.map) self.ui.status("scanning source...\n") heads = self.source.getheads() @@ -257,8 +258,9 @@ self.cleanup() def cleanup(self): - if self.revmapfilefd: - self.revmapfilefd.close() + self.dest.after() + if self.revmapfilefd: + self.revmapfilefd.close() def _convert(ui, src, dest=None, revmapfile=None, **opts): """Convert a foreign SCM repository to a Mercurial one.
--- a/hgext/convert/hg.py Thu Jul 26 13:34:36 2007 -0700 +++ b/hgext/convert/hg.py Thu Jul 26 13:34:36 2007 -0700 @@ -8,8 +8,9 @@ import os, time +from mercurial.i18n import _ from mercurial.node import * -from mercurial import hg, revlog, util +from mercurial import hg, lock, revlog, util from common import NoRepo, commit, converter_source, converter_sink @@ -21,6 +22,16 @@ self.repo = hg.repository(self.ui, path) except: raise NoRepo("could not open hg repo %s as sink" % path) + self.lock = None + self.wlock = None + + def before(self): + self.lock = self.repo.lock() + self.wlock = self.repo.wlock() + + def after(self): + self.lock = None + self.wlock = None def revmapfile(self): return os.path.join(self.path, ".hg", "shamap") @@ -72,6 +83,7 @@ p2 = parents.pop(0) a = self.repo.rawcommit(files, text, commit.author, commit.date, hg.bin(p1), hg.bin(p2), extra=extra) + self.repo.dirstate.invalidate() text = "(octopus merge fixup)\n" p2 = hg.hex(self.repo.changelog.tip())