Merge lp:~phanatic/bzr/795557-export-subdir-timestamps into lp:bzr

Proposed by Szilveszter Farkas
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5974
Proposed branch: lp:~phanatic/bzr/795557-export-subdir-timestamps
Merge into: lp:bzr
Diff against target: 80 lines (+37/-1)
4 files modified
bzrlib/export/dir_exporter.py (+5/-1)
bzrlib/tests/blackbox/test_export.py (+10/-0)
bzrlib/tests/test_export.py (+19/-0)
doc/en/release-notes/bzr-2.4.txt (+3/-0)
To merge this branch: bzr merge lp:~phanatic/bzr/795557-export-subdir-timestamps
Reviewer Review Type Date Requested Status
John A Meinel Approve
Vincent Ladeuil Approve
Jelmer Vernooij (community) Approve
Review via email: mp+64195@code.launchpad.net

Commit message

Bug #795557, allow exporting a subdir when also exporting the timestamps.

Description of the change

A quick fix for bug 795557 (exporting subdirectories with --per-file-timestamps fails). This is my first patch for Bazaar, so I welcome comments, suggestions.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Looks great :) Can you add an entry to NEWS (doc/en/release-notes/bzr-2.4.txt) ?

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

Hey phanatic ! Welcome back ;)

Can you execute the contributor agreement http://www.canonical.com/contributors ?

Once that's done and with a news entry added we could land this.

review: Approve
Revision history for this message
Szilveszter Farkas (phanatic) wrote :

Thanks for the review, I have also sent the contributor agreement :)

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

I'll mark this approved, and assume Martin will notice the contributor agreement soon and update the groups.

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

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/export/dir_exporter.py'
2--- bzrlib/export/dir_exporter.py 2011-06-06 09:31:59 +0000
3+++ bzrlib/export/dir_exporter.py 2011-06-11 20:33:31 +0000
4@@ -96,7 +96,11 @@
5 if force_mtime is not None:
6 mtime = force_mtime
7 else:
8- mtime = tree.get_file_mtime(tree.path2id(relpath), relpath)
9+ if subdir is None:
10+ file_id = tree.path2id(relpath)
11+ else:
12+ file_id = tree.path2id(osutils.pathjoin(subdir, relpath))
13+ mtime = tree.get_file_mtime(file_id, relpath)
14 os.utime(fullpath, (mtime, mtime))
15
16 yield
17
18=== modified file 'bzrlib/tests/blackbox/test_export.py'
19--- bzrlib/tests/blackbox/test_export.py 2011-06-07 13:33:41 +0000
20+++ bzrlib/tests/blackbox/test_export.py 2011-06-11 20:33:31 +0000
21@@ -387,6 +387,16 @@
22 har_st = os.stat('t/har')
23 self.assertEquals(315532800, har_st.st_mtime)
24
25+ def test_dir_export_partial_tree_per_file_timestamps(self):
26+ tree = self.example_branch()
27+ self.build_tree(['branch/subdir/', 'branch/subdir/foo.txt'])
28+ tree.smart_add(['branch'])
29+ # Earliest allowable date on FAT32 filesystems is 1980-01-01
30+ tree.commit('setup', timestamp=315532800)
31+ self.run_bzr('export --per-file-timestamps tpart branch/subdir')
32+ foo_st = os.stat('tpart/foo.txt')
33+ self.assertEquals(315532800, foo_st.st_mtime)
34+
35 def test_export_directory(self):
36 """Test --directory option"""
37 self.example_branch()
38
39=== modified file 'bzrlib/tests/test_export.py'
40--- bzrlib/tests/test_export.py 2011-05-13 12:51:05 +0000
41+++ bzrlib/tests/test_export.py 2011-06-11 20:33:31 +0000
42@@ -146,6 +146,25 @@
43 self.assertEqual(a_time, t.stat('a').st_mtime)
44 self.assertEqual(b_time, t.stat('b').st_mtime)
45
46+ def test_subdir_files_per_timestamps(self):
47+ builder = self.make_branch_builder('source')
48+ builder.start_series()
49+ foo_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0))
50+ builder.build_snapshot(None, None, [
51+ ('add', ('', 'root-id', 'directory', '')),
52+ ('add', ('subdir', 'subdir-id', 'directory', '')),
53+ ('add', ('subdir/foo.txt', 'foo-id', 'file', 'content\n'))],
54+ timestamp=foo_time)
55+ builder.finish_series()
56+ b = builder.get_branch()
57+ b.lock_read()
58+ self.addCleanup(b.unlock)
59+ tree = b.basis_tree()
60+ export.export(tree, 'target', format='dir', subdir='subdir',
61+ per_file_timestamps=True)
62+ t = self.get_transport('target')
63+ self.assertEquals(foo_time, t.stat('foo.txt').st_mtime)
64+
65
66 class TarExporterTests(tests.TestCaseWithTransport):
67
68
69=== modified file 'doc/en/release-notes/bzr-2.4.txt'
70--- doc/en/release-notes/bzr-2.4.txt 2011-06-09 11:59:08 +0000
71+++ doc/en/release-notes/bzr-2.4.txt 2011-06-11 20:33:31 +0000
72@@ -73,6 +73,9 @@
73 ``UIFactory.get_password`` and ``UIFactory.get_boolean`` now require a
74 unicode prompt to be passed in. (Jelmer Vernooij, #592083)
75
76+* Fix exporting subdirectory with ``--per-file-timestamps``.
77+ (Szilveszter Farkas, #795557)
78+
79 Documentation
80 *************
81