Mercurial > hg-stable
comparison hgext/mq.py @ 22821:5d4c17d11d7e
qimport: use `first` and `last` instead of direct indexing
This makes it compatible with all smartset classes.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 07 Oct 2014 00:33:47 -0700 |
parents | 602aa2b98628 |
children | 68df36ce3d8a |
comparison
equal
deleted
inserted
replaced
22820:103dcfbb385f | 22821:5d4c17d11d7e |
---|---|
1990 imported = [] | 1990 imported = [] |
1991 if rev: | 1991 if rev: |
1992 # If mq patches are applied, we can only import revisions | 1992 # If mq patches are applied, we can only import revisions |
1993 # that form a linear path to qbase. | 1993 # that form a linear path to qbase. |
1994 # Otherwise, they should form a linear path to a head. | 1994 # Otherwise, they should form a linear path to a head. |
1995 heads = repo.changelog.heads(repo.changelog.node(rev[-1])) | 1995 heads = repo.changelog.heads(repo.changelog.node(rev.first())) |
1996 if len(heads) > 1: | 1996 if len(heads) > 1: |
1997 raise util.Abort(_('revision %d is the root of more than one ' | 1997 raise util.Abort(_('revision %d is the root of more than one ' |
1998 'branch') % rev.last()) | 1998 'branch') % rev.last()) |
1999 if self.applied: | 1999 if self.applied: |
2000 base = repo.changelog.node(rev[0]) | 2000 base = repo.changelog.node(rev.first()) |
2001 if base in [n.node for n in self.applied]: | 2001 if base in [n.node for n in self.applied]: |
2002 raise util.Abort(_('revision %d is already managed') | 2002 raise util.Abort(_('revision %d is already managed') |
2003 % rev[0]) | 2003 % rev[0]) |
2004 if heads != [self.applied[-1].node]: | 2004 if heads != [self.applied[-1].node]: |
2005 raise util.Abort(_('revision %d is not the parent of ' | 2005 raise util.Abort(_('revision %d is not the parent of ' |
2006 'the queue') % rev[0]) | 2006 'the queue') % rev.first()) |
2007 base = repo.changelog.rev(self.applied[0].node) | 2007 base = repo.changelog.rev(self.applied[0].node) |
2008 lastparent = repo.changelog.parentrevs(base)[0] | 2008 lastparent = repo.changelog.parentrevs(base)[0] |
2009 else: | 2009 else: |
2010 if heads != [repo.changelog.node(rev[0])]: | 2010 if heads != [repo.changelog.node(rev.first())]: |
2011 raise util.Abort(_('revision %d has unmanaged children') | 2011 raise util.Abort(_('revision %d has unmanaged children') |
2012 % rev[0]) | 2012 % rev.first()) |
2013 lastparent = None | 2013 lastparent = None |
2014 | 2014 |
2015 diffopts = self.diffopts({'git': git}) | 2015 diffopts = self.diffopts({'git': git}) |
2016 tr = repo.transaction('qimport') | 2016 tr = repo.transaction('qimport') |
2017 try: | 2017 try: |