D7844: nodemap: code to parse a serialized nodemap

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

D7844: nodemap: code to parse a serialized nodemap

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

REVISION SUMMARY
  We now have code to read back what we serialized. This will be put to use in
  later changesets.

REPOSITORY
  rHG Mercurial

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

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
@@ -310,3 +310,33 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse serialized nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    for i in range(0, len(data), S_BLOCK.size):
+        block = _parse_block(block_map, data[i : i + S_BLOCK.size])
+    return block
+
+
+def _parse_block(block_map, block_data):
+    """Parse the serialization of an individual block
+    """
+    block = Block()
+    ondisk_id = len(block_map)
+    block_map[ondisk_id] = block
+    values = S_BLOCK.unpack(block_data)
+    for idx, v in enumerate(values):
+        if v == NO_ENTRY:
+            continue
+        elif v >= 0:
+            block[idx] = block_map[v]
+        else:
+            block[idx] = _transform_rev(v)
+    return block



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
|

D7844: nodemap: code to parse a serialized nodemap

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7844?vs=19181&id=19298

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

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

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
@@ -311,3 +311,33 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse serialized nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    for i in range(0, len(data), S_BLOCK.size):
+        block = _parse_block(block_map, data[i : i + S_BLOCK.size])
+    return block
+
+
+def _parse_block(block_map, block_data):
+    """Parse the serialization of an individual block
+    """
+    block = Block()
+    ondisk_id = len(block_map)
+    block_map[ondisk_id] = block
+    values = S_BLOCK.unpack(block_data)
+    for idx, v in enumerate(values):
+        if v == NO_ENTRY:
+            continue
+        elif v >= 0:
+            block[idx] = block_map[v]
+        else:
+            block[idx] = _transform_rev(v)
+    return block



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
|

D7844: nodemap: code to parse the persistent binary nodemap data

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
marmoute edited the summary of this revision.
marmoute retitled this revision from "nodemap: code to parse a serialized nodemap" to "nodemap: code to parse the persistent binary nodemap data".
marmoute updated this revision to Diff 19760.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7844?vs=19298&id=19760

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

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

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
@@ -308,3 +308,33 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse parse nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    for i in range(0, len(data), S_BLOCK.size):
+        block = _parse_block(block_map, data[i : i + S_BLOCK.size])
+    return block
+
+
+def _parse_block(block_map, block_data):
+    """Parse the persisted version of an individual block
+    """
+    block = Block()
+    ondisk_id = len(block_map)
+    block_map[ondisk_id] = block
+    values = S_BLOCK.unpack(block_data)
+    for idx, v in enumerate(values):
+        if v == NO_ENTRY:
+            continue
+        elif v >= 0:
+            block[idx] = block_map[v]
+        else:
+            block[idx] = _transform_rev(v)
+    return block



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
|

D7844: nodemap: code to parse the persistent binary nodemap data

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7844?vs=19760&id=19789

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

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

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
@@ -309,3 +309,33 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse parse nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    for i in range(0, len(data), S_BLOCK.size):
+        block = _parse_block(block_map, data[i : i + S_BLOCK.size])
+    return block
+
+
+def _parse_block(block_map, block_data):
+    """Parse the persisted version of an individual block
+    """
+    block = Block()
+    ondisk_id = len(block_map)
+    block_map[ondisk_id] = block
+    values = S_BLOCK.unpack(block_data)
+    for idx, v in enumerate(values):
+        if v == NO_ENTRY:
+            continue
+        elif v >= 0:
+            block[idx] = block_map[v]
+        else:
+            block[idx] = _transform_rev(v)
+    return block



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
|

D7844: nodemap: code to parse the persistent binary nodemap data

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


  small doc update on .#s[1]

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7844?vs=19789&id=19833

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

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

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
@@ -310,3 +310,33 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse parse nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    for i in range(0, len(data), S_BLOCK.size):
+        block = _parse_block(block_map, data[i : i + S_BLOCK.size])
+    return block
+
+
+def _parse_block(block_map, block_data):
+    """Parse the persisted version of an individual block
+    """
+    block = Block()
+    ondisk_id = len(block_map)
+    block_map[ondisk_id] = block
+    values = S_BLOCK.unpack(block_data)
+    for idx, v in enumerate(values):
+        if v == NO_ENTRY:
+            continue
+        elif v >= 0:
+            block[idx] = block_map[v]
+        else:
+            block[idx] = _transform_rev(v)
+    return block



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
|

D7844: nodemap: code to parse the persistent binary nodemap data

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


  rebase to latest default

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7844?vs=19833&id=19892

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

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

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
@@ -310,3 +310,30 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse parse nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    new_blocks = []
+    for i in range(0, len(data), S_BLOCK.size):
+        block = Block()
+        ondisk_id = len(block_map)
+        block_map[ondisk_id] = block
+        block_data = data[i : i + S_BLOCK.size]
+        values = S_BLOCK.unpack(block_data)
+        new_blocks.append((block, values))
+    for b, values in new_blocks:
+        for idx, v in enumerate(values):
+            if v == NO_ENTRY:
+                continue
+            elif v >= 0:
+                b[idx] = block_map[v]
+            else:
+                b[idx] = _transform_rev(v)
+    return block



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
|

D7844: nodemap: code to parse the persistent binary nodemap data

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
Closed by commit rHG78721bbdb2ab: nodemap: code to parse the persistent binary nodemap data (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/D7844?vs=19892&id=20112

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

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

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
@@ -310,3 +310,30 @@
         return block_map[id(item)]
     else:
         return _transform_rev(item)
+
+
+def parse_data(data):
+    """parse parse nodemap data into a nodemap Trie"""
+    if (len(data) % S_BLOCK.size) != 0:
+        msg = "nodemap data size is not a multiple of block size (%d): %d"
+        raise error.Abort(msg % (S_BLOCK.size, len(data)))
+    if not data:
+        return Block()
+    block_map = {}
+    new_blocks = []
+    for i in range(0, len(data), S_BLOCK.size):
+        block = Block()
+        ondisk_id = len(block_map)
+        block_map[ondisk_id] = block
+        block_data = data[i : i + S_BLOCK.size]
+        values = S_BLOCK.unpack(block_data)
+        new_blocks.append((block, values))
+    for b, values in new_blocks:
+        for idx, v in enumerate(values):
+            if v == NO_ENTRY:
+                continue
+            elif v >= 0:
+                b[idx] = block_map[v]
+            else:
+                b[idx] = _transform_rev(v)
+    return block



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