diff -r 414e81ae971f mercurial/localrepo.py --- a/mercurial/localrepo.py Thu Feb 23 22:47:40 2006 +0100 +++ b/mercurial/localrepo.py Fri Feb 24 05:20:57 2006 +0100 @@ -310,9 +310,12 @@ class localrepository(object): return (None, fp1, fp2) def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None): - orig_parent = self.dirstate.parents()[0] or nullid - p1 = p1 or self.dirstate.parents()[0] or nullid - p2 = p2 or self.dirstate.parents()[1] or nullid + if not wlock: + wlock = self.wlock() + pl = self.dirstate.parents() + orig_parent = pl[0] or nullid + p1 = p1 or pl[0] or nullid + p2 = p2 or pl[1] or nullid c1 = self.changelog.read(p1) c2 = self.changelog.read(p2) m1 = self.manifest.read(c1[0]) @@ -325,8 +328,6 @@ class localrepository(object): else: update_dirstate = 0 - if not wlock: - wlock = self.wlock() l = self.lock() tr = self.transaction() mm = m1.copy() @@ -371,6 +372,9 @@ class localrepository(object): remove = [] changed = [] + if not wlock: + wlock = self.wlock() + if files: for f in files: s = self.dirstate.state(f) @@ -402,8 +406,6 @@ class localrepository(object): self.hook("precommit", throw=True, parent1=xp1, parent2=xp2) - if not wlock: - wlock = self.wlock() l = self.lock() tr = self.transaction() @@ -620,12 +622,12 @@ class localrepository(object): self.dirstate.update([f], "r") def undelete(self, list, wlock=None): + if not wlock: + wlock = self.wlock() p = self.dirstate.parents()[0] mn = self.changelog.read(p)[0] mf = self.manifest.readflags(mn) m = self.manifest.read(mn) - if not wlock: - wlock = self.wlock() for f in list: if self.dirstate.state(f) not in "r": self.ui.warn("%s not removed!\n" % f) @@ -1423,6 +1425,9 @@ class localrepository(object): def update(self, node, allow=False, force=False, choose=None, moddirstate=True, forcemerge=False, wlock=None): + if moddirstate and not wlock: + wlock = self.wlock() + pl = self.dirstate.parents() if not force and pl[1] != nullid: self.ui.warn(_("aborting: outstanding uncommitted merges\n")) @@ -1442,7 +1447,7 @@ class localrepository(object): ma = self.manifest.read(man) mfa = self.manifest.readflags(man) - modified, added, removed, deleted, unknown = self.changes() + modified, added, removed, deleted, unknown = self.changes(wlock=wlock) # is this a jump, or a merge? i.e. is there a linear path # from p1 to p2? @@ -1483,9 +1488,6 @@ class localrepository(object): for f in added + modified + unknown: mw[f] = "" mfw[f] = util.is_exec(self.wjoin(f), mfw.get(f, False)) - - if moddirstate and not wlock: - wlock = self.wlock() for f in deleted + removed: if f in mw: