LEFT | RIGHT |
| 1 // Copyright 2011 The Go Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style |
| 3 // license that can be found in the LICENSE file. |
| 4 |
1 package main | 5 package main |
2 | 6 |
3 import ( | 7 import ( |
4 "fmt" | 8 "fmt" |
5 "os" | 9 "os" |
6 "regexp" | 10 "regexp" |
7 "strconv" | 11 "strconv" |
8 "strings" | 12 "strings" |
9 ) | 13 ) |
10 | 14 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 "--rev", rev, | 56 "--rev", rev, |
53 "--limit", "1", | 57 "--limit", "1", |
54 "--template", format, | 58 "--template", format, |
55 ) | 59 ) |
56 if err != nil { | 60 if err != nil { |
57 return | 61 return |
58 } | 62 } |
59 return strings.Split(s, ">", 5), nil | 63 return strings.Split(s, ">", 5), nil |
60 } | 64 } |
61 | 65 |
62 var revisionRe = regexp.MustCompile("([0-9]+):[0-9a-f]+$") | 66 var revisionRe = regexp.MustCompile(`([0-9]+):[0-9a-f]+$`) |
63 | 67 |
64 // getTag fetches a Commit by finding the first hg tag that matches re. | 68 // getTag fetches a Commit by finding the first hg tag that matches re. |
65 func getTag(re *regexp.Regexp) (c Commit, tag string, err os.Error) { | 69 func getTag(re *regexp.Regexp) (c Commit, tag string, err os.Error) { |
66 o, _, err := runLog(nil, "", goroot, "hg", "tags") | 70 o, _, err := runLog(nil, "", goroot, "hg", "tags") |
67 for _, l := range strings.Split(o, "\n", -1) { | 71 for _, l := range strings.Split(o, "\n", -1) { |
68 tag = re.FindString(l) | 72 tag = re.FindString(l) |
69 if tag == "" { | 73 if tag == "" { |
70 continue | 74 continue |
71 } | 75 } |
72 s := revisionRe.FindStringSubmatch(l) | 76 s := revisionRe.FindStringSubmatch(l) |
73 if s == nil { | 77 if s == nil { |
74 err = os.NewError("couldn't find revision number") | 78 err = os.NewError("couldn't find revision number") |
75 return | 79 return |
76 } | 80 } |
77 c, err = getCommit(s[1]) | 81 c, err = getCommit(s[1]) |
78 return | 82 return |
79 } | 83 } |
80 err = os.NewError("no matching tag found") | 84 err = os.NewError("no matching tag found") |
81 return | 85 return |
82 } | 86 } |
LEFT | RIGHT |