diff options
Diffstat (limited to 'meta/classes/metadata_scm.bbclass')
-rw-r--r-- | meta/classes/metadata_scm.bbclass | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass index e9b207c24f..8d3988ace8 100644 --- a/meta/classes/metadata_scm.bbclass +++ b/meta/classes/metadata_scm.bbclass | |||
@@ -32,10 +32,11 @@ def base_get_scmbasepath(d): | |||
32 | def base_get_metadata_monotone_branch(path, d): | 32 | def base_get_metadata_monotone_branch(path, d): |
33 | monotone_branch = "<unknown>" | 33 | monotone_branch = "<unknown>" |
34 | try: | 34 | try: |
35 | monotone_branch = file( "%s/_MTN/options" % path ).read().strip() | 35 | with open("%s/_MTN/options" % path) as f: |
36 | if monotone_branch.startswith( "database" ): | 36 | monotone_branch = f.read().strip() |
37 | monotone_branch_words = monotone_branch.split() | 37 | if monotone_branch.startswith( "database" ): |
38 | monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1] | 38 | monotone_branch_words = monotone_branch.split() |
39 | monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1] | ||
39 | except: | 40 | except: |
40 | pass | 41 | pass |
41 | return monotone_branch | 42 | return monotone_branch |
@@ -43,10 +44,11 @@ def base_get_metadata_monotone_branch(path, d): | |||
43 | def base_get_metadata_monotone_revision(path, d): | 44 | def base_get_metadata_monotone_revision(path, d): |
44 | monotone_revision = "<unknown>" | 45 | monotone_revision = "<unknown>" |
45 | try: | 46 | try: |
46 | monotone_revision = file( "%s/_MTN/revision" % path ).read().strip() | 47 | with open("%s/_MTN/revision" % path) as f: |
47 | if monotone_revision.startswith( "format_version" ): | 48 | monotone_revision = f.read().strip() |
48 | monotone_revision_words = monotone_revision.split() | 49 | if monotone_revision.startswith( "format_version" ): |
49 | monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1] | 50 | monotone_revision_words = monotone_revision.split() |
51 | monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1] | ||
50 | except IOError: | 52 | except IOError: |
51 | pass | 53 | pass |
52 | return monotone_revision | 54 | return monotone_revision |
@@ -54,7 +56,8 @@ def base_get_metadata_monotone_revision(path, d): | |||
54 | def base_get_metadata_svn_revision(path, d): | 56 | def base_get_metadata_svn_revision(path, d): |
55 | revision = "<unknown>" | 57 | revision = "<unknown>" |
56 | try: | 58 | try: |
57 | revision = file( "%s/.svn/entries" % path ).readlines()[3].strip() | 59 | with open("%s/.svn/entries" % path) as f: |
60 | revision = f.readlines()[3].strip() | ||
58 | except IOError: | 61 | except IOError: |
59 | pass | 62 | pass |
60 | return revision | 63 | return revision |