Commits

ZyX_I  committed 24fab08

Fixed some :AuGrep errors
Made :AuGrep use file in working directory if it was not modified compared to
its state in found revision

  • Participants
  • Parent commits 88db3a5

Comments (0)

Files changed (2)

File plugin/aurum.vim

     endwhile
     let files=[]
     if a:0
-        let allfiless=map(copy(revisions),
-                    \'repo.functions.getcsprop(repo, '.
-                    \                         'repo.functions.getcs(v:val), '.
-                    \                         '"allfiles")')
+        if empty(revisions)
+            call repo.functions.getchangesets(repo)
+            let cslist=copy(repo.cslist)
+        else
+            let cslist=map(copy(revisions), 'repo.functions.getcs(v:val)')
+        endif
+        let allfiless=map(copy(cslist), 'repo.functions.getcsprop(repo, v:val,'.
+                    \                                            '"allfiles")')
         for pattern in map(copy(a:000), 's:_r.cmdutils.globtopat('.
                     \                   'repo.functions.reltorepo(repo, v:val))')
             for allfiles in allfiless
     endif
     let qf=repo.functions.grep(repo, a:pattern, files, revisions,
                 \              get(a:opts, 'ignore_case', 0))
-    " FIXME <CR> in qflist does not jump to desired line number
+    " FIXME <CR> in qflist does not jump to desired line number for aurum://file
     call setqflist(qf)
 endfunction
 let s:grepfunc['@FWC']=['-onlystrings '.

File python/aurum.py

 
-from mercurial import hg, ui, commands
+from mercurial import hg, ui, commands, match
 from mercurial.repo import error
 import vim
 import os
         run_in_dir(repo.root, commands.grep, *args, **kwargs)
         lines=ui._getCaptured()
         r_vim=[]
-        clean=repo.status(ignored=False, unknown=False, clean=True)[6]
+        status_cache={}
+        def check_not_modified_since(rev, file):
+            key=rev+':'+file
+            if key in status_cache:
+                return status_cache[key]
+            r=file in repo.status(node1=rev, clean=True,
+                                  match=match.match(None, None, [file],
+                                                    exact=True))[6]
+            status_cache[key]=r
+            return r
         for line in lines:
-            match=grepre.match(line)
-            if not match:
+            m=grepre.match(line)
+            if not m:
                 continue
-            (file, rev, lnum, text)=match.groups()
+            (file, rev, lnum, text)=m.groups()
             rev=repo[int(rev)].hex()
-            if rev == repo['.'].hex() and file in clean:
-                file=os.path.join(repo.path, file)
+            if check_not_modified_since(rev, file):
+                file=os.path.join(repo.root, file)
             else:
                 file='aurum://file:'+\
-                        repo.path.replace('\\', '\\\\').replace(':', '\\:')+\
+                        repo.root.replace('\\', '\\\\').replace(':', '\\:')+\
                         ':'+rev+':'+file
             r_vim.append({'filename': file, 'lnum': int(lnum), 'text': line})
         vim.eval('extend(r, '+nonutf_dumps(r_vim)+')')