git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATH 3/4] remote-hg: add version checks to the marks

From
Jed Brown <jed@59a2.org>
Date
Apr 5, 2013, 12:46 UTC
Message-ID
<8738v5qh5v.fsf@59A2.org>
In-Reply-To
<1365161779-32170-4-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 9 quoted lines
> @@ -76,12 +78,19 @@ class Marks:
>  
>      def __init__(self, path):
>          self.path = path
> +        self.clear()
> +        self.load()
> +
> +        if self.version < VERSION:
> +            self.clear()

It's friendlier to just upgrade the marks in-place. This takes less than one second to run on repositories where full re-import would take half an hour:

    def upgrade_marks(self, hgrepo):
        if self.marks_version == 1: # Convert from integer reversions to hgsha1
            warn("Upgrading marks-hg from hg sequence number to SHA1")
            self.marks_to_revisions = dict(
                (mark, hghex(hgrepo.changelog.node(int(rev))))
                for mark, rev in self.marks_to_revisions.iteritems())
            self.revisions_to_marks = dict(
                (hghex(hgrepo.changelog.node(int(rev))), mark)
                for rev, mark in self.revisions_to_marks.iteritems())
            self.marks_version = 2
            warn("Upgrade complete")
https://github.com/buchuki/gitifyhg/commit/23a6709efd14f3e058e3a846624b7677d1e8b497#L0R195
Previous: Felipe ContrerasNext: Felipe Contreras
Message 5 of 7 in “[RFC/PATH 0/4] remoe-hg: switch to SHA-1 ids”
  1. Felipe ContrerasApr 5, 2013
  2. 1/4 remote-hg: shuffle some codeFelipe Contreras, Apr 5, 2013
  3. 2/4 remote-hg: improve node traversingFelipe Contreras, Apr 5, 2013
  4. 3/4 remote-hg: add version checks to the marksFelipe Contreras, Apr 5, 2013
  5. Jed BrownApr 5, 2013
  6. Felipe ContrerasApr 5, 2013
  7. 4/4 remote-hg: switch from revisions to SHA-1 noteidsFelipe Contreras, Apr 5, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.