repair: use `first` instead of direct indexing
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 07 Oct 2014 00:09:50 -0700
changeset 22818 d7b114493315
parent 22817 e4eb4bfc3616
child 22819 602aa2b98628
repair: use `first` instead of direct indexing This makes it compatible with all smartset classes.
mercurial/hg.py
mercurial/repair.py
--- a/mercurial/hg.py	Mon Oct 06 23:45:07 2014 -0700
+++ b/mercurial/hg.py	Tue Oct 07 00:09:50 2014 -0700
@@ -24,7 +24,14 @@
     peer = other.peer() # a courtesy to callers using a localrepo for other
     hashbranch, branches = branches
     if not hashbranch and not branches:
-        return revs or None, revs and revs[0] or None
+        x = revs or None
+        if util.safehasattr(revs, 'first'):
+            y =  revs.first()
+        elif revs:
+            y = revs[0]
+        else:
+            y = None
+        return x, y
     revs = revs and list(revs) or []
     if not peer.capable('branchmap'):
         if branches:
--- a/mercurial/repair.py	Mon Oct 06 23:45:07 2014 -0700
+++ b/mercurial/repair.py	Tue Oct 07 00:09:50 2014 -0700
@@ -99,7 +99,7 @@
     # is much faster
     newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
     if newbmtarget:
-        newbmtarget = repo[newbmtarget[0]].node()
+        newbmtarget = repo[newbmtarget.first()].node()
     else:
         newbmtarget = '.'