
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import six

from asv import config
from asv import repo


def test_repo(tmpdir):
    conf = config.Config()

    conf.project = six.text_type(tmpdir.join("repo"))
    conf.repo = "https://github.com/spacetelescope/asv.git"

    r = repo.get_repo(conf)
    r.checkout("master")
    r.checkout("gh-pages")
    r.checkout("master")

    hashes = r.get_hashes_from_range("ae0c27b65741..e6f382a704f7")
    assert len(hashes) == 4

    dates = [r.get_date(hash) for hash in hashes]
    assert dates == sorted(dates)[::-1]

    tags = r.get_tags()
    for tag in tags:
        r.get_date_from_tag(tag)


from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import six

from asv import config
from asv import repo


def _test_generic_repo(conf,
                       hash_range="ae0c27b65741..e6f382a704f7",
                       master="master",
                       branch="gh-pages"):

    r = repo.get_repo(conf)
    r.checkout(master)
    r.checkout(branch)
    r.checkout(master)

    hashes = r.get_hashes_from_range(hash_range)
    assert len(hashes) == 4

    dates = [r.get_date(hash) for hash in hashes]
    assert dates == sorted(dates)[::-1]

    tags = r.get_tags()
    for tag in tags:
        r.get_date_from_tag(tag)


def test_repo_git(tmpdir):
    conf = config.Config()

    conf.project = six.text_type(tmpdir.join("repo"))
    conf.repo = "https://github.com/spacetelescope/asv.git"
    _test_generic_repo(conf)


def test_repo_hg(tmpdir):
    conf = config.Config()

    conf.project = six.text_type(tmpdir.join("repo"))
    conf.repo = "hg+https://bitbucket.org/nds-org/nds-labs"
    _test_generic_repo(conf, hash_range="a8ca24ac6b77:9dc758deba8",
                       master="tip", branch="dev")

Add test for mercurial repo
Add test for mercurial repo

  
  from __future__ import (absolute_import, division, print_function,
                          unicode_literals)
  
  import six
  
  from asv import config
  from asv import repo
  
  
+ def _test_generic_repo(conf,
+                        hash_range="ae0c27b65741..e6f382a704f7",
+                        master="master",
+                        branch="gh-pages"):
- def test_repo(tmpdir):
-     conf = config.Config()
- 
-     conf.project = six.text_type(tmpdir.join("repo"))
-     conf.repo = "https://github.com/spacetelescope/asv.git"
  
      r = repo.get_repo(conf)
-     r.checkout("master")
+     r.checkout(master)
-     r.checkout("gh-pages")
+     r.checkout(branch)
-     r.checkout("master")
+     r.checkout(master)
  
-     hashes = r.get_hashes_from_range("ae0c27b65741..e6f382a704f7")
+     hashes = r.get_hashes_from_range(hash_range)
      assert len(hashes) == 4
  
      dates = [r.get_date(hash) for hash in hashes]
      assert dates == sorted(dates)[::-1]
  
      tags = r.get_tags()
      for tag in tags:
          r.get_date_from_tag(tag)
  
+ 
+ def test_repo_git(tmpdir):
+     conf = config.Config()
+ 
+     conf.project = six.text_type(tmpdir.join("repo"))
+     conf.repo = "https://github.com/spacetelescope/asv.git"
+     _test_generic_repo(conf)
+ 
+ 
+ def test_repo_hg(tmpdir):
+     conf = config.Config()
+ 
+     conf.project = six.text_type(tmpdir.join("repo"))
+     conf.repo = "hg+https://bitbucket.org/nds-org/nds-labs"
+     _test_generic_repo(conf, hash_range="a8ca24ac6b77:9dc758deba8",
+                        master="tip", branch="dev")
+ 
Add test for mercurial repo
## Code Before:

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import six

from asv import config
from asv import repo


def test_repo(tmpdir):
    conf = config.Config()

    conf.project = six.text_type(tmpdir.join("repo"))
    conf.repo = "https://github.com/spacetelescope/asv.git"

    r = repo.get_repo(conf)
    r.checkout("master")
    r.checkout("gh-pages")
    r.checkout("master")

    hashes = r.get_hashes_from_range("ae0c27b65741..e6f382a704f7")
    assert len(hashes) == 4

    dates = [r.get_date(hash) for hash in hashes]
    assert dates == sorted(dates)[::-1]

    tags = r.get_tags()
    for tag in tags:
        r.get_date_from_tag(tag)

## Instruction:
Add test for mercurial repo
## Code After:

from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

import six

from asv import config
from asv import repo


def _test_generic_repo(conf,
                       hash_range="ae0c27b65741..e6f382a704f7",
                       master="master",
                       branch="gh-pages"):

    r = repo.get_repo(conf)
    r.checkout(master)
    r.checkout(branch)
    r.checkout(master)

    hashes = r.get_hashes_from_range(hash_range)
    assert len(hashes) == 4

    dates = [r.get_date(hash) for hash in hashes]
    assert dates == sorted(dates)[::-1]

    tags = r.get_tags()
    for tag in tags:
        r.get_date_from_tag(tag)


def test_repo_git(tmpdir):
    conf = config.Config()

    conf.project = six.text_type(tmpdir.join("repo"))
    conf.repo = "https://github.com/spacetelescope/asv.git"
    _test_generic_repo(conf)


def test_repo_hg(tmpdir):
    conf = config.Config()

    conf.project = six.text_type(tmpdir.join("repo"))
    conf.repo = "hg+https://bitbucket.org/nds-org/nds-labs"
    _test_generic_repo(conf, hash_range="a8ca24ac6b77:9dc758deba8",
                       master="tip", branch="dev")
