From patchwork Fri Jun 23 18:39:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: dagop: make stopdepth in _genrevancestors() match revset arg From: via Mercurial-devel X-Patchwork-Id: 21643 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Fri, 23 Jun 2017 11:39:37 -0700 # HG changeset patch # User Martin von Zweigbergk # Date 1498241757 25200 # Fri Jun 23 11:15:57 2017 -0700 # Node ID ba913ce1b38584554a62ba3d765d124c284e7e0d # Parent f63d111258dab8375322483888a44bf9be6c4673 dagop: make stopdepth in _genrevancestors() match revset arg I was confused for a while that stopdepth was exclusive in dagop.py but not in the ancestors() revset. Let's also raise an exception if stopdepth<0, since revset.py already checks that. diff --git a/mercurial/dagop.py b/mercurial/dagop.py --- a/mercurial/dagop.py +++ b/mercurial/dagop.py @@ -32,8 +32,8 @@ startdepth = 0 if stopdepth is None: stopdepth = _maxlogdepth - if stopdepth <= 0: - return + if stopdepth < 0: + raise error.ProgrammingError('negative stopdepth') cl = repo.changelog @@ -62,7 +62,7 @@ lastrev = currev yield currev pdepth = curdepth + 1 - if foundnew and pdepth < stopdepth: + if foundnew and pdepth <= stopdepth: try: for prev in cl.parentrevs(currev)[:cut]: if prev != node.nullrev: @@ -76,7 +76,7 @@ """Like revlog.ancestors(), but supports additional options, includes the given revs themselves, and returns a smartset - Scan ends at the stopdepth (exlusive) if specified. Revisions found + Scan ends at the stopdepth (inclusive) if specified. Revisions found earlier than the startdepth are omitted. """ gen = _genrevancestors(repo, revs, followfirst, startdepth, stopdepth) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -271,7 +271,7 @@ n = getinteger(args['depth'], _("ancestors expects an integer depth")) if n < 0: raise error.ParseError(_("negative depth")) - stopdepth = n + 1 + stopdepth = n return _ancestors(repo, subset, args['set'], startdepth=startdepth, stopdepth=stopdepth)