diff -r 5afdcec8a01f -r 430837dbe7f4 hgkw/keyword.py --- a/hgkw/keyword.py Sat Jul 21 21:44:33 2007 +0200 +++ b/hgkw/keyword.py Sun Jul 22 14:56:13 2007 +0200 @@ -184,6 +184,8 @@ expand = self.t is not None action = ('shrinking', 'expanding')[expand] notify = (self.ui.note, self.ui.debug)[commit] + # backwards compatibility: older versions have dirstate.update + nodirstateupdate = not hasattr(self.repo.dirstate, 'update') files = [] for f in candidates: fp = self.repo.file(f, kwexp=expand, kwcnt=True) @@ -195,7 +197,10 @@ except AttributeError: # older versions want file descriptor as 3. optional arg self.repo.wwrite(f, data) - files.append(f) + if nodirstateupdate: + self.repo.dirstate.normal(f) + else: + files.append(f) if files: self.repo.dirstate.update(files, 'n') @@ -248,9 +253,10 @@ def _overwrite(ui, repo, files, expand): '''Expands/shrinks keywords in working directory.''' - wlock = None + wlock = lock = None try: wlock = repo.wlock() + lock = repo.lock() bail_if_changed(repo) ctx = repo.changectx() if not ctx: @@ -264,16 +270,19 @@ files = [f for f in files if f in m.keys()] else: files = m.keys() - files = [f for f in files if kwfmatcher(f) and not os.path.islink(f)] + if hasattr(repo, '_link'): + files = [f for f in files if kwfmatcher(f) and not repo._link(f)] + else: + files = [f for f in files if kwfmatcher(f) + and not os.path.islink(repo.wjoin(f))] if not files: ui.warn(_('files not configured for expansion or untracked\n')) return commit = False kwt = kwtemplater(ui, repo, expand, node=ctx.node()) kwt.overwrite(files, m, commit) - wlock = None finally: - del wlock + del wlock, lock def shrink(ui, repo, *args): @@ -392,31 +401,54 @@ match=util.always, force=False, lock=None, wlock=None, force_editor=False, p1=None, p2=None, extra={}): try: - if not wlock: - wlock = self.wlock() - removed = self.status(node1=p1, node2=p2, files=files, - match=match, wlock=wlock)[2] - - node = super(kwrepo, - self).commit(files=files, text=text, user=user, - date=date, match=match, force=force, - lock=lock, wlock=wlock, - force_editor=force_editor, - p1=p1, p2=p2, extra=extra) + kwlock = lock + kwwlock = wlock + del wlock, lock + except NameError: + # (w)lock arguments removed in recent Hg versions + kwwlock = kwlock = None + try: + if not kwwlock: + kwwlock = self.wlock() + if not kwlock: + kwlock = self.lock() + try: + removed = self.status(node1=p1, node2=p2, files=files, + match=match, wlock=kwwlock)[2] + node = super(kwrepo, + self).commit(files=files, text=text, + user=user, date=date, + match=match, force=force, + lock=kwlock, wlock=kwwlock, + force_editor=force_editor, + p1=p1, p2=p2, extra=extra) + except TypeError: + removed = self.status(node1=p1, node2=p2, + files=files, match=match)[2] + node = super(kwrepo, + self).commit(files=files, text=text, + user=user, date=date, + match=match, force=force, + force_editor=force_editor, + p1=p1, p2=p2, extra=extra) if node is not None: cl = self.changelog.read(node) - candidates = [f for f in cl[3] if kwfmatcher(f) - and f not in removed - and not os.path.islink(self.wjoin(f))] + if hasattr(self, '_link'): + candidates = [f for f in cl[3] if kwfmatcher(f) + and f not in removed + and not self._link(f)] + else: + candidates = [f for f in cl[3] if kwfmatcher(f) + and f not in removed + and not os.path.islink(self.wjoin(f))] if candidates: - m = self.manifest.read(cl[0]) + mn = self.manifest.read(cl[0]) expand = commit = True kwt = kwtemplater(ui, self, expand, node=node) - kwt.overwrite(candidates, m, commit) - wlock = None + kwt.overwrite(candidates, mn, commit) return node finally: - del wlock + del kwwlock, kwlock repo.__class__ = kwrepo