Merge lp:~jelmer/bzr/ghost-diffs into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jelmer/bzr/ghost-diffs
Merge into: lp:bzr
Diff against target: 132 lines (+44/-4)
7 files modified
NEWS (+4/-0)
bzrlib/diff.py (+8/-2)
bzrlib/errors.py (+10/-0)
bzrlib/revisiontree.py (+4/-1)
bzrlib/tests/test_errors.py (+5/-0)
bzrlib/tests/test_revisiontree.py (+8/-0)
bzrlib/workingtree_4.py (+5/-1)
To merge this branch: bzr merge lp:~jelmer/bzr/ghost-diffs
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+17796@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This makes "bzr diff" print the epoch time if it is unable to find the modification time for a commit.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/bzr/ghost-diffs into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #295611 NoSuchRevision: KnitPackRepository
> https://bugs.launchpad.net/bugs/295611
>
>
> This makes "bzr diff" print the epoch time if it is unable to find the modification time for a commit.
>

Better than failing. I'm not sure that 'epoch' is the best choice, but
we can get there from here.

John
=:->

 merge: approve

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktXq0sACgkQJdeBCYSNAAOYJwCcCGi2z9FSD5BLIqrVhCJmRSr9
81wAoIaZD2J0m2GC05bSkpDiZGTkoCvX
=NNmc
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Thu, 2010-01-21 at 01:21 +0000, John A Meinel wrote:
> Jelmer Vernooij wrote:
> > Jelmer Vernooij has proposed merging lp:~jelmer/bzr/ghost-diffs into lp:bzr.
> >
> > Requested reviews:
> > bzr-core (bzr-core)
> > Related bugs:
> > #295611 NoSuchRevision: KnitPackRepository
> > https://bugs.launchpad.net/bugs/295611
> >
> >
> > This makes "bzr diff" print the epoch time if it is unable to find the modification time for a commit.
> Better than failing. I'm not sure that 'epoch' is the best choice, but
> we can get there from here.
The reason I picked the epoch is because it's still a date (requirement
for some patch parsing tools) and the epoch is already used for new
files. But I agree it's not ideal.

Cheers,

