comparison src/hgext3rd/hggit_serve/_export.py @ 20:84dfbee2ced6

Fix error messages and default branch handling in git export.
author Paul Fisher <paul@pfish.zone>
date Mon, 23 Feb 2026 17:12:20 -0500
parents 78ea1ec94be5
children
comparison
equal deleted inserted replaced
19:ba45dc4ed212 20:84dfbee2ced6
116 # Not a real bookmark. Assume we want the tip of the current branch. 116 # Not a real bookmark. Assume we want the tip of the current branch.
117 branch = repo.dirstate.branch() 117 branch = repo.dirstate.branch()
118 try: 118 try:
119 hgnode = repo.branchtip(branch) 119 hgnode = repo.branchtip(branch)
120 except hgerr.RepoLookupError: 120 except hgerr.RepoLookupError:
121 # This branch somehow doesn't exist??? 121 # The default branch may not exist.
122 ui.warn(f"{branch!r} doesn't seem to exist?".encode()) 122 if branch != b'default':
123 return 123 ui.warn(f"{branch!r} doesn't seem to exist?\n".encode())
124 return
125 hgnode = repo.changelog.tip()
124 hgsha = binascii.hexlify(hgnode) 126 hgsha = binascii.hexlify(hgnode)
125 gitsha = repo.githandler.map_git_get(hgsha) 127 gitsha = repo.githandler.map_git_get(hgsha)
126 if not gitsha: 128 if not gitsha:
127 # No Git SHA to match this Hg sha. Give up. 129 # No Git SHA to match this Hg sha. Give up.
128 ui.warn(f'revision {hgsha!r} was not exported to Git'.encode()) 130 ui.warn(f'revision {hgsha!r} was not exported to Git\n'.encode())
129 return 131 return
130 refs = repo.githandler.git.refs 132 refs = repo.githandler.git.refs
131 refs.add_packed_refs({git_branch: gitsha}) 133 refs.add_packed_refs({git_branch: gitsha})
132 refs.set_symbolic_ref(b'HEAD', git_branch) 134 refs.set_symbolic_ref(b'HEAD', git_branch)
133 135