D2855: graft: add a version number to the state file formats

2018-06-14 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added a comment.


  In https://phab.mercurial-scm.org/D2855#47833, @yuja wrote:
  
  > Perhaps the version shouldn't be in the CBOR data structure, because future
  >  state file might not be a superset of CBOR.
  
  
  That was a very nice suggestion. Thanks!
  
  Abandoning since it's not required anymore because now by default, 
state.cmdstate() write version numbers in plain text.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2855: graft: add a version number to the state file formats

2018-03-27 Thread yuja (Yuya Nishihara)
yuja added a comment.


  Perhaps the version shouldn't be in the CBOR data structure, because future
  state file might not be a superset of CBOR.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2855: graft: add a version number to the state file formats

2018-03-26 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 7304.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2855?vs=7108&id=7304

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2187,8 +2187,13 @@
 # read in unfinished revisions
 if cmdstate:
 cmdstate.load()
-nodes = cmdstate['nodes']
-revs = [repo[node].rev() for node in nodes]
+if cmdstate['version'] < 2:
+nodes = cmdstate['nodes']
+revs = [repo[node].rev() for node in nodes]
+else:
+# state-file is written by a newer mercurial than what we are
+# using
+raise error.Abort(_("unable to read to read the state file"))
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
 else:
@@ -2315,7 +2320,7 @@
 if stats.unresolvedcount > 0:
 # write out state for --continue
 nodelines = [repo[rev].hex() for rev in revs[pos:]]
-cmdstate.addopts({'nodes': nodelines})
+cmdstate.addopts({'version': 1, 'nodes': nodelines})
 cmdstate.save()
 extra = ''
 if opts.get('user'):
@@ -2348,7 +2353,7 @@
 @statemod.readoldstatefile('graftstate')
 def _oldgraftstate(fp):
 nodes = fp.read().splitlines()
-return {'nodes': nodes}
+return {'version': 0, 'nodes': nodes}
 
 @command('grep',
 [('0', 'print0', None, _('end fields with NUL')),



To: pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2855: graft: add a version number to the state file formats

2018-03-19 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 7108.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2855?vs=7024&id=7108

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -117,4 +117,4 @@
 @readoldstatefile('graftstate')
 def oldgraftstate(fp):
 nodes = fp.read().splitlines()
-return {'nodes': nodes}
+return {'version': 0, 'nodes': nodes}
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2183,8 +2183,13 @@
 # read in unfinished revisions
 if cmdstate:
 cmdstate.load()
-nodes = cmdstate['nodes']
-revs = [repo[node].rev() for node in nodes]
+if cmdstate['version'] < 2:
+nodes = cmdstate['nodes']
+revs = [repo[node].rev() for node in nodes]
+else:
+# state-file is written by a newer mercurial than what we are
+# using
+raise error.Abort(_("unable to read to read the state file"))
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
 else:
@@ -2311,7 +2316,7 @@
 if stats[3] > 0:
 # write out state for --continue
 nodelines = [repo[rev].hex() for rev in revs[pos:]]
-cmdstate.addopts({'nodes': nodelines})
+cmdstate.addopts({'version': 1, 'nodes': nodelines})
 cmdstate.save()
 extra = ''
 if opts.get('user'):



To: pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2855: graft: add a version number to the state file formats

2018-03-14 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Adding version number to state file formats can help us in preventing an older
  mercurial try to read a newer graft state file which can cause issues.
  Moreover, the version numbers can help in lot of other ways also.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -117,4 +117,4 @@
 @readoldstatefile('graftstate')
 def oldgraftstate(fp):
 nodes = fp.read().splitlines()
-return {'nodes': nodes}
+return {'version': 0, 'nodes': nodes}
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2177,8 +2177,13 @@
 # read in unfinished revisions
 if cmdstate:
 cmdstate.load()
-nodes = cmdstate['nodes']
-revs = [repo[node].rev() for node in nodes]
+if cmdstate['version'] < 2:
+nodes = cmdstate['nodes']
+revs = [repo[node].rev() for node in nodes]
+else:
+# state-file is written by a newer mercurial than what we are
+# using
+raise error.Abort(_("unable to read to read the state file"))
 else:
 cmdutil.wrongtooltocontinue(repo, _('graft'))
 else:
@@ -2305,7 +2310,7 @@
 if stats and stats[3] > 0:
 # write out state for --continue
 nodelines = [repo[rev].hex() for rev in revs[pos:]]
-cmdstate.addopts({'nodes': nodelines})
+cmdstate.addopts({'version': 1, 'nodes': nodelines})
 cmdstate.save()
 extra = ''
 if opts.get('user'):



To: pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel