Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 5743:df09fad0059e
util: simplify unique
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 27 Dec 2007 23:55:40 -0600 |
parents | 2bd4d56ff37c |
children | 027264e720aa |
comparison
equal
deleted
inserted
replaced
5742:2bd4d56ff37c | 5743:df09fad0059e |
---|---|
222 return True | 222 return True |
223 return False | 223 return False |
224 | 224 |
225 def unique(g): | 225 def unique(g): |
226 """return the uniq elements of iterable g""" | 226 """return the uniq elements of iterable g""" |
227 seen = {} | 227 return dict.fromkeys(g).keys() |
228 l = [] | |
229 for f in g: | |
230 if f not in seen: | |
231 seen[f] = 1 | |
232 l.append(f) | |
233 return l | |
234 | 228 |
235 class Abort(Exception): | 229 class Abort(Exception): |
236 """Raised if a command needs to print an error and exit.""" | 230 """Raised if a command needs to print an error and exit.""" |
237 | 231 |
238 class UnexpectedOutput(Abort): | 232 class UnexpectedOutput(Abort): |