git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Simon Ruderich <simon@ruderich.org>
Subject: Re: [PATCH 15/16] remote-hg: use marks instead of inlined files
Date: Mon, 22 Apr 2013 15:33:17 -0700	[thread overview]
Message-ID: <7v1ua2nqky.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1366667724-567-16-git-send-email-felipe.contreras@gmail.com> (Felipe Contreras's message of "Mon, 22 Apr 2013 16:55:23 -0500")

Felipe Contreras <felipe.contreras@gmail.com> writes:

> So that we can find already exported ones. We can never be 100% sure
> that we already exported such data, due to mercurial design, it at least
> sometimes we should detect them, and so should give ups some performance

s/ups/us/ (will locally tweak).

> boost.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/remote-helpers/git-remote-hg | 41 +++++++++++++++++++++++++++++-------
>  1 file changed, 33 insertions(+), 8 deletions(-)
>
> diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
> index f80236b..d0e552c 100755
> --- a/contrib/remote-helpers/git-remote-hg
> +++ b/contrib/remote-helpers/git-remote-hg
> @@ -126,6 +126,10 @@ class Marks:
>      def to_rev(self, mark):
>          return self.rev_marks[mark]
>  
> +    def next_mark(self):
> +        self.last_mark += 1
> +        return self.last_mark
> +
>      def get_mark(self, rev):
>          self.last_mark += 1
>          self.marks[str(rev)] = self.last_mark
> @@ -218,12 +222,29 @@ def fix_file_path(path):
>          return path
>      return os.path.relpath(path, '/')
>  
> -def export_file(fc):
> -    d = fc.data()
> -    path = fix_file_path(fc.path())
> -    print "M %s inline %s" % (gitmode(fc.flags()), path)
> -    print "data %d" % len(d)
> -    print d
> +def export_files(files):
> +    global marks, filenodes
> +
> +    final = []
> +    for f in files:
> +        fid = node.hex(f.filenode())
> +
> +        if fid in filenodes:
> +            mark = filenodes[fid]
> +        else:
> +            mark = marks.next_mark()
> +            filenodes[fid] = mark
> +            d = f.data()
> +
> +            print "blob"
> +            print "mark :%u" % mark
> +            print "data %d" % len(d)
> +            print d
> +
> +        path = fix_file_path(f.path())
> +        final.append((gitmode(f.flags()), mark, path))
> +
> +    return final
>  
>  def get_filechanges(repo, ctx, parent):
>      modified = set()
> @@ -413,6 +434,8 @@ def export_ref(repo, name, kind, head):
>          if len(parents) == 0 and rev:
>              print 'reset %s/%s' % (prefix, ename)
>  
> +        modified_final = export_files(c.filectx(f) for f in modified)
> +
>          print "commit %s/%s" % (prefix, ename)
>          print "mark :%d" % (marks.get_mark(rev))
>          print "author %s" % (author)
> @@ -425,8 +448,8 @@ def export_ref(repo, name, kind, head):
>              if len(parents) > 1:
>                  print "merge :%s" % (rev_to_mark(parents[1]))
>  
> -        for f in modified:
> -            export_file(c.filectx(f))
> +        for f in modified_final:
> +            print "M %s :%u %s" % f
>          for f in removed:
>              print "D %s" % (fix_file_path(f))
>          print
> @@ -878,6 +901,7 @@ def main(args):
>      global peer, mode, bad_mail, bad_name
>      global track_branches, force_push, is_tmp
>      global parsed_tags
> +    global filenodes
>  
>      alias = args[1]
>      url = args[2]
> @@ -921,6 +945,7 @@ def main(args):
>      parsed_refs = {}
>      marks = None
>      parsed_tags = {}
> +    filenodes = {}
>  
>      repo = get_repo(url, alias)
>      prefix = 'refs/hg/%s' % alias

  reply	other threads:[~2013-04-22 22:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 21:55 [PATCH 00/16] remote-hg: second round of improvements Felipe Contreras
2013-04-22 21:55 ` [PATCH 01/16] remote-helpers: avoid has_key Felipe Contreras
2013-04-22 22:28   ` Junio C Hamano
2013-04-22 22:35     ` Felipe Contreras
2013-04-22 22:51       ` Dusty Phillips
2013-04-22 21:55 ` [PATCH 02/16] remote-hg: safer bookmark pushing Felipe Contreras
2013-04-22 21:55 ` [PATCH 03/16] remote-hg: use python urlparse Felipe Contreras
2013-04-22 21:55 ` [PATCH 04/16] remote-hg: properly mark branches up-to-date Felipe Contreras
2013-04-22 21:55 ` [PATCH 05/16] remote-hg: add branch_tip() helper Felipe Contreras
2013-04-22 21:55 ` [PATCH 06/16] remote-hg: add support for tag objects Felipe Contreras
2013-04-22 21:55 ` [PATCH 07/16] remote-hg: custom method to write tags Felipe Contreras
2013-04-22 21:55 ` [PATCH 08/16] remote-hg: write tags in the appropriate branch Felipe Contreras
2013-04-22 21:55 ` [PATCH 09/16] remote-hg: add custom local tag write code Felipe Contreras
2013-04-22 21:55 ` [PATCH 10/16] remote-hg: improve email sanitation Felipe Contreras
2013-04-22 21:55 ` [PATCH 11/16] remote-hg: add support for schemes extension Felipe Contreras
2013-04-22 21:55 ` [PATCH 12/16] remote-hg: don't update bookmarks unnecessarily Felipe Contreras
2013-04-22 21:55 ` [PATCH 13/16] remote-hg: allow refs with spaces Felipe Contreras
2013-04-22 22:32   ` Junio C Hamano
2013-04-22 22:38     ` Felipe Contreras
2013-04-22 23:03       ` Junio C Hamano
2013-04-22 21:55 ` [PATCH 14/16] remote-hg: small performance improvement Felipe Contreras
2013-04-22 21:55 ` [PATCH 15/16] remote-hg: use marks instead of inlined files Felipe Contreras
2013-04-22 22:33   ` Junio C Hamano [this message]
2013-04-22 21:55 ` [PATCH 16/16] remote-hg: strip extra newline Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1ua2nqky.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=simon@ruderich.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).