##// END OF EJS Templates
convert_git: add --filemap support
Alexis S. L. Carvalho -
r5380:a5a7f7fd default
parent child Browse files
Show More
@@ -122,3 +122,21 b' class convert_git(converter_source):'
122 tags[tag] = node
122 tags[tag] = node
123
123
124 return tags
124 return tags
125
126 def getchangedfiles(self, version, i):
127 changes = []
128 if i is None:
129 fh = self.gitcmd("git-diff-tree --root -m -r %s" % version)
130 for l in fh:
131 if "\t" not in l:
132 continue
133 m, f = l[:-1].split("\t")
134 changes.append(f)
135 fh.close()
136 else:
137 fh = self.gitcmd("git-diff-tree --name-only --root -r %s %s^%s --"
138 % (version, version, i+1))
139 changes = [f.rstrip('\n') for f in fh]
140 fh.close()
141
142 return changes
@@ -4,6 +4,7 b''
4
4
5 echo "[extensions]" >> $HGRCPATH
5 echo "[extensions]" >> $HGRCPATH
6 echo "convert=" >> $HGRCPATH
6 echo "convert=" >> $HGRCPATH
7 echo 'hgext.graphlog =' >> $HGRCPATH
7
8
8 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
9 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
9 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
10 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
@@ -54,3 +55,78 b' cd ..'
54 hg convert --datesort git-repo
55 hg convert --datesort git-repo
55
56
56 hg -R git-repo-hg tip -v
57 hg -R git-repo-hg tip -v
58
59 count=10
60 mkdir git-repo2
61 cd git-repo2
62 git init-db >/dev/null 2>/dev/null
63
64 echo foo > foo
65 git add foo
66 commit -a -m 'add foo'
67
68 echo >> foo
69 commit -a -m 'change foo'
70
71 git checkout -b Bar HEAD^ >/dev/null 2>/dev/null
72 echo quux >> quux
73 git add quux
74 commit -a -m 'add quux'
75
76 echo bar > bar
77 git add bar
78 commit -a -m 'add bar'
79
80 git checkout -b Baz HEAD^ >/dev/null 2>/dev/null
81 echo baz > baz
82 git add baz
83 commit -a -m 'add baz'
84
85 git checkout master >/dev/null 2>/dev/null
86 git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
87 commit -m 'Octopus merge'
88
89 echo bar >> bar
90 commit -a -m 'change bar'
91
92 git checkout -b Foo HEAD^ >/dev/null 2>/dev/null
93 echo >> foo
94 commit -a -m 'change foo'
95
96 git checkout master >/dev/null 2>/dev/null
97 git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
98 commit -m 'Discard change to foo'
99
100 cd ..
101
102 glog()
103 {
104 hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@"
105 }
106
107 splitrepo()
108 {
109 msg="$1"
110 files="$2"
111 opts=$3
112 echo "% $files: $msg"
113 prefix=`echo "$files" | sed -e 's/ /-/g'`
114 fmap="$prefix.fmap"
115 repo="$prefix.repo"
116 for i in $files; do
117 echo "include $i" >> "$fmap"
118 done
119 hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
120 glog -R "$repo"
121 hg -R "$repo" manifest --debug
122 }
123
124 echo '% full conversion'
125 hg -q convert --datesort git-repo2 fullrepo
126 glog -R fullrepo
127 hg -R fullrepo manifest --debug
128
129 splitrepo 'octopus merge' 'foo bar baz'
130
131 splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux'
132
@@ -23,3 +23,68 b' Merge branch other'
23 committer: test <test@example.org>
23 committer: test <test@example.org>
24
24
25
25
26 % full conversion
27 o 9 "Discard change to foo" files: foo
28 |\
29 | o 8 "change foo" files: foo
30 | |
31 o | 7 "change bar" files: bar
32 |/
33 o 6 "(octopus merge fixup)" files:
34 |\
35 | o 5 "Octopus merge" files: baz
36 | |\
37 o | | 4 "add baz" files: baz
38 | | |
39 +---o 3 "add bar" files: bar
40 | |
41 o | 2 "add quux" files: quux
42 | |
43 | o 1 "change foo" files: foo
44 |/
45 o 0 "add foo" files: foo
46
47 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
48 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
49 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
50 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
51 % foo bar baz: octopus merge
52 o 8 "Discard change to foo" files: foo
53 |\
54 | o 7 "change foo" files: foo
55 | |
56 o | 6 "change bar" files: bar
57 |/
58 o 5 "(octopus merge fixup)" files:
59 |\
60 | o 4 "Octopus merge" files: baz
61 | |\
62 o | | 3 "add baz" files: baz
63 | | |
64 +---o 2 "add bar" files: bar
65 | |
66 | o 1 "change foo" files: foo
67 |/
68 o 0 "add foo" files: foo
69
70 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
71 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
72 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
73 % foo baz quux: only some parents of an octopus merge; "discard" a head
74 o 6 "Discard change to foo" files: foo
75 |
76 o 5 "change foo" files: foo
77 |
78 o 4 "Octopus merge" files:
79 |\
80 | o 3 "add baz" files: baz
81 | |
82 | o 2 "add quux" files: quux
83 | |
84 o | 1 "change foo" files: foo
85 |/
86 o 0 "add foo" files: foo
87
88 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
89 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
90 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
General Comments 0
You need to be logged in to leave comments. Login now