Show More
@@ -371,28 +371,31 b' class convert_git(converter_source):' | |||
|
371 | 371 | def getbookmarks(self): |
|
372 | 372 | bookmarks = {} |
|
373 | 373 | |
|
374 | # Interesting references in git are prefixed | |
|
375 | prefix = 'refs/heads/' | |
|
376 | prefixlen = len(prefix) | |
|
374 | # Handle local and remote branches | |
|
375 | remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote') | |
|
376 | reftypes = [ | |
|
377 | # (git prefix, hg prefix) | |
|
378 | ('refs/remotes/origin/', remoteprefix + '/'), | |
|
379 | ('refs/heads/', '') | |
|
380 | ] | |
|
377 | 381 | |
|
378 | # factor two commands | |
|
379 | remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote') | |
|
380 | gitcmd = { remoteprefix + '/': 'git ls-remote --heads origin', | |
|
381 | '': 'git show-ref'} | |
|
382 | exclude = set([ | |
|
383 | 'refs/remotes/origin/HEAD', | |
|
384 | ]) | |
|
382 | 385 | |
|
383 | # Origin heads | |
|
384 | for reftype in gitcmd: | |
|
385 |
|
|
|
386 | fh = self.gitopen(gitcmd[reftype], err=subprocess.PIPE) | |
|
387 | for line in fh: | |
|
388 | line = line.strip() | |
|
389 | rev, name = line.split(None, 1) | |
|
390 | if not name.startswith(prefix): | |
|
386 | try: | |
|
387 | fh = self.gitopen('git show-ref', err=subprocess.PIPE) | |
|
388 | for line in fh: | |
|
389 | line = line.strip() | |
|
390 | rev, name = line.split(None, 1) | |
|
391 | # Process each type of branch | |
|
392 | for gitprefix, hgprefix in reftypes: | |
|
393 | if not name.startswith(gitprefix) or name in exclude: | |
|
391 | 394 | continue |
|
392 |
name = '%s%s' % ( |
|
|
395 | name = '%s%s' % (hgprefix, name[len(gitprefix):]) | |
|
393 | 396 | bookmarks[name] = rev |
|
394 |
|
|
|
395 |
|
|
|
397 | except Exception: | |
|
398 | pass | |
|
396 | 399 | |
|
397 | 400 | return bookmarks |
|
398 | 401 |
@@ -666,6 +666,28 b' convert using a different remote prefix' | |||
|
666 | 666 | master 0:03bf38caa4c6 |
|
667 | 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 | 691 | damaged git repository tests: |
|
670 | 692 | In case the hard-coded hashes change, the following commands can be used to |
|
671 | 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