# HG changeset patch # User Martin von Zweigbergk # Date 1554488640 25200 # Node ID fcd7a91dec23a09e9e23a2bbae47c5de2a6a4295 # Parent 50b69c08651b2fc29db36fd84ddecfacc49bd32f localrepo: don't allow lookup of working directory revision It seems that repo.lookup(), which is what supports the "lookup" wire protocol command, should not allow the working copy revision input. This fixes both the pull test and the convert test I just added. Differential Revision: https://phab.mercurial-scm.org/D6215 diff -r 50b69c08651b -r fcd7a91dec23 mercurial/localrepo.py --- a/mercurial/localrepo.py Fri Apr 05 11:22:26 2019 -0700 +++ b/mercurial/localrepo.py Fri Apr 05 11:24:00 2019 -0700 @@ -1564,7 +1564,10 @@ pass def lookup(self, key): - return scmutil.revsymbol(self, key).node() + node = scmutil.revsymbol(self, key).node() + if node is None: + raise error.RepoLookupError(_("unknown revision '%s'") % key) + return node def lookupbranch(self, key): if self.branchmap().hasbranch(key): diff -r 50b69c08651b -r fcd7a91dec23 tests/test-convert-hg-source.t --- a/tests/test-convert-hg-source.t Fri Apr 05 11:22:26 2019 -0700 +++ b/tests/test-convert-hg-source.t Fri Apr 05 11:24:00 2019 -0700 @@ -218,11 +218,10 @@ $ hg ci -Aqm 'the working copy is called ffffffffffff' $ cd .. -BROKEN: crashes when the "ffffffffffff" is encountered $ hg convert commit-references new-commit-references -q \ - > --config convert.hg.sourcename=yes 2>&1 | grep TypeError - TypeError: b2a_hex() argument 1 must be string or buffer, not None + > --config convert.hg.sourcename=yes $ cd new-commit-references $ hg log -T '{node|short} {desc}\n' + fe295c9e6bc6 the working copy is called ffffffffffff 642508659503 the previous commit was c2491f685436 c2491f685436 initial diff -r 50b69c08651b -r fcd7a91dec23 tests/test-pull.t --- a/tests/test-pull.t Fri Apr 05 11:22:26 2019 -0700 +++ b/tests/test-pull.t Fri Apr 05 11:24:00 2019 -0700 @@ -76,10 +76,9 @@ [255] Test pull of working copy revision -BROKEN: should give a better error message $ hg pull -r 'ffffffffffff' pulling from http://foo@localhost:$HGPORT/ - abort: b2a_hex() argument 1 must be string or buffer, not None! + abort: unknown revision 'ffffffffffff'! [255] Issue622: hg init && hg pull -u URL doesn't checkout default branch