D7892: nodemap: never read more than the expected data amount

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

D7892: nodemap: never read more than the expected data amount

martinvonz (Martin von Zweigbergk)
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Since we are tracking this number we can use it to detect corrupted rawdata file
  and to only read the correct amount of data when possible.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -45,7 +45,12 @@
     docket.data_unused = data_unused
 
     filename = _rawdata_filepath(revlog, docket)
-    return docket, revlog.opener.tryread(filename)
+    data = revlog.opener.tryread(filename)
+    if len(data) < data_length:
+        return None
+    elif len(data) > data_length:
+        data = data[:data_length]
+    return docket, data
 
 
 def setup_persistent_nodemap(tr, revlog):



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D7892: nodemap: never read more than the expected data amount

martinvonz (Martin von Zweigbergk)
marmoute updated this revision to Diff 19773.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7892?vs=19310&id=19773

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7892/new/

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -45,7 +45,12 @@
     docket.data_unused = data_unused
 
     filename = _rawdata_filepath(revlog, docket)
-    return docket, revlog.opener.tryread(filename)
+    data = revlog.opener.tryread(filename)
+    if len(data) < data_length:
+        return None
+    elif len(data) > data_length:
+        data = data[:data_length]
+    return docket, data
 
 
 def setup_persistent_nodemap(tr, revlog):



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D7892: nodemap: never read more than the expected data amount

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
marmoute updated this revision to Diff 19800.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7892?vs=19773&id=19800

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7892/new/

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -45,7 +45,12 @@
     docket.data_unused = data_unused
 
     filename = _rawdata_filepath(revlog, docket)
-    return docket, revlog.opener.tryread(filename)
+    data = revlog.opener.tryread(filename)
+    if len(data) < data_length:
+        return None
+    elif len(data) > data_length:
+        data = data[:data_length]
+    return docket, data
 
 
 def setup_persistent_nodemap(tr, revlog):



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D7892: nodemap: never read more than the expected data amount

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
marmoute added a comment.
marmoute updated this revision to Diff 19844.


  small doc update on .#s[1]

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7892?vs=19800&id=19844

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7892/new/

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -45,7 +45,12 @@
     docket.data_unused = data_unused
 
     filename = _rawdata_filepath(revlog, docket)
-    return docket, revlog.opener.tryread(filename)
+    data = revlog.opener.tryread(filename)
+    if len(data) < data_length:
+        return None
+    elif len(data) > data_length:
+        data = data[:data_length]
+    return docket, data
 
 
 def setup_persistent_nodemap(tr, revlog):



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D7892: nodemap: never read more than the expected data amount

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
marmoute added a comment.
marmoute updated this revision to Diff 19904.


  rebase to latest default

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7892?vs=19844&id=19904

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7892/new/

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -45,7 +45,12 @@
     docket.data_unused = data_unused
 
     filename = _rawdata_filepath(revlog, docket)
-    return docket, revlog.opener.tryread(filename)
+    data = revlog.opener.tryread(filename)
+    if len(data) < data_length:
+        return None
+    elif len(data) > data_length:
+        data = data[:data_length]
+    return docket, data
 
 
 def setup_persistent_nodemap(tr, revlog):



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D7892: nodemap: never read more than the expected data amount

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
Closed by commit rHGc7eebdb15139: nodemap: never read more than the expected data amount (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7892?vs=19904&id=20125

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7892/new/

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -45,7 +45,12 @@
     docket.data_unused = data_unused
 
     filename = _rawdata_filepath(revlog, docket)
-    return docket, revlog.opener.tryread(filename)
+    data = revlog.opener.tryread(filename)
+    if len(data) < data_length:
+        return None
+    elif len(data) > data_length:
+        data = data[:data_length]
+    return docket, data
 
 
 def setup_persistent_nodemap(tr, revlog):



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel