Repository: readthedocs/readthedocs.org

Issue:
mercurial project imported from bitbucket stuck in 'Triggered' state
The docs for pylibftdi are set to be built (via a POST trigger) from https://bitbucket.org/codedstructure/pylibftdi, but builds (https://readthedocs.org/builds/pylibftdi/) are stuck at 'Triggered'.

Based on comments in #435 I set the project up to build against a github mirror, and that worked successfully, so it seems (from #435) that this is likely an hg issue.



Discussion:
Looks like this is the error:

```
[19/Nov/2013 14:22:49] INFO [vcs_support.base:56] VCS[pylibftdi:latest]: hg tags
[19/Nov/2013 14:22:49] INFO [vcs_support.base:60] VCS[pylibftdi:latest]: tip                              104:b74c82a64dc6
0.13                             102:ff24d3de9a39
0.12                              89:88b7b7113d5b
0.11                              76:b971b80a8607
0.10.3                            65:7e5e09196069
0.10.2                            58:8c6471bb5e78
0.10.1                            56:9beeef69cefd
0.10                              46:36ede894aa9c
release 0.9                       30:496541913263
release 0.8                       19:68d432f9a4cd
release 0.7                       17:bce2b77265b7

[19/Nov/2013 14:22:49] INFO [vcs_support.utils:42] Lock (pylibftdi): Releasing
[19/Nov/2013 14:22:49] ERROR [celery.worker.job:246] Task projects.tasks.update_docs[00f5c839-af52-46f1-9cba-7040c68f48c7] raised exception: ValueError('too many values to unpack',)
Traceback (most recent call last):
  File "/home/docs/local/lib/python2.7/site-packages/celery/task/trace.py", line 233, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/docs/local/lib/python2.7/site-packages/celery/task/trace.py", line 420, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/docs/checkouts/readthedocs.org/readthedocs/doc_builder/base.py", line 14, in decorator
    return fn(*args, **kw)
  File "/home/docs/checkouts/readthedocs.org/readthedocs/projects/tasks.py", line 142, in update_docs
    update_output = update_imported_docs(version.pk, api)
  File "/home/docs/local/lib/python2.7/site-packages/celery/task/trace.py", line 421, in __protected_call__
    return orig(self, *args, **kwargs)
  File "/home/docs/local/lib/python2.7/site-packages/celery/app/task.py", line 329, in __call__
    return self.run(*args, **kwargs)
  File "/home/docs/checkouts/readthedocs.org/readthedocs/projects/tasks.py", line 450, in update_imported_docs
    } for v in version_repo.tags
  File "/home/docs/checkouts/readthedocs.org/readthedocs/vcs_support/backends/hg.py", line 68, in tags
    return self.parse_tags(stdout)
  File "/home/docs/checkouts/readthedocs.org/readthedocs/vcs_support/backends/hg.py", line 86, in parse_tags
    name, commit = row
ValueError: too many values to unpack
```

https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/vcs_support/backends/hg.py#L80

Looks like we aren't expecting spaces in tags.

Yep, was just about to comment that very thing ;-)

So it's sort of my fault for having bad tag names earlier on, but at least it exposed a problem.

https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/vcs_support/backends/hg.py#L80

Looks like we aren't expecting spaces in tags.

On Tue, Nov 19, 2013 at 1:02 PM, Ben Bass notifications@github.com wrote:

> The docs for pylibftdi are set to be built (via a POST trigger) from
> https://bitbucket.org/codedstructure/pylibftdi, but builds (
> https://readthedocs.org/builds/pylibftdi/) are stuck at 'Triggered'.
> 
> Based on comments in #435https://github.com/rtfd/readthedocs.org/issues/435I set the project up to build against a github mirror, and that worked
> successfully, so it seems (from #435https://github.com/rtfd/readthedocs.org/issues/435)
> that this is likely an hg issue.
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/rtfd/readthedocs.org/issues/547
> .

## 

Eric Holscher
Maker of the internet residing in Portland, Or
http://ericholscher.com


Resolving patch:
diff --git a/readthedocs/vcs_support/backends/hg.py b/readthedocs/vcs_support/backends/hg.py
--- a/readthedocs/vcs_support/backends/hg.py
+++ b/readthedocs/vcs_support/backends/hg.py
@@ -1,6 +1,3 @@
-import csv
-from StringIO import StringIO
-
 from projects.exceptions import ProjectImportError
 from vcs_support.base import BaseVCS, VCSVersion
 
@@ -69,19 +66,24 @@ def tags(self):
 
     def parse_tags(self, data):
         """
-        Parses output of show-ref --tags, eg:
+        Parses output of `hg tags`, eg:
+
+            tip                              278:c4b2d21db51a
+            0.2.2                            152:6b0364d98837
+            0.2.1                            117:a14b7b6ffa03
+            0.1                               50:30c2c6b3a055
+            maintenance release 1             10:f83c32fe8126
 
-        tip                              278:c4b2d21db51a
-        0.2.2                            152:6b0364d98837
-        0.2.1                            117:a14b7b6ffa03
-        0.1                               50:30c2c6b3a055
+        Into VCSVersion objects with the tag name as verbose_name and the
+        commit hash as identifier.
         """
-        # parse the lines into a list of tuples (commit-hash, tag ref name)
-        raw_tags = csv.reader(StringIO(data), delimiter=' ')
         vcs_tags = []
-        for row in raw_tags:
-            row = filter(lambda f: f != '', row)
-            if row == []:
+        tag_lines = [line.strip() for line in data.splitlines()]
+        # starting from the rhs of each line, split a single value (changeset)
+        # off at whitespace; the tag name is the string to the left of that
+        tag_pairs = [line.rsplit(None, 1) for line in tag_lines]
+        for row in tag_pairs:
+            if len(row) != 2:
                 continue
             name, commit = row
             if name == 'tip':


Test patch: