-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infrastructure to write revisions in fast-export format
repo_tree maintains the exporter's state and provides a facility to to call fast_export, which writes objects to stdout suitable for consumption by fast-import. The exported functions roughly correspond to Subversion FS operations. . repo_add, repo_modify, repo_copy, repo_replace, and repo_delete update the current commit, based roughly on the corresponding Subversion FS operation. . repo_commit calls out to fast_export to write the current commit to the fast-import stream in stdout. . repo_diff is used by the fast_export module to write the changes for a commit. . repo_reset erases the exporter's state, so valgrind can be happy. [rr: squelched compiler warnings] [jn: removed support for maintaining state on-disk, though we may want to add it back later] Signed-off-by: David Barr <david.barr@cordelta.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
David Barr
authored and
Junio C Hamano
committed
Aug 15, 2010
1 parent
3bbaec0
commit c0e6c23
Showing
5 changed files
with
443 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed under a two-clause BSD-style license. | ||
* See LICENSE for details. | ||
*/ | ||
|
||
#include "git-compat-util.h" | ||
#include "fast_export.h" | ||
#include "line_buffer.h" | ||
#include "repo_tree.h" | ||
#include "string_pool.h" | ||
|
||
#define MAX_GITSVN_LINE_LEN 4096 | ||
|
||
static uint32_t first_commit_done; | ||
|
||
void fast_export_delete(uint32_t depth, uint32_t *path) | ||
{ | ||
putchar('D'); | ||
putchar(' '); | ||
pool_print_seq(depth, path, '/', stdout); | ||
putchar('\n'); | ||
} | ||
|
||
void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode, | ||
uint32_t mark) | ||
{ | ||
/* Mode must be 100644, 100755, 120000, or 160000. */ | ||
printf("M %06o :%d ", mode, mark); | ||
pool_print_seq(depth, path, '/', stdout); | ||
putchar('\n'); | ||
} | ||
|
||
static char gitsvnline[MAX_GITSVN_LINE_LEN]; | ||
void fast_export_commit(uint32_t revision, uint32_t author, char *log, | ||
uint32_t uuid, uint32_t url, | ||
unsigned long timestamp) | ||
{ | ||
if (!log) | ||
log = ""; | ||
if (~uuid && ~url) { | ||
snprintf(gitsvnline, MAX_GITSVN_LINE_LEN, "\n\ngit-svn-id: %s@%d %s\n", | ||
pool_fetch(url), revision, pool_fetch(uuid)); | ||
} else { | ||
*gitsvnline = '\0'; | ||
} | ||
printf("commit refs/heads/master\n"); | ||
printf("committer %s <%s@%s> %ld +0000\n", | ||
~author ? pool_fetch(author) : "nobody", | ||
~author ? pool_fetch(author) : "nobody", | ||
~uuid ? pool_fetch(uuid) : "local", timestamp); | ||
printf("data %zd\n%s%s\n", | ||
strlen(log) + strlen(gitsvnline), log, gitsvnline); | ||
if (!first_commit_done) { | ||
if (revision > 1) | ||
printf("from refs/heads/master^0\n"); | ||
first_commit_done = 1; | ||
} | ||
repo_diff(revision - 1, revision); | ||
fputc('\n', stdout); | ||
|
||
printf("progress Imported commit %d.\n\n", revision); | ||
} | ||
|
||
void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len) | ||
{ | ||
if (mode == REPO_MODE_LNK) { | ||
/* svn symlink blobs start with "link " */ | ||
buffer_skip_bytes(5); | ||
len -= 5; | ||
} | ||
printf("blob\nmark :%d\ndata %d\n", mark, len); | ||
buffer_copy_bytes(len); | ||
fputc('\n', stdout); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef FAST_EXPORT_H_ | ||
#define FAST_EXPORT_H_ | ||
|
||
void fast_export_delete(uint32_t depth, uint32_t *path); | ||
void fast_export_modify(uint32_t depth, uint32_t *path, uint32_t mode, | ||
uint32_t mark); | ||
void fast_export_commit(uint32_t revision, uint32_t author, char *log, | ||
uint32_t uuid, uint32_t url, unsigned long timestamp); | ||
void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len); | ||
|
||
#endif |
Oops, something went wrong.