Show More
@@ -371,28 +371,31 b' class convert_git(converter_source):' | |||||
371 | def getbookmarks(self): |
|
371 | def getbookmarks(self): | |
372 | bookmarks = {} |
|
372 | bookmarks = {} | |
373 |
|
373 | |||
374 | # Interesting references in git are prefixed |
|
374 | # Handle local and remote branches | |
375 | prefix = 'refs/heads/' |
|
375 | remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote') | |
376 | prefixlen = len(prefix) |
|
376 | reftypes = [ | |
|
377 | # (git prefix, hg prefix) | |||
|
378 | ('refs/remotes/origin/', remoteprefix + '/'), | |||
|
379 | ('refs/heads/', '') | |||
|
380 | ] | |||
377 |
|
381 | |||
378 | # factor two commands |
|
382 | exclude = set([ | |
379 | remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote') |
|
383 | 'refs/remotes/origin/HEAD', | |
380 | gitcmd = { remoteprefix + '/': 'git ls-remote --heads origin', |
|
384 | ]) | |
381 | '': 'git show-ref'} |
|
|||
382 |
|
385 | |||
383 | # Origin heads |
|
386 | try: | |
384 | for reftype in gitcmd: |
|
387 | fh = self.gitopen('git show-ref', err=subprocess.PIPE) | |
385 |
|
|
388 | for line in fh: | |
386 | fh = self.gitopen(gitcmd[reftype], err=subprocess.PIPE) |
|
389 | line = line.strip() | |
387 | for line in fh: |
|
390 | rev, name = line.split(None, 1) | |
388 | line = line.strip() |
|
391 | # Process each type of branch | |
389 | rev, name = line.split(None, 1) |
|
392 | for gitprefix, hgprefix in reftypes: | |
390 | if not name.startswith(prefix): |
|
393 | if not name.startswith(gitprefix) or name in exclude: | |
391 | continue |
|
394 | continue | |
392 |
name = '%s%s' % ( |
|
395 | name = '%s%s' % (hgprefix, name[len(gitprefix):]) | |
393 | bookmarks[name] = rev |
|
396 | bookmarks[name] = rev | |
394 |
|
|
397 | except Exception: | |
395 |
|
|
398 | pass | |
396 |
|
399 | |||
397 | return bookmarks |
|
400 | return bookmarks | |
398 |
|
401 |
@@ -666,6 +666,28 b' convert using a different remote prefix' | |||||
666 | master 0:03bf38caa4c6 |
|
666 | master 0:03bf38caa4c6 | |
667 | origin/master 0:03bf38caa4c6 |
|
667 | origin/master 0:03bf38caa4c6 | |
668 |
|
668 | |||
|
669 | Run convert when the remote branches have changed | |||
|
670 | (there was an old bug where the local convert read branches from the server) | |||
|
671 | ||||
|
672 | $ cd git-repo7 | |||
|
673 | $ echo a >> a | |||
|
674 | $ git commit -am "move master forward" | |||
|
675 | [master 0c81947] move master forward | |||
|
676 | Author: nottest <test@example.org> | |||
|
677 | 1 file changed, 1 insertion(+) | |||
|
678 | $ cd .. | |||
|
679 | $ rm -rf hg-repo7 | |||
|
680 | $ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 | |||
|
681 | initializing destination hg-repo7 repository | |||
|
682 | scanning source... | |||
|
683 | sorting... | |||
|
684 | converting... | |||
|
685 | 0 commit a | |||
|
686 | updating bookmarks | |||
|
687 | $ hg -R hg-repo7 bookmarks | |||
|
688 | master 0:03bf38caa4c6 | |||
|
689 | origin/master 0:03bf38caa4c6 | |||
|
690 | ||||
669 | damaged git repository tests: |
|
691 | damaged git repository tests: | |
670 | In case the hard-coded hashes change, the following commands can be used to |
|
692 | In case the hard-coded hashes change, the following commands can be used to | |
671 | list the hashes and their corresponding types in the repository: |
|
693 | list the hashes and their corresponding types in the repository: |
General Comments 0
You need to be logged in to leave comments.
Login now