Show More
@@ -17,19 +17,27 b' class convert_git(converter_source):' | |||
|
17 | 17 | # cannot remove environment variable. Just assume none have |
|
18 | 18 | # both issues. |
|
19 | 19 | if hasattr(os, 'unsetenv'): |
|
20 | def gitopen(self, s): | |
|
20 | def gitopen(self, s, noerr=False): | |
|
21 | 21 | prevgitdir = os.environ.get('GIT_DIR') |
|
22 | 22 | os.environ['GIT_DIR'] = self.path |
|
23 | 23 | try: |
|
24 | return util.popen(s, 'rb') | |
|
24 | if noerr: | |
|
25 | (stdin, stdout, stderr) = util.popen3(s) | |
|
26 | return stdout | |
|
27 | else: | |
|
28 | return util.popen(s, 'rb') | |
|
25 | 29 | finally: |
|
26 | 30 | if prevgitdir is None: |
|
27 | 31 | del os.environ['GIT_DIR'] |
|
28 | 32 | else: |
|
29 | 33 | os.environ['GIT_DIR'] = prevgitdir |
|
30 | 34 | else: |
|
31 | def gitopen(self, s): | |
|
32 | return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb') | |
|
35 | def gitopen(self, s, noerr=False): | |
|
36 | if noerr: | |
|
37 | (sin, so, se) = util.popen3('GIT_DIR=%s %s' % (self.path, s)) | |
|
38 | return stdout | |
|
39 | else: | |
|
40 | util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb') | |
|
33 | 41 | |
|
34 | 42 | def gitread(self, s): |
|
35 | 43 | fh = self.gitopen(s) |
@@ -168,3 +176,30 b' class convert_git(converter_source):' | |||
|
168 | 176 | raise util.Abort(_('cannot read changes in %s') % version) |
|
169 | 177 | |
|
170 | 178 | return changes |
|
179 | ||
|
180 | def getbookmarks(self): | |
|
181 | bookmarks = {} | |
|
182 | ||
|
183 | # Interesting references in git are prefixed | |
|
184 | prefix = 'refs/heads/' | |
|
185 | prefixlen = len(prefix) | |
|
186 | ||
|
187 | # factor two commands | |
|
188 | gitcmd = { 'remote/': 'git ls-remote --heads origin', | |
|
189 | '': 'git show-ref'} | |
|
190 | ||
|
191 | # Origin heads | |
|
192 | for reftype in gitcmd: | |
|
193 | try: | |
|
194 | fh = self.gitopen(gitcmd[reftype], noerr=True) | |
|
195 | for line in fh: | |
|
196 | line = line.strip() | |
|
197 | rev, name = line.split(None, 1) | |
|
198 | if not name.startswith(prefix): | |
|
199 | continue | |
|
200 | name = '%s%s' % (reftype, name[prefixlen:]) | |
|
201 | bookmarks[name] = rev | |
|
202 | except: | |
|
203 | pass | |
|
204 | ||
|
205 | return bookmarks |
@@ -57,9 +57,11 b' Remove the directory, then try to replac' | |||
|
57 | 57 | 2 t4.1 |
|
58 | 58 | 1 t4.2 |
|
59 | 59 | 0 Merge branch other |
|
60 | updating bookmarks | |
|
60 | 61 | $ hg up -q -R git-repo-hg |
|
61 | 62 | $ hg -R git-repo-hg tip -v |
|
62 | 63 | changeset: 5:c78094926be2 |
|
64 | bookmark: master | |
|
63 | 65 | tag: tip |
|
64 | 66 | parent: 3:f5f5cb45432b |
|
65 | 67 | parent: 4:4e174f80c67c |
@@ -217,6 +219,7 b' convert binary file' | |||
|
217 | 219 | sorting... |
|
218 | 220 | converting... |
|
219 | 221 | 0 addbinary |
|
222 | updating bookmarks | |
|
220 | 223 | $ cd git-repo3-hg |
|
221 | 224 | $ hg up -C |
|
222 | 225 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
@@ -248,8 +251,10 b' convert author committer' | |||
|
248 | 251 | converting... |
|
249 | 252 | 1 addfoo |
|
250 | 253 | 0 addfoo2 |
|
254 | updating bookmarks | |
|
251 | 255 | $ hg -R git-repo4-hg log -v |
|
252 | 256 | changeset: 1:d63e967f93da |
|
257 | bookmark: master | |
|
253 | 258 | tag: tip |
|
254 | 259 | user: nottest <test@example.org> |
|
255 | 260 | date: Mon Jan 01 00:00:21 2007 +0000 |
@@ -49,6 +49,7 b' Do a first conversion' | |||
|
49 | 49 | converting... |
|
50 | 50 | 0 rev1 |
|
51 | 51 | updating tags |
|
52 | updating bookmarks | |
|
52 | 53 | |
|
53 | 54 | Simulate upstream updates after first conversion |
|
54 | 55 | |
@@ -67,6 +68,7 b' Perform an incremental conversion' | |||
|
67 | 68 | converting... |
|
68 | 69 | 0 rev2 |
|
69 | 70 | updating tags |
|
71 | updating bookmarks | |
|
70 | 72 | |
|
71 | 73 | Print the log |
|
72 | 74 |
General Comments 0
You need to be logged in to leave comments.
Login now