{"id":325937,"date":"2021-07-04T15:00:25","date_gmt":"2021-07-04T15:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=325937"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=325937","title":{"rendered":"\u041d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e git-filter-repo"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/522942\/\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432<\/a>. \u0421\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0442\u0430\u043a\u043e\u0432\u0430: \u043d\u0430\u0434\u043e \u0441\u043b\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u043e\u0434\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 gitpython \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0437\u0430 6 \u0447\u0430\u0441\u043e\u0432 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041d\u043e \u043f\u0435\u0440\u0435\u0438\u0437\u0431\u044b\u0442\u043e\u043a \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 <s>\u0433\u0432\u043e\u0437\u0434\u044c \u0432 \u0436\u043e\u043f\u0435<\/s> \u0432\u0440\u043e\u0436\u0434\u0451\u043d\u043d\u0430\u044f \u043b\u044e\u0431\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043c\u0435\u043d\u044f \u043a \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0443 \u0441 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u043c \u043c\u0438\u0440\u043e\u043c <a href=\"https:\/\/github.com\/newren\/git-filter-repo\" rel=\"noopener noreferrer nofollow\">git-filter-repo<\/a>.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 git-filter-repo?<\/h3>\n<p>\u042d\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>git fast-export<\/code> \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, <code>git fast-import<\/code> \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u044f\u043a\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e. <code>git fast-export<\/code>, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u0442 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b git-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f (\u0430 git-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430) \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434, \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0425, \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0425. <code>git fast-import<\/code>, \u043a\u0430\u043a \u043d\u0435 \u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e: \u0431\u0435\u0440\u0451\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0441\u0442\u044b\u043d\u044e \u0438 \u0440\u0430\u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0444\u0430\u0439\u043b\u0430\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 .git.<\/p>\n<h3>\u041f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0435\u0439<\/h3>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0432 \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u0440\u0430\u0444\u0430 \u2014 \u043b\u0438\u0448\u043d\u044f\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u0412\u0435\u0434\u044c \u043c\u0435\u0441\u0442\u043e, \u043a\u0443\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0438\u0442\u044b \u0438\u0437 secondary-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0439\u0442\u0438: \u044d\u0442\u043e \u0442\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u044b, \u0433\u0434\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b secondary.version. \u041f\u0440\u0438\u0447\u0451\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d secondary \u043a\u043e\u043c\u043c\u0438\u0442\u043e\u0432 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043f\u0438\u0441\u043e\u043a (secondary.version \u0434\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f)..(secondary.version \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f). \u0418, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e \u0433\u0440\u0430\u0444\u0443 \u043a\u043e\u043c\u043c\u0438\u0442\u043e\u0432 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0432 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 3-\u0445 \u0447\u0430\u0441\u043e\u0432. \u041d\u043e, \u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b. \u0412\u0435\u0434\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043c\u0438\u0442\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u044f\u0434 \u043b\u0438\u043d\u0435\u0439\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u0438\u0445 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 <code>git fast-export<\/code>. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c git-filter-repo.<\/p>\n<h3>\u041d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>git filter-repo<\/code>, \u043a\u0430\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041b\u0438\u0431\u043e \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0431\u0435\u043a\u0438 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u043e\u0433 \u0437\u043d\u0430\u0435\u0442 \u0433\u0434\u0435. \u0418\u0441\u0442\u0438\u043d\u043d\u043e, \u044d\u0442\u043e \u043d\u0435 \u043f\u0443\u0442\u044c \u0414\u0430\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u0443\u0434\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 <code>git filter-repo<\/code> \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 FastExportParser, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 <code>git fast-export<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (Blob, Commit \u0438 \u0442.\u0434.), \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 dump() \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0432\u0438\u0434 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0439 \u0434\u043b\u044f <code>git fast-import<\/code>. <\/p>\n<h3>\u0418\u0442\u043e\u0433\u043e<\/h3>\n<p>\u0411\u0435\u0440\u0451\u043c \u043a\u043b\u0430\u0441\u0441 RepoFilter \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0445\u043e\u0434 (<code>git fast-export<\/code>) \u0438 \u0432\u044b\u0445\u043e\u0434 (<code>git fast-import<\/code>) \u0434\u043b\u044f FastExportParser&#8217;\u0430.<\/p>\n<pre><code class=\"python\">fep_cmd = ['git', '-C', args.source, 'fast-export', '--show-original-ids', '--progress=128'            , '--signed-tags=strip', '--tag-of-filtered-object=rewrite', '--mark-tags'            , '--fake-missing-tagger', '--reference-excluded-parents', '--all'] fep = subproc.Popen(fep_cmd, bufsize=-1, stdout=subproc.PIPE) inpt = fep.stdout  fip_cmd = ['git', '-C', args.target, '-c', 'core.ignorecase=false'            , 'fast-import', '--force'] fip = subproc.Popen(fip_cmd, bufsize=-1, stdin=subproc.PIPE, stdout=subproc.PIPE) otpt = fip.stdin  processor = Processor(args.source, args.secondary, otpt, fip.stdout) parser = gfr.FastExportParser(blob_callback = processor.blob_callback                               , commit_callback = processor.commit_callback                               , progress_callback = processor.progress_cb)   parser.run(inpt, otpt) otpt.close() inpt.close() <\/code><\/pre>\n<p>\u0418 \u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Processor<\/code> c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043a\u043e\u043b\u043b\u0431\u0435\u043a\u0430\u043c\u0438. \u0421\u0430\u043c\u044b\u0439 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u2014 \u043a\u043e\u043c\u043c\u0438\u0442\u043d\u044b\u0439. \u0422\u0430\u043c \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0438\u0442 \u043c\u0435\u043d\u044f\u0435\u0442 secondary.version. \u0427\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a <code>git fast-export<\/code> \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0434\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043a\u043e\u043c\u043c\u0438\u0442\u0435. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 <code>git fast-export<\/code> \u0441 \u043d\u043e\u0432\u044b\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c FastExportParser&#8217;\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u043e\u043c\u043c\u0438\u0442\u044b \u0443\u0436\u0435 \u0438\u0437 secondary \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f, \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0441 \u043d\u0438\u043c\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043f\u0438\u0448\u0435\u0442 \u0432 \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0442\u043e\u043a <code>git fast-import<\/code>. \u041f\u0440\u0438\u0447\u0451\u043c, \u043c\u043d\u043e\u0433\u0438\u0435 \u0431\u043b\u043e\u0431\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 git fast-import \u043f\u043e \u043c\u043d\u043e\u0433\u0443 \u0440\u0430\u0437, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u044f\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432, \u0432\u0435\u0434\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b git \u0430\u0434\u0440\u0435\u0441\u0443\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c\u0438 \u0445\u044d\u0448\u0430\u043c\u0438, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 (\u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u043c\u0438). \u041a\u043b\u0430\u0441\u0441 Commit \u0438 \u043a\u043e\u043c\u043c\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a.<\/p>\n<pre><code class=\"python\">  class Commit(_GitElementWithId):   \"\"\"   This class defines our representation of commit elements. Commit elements   contain all the information associated with a commit.   \"\"\"    def __init__(self, branch,                author_name,    author_email,    author_date,                committer_name, committer_email, committer_date,                message,                file_changes,                parents,                original_id = None,                encoding = None, # encoding for message; None implies UTF-8                **kwargs):         pass      class Processor :      def process_commit(self, commit) :         idx = len(commit.file_changes)         commit.message = self.message_reformat(commit.message)         while idx &gt; 0 :             idx -= 1             fc = commit.file_changes[idx]             if fc.type == b'M' :                 process_meth = self.MAP.get(fc.filename)                 if process_meth is not None:                     commit.file_changes.pop(idx)                     process_meth(commit, fc) <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, process_commit \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430. \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f secondary.version:<\/p>\n<pre><code class=\"python\">    def process_secondary_version(self, commit) :         parent = commit.original_id.decode('ascii')         res = subproc.run(['git', '-C', self.prepo, 'cat-file'                            , 'blob', f'{parent}^:secondary.version']                           , capture_output = True)         hsh_from = res.stdout[:40].decode('ascii')         if len(hsh_from) &lt; 40 :             sr_range = f'{hsh}^!'         else :             sr_range = f'{hsh_from}..{hsh}'         self.sub_parsed = False         self.super_commit = commit         self.sub_top_hsh = hsh.encode('ascii')          sub_fep_cmd = ['git', '-C', self.srepo, 'fast-export', '--show-original-ids'                        , '--signed-tags=strip', '--tag-of-filtered-object=drop'                        , '--import-marks=secondary.marks'                        , sr_range]         sub_fep = subproc.Popen(sub_fep_cmd, bufsize=-1, stdout=subproc.PIPE)         self.sub_parser.run(sub_fep.stdout, self.output)         sub_fep.stdout.close() <\/code><\/pre>\n<h3>\u042d\u043f\u0438\u043b\u043e\u0433<\/h3>\n<p>\u041d\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430 10 \u043c\u0438\u043d\u0443\u0442 \u0432\u043c\u0435\u0441\u0442\u043e 6-\u0438 \u0447\u0430\u0441\u043e\u0432. \u041c\u043e\u0440\u0430\u043b\u044c: \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043b\u0443\u0447\u0448\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u0430\u044e\u0442 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/566034\/\"> https:\/\/habr.com\/ru\/post\/566034\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/522942\/\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432<\/a>. \u0421\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0442\u0430\u043a\u043e\u0432\u0430: \u043d\u0430\u0434\u043e \u0441\u043b\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u043e\u0434\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u0438. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 gitpython \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0437\u0430 6 \u0447\u0430\u0441\u043e\u0432 \u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041d\u043e \u043f\u0435\u0440\u0435\u0438\u0437\u0431\u044b\u0442\u043e\u043a \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 <s>\u0433\u0432\u043e\u0437\u0434\u044c \u0432 \u0436\u043e\u043f\u0435<\/s> \u0432\u0440\u043e\u0436\u0434\u0451\u043d\u043d\u0430\u044f \u043b\u044e\u0431\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043c\u0435\u043d\u044f \u043a \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0443 \u0441 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u043c \u043c\u0438\u0440\u043e\u043c <a href=\"https:\/\/github.com\/newren\/git-filter-repo\" rel=\"noopener noreferrer nofollow\">git-filter-repo<\/a>.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 git-filter-repo?<\/h3>\n<p>\u042d\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>git fast-export<\/code> \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, <code>git fast-import<\/code> \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u044f\u043a\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e. <code>git fast-export<\/code>, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0451\u0442 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b git-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f (\u0430 git-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430) \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434, \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0425, \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0425. <code>git fast-import<\/code>, \u043a\u0430\u043a \u043d\u0435 \u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e: \u0431\u0435\u0440\u0451\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0441\u0442\u044b\u043d\u044e \u0438 \u0440\u0430\u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0444\u0430\u0439\u043b\u0430\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 .git.<\/p>\n<h3>\u041f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0435\u0439<\/h3>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u0432 \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0433\u0440\u0430\u0444\u0430 \u2014 \u043b\u0438\u0448\u043d\u044f\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u0412\u0435\u0434\u044c \u043c\u0435\u0441\u0442\u043e, \u043a\u0443\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0438\u0442\u044b \u0438\u0437 secondary-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0439\u0442\u0438: \u044d\u0442\u043e \u0442\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u044b, \u0433\u0434\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b secondary.version. \u041f\u0440\u0438\u0447\u0451\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d secondary \u043a\u043e\u043c\u043c\u0438\u0442\u043e\u0432 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043f\u0438\u0441\u043e\u043a (secondary.version \u0434\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f)..(secondary.version \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f). \u0418, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e \u0433\u0440\u0430\u0444\u0443 \u043a\u043e\u043c\u043c\u0438\u0442\u043e\u0432 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0432 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 3-\u0445 \u0447\u0430\u0441\u043e\u0432. \u041d\u043e, \u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b. \u0412\u0435\u0434\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043c\u0438\u0442\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u044f\u0434 \u043b\u0438\u043d\u0435\u0439\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u0438\u0445 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 <code>git fast-export<\/code>. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c git-filter-repo.<\/p>\n<h3>\u041d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>git filter-repo<\/code>, \u043a\u0430\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0436\u0438\u043c \u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041b\u0438\u0431\u043e \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0431\u0435\u043a\u0438 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u043e\u0433 \u0437\u043d\u0430\u0435\u0442 \u0433\u0434\u0435. \u0418\u0441\u0442\u0438\u043d\u043d\u043e, \u044d\u0442\u043e \u043d\u0435 \u043f\u0443\u0442\u044c \u0414\u0430\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u0443\u0434\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 <code>git filter-repo<\/code> \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 FastExportParser, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 <code>git fast-export<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (Blob, Commit \u0438 \u0442.\u0434.), \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 dump() \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0432\u0438\u0434 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0439 \u0434\u043b\u044f <code>git fast-import<\/code>. <\/p>\n<h3>\u0418\u0442\u043e\u0433\u043e<\/h3>\n<p>\u0411\u0435\u0440\u0451\u043c \u043a\u043b\u0430\u0441\u0441 RepoFilter \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0445\u043e\u0434 (<code>git fast-export<\/code>) \u0438 \u0432\u044b\u0445\u043e\u0434 (<code>git fast-import<\/code>) \u0434\u043b\u044f FastExportParser&#8217;\u0430.<\/p>\n<pre><code class=\"python\">fep_cmd = ['git', '-C', args.source, 'fast-export', '--show-original-ids', '--progress=128'            , '--signed-tags=strip', '--tag-of-filtered-object=rewrite', '--mark-tags'            , '--fake-missing-tagger', '--reference-excluded-parents', '--all'] fep = subproc.Popen(fep_cmd, bufsize=-1, stdout=subproc.PIPE) inpt = fep.stdout  fip_cmd = ['git', '-C', args.target, '-c', 'core.ignorecase=false'            , 'fast-import', '--force'] fip = subproc.Popen(fip_cmd, bufsize=-1, stdin=subproc.PIPE, stdout=subproc.PIPE) otpt = fip.stdin  processor = Processor(args.source, args.secondary, otpt, fip.stdout) parser = gfr.FastExportParser(blob_callback = processor.blob_callback                               , commit_callback = processor.commit_callback                               , progress_callback = processor.progress_cb)   parser.run(inpt, otpt) otpt.close() inpt.close() <\/code><\/pre>\n<p>\u0418 \u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Processor<\/code> c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043a\u043e\u043b\u043b\u0431\u0435\u043a\u0430\u043c\u0438. \u0421\u0430\u043c\u044b\u0439 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u2014 \u043a\u043e\u043c\u043c\u0438\u0442\u043d\u044b\u0439. \u0422\u0430\u043c \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0438\u0442 \u043c\u0435\u043d\u044f\u0435\u0442 secondary.version. \u0427\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a <code>git fast-export<\/code> \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0434\u0430\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043a\u043e\u043c\u043c\u0438\u0442\u0435. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 <code>git fast-export<\/code> \u0441 \u043d\u043e\u0432\u044b\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c FastExportParser&#8217;\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u043e\u043c\u043c\u0438\u0442\u044b \u0443\u0436\u0435 \u0438\u0437 secondary \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f, \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0441 \u043d\u0438\u043c\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043f\u0438\u0448\u0435\u0442 \u0432 \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0442\u043e\u043a <code>git fast-import<\/code>. \u041f\u0440\u0438\u0447\u0451\u043c, \u043c\u043d\u043e\u0433\u0438\u0435 \u0431\u043b\u043e\u0431\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 git fast-import \u043f\u043e \u043c\u043d\u043e\u0433\u0443 \u0440\u0430\u0437, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u044f\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432, \u0432\u0435\u0434\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b git \u0430\u0434\u0440\u0435\u0441\u0443\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c\u0438 \u0445\u044d\u0448\u0430\u043c\u0438, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 (\u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u044b\u043c\u0438). \u041a\u043b\u0430\u0441\u0441 Commit \u0438 \u043a\u043e\u043c\u043c\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a.<\/p>\n<pre><code class=\"python\">  class Commit(_GitElementWithId):   \"\"\"   This class defines our representation of commit elements. Commit elements   contain all the information associated with a commit.   \"\"\"    def __init__(self, branch,                author_name,    author_email,    author_date,                committer_name, committer_email, committer_date,                message,                file_changes,                parents,                original_id = None,                encoding = None, # encoding for message; None implies UTF-8                **kwargs):         pass      class Processor :      def process_commit(self, commit) :         idx = len(commit.file_changes)         commit.message = self.message_reformat(commit.message)         while idx &gt; 0 :             idx -= 1             fc = commit.file_changes[idx]             if fc.type == b'M' :                 process_meth = self.MAP.get(fc.filename)                 if process_meth is not None:                     commit.file_changes.pop(idx)                     process_meth(commit, fc) <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, process_commit \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430. \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f secondary.version:<\/p>\n<pre><code class=\"python\">    def process_secondary_version(self, commit) :         parent = commit.original_id.decode('ascii')         res = subproc.run(['git', '-C', self.prepo, 'cat-file'                            , 'blob', f'{parent}^:secondary.version']                           , capture_output = True)         hsh_from = res.stdout[:40].decode('ascii')         if len(hsh_from) &lt; 40 :             sr_range = f'{hsh}^!'         else :             sr_range = f'{hsh_from}..{hsh}'         self.sub_parsed = False         self.super_commit = commit         self.sub_top_hsh = hsh.encode('ascii')          sub_fep_cmd = ['git', '-C', self.srepo, 'fast-export', '--show-original-ids'                        , '--signed-tags=strip', '--tag-of-filtered-object=drop'                        , '--import-marks=secondary.marks'                        , sr_range]         sub_fep = subproc.Popen(sub_fep_cmd, bufsize=-1, stdout=subproc.PIPE)         self.sub_parser.run(sub_fep.stdout, self.output)         sub_fep.stdout.close() <\/code><\/pre>\n<h3>\u042d\u043f\u0438\u043b\u043e\u0433<\/h3>\n<p>\u041d\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430 10 \u043c\u0438\u043d\u0443\u0442 \u0432\u043c\u0435\u0441\u0442\u043e 6-\u0438 \u0447\u0430\u0441\u043e\u0432. \u041c\u043e\u0440\u0430\u043b\u044c: \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043b\u0443\u0447\u0448\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u0430\u044e\u0442 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/566034\/\"> https:\/\/habr.com\/ru\/post\/566034\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-325937","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325937","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=325937"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325937\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}