kiilerix avatar kiilerix committed f786fc4

log: follow filenames through renames (issue647)

In commands.log a displayer was initialized from
cmdutil.show_changeset() with the initial matchfn (which designates
the specified files which only is correct in the highest revision in
the range). prep() is handed the correct list of files, but
displayer.show() didn't use that list but keept using the original
matchfn.

The matchfn argument to cmdutil.show_changeset() wasn't specified in
other places and is only used in .show(), so now we give the matchfn
as an optional parameter to .show().

We do however still have to detect --patch and --stat from opts in
show_changeset() and let it imply a matchall, but that can now be
overruled with the new .show() matchfn parameter.

Comments (0)

Files changed (2)

mercurial/cmdutil.py

         if self.footer:
             self.ui.write(self.footer)
 
-    def show(self, ctx, copies=None, **props):
+    def show(self, ctx, copies=None, matchfn=None, **props):
         if self.buffered:
             self.ui.pushbuffer()
-            self._show(ctx, copies, props)
+            self._show(ctx, copies, matchfn, props)
             self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True)
         else:
-            self._show(ctx, copies, props)
+            self._show(ctx, copies, matchfn, props)
 
-    def _show(self, ctx, copies, props):
+    def _show(self, ctx, copies, matchfn, props):
         '''show a single changeset or file revision'''
         changenode = ctx.node()
         rev = ctx.rev()
                               label='log.summary')
         self.ui.write("\n")
 
-        self.showpatch(changenode)
+        self.showpatch(changenode, matchfn)
 
-    def showpatch(self, node):
-        if self.patch:
+    def showpatch(self, node, matchfn):
+        if not matchfn:
+            matchfn = self.patch
+        if matchfn:
             stat = self.diffopts.get('stat')
             diffopts = patch.diffopts(self.ui, self.diffopts)
             prev = self.repo.changelog.parents(node)[0]
             diffordiffstat(self.ui, self.repo, diffopts, prev, node,
-                           match=self.patch, stat=stat)
+                           match=matchfn, stat=stat)
             self.ui.write("\n")
 
     def _meaningful_parentrevs(self, log, rev):
             return []
         return parents
 
-    def _show(self, ctx, copies, props):
+    def _show(self, ctx, copies, matchfn, props):
         '''show a single changeset or file revision'''
 
         showlist = templatekw.showlist
             # write changeset metadata, then patch if requested
             key = types['changeset']
             self.ui.write(templater.stringify(self.t(key, **props)))
-            self.showpatch(ctx.node())
+            self.showpatch(ctx.node(), matchfn)
 
             if types['footer']:
                 if not self.footer:
         except SyntaxError, inst:
             raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
 
-def show_changeset(ui, repo, opts, buffered=False, matchfn=False):
+def show_changeset(ui, repo, opts, buffered=False):
     """show one changeset using template or regular display.
 
     Display format will be the first non-empty hit of:
     # options
     patch = False
     if opts.get('patch') or opts.get('stat'):
-        patch = matchfn or matchall(repo)
+        patch = matchall(repo)
 
     tmpl = opts.get('template')
     style = None

mercurial/commands.py

     branches = opts.get('branch', []) + opts.get('only_branch', [])
     opts['branch'] = [repo.lookupbranch(b) for b in branches]
 
-    displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
+    displayer = cmdutil.show_changeset(ui, repo, opts, True)
     def prep(ctx, fns):
         rev = ctx.rev()
         parents = [p for p in repo.changelog.parentrevs(rev)
                 if rename:
                     copies.append((fn, rename[0]))
 
-        displayer.show(ctx, copies=copies)
+        revmatchfn = None
+        if opts.get('patch') or opts.get('stat'):
+            revmatchfn = cmdutil.match(repo, fns)
+
+        displayer.show(ctx, copies=copies, matchfn=revmatchfn)
 
     for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
         if count == limit:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.