changeset 40081:a4d62ff9a86d

obsolete: fix ValueError when stored note contains ':' char (issue5783) The newer version of `amend -n 'Some some'` accepts containing ':' char. The information contained in this note 'Testing::Obstore' gives ValueError, because we are trying to store more than 2 values in key and value. Differential Revision: https://phab.mercurial-scm.org/D4883 Differential Revision: https://phab.mercurial-scm.org/D4882
author Zharaskhan Aman <aman.zharaskhan@gmail.com>
date Fri, 05 Oct 2018 01:55:51 +0300
parents 56d4f88530fc
children 4fd0fac48922
files mercurial/obsolete.py tests/test-obsolete.t
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Fri Oct 05 16:06:51 2018 -0700
+++ b/mercurial/obsolete.py	Fri Oct 05 01:55:51 2018 +0300
@@ -278,7 +278,7 @@
     d = {}
     for l in data.split('\0'):
         if l:
-            key, value = l.split(':')
+            key, value = l.split(':', 1)
             d[key] = value
     return d
 
--- a/tests/test-obsolete.t	Fri Oct 05 16:06:51 2018 -0700
+++ b/tests/test-obsolete.t	Fri Oct 05 01:55:51 2018 +0300
@@ -1620,3 +1620,22 @@
   
 
   $ cd ..
+
+Test issue 5783
+
+  $ hg init issue-5783 --config format.obsstore-version=0
+  $ cd issue-5783
+  $ touch a.cpp
+  $ hg add a.cpp
+  $ hg commit -m 'Add a.cpp'
+  $ echo 'Hello' > a.cpp
+  $ hg amend -n 'Testing::Obsstore' --config format.obsstore-version=0 --config extensions.amend=
+  $ touch b.cpp
+  $ hg add b.cpp
+  $ hg commit -m 'Add b.cpp'
+  $ echo 'Hello' > b.cpp
+  $ hg amend -n 'Testing::Obsstore2' --config extensions.amend=
+  $ hg debugobsolete
+  d1b09fe3ad2b2a03e23a72f0c582e29a49570145 1a1a11184d2588af24e767e5335d5d9d07e8c550 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'Testing::Obsstore', 'operation': 'amend', 'user': 'test'}
+  1bfd8e3868f641e048b6667cd672c68932f26d00 79959ca316d5b27ac6be1dd0cfd0843a5b5412eb 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'Testing::Obsstore2', 'operation': 'amend', 'user': 'test'}
+  $ cd ..