return '%s <%s>' % (name, mail)
+def updatebookmarks(repo, peer):
+ remotemarks = peer.listkeys('bookmarks')
+ localmarks = repo._bookmarks
+
+ if not remotemarks:
+ return
+
+ for k, v in remotemarks.iteritems():
+ localmarks[k] = hgbin(v)
+
+ if hasattr(localmarks, 'write'):
+ localmarks.write()
+ else:
+ bookmarks.write(repo)
+
def get_repo(url, alias):
global dirname, peer
extensions.loadall(myui)
- if hg.islocal(url):
+ if hg.islocal(url) and not os.environ.get('GIT_REMOTE_HG_TEST_REMOTE'):
repo = hg.repository(myui, url)
if not os.path.exists(dirname):
os.makedirs(dirname)
die('Repository error')
repo.pull(peer, heads=None, force=True)
+ updatebookmarks(repo, peer)
+
return repo
def rev_to_mark(rev):
tip = 0
revs = xrange(tip, head.rev() + 1)
- count = 0
+ total = len(revs)
for rev in revs:
node = c.node()
if marks.is_marked(c.hex()):
- count += 1
continue
(manifest, user, (time, tz), files, desc, extra) = repo.changelog.read(node)
print "D %s" % (fix_file_path(f))
print
- count += 1
- if (count % 100 == 0):
- print "progress revision %d '%s' (%d/%d)" % (rev, name, count, len(revs))
+ progress = (rev - tip)
+ if (progress % 100 == 0):
+ print "progress revision %d '%s' (%d/%d)" % (rev, name, progress, total)
# make sure the ref is updated
print "reset %s/%s" % (prefix, ename)
return heads[0]
def list_head(repo, cur):
- global g_head, bmarks
+ global g_head, bmarks, fake_bmark
- head = bookmarks.readcurrent(repo)
- if head:
- node = repo[head]
- else:
- # fake bookmark from current branch
- head = cur
- node = repo['.']
- if not node:
- node = repo['tip']
- if not node:
- return
- if head == 'default':
- head = 'master'
- bmarks[head] = node
+ if 'default' not in repo:
+ # empty repo
+ return
+
+ node = repo['default']
+ head = 'master' if not 'master' in bmarks else 'default'
+ fake_bmark = head
+ bmarks[head] = node
head = gitref(head)
print "@refs/heads/%s HEAD" % head
if old == new:
continue
- if bmark == 'master' and 'master' not in parser.repo._bookmarks:
- # fake bookmark
+ if bmark == fake_bmark or \
+ bmark == 'master' and 'master' not in parser.repo._bookmarks:
print "ok %s" % ref
continue
elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
global track_branches, force_push, is_tmp
global parsed_tags
global filenodes
+ global fake_bmark
alias = args[1]
url = args[2]
marks = None
parsed_tags = {}
filenodes = {}
+ fake_bmark = None
repo = get_repo(url, alias)
prefix = 'refs/hg/%s' % alias