Jelmer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-01-20 16:31:24 +0000
3+++ NEWS 2010-01-20 23:32:13 +0000
4@@ -64,6 +64,10 @@
5 * Better explain the --uncommitted option of merge.
6 (Neil Martinsen-Burrell, #505088)
7
8+* ``bzr diff`` will now use the epoch when it is unable to determine
9+ the timestamp of a file, if the revision it was introduced in is a
10+ ghost. (Jelmer Vernooij, #295611)
11+
12 * ``bzr export dir`` now requests all file content as a record stream,
13 rather than requsting the file content one file-at-a-time. This can make
14 exporting over the network significantly faster (54min => 9min in one
15
16=== modified file 'bzrlib/diff.py'
17--- bzrlib/diff.py 2009-12-03 07:36:17 +0000
18+++ bzrlib/diff.py 2010-01-20 23:32:13 +0000
19@@ -453,7 +453,10 @@
20
21 def _patch_header_date(tree, file_id, path):
22 """Returns a timestamp suitable for use in a patch header."""
23- mtime = tree.get_file_mtime(file_id, path)
24+ try:
25+ mtime = tree.get_file_mtime(file_id, path)
26+ except errors.FileTimestampUnavailable:
27+ mtime = 0
28 return timestamp.format_patch_date(mtime)
29
30
31@@ -747,7 +750,10 @@
32 source.close()
33 if not allow_write:
34 osutils.make_readonly(full_path)
35- mtime = tree.get_file_mtime(file_id)
36+ try:
37+ mtime = tree.get_file_mtime(file_id)
38+ except errors.FileTimestampUnavailable:
39+ mtime = 0
40 os.utime(full_path, (mtime, mtime))
41 return full_path
42
43
44=== modified file 'bzrlib/errors.py'
45--- bzrlib/errors.py 2010-01-12 02:48:41 +0000
46+++ bzrlib/errors.py 2010-01-20 23:32:13 +0000
47@@ -3114,3 +3114,13 @@
48 def __init__(self, source_branch, target_branch):
49 self.source_branch = source_branch
50 self.target_branch = target_branch
51+
52+
53+class FileTimestampUnavailable(BzrError):
54+
55+ _fmt = "The filestamp for %(path)s is not available."
56+
57+ internal_error = True
58+
59+ def __init__(self, path):
60+ self.path = path
61
62=== modified file 'bzrlib/revisiontree.py'
63--- bzrlib/revisiontree.py 2009-10-15 02:19:43 +0000
64+++ bzrlib/revisiontree.py 2010-01-20 23:32:13 +0000
65@@ -103,7 +103,10 @@
66
67 def get_file_mtime(self, file_id, path=None):
68 ie = self._inventory[file_id]
69- revision = self._repository.get_revision(ie.revision)
70+ try:
71+ revision = self._repository.get_revision(ie.revision)
72+ except errors.NoSuchRevision:
73+ raise errors.FileTimestampUnavailable(self.id2path(file_id))
74 return revision.timestamp
75
76 def is_executable(self, file_id, path=None):
77
78=== modified file 'bzrlib/tests/test_errors.py'
79--- bzrlib/tests/test_errors.py 2010-01-12 02:48:41 +0000
80+++ bzrlib/tests/test_errors.py 2010-01-20 23:32:13 +0000
81@@ -708,3 +708,8 @@
82 socket.error(13, 'Permission denied'))
83 self.assertContainsRe(str(e),
84 r'Cannot bind address "example\.com:22":.*Permission denied')
85+
86+ def test_file_timestamp_unavailable(self):
87+ e = errors.FileTimestampUnavailable("/path/foo")
88+ self.assertEquals("The filestamp for /path/foo is not available.",
89+ str(e))
90
91=== modified file 'bzrlib/tests/test_revisiontree.py'
92--- bzrlib/tests/test_revisiontree.py 2009-03-23 14:59:43 +0000
93+++ bzrlib/tests/test_revisiontree.py 2010-01-20 23:32:13 +0000
94@@ -18,9 +18,11 @@
95 """Tests for the RevisionTree class."""
96
97 from bzrlib import (
98+ errors,
99 revision,
100 )
101 import bzrlib
102+from bzrlib.inventory import ROOT_ID
103 from bzrlib.tests import TestCaseWithTransport
104
105
106@@ -59,3 +61,9 @@
107 null_tree = self.t.branch.repository.revision_tree(
108 revision.NULL_REVISION)
109 self.assertIs(None, null_tree.inventory.root)
110+
111+ def test_get_file_mtime_ghost(self):
112+ file_id = iter(self.rev_tree).next()
113+ self.rev_tree.inventory[file_id].revision = 'ghostrev'
114+ self.assertRaises(errors.FileTimestampUnavailable,
115+ self.rev_tree.get_file_mtime, file_id)
116
117=== modified file 'bzrlib/workingtree_4.py'
118--- bzrlib/workingtree_4.py 2009-12-22 17:05:47 +0000
119+++ bzrlib/workingtree_4.py 2010-01-20 23:32:13 +0000
120@@ -1755,7 +1755,11 @@
121 return None
122 parent_index = self._get_parent_index()
123 last_changed_revision = entry[1][parent_index][4]
124- return self._repository.get_revision(last_changed_revision).timestamp
125+ try:
126+ rev = self._repository.get_revision(last_changed_revision)
127+ except errors.NoSuchRevision:
128+ raise errors.FileTimestampUnavailable(self.id2path(file_id))
129+ return rev.timestamp
130
131 def get_file_sha1(self, file_id, path=None, stat_value=None):
132 entry = self._get_entry(file_id=file_id, path=path)