[PATCH 2 of 3 RFC] context: start the move of wlock from repo to workingctx
Sean Farley
sean at farley.io
Wed May 31 20:25:21 EDT 2017
# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1494537056 25200
# Thu May 11 14:10:56 2017 -0700
# Branch wctxds
# Node ID 11f1b897d1475648a88ff0115954413f46bf4137
# Parent 498dae194ccf1e82caed51a02e6ce0b77f8d92e8
context: start the move of wlock from repo to workingctx
diff --git a/mercurial/context.py b/mercurial/context.py
index a3dc7c5..c42c5e6 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1564,10 +1564,11 @@ class workingctx(committablectx):
changes=None):
super(workingctx, self).__init__(repo, text, user, date, extra, changes)
# This is where working directory references should live. For now we
# just borrow references to stuff in localrepo.
+ self.wlock = self._repo.wlock
@property
def dirstate(self):
return self._repo.dirstate
@@ -1607,11 +1608,11 @@ class workingctx(committablectx):
self.modified() or self.added() or self.removed() or
(missing and self.deleted()))
def add(self, list, prefix=""):
join = lambda f: os.path.join(prefix, f)
- with self._repo.wlock():
+ with self.wlock():
ui, ds = self._repo.ui, self.dirstate
rejected = []
lstat = self._repo.wvfs.lstat
for f in list:
scmutil.checkportable(ui, join(f))
@@ -1639,11 +1640,11 @@ class workingctx(committablectx):
ds.add(f)
return rejected
def forget(self, files, prefix=""):
join = lambda f: os.path.join(prefix, f)
- with self._repo.wlock():
+ with self.wlock():
rejected = []
for f in files:
if f not in self.dirstate:
self._repo.ui.warn(_("%s not tracked!\n") % join(f))
rejected.append(f)
@@ -1653,11 +1654,11 @@ class workingctx(committablectx):
self.dirstate.drop(f)
return rejected
def undelete(self, list):
pctxs = self.parents()
- with self._repo.wlock():
+ with self.wlock():
for f in list:
if self.dirstate[f] != 'r':
self._repo.ui.warn(_("%s not removed!\n") % f)
else:
fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
@@ -1675,11 +1676,11 @@ class workingctx(committablectx):
return
if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
self._repo.ui.warn(_("copy failed: %s is not a file or a "
"symbolic link\n") % dest)
else:
- with self._repo.wlock():
+ with self.wlock():
if self.dirstate[dest] in '?':
self.dirstate.add(dest)
elif self.dirstate[dest] in 'r':
self.dirstate.normallookup(dest)
self.dirstate.copy(source, dest)
@@ -1738,11 +1739,11 @@ class workingctx(committablectx):
try:
# updating the dirstate is optional
# so we don't wait on the lock
# wlock can invalidate the dirstate, so cache normal _after_
# taking the lock
- with self._repo.wlock(False):
+ with self.wlock(False):
normal = self.dirstate.normal
for f in fixup:
normal(f)
# write changes out explicitly, because nesting
# wlock at runtime may prevent 'wlock.release()'
More information about the Mercurial-devel
mailing list