bookmarks: refactor code responsible for updates of bookmarks
introduce _bookmarksupdate for common parts from commitctx and addchangegroup
hook: fix bug (reuse of variable) introduced in
872d49dd577a
For binary installs, the 'name' argument would be reused as a local variable,
destroying its original value. The patch fixes that, and also avoids copying
sys.path when it's not necessary.