Fix log regression where log -p file showed diffs for other files
authorMatt Mackall <mpm@selenic.com>
Fri, 08 Dec 2006 20:44:58 -0600
changeset 3837 7df171ea50cd
parent 3836 925b1816c746
child 3838 dec4eba7ccad
Fix log regression where log -p file showed diffs for other files
mercurial/cmdutil.py
mercurial/commands.py
tests/test-log
tests/test-log.out
--- a/mercurial/cmdutil.py	Fri Dec 08 17:10:40 2006 -0800
+++ b/mercurial/cmdutil.py	Fri Dec 08 20:44:58 2006 -0600
@@ -314,7 +314,7 @@
     def showpatch(self, node):
         if self.patch:
             prev = self.repo.changelog.parents(node)[0]
-            patch.diff(self.repo, prev, node, fp=self.ui)
+            patch.diff(self.repo, prev, node, match=self.patch, fp=self.ui)
             self.ui.write("\n")
 
 class changeset_templater(changeset_printer):
@@ -510,7 +510,7 @@
         except SyntaxError, inst:
             raise util.Abort(_('%s: %s') % (self.t.mapfile, inst.args[0]))
 
-def show_changeset(ui, repo, opts, buffered=False):
+def show_changeset(ui, repo, opts, buffered=False, matchfn=False):
     """show one changeset using template or regular display.
 
     Display format will be the first non-empty hit of:
@@ -522,7 +522,12 @@
     regular display via changeset_printer() is done.
     """
     # options
-    patch = opts.get('patch')
+    patch = False
+    if opts.get('patch'):
+        patch = lambda x: True
+        if matchfn:
+            patch = matchfn
+
     br = None
     if opts.get('branches'):
         ui.warn(_("the --branches option is deprecated, "
--- a/mercurial/commands.py	Fri Dec 08 17:10:40 2006 -0800
+++ b/mercurial/commands.py	Fri Dec 08 20:44:58 2006 -0600
@@ -1548,7 +1548,7 @@
         df = util.matchdate(opts["date"])
 
 
-    displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
+    displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
     for st, rev, fns in changeiter:
         if st == 'add':
             changenode = repo.changelog.node(rev)
--- a/tests/test-log	Fri Dec 08 17:10:40 2006 -0800
+++ b/tests/test-log	Fri Dec 08 20:44:58 2006 -0600
@@ -14,6 +14,8 @@
 hg ci -mc -d '3 0'
 
 hg mv a b
+echo a > d
+hg add d
 hg ci -md -d '4 0'
 
 hg mv dir/b e
@@ -39,6 +41,9 @@
 hg ci -Ame2 -d '6 0'
 hg log -vC --template '{rev} {file_copies%filecopy}\n' -r 5
 
+echo '% log -p d'
+hg log -pv d
+
 # log --follow tests
 hg init ../follow
 cd ../follow
--- a/tests/test-log.out	Fri Dec 08 17:10:40 2006 -0800
+++ b/tests/test-log.out	Fri Dec 08 20:44:58 2006 -0600
@@ -7,13 +7,13 @@
 % -f, directory
 abort: can only follow copies/renames for explicit file names
 % -f, but no args
-changeset:   4:8c1c8408f737
+changeset:   4:b30c444c7c84
 tag:         tip
 user:        test
 date:        Thu Jan 01 00:00:05 1970 +0000
 summary:     e
 
-changeset:   3:c4ba038c90ce
+changeset:   3:16b60bf3f99a
 user:        test
 date:        Thu Jan 01 00:00:04 1970 +0000
 summary:     d
@@ -43,7 +43,7 @@
 
 
 % many renames
-changeset:   4:8c1c8408f737
+changeset:   4:b30c444c7c84
 tag:         tip
 user:        test
 date:        Thu Jan 01 00:00:05 1970 +0000
@@ -86,6 +86,21 @@
 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 adding foo
 5 e (dir/b)
+% log -p d
+changeset:   3:16b60bf3f99a
+user:        test
+date:        Thu Jan 01 00:00:04 1970 +0000
+files:       a b d
+description:
+d
+
+
+diff -r 21fba396af4c -r 16b60bf3f99a d
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/d	Thu Jan 01 00:00:04 1970 +0000
+@@ -0,0 +1,1 @@
++a
+
 adding base
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 adding b1