changeset 8151:127281884959

util: use built-in set instead of util.unique
author Martin Geisler <mg@lazybytes.net>
date Wed, 22 Apr 2009 00:56:06 +0200
parents bbc24c0753a0
children 08e1baf924ca
files hgext/convert/gnuarch.py hgext/convert/subversion.py hgext/mq.py mercurial/context.py mercurial/dirstate.py mercurial/localrepo.py mercurial/util.py mercurial/verify.py
diffstat 8 files changed, 11 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/gnuarch.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/hgext/convert/gnuarch.py	Wed Apr 22 00:56:06 2009 +0200
@@ -168,7 +168,7 @@
             copies.update(cps)
 
         self.lastrev = rev
-        return util.sort(util.unique(changes)), copies
+        return util.sort(set(changes)), copies
 
     def getcommit(self, rev):
         changes = self.changes[rev]
--- a/hgext/convert/subversion.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/hgext/convert/subversion.py	Wed Apr 22 00:56:06 2009 +0200
@@ -754,7 +754,7 @@
                     copytopath = self.getrelpath(copytopath)
                     copies[self.recode(copytopath)] = self.recode(entry, pmodule)
 
-        return (util.unique(entries), copies)
+        return (list(set(entries)), copies)
 
     def _fetch_revisions(self, from_revnum, to_revnum):
         if from_revnum < to_revnum:
--- a/hgext/mq.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/hgext/mq.py	Wed Apr 22 00:56:06 2009 +0200
@@ -204,7 +204,7 @@
             bad = self.check_guard(guard)
             if bad:
                 raise util.Abort(bad)
-        guards = util.sort(util.unique(guards))
+        guards = util.sort(set(guards))
         self.ui.debug(_('active guards: %s\n') % ' '.join(guards))
         self.active_guards = guards
         self.guards_dirty = True
@@ -1190,11 +1190,11 @@
                         del mm[mm.index(x)]
                     dd.append(x)
 
-                m = util.unique(mm)
-                r = util.unique(dd)
-                a = util.unique(aa)
+                m = list(set(mm))
+                r = list(set(dd))
+                a = list(set(aa))
                 c = [filter(matchfn, l) for l in (m, a, r)]
-                match = cmdutil.matchfiles(repo, util.unique(c[0] + c[1] + c[2]))
+                match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2]))
                 chunks = patch.diff(repo, patchparent, match=match,
                                     changes=c, opts=self.diffopts())
                 for chunk in chunks:
--- a/mercurial/context.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/mercurial/context.py	Wed Apr 22 00:56:06 2009 +0200
@@ -734,7 +734,7 @@
         parents = [(p or nullid) for p in parents]
         p1, p2 = parents
         self._parents = [changectx(self._repo, p) for p in (p1, p2)]
-        files = util.sort(util.unique(files))
+        files = util.sort(set(files))
         self._status = [files, [], [], [], []]
         self._filectxfn = filectxfn
 
--- a/mercurial/dirstate.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/mercurial/dirstate.py	Wed Apr 22 00:56:06 2009 +0200
@@ -454,7 +454,7 @@
         work = []
         wadd = work.append
 
-        files = util.unique(match.files())
+        files = set(match.files())
         if not files or '.' in files:
             files = ['']
         results = {'.hg': None}
--- a/mercurial/localrepo.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/mercurial/localrepo.py	Wed Apr 22 00:56:06 2009 +0200
@@ -791,7 +791,7 @@
         if extra.get("close"):
             force = True
         if files:
-            files = util.unique(files)
+            files = list(set(files))
         try:
             wlock = self.wlock()
             lock = self.lock()
--- a/mercurial/util.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/mercurial/util.py	Wed Apr 22 00:56:06 2009 +0200
@@ -219,10 +219,6 @@
     """return true if a string is binary data"""
     return bool(s and '\0' in s)
 
-def unique(g):
-    """return the uniq elements of iterable g"""
-    return dict.fromkeys(g).keys()
-
 def sort(l):
     if not isinstance(l, list):
         l = list(l)
--- a/mercurial/verify.py	Wed Apr 22 00:55:32 2009 +0200
+++ b/mercurial/verify.py	Wed Apr 22 00:56:06 2009 +0200
@@ -171,7 +171,7 @@
         elif size > 0:
             storefiles[f] = True
 
-    files = util.sort(util.unique(filenodes.keys() + filelinkrevs.keys()))
+    files = util.sort(set(filenodes.keys() + filelinkrevs.keys()))
     for f in files:
         lr = filelinkrevs[f][0]
         try: