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

Re: [PATCH] remote-hg: support for notes

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 29, 2013, 22:12 UTC
Message-ID
<xmqqzjs016zx.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1377813000-24465-1-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
I somehow find this way under-explained to be useful for its users.

Is it clear what "support for notes" means in the context of remote-hg? Do we send data stored in our notes when we push back to Hg? Does Hg have a mechanism to store additional data out of band, and we add notes when we pull from Hg? Or does this "support" do something else, and if so what does it do?

Show 88 quoted lines
>  contrib/remote-helpers/git-remote-hg | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
> index 307d82c..e49fcfa 100755
> --- a/contrib/remote-helpers/git-remote-hg
> +++ b/contrib/remote-helpers/git-remote-hg
> @@ -23,6 +23,7 @@ import subprocess
>  import urllib
>  import atexit
>  import urlparse, hashlib
> +import time as ptime
>  
>  #
>  # If you are not in hg-git-compat mode and want to disable the tracking of
> @@ -126,6 +127,7 @@ class Marks:
>          self.rev_marks = {}
>          self.last_mark = 0
>          self.version = 0
> +        self.last_note = 0
>  
>      def load(self):
>          if not os.path.exists(self.path):
> @@ -137,6 +139,7 @@ class Marks:
>          self.marks = tmp['marks']
>          self.last_mark = tmp['last-mark']
>          self.version = tmp.get('version', 1)
> +        self.last_note = tmp.get('last-note', 0)
>  
>          for rev, mark in self.marks.iteritems():
>              self.rev_marks[mark] = rev
> @@ -150,7 +153,7 @@ class Marks:
>          self.version = 2
>  
>      def dict(self):
> -        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
> +        return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
>  
>      def store(self):
>          json.dump(self.dict(), open(self.path, 'w'))
> @@ -525,6 +528,31 @@ def export_ref(repo, name, kind, head):
>      print "from :%u" % rev_to_mark(head)
>      print
>  
> +    pending_revs = set(revs) - notes
> +    if pending_revs:
> +        note_mark = marks.next_mark()
> +        ref = "refs/notes/hg"
> +
> +        print "commit %s" % ref
> +        print "mark :%d" % (note_mark)
> +        print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
> +        desc = "Notes for %s\n" % (name)
> +        print "data %d" % (len(desc))
> +        print desc
> +        if marks.last_note:
> +            print "from :%u" % marks.last_note
> +
> +        for rev in pending_revs:
> +            notes.add(rev)
> +            c = repo[rev]
> +            print "N inline :%u" % rev_to_mark(c)
> +            msg = c.hex()
> +            print "data %d" % (len(msg))
> +            print msg
> +        print
> +
> +        marks.last_note = note_mark
> +
>      marks.set_tip(ename, head.hex())
>  
>  def export_tag(repo, tag):
> @@ -1126,6 +1154,7 @@ def main(args):
>      global filenodes
>      global fake_bmark, hg_version
>      global dry_run
> +    global notes, alias
>  
>      alias = args[1]
>      url = args[2]
> @@ -1165,6 +1194,7 @@ def main(args):
>      except:
>          hg_version = None
>      dry_run = False
> +    notes = set()
>  
>      repo = get_repo(url, alias)
>      prefix = 'refs/hg/%s' % alias
Previous: Felipe ContrerasNext: Felipe Contreras
Message 30 of 32 in “remote-{hg,bzr}: updates”
  1. 0/8 remote-{hg,bzr}: updatesFelipe Contreras, Aug 28, 2013
  2. 1/8 remote-bzr: fix export of utf-8 authorsFelipe Contreras, Aug 28, 2013
  3. Matthieu MoyAug 28, 2013
  4. Felipe ContrerasAug 28, 2013
  5. Antoine PelisseAug 28, 2013
  6. Felipe ContrerasAug 28, 2013
  7. Felipe ContrerasAug 28, 2013
  8. Matthieu MoyAug 28, 2013
  9. Felipe ContrerasAug 28, 2013
  10. Junio C HamanoAug 28, 2013
  11. Felipe ContrerasAug 28, 2013
  12. Re* [PATCH 1/8] remote-bzr: fix export of utf-8 authorsJunio C Hamano, Aug 29, 2013
  13. Junio C HamanoAug 29, 2013
  14. Michael HaggertySep 1, 2013
  15. Antoine PelisseAug 29, 2013
  16. Junio C HamanoAug 29, 2013
  17. Junio C HamanoAug 29, 2013
  18. Michael HaggertySep 1, 2013
  19. Eric SunshineAug 28, 2013
  20. remote-bzr: fix export of utf-8 authorsFelipe Contreras, Aug 28, 2013
  21. 2/8 remote-bzr: make bzr branches configurable per-repoFelipe Contreras, Aug 28, 2013
  22. 3/8 remote-hg: fix testFelipe Contreras, Aug 28, 2013
  23. 4/8 remote-hg: add missing &&s in the testFelipe Contreras, Aug 28, 2013
  24. 5/8 remote-hg: improve basic testFelipe Contreras, Aug 28, 2013
  25. 6/8 remote-helpers: trivial style fixesFelipe Contreras, Aug 28, 2013
  26. 7/8 remote-helpers: cleanup more global variablesFelipe Contreras, Aug 28, 2013
  27. 8/8 remote-hg: support for notesFelipe Contreras, Aug 28, 2013
  28. Junio C HamanoAug 29, 2013
  29. remote-hg: support for notesFelipe Contreras, Aug 29, 2013
  30. Junio C HamanoAug 29, 2013
  31. remote-hg: support for notesFelipe Contreras, Aug 29, 2013
  32. Junio C HamanoAug 29, 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.