stop the addition of the branch name in the #egg=... fragment

This commit is contained in:
Stéphane Bidoul 2015-12-18 22:48:12 +01:00
parent 623bc75f94
commit 6f790d1d80
7 changed files with 18 additions and 82 deletions

View File

@ -110,6 +110,9 @@
* Improve message when an unexisting path is passed to --find-links option
(:issue:`2968`).
* pip freeze does not add the VCS branch/tag name in the #egg=... fragment anymore
(:pull:`3312`).
* Warn on installation of editable if the provided #egg=name part does not
match the metadata produced by `setup.py egg_info`. :issue:`3143`.

View File

@ -119,14 +119,7 @@ class Bazaar(VersionControl):
repo = 'bzr+' + repo
egg_project_name = dist.egg_name().split('-', 1)[0]
current_rev = self.get_revision(location)
tag_revs = self.get_tag_revs(location)
if current_rev in tag_revs:
# It's a tag
full_egg_name = '%s-%s' % (egg_project_name, tag_revs[current_rev])
else:
full_egg_name = '%s-dev_r%s' % (dist.egg_name(), current_rev)
return '%s@%s#egg=%s' % (repo, current_rev, full_egg_name)
return '%s@%s#egg=%s' % (repo, current_rev, egg_project_name)
def check_version(self, dest, rev_options):
"""Always assume the versions don't match"""

View File

@ -223,25 +223,7 @@ class Git(VersionControl):
if not repo:
return None
current_rev = self.get_revision(location)
refs = self.get_short_refs(location)
# refs maps names to commit hashes; we need the inverse
# if multiple names map to a single commit, we pick the first one
# alphabetically
names_by_commit = {}
for ref, commit in sorted(refs.items()):
if commit not in names_by_commit:
names_by_commit[commit] = ref
if current_rev in names_by_commit:
# It's a tag or branch.
name = names_by_commit[current_rev]
full_egg_name = (
'%s-%s' % (egg_project_name, self.translate_egg_surname(name))
)
else:
full_egg_name = '%s-dev' % egg_project_name
req = '%s@%s#egg=%s' % (repo, current_rev, full_egg_name)
req = '%s@%s#egg=%s' % (repo, current_rev, egg_project_name)
subdirectory = self._get_subdirectory(location)
if subdirectory:
req += '&subdirectory=' + subdirectory

View File

@ -119,22 +119,8 @@ class Mercurial(VersionControl):
egg_project_name = dist.egg_name().split('-', 1)[0]
if not repo:
return None
current_rev = self.get_revision(location)
current_rev_hash = self.get_revision_hash(location)
tag_revs = self.get_tag_revs(location)
branch_revs = self.get_branch_revs(location)
if current_rev in tag_revs:
# It's a tag
full_egg_name = '%s-%s' % (egg_project_name, tag_revs[current_rev])
elif current_rev in branch_revs:
# It's the tip of a branch
full_egg_name = '%s-%s' % (
egg_project_name,
branch_revs[current_rev],
)
else:
full_egg_name = '%s-dev' % egg_project_name
return '%s@%s#egg=%s' % (repo, current_rev_hash, full_egg_name)
return '%s@%s#egg=%s' % (repo, current_rev_hash, egg_project_name)
def check_version(self, dest, rev_options):
"""Always assume the versions don't match"""

View File

