diff -r 03268523c017 -r a3b8a3a03cc7 hgkw/keyword.py --- a/hgkw/keyword.py Mon Jun 30 12:33:36 2008 +0200 +++ b/hgkw/keyword.py Mon Jun 30 12:42:48 2008 +0200 @@ -310,14 +310,28 @@ def overwrite(self, node, expand, files): '''Overwrites selected files expanding/shrinking keywords.''' - ctx = self.repo.changectx(node) - mf = ctx.manifest() + # repo[changeid] introduced in f6c00b17387c if node is not None: # commit + try: + ctx = self.repo[node] + except TypeError: + ctx = self.repo.changectx(node) + mf = ctx.manifest() files = [f for f in ctx.files() if f in mf] notify = self.ui.debug else: # kwexpand/kwshrink + try: + ctx = self.repo['.'] + except TypeError: + ctx = self.repo.changectx() + mf = ctx.manifest() notify = self.ui.note - candidates = [f for f in files if self.iskwfile(f, mf.linkf)] + if hasattr(ctx, 'flags'): + # 51b0e799352f + islink = lambda p: 'l' in ctx.flags(p) + else: + islink = mf.linkf + candidates = [f for f in files if self.iskwfile(f, islink)] if candidates: self.restrict = True # do not expand when reading candidates.sort() @@ -392,14 +406,18 @@ return t2 != text return revlog.revlog.cmp(self, node, text) -def _status(ui, repo, kwt, *pats, **opts): +def _status(ui, repo, kwt, unknown, *pats, **opts): '''Bails out if [keyword] configuration is not active. Returns status of working directory.''' if kwt: try: # 0159b7a36184 ff. matcher = cmdutil.match(repo, pats, opts) - return repo.status(match=matcher, list_clean=True) + try: + # 4faaa0535ea7 + return repo.status(match=matcher, unknown=unknown, clean=True) + except TypeError: + return repo.status(match=matcher, list_clean=True) except AttributeError: files, match, anypats = cmdutil.matchpats(repo, pats, opts) return repo.status(files=files, match=match, list_clean=True) @@ -412,15 +430,15 @@ if repo.dirstate.parents()[1] != nullid: raise util.Abort(_('outstanding uncommitted merge')) kwt = kwtools['templater'] - status = _status(ui, repo, kwt, *pats, **opts) - modified, added, removed, deleted, unknown, ignored, clean = status + status = _status(ui, repo, kwt, False, *pats, **opts) + modified, added, removed, deleted = status[:4] if modified or added or removed or deleted: raise util.Abort(_('outstanding uncommitted changes')) wlock = lock = None try: wlock = repo.wlock() lock = repo.lock() - kwt.overwrite(None, expand, clean) + kwt.overwrite(None, expand, status[6]) finally: del wlock, lock @@ -523,14 +541,24 @@ That is, files matched by [keyword] config patterns but not symlinks. ''' kwt = kwtools['templater'] - status = _status(ui, repo, kwt, *pats, **opts) + status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts) modified, added, removed, deleted, unknown, ignored, clean = status - files = modified + added + clean - if opts.get('untracked'): - files += unknown - files.sort() - wctx = repo.workingctx() - if hasattr(wctx, 'fileflags'): + try: + # f67d1468ac50 + files = util.sort(modified + added + clean + unknown) + except AttributeError: + files = modified + added + clean + if opts.get('untracked'): + files += unknown + files.sort() + try: + # f6c00b17387c + wctx = repo[None] + except TypeError: + wctx = repo.workingctx() + if hasattr(wctx, 'flags'): + islink = lambda p: 'l' in wctx.flags(p) + elif hasattr(wctx, 'fileflags'): islink = lambda p: 'l' in wctx.fileflags(p) else: mf = wctx.manifest()