Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eden/scm/edenscm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def clone(ui, url, destpath=None, update=True, pullnames=None):
# If `git ls-remote --symref <url> HEAD` failed to yield a name,
# fall back to the using the names in the config.
pullnames = bookmod.selectivepullbookmarknames(repo)
default_publicheads = repo.ui.configlist('remotenames', 'publicheads') # ['remote/master', 'remote/main']
remote_publicheads = ['remote/' + path for path in pullnames]
all_publicheads = ','.join(sorted(set(default_publicheads + remote_publicheads)))

repo.update_and_persist_config('remotenames', 'publicheads',
all_publicheads)

# Make sure we pull "update". If it looks like a hash, add to
# "nodes", otherwise to "names".
Expand Down
7 changes: 7 additions & 0 deletions eden/scm/edenscm/localrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
progress,
pushkey,
pycompat,
rcutil,
repository,
revset,
revsetlang,
Expand Down Expand Up @@ -3196,6 +3197,12 @@ def smallcommitmetadata(self):
def metalog(self):
return self.svfs.metalog

def update_and_persist_config(self, section, name, value):
"""edit config and save it to the repo's config file"""
configfilename = self.ui.identity.configrepofile() # config
configfilepath = self.localvfs.join(configfilename) # <reporoot>/.hg/config
rcutil.editconfig(self.ui, configfilepath, section, name, value)


# used to avoid circular references so destructors work
# This function is passed as the `after` function to `transaction`, and is
Expand Down
30 changes: 30 additions & 0 deletions eden/scm/tests/test-git-clone-sets-publicheads.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#debugruntest-compatible
#chg-compatible
#require git no-windows

$ . $TESTDIR/git.sh

Prepare a git repo:

$ git init -q gitrepo
$ cd gitrepo
$ git config core.autocrlf false
$ echo 1 > alpha
$ git add alpha
$ git commit -q -malpha

$ git switch -c foo
Switched to a new branch 'foo'

$ echo 2 > beta
$ git add beta
$ git commit -q -mbeta

Test git clone sets publicheads
$ hg clone --git "$TESTTMP/gitrepo" cloned
From $TESTTMP/gitrepo
* [new ref] 3f5848713286c67b8a71a450e98c7fa66787bde2 -> remote/foo
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd cloned
$ hg config remotenames.publicheads
remote/foo,remote/main,remote/master