##// END OF EJS Templates
churn: do not crash on malformed lines in alias file
Martin Geisler -
r12069:7c3c4441 stable
parent child Browse files
Show More
@@ -129,10 +129,14 b' def churn(ui, repo, *pats, **opts):'
129 aliases = repo.wjoin('.hgchurn')
129 aliases = repo.wjoin('.hgchurn')
130 if aliases:
130 if aliases:
131 for l in open(aliases, "r"):
131 for l in open(aliases, "r"):
132 if not l.strip():
132 try:
133 alias, actual = l.split('=' in l and '=' or None, 1)
134 amap[alias.strip()] = actual.strip()
135 except ValueError:
136 l = l.strip()
137 if l:
138 ui.warn(_("skipping malformed alias: %s\n" % l))
133 continue
139 continue
134 alias, actual = l.split('=' in l and '=' or None, 1)
135 amap[alias.strip()] = actual.strip()
136
140
137 rate = countrate(ui, repo, amap, *pats, **opts).items()
141 rate = countrate(ui, repo, amap, *pats, **opts).items()
138 if not rate:
142 if not rate:
@@ -40,6 +40,7 b' cat > ../aliases <<EOF'
40 user1 alias1
40 user1 alias1
41
41
42 user3 alias3
42 user3 alias3
43 not-an-alias
43 EOF
44 EOF
44 hg churn --aliases ../aliases
45 hg churn --aliases ../aliases
45 echo % churn with .hgchurn
46 echo % churn with .hgchurn
@@ -16,10 +16,12 b' user1 2 ***************************'
16 user2 2 ***************************************************************
16 user2 2 ***************************************************************
17 user1 1 ********************************
17 user1 1 ********************************
18 % churn with aliases
18 % churn with aliases
19 skipping malformed alias: not-an-alias
19 alias3 3 **************************************************************
20 alias3 3 **************************************************************
20 alias1 3 **************************************************************
21 alias1 3 **************************************************************
21 user2 2 *****************************************
22 user2 2 *****************************************
22 % churn with .hgchurn
23 % churn with .hgchurn
24 skipping malformed alias: not-an-alias
23 alias3 3 **************************************************************
25 alias3 3 **************************************************************
24 alias1 3 **************************************************************
26 alias1 3 **************************************************************
25 user2 2 *****************************************
27 user2 2 *****************************************
General Comments 0
You need to be logged in to leave comments. Login now