[states] update qimport code so it doesn't fails on qimport without -r
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 14 Sep 2011 17:51:25 +0200
changeset 77 45afdbf062f4
parent 76 e68f6821ae84
child 78 ddcc4bb6c4d4
[states] update qimport code so it doesn't fails on qimport without -r
hgext/states.py
--- a/hgext/states.py	Wed Sep 14 17:40:24 2011 +0200
+++ b/hgext/states.py	Wed Sep 14 17:51:25 2011 +0200
@@ -679,14 +679,17 @@
 
 def wrapmqqimport(orig, queue, repo, *args, **kwargs):
    if 'rev' in kwargs:
-       # we can take the min as non linear import wil break
-       base = min(scmutil.revrange(repo, kwargs['rev']))
-       basenode = repo.changelog.node(base)
-       state = repo.nodestate(basenode)
-       if not state.mutable:
-           raise util.Abort(_('can not qimport published changeset %s')
-                            % node.short(basenode),
-                            hint=_('see `hg help --extension states` for details'))
+       # we can take the min as non linear import will break
+       # anyway
+       revs = scmutil.revrange(repo, kwargs['rev'])
+       if revs:
+           base = min(revs)
+           basenode = repo.changelog.node(base)
+           state = repo.nodestate(basenode)
+           if not state.mutable:
+               raise util.Abort(_('can not qimport published changeset %s')
+                    % node.short(basenode),
+                    hint=_('see `hg help --extension states` for details'))
    return orig(queue, repo, *args, **kwargs)
 
 
@@ -753,7 +756,6 @@
         def nodestate(self, node):
             """return the state object associated to the given node"""
             rev = self.changelog.rev(node)
-
             for state in STATES:
                 # avoid for untracked heads
                 if state.next is not None: