[PATCH 2 of 5] trydiff: extract 'date2' variable like existing 'date1'

Martin von Zweigbergk martinvonz at google.com
Tue Dec 23 18:44:12 CST 2014


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1419375390 28800
#      Tue Dec 23 14:56:30 2014 -0800
# Node ID e239ac84efe8205f6f5c30bad1931fae9c095791
# Parent  9b88a9a3e4f46568183e498d499158be78512c57
trydiff: extract 'date2' variable like existing 'date1'

Note that there is a comment saying "ctx2 date may be dynamic". The
comment was introduced in dccb83241dd0 (patch: use contexts for diff,
2006-12-25), but it seems like it stopped being dynamic in that very
changeset -- before that changeset, the date seems to have been the
file's mtime, but after the changeset, it seems to be the changeset's
timestamp (current time for workingctx). Since no one seems to have
missed the "dynamicness", let's simplify and extract a date2 for
symmetry with date1.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1784,6 +1784,7 @@
         return line
 
     date1 = util.datestr(ctx1.date())
+    date2 = util.datestr(ctx2.date())
     man1 = ctx1.manifest()
 
     gone = set()
@@ -1878,9 +1879,8 @@
                     addindexmeta(header, [gitindex(to), gitindex(tn)])
             else:
                 text = mdiff.unidiff(to, date1,
-                                    # ctx2 date may be dynamic
-                                    tn, util.datestr(ctx2.date()),
-                                    join(a), join(b), opts=opts)
+                                     tn, date2,
+                                     join(a), join(b), opts=opts)
             if header and (text or len(header) > 1):
                 yield ''.join(header)
             if text:


More information about the Mercurial-devel mailing list