author | Yiteng Zhang <yiteng.zhang@oracle.com> |
Mon, 09 Sep 2013 10:52:27 -0700 | |
changeset 2942 | 17aad7c202b0 |
parent 2588 | 8d4e4d8d5ab4 |
child 3143 | f6fac0617411 |
child 3230 | 30355eee0c43 |
permissions | -rwxr-xr-x |
2508
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
2 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
3 |
# This program is free software; you can redistribute it and/or modify |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
4 |
# it under the terms of the GNU General Public License version 2 |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
5 |
# as published by the Free Software Foundation. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
6 |
# |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
7 |
# This program is distributed in the hope that it will be useful, |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
10 |
# GNU General Public License for more details. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
11 |
# |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
12 |
# You should have received a copy of the GNU General Public License |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
13 |
# along with this program; if not, write to the Free Software |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
14 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
15 |
# |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
16 |
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
17 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
18 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
19 |
# Create a dictionary (timestamps) mapping paths of python files in the modules |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
20 |
# directory to their timestamps. If a file is modified, its timestamp is the |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
21 |
# filesystem timestamp. If it's unchanged, its timestamp is the timestamp of |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
22 |
# the last changeset which modified it. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
23 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
24 |
import os |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
25 |
import time |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
26 |
import mercurial.cmdutil as cmdutil |
2588
8d4e4d8d5ab4
19054 support mercurial 2.0
Danek Duvall <danek.duvall@oracle.com>
parents:
2561
diff
changeset
|
27 |
import mercurial.match as matchmod |
2508
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
28 |
from mercurial.localrepo import localrepository |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
29 |
from mercurial.ui import ui |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
30 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
31 |
myui = ui() |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
32 |
repo = localrepository(myui, cmdutil.findrepo(os.getcwd())) |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
33 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
34 |
# Match only python files in src/modules. |
2588
8d4e4d8d5ab4
19054 support mercurial 2.0
Danek Duvall <danek.duvall@oracle.com>
parents:
2561
diff
changeset
|
35 |
matchfn = matchmod.match(repo.root, os.getcwd(), patterns=["re:src/modules/.*\.py$"]) |
2508
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
36 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
37 |
# Dummy prep function. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
38 |
def prep(ctx, fns): |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
39 |
pass |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
40 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
41 |
# Get the set of matching files in the working directory parent. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
42 |
manifest = set( |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
43 |
f |
2588
8d4e4d8d5ab4
19054 support mercurial 2.0
Danek Duvall <danek.duvall@oracle.com>
parents:
2561
diff
changeset
|
44 |
for f in repo["."] |
2508
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
45 |
if f.startswith("src/modules/") and f.endswith(".py") |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
46 |
) |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
47 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
48 |
# Find out which files have changed. |
2561
99ce9d129c70
18815 make install doesn't seem to update proto area any more
Danek Duvall <danek.duvall@oracle.com>
parents:
2508
diff
changeset
|
49 |
status = repo.status(match=matchfn) |
2508
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
50 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
51 |
timestamps = {} |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
52 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
53 |
# Handle the modified files first: get their timestamps from the filesystem. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
54 |
# Remove the filenames from "manifest" so that we don't look for their changeset |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
55 |
# timestamps in the next loop. |
2561
99ce9d129c70
18815 make install doesn't seem to update proto area any more
Danek Duvall <danek.duvall@oracle.com>
parents:
2508
diff
changeset
|
56 |
for f in status[0] + status[1]: |
2508
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
57 |
if f in manifest: |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
58 |
timestamps[f] = \ |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
59 |
os.stat(os.path.join(repo.root, f)).st_mtime |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
60 |
manifest.remove(f) |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
61 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
62 |
# Now walk backwards through the changesets from the working directory parent |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
63 |
# (making sure we don't look at changesets that aren't ancestors), and for each |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
64 |
# file that still needs a timestamp, grab it from the changeset and make sure we |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
65 |
# don't look at it again. |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
66 |
revs = ['reverse(ancestors(.))'] |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
67 |
for ctx in cmdutil.walkchangerevs(repo, matchfn, {'rev': revs}, prep): |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
68 |
for f in ctx.files(): |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
69 |
if f in manifest: |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
70 |
timestamps[f] = ctx.date()[0] |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
71 |
manifest.remove(f) |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
72 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
73 |
for name, stamp in timestamps.iteritems(): |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
74 |
print stamp, name |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
75 |
|
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
76 |
# Get the timestamp of the workspace. If it's unmodified, then use the |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
77 |
# timestamp of the parent of the working directory, and the latest timestamp of |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
78 |
# the modified and added files if not. (We would do removed, but we don't know |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
79 |
# when they were removed.) |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
80 |
s = repo.status() |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
81 |
modadd = s[0] + s[1] |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
82 |
if any(modadd): |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
83 |
print max(( |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
84 |
os.stat(os.path.join(repo.root, f)).st_mtime |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
85 |
for f in modadd |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
86 |
)), "." |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
87 |
else: |
619ec4359319
5965 all .pyc files are shipped in every update
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
88 |
print repo["."].date()[0], "." |