Patchwork D3946: obsolete: resolved ValueError for var containing 2 ':' chars(issue-5783)

login
register
mail settings
Submitter phabricator
Date July 14, 2018, 6:43 p.m.
Message ID <differential-rev-PHID-DREV-oikovjrrqnqafbgflwxp-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32848/
State New
Headers show

Comments

phabricator - July 14, 2018, 6:43 p.m.
abhyudaypratap created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  feature Note accepts ':' chars
  So metadata of obsmarker consists of more then 1 ':' char,
  The content of the variable 'data' in this function is:
  'date:1518013344.878793 -3600\x00ef1:0\x00note:6c95ca::a1e17f\x00p1:ed7673f73387b36521da58a87f08e02e4a795ded\x00user:Denis Laxalde <xxx@yyy.zz>'
  
  resulting in giving a error ValueError (too many values to unpack) because we are trying to store multiple values into two variables key and value
  
  Resolving this error by splitting the variable 'l' from the first occurence of ':'
  key, value = l.split("", 1)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3946

AFFECTED FILES
  mercurial/obsolete.py

CHANGE DETAILS




To: abhyudaypratap, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - July 15, 2018, 1:26 p.m.
Looks good. Can you add a test?

https://www.mercurial-scm.org/wiki/ContributingChanges#Coding_style_and_testing

The version 0 format can be enforced by `--config format.obsstore-version=0`.
phabricator - July 15, 2018, 1:27 p.m.
yuja added a comment.


  Looks good. Can you add a test?
  
  https://www.mercurial-scm.org/wiki/ContributingChanges#Coding_style_and_testing
  
  The version 0 format can be enforced by `--config format.obsstore-version=0`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3946

To: abhyudaypratap, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -275,7 +275,7 @@ 
     d = {}
     for l in data.split('\0'):
         if l:
-            key, value = l.split(':')
+            key, value = l.split(':', 1)
             d[key] = value
     return d