@ -234,35 +234,7 @@ class Subversion(VersionControl):
# FIXME: why not project name?
egg_project_name = dist.egg_name().split('-', 1)[0]
rev = self.get_revision(location)
if parts[-2] in ('tags', 'tag'):
# It's a tag, perfect!
full_egg_name = '%s-%s' % (egg_project_name, parts[-1])
elif parts[-2] in ('branches', 'branch'):
# It's a branch :(
full_egg_name = '%s-%s-r%s' % (dist.egg_name(), parts[-1], rev)
elif parts[-1] == 'trunk':
# Trunk :-/
full_egg_name = '%s-dev_r%s' % (dist.egg_name(), rev)
if find_tags:
tag_url = '/'.join(parts[:-1]) + '/tags'
tag_revs = self.get_tag_revs(tag_url)
match = self.find_tag_match(rev, tag_revs)
if match:
logger.info(
'trunk checkout %s seems to be equivalent to tag %s',
match,
)
repo = '%s/%s' % (tag_url, match)
full_egg_name = '%s-%s' % (egg_project_name, match)
else:
# Don't know what it is
logger.warning(
'svn URL does not fit normal structure (tags/branches/trunk): '
'%s',
repo,
)
full_egg_name = '%s-dev_r%s' % (egg_project_name, rev)
return 'svn+%s@%s#egg=%s' % (repo, rev, full_egg_name)
return 'svn+%s@%s#egg=%s' % (repo, rev, egg_project_name)
def check_version(self, dest, rev_options):
"""Always assume the versions don't match"""

View File

@ -76,7 +76,7 @@ def test_freeze_svn(script, tmpdir):
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
...-e svn+...#egg=version_pkg-0.1-...
...-e svn+...#egg=version_pkg
...""")
_check_output(result.stdout, expected)
@ -102,7 +102,7 @@ def test_freeze_git_clone(script, tmpdir):
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e git+...#egg=version_pkg-master
...-e git+...#egg=version_pkg
...
"""
).strip()
@ -115,7 +115,7 @@ def test_freeze_git_clone(script, tmpdir):
expected = textwrap.dedent(
"""
-f %(repo)s#egg=pip_test_package...
-e git+...#egg=version_pkg-master
-e git+...#egg=version_pkg
...
""" % {'repo': repo_dir},
).strip()
@ -137,7 +137,7 @@ def test_freeze_git_clone(script, tmpdir):
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e ...@...#egg=version_pkg-branch_name_with_slash...
...-e ...@...#egg=version_pkg
...
"""
).strip()
@ -167,7 +167,7 @@ def test_freeze_git_clone_srcdir(script, tmpdir):
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e git+...#egg=version_pkg-master&subdirectory=subdir
...-e git+...#egg=version_pkg&subdirectory=subdir
...
"""
).strip()
@ -180,7 +180,7 @@ def test_freeze_git_clone_srcdir(script, tmpdir):
expected = textwrap.dedent(
"""
-f %(repo)s#egg=pip_test_package...
-e git+...#egg=version_pkg-master&subdirectory=subdir
-e git+...#egg=version_pkg&subdirectory=subdir
...
""" % {'repo': repo_dir},
).strip()
@ -209,7 +209,7 @@ def test_freeze_mercurial_clone(script, tmpdir):
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e hg+...#egg=version_pkg-dev
...-e hg+...#egg=version_pkg
...
"""
).strip()
@ -222,7 +222,7 @@ def test_freeze_mercurial_clone(script, tmpdir):
expected = textwrap.dedent(
"""
-f %(repo)s#egg=pip_test_package...
...-e hg+...#egg=version_pkg-dev
...-e hg+...#egg=version_pkg
...
""" % {'repo': repo_dir},
).strip()
@ -250,7 +250,7 @@ def test_freeze_bazaar_clone(script, tmpdir):
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent("""\
...-e bzr+file://...@1#egg=version_pkg-0.1-...
...-e bzr+file://...@1#egg=version_pkg
...""")
_check_output(result.stdout, expected)
@ -261,7 +261,7 @@ def test_freeze_bazaar_clone(script, tmpdir):
)
expected = textwrap.dedent("""\
-f %(repo)s/#egg=django-wikiapp
...-e bzr+file://...@...#egg=version_pkg-...
...-e bzr+file://...@...#egg=version_pkg
...""" % {'repo': checkout_path})
_check_output(result.stdout, expected)

View File

@ -46,7 +46,7 @@ def test_git_get_src_requirements(git, dist):
assert ret == ''.join([
'git+http://github.com/pypa/pip-test-package',
'@5547fa909e83df8bd743d3978d6667497983a4b7',
'#egg=pip_test_package-bar'
'#egg=pip_test_package'